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.

--HG--
extra : transplant_source : %CA%60%B7%10%AD%01%14%92%98%28o%AA%BF%5E%8F%7BV%AA%24%D5
This commit is contained in:
L. David Baron 2014-10-23 14:58:21 -04:00
parent 4a7e5a8c86
commit 977efff305
2 changed files with 23 additions and 32 deletions

View File

@ -76,11 +76,6 @@ nsCanvasFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
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");
@ -97,15 +92,11 @@ nsCanvasFrame::CreateAnonymousContent(nsTArray<ContentInfo>& aElements)
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);

View File

@ -309,9 +309,9 @@ parsererror|sourcetext {
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;
@ -322,69 +322,69 @@ div[\_moz_anonclass="mozTouchCaret"].moz-selectioncaret-right {
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;