Bug 265894 - Part 1. Not allowing cross boundary style matching for elements in use-element shadow tree. draft
authorcku <cku@mozilla.com>
Mon, 05 Jun 2017 11:41:13 +0800
changeset 589583 34323728ac39e16e2d77ada09eabb56f083309c0
parent 586973 7b8937970f9ca85db88cb2496f2112175fd847c8
child 589584 19d35cf1c182cdfeacaa34231f882e18b88b3af3
push id62435
push userbmo:cku@mozilla.com
push dateTue, 06 Jun 2017 12:33:20 +0000
bugs265894
milestone55.0a1
Bug 265894 - Part 1. Not allowing cross boundary style matching for elements in use-element shadow tree. MozReview-Commit-ID: Fxb3F7SkwNl
layout/style/nsCSSRuleProcessor.cpp
--- 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);
         }