Bug 1088179 - Convert touch caret code to using :-moz-native-anonymous so that it doesn't expose styles for magic attribute names to content. r=birtles
authorL. David Baron <dbaron@dbaron.org>
Thu, 23 Oct 2014 14:58:21 -0400
changeset 212065 efee5ba65af4e652d3371c9e9db29935d2ec642a
parent 212064 3a72e359110a92cada24fe8d4620433a7e3786f9
child 212066 95e70cc80f82529459f1f5e1e59bb698315ab6b5
push id27697
push usercbook@mozilla.com
push dateFri, 24 Oct 2014 13:48:53 +0000
treeherdermozilla-central@de805196bbc4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbirtles
bugs1088179, 1082899
milestone36.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 1088179 - Convert touch caret code to using :-moz-native-anonymous so that it doesn't expose styles for magic attribute names to content. r=birtles I tested locally on a Flame that using this without the ua.css changes breaks the touch caret (it doesn't appear), but with the ua.css changes the touch caret appears again. This was formerly bug 1082899 patch 6.
layout/generic/nsCanvasFrame.cpp
layout/style/ua.css
--- a/layout/generic/nsCanvasFrame.cpp
+++ b/layout/generic/nsCanvasFrame.cpp
@@ -71,46 +71,37 @@ nsCanvasFrame::CreateAnonymousContent(ns
                                                    nsIDOMNode::ELEMENT_NODE);
     NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
 
     rv = NS_NewHTMLElement(getter_AddRefs(mTouchCaretElement), nodeInfo.forget(),
                            mozilla::dom::NOT_FROM_PARSER);
     NS_ENSURE_SUCCESS(rv, rv);
     aElements.AppendElement(mTouchCaretElement);
 
-    // Add a _moz_anonclass attribute as touch caret selector.
-    mTouchCaretElement->SetAttribute(NS_LITERAL_STRING("_moz_anonclass"),
-                                     NS_LITERAL_STRING("mozTouchCaret"), er);
-    NS_ENSURE_SUCCESS(er.ErrorCode(), er.ErrorCode());
-
     // Set touch caret to visibility: hidden by default.
     nsAutoString classValue;
     classValue.AppendLiteral("moz-touchcaret hidden");
     rv = mTouchCaretElement->SetAttr(kNameSpaceID_None, nsGkAtoms::_class,
                                      classValue, true);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   if (PresShell::SelectionCaretPrefEnabled()) {
     // Selection caret
     mSelectionCaretsStartElement = doc->CreateHTMLElement(nsGkAtoms::div);
     aElements.AppendElement(mSelectionCaretsStartElement);
 
     mSelectionCaretsEndElement = doc->CreateHTMLElement(nsGkAtoms::div);
     aElements.AppendElement(mSelectionCaretsEndElement);
 
-    mSelectionCaretsStartElement->SetAttribute(NS_LITERAL_STRING("_moz_anonclass"),
-                                               NS_LITERAL_STRING("mozTouchCaret"), er);
     rv = mSelectionCaretsStartElement->SetAttr(kNameSpaceID_None, nsGkAtoms::_class,
                                                NS_LITERAL_STRING("moz-selectioncaret-left hidden"),
                                                true);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    mSelectionCaretsEndElement->SetAttribute(NS_LITERAL_STRING("_moz_anonclass"),
-                                             NS_LITERAL_STRING("mozTouchCaret"), er);
     rv = mSelectionCaretsEndElement->SetAttr(kNameSpaceID_None, nsGkAtoms::_class,
                                              NS_LITERAL_STRING("moz-selectioncaret-right hidden"),
                                              true);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   return NS_OK;
 }
--- a/layout/style/ua.css
+++ b/layout/style/ua.css
@@ -304,89 +304,89 @@ parsererror|sourcetext {
   font-family: -moz-fixed;
   margin-top: 2em;
   margin-bottom: 1em;
   color: red;
   font-weight: bold;
   font-size: 12pt;
 }
 
