Bug 1447476: Remove TreeMatchContext. r?xidorn draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Tue, 20 Mar 2018 19:34:44 +0100
changeset 770322 c43ba1ea661480cad0b2dc6d65796bc4acfbdb26
parent 770321 2344efe2fe27025475b7392efff8f9c719f59838
child 770323 90d70ffb067799835f7d156ef9c83a3e5b1e7a8a
child 770325 5b93c660daa6f27ca67457330c0e2409acbe244e
push id103377
push userbmo:emilio@crisal.io
push dateWed, 21 Mar 2018 00:02:10 +0000
reviewersxidorn
bugs1447476
milestone61.0a1
Bug 1447476: Remove TreeMatchContext. r?xidorn MozReview-Commit-ID: ETK0uGXytqb
layout/base/nsCSSFrameConstructor.cpp
layout/base/nsCSSFrameConstructor.h
layout/style/StyleSetHandle.h
layout/style/StyleSetHandleInlines.h
layout/style/moz.build
layout/style/nsRuleProcessorData.h
layout/style/nsTransitionManager.cpp
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -118,17 +118,16 @@
 
 #undef NOISY_FIRST_LETTER
 
 #include "nsMathMLParts.h"
 #include "mozilla/dom/SVGTests.h"
 #include "nsSVGUtils.h"
 
 #include "nsRefreshDriver.h"
-#include "nsRuleProcessorData.h"
 #include "nsTextNode.h"
 #include "ActiveLayerTracker.h"
 #include "nsIPresShellInlines.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 // An alias for convenience.
@@ -331,28 +330,16 @@ NS_NewScrollbarButtonFrame (nsIPresShell
 static int32_t FFWC_totalCount=0;
 static int32_t FFWC_doLoop=0;
 static int32_t FFWC_doSibling=0;
 static int32_t FFWC_recursions=0;
 static int32_t FFWC_nextInFlows=0;
 #endif
 
 
-// Define this dummy class so there are fewer call sites to change when the old
-// style system code is compiled out.
-class TreeMatchContextHolder
-{
-public:
-  explicit TreeMatchContextHolder(nsIDocument* aDocument) {}
-  bool Exists() const { return false; }
-  operator TreeMatchContext*() { return nullptr; }
-  TreeMatchContext* operator->() { MOZ_CRASH("old style system disabled"); }
-};
-
-
 // Returns true if aFrame is an anonymous flex/grid item.
 static inline bool
 IsAnonymousFlexOrGridItem(const nsIFrame* aFrame)
 {
   const nsAtom* pseudoType = aFrame->StyleContext()->GetPseudo();
   return pseudoType == nsCSSAnonBoxes::anonymousFlexItem ||
          pseudoType == nsCSSAnonBoxes::anonymousGridItem;
 }
@@ -835,45 +822,32 @@ public:
   // yet.  The mCreatingExtraFrames == true mode is meant to be used for
   // construction of random "extra" frames for elements via normal frame
   // construction APIs (e.g. replication of things across pages in paginated
   // mode).
   bool                      mCreatingExtraFrames;
 
   nsCOMArray<nsIContent>    mGeneratedTextNodesWithInitializer;
 
-  // Selector matching context for. This is null when we're using the Servo style
-  // system.
-  TreeMatchContext*         mTreeMatchContext;
-
   // Constructor
   // Use the passed-in history state.
-  //
-  // aTreeMatchContext is null when we're using the Servo style system.
   nsFrameConstructorState(
     nsIPresShell* aPresShell,
-    TreeMatchContext* aTreeMatchContext,
     nsContainerFrame* aFixedContainingBlock,
     nsContainerFrame* aAbsoluteContainingBlock,
     nsContainerFrame* aFloatContainingBlock,
     already_AddRefed<nsILayoutHistoryState> aHistoryState);
   // Get the history state from the pres context's pres shell.
   nsFrameConstructorState(nsIPresShell* aPresShell,
-                          TreeMatchContext* aTreeMatchContext,
                           nsContainerFrame* aFixedContainingBlock,
                           nsContainerFrame* aAbsoluteContainingBlock,
                           nsContainerFrame* aFloatContainingBlock);
 
   ~nsFrameConstructorState();
 
-  bool HasAncestorFilter()
-  {
-    return false;
-  }
-
   // Function to push the existing absolute containing block state and
   // create a new scope. Code that uses this function should get matching
   // logic in GetAbsoluteContainingBlock.
   // Also makes aNewAbsoluteContainingBlock the containing block for
   // fixed-pos elements if necessary.
   // aPositionedFrame is the frame whose style actually makes
   // aNewAbsoluteContainingBlock a containing block. E.g. for a scrollable element
   // aPositionedFrame is the element's primary frame and
@@ -1009,34 +983,18 @@ protected:
 
   // Our list of all pending bindings.  When we're done, we need to call
   // AddToAttachedQueue on all of them, in order.
   LinkedList<PendingBinding> mPendingBindings;
 
   PendingBinding* mCurrentPendingBindingInsertionPoint;
 };
 
-
-namespace mozilla {
-
-class AutoDisplayContentsAncestorPusher
-{
-public:
-  AutoDisplayContentsAncestorPusher(TreeMatchContext& aTreeMatchContext,
-                                    nsPresContext* aPresContext,
-                                    nsIContent* aParent) {}
-  bool IsEmpty() const { return false; }
-};
-
-} // namespace mozilla
-
-
 nsFrameConstructorState::nsFrameConstructorState(
   nsIPresShell* aPresShell,
-  TreeMatchContext* aTreeMatchContext,
   nsContainerFrame* aFixedContainingBlock,
   nsContainerFrame* aAbsoluteContainingBlock,
   nsContainerFrame* aFloatContainingBlock,
   already_AddRefed<nsILayoutHistoryState> aHistoryState)
   : mPresContext(aPresShell->GetPresContext()),
     mPresShell(aPresShell),
     mFrameManager(aPresShell->FrameConstructor()),
 #ifdef MOZ_XUL
@@ -1053,35 +1011,32 @@ nsFrameConstructorState::nsFrameConstruc
     mFrameState(aHistoryState),
     mAdditionalStateBits(nsFrameState(0)),
     // If the fixed-pos containing block is equal to the abs-pos containing
     // block, use the abs-pos containing block's abs-pos list for fixed-pos
     // frames.
     mFixedPosIsAbsPos(aFixedContainingBlock == aAbsoluteContainingBlock),
     mHavePendingPopupgroup(false),
     mCreatingExtraFrames(false),
-    mTreeMatchContext(aTreeMatchContext),
     mCurrentPendingBindingInsertionPoint(nullptr)
 {
 #ifdef MOZ_XUL
   nsIRootBox* rootBox = nsIRootBox::GetRootBox(aPresShell);
   if (rootBox) {
     mPopupItems.containingBlock = rootBox->GetPopupSetFrame();
   }
 #endif
   MOZ_COUNT_CTOR(nsFrameConstructorState);
 }
 
 nsFrameConstructorState::nsFrameConstructorState(nsIPresShell* aPresShell,
-                                                 TreeMatchContext* aTreeMatchContext,
                                                  nsContainerFrame* aFixedContainingBlock,
                                                  nsContainerFrame* aAbsoluteContainingBlock,
                                                  nsContainerFrame* aFloatContainingBlock)
   : nsFrameConstructorState(aPresShell,
-                            aTreeMatchContext,
                             aFixedContainingBlock,
                             aAbsoluteContainingBlock,
                             aFloatContainingBlock,
                             aPresShell->GetDocument()->GetLayoutHistoryState())
 {
 }
 
 nsFrameConstructorState::~nsFrameConstructorState()
