Bug 1397500 - Disable the ActiveElementUsesStyle optimization for stylo. r=emilio
authorBobby Holley <bobbyholley@gmail.com>
Wed, 06 Sep 2017 15:20:52 -0700
changeset 660403 7efa30ab3893c3eb67e99ca115200c7e403bf941
parent 660402 48ed0961198671541c2a91a6d6cdf18758a6ace0
child 660404 c6d22c5e19ab5bcbfadd012dc6f712839c613774
push id78390
push userbmo:emilio@crisal.io
push dateWed, 06 Sep 2017 23:04:15 +0000
reviewersemilio
bugs1397500
milestone57.0a1
Bug 1397500 - Disable the ActiveElementUsesStyle optimization for stylo. r=emilio MozReview-Commit-ID: 20aqaFv9fxE
gfx/layers/apz/util/ActiveElementManager.cpp
layout/base/GeckoRestyleManager.cpp
layout/style/ServoStyleSet.cpp
layout/style/ServoStyleSet.h
layout/style/StyleSetHandle.h
layout/style/StyleSetHandleInlines.h
--- a/gfx/layers/apz/util/ActiveElementManager.cpp
+++ b/gfx/layers/apz/util/ActiveElementManager.cpp
@@ -163,17 +163,23 @@ GetPresContextFor(nsIContent* aContent)
 
 static bool
 ElementHasActiveStyle(dom::Element* aElement)
 {
   nsPresContext* pc = GetPresContextFor(aElement);
   if (!pc) {
     return false;
   }
-  StyleSetHandle styleSet = pc->StyleSet();
+  nsStyleSet* styleSet = pc->StyleSet()->GetAsGecko();
+  if (!styleSet) {
+    // Bug 1397434 tracks making this optimization work for stylo.
+    AEM_LOG("Element %p uses Servo style backend, assuming dependence on active state\n", aElement);
+    return true;
+  }
+
   for (dom::Element* e = aElement; e; e = e->GetParentElement()) {
     if (styleSet->HasStateDependentStyle(e, NS_EVENT_STATE_ACTIVE)) {
       AEM_LOG("Element %p's style is dependent on the active state\n", e);
       return true;
     }
   }
   AEM_LOG("Element %p doesn't use active styles\n", aElement);
   return false;
--- a/layout/base/GeckoRestyleManager.cpp
+++ b/layout/base/GeckoRestyleManager.cpp
@@ -297,17 +297,17 @@ GeckoRestyleManager::ContentStateChanged
 
   // Assemble what we'll need to calculate the nsRestyleHint.
   nsIFrame* primaryFrame = aElement->GetPrimaryFrame();
   CSSPseudoElementType pseudoType = CSSPseudoElementType::NotPseudo;
   if (primaryFrame) {
     pseudoType = primaryFrame->StyleContext()->GetPseudoType();
   }
 
-  StyleSetHandle styleSet = PresContext()->StyleSet();
+  nsStyleSet* styleSet = PresContext()->StyleSet()->AsGecko();
   MOZ_ASSERT(styleSet);
 
   nsRestyleHint restyleHint;
   if (pseudoType >= CSSPseudoElementType::Count) {
     restyleHint = styleSet->HasStateDependentStyle(aElement, aStateMask);
   } else if (nsCSSPseudoElements::PseudoElementSupportsUserActionState(
                pseudoType)) {
     // If aElement is a pseudo-element, we want to check to see whether there
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -922,34 +922,16 @@ ServoStyleSet::ProbePseudoElementStyle(E
         content->ContentCount() == 0) {
       return nullptr;
     }
   }
 
   return computedValues.forget();
 }
 
