Bug 265894 - Part 1. Not allowing cross boundary style matching for elements in use-element shadow tree.
MozReview-Commit-ID: Fxb3F7SkwNl
--- a/layout/style/nsCSSRuleProcessor.cpp
+++ b/layout/style/nsCSSRuleProcessor.cpp
@@ -2416,16 +2416,21 @@ SelectorMatchesTree(Element* aPrevElemen
// for descendant combinators and child combinators, the element
// to test against is the parent
else {
nsIContent *content = prevElement->GetParent();
// GetParent could return a document fragment; we only want
// element parents.
if (content && content->IsElement()) {
element = content->AsElement();
+ // Do not cross the boundary of use-element shadow DOM.
+ if (element->IsSVGElement(nsGkAtoms::use) &&
+ aPrevElement->IsAnonymousContentInSVGUseSubtree()) {
+ return false;
+ }
if (aTreeMatchContext.mForScopedStyle) {
// We are moving up to the parent element; tell the
// TreeMatchContext, so that in case this element is the
// style scope element, selector matching stops before we
// traverse further up the tree.
aTreeMatchContext.PopStyleScopeForSelectorMatching(element);
}