@@ -1879,20 +1834,18 @@ nsCSSFrameConstructor::CreateGeneratedCo
              aPseudoElement == CSSPseudoElementType::after,
              "unexpected aPseudoElement");
 
   StyleSetHandle styleSet = mPresShell->StyleSet();
 
   // Probe for the existence of the pseudo-element
   RefPtr<nsStyleContext> pseudoStyleContext;
   pseudoStyleContext =
-    styleSet->ProbePseudoElementStyle(aParentContent,
-                                      aPseudoElement,
-                                      aStyleContext,
-                                      aState.mTreeMatchContext);
+    styleSet->ProbePseudoElementStyle(aParentContent, aPseudoElement,
+                                      aStyleContext);
   if (!pseudoStyleContext)
     return;
 
   bool isBefore = aPseudoElement == CSSPseudoElementType::before;
 
   // |ProbePseudoStyleFor| checked the 'display' property and the
   // |ContentCount()| of the 'content' property for us.
   RefPtr<NodeInfo> nodeInfo;
@@ -2473,25 +2426,17 @@ nsCSSFrameConstructor::ConstructDocEleme
   DebugOnly<nsIContent*> propagatedScrollFrom;
   if (nsPresContext* presContext = mPresShell->GetPresContext()) {
     propagatedScrollFrom = presContext->UpdateViewportScrollbarStylesOverride();
   }
 
   SetUpDocElementContainingBlock(aDocElement);
 
   NS_ASSERTION(mDocElementContainingBlock, "Should have parent by now");
-
-  TreeMatchContextHolder matchContext(mDocument);
-  // Initialize the ancestor filter with null for now; we'll push
-  // aDocElement once we finish resolving style for it.
-  if (matchContext.Exists()) {
-    matchContext->InitAncestors(nullptr);
-  }
   nsFrameConstructorState state(mPresShell,
-                                matchContext,
                                 GetAbsoluteContainingBlock(mDocElementContainingBlock, FIXED_POS),
                                 nullptr,
                                 nullptr, do_AddRef(aFrameState));
 
   // XXXbz why, exactly?
   if (!mTempFrameTreeState)
     state.mPresShell->CaptureHistoryState(getter_AddRefs(mTempFrameTreeState));
 
@@ -2568,19 +2513,16 @@ nsCSSFrameConstructor::ConstructDocEleme
                propagatedScrollFrom == aDocElement,
                "Scrollbars should have been propagated to the viewport");
 
   if (MOZ_UNLIKELY(display->mDisplay == StyleDisplay::None)) {
     RegisterDisplayNoneStyleFor(aDocElement, styleContext);
     return nullptr;
   }
 
