Bug 770058. InvalidateFrame doesn't need flags, we can just avoid calling ScheduleRepaint if we find any ancestor frame with a descendant that needs invalidation. r=mattwoodrow
authorRobert O'Callahan <robert@ocallahan.org>
Wed, 29 Aug 2012 17:48:44 +1200
changeset 112052 5f4c8635e87e4d9637a299600392311196b0a894
parent 112051 32c4a08f8e6ec61221fa4816e89d803c2adc4c64
child 112053 9366a70acb1d07ca4f8d5a902914089214f9566e
push idunknown
push userunknown
push dateunknown
reviewersmattwoodrow
bugs770058
milestone18.0a1
Bug 770058. InvalidateFrame doesn't need flags, we can just avoid calling ScheduleRepaint if we find any ancestor frame with a descendant that needs invalidation. r=mattwoodrow
layout/generic/nsFrame.cpp
layout/generic/nsIFrame.h
layout/tables/nsTableCellFrame.h
layout/tables/nsTableColFrame.cpp
layout/tables/nsTableColFrame.h
layout/tables/nsTableColGroupFrame.cpp
layout/tables/nsTableColGroupFrame.h
layout/tables/nsTableRowFrame.cpp
layout/tables/nsTableRowFrame.h
layout/tables/nsTableRowGroupFrame.cpp
layout/tables/nsTableRowGroupFrame.h
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -4746,35 +4746,34 @@ nsIFrame::GetTransformMatrix(const nsIFr
   int32_t scaleFactor = PresContext()->AppUnitsPerDevPixel();
   return gfx3DMatrix().Translation
     (NSAppUnitsToFloatPixels(delta.x, scaleFactor),
      NSAppUnitsToFloatPixels(delta.y, scaleFactor),
      0.0f);
 }
 
 void