-nsRestyleHint
-ServoStyleSet::HasStateDependentStyle(dom::Element* aElement,
-                                      EventStates aStateMask)
-{
-  NS_WARNING("stylo: HasStateDependentStyle always returns zero!");
-  return nsRestyleHint(0);
-}
-
-nsRestyleHint
-ServoStyleSet::HasStateDependentStyle(dom::Element* aElement,
-                                      CSSPseudoElementType aPseudoType,
-                                      dom::Element* aPseudoElement,
-                                      EventStates aStateMask)
-{
-  NS_WARNING("stylo: HasStateDependentStyle always returns zero!");
-  return nsRestyleHint(0);
-}
-
 bool
 ServoStyleSet::StyleDocument(ServoTraversalFlags aFlags)
 {
   nsIDocument* doc = mPresContext->Document();
   if (!doc->GetServoRestyleRoot()) {
     return false;
   }
 
--- a/layout/style/ServoStyleSet.h
+++ b/layout/style/ServoStyleSet.h
@@ -258,23 +258,16 @@ public:
   nsresult AddDocStyleSheet(ServoStyleSheet* aSheet, nsIDocument* aDocument);
 
   // check whether there is ::before/::after style for an element
   already_AddRefed<ServoStyleContext>
   ProbePseudoElementStyle(dom::Element* aOriginatingElement,
                           mozilla::CSSPseudoElementType aType,
                           ServoStyleContext* aParentContext);
 
-  // Test if style is dependent on content state
-  nsRestyleHint HasStateDependentStyle(dom::Element* aElement,
-                                       EventStates aStateMask);
-  nsRestyleHint HasStateDependentStyle(
-    dom::Element* aElement, mozilla::CSSPseudoElementType aPseudoType,
-    dom::Element* aPseudoElement, EventStates aStateMask);
-
   /**
    * Performs a Servo traversal to compute style for all dirty nodes in the
    * document.
    *
    * This will traverse all of the document's style roots (that is, its document
    * element, and the roots of the document-level native anonymous content).
    *
    * We specify |ForCSSRuleChanges| to try to update all CSS animations
--- a/layout/style/StyleSetHandle.h
+++ b/layout/style/StyleSetHandle.h
@@ -166,24 +166,16 @@ public:
     ProbePseudoElementStyle(dom::Element* aParentElement,
                             mozilla::CSSPseudoElementType aType,
                             nsStyleContext* aParentContext);
     inline already_AddRefed<nsStyleContext>
     ProbePseudoElementStyle(dom::Element* aParentElement,
                             mozilla::CSSPseudoElementType aType,
                             nsStyleContext* aParentContext,
                             TreeMatchContext* aTreeMatchContext);
-    inline nsRestyleHint HasStateDependentStyle(dom::Element* aElement,
-                                                EventStates aStateMask);
-    inline nsRestyleHint HasStateDependentStyle(
-        dom::Element* aElement,
-        mozilla::CSSPseudoElementType aPseudoType,
-        dom::Element* aPseudoElement,
-        EventStates aStateMask);
-
     inline void RootStyleContextAdded();
     inline void RootStyleContextRemoved();
 
     inline bool AppendFontFaceRules(nsTArray<nsFontFaceRuleContainer>& aArray);
     inline nsCSSCounterStyleRule* CounterStyleRuleForName(nsIAtom* aName);
     inline already_AddRefed<gfxFontFeatureValueSet> BuildFontFeatureValueSet();
 
     inline bool EnsureUniqueInnerOnCSSSheets();
--- a/layout/style/StyleSetHandleInlines.h
+++ b/layout/style/StyleSetHandleInlines.h
@@ -287,33 +287,16 @@ StyleSetHandle::Ptr::ProbePseudoElementS
     auto* parent = aParentContext ? aParentContext->AsGecko() : nullptr;
     return AsGecko()->ProbePseudoElementStyle(aParentElement, aType, parent,
                                               *aTreeMatchContext);
   }
   auto* parent = aParentContext ? aParentContext->AsServo() : nullptr;
   return AsServo()->ProbePseudoElementStyle(aParentElement, aType, parent);
 }
 
-nsRestyleHint
-StyleSetHandle::Ptr::HasStateDependentStyle(dom::Element* aElement,
-                                            EventStates aStateMask)
-{
-  FORWARD(HasStateDependentStyle, (aElement, aStateMask));
-}
-
-nsRestyleHint
-StyleSetHandle::Ptr::HasStateDependentStyle(dom::Element* aElement,
-                                            CSSPseudoElementType aPseudoType,
-                                            dom::Element* aPseudoElement,
-                                            EventStates aStateMask)
-{
-  FORWARD(HasStateDependentStyle, (aElement, aPseudoType, aPseudoElement,
-                                   aStateMask));
-}
-
 void
 StyleSetHandle::Ptr::RootStyleContextAdded()
 {
   if (IsGecko()) {
     AsGecko()->RootStyleContextAdded();
   } else {
     // Not needed.
   }