Bug 1364412: Simplify Servo_HasAuthorSpecifiedRules looking at the pseudo style. r?bholley draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 12 May 2017 17:51:32 +0200
changeset 578206 4093572f18d3eb812bd457774ceaeb32fddf2758
parent 578205 1f595ec2b2a260460296adaf3999da88c69af866
child 578207 cf25681a38d718d3bda464f7191de60441359aaa
push id58929
push userbmo:emilio+bugs@crisal.io
push dateTue, 16 May 2017 02:57:42 +0000
reviewersbholley
bugs1364412
milestone55.0a1
Bug 1364412: Simplify Servo_HasAuthorSpecifiedRules looking at the pseudo style. r?bholley MozReview-Commit-ID: HpV92ttZGJz Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
layout/base/nsPresContext.cpp
layout/style/ServoBindingList.h
layout/style/ServoStyleSet.cpp
layout/style/ServoStyleSet.h
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -2205,44 +2205,33 @@ nsPresContext::CountReflows(const char *
 void
 nsPresContext::UpdateIsChrome()
 {
   mIsChrome = mContainer &&
               nsIDocShellTreeItem::typeChrome == mContainer->ItemType();
 }
 
 bool
-nsPresContext::HasAuthorSpecifiedRules(const nsIFrame *aFrame,
-                                       uint32_t ruleTypeMask) const
+nsPresContext::HasAuthorSpecifiedRules(const nsIFrame* aFrame,
+                                       uint32_t aRuleTypeMask) const
 {
   if (mShell->StyleSet()->IsGecko()) {
     return
       nsRuleNode::HasAuthorSpecifiedRules(aFrame->StyleContext(),
-                                          ruleTypeMask,
+                                          aRuleTypeMask,
                                           UseDocumentColors());
-  } else {
-    Element *elem = aFrame->GetContent()->AsElement();
-    if (elem->IsNativeAnonymous()) {
-      elem = nsContentUtils::GetClosestNonNativeAnonymousAncestor(elem);
-    }
-    if (!elem->HasServoData()) {
-      return false;
-    }
-
-    nsIAtom *pseudoTag = aFrame->StyleContext()->GetPseudo();
-    RefPtr<RawServoRuleNode> ruleNode;
-    ruleNode = mShell->StyleSet()->AsServo()->ResolveRuleNode(elem, pseudoTag);
-    if (!ruleNode) {
-      return false;
-    }
-    return Servo_HasAuthorSpecifiedRules(ruleNode,
-                                         elem,
-                                         ruleTypeMask,
-                                         UseDocumentColors());
   }
+  Element* elem = aFrame->GetContent()->AsElement();
+
+  MOZ_ASSERT(elem->GetPseudoElementType() ==
+             aFrame->StyleContext()->GetPseudoType());
+  MOZ_ASSERT(elem->HasServoData());
+  return Servo_HasAuthorSpecifiedRules(elem,
+                                       aRuleTypeMask,
+                                       UseDocumentColors());
 }
 
 gfxUserFontSet*
 nsPresContext::GetUserFontSet(bool aFlushUserFontSet)
 {
   return mDocument->GetUserFontSet(aFlushUserFontSet);
 }
 
--- a/layout/style/ServoBindingList.h
+++ b/layout/style/ServoBindingList.h
@@ -380,21 +380,17 @@ SERVO_BINDING_FUNC(Servo_NoteExplicitHin
 SERVO_BINDING_FUNC(Servo_TakeChangeHint, nsChangeHint, RawGeckoElementBorrowed element)
 SERVO_BINDING_FUNC(Servo_ResolveStyle, ServoComputedValuesStrong,
                    RawGeckoElementBorrowed element,
                    RawServoStyleSetBorrowed set,
                    bool allow_stale)
 SERVO_BINDING_FUNC(Servo_ResolvePseudoStyle, ServoComputedValuesStrong,
                    RawGeckoElementBorrowed element, nsIAtom* pseudo_tag,
                    bool is_probe, RawServoStyleSetBorrowed set)
-SERVO_BINDING_FUNC(Servo_ResolveRuleNode, RawServoRuleNodeStrong,
-                   RawGeckoElementBorrowed element, nsIAtom* pseudo_tag,
-                   RawServoStyleSetBorrowed set)
 SERVO_BINDING_FUNC(Servo_HasAuthorSpecifiedRules, bool,
-                   RawServoRuleNodeBorrowed rule_node,
                    RawGeckoElementBorrowed element,
                    uint32_t rule_type_mask,
                    bool author_colors_allowed)
 
 // Resolves style for an element or pseudo-element without processing pending
 // restyles first. The Element and its ancestors may be unstyled, have pending
 // restyles, or be in a display:none subtree. Styles are cached when possible,
 // though caching is not possible within display:none subtrees, and the styles
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -555,23 +555,16 @@ ServoStyleSet::ResolveNonInheritingAnony
 
   RefPtr<nsStyleContext> retval =
     GetContext(computedValues.forget(), nullptr, aPseudoTag,
                CSSPseudoElementType::NonInheritingAnonBox, nullptr);
   cache = retval;
   return retval.forget();
 }
 
-already_AddRefed<RawServoRuleNode>
-ServoStyleSet::ResolveRuleNode(dom::Element *aElement, nsIAtom *aPseudoTag)
-{
-  MOZ_ASSERT(aElement);
-  return Servo_ResolveRuleNode(aElement, aPseudoTag, mRawSet.get()).Consume();
-}
-
 // manage the set of style sheets in the style set
 nsresult
 ServoStyleSet::AppendStyleSheet(SheetType aType,
                                 ServoStyleSheet* aSheet)
 {
   MOZ_ASSERT(aSheet);
   MOZ_ASSERT(aSheet->IsApplicable());
   MOZ_ASSERT(nsStyleSet::IsCSSSheetType(aType));
--- a/layout/style/ServoStyleSet.h
+++ b/layout/style/ServoStyleSet.h
@@ -191,20 +191,16 @@ public:
                                      nsStyleContext* aParentContext);
 
   // Get a style context for an anonymous box that does not inherit style from
   // anything.  aPseudoTag is the pseudo-tag to use and must be non-null.  It
   // must be an anon box, and must be a non-inheriting one.
   already_AddRefed<nsStyleContext>
   ResolveNonInheritingAnonymousBoxStyle(nsIAtom* aPseudoTag);
 
-  // Get the rule node for a (pseudo-)element, resolving it lazily if needed.
-  already_AddRefed<RawServoRuleNode>
-  ResolveRuleNode(dom::Element *aElement, nsIAtom *aPseudoTag);
-
   // manage the set of style sheets in the style set
   nsresult AppendStyleSheet(SheetType aType, ServoStyleSheet* aSheet);
   nsresult PrependStyleSheet(SheetType aType, ServoStyleSheet* aSheet);
   nsresult RemoveStyleSheet(SheetType aType, ServoStyleSheet* aSheet);
   nsresult ReplaceSheets(SheetType aType,
                          const nsTArray<RefPtr<ServoStyleSheet>>& aNewSheets);
   nsresult InsertStyleSheetBefore(SheetType aType,
                                   ServoStyleSheet* aNewSheet,