-  TreeMatchContext::AutoAncestorPusher ancestorPusher(state.mTreeMatchContext);
-  ancestorPusher.PushAncestor(aDocElement);
-
   // Make sure to start any background image loads for the root element now.
   styleContext->StartBackgroundImageLoads();
 
   nsFrameConstructorSaveState docElementContainingBlockAbsoluteSaveState;
   if (mHasRootAbsPosContainingBlock) {
     // Push the absolute containing block now so we can absolutely position
     // the root element
     mDocElementContainingBlock->AddStateBits(NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN);
@@ -2924,18 +2866,17 @@ nsCSSFrameConstructor::SetUpDocElementCo
   // propagated
   NS_ASSERTION(!isScrollable || !isXUL,
                "XUL documents should never be scrollable - see above");
 
   nsContainerFrame* newFrame = rootFrame;
   RefPtr<nsStyleContext> rootPseudoStyle;
   // we must create a state because if the scrollbars are GFX it needs the
   // state to build the scrollbar frames.
-  TreeMatchContextHolder matchContext(mDocument);
-  nsFrameConstructorState state(mPresShell, matchContext, nullptr, nullptr, nullptr);
+  nsFrameConstructorState state(mPresShell, nullptr, nullptr, nullptr);
 
   // Start off with the viewport as parent; we'll adjust it as needed.
   nsContainerFrame* parentFrame = viewportFrame;
 
   StyleSetHandle styleSet = mPresShell->StyleSet();
   // If paginated, make sure we don't put scrollbars in
   if (!isScrollable) {
     rootPseudoStyle =
@@ -3935,55 +3876,16 @@ nsCSSFrameConstructor::ConstructFrameFro
   // Don't create a subdocument frame for iframes if we're creating extra frames
   if (aState.mCreatingExtraFrames &&
       aItem.mContent->IsHTMLElement(nsGkAtoms::iframe))
   {
     return;
   }
 
   nsIContent* const content = aItem.mContent;
-  nsIContent* parent = content->GetParent();
-
-  // Push display:contents ancestors.
-  Maybe<AutoDisplayContentsAncestorPusher> adcp;
-  if (aState.mTreeMatchContext) {
-    adcp.emplace(*aState.mTreeMatchContext, aState.mPresContext, parent);
-  } else {
-    MOZ_ASSERT(content->IsStyledByServo());
-  }
-
-  // Get the parent of the content and check if it is a XBL children element.
-  // Push the children element as an ancestor here because it does
-  // not have a frame and would not otherwise be pushed as an ancestor. It is
-  // necessary to do so in order to correctly handle style resolution on
-  // descendants.  (If !adcp.IsEmpty() then it was already pushed by
-  // AutoDisplayContentsAncestorPusher above.)
-  TreeMatchContext::AutoAncestorPusher
-    insertionPointPusher(aState.mTreeMatchContext);
-  if (adcp.isSome() && adcp->IsEmpty() && parent &&
-      parent->IsActiveChildrenElement()) {
-    if (aState.HasAncestorFilter()) {
-      insertionPointPusher.PushAncestor(parent);
-    }
-  }
-
-  // Push the content as a style ancestor now, so we don't have to do
-  // it in our various full-constructor functions.  In particular,
-  // since a number of full-constructor functions don't actually call
-  // ProcessChildren in some cases (e.g. for CSS anonymous table boxes
-  // or for situations where only anonymouse children are having
-  // frames constructed), this is the best place to bottleneck the
-  // pushing of the content instead of having to do it in multiple
-  // places.
-  TreeMatchContext::AutoAncestorPusher
-    ancestorPusher(aState.mTreeMatchContext);
-  if (aState.HasAncestorFilter()) {
-    ancestorPusher.PushAncestor(content);
-  }
-
   nsIFrame* newFrame;
   nsIFrame* primaryFrame;
   nsStyleContext* const styleContext = aItem.mStyleContext;
   const nsStyleDisplay* display = styleContext->StyleDisplay();
   if (bits & FCDATA_FUNC_IS_FULL_CTOR) {
     newFrame =
       (this->*(data->mFullConstructor))(aState, aItem, aParentFrame,
                                         display, aFrameItems);
@@ -4703,21 +4605,16 @@ nsCSSFrameConstructor::BeginBuildingScro
   //
   // We can't take the normal ProcessChildren path, because the NAC needs to
   // be parented to the scrollframe, and everything else needs to be parented
   // to the scrolledframe.
   AutoTArray<nsIAnonymousContentCreator::ContentInfo, 4> scrollNAC;
   DebugOnly<nsresult> rv = GetAnonymousContent(aContent, gfxScrollFrame, scrollNAC);
   MOZ_ASSERT(NS_SUCCEEDED(rv));
   if (scrollNAC.Length() > 0) {
-    TreeMatchContext::AutoAncestorPusher ancestorPusher(aState.mTreeMatchContext);
-    if (aState.HasAncestorFilter()) {
-      ancestorPusher.PushAncestor(aContent->AsElement());
-    }
-
     AutoFrameConstructionItemList items(this);
     AddFCItemsForAnonymousContent(aState, gfxScrollFrame, scrollNAC, items);
     ConstructFramesFromItemList(aState, items, gfxScrollFrame,
                                 /* aParentIsWrapperAnonBox = */ false,
                                 anonymousItems);
   }
 
   aNewFrame = gfxScrollFrame;
@@ -5127,20 +5024,19 @@ nsCSSFrameConstructor::InitAndRestoreFra
 
   if (aAllowCounters &&
       mCounterManager.AddCounterResetsAndIncrements(aNewFrame)) {
     CountersDirty();
   }
 }
 
 already_AddRefed<nsStyleContext>
-nsCSSFrameConstructor::ResolveStyleContext(nsIFrame*         aParentFrame,
-                                           nsIContent*       aContainer,
-                                           nsIContent*       aChild,
-                                           nsFrameConstructorState* aState)
+nsCSSFrameConstructor::ResolveStyleContext(nsIFrame* aParentFrame,
+                                           nsIContent* aContainer,
+                                           nsIContent* aChild)
 {
   MOZ_ASSERT(aContainer, "Must have parent here");
   // XXX uncomment when bug 1089223 is fixed:
   // MOZ_ASSERT(aContainer == aChild->GetFlattenedTreeParent());
   nsStyleContext* parentStyleContext = GetDisplayContentsStyleFor(aContainer);
   if (MOZ_LIKELY(!parentStyleContext)) {
     aParentFrame = nsFrame::CorrectStyleParentFrame(aParentFrame, nullptr);
     if (aParentFrame) {
@@ -5152,59 +5048,49 @@ nsCSSFrameConstructor::ResolveStyleConte
       // Perhaps aParentFrame is a canvasFrame and we're replicating
       // fixed-pos frames.
       // XXX should we create a way to tell ConstructFrame which style
       // context to use, and pass it the style context for the
       // previous page's fixed-pos frame?
     }
   }
 
-  return ResolveStyleContext(parentStyleContext, aChild, aState);
+  return ResolveStyleContext(parentStyleContext, aChild);
 }
 
 already_AddRefed<nsStyleContext>
-nsCSSFrameConstructor::ResolveStyleContext(nsIFrame*          aParentFrame,
-                                           nsIContent*              aChild,
-                                           nsFrameConstructorState* aState)
-{
-  return ResolveStyleContext(aParentFrame, aChild->GetFlattenedTreeParent(), aChild, aState);
+nsCSSFrameConstructor::ResolveStyleContext(nsIFrame* aParentFrame,
+                                           nsIContent* aChild)
+{
+  return ResolveStyleContext(aParentFrame, aChild->GetFlattenedTreeParent(), aChild);
 }
 
 already_AddRefed<nsStyleContext>
-nsCSSFrameConstructor::ResolveStyleContext(const InsertionPoint&    aInsertion,
-                                           nsIContent*              aChild,
-                                           nsFrameConstructorState* aState)
+nsCSSFrameConstructor::ResolveStyleContext(const InsertionPoint& aInsertion,
+                                           nsIContent* aChild)
 {
   return ResolveStyleContext(aInsertion.mParentFrame, aInsertion.mContainer,
-                             aChild, aState);
+                             aChild);
 }
 
 already_AddRefed<nsStyleContext>
 nsCSSFrameConstructor::ResolveStyleContext(nsStyleContext* aParentStyleContext,
                                            nsIContent* aContent,
-                                           nsFrameConstructorState* aState,
                                            Element* aOriginatingElementOrNull)
 {
   StyleSetHandle styleSet = mPresShell->StyleSet();
 
   RefPtr<nsStyleContext> result;
   if (aContent->IsElement()) {
     auto pseudoType = aContent->AsElement()->GetPseudoElementType();
     if (pseudoType == CSSPseudoElementType::NotPseudo) {
       MOZ_ASSERT(!aOriginatingElementOrNull);
-      if (aState) {
-        result = styleSet->ResolveStyleFor(aContent->AsElement(),
-                                           aParentStyleContext,
-                                           LazyComputeBehavior::Assert,
-                                           aState->mTreeMatchContext);
-      } else {
-        result = styleSet->ResolveStyleFor(aContent->AsElement(),
-                                           aParentStyleContext,
-                                           LazyComputeBehavior::Assert);
-      }
+      result = styleSet->ResolveStyleFor(aContent->AsElement(),
+                                         aParentStyleContext,
+                                         LazyComputeBehavior::Assert);
     } else {
       MOZ_ASSERT(aContent->IsInNativeAnonymousSubtree());
       if (!aOriginatingElementOrNull) {
         // For pseudo-implementing NAC created by JS using the ChromeOnly
         // document.createElement(..., { pseudo: ... }) API, we find the
         // originating element by lookup the tree until we find a non-NAC
         // ancestor.  (These are the correct semantics for C++-generated pseudo-
         // implementing NAC as well, but for those cases we already have a
@@ -5822,17 +5708,17 @@ nsCSSFrameConstructor::AddFrameConstruct
                                                  const InsertionPoint& aInsertion,
                                                  FrameConstructionItemList& aItems)
 {
   nsContainerFrame* parentFrame = aInsertion.mParentFrame;
   if (!ShouldCreateItemsForChild(aState, aContent, parentFrame)) {
     return;
   }
   RefPtr<nsStyleContext> styleContext =
-    ResolveStyleContext(aInsertion, aContent, &aState);
+    ResolveStyleContext(aInsertion, aContent);
   DoAddFrameConstructionItems(aState, aContent, styleContext,
                               aSuppressWhiteSpaceOptimizations, parentFrame,
                               nullptr, aItems);
 }
 
 void
 nsCSSFrameConstructor::SetAsUndisplayedContent(nsFrameConstructorState& aState,
                                                FrameConstructionItemList& aList,
@@ -6079,50 +5965,31 @@ nsCSSFrameConstructor::AddFrameConstruct
                  "Should have had pseudo type");
       aState.mFrameManager->RegisterDisplayContentsStyleFor(aContent,
                                                             styleContext);
     } else {
       aState.mFrameManager->ChangeRegisteredDisplayContentsStyleFor(aContent,
                                                                     styleContext);
     }
 
-    TreeMatchContext::AutoAncestorPusher ancestorPusher(aState.mTreeMatchContext);
-    if (aState.HasAncestorFilter()) {
-      ancestorPusher.PushAncestor(aContent->AsElement());
-    }
-
     if (aParentFrame) {
       aParentFrame->AddStateBits(NS_FRAME_MAY_HAVE_GENERATED_CONTENT);
     }
     CreateGeneratedContentItem(aState, aParentFrame, aContent->AsElement(),
                                styleContext, CSSPseudoElementType::before,
                                aItems);
 
     FlattenedChildIterator iter(aContent);
     for (nsIContent* child = iter.GetNextChild(); child; child = iter.GetNextChild()) {
       if (!ShouldCreateItemsForChild(aState, child, aParentFrame)) {
         continue;
       }
 
-      // Get the parent of the content and check if it is a XBL children element
-      // (if the content is a children element then parent != aContent because the
-      // FlattenedChildIterator will transitively iterate through <xbl:children>
-      // for default content). Push the children element as an ancestor here because
-      // it does not have a frame and would not otherwise be pushed as an ancestor.
-      nsIContent* parent = child->GetParent();
-      MOZ_ASSERT(parent, "Parent must be non-null because we are iterating children.");
-      TreeMatchContext::AutoAncestorPusher ancestorPusher(aState.mTreeMatchContext);
-      if (parent != aContent && parent->IsElement()) {
-        if (aState.HasAncestorFilter()) {
-          ancestorPusher.PushAncestor(parent->AsElement());
-        }
-      }
-
       RefPtr<nsStyleContext> childContext =
-        ResolveStyleContext(styleContext, child, &aState);
+        ResolveStyleContext(styleContext, child);
       DoAddFrameConstructionItems(aState, child, childContext,
                                   aSuppressWhiteSpaceOptimizations,
                                   aParentFrame, aAnonChildren, aItems);
     }
     aItems.SetParentHasNoXBLChildren(!iter.XBLInvolved());
 
     CreateGeneratedContentItem(aState, aParentFrame, aContent->AsElement(),
                                styleContext, CSSPseudoElementType::after,
@@ -6670,20 +6537,19 @@ nsCSSFrameConstructor::IsValidSibling(ns
         return false;
       }
       if (aContent->IsNodeOfType(nsINode::eCOMMENT) ||
           aContent->IsNodeOfType(nsINode::ePROCESSING_INSTRUCTION)) {
         // Comments and processing instructions never have frames, so we
         // should not try to generate style contexts for them.
         return false;
       }
-      // XXXbz when this code is killed, the state argument to
-      // ResolveStyleContext can be made non-optional.
+      // FIXME(emilio): This is buggy some times, see bug 1424656.
       RefPtr<nsStyleContext> styleContext =
-        ResolveStyleContext(styleParent, aContent, nullptr);
+        ResolveStyleContext(styleParent, aContent);
       const nsStyleDisplay* display = styleContext->StyleDisplay();
       aDisplay = display->mDisplay;
     }
     if (LayoutFrameType::Menu == parentType) {
       return
         (StyleDisplay::MozPopup == aDisplay) ==
         (StyleDisplay::MozPopup == siblingDisplay);
     }
@@ -7204,17 +7070,17 @@ nsCSSFrameConstructor::IssueSingleInsert
     // listboxes suck.
     MOZ_ASSERT(MaybeGetListBoxBodyFrame(aContainer, child) ||
                (!child->GetPrimaryFrame() &&
                 !GetDisplayNoneStyleFor(child) &&
                 !GetDisplayContentsStyleFor(child)));
 
     // Call ContentRangeInserted with this node.
     ContentRangeInserted(aContainer, child, child->GetNextSibling(),
-                         mTempFrameTreeState, InsertionKind::Sync, nullptr);
+                         mTempFrameTreeState, InsertionKind::Sync);
   }
 }
 
 bool
 nsCSSFrameConstructor::InsertionPoint::IsMultiple() const
 {
   if (!mParentFrame) {
     return false;
@@ -7340,21 +7206,18 @@ nsCSSFrameConstructor::StyleNewChildRang
       }
     }
   }
 }
 
 void
 nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer,
                                        nsIContent* aFirstNewContent,
