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
--- 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;
}