Bug 1261343 - Implement text-transform: rot13. r?dbaron draft
authorXidorn Quan <quanxunzhen@gmail.com>
Sat, 02 Apr 2016 00:00:01 +1100
changeset 346566 6cf3bf34b057a3dd43395bf707e417a52445cd25
parent 346552 538d248fa252a4100082fd9bc3fdc08d322cda22
child 517480 346b0789da6aaa52c6c4fd479b7104faefe3e5a0
push id14416
push userquanxunzhen@gmail.com
push dateFri, 01 Apr 2016 13:01:01 +0000
reviewersdbaron
bugs1261343
milestone48.0a1
Bug 1261343 - Implement text-transform: rot13. r?dbaron MozReview-Commit-ID: JIeFjIhcx9t
layout/generic/nsTextRunTransformations.cpp
layout/reftests/w3c-css/submitted/text3/reftest.list
layout/reftests/w3c-css/submitted/text3/text-transform-rot13-001-ref.html
layout/reftests/w3c-css/submitted/text3/text-transform-rot13-001.html
layout/style/nsCSSKeywordList.h
layout/style/nsCSSProps.cpp
layout/style/nsStyleConsts.h
--- a/layout/generic/nsTextRunTransformations.cpp
+++ b/layout/generic/nsTextRunTransformations.cpp
@@ -551,16 +551,26 @@ nsCaseTransformTextRunFactory::Transform
         }
       }
       break;
 
     case NS_STYLE_TEXT_TRANSFORM_FULLWIDTH:
       ch = mozilla::unicode::GetFullWidth(ch);
       break;
 