-                                       InsertionKind aInsertionKind,
-                                       TreeMatchContext* aProvidedTreeMatchContext)
-{
-  MOZ_ASSERT(!aProvidedTreeMatchContext ||
-             aInsertionKind == InsertionKind::Sync);
+                                       InsertionKind aInsertionKind)
+{
   MOZ_ASSERT(aInsertionKind == InsertionKind::Sync ||
              !RestyleManager()->IsInStyleRefresh());
 
   AUTO_LAYOUT_PHASE_ENTRY_POINT(mPresShell->GetPresContext(), FrameC);
 
 #ifdef DEBUG
   if (gNoisyContentUpdates) {
     printf("nsCSSFrameConstructor::ContentAppended container=%p "
@@ -7511,28 +7374,17 @@ nsCSSFrameConstructor::ContentAppended(n
       if (nextSibling) {
         parentFrame = nextSibling->GetParent()->GetContentInsertionFrame();
         containingBlock = GetFloatContainingBlock(parentFrame);
       }
     }
   }
 
   // Create some new frames
-  //
-  // We use the provided tree match context, or create a new one on the fly
-  // otherwise.
-  Maybe<TreeMatchContext> matchContext;
-  if (!aProvidedTreeMatchContext && !aContainer->IsStyledByServo()) {
-    // We use GetParentElementCrossingShadowRoot to handle the case where
-    // aContainer is a ShadowRoot.
-    matchContext.emplace(mDocument, TreeMatchContext::ForFrameConstruction);
-    matchContext->InitAncestors(aFirstNewContent->GetParentElementCrossingShadowRoot());
-  }
   nsFrameConstructorState state(mPresShell,
-                                matchContext.ptrOr(aProvidedTreeMatchContext),
                                 GetAbsoluteContainingBlock(parentFrame, FIXED_POS),
                                 GetAbsoluteContainingBlock(parentFrame, ABS_POS),
                                 containingBlock);
 
   LayoutFrameType frameType = parentFrame->Type();
 
   FlattenedChildIterator iter(aContainer);
   const bool haveNoXBLChildren = !iter.XBLInvolved() || !iter.GetNextChild();
@@ -7741,21 +7593,18 @@ nsCSSFrameConstructor::ContentInserted(n
 // in the caption list, while skipping any nodes in the range being inserted
 // (because when we treat the caption frames the other nodes have had their
 // frames constructed but not yet inserted into the frame tree).
 void
 nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer,
                                             nsIContent* aStartChild,
                                             nsIContent* aEndChild,
                                             nsILayoutHistoryState* aFrameState,
-                                            InsertionKind aInsertionKind,
-                                            TreeMatchContext* aProvidedTreeMatchContext)
-{
-  MOZ_ASSERT(!aProvidedTreeMatchContext ||
-             aInsertionKind == InsertionKind::Sync);
+                                            InsertionKind aInsertionKind)
+{
   MOZ_ASSERT(aInsertionKind == InsertionKind::Sync ||
              !RestyleManager()->IsInStyleRefresh());
 
   AUTO_LAYOUT_PHASE_ENTRY_POINT(mPresShell->GetPresContext(), FrameC);
 
   NS_PRECONDITION(aStartChild, "must always pass a child");
 
 #ifdef DEBUG
@@ -7988,25 +7837,17 @@ nsCSSFrameConstructor::ContentRangeInser
   if (insertion.mParentFrame->IsFrameOfType(nsIFrame::eMathML)) {
     LAYOUT_PHASE_TEMP_EXIT();
     RecreateFramesForContent(insertion.mParentFrame->GetContent(),
                              InsertionKind::Async);
     LAYOUT_PHASE_TEMP_REENTER();
     return;
   }
 
-  Maybe<TreeMatchContext> matchContext;
-  if (!aProvidedTreeMatchContext && !aContainer->IsStyledByServo()) {
-    // We use GetParentElementCrossingShadowRoot to handle the case where
-    // aContainer is a ShadowRoot.
-    matchContext.emplace(mDocument, TreeMatchContext::ForFrameConstruction);
-    matchContext->InitAncestors(aStartChild->GetParentElementCrossingShadowRoot());
-  }
   nsFrameConstructorState state(mPresShell,
-                                matchContext.ptrOr(aProvidedTreeMatchContext),
                                 GetAbsoluteContainingBlock(insertion.mParentFrame, FIXED_POS),
                                 GetAbsoluteContainingBlock(insertion.mParentFrame, ABS_POS),
                                 GetFloatContainingBlock(insertion.mParentFrame),
                                 do_AddRef(aFrameState));
 
   // Recover state for the containing block - we need to know if
   // it has :first-letter or :first-line style applied to it. The
   // reason we care is that the internal structure in these cases
@@ -8818,19 +8659,17 @@ nsCSSFrameConstructor::CreateContinuingT
     if (rgNextInFlow) {
       rowGroupFrame->SetRepeatable(false);
     }
     else if (rowGroupFrame->IsRepeatable()) {
       // Replicate the header/footer frame.
       nsTableRowGroupFrame*   headerFooterFrame;
       nsFrameItems            childItems;
 
-      TreeMatchContextHolder matchContext(mDocument);
       nsFrameConstructorState state(mPresShell,
-                                    matchContext,
                                     GetAbsoluteContainingBlock(newFrame, FIXED_POS),
                                     GetAbsoluteContainingBlock(newFrame, ABS_POS),
                                     nullptr);
       state.mCreatingExtraFrames = true;
 
       nsStyleContext* const headerFooterStyleContext = rowGroupFrame->StyleContext();
       headerFooterFrame = static_cast<nsTableRowGroupFrame*>
                                      (NS_NewTableRowGroupFrame(aPresShell, headerFooterStyleContext));
@@ -9093,19 +8932,17 @@ nsCSSFrameConstructor::ReplicateFixedFra
   if (!firstFixed) {
     return NS_OK;
   }
 
   // Don't allow abs-pos descendants of the fixed content to escape the content.
   // This should not normally be possible (because fixed-pos elements should
   // be absolute containers) but fixed-pos tables currently aren't abs-pos
   // containers.
-  TreeMatchContextHolder matchContext(mDocument);
   nsFrameConstructorState state(mPresShell,
-                                matchContext,
                                 aParentFrame,
                                 nullptr,
                                 mRootElementFrame);
   state.mCreatingExtraFrames = true;
 
   // We can't use an ancestor filter here, because we're not going to
   // be usefully recurring down the tree.  This means that other
   // places in frame construction can't assume a filter is
@@ -9569,18 +9406,17 @@ nsCSSFrameConstructor::RecreateFramesFor
                                            nsRestyleHint(0),
                                            nsChangeHint_ReconstructFrame);
       } else {
         // Now, recreate the frames associated with this content object. If
         // ContentRemoved triggered reconstruction, then we don't need to do this
         // because the frames will already have been built.
         ContentRangeInserted(container, aContent, aContent->GetNextSibling(),
                              mTempFrameTreeState,
-                             aInsertionKind,
-                             nullptr);
+                             aInsertionKind);
       }
     }
   }
 }
 
 bool
 nsCSSFrameConstructor::DestroyFramesFor(Element* aElement)
 {
@@ -10559,24 +10395,16 @@ nsCSSFrameConstructor::AddFCItemsForAnon
                  (NODE_DESCENDANTS_NEED_FRAMES | NODE_NEEDS_FRAME)),
                "Should not be marked as needing frames");
     MOZ_ASSERT(!content->GetPrimaryFrame(),
                "Should have no existing frame");
     MOZ_ASSERT(!content->IsNodeOfType(nsINode::eCOMMENT) &&
                !content->IsNodeOfType(nsINode::ePROCESSING_INSTRUCTION),
                "Why is someone creating garbage anonymous content");
 