-nsIFrame::InvalidateFrameSubtree(uint32_t aFlags)
-{
-  InvalidateFrame(aFlags);
+nsIFrame::InvalidateFrameSubtree()
+{
+  InvalidateFrame();
 
   if (HasAnyStateBits(NS_FRAME_ALL_DESCENDANTS_NEED_PAINT)) {
     return;
   }
 
   AddStateBits(NS_FRAME_ALL_DESCENDANTS_NEED_PAINT);
   
   nsAutoTArray<nsIFrame::ChildList,4> childListArray;
   GetCrossDocChildLists(&childListArray);
 
   nsIFrame::ChildListArrayIterator lists(childListArray);
   for (; !lists.IsDone(); lists.Next()) {
     nsFrameList::Enumerator childFrames(lists.CurrentList());
     for (; !childFrames.AtEnd(); childFrames.Next()) {
-      childFrames.get()->
-        InvalidateFrameSubtree(aFlags | INVALIDATE_DONT_SCHEDULE_PAINT);
+      childFrames.get()->InvalidateFrameSubtree();
     }
   }
 }
 
 void
 nsIFrame::ClearInvalidationStateBits()
 {
   if (HasAnyStateBits(NS_FRAME_DESCENDANT_NEEDS_PAINT)) {
@@ -4791,25 +4790,25 @@ nsIFrame::ClearInvalidationStateBits()
   }
 
   RemoveStateBits(NS_FRAME_NEEDS_PAINT | 
                   NS_FRAME_DESCENDANT_NEEDS_PAINT | 
                   NS_FRAME_ALL_DESCENDANTS_NEED_PAINT);
 }
 
 void
-nsIFrame::InvalidateFrame(uint32_t aFlags)
+nsIFrame::InvalidateFrame()
 {
   AddStateBits(NS_FRAME_NEEDS_PAINT);
   nsIFrame *parent = nsLayoutUtils::GetCrossDocParentFrame(this);
   while (parent && !parent->HasAnyStateBits(NS_FRAME_DESCENDANT_NEEDS_PAINT)) {
     parent->AddStateBits(NS_FRAME_DESCENDANT_NEEDS_PAINT);
     parent = nsLayoutUtils::GetCrossDocParentFrame(parent);
   }
-  if (!(aFlags & INVALIDATE_DONT_SCHEDULE_PAINT)) {
+  if (!parent) {
     SchedulePaint();
   }
 }
   
 bool 
 nsIFrame::IsInvalid() 
 {
   return HasAnyStateBits(NS_FRAME_NEEDS_PAINT);
@@ -8003,17 +8002,17 @@ nsFrame::SetParent(nsIFrame* aParent)
   } else {
     RemoveInPopupStateBitFromDescendants(this);
   }
   
   // If our new parent only has invalid children, then we just invalidate
   // ourselves too. This is probably faster than clearing the flag all
   // the way up the frame tree.
   if (aParent->HasAnyStateBits(NS_FRAME_ALL_DESCENDANTS_NEED_PAINT)) {
-    InvalidateFrame(INVALIDATE_DONT_SCHEDULE_PAINT);
+    InvalidateFrame();
   }
 }
 
 void
 nsFrame::InitBoxMetrics(bool aClear)
 {
   FrameProperties props = Properties();
   if (aClear) {
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -2168,36 +2168,31 @@ public:
    * nsChangeHint_UpdateOpacityLayer. We return true only if
    * a change in the transform or opacity has been recorded while layers have
    * been marked active for this frame.
    */
   bool AreLayersMarkedActive(nsChangeHint aChangeHint);
 
   /**
    * Marks all display items created by this frame as needing a repaint,
-   * and calls SchedulePaint() if requested.
+   * and calls SchedulePaint() if requested and one is not already pending.
    *
    * This includes all display items created by this frame, including
    * container types.
-   * @param aFlags INVALIDATE_DONT_SCHEDULE_PAINT: Don't call SchedulePaint()
-   * when invalidating.
    */
-  enum {
-    INVALIDATE_DONT_SCHEDULE_PAINT
-  };
-  virtual void InvalidateFrame(uint32_t aFlags = 0);
+  virtual void InvalidateFrame();
   
   /**
    * Calls InvalidateFrame() on all frames descendant frames (including
    * this one).
    * 
    * This function doesn't walk through placeholder frames to invalidate
    * the out-of-flow frames.
    */
-  void InvalidateFrameSubtree(uint32_t aFlags = 0);
+  void InvalidateFrameSubtree();
   
   /**
    * Checks if a frame has had InvalidateFrame() called on it since the
    * last paint.
    */
   bool IsInvalid();
  
   /**
--- a/layout/tables/nsTableCellFrame.h
+++ b/layout/tables/nsTableCellFrame.h
@@ -206,21 +206,21 @@ public:
                                nsPoint              aPt,
                                uint32_t             aFlags);
 
   void DecorateForSelection(nsRenderingContext& aRenderingContext,
                             nsPoint              aPt);
 
   virtual bool UpdateOverflow();
   
-  virtual void InvalidateFrame(uint32_t aFlags = 0)
+  virtual void InvalidateFrame()
   {
-    nsIFrame::InvalidateFrame(aFlags);
+    nsIFrame::InvalidateFrame();
     nsTableFrame *tableFrame = nsTableFrame::GetTableFrame(this);
-    tableFrame->InvalidateFrame(aFlags | INVALIDATE_DONT_SCHEDULE_PAINT);
+    tableFrame->InvalidateFrame();
   }
 
 protected:
   /** implement abstract method on nsContainerFrame */
   virtual int GetSkipSides() const;
 
   /**
    * GetBorderOverflow says how far the cell's own borders extend
--- a/layout/tables/nsTableColFrame.cpp
+++ b/layout/tables/nsTableColFrame.cpp
@@ -186,15 +186,15 @@ nsTableColFrame::GetFrameName(nsAString&
 
 nsSplittableType
 nsTableColFrame::GetSplittableType() const
 {
   return NS_FRAME_NOT_SPLITTABLE;
 }
 
 void
-nsTableColFrame::InvalidateFrame(uint32_t aFlags)
+nsTableColFrame::InvalidateFrame()
 {
-  nsIFrame::InvalidateFrame(aFlags);
+  nsIFrame::InvalidateFrame();
   nsTableFrame *tableFrame = nsTableFrame::GetTableFrame(this);
-  tableFrame->InvalidateFrame(aFlags | INVALIDATE_DONT_SCHEDULE_PAINT);
+  tableFrame->InvalidateFrame();
 }
 
--- a/layout/tables/nsTableColFrame.h
+++ b/layout/tables/nsTableColFrame.h
@@ -259,17 +259,17 @@ public:
   }
   void SetFinalWidth(nscoord aFinalWidth) {
     mFinalWidth = aFinalWidth;
   }
   nscoord GetFinalWidth() {
     return mFinalWidth;
   }
   
-  virtual void InvalidateFrame(uint32_t aFlags = 0);
+  virtual void InvalidateFrame();
 
 protected:
 
   nsTableColFrame(nsStyleContext* aContext);
   ~nsTableColFrame();
 
   nscoord mMinCoord;
   nscoord mPrefCoord;
--- a/layout/tables/nsTableColGroupFrame.cpp
+++ b/layout/tables/nsTableColGroupFrame.cpp
@@ -460,21 +460,21 @@ NS_IMPL_FRAMEARENA_HELPERS(nsTableColGro
 
 nsIAtom*
 nsTableColGroupFrame::GetType() const
 {
   return nsGkAtoms::tableColGroupFrame;
 }
   
 void 
-nsTableColGroupFrame::InvalidateFrame(uint32_t aFlags)
+nsTableColGroupFrame::InvalidateFrame()
 {
-  nsIFrame::InvalidateFrame(aFlags);
+  nsIFrame::InvalidateFrame();
   nsTableFrame *tableFrame = nsTableFrame::GetTableFrame(this);
-  tableFrame->InvalidateFrame(aFlags | INVALIDATE_DONT_SCHEDULE_PAINT);
+  tableFrame->InvalidateFrame();
 }
 
 #ifdef DEBUG
 NS_IMETHODIMP
 nsTableColGroupFrame::GetFrameName(nsAString& aResult) const
 {
   return MakeFrameName(NS_LITERAL_STRING("TableColGroup"), aResult);
 }
--- a/layout/tables/nsTableColGroupFrame.h
+++ b/layout/tables/nsTableColGroupFrame.h
@@ -192,17 +192,17 @@ public:
   void GetContinuousBCBorderWidth(nsMargin& aBorder);
   /**
    * Set full border widths before collapsing with cell borders
    * @param aForSide - side to set; only accepts top and bottom
    */
   void SetContinuousBCBorderWidth(uint8_t     aForSide,
                                   BCPixelSize aPixelValue);
   
-  virtual void InvalidateFrame(uint32_t aFlags = 0);
+  virtual void InvalidateFrame();
 
 protected:
   nsTableColGroupFrame(nsStyleContext* aContext);
 
   void InsertColsReflow(int32_t                   aColIndex,
                         const nsFrameList::Slice& aCols);
 
   /** implement abstract method on nsContainerFrame */
--- a/layout/tables/nsTableRowFrame.cpp
+++ b/layout/tables/nsTableRowFrame.cpp
@@ -1347,21 +1347,21 @@ void nsTableRowFrame::InitHasCellWithSty
       AddStateBits(NS_ROW_HAS_CELL_WITH_STYLE_HEIGHT);
       return;
     }
   }
   RemoveStateBits(NS_ROW_HAS_CELL_WITH_STYLE_HEIGHT);
 }
   
 void 
