Bug 721136 - transform property serialization doesn't normalize case; r=dbaron
authorAryeh Gregor <ayg@aryeh.name>
Mon, 13 Feb 2012 16:23:15 -0500
changeset 86932 7c1f492fc1b193d5eba85c17a08fd35bb8a3c268
parent 86931 816cc4b14ff848fc92d9eb99a47d628231d63fb1
child 86933 e8d87ff90d0f7024659d29b167d92c7acfc6c511
push id22066
push usermak77@bonardo.net
push dateThu, 16 Feb 2012 10:45:58 +0000
treeherdermozilla-central@31fa580e684c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs721136
milestone13.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 721136 - transform property serialization doesn't normalize case; r=dbaron
layout/style/nsCSSParser.cpp
layout/style/test/Makefile.in
layout/style/test/test_bug721136.html
--- a/layout/style/nsCSSParser.cpp
+++ b/layout/style/nsCSSParser.cpp
@@ -7760,16 +7760,45 @@ CSSParserImpl::ParseSingleTransform(nsCS
   const PRInt32* variantMask;
   PRUint16 minElems, maxElems;
   nsCSSKeyword keyword = nsCSSKeywords::LookupKeyword(mToken.mIdent);
 
   if (!GetFunctionParseInformation(keyword,
                                    minElems, maxElems, variantMask, aIs3D))
     return false;
 
+  // Bug 721136: Normalize the identifier to lowercase, except that things
+  // like scaleX should have the last character capitalized.  This matches
+  // what other browsers do.
+  nsContentUtils::ASCIIToLower(mToken.mIdent);
+  switch (keyword) {
+    case eCSSKeyword_rotatex:
+    case eCSSKeyword_scalex:
+    case eCSSKeyword_skewx:
+    case eCSSKeyword_translatex:
+      mToken.mIdent.Replace(mToken.mIdent.Length() - 1, 1, PRUnichar('X'));
+      break;
+
+    case eCSSKeyword_rotatey:
+    case eCSSKeyword_scaley:
+    case eCSSKeyword_skewy:
+    case eCSSKeyword_translatey:
+      mToken.mIdent.Replace(mToken.mIdent.Length() - 1, 1, PRUnichar('Y'));
+      break;
+
+    case eCSSKeyword_rotatez:
+    case eCSSKeyword_scalez:
+    case eCSSKeyword_translatez:
+      mToken.mIdent.Replace(mToken.mIdent.Length() - 1, 1, PRUnichar('Z'));
+      break;
+
+    default:
+      break;
+  }
+
   return ParseFunction(mToken.mIdent, variantMask, minElems, maxElems, aValue);
 }
 
 /* Parses a -moz-transform property list by continuously reading in properties
  * and constructing a matrix from it.
  */
 bool CSSParserImpl::ParseMozTransform()
 {
--- a/layout/style/test/Makefile.in
+++ b/layout/style/test/Makefile.in
@@ -224,16 +224,17 @@ GARBAGE += css_properties.js
 		ccd-standards.html \
 		ccd.sjs \
 		visited-pref-iframe.html \
 		visited-lying-inner.html \
 		visited_image_loading.sjs \
 		visited_image_loading_frame.html \
 		visited_image_loading_frame_empty.html \
 		test_load_events_on_stylesheets.html \
+		test_bug721136.html \
 		$(NULL)
 
 _VISITED_REFTEST_FILES = \
 		$(shell find $(topsrcdir)/layout/reftests/css-visited/ -name '*.html' -o -name '*.xhtml') \
 		$(topsrcdir)/layout/reftests/svg/pseudo-classes-02.svg \
 		$(topsrcdir)/layout/reftests/svg/pseudo-classes-02-ref.svg \
 		$(topsrcdir)/layout/reftests/svg/as-image/lime100x100.svg \
 		$(topsrcdir)/layout/reftests/svg/as-image/svg-image-visited-1-helper.svg \
new file mode 100644
--- /dev/null
+++ b/layout/style/test/test_bug721136.html
@@ -0,0 +1,45 @@
+<!doctype html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=721136
+-->
+<title>Test for Bug 721136</title>
+<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=721136">Mozilla Bug 721136</a>
+<pre id="test">
+<script>
+[
+  [" mAtRiX(1, 2,3,4, 5,6 ) ", "matrix(1, 2, 3, 4, 5, 6)"],
+  [" mAtRiX3d( 1,2,3,0,4 ,5,6,0,7,8 , 9,0,10, 11,12,1 )  ",
+   "matrix3d(1, 2, 3, 0, 4, 5, 6, 0, 7, 8, 9, 0, 10, 11, 12, 1)"],
+  [" pErSpEcTiVe( 400Px ) ", "perspective(400px)"],
+  [" rOtAtE( 90dEg ) ", "rotate(90deg)"],
+  [" rOtAtE3d( 0,0 , 1 ,180DeG ) ", "rotate3d(0, 0, 1, 180deg)"],
+  [" rOtAtEx( 100GrAD ) ", "rotateX(100grad)"],
+  [" rOtAtEy( 1.57RaD ) ", "rotateY(1.57rad)"],
+  [" rOtAtEz( 0.25TuRn ) ", "rotateZ(0.25turn)"],
+  [" sCaLe( 2 ) ", "scale(2)"],
+  [" sCaLe( 2,3 ) ", "scale(2, 3)"],
+  [" sCaLe3D( 2,4 ,  -9 )  ", "scale3d(2, 4, -9)"],
+  [" sCaLeX( 2 ) ", "scaleX(2)"],
+  [" sCaLeY( 2 ) ", "scaleY(2)"],
+  [" sCaLeZ( 2 ) ", "scaleZ(2)"],
+  [" sKeW( 45dEg ) ", "skew(45deg)"],
+  [" sKeW( 45dEg,45DeG ) ", "skew(45deg, 45deg)"],
+  [" sKeWx( 45DeG ) ", "skewX(45deg)"],
+  [" sKeWy( 45DeG ) ", "skewY(45deg)"],
+  [" tRaNsLaTe( 1Px ) ", "translate(1px)"],
+  [" tRaNsLaTe( 1Px,3Pt ) ", "translate(1px, 3pt)"],
+  [" tRaNsLaTe3D( 21pX,-6pX , 4pX )  ", "translate3d(21px, -6px, 4px)"],
+  [" tRaNsLaTeX( 1pT ) ", "translateX(1pt)"],
+  [" tRaNsLaTeY( 1iN ) ", "translateY(1in)"],
+  [" tRaNsLaTeZ( 15.4pX ) ", "translateZ(15.4px)"],
+  ["tranSlatex( 16px )rotatez(-90deg)  rotate(100grad)\ttranslate3d(12pt, 0pc, 0.0em)",
+   "translateX(16px) rotateZ(-90deg) rotate(100grad) translate3d(12pt, 0pc, 0em)"],
+].forEach(function(arr) {
+  document.documentElement.style.MozTransform = arr[0];
+  is(document.documentElement.style.MozTransform, arr[1],
+    "incorrect serialization");
+});
+</script>
+</pre>