-    RefPtr<nsStyleContext> styleContext;
-    Maybe<TreeMatchContext::AutoParentDisplayBasedStyleFixupSkipper>
-      parentDisplayBasedStyleFixupSkipper;
-    MOZ_ASSERT(aState.mTreeMatchContext || content->IsStyledByServo());
-    if (aState.mTreeMatchContext) {
-      parentDisplayBasedStyleFixupSkipper.emplace(*aState.mTreeMatchContext);
-    }
-
     // Make sure we eagerly performed the servo cascade when the anonymous
     // nodes were created.
     MOZ_ASSERT(!content->IsStyledByServo() || !content->IsElement() ||
                content->AsElement()->HasServoData());
 
     // Determine whether this NAC is pseudo-implementing.
     nsAtom* pseudo = nullptr;
     if (content->IsElement()) {
@@ -10667,18 +10495,18 @@ nsCSSFrameConstructor::AddFCItemsForAnon
     MOZ_ASSERT(styleParentFrame || inheritFrame->IsCanvasFrame());
     // And that anonymous div has no pseudo.
     MOZ_ASSERT(styleParentFrame || !pseudo);
 
     Element* originating =
       pseudo ? styleParentFrame->GetContent()->AsElement() : nullptr;
     nsStyleContext* parentStyle =
       styleParentFrame ? styleParentFrame->StyleContext() : nullptr;
-    styleContext =
-      ResolveStyleContext(parentStyle, content, &aState, originating);
+    RefPtr<nsStyleContext> styleContext =
+      ResolveStyleContext(parentStyle, content, originating);
 
     nsTArray<nsIAnonymousContentCreator::ContentInfo>* anonChildren = nullptr;
     if (!aAnonymousItems[i].mChildren.IsEmpty()) {
       anonChildren = &aAnonymousItems[i].mChildren;
     }
 
     uint32_t flags = ITEM_ALLOW_XBL_BASE | ITEM_ALLOW_PAGE_BREAK |
                      ITEM_IS_ANONYMOUSCONTENTCREATOR_CONTENT | aExtraFlags;
@@ -10786,43 +10614,34 @@ nsCSSFrameConstructor::ProcessChildren(n
                                  itemsToConstruct);
     }
 
     const bool addChildItems = MOZ_LIKELY(mCurrentDepth < kMaxDepth);
     if (!addChildItems) {
       NS_WARNING("ProcessChildren max depth exceeded");
     }
 
