Bug 1367209 part 3 - Add a generic frame state bit, NS_FRAME_HAS_CSS_COUNTERS, to indicate that a frame maybe has some counter styles and thus be known by nsCounterManager. r=jfkthame
authorMats Palmgren <mats@mozilla.com>
Sun, 04 Jun 2017 16:45:15 +0200
changeset 410358 1b9d1468f7b4c1eb9b40fb19137f252bb113aff4
parent 410357 fbfa99d9a737838a1b0811b46d3656643f71dbf4
child 410359 22108a33acd5ce6ecbf0ca5f696a01591c5c0ca1
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs1367209
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1367209 part 3 - Add a generic frame state bit, NS_FRAME_HAS_CSS_COUNTERS, to indicate that a frame maybe has some counter styles and thus be known by nsCounterManager. r=jfkthame If a frame doesn't have that bit then skip mCounterManager.DestroyNodesFor() when the frame is destroyed because it's definitely not known by the CounterManager. MozReview-Commit-ID: Ky3575QvZME
layout/base/nsCSSFrameConstructor.cpp
layout/base/nsCounterManager.cpp
layout/generic/nsFrameStateBits.h
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -1648,17 +1648,18 @@ nsCSSFrameConstructor::NotifyDestroyingF
   NS_PRECONDITION(mUpdateCount != 0,
                   "Should be in an update while destroying frames");
 
   if (aFrame->GetStateBits() & NS_FRAME_GENERATED_CONTENT) {
     if (mQuoteList.DestroyNodesFor(aFrame))
       QuotesDirty();
   }
 
-  if (mCounterManager.DestroyNodesFor(aFrame)) {
+  if (aFrame->HasAnyStateBits(NS_FRAME_HAS_CSS_COUNTER_STYLE) &&
+      mCounterManager.DestroyNodesFor(aFrame)) {
     // Technically we don't need to update anything if we destroyed only
     // USE nodes.  However, this is unlikely to happen in the real world
     // since USE nodes generally go along with INCREMENT nodes.
     CountersDirty();
   }
 
   RestyleManager()->NotifyDestroyingFrame(aFrame);
 
--- a/layout/base/nsCounterManager.cpp
+++ b/layout/base/nsCounterManager.cpp
@@ -20,16 +20,17 @@ bool
 nsCounterUseNode::InitTextFrame(nsGenConList* aList,
                                 nsIFrame* aPseudoFrame,
                                 nsIFrame* aTextFrame)
 {
   nsCounterNode::InitTextFrame(aList, aPseudoFrame, aTextFrame);
 
   nsCounterList* counterList = static_cast<nsCounterList*>(aList);
   counterList->Insert(this);
+  aPseudoFrame->AddStateBits(NS_FRAME_HAS_CSS_COUNTER_STYLE);
   bool dirty = counterList->IsDirty();
   if (!dirty) {
     if (counterList->IsLast(this)) {
       Calc(counterList);
       nsAutoString contentString;
       GetText(contentString);
       aTextFrame->GetContent()->SetText(contentString, false);
     } else {
@@ -183,19 +184,22 @@ nsCounterList::RecalcAll()
 }
 
 bool
 nsCounterManager::AddCounterResetsAndIncrements(nsIFrame* aFrame)
 {
   const nsStyleContent* styleContent = aFrame->StyleContent();
   if (!styleContent->CounterIncrementCount() &&
       !styleContent->CounterResetCount()) {
+    MOZ_ASSERT(!aFrame->HasAnyStateBits(NS_FRAME_HAS_CSS_COUNTER_STYLE));
     return false;
   }
 
+  aFrame->AddStateBits(NS_FRAME_HAS_CSS_COUNTER_STYLE);
+
   // Add in order, resets first, so all the comparisons will be optimized
   // for addition at the end of the list.
   int32_t i, i_end;
   bool dirty = false;
   for (i = 0, i_end = styleContent->CounterResetCount(); i != i_end; ++i) {
     dirty |= AddResetOrIncrement(aFrame, i, styleContent->CounterResetAt(i),
                                  nsCounterChangeNode::RESET);
   }
@@ -261,16 +265,18 @@ nsCounterManager::SetAllDirty()
   for (auto iter = mNames.Iter(); !iter.Done(); iter.Next()) {
     iter.UserData()->SetDirty();
   }
 }
 
 bool
 nsCounterManager::DestroyNodesFor(nsIFrame* aFrame)
 {
+  MOZ_ASSERT(aFrame->HasAnyStateBits(NS_FRAME_HAS_CSS_COUNTER_STYLE),
+             "why call me?");
   bool destroyedAny = false;
   for (auto iter = mNames.Iter(); !iter.Done(); iter.Next()) {
     nsCounterList* list = iter.UserData();
     if (list->DestroyNodesFor(aFrame)) {
       destroyedAny = true;
       list->SetDirty();
     }
   }
--- a/layout/generic/nsFrameStateBits.h
+++ b/layout/generic/nsFrameStateBits.h
@@ -265,18 +265,18 @@ FRAME_STATE_BIT(Generic, 53, NS_FRAME_IS
 
 // Frame has a LayerActivityProperty property
 FRAME_STATE_BIT(Generic, 54, NS_FRAME_HAS_LAYER_ACTIVITY_PROPERTY)
 
 // Frame owns anonymous boxes whose style contexts it will need to update during
 // a stylo tree traversal.
 FRAME_STATE_BIT(Generic, 55, NS_FRAME_OWNS_ANON_BOXES)
 
-// ** currently unused Generic bit **
-// FRAME_STATE_BIT(Generic, 56, ...)
+// Frame maybe has a counter-reset/increment style
+FRAME_STATE_BIT(Generic, 56, NS_FRAME_HAS_CSS_COUNTER_STYLE)
 
 // The display list of the frame can be handled by the shortcut for
 // COMMON CASE.
 FRAME_STATE_BIT(Generic, 57, NS_FRAME_SIMPLE_DISPLAYLIST)
 
 // Set for all descendants of MathML sub/supscript elements (other than the
 // base frame) to indicate that the SSTY font feature should be used.
 FRAME_STATE_BIT(Generic, 58, NS_FRAME_MATHML_SCRIPT_DESCENDANT)