Bug 265894 - Part 8. Implement -moz-use-shadow-tree-root pseudo class. draft
authorcku <cku@mozilla.com>
Wed, 14 Jun 2017 22:51:56 +0800
changeset 597168 71751d5a009cf53e49bf244741171eb2d2c8d28e
parent 597167 3a7894c061335d23e883ce6bfe9aa0d2765d51a2
child 597169 855e5ca287918978cf727c58466af829d2788750
push id64856
push userbmo:cku@mozilla.com
push dateTue, 20 Jun 2017 07:46:45 +0000
bugs265894
milestone56.0a1
Bug 265894 - Part 8. Implement -moz-use-shadow-tree-root pseudo class. The spec said: The generated instance of a ‘symbol’ that is the direct referenced element of a ‘use’ element must always have a computed value of inline for the display property. In other words, it must be rendered whenever the host ‘use’ element is rendered. We use -moz-use-shadow-tree-root pseudo class to achieve this requirement. MozReview-Commit-ID: 1ReJjmjxq6G
layout/style/nsCSSPseudoClassList.h
layout/style/nsCSSPseudoClasses.cpp
layout/svg/svg.css
--- a/layout/style/nsCSSPseudoClassList.h
+++ b/layout/style/nsCSSPseudoClassList.h
@@ -93,16 +93,19 @@ CSS_PSEUDO_CLASS(mozIsHTML, ":-moz-is-ht
  CSS_STATE_PSEUDO_CLASS(unresolved, ":unresolved", 0, "", NS_EVENT_STATE_UNRESOLVED)
 
 // Matches nodes that are in a native-anonymous subtree (i.e., nodes in
 // a subtree of C++ anonymous content constructed by Gecko for its own
 // purposes).
 CSS_PSEUDO_CLASS(mozNativeAnonymous, ":-moz-native-anonymous",
                  CSS_PSEUDO_CLASS_ENABLED_IN_UA_SHEETS, "")
 
+CSS_PSEUDO_CLASS(mozUseShadowTreeRoot, ":-moz-use-shadow-tree-root",
+                 CSS_PSEUDO_CLASS_ENABLED_IN_UA_SHEETS, "")
+
 // Matches anything when the specified look-and-feel metric is set
 CSS_PSEUDO_CLASS(mozSystemMetric, ":-moz-system-metric", 0, "")
 
 // -moz-locale-dir(ltr) and -moz-locale-dir(rtl) may be used
 // to match based on the locale's chrome direction
 CSS_PSEUDO_CLASS(mozLocaleDir, ":-moz-locale-dir", 0, "")
 
 // -moz-lwtheme may be used to match a document that has a lightweight theme
--- a/layout/style/nsCSSPseudoClasses.cpp
+++ b/layout/style/nsCSSPseudoClasses.cpp
@@ -134,16 +134,20 @@ nsCSSPseudoClasses::IsUserActionPseudoCl
 }
 
 /* static */ Maybe<bool>
 nsCSSPseudoClasses::MatchesElement(Type aType, const dom::Element* aElement)
 {
   switch (aType) {
     case CSSPseudoClassType::mozNativeAnonymous:
       return Some(aElement->IsInNativeAnonymousSubtree());
+    case CSSPseudoClassType::mozUseShadowTreeRoot:
+      return Some(aElement->IsRootOfAnonymousSubtree() &&
+                  aElement->GetParent() &&
+                  aElement->GetParent()->IsSVGElement(nsGkAtoms::use));
     case CSSPseudoClassType::mozTableBorderNonzero: {
       if (!aElement->IsHTMLElement(nsGkAtoms::table)) {
         return Some(false);
       }
       const nsAttrValue *val = aElement->GetParsedAttr(nsGkAtoms::border);
       return Some(val && (val->Type() != nsAttrValue::eInteger ||
                           val->GetIntegerValue() != 0));
     }
--- a/layout/svg/svg.css
+++ b/layout/svg/svg.css
@@ -6,16 +6,20 @@
 
 @namespace url(http://www.w3.org/2000/svg);
 @namespace xml url(http://www.w3.org/XML/1998/namespace);
 
 style, script, symbol {
  display: none;
 }
 
+symbol:-moz-use-shadow-tree-root {
+  display: inline !important;
+}
+
 switch {
  -moz-binding: none !important;
 }
 
 svg:not(:root), symbol, image, marker, pattern, foreignObject {
  overflow: hidden;
 }