-div[\_moz_anonclass="mozTouchCaret"].moz-touchcaret,
-div[\_moz_anonclass="mozTouchCaret"].moz-selectioncaret-left,
-div[\_moz_anonclass="mozTouchCaret"].moz-selectioncaret-right {
+div:-moz-native-anonymous.moz-touchcaret,
+div:-moz-native-anonymous.moz-selectioncaret-left,
+div:-moz-native-anonymous.moz-selectioncaret-right {
   background-image: url("resource://gre/res/text_caret.png");
   position: absolute;
   width: 29px;
   height: 31px;
   margin-left: -15px;
   background-position: center center;
   background-size: 100% 100%;
   z-index: 2147483647;
 }
 
-div[\_moz_anonclass="mozTouchCaret"].moz-selectioncaret-left.tilt {
+div:-moz-native-anonymous.moz-selectioncaret-left.tilt {
   background-image: url("resource://gre/res/text_caret_tilt_left.png");
   margin-left: -29px;
   width: 29px;
 }
 
-div[\_moz_anonclass="mozTouchCaret"].moz-selectioncaret-right.tilt {
+div:-moz-native-anonymous.moz-selectioncaret-right.tilt {
   background-image: url("resource://gre/res/text_caret_tilt_right.png");
   margin-left: 0px;
   width: 29px;
 }
 
 @media (min-resolution: 1.5dppx) {
-  div[\_moz_anonclass="mozTouchCaret"].moz-touchcaret,
-  div[\_moz_anonclass="mozTouchCaret"].moz-selectioncaret-left,
-  div[\_moz_anonclass="mozTouchCaret"].moz-selectioncaret-right {
+  div:-moz-native-anonymous.moz-touchcaret,
+  div:-moz-native-anonymous.moz-selectioncaret-left,
+  div:-moz-native-anonymous.moz-selectioncaret-right {
     background-image: url("resource://gre/res/text_caret@1.5x.png");
   }
 
-  div[\_moz_anonclass="mozTouchCaret"].moz-selectioncaret-left.tilt {
+  div:-moz-native-anonymous.moz-selectioncaret-left.tilt {
     background-image: url("resource://gre/res/text_caret_tilt_left@1.5x.png");
   }
 
-  div[\_moz_anonclass="mozTouchCaret"].moz-selectioncaret-right.tilt {
+  div:-moz-native-anonymous.moz-selectioncaret-right.tilt {
     background-image: url("resource://gre/res/text_caret_tilt_right@1.5x.png");
   }
 }
 
 @media (min-resolution: 2dppx) {
-  div[\_moz_anonclass="mozTouchCaret"].moz-touchcaret,
-  div[\_moz_anonclass="mozTouchCaret"].moz-selectioncaret-left,
-  div[\_moz_anonclass="mozTouchCaret"].moz-selectioncaret-right {
+  div:-moz-native-anonymous.moz-touchcaret,
+  div:-moz-native-anonymous.moz-selectioncaret-left,
+  div:-moz-native-anonymous.moz-selectioncaret-right {
     background-image: url("resource://gre/res/text_caret@2x.png");
   }
 
-  div[\_moz_anonclass="mozTouchCaret"].moz-selectioncaret-left.tilt {
+  div:-moz-native-anonymous.moz-selectioncaret-left.tilt {
     background-image: url("resource://gre/res/text_caret_tilt_left@2x.png");
   }
 
-  div[\_moz_anonclass="mozTouchCaret"].moz-selectioncaret-right.tilt {
+  div:-moz-native-anonymous.moz-selectioncaret-right.tilt {
     background-image: url("resource://gre/res/text_caret_tilt_right@2x.png");
   }
 }
 
 @media (min-resolution: 2.25dppx) {
-  div[\_moz_anonclass="mozTouchCaret"].moz-touchcaret,
-  div[\_moz_anonclass="mozTouchCaret"].moz-selectioncaret-left,
-  div[\_moz_anonclass="mozTouchCaret"].moz-selectioncaret-right {
+  div:-moz-native-anonymous.moz-touchcaret,
+  div:-moz-native-anonymous.moz-selectioncaret-left,
+  div:-moz-native-anonymous.moz-selectioncaret-right {
     background-image: url("resource://gre/res/text_caret@2.25x.png");
   }
 
-  div[\_moz_anonclass="mozTouchCaret"].moz-selectioncaret-left.tilt {
+  div:-moz-native-anonymous.moz-selectioncaret-left.tilt {
     background-image: url("resource://gre/res/text_caret_tilt_left@2.25x.png");
   }
 
-  div[\_moz_anonclass="mozTouchCaret"].moz-selectioncaret-right.tilt {
+  div:-moz-native-anonymous.moz-selectioncaret-right.tilt {
     background-image: url("resource://gre/res/text_caret_tilt_right@2.25x.png");
   }
 }
 
-div[\_moz_anonclass="mozTouchCaret"].moz-touchcaret.hidden,
-div[\_moz_anonclass="mozTouchCaret"].moz-selectioncaret-left.hidden,
-div[\_moz_anonclass="mozTouchCaret"].moz-selectioncaret-right.hidden {
+div:-moz-native-anonymous.moz-touchcaret.hidden,
+div:-moz-native-anonymous.moz-selectioncaret-left.hidden,
+div:-moz-native-anonymous.moz-selectioncaret-right.hidden {
   width: 0px;
   height: 0px;
   margin: 0px;
   visibility: hidden;
 }