-    // Don't blockify 'display' in ApplyStyleFixups unless aFrame really is
-    // a flex/grid container frame, not just has display:flex/grid.
-    Maybe<TreeMatchContext::AutoParentDisplayBasedStyleFixupSkipper>
-      parentDisplayBasedStyleFixupSkipper;
-    MOZ_ASSERT(aState.mTreeMatchContext || aContent->IsStyledByServo());
-    if (!isFlexOrGridContainer && aState.mTreeMatchContext) {
-      parentDisplayBasedStyleFixupSkipper.emplace(*aState.mTreeMatchContext);
-    }
-
     InsertionPoint insertion(aFrame, nullptr);
     FlattenedChildIterator iter(aContent);
     for (nsIContent* child = iter.GetNextChild(); child; child = iter.GetNextChild()) {
       // Get the parent of the content and check if it is a XBL children element
       // (if the content is a children element then parent != aContent because the
       // FlattenedChildIterator will transitively iterate through <xbl:children>
       // for default content). Push the children element as an ancestor here because
       // it does not have a frame and would not otherwise be pushed as an ancestor.
       insertion.mContainer = aContent;
+
+
+      // FIXME(emilio): This code can go away, child->GetFlattenedTreeParent()
+      // is always aContent, wtf.
       nsIContent* parent = child->GetParent();
       MOZ_ASSERT(parent, "Parent must be non-null because we are iterating children.");
-      TreeMatchContext::AutoAncestorPusher ancestorPusher(aState.mTreeMatchContext);
       if (parent != aContent && parent->IsElement()) {
         insertion.mContainer = child->GetFlattenedTreeParent();
         MOZ_ASSERT(insertion.mContainer == GetInsertionPoint(child).mContainer);
-        if (aState.HasAncestorFilter()) {
-          ancestorPusher.PushAncestor(parent->AsElement());
-        }
       }
 
       // Frame construction item construction should not post
       // restyles, so removing restyle flags here is safe.
       child->UnsetRestyleFlagsIfGecko();
       if (addChildItems) {
         AddFrameConstructionItems(aState, child, iter.XBLInvolved(), insertion,
                                   itemsToConstruct);
@@ -11260,19 +11079,17 @@ nsCSSFrameConstructor::CreateLetterFrame
     // frame.
     // XXXbz it would be really nice to destroy the old frame _first_,
     // then create the new one, so we could avoid this hack.
     aTextContent->SetPrimaryFrame(nullptr);
     nsIFrame* textFrame = NS_NewTextFrame(mPresShell, textSC);
 
     NS_ASSERTION(aBlockContinuation == GetFloatContainingBlock(aParentFrame),
                  "Containing block is confused");
-    TreeMatchContextHolder matchContext(mDocument);
     nsFrameConstructorState state(mPresShell,
-                                  matchContext,
                                   GetAbsoluteContainingBlock(aParentFrame, FIXED_POS),
                                   GetAbsoluteContainingBlock(aParentFrame, ABS_POS),
                                   aBlockContinuation);
 
     // Create the right type of first-letter frame
     const nsStyleDisplay* display = sc->StyleDisplay();
     nsFirstLetterFrame* letterFrame;
     if (display->IsFloatingStyle() &&
@@ -11647,31 +11464,29 @@ void
 nsCSSFrameConstructor::CreateListBoxContent(nsContainerFrame*      aParentFrame,
                                             nsIFrame*              aPrevFrame,
                                             nsIContent*            aChild,
                                             nsIFrame**             aNewFrame,
                                             bool                   aIsAppend)
 {
 #ifdef MOZ_XUL
   // Construct a new frame
-  if (nullptr != aParentFrame) {
+  if (aParentFrame) {
     nsFrameItems            frameItems;
-    TreeMatchContextHolder matchContext(mDocument);
     nsFrameConstructorState state(mPresShell,
-                                  matchContext,
                                   GetAbsoluteContainingBlock(aParentFrame, FIXED_POS),
                                   GetAbsoluteContainingBlock(aParentFrame, ABS_POS),
                                   GetFloatContainingBlock(aParentFrame),
                                   do_AddRef(mTempFrameTreeState));
 
     // If we ever initialize the ancestor filter on |state|, make sure
     // to push the right parent!
 
-    RefPtr<nsStyleContext> styleContext;
-    styleContext = ResolveStyleContext(aParentFrame, aChild, &state);
+    RefPtr<nsStyleContext> styleContext =
+      ResolveStyleContext(aParentFrame, aChild);
 
     // Pre-check for display "none" - only if we find that, do we create
     // any frame at all
     const nsStyleDisplay* display = styleContext->StyleDisplay();
 
     if (StyleDisplay::None == display->mDisplay) {
       *aNewFrame = nullptr;
       return;
@@ -11997,21 +11812,16 @@ nsCSSFrameConstructor::BuildInlineChildI
   // XXXbz should we preallocate aParentItem.mChildItems to some sane
   // length?  Maybe even to parentContent->GetChildCount()?
   nsFrameConstructorState::PendingBindingAutoPusher
     pusher(aState, aParentItem.mPendingBinding);
 
   nsStyleContext* const parentStyleContext = aParentItem.mStyleContext;
   nsIContent* const parentContent = aParentItem.mContent;
 
-  TreeMatchContext::AutoAncestorPusher ancestorPusher(aState.mTreeMatchContext);
-  if (aState.HasAncestorFilter()) {
-    ancestorPusher.PushAncestor(parentContent->AsElement());
-  }
-
   if (!aItemIsWithinSVGText) {
     // Probe for generated content before
     CreateGeneratedContentItem(aState, nullptr, parentContent->AsElement(),
                                parentStyleContext, CSSPseudoElementType::before,
                                aParentItem.mChildItems);
   }
 
   uint32_t flags = ITEM_ALLOW_XBL_BASE | ITEM_ALLOW_PAGE_BREAK;
@@ -12028,47 +11838,33 @@ nsCSSFrameConstructor::BuildInlineChildI
     // the children, and so that we won't try to construct grandchildren frame
     // constructor items before the frame is available for their parent.
     AddFCItemsForAnonymousContent(aState, nullptr, aParentItem.mAnonChildren,
                                   aParentItem.mChildItems, flags);
   } else {
     // Use the content tree child list:
     FlattenedChildIterator iter(parentContent);
     for (nsIContent* content = iter.GetNextChild(); content; content = iter.GetNextChild()) {
-      // Get the parent of the content and check if it is a XBL children element
-      // (if the content is a children element then contentParent != parentContent because the
-      // FlattenedChildIterator will transitively iterate through <xbl:children>
-      // for default content). Push the children element as an ancestor here because
-      // it does not have a frame and would not otherwise be pushed as an ancestor.
-      nsIContent* contentParent = content->GetParent();
-      MOZ_ASSERT(contentParent, "Parent must be non-null because we are iterating children.");
-      TreeMatchContext::AutoAncestorPusher insertionPointPusher(aState.mTreeMatchContext);
-      if (contentParent != parentContent && contentParent->IsElement()) {
-        if (aState.HasAncestorFilter()) {
-          insertionPointPusher.PushAncestor(contentParent->AsElement());
-        }
-      }
-
       // Manually check for comments/PIs, since we don't have a frame to pass to
       // AddFrameConstructionItems.  We know our parent is a non-replaced inline,
       // so there is no need to do the NeedFrameFor check.
       content->UnsetFlags(NODE_DESCENDANTS_NEED_FRAMES | NODE_NEEDS_FRAME);
       if (content->IsNodeOfType(nsINode::eCOMMENT) ||
           content->IsNodeOfType(nsINode::ePROCESSING_INSTRUCTION)) {
         continue;
       }
 
       // See comment explaining why we need to remove the "is possible
       // restyle root" flags in AddFrameConstructionItems.  But note
       // that we can remove all restyle flags, just like in
       // ProcessChildren and for the same reason.
       content->UnsetRestyleFlagsIfGecko();
 
       RefPtr<nsStyleContext> childContext =
-        ResolveStyleContext(parentStyleContext, content, &aState);
+        ResolveStyleContext(parentStyleContext, content);
 
       AddFrameConstructionItemsInternal(aState, content, nullptr,
                                         content->NodeInfo()->NameAtom(),
                                         content->GetNameSpaceID(),
                                         iter.XBLInvolved(), childContext,
                                         flags, nullptr,
                                         aParentItem.mChildItems);
     }
@@ -12521,18 +12317,17 @@ nsCSSFrameConstructor::ReframeContaining
 }
 
 void
 nsCSSFrameConstructor::GenerateChildFrames(nsContainerFrame* aFrame)
 {
   {
     nsAutoScriptBlocker scriptBlocker;
     nsFrameItems childItems;
-    TreeMatchContextHolder matchContext(mDocument);
-    nsFrameConstructorState state(mPresShell, matchContext, nullptr, nullptr, nullptr);
+    nsFrameConstructorState state(mPresShell, nullptr, nullptr, nullptr);
     // We don't have a parent frame with a pending binding constructor here,
     // so no need to worry about ordering of the kids' constructors with it.
     // Pass null for the PendingBinding.
     ProcessChildren(state, aFrame->GetContent(), aFrame->StyleContext(),
                     aFrame, false, childItems, false,
                     nullptr);
 
     aFrame->SetInitialChildList(kPrincipalList, childItems);
--- a/layout/base/nsCSSFrameConstructor.h
+++ b/layout/base/nsCSSFrameConstructor.h
@@ -242,50 +242,40 @@ public:
    * quicker by processing the content tree from top down the next time we call
    * CreateNeededFrames. (We do clear the bits when BindToTree is called on any
    * nsIContent; so any nodes added to the document will not have any lazy bits
    * set.)
    */
 
   // If aInsertionKind is Async then frame construction of the new children can
   // be done lazily.
-  //
-  // When constructing frames lazily, we can keep the tree match context in a
-  // much easier way than nsFrameConstructorState, and thus, we're allowed to
-  // provide a TreeMatchContext to avoid calling InitAncestors repeatedly deep
-  // in the DOM.
   void ContentAppended(nsIContent* aContainer,
                        nsIContent* aFirstNewContent,
-                       InsertionKind aInsertionKind,
-                       TreeMatchContext* aProvidedTreeMatchContext = nullptr);
+                       InsertionKind aInsertionKind);
 
   // If aInsertionkind is Async then frame construction of the new child
   // can be done lazily.
   void ContentInserted(nsIContent* aContainer,
                        nsIContent* aChild,
                        nsILayoutHistoryState* aFrameState,
                        InsertionKind aInsertionKind);
 
   // Like ContentInserted but handles inserting the children of aContainer in
   // the range [aStartChild, aEndChild).  aStartChild must be non-null.
   // aEndChild may be null to indicate the range includes all kids after
   // aStartChild.
   //
   // If aInsertionKind is Async then frame construction of the new children can
   // be done lazily. It is only allowed to be Async when inserting a single
   // node.
-  //
-  // See ContentAppended to see why we allow passing an already initialized
-  // TreeMatchContext.
   void ContentRangeInserted(nsIContent* aContainer,
                             nsIContent* aStartChild,
                             nsIContent* aEndChild,
                             nsILayoutHistoryState* aFrameState,
-                            InsertionKind aInsertionKind,
-                            TreeMatchContext* aProvidedTreeMatchContext = nullptr);
+                            InsertionKind aInsertionKind);
 
   enum RemoveFlags {
     REMOVE_CONTENT,
     REMOVE_FOR_RECONSTRUCTION,
   };
 
   /**
    * Recreate or destroy frames for aChild in aContainer.
@@ -394,36 +384,31 @@ private:
                                        nsContainerFrame*& aCanvasFrame);
 
   void InitAndRestoreFrame (const nsFrameConstructorState& aState,
                             nsIContent*                    aContent,
                             nsContainerFrame*              aParentFrame,
                             nsIFrame*                      aNewFrame,
                             bool                           aAllowCounters = true);
 
-  // aState can be null if not available; it's used as an optimization.
-  // XXXbz IsValidSibling is the only caller that doesn't pass a state here!
   already_AddRefed<nsStyleContext>
-  ResolveStyleContext(nsIFrame*                aParentFrame,
-                      nsIContent*              aContainer,
-                      nsIContent*              aChild,
-                      nsFrameConstructorState* aState);
+  ResolveStyleContext(nsIFrame* aParentFrame,
+                      nsIContent* aContainer,
+                      nsIContent* aChild);
+
   already_AddRefed<nsStyleContext>
-  ResolveStyleContext(nsIFrame*                aParentFrame,
-                      nsIContent*              aChild,
-                      nsFrameConstructorState* aState);
+  ResolveStyleContext(nsIFrame* aParentFrame, nsIContent* aChild);
+
   already_AddRefed<nsStyleContext>
-  ResolveStyleContext(const InsertionPoint&    aInsertion,
-                      nsIContent*              aChild,
-                      nsFrameConstructorState* aState);
+  ResolveStyleContext(const InsertionPoint& aInsertion, nsIContent* aChild);
+
   already_AddRefed<nsStyleContext>
-  ResolveStyleContext(nsStyleContext*          aParentStyleContext,
-                      nsIContent*              aContent,
-                      nsFrameConstructorState* aState,
-                      Element*                 aOriginatingElementOrNull = nullptr);
+  ResolveStyleContext(nsStyleContext* aParentStyleContext,
+                      nsIContent* aContent,
+                      Element* aOriginatingElementOrNull = nullptr);
 
   // Add the frame construction items for the given aContent and aParentFrame
   // to the list.  This might add more than one item in some rare cases.
   // If aSuppressWhiteSpaceOptimizations is true, optimizations that
   // may suppress the construction of white-space-only text frames
   // must be skipped for these items and items around them.
   void AddFrameConstructionItems(nsFrameConstructorState& aState,
                                  nsIContent*              aContent,
--- a/layout/style/StyleSetHandle.h
+++ b/layout/style/StyleSetHandle.h
@@ -25,17 +25,16 @@ struct nsFontFaceRuleContainer;
 class nsAtom;
 class nsICSSAnonBoxPseudo;
 class nsIContent;
 class nsIDocument;
 class nsStyleContext;
 class nsStyleSet;
 class nsPresContext;
 class gfxFontFeatureValueSet;
-struct TreeMatchContext;
 
 namespace mozilla {
 
 class CSSStyleSheet;
 class ServoStyleSet;
 namespace dom {
 class Element;
 class ShadowRoot;
@@ -112,23 +111,26 @@ public:
     inline void SetAuthorStyleDisabled(bool aStyleDisabled);
     inline void BeginUpdate();
     inline nsresult EndUpdate();
     inline already_AddRefed<nsStyleContext>
     ResolveStyleFor(dom::Element* aElement,
                     nsStyleContext* aParentContext,
                     LazyComputeBehavior aMayCompute);
     inline already_AddRefed<nsStyleContext>
-    ResolveStyleFor(dom::Element* aElement,
-                    nsStyleContext* aParentContext,
-                    LazyComputeBehavior aMayCompute,
-                    TreeMatchContext* aTreeMatchContext);
+    ResolveStyleFor(dom::Element* aElement, LazyComputeBehavior aMayCompute);
+
+    // TODO(emilio): This might be nicer (albeit a bit slower) if we just grab
+    // the style from the parent in ServoStyleSet.
+    //
+    // It may be faster if we account not having to pass it around in
+    // nsCSSFrameConstructor though.
     inline already_AddRefed<nsStyleContext>
-    ResolveStyleForText(nsIContent* aTextNode,
-                        nsStyleContext* aParentContext);
+    ResolveStyleForText(nsIContent* aTextNode, nsStyleContext* aParentContext);
+
     inline already_AddRefed<nsStyleContext>
     ResolveStyleForFirstLetterContinuation(nsStyleContext* aParentContext);
     inline already_AddRefed<nsStyleContext>
     ResolveStyleForPlaceholder();
     inline already_AddRefed<nsStyleContext>
     ResolvePseudoElementStyle(dom::Element* aParentElement,
                               mozilla::CSSPseudoElementType aType,
                               nsStyleContext* aParentContext,
@@ -170,19 +172,17 @@ public:
     inline void InvalidateStyleForCSSRuleChanges();
     inline nsRestyleHint MediumFeaturesChanged(mozilla::MediaFeatureChangeReason);
     inline already_AddRefed<nsStyleContext>
     ProbePseudoElementStyle(dom::Element* aParentElement,
                             mozilla::CSSPseudoElementType aType,
                             nsStyleContext* aParentContext);
     inline already_AddRefed<nsStyleContext>
     ProbePseudoElementStyle(dom::Element* aParentElement,
-                            mozilla::CSSPseudoElementType aType,
-                            nsStyleContext* aParentContext,
-                            TreeMatchContext* aTreeMatchContext);
+                            mozilla::CSSPseudoElementType aType);
     inline void RootStyleContextAdded();
     inline void RootStyleContextRemoved();
 
     inline bool AppendFontFaceRules(nsTArray<nsFontFaceRuleContainer>& aArray);
     inline nsCSSCounterStyleRule* CounterStyleRuleForName(nsAtom* aName);
     inline already_AddRefed<gfxFontFeatureValueSet> BuildFontFeatureValueSet();
 
     inline bool EnsureUniqueInnerOnCSSSheets();
--- a/layout/style/StyleSetHandleInlines.h
+++ b/layout/style/StyleSetHandleInlines.h
@@ -83,30 +83,16 @@ already_AddRefed<nsStyleContext>
 StyleSetHandle::Ptr::ResolveStyleFor(dom::Element* aElement,
                                      nsStyleContext* aParentContext,
                                      LazyComputeBehavior aMayCompute)
 {
   FORWARD_WITH_PARENT(ResolveStyleFor, aParentContext, (aElement, parent, aMayCompute));
 }
 
 already_AddRefed<nsStyleContext>
-StyleSetHandle::Ptr::ResolveStyleFor(dom::Element* aElement,
-                                     nsStyleContext* aParentContext,
-                                     LazyComputeBehavior aMayCompute,
-                                     TreeMatchContext* aTreeMatchContext)
-{
-  if (IsGecko()) {
-    MOZ_CRASH("old style system disabled");
-  }
-
-  auto* parent = aParentContext ? aParentContext->AsServo() : nullptr;
-  return AsServo()->ResolveStyleFor(aElement, parent, aMayCompute);
-}
-
-already_AddRefed<nsStyleContext>
 StyleSetHandle::Ptr::ResolveStyleForText(nsIContent* aTextNode,
                                          nsStyleContext* aParentContext)
 {
   FORWARD_WITH_PARENT(ResolveStyleForText, aParentContext, (aTextNode, parent));
 }
 
 already_AddRefed<nsStyleContext>
 StyleSetHandle::Ptr::ResolveStyleForPlaceholder()
@@ -290,30 +276,16 @@ StyleSetHandle::Ptr::InvalidateStyleForC
 already_AddRefed<nsStyleContext>
 StyleSetHandle::Ptr::ProbePseudoElementStyle(dom::Element* aParentElement,
                                              CSSPseudoElementType aType,
                                              nsStyleContext* aParentContext)
 {
   FORWARD_WITH_PARENT(ProbePseudoElementStyle, aParentContext, (aParentElement, aType, parent));
 }
 
-already_AddRefed<nsStyleContext>
-StyleSetHandle::Ptr::ProbePseudoElementStyle(dom::Element* aParentElement,
-                                             CSSPseudoElementType aType,
-                                             nsStyleContext* aParentContext,
-                                             TreeMatchContext* aTreeMatchContext)
-{
-  if (IsGecko()) {
-    MOZ_CRASH("old style system disabled");
-  }
-
-  auto* parent = aParentContext ? aParentContext->AsServo() : nullptr;
-  return AsServo()->ProbePseudoElementStyle(aParentElement, aType, parent);
-}
-
 void
 StyleSetHandle::Ptr::RootStyleContextAdded()
 {
   if (IsGecko()) {
     MOZ_CRASH("old style system disabled");
   }
 
   // Not needed.
--- a/layout/style/moz.build
+++ b/layout/style/moz.build
@@ -51,17 +51,16 @@ EXPORTS += [
     'nsCSSValue.h',
     'nsDOMCSSAttrDeclaration.h',
     'nsDOMCSSDeclaration.h',
     'nsDOMCSSRGBColor.h',
     'nsICSSDeclaration.h',
     'nsICSSLoaderObserver.h',
     'nsLayoutStylesheetCache.h',
     'nsMediaFeatures.h',
-    'nsRuleProcessorData.h',
     'nsStyleAutoArray.h',
     'nsStyleConsts.h',
     'nsStyleContext.h',
     'nsStyleContextInlines.h',
     'nsStyleCoord.h',
     'nsStyleStruct.h',
     'nsStyleStructFwd.h',
     'nsStyleStructInlines.h',
deleted file mode 100644
--- a/layout/style/nsRuleProcessorData.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/*
- * data structures passed to nsIStyleRuleProcessor methods (to pull loop
- * invariant computations out of the loop)
- */
-
-#ifndef nsRuleProcessorData_h_
-#define nsRuleProcessorData_h_
-
-
-// Define this dummy class so there are fewer call sites to change when the old
-// style system code is compiled out.
-struct TreeMatchContext
-{
-public:
-  class AutoAncestorPusher
-  {
-  public:
-    explicit AutoAncestorPusher(TreeMatchContext* aTreeMatchContext) {}
-    void PushAncestor(nsIContent* aContent) {}
-  };
-
-  class AutoParentDisplayBasedStyleFixupSkipper
-  {
-  public:
-    explicit AutoParentDisplayBasedStyleFixupSkipper(
-        TreeMatchContext& aTreeMatchContext,
-        bool aSkipParentDisplayBasedStyleFixup = true) {}
-  };
-
-  enum ForFrameConstructionTag { ForFrameConstruction };
-
-  TreeMatchContext(nsIDocument* aDocument, ForFrameConstructionTag) {}
-
-  void InitAncestors(mozilla::dom::Element* aElement) {}
-};
-
-
-#endif /* !defined(nsRuleProcessorData_h_) */
--- a/layout/style/nsTransitionManager.cpp
+++ b/layout/style/nsTransitionManager.cpp
@@ -11,17 +11,16 @@
 #include "mozilla/dom/CSSTransitionBinding.h"
 
 #include "nsIContent.h"
 #include "nsContentUtils.h"
 #include "nsStyleContext.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/TimeStamp.h"
 #include "nsRefreshDriver.h"
-#include "nsRuleProcessorData.h"
 #include "nsCSSPropertyIDSet.h"
 #include "mozilla/AnimationEventDispatcher.h"
 #include "mozilla/EffectCompositor.h"
 #include "mozilla/EffectSet.h"
 #include "mozilla/EventDispatcher.h"
 #include "mozilla/ServoBindings.h"
 #include "mozilla/StyleAnimationValue.h"
 #include "mozilla/dom/DocumentTimeline.h"