Bug 1115691 patch 1 - Store counts of frames constructed and reflowed on the pres context. r=roc
authorL. David Baron <dbaron@dbaron.org>
Sun, 11 Jan 2015 15:43:10 -0800
changeset 248994 d1510c5deff9c9972fda8edfebaac493d3ea5635
parent 248993 5c772b35c40dd6d6d3966f7f3f02c2d9032acaae
child 248995 9fe58932c19292f5df92507aa611db1506ea51d5
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1115691, 1110277
milestone37.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 1115691 patch 1 - Store counts of frames constructed and reflowed on the pres context. r=roc (I've tested the frame construction counts in my test for bug 1110277; I haven't actually tested the reflow counts.)
layout/base/nsPresContext.h
layout/generic/nsFrame.cpp
--- a/layout/base/nsPresContext.h
+++ b/layout/base/nsPresContext.h
@@ -816,16 +816,30 @@ public:
   */
   bool EnsureVisible();
 
 #ifdef MOZ_REFLOW_PERF
   void CountReflows(const char * aName,
                                 nsIFrame * aFrame);
 #endif
 
+  void ConstructedFrame() {
+    ++mFramesConstructed;
+  }
+  void ReflowedFrame() {
+    ++mFramesReflowed;
+  }
+
+  uint64_t FramesConstructedCount() {
+    return mFramesConstructed;
+  }
+  uint64_t FramesReflowedCount() {
+    return mFramesReflowed;
+  }
+
   /**
    * This table maps border-width enums 'thin', 'medium', 'thick'
    * to actual nscoord values.
    */
   const nscoord* GetBorderWidthTable() { return mBorderWidthTable; }
 
   gfxTextPerfMetrics *GetTextPerfMetrics() { return mTextPerf; }
 
@@ -1284,16 +1298,21 @@ protected:
   uint16_t              mImageAnimationModePref;
 
   LangGroupFontPrefs    mLangGroupFontPrefs;
 
   nscoord               mBorderWidthTable[3];
 
   uint32_t              mInterruptChecksToSkip;
 
+  // Counters for tests and tools that want to detect frame construction
+  // or reflow.
+  uint64_t              mFramesConstructed;
+  uint64_t              mFramesReflowed;
+
   mozilla::TimeStamp    mReflowStartTime;
 
   // last time we did a full style flush
   mozilla::TimeStamp    mLastStyleUpdateForAllAnimations;
 
   unsigned              mHasPendingInterrupt : 1;
   unsigned              mInterruptsEnabled : 1;
   unsigned              mUseDocumentFonts : 1;
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -533,16 +533,18 @@ nsFrame::Init(nsIContent*       aContent
     nsFrameState state = aPrevInFlow->GetStateBits();
 
     // Make bits that are currently off (see constructor) the same:
     mState |= state & (NS_FRAME_INDEPENDENT_SELECTION |
                        NS_FRAME_PART_OF_IBSPLIT |
                        NS_FRAME_MAY_BE_TRANSFORMED |
                        NS_FRAME_MAY_HAVE_GENERATED_CONTENT |
                        NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN);
+  } else {
+    PresContext()->ConstructedFrame();
   }
   if (GetParent()) {
     nsFrameState state = GetParent()->GetStateBits();
 
     // Make bits that are currently off (see constructor) the same:
     mState |= state & (NS_FRAME_INDEPENDENT_SELECTION |
                        NS_FRAME_GENERATED_CONTENT |
                        NS_FRAME_IS_SVG_TEXT |
@@ -4427,16 +4429,18 @@ nsFrame::DidReflow(nsPresContext*       
   // height but can fabricate one when the cell height is known.
   if (aReflowState && aReflowState->mPercentHeightObserver &&
       !GetPrevInFlow()) {
     const nsStyleCoord &height = aReflowState->mStylePosition->mHeight;
     if (height.HasPercent()) {
       aReflowState->mPercentHeightObserver->NotifyPercentHeight(*aReflowState);
     }
   }
+
+  aPresContext->ReflowedFrame();
 }
 
 void
 nsFrame::FinishReflowWithAbsoluteFrames(nsPresContext*           aPresContext,
                                         nsHTMLReflowMetrics&     aDesiredSize,
                                         const nsHTMLReflowState& aReflowState,
                                         nsReflowStatus&          aStatus,
                                         bool                     aConstrainHeight)