Bug 826817. Part 3: Remove will-send-did-paint flag from nsIWidgetListener::WillPaintWindow. r=tnikkel
authorRobert O'Callahan <robert@ocallahan.org>
Mon, 28 Jan 2013 13:34:08 -0600
changeset 120098 198516229e54c72e59544bf08bad7ab65a411af4
parent 120097 dbd2536c95b386af1e2de26a26a9e0f786521455
child 120099 f4b4392eb8a151f8dd1e6f4d3d716817a90ce0fd
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewerstnikkel
bugs826817
milestone21.0a1
Bug 826817. Part 3: Remove will-send-did-paint flag from nsIWidgetListener::WillPaintWindow. r=tnikkel
view/public/nsView.h
view/public/nsViewManager.h
view/src/nsView.cpp
view/src/nsViewManager.cpp
widget/android/nsWindow.cpp
widget/cocoa/nsChildView.mm
widget/gonk/nsWindow.cpp
widget/gtk2/nsWindow.cpp
widget/nsIWidgetListener.h
widget/qt/nsWindow.cpp
widget/windows/nsWindowGfx.cpp
widget/xpwidgets/PuppetWidget.cpp
--- a/view/public/nsView.h
+++ b/view/public/nsView.h
@@ -375,17 +375,17 @@ public:
   }
 
   // nsIWidgetListener
   virtual nsIPresShell* GetPresShell() MOZ_OVERRIDE;
   virtual nsView* GetView() MOZ_OVERRIDE { return this; }
   virtual bool WindowMoved(nsIWidget* aWidget, int32_t x, int32_t y) MOZ_OVERRIDE;
   virtual bool WindowResized(nsIWidget* aWidget, int32_t aWidth, int32_t aHeight) MOZ_OVERRIDE;
   virtual bool RequestWindowClose(nsIWidget* aWidget) MOZ_OVERRIDE;
-  virtual void WillPaintWindow(nsIWidget* aWidget, bool aWillSendDidPaint) MOZ_OVERRIDE;
+  virtual void WillPaintWindow(nsIWidget* aWidget) MOZ_OVERRIDE;
   virtual bool PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion, uint32_t aFlags) MOZ_OVERRIDE;
   virtual void DidPaintWindow() MOZ_OVERRIDE;
   virtual void RequestRepaint() MOZ_OVERRIDE;
   virtual nsEventStatus HandleEvent(nsGUIEvent* aEvent, bool aUseAttachedEvents) MOZ_OVERRIDE;
 
   virtual ~nsView();
 
   nsPoint GetOffsetTo(const nsView* aOther, const int32_t aAPD) const;
--- a/view/public/nsViewManager.h
+++ b/view/public/nsViewManager.h
@@ -327,25 +327,25 @@ private:
   void FlushPendingInvalidates();
 
   void ProcessPendingUpdatesForView(nsView *aView,
                                     bool aFlushDirtyRegion = true);
   void FlushDirtyRegionToWidget(nsView* aView);
   /**
    * Call WillPaint() on all view observers under this vm root.
    */
-  void CallWillPaintOnObservers(bool aWillSendDidPaint);
+  void CallWillPaintOnObservers();
   void ReparentChildWidgets(nsView* aView, nsIWidget *aNewWidget);
   void ReparentWidgets(nsView* aView, nsView *aParent);
   void InvalidateWidgetArea(nsView *aWidgetView, const nsRegion &aDamagedRegion);
 
   void InvalidateViews(nsView *aView);
 
   // aView is the view for aWidget and aRegion is relative to aWidget.
-  void Refresh(nsView *aView, const nsIntRegion& aRegion, bool aWillSendDidPaint);
+  void Refresh(nsView *aView, const nsIntRegion& aRegion);
 
   void InvalidateRectDifference(nsView *aView, const nsRect& aRect, const nsRect& aCutOut);
   void InvalidateHorizontalBandDifference(nsView *aView, const nsRect& aRect, const nsRect& aCutOut,
                                           nscoord aY1, nscoord aY2, bool aInCutOut);
 
   // Utilities
 
   bool IsViewInserted(nsView *aView);
@@ -372,17 +372,17 @@ private:
   nsViewManager* RootViewManager() const { return mRootViewManager; }
   bool IsRootVM() const { return this == RootViewManager(); }
 
   // Whether synchronous painting is allowed at the moment. For example,
   // widget geometry changes can cause synchronous painting, so they need to
   // be deferred while refresh is disabled.
   bool IsPaintingAllowed() { return RootViewManager()->mRefreshDisableCount == 0; }
 
-  void WillPaintWindow(nsIWidget* aWidget, bool aWillSendDidPaint);
+  void WillPaintWindow(nsIWidget* aWidget);
   bool PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion,
                    uint32_t aFlags);
   void DidPaintWindow();
 
   // Call this when you need to let the viewmanager know that it now has
   // pending updates.
   void PostPendingUpdate();
 
--- a/view/src/nsView.cpp
+++ b/view/src/nsView.cpp
@@ -946,20 +946,20 @@ nsView::RequestWindowClose(nsIWidget* aW
       return true;
     }
   }
 
   return false;
 }
 
 void
-nsView::WillPaintWindow(nsIWidget* aWidget, bool aWillSendDidPaint)
+nsView::WillPaintWindow(nsIWidget* aWidget)
 {
   nsRefPtr<nsViewManager> vm = mViewManager;
-  vm->WillPaintWindow(aWidget, aWillSendDidPaint);
+  vm->WillPaintWindow(aWidget);
 }
 
 bool
 nsView::PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion, uint32_t aFlags)
 {
   NS_ASSERTION(this == nsView::GetViewFor(aWidget), "wrong view for widget?");
 
   mInAlternatePaint = aFlags & PAINT_IS_ALTERNATE;
--- a/view/src/nsViewManager.cpp
+++ b/view/src/nsViewManager.cpp
@@ -283,18 +283,17 @@ nsView* nsViewManager::GetDisplayRootFor
   }
 }
 
 /**
    aRegion is given in device coordinates!!
    aContext may be null, in which case layers should be used for
    rendering.
 */
-void nsViewManager::Refresh(nsView *aView, const nsIntRegion& aRegion,
-                            bool aWillSendDidPaint)
+void nsViewManager::Refresh(nsView *aView, const nsIntRegion& aRegion)
 {
   NS_ASSERTION(aView->GetViewManager() == this, "wrong view manager");
 
   // damageRegion is the damaged area, in twips, relative to the view origin
   nsRegion damageRegion = aRegion.ToAppUnits(AppUnitsPerDevPixel());
   // move region from widget coordinates into view coordinates
   damageRegion.MoveBy(-aView->ViewToWidgetOffset());
 
@@ -328,17 +327,17 @@ void nsViewManager::Refresh(nsView *aVie
                  "Widgets that we paint must all be display roots");
 
     if (mPresShell) {
 #ifdef DEBUG_INVALIDATIONS
       printf("--COMPOSITE-- %p\n", mPresShell);
 #endif
       mPresShell->Paint(aView, damageRegion,
                         nsIPresShell::PAINT_COMPOSITE |
-                        (aWillSendDidPaint ? nsIPresShell::PAINT_WILL_SEND_DID_PAINT : 0));
+                        nsIPresShell::PAINT_WILL_SEND_DID_PAINT);
 #ifdef DEBUG_INVALIDATIONS
       printf("--ENDCOMPOSITE--\n");
 #endif
       mozilla::StartupTimeline::RecordOnce(mozilla::StartupTimeline::FIRST_PAINT);
     }
 
     SetPainting(false);
   }
@@ -610,51 +609,51 @@ void nsViewManager::InvalidateViews(nsVi
   // Invalidate all children as well.
   nsView* childView = aView->GetFirstChild();
   while (nullptr != childView)  {
     childView->GetViewManager()->InvalidateViews(childView);
     childView = childView->GetNextSibling();
   }
 }
 