-nsTableRowFrame::InvalidateFrame(uint32_t aFlags)
+nsTableRowFrame::InvalidateFrame()
 {
-  nsIFrame::InvalidateFrame(aFlags);
+  nsIFrame::InvalidateFrame();
   nsTableFrame *tableFrame = nsTableFrame::GetTableFrame(this);
-  tableFrame->InvalidateFrame(aFlags | INVALIDATE_DONT_SCHEDULE_PAINT);
+  tableFrame->InvalidateFrame();
 }
 
 /* ----- global methods ----- */
 
 nsIFrame* 
 NS_NewTableRowFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
 {
   return new (aPresShell) nsTableRowFrame(aContext);
--- a/layout/tables/nsTableRowFrame.h
+++ b/layout/tables/nsTableRowFrame.h
@@ -219,17 +219,17 @@ public:
   nscoord GetOuterTopContBCBorderWidth();
   /**
    * Sets full border widths before collapsing with cell borders
    * @param aForSide - side to set; only accepts right, left, and top
    */
   void SetContinuousBCBorderWidth(uint8_t     aForSide,
                                   BCPixelSize aPixelValue);
 
-  virtual void InvalidateFrame(uint32_t aFlags = 0);
+  virtual void InvalidateFrame();
 
 #ifdef ACCESSIBILITY
   virtual already_AddRefed<Accessible> CreateAccessible() MOZ_OVERRIDE;
 #endif
 
 protected:
 
   /** protected constructor.
--- a/layout/tables/nsTableRowGroupFrame.cpp
+++ b/layout/tables/nsTableRowGroupFrame.cpp
@@ -1838,14 +1838,14 @@ nsTableRowGroupFrame::FrameCursorData::A
   nscoord overflowAbove = -overflowRect.y;
   nscoord overflowBelow = overflowRect.YMost() - aFrame->GetSize().height;
   mOverflowAbove = NS_MAX(mOverflowAbove, overflowAbove);
   mOverflowBelow = NS_MAX(mOverflowBelow, overflowBelow);
   return mFrames.AppendElement(aFrame) != nullptr;
 }
   
 void 
-nsTableRowGroupFrame::InvalidateFrame(uint32_t aFlags)
+nsTableRowGroupFrame::InvalidateFrame()
 {
-  nsIFrame::InvalidateFrame(aFlags);
+  nsIFrame::InvalidateFrame();
   nsTableFrame *tableFrame = nsTableFrame::GetTableFrame(this);
-  tableFrame->InvalidateFrame(aFlags | INVALIDATE_DONT_SCHEDULE_PAINT);
+  tableFrame->InvalidateFrame();
 }
--- a/layout/tables/nsTableRowGroupFrame.h
+++ b/layout/tables/nsTableRowGroupFrame.h
@@ -320,17 +320,17 @@ public:
    * form non-decreasing sequences (should always be true for table rows);
    * if this is violated, call ClearRowCursor(). If we return nullptr, then we
    * decided not to use a cursor or we already have one set up.
    */
   FrameCursorData* SetupRowCursor();
 
   virtual nsILineIterator* GetLineIterator() { return this; }
 
-  virtual void InvalidateFrame(uint32_t aFlags = 0);
+  virtual void InvalidateFrame();
 
 protected:
   nsTableRowGroupFrame(nsStyleContext* aContext);
 
   void InitChildReflowState(nsPresContext&     aPresContext, 
                             bool               aBorderCollapse,
                             nsHTMLReflowState& aReflowState);