Commit 8c5857d8 authored by L. David Baron's avatar L. David Baron
Browse files

Bug 1256500 - Root style contexts before calling ApplyStyleFixups. r=heycam

MozReview-Commit-ID: 8P4AyTCvhmW
parent d5bd282a
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -121,6 +121,16 @@ nsStyleContext::nsStyleContext(nsStyleContext* aParent,
  mRuleNode->AddRef();
  mRuleNode->SetUsedDirectly(); // before ApplyStyleFixups()!

  if (!mParent) {
    // Add as a root before ApplyStyleFixups, since ApplyStyleFixups
    // can trigger rule tree GC.
    nsStyleSet* styleSet =
      mRuleNode->PresContext()->PresShell()->StyleSet()->GetAsGecko();
    if (styleSet) {
      styleSet->AddStyleContextRoot(this);
    }
  }

  ApplyStyleFixups(aSkipParentDisplayBasedStyleFixup);

  #define eStyleStruct_LastItem (nsStyleStructID_Length - 1)
+10 −6
Original line number Diff line number Diff line
@@ -973,9 +973,6 @@ nsStyleSet::GetContext(nsStyleContext* aParentContext,
        NS_NewStyleContext(parentIfVisited, aPseudoTag, aPseudoType,
                           aVisitedRuleNode,
                           aFlags & eSkipParentDisplayBasedStyleFixup);
      if (!parentIfVisited) {
        mRoots.AppendElement(resultIfVisited);
      }
      resultIfVisited->SetIsStyleIfVisited();
      result->SetStyleIfVisited(resultIfVisited.forget());

@@ -983,9 +980,6 @@ nsStyleSet::GetContext(nsStyleContext* aParentContext,
        result->AddStyleBit(NS_STYLE_RELEVANT_LINK_VISITED);
      }
    }
    if (!aParentContext) {
      mRoots.AppendElement(result);
    }
  }
  else {
    NS_ASSERTION(result->GetPseudoType() == aPseudoType, "Unexpected type");
@@ -2224,6 +2218,16 @@ nsStyleSet::Shutdown()

static const uint32_t kGCInterval = 300;

// Notification that a style context with a null parent has been created.
void
nsStyleSet::AddStyleContextRoot(nsStyleContext* aStyleContext)
{
  // aStyleContext has not been fully initialized, but its parent and
  // rule node are correct.
  MOZ_ASSERT(!aStyleContext->GetParent());
  mRoots.AppendElement(aStyleContext);
}

void
nsStyleSet::NotifyStyleContextDestroyed(nsStyleContext* aStyleContext)
{
+5 −0
Original line number Diff line number Diff line
@@ -261,6 +261,11 @@ class nsStyleSet final
  // Free all of the data associated with this style set.
  void Shutdown();

  // Notification that a style context with a null parent has been created.
  // The argument is a style context that has not been fully initialized,
  // but its parent and rule node are correct.
  void AddStyleContextRoot(nsStyleContext* aStyleContext);

  // Notification that a style context is being destroyed.
  void NotifyStyleContextDestroyed(nsStyleContext* aStyleContext);