+    case NS_STYLE_TEXT_TRANSFORM_ROT13:
+      if ((ch >= 'A' && ch <= 'M') ||
+          (ch >= 'a' && ch <= 'm')) {
+        ch += 13;
+      } else if ((ch >= 'N' && ch <= 'Z') ||
+                 (ch >= 'n' && ch <= 'z')) {
+        ch -= 13;
+      }
+      break;
+
     default:
       break;
     }
 
     if (ch == uint32_t(-1)) {
       aDeletedCharsArray.AppendElement(true);
       mergeNeeded = true;
     } else {
--- a/layout/reftests/w3c-css/submitted/text3/reftest.list
+++ b/layout/reftests/w3c-css/submitted/text3/reftest.list
@@ -1,8 +1,10 @@
 == text-align-match-parent-01.html text-align-match-parent-ref.html
 == text-align-match-parent-02.html text-align-match-parent-ref.html
 == text-align-match-parent-03.html text-align-match-parent-ref.html
 == text-align-match-parent-04.html text-align-match-parent-ref.html
 == text-align-match-parent-root-ltr.html text-align-match-parent-root-ltr-ref.html
 == text-align-match-parent-root-rtl.html text-align-match-parent-root-rtl-ref.html
 
 == text-word-spacing-001.html text-word-spacing-ref.html
+
+== text-transform-rot13-001.html text-transform-rot13-001-ref.html
new file mode 100644
--- /dev/null
+++ b/layout/reftests/w3c-css/submitted/text3/text-transform-rot13-001-ref.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="UTF-8">
+  <title>CSS Reference: text-transform: rot13</title>
+</head>
+<body>
+  <p>Test passes if the following sentence doesn't make sense to you, assuming you are not a cryptanalyst:</p>
+  <p>Gur dhvpx oebja sbk whzcf bire gur ynml qbt.</p>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/w3c-css/submitted/text3/text-transform-rot13-001.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="UTF-8">
+  <title>CSS Text: text-transform: rot13</title>
+  <link rel="author" title="Xidorn Quan" href="https://www.upsuper.org/">
+  <link rel="help" href="https://drafts.csswg.org/css-text-3/#valdef-text-transform-rot13">
+  <link rel="match" href="text-transform-rot13-001-ref.html">
+</head>
+<body>
+  <p>Test passes if the following sentence doesn't make sense to you, assuming you are not a cryptanalyst:</p>
+  <p style="text-transform: rot13">The quick brown fox jumps over the lazy dog.</p>
+</body>
+</html>
--- a/layout/style/nsCSSKeywordList.h
+++ b/layout/style/nsCSSKeywordList.h
@@ -456,16 +456,17 @@ CSS_KEY(relative, relative)
 CSS_KEY(repeat, repeat)
 CSS_KEY(repeat-x, repeat_x)
 CSS_KEY(repeat-y, repeat_y)
 CSS_KEY(reverse, reverse)
 CSS_KEY(ridge, ridge)
 CSS_KEY(right, right)
 CSS_KEY(rl, rl)
 CSS_KEY(rl-tb, rl_tb)
+CSS_KEY(rot13, rot13)
 CSS_KEY(rotate, rotate)
 CSS_KEY(rotate3d, rotate3d)
 CSS_KEY(rotatex, rotatex)
 CSS_KEY(rotatey, rotatey)
 CSS_KEY(rotatez, rotatez)
 CSS_KEY(round, round)
 CSS_KEY(row, row)
 CSS_KEY(row-resize, row_resize)
--- a/layout/style/nsCSSProps.cpp
+++ b/layout/style/nsCSSProps.cpp
@@ -2040,16 +2040,17 @@ const KTableEntry nsCSSProps::kTextOverf
 };
 
 const KTableEntry nsCSSProps::kTextTransformKTable[] = {
   { eCSSKeyword_none, NS_STYLE_TEXT_TRANSFORM_NONE },
   { eCSSKeyword_capitalize, NS_STYLE_TEXT_TRANSFORM_CAPITALIZE },
   { eCSSKeyword_lowercase, NS_STYLE_TEXT_TRANSFORM_LOWERCASE },
   { eCSSKeyword_uppercase, NS_STYLE_TEXT_TRANSFORM_UPPERCASE },
   { eCSSKeyword_full_width, NS_STYLE_TEXT_TRANSFORM_FULLWIDTH },
+  { eCSSKeyword_rot13, NS_STYLE_TEXT_TRANSFORM_ROT13 },
   { eCSSKeyword_UNKNOWN, -1 }
 };
 
 const KTableEntry nsCSSProps::kTouchActionKTable[] = {
   { eCSSKeyword_none,         NS_STYLE_TOUCH_ACTION_NONE },
   { eCSSKeyword_auto,         NS_STYLE_TOUCH_ACTION_AUTO },
   { eCSSKeyword_pan_x,        NS_STYLE_TOUCH_ACTION_PAN_X },
   { eCSSKeyword_pan_y,        NS_STYLE_TOUCH_ACTION_PAN_Y },
--- a/layout/style/nsStyleConsts.h
+++ b/layout/style/nsStyleConsts.h
@@ -843,16 +843,17 @@ enum class FillMode : uint32_t;
 #define NS_STYLE_TEXT_OVERFLOW_STRING   2
 
 // See nsStyleText
 #define NS_STYLE_TEXT_TRANSFORM_NONE            0
 #define NS_STYLE_TEXT_TRANSFORM_CAPITALIZE      1
 #define NS_STYLE_TEXT_TRANSFORM_LOWERCASE       2
 #define NS_STYLE_TEXT_TRANSFORM_UPPERCASE       3
 #define NS_STYLE_TEXT_TRANSFORM_FULLWIDTH       4
+#define NS_STYLE_TEXT_TRANSFORM_ROT13           5
 
 // See nsStyleDisplay
 #define NS_STYLE_TOUCH_ACTION_NONE            (1 << 0)
 #define NS_STYLE_TOUCH_ACTION_AUTO            (1 << 1)
 #define NS_STYLE_TOUCH_ACTION_PAN_X           (1 << 2)
 #define NS_STYLE_TOUCH_ACTION_PAN_Y           (1 << 3)
 #define NS_STYLE_TOUCH_ACTION_MANIPULATION    (1 << 4)