-void nsViewManager::WillPaintWindow(nsIWidget* aWidget, bool aWillSendDidPaint)
+void nsViewManager::WillPaintWindow(nsIWidget* aWidget)
 {
   if (aWidget) {
     nsView* view = nsView::GetViewFor(aWidget);
     if (view && view->ForcedRepaint()) {
       ProcessPendingUpdates();
       // Re-get the view pointer here since the ProcessPendingUpdates might have
       // destroyed it during CallWillPaintOnObservers.
       view = nsView::GetViewFor(aWidget);
       if (view) {
         view->SetForcedRepaint(false);
       }
     }
   }
 
   nsCOMPtr<nsIPresShell> shell = mPresShell;
   if (shell) {
-    shell->WillPaintWindow(aWillSendDidPaint);
+    shell->WillPaintWindow(true);
   }
 }
 
 bool nsViewManager::PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion,
                                 uint32_t aFlags)
 {
   if (!aWidget || !mContext)
     return false;
 
   NS_ASSERTION(IsPaintingAllowed(),
                "shouldn't be receiving paint events while painting is disallowed!");
 
   // Get the view pointer here since NS_WILL_PAINT might have
   // destroyed it during CallWillPaintOnObservers (bug 378273).
   nsView* view = nsView::GetViewFor(aWidget);
   if (view && !aRegion.IsEmpty()) {
-    Refresh(view, aRegion, true);
+    Refresh(view, aRegion);
   }
 
   return true;
 }
 
 void nsViewManager::DidPaintWindow()
 {
   nsCOMPtr<nsIPresShell> shell = mPresShell;
@@ -1112,17 +1111,17 @@ nsViewManager::ProcessPendingUpdates()
     RootViewManager()->ProcessPendingUpdates();
     return;
   }
 
   mPresShell->GetPresContext()->RefreshDriver()->RevokeViewManagerFlush();
 
   // Flush things like reflows by calling WillPaint on observer presShells.
   if (mPresShell) {
-    CallWillPaintOnObservers(true);
+    CallWillPaintOnObservers();
   }
   ProcessPendingUpdatesForView(mRootView, true);
 }
 
 void
 nsViewManager::UpdateWidgetGeometry()
 {
   if (!IsRootVM()) {
@@ -1132,29 +1131,29 @@ nsViewManager::UpdateWidgetGeometry()
 
   if (mHasPendingWidgetGeometryChanges) {
     mHasPendingWidgetGeometryChanges = false;
     ProcessPendingUpdatesForView(mRootView, false);
   }
 }
 
 void
-nsViewManager::CallWillPaintOnObservers(bool aWillSendDidPaint)
+nsViewManager::CallWillPaintOnObservers()
 {
   NS_PRECONDITION(IsRootVM(), "Must be root VM for this to be called!");
 
   int32_t index;
   for (index = 0; index < mVMCount; index++) {
     nsViewManager* vm = (nsViewManager*)gViewManagers->ElementAt(index);
     if (vm->RootViewManager() == this) {
       // One of our kids.
       if (vm->mRootView && vm->mRootView->IsEffectivelyVisible()) {
         nsCOMPtr<nsIPresShell> shell = vm->GetPresShell();
         if (shell) {
-          shell->WillPaint(aWillSendDidPaint);
+          shell->WillPaint(true);
         }
       }
     }
   }
 }
 
 void
 nsViewManager::GetLastUserEventTime(uint32_t& aTime)
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -1009,17 +1009,17 @@ nsWindow::DrawTo(gfxASurface *targetSurf
         }
     }
 
     // If we have no covering child, then we need to render this.
     if (coveringChildIndex == -1) {
         bool painted = false;
         nsIntRegion region = invalidRect;
 
-        mWidgetListener->WillPaintWindow(this, true);
+        mWidgetListener->WillPaintWindow(this);
 
         switch (GetLayerManager(nullptr)->GetBackendType()) {
             case mozilla::layers::LAYERS_BASIC: {
 
                 nsRefPtr<gfxContext> ctx = new gfxContext(targetSurface);
 
                 {
                     mozilla::layers::RenderTraceScope trace2("Basic DrawTo", "727272");
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -2678,17 +2678,17 @@ NSEvent* gLastDragMouseDownEvent = nil;
       [widgetArray addObject:[NSNumber numberWithUnsignedInteger:(NSUInteger)mGeckoChild]];
       [self performSelector:@selector(releaseWidgets:)
                  withObject:widgetArray
                  afterDelay:0];
     }
 
     nsIWidgetListener* listener = mGeckoChild->GetWidgetListener();
     if (listener) {
-      listener->WillPaintWindow(mGeckoChild, false);
+      listener->WillPaintWindow(mGeckoChild);
     }
   }
   [super viewWillDraw];
 }
 
 // Allows us to turn off setting up the clip region
 // before each drawRect. We already clip within gecko.
 - (BOOL)wantsDefaultClipping
--- a/widget/gonk/nsWindow.cpp
+++ b/widget/gonk/nsWindow.cpp
@@ -219,17 +219,17 @@ nsWindow::DoDraw(void)
 
     StopBootAnimation();
 
     nsIntRegion region = gWindowToRedraw->mDirtyRegion;
     gWindowToRedraw->mDirtyRegion.SetEmpty();
 
     nsIWidgetListener* listener = gWindowToRedraw->GetWidgetListener();
     if (listener) {
-        listener->WillPaintWindow(gWindowToRedraw, true);
+        listener->WillPaintWindow(gWindowToRedraw);
     }
 
     LayerManager* lm = gWindowToRedraw->GetLayerManager();
     if (mozilla::layers::LAYERS_OPENGL == lm->GetBackendType()) {
         LayerManagerOGL* oglm = static_cast<LayerManagerOGL*>(lm);
         oglm->SetClippingRegion(region);
         oglm->SetWorldTransform(sRotationMatrix);
 
--- a/widget/gtk2/nsWindow.cpp
+++ b/widget/gtk2/nsWindow.cpp
@@ -2003,17 +2003,17 @@ nsWindow::OnExposeEvent(cairo_t *cr)
     nsIWidgetListener *listener =
         mAttachedWidgetListener ? mAttachedWidgetListener : mWidgetListener;
     if (!listener)
         return FALSE;
 
     // Dispatch WillPaintWindow notification to allow scripts etc. to run
     // before we paint
     {
-        listener->WillPaintWindow(this, true);
+        listener->WillPaintWindow(this);
 
         // If the window has been destroyed during the will paint notification,
         // there is nothing left to do.
         if (!mGdkWindow)
             return TRUE;
 
         // Re-get the listener since the will paint notification might have
         // killed it.
--- a/widget/nsIWidgetListener.h
+++ b/widget/nsIWidgetListener.h
@@ -112,17 +112,17 @@ public:
    */
   virtual bool RequestWindowClose(nsIWidget* aWidget) { return false; }
 
   /*
    * Indicate that a paint is about to occur on this window. This is called
    * at a time when it's OK to change the geometry of this widget or of
    * other widgets. Must be called before every call to PaintWindow.
    */
-  virtual void WillPaintWindow(nsIWidget* aWidget, bool aWillSendDidPaint) { }
+  virtual void WillPaintWindow(nsIWidget* aWidget) { }
 
   /**
    * Paint the specified region of the window. Returns true if the
    * notification was handled.
    * This is called at a time when it is not OK to change the geometry of
    * this widget or of other widgets.
    */
   enum {
--- a/widget/qt/nsWindow.cpp
+++ b/widget/qt/nsWindow.cpp
@@ -1029,17 +1029,17 @@ nsWindow::DoPaint(QPainter* aPainter, co
         LOG(("Expose event on destroyed window [%p] window %p\n",
              (void *)this, mWidget));
         return false;
     }
 
     // Call WillPaintWindow to allow scripts etc. to run before we paint
     {
         if (mWidgetListener)
-            mWidgetListener->WillPaintWindow(this, true);
+            mWidgetListener->WillPaintWindow(this);
     }
 
     if (!mWidget)
         return false;
 
     QRectF r;
     if (aOption)
         r = aOption->exposedRect;
--- a/widget/windows/nsWindowGfx.cpp
+++ b/widget/windows/nsWindowGfx.cpp
@@ -209,17 +209,17 @@ bool nsWindow::OnPaint(HDC aDC, uint32_t
     }
 
     ValidateRect(mWnd, NULL);
     return true;
   }
 
   nsIWidgetListener* listener = GetPaintListener();
   if (listener) {
-    listener->WillPaintWindow(this, true);
+    listener->WillPaintWindow(this);
   }
   // Re-get the listener since the will paint notification may have killed it.
   listener = GetPaintListener();
   if (!listener)
     return false;
 
   bool result = true;
   PAINTSTRUCT ps;
--- a/widget/xpwidgets/PuppetWidget.cpp
+++ b/widget/xpwidgets/PuppetWidget.cpp
@@ -516,17 +516,17 @@ PuppetWidget::Paint()
     return NS_OK;
 
   nsIntRegion region = mDirtyRegion;
 
   // reset repaint tracking
   mDirtyRegion.SetEmpty();
   mPaintTask.Revoke();
 
-  mAttachedWidgetListener->WillPaintWindow(this, true);
+  mAttachedWidgetListener->WillPaintWindow(this);
 
   if (mAttachedWidgetListener) {
 #ifdef DEBUG
     debug_DumpPaintEvent(stderr, this, region,
                          nsAutoCString("PuppetWidget"), 0);
 #endif
 
     if (mozilla::layers::LAYERS_D3D10 == mLayerManager->GetBackendType()) {