Bug 795833 - Add a RequestRepaint method to nsIWidgetListener and use it in the android widget instead of invalidating the view. r=roc a=bajaj
authorMatt Woodrow <mwoodrow@mozilla.com>
Tue, 18 Dec 2012 16:42:02 +1300
changeset 122612 465507610dabe36c4a60095bfa6c89a0e17eb934
parent 122611 861349ea41c0debe128e6cf61e22c37fc866c70b
child 122613 75fdd5231adf25af0d9e8c8573d943bc3713d539
push id2045
push usermwoodrow@mozilla.com
push dateWed, 16 Jan 2013 00:10:20 +0000
treeherdermozilla-beta@465507610dab [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc, bajaj
bugs795833
milestone19.0
Bug 795833 - Add a RequestRepaint method to nsIWidgetListener and use it in the android widget instead of invalidating the view. r=roc a=bajaj
view/src/nsView.cpp
view/src/nsView.h
widget/android/nsWindow.cpp
widget/nsIWidgetListener.h
--- a/view/src/nsView.cpp
+++ b/view/src/nsView.cpp
@@ -1051,16 +1051,25 @@ nsView::PaintWindow(nsIWidget* aWidget, 
 
 void
 nsView::DidPaintWindow()
 {
   nsCOMPtr<nsViewManager> vm = mViewManager;
   vm->DidPaintWindow();
 }
 
+void
+nsView::RequestRepaint()
+{
+  nsIPresShell* presShell = mViewManager->GetPresShell();
+  if (presShell) {
+    presShell->ScheduleViewManagerFlush();
+  }
+}
+
 nsEventStatus
 nsView::HandleEvent(nsGUIEvent* aEvent, bool aUseAttachedEvents)
 {
   NS_PRECONDITION(nullptr != aEvent->widget, "null widget ptr");
 
   nsEventStatus result = nsEventStatus_eIgnore;
   nsIView* view;
   if (aUseAttachedEvents) {
--- a/view/src/nsView.h
+++ b/view/src/nsView.h
@@ -165,16 +165,17 @@ public:
   virtual nsIPresShell* GetPresShell();
   virtual nsIView* GetView() { return this; }
   bool WindowMoved(nsIWidget* aWidget, int32_t x, int32_t y);
   bool WindowResized(nsIWidget* aWidget, int32_t aWidth, int32_t aHeight);
   bool RequestWindowClose(nsIWidget* aWidget);
   void WillPaintWindow(nsIWidget* aWidget, bool aWillSendDidPaint);
   bool PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion, uint32_t aFlags);
   void DidPaintWindow();
+  void RequestRepaint() MOZ_OVERRIDE;
   nsEventStatus HandleEvent(nsGUIEvent* aEvent, bool aUseAttachedEvents);
 
   virtual ~nsView();
 
   nsPoint GetOffsetTo(const nsView* aOther) const;
   nsIWidget* GetNearestWidget(nsPoint* aOffset) const;
   nsPoint GetOffsetTo(const nsView* aOther, const int32_t aAPD) const;
   nsIWidget* GetNearestWidget(nsPoint* aOffset, const int32_t aAPD) const;
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -267,20 +267,17 @@ nsWindow::ConfigureChildren(const nsTArr
 
     return NS_OK;
 }
 
 void
 nsWindow::RedrawAll()
 {
     if (mFocus && mFocus->mWidgetListener) {
-        nsIView* view = mFocus->mWidgetListener->GetView();
-        if (view && view->GetViewManager()) {
-            view->GetViewManager()->InvalidateView(view);
-        }
+        mFocus->mWidgetListener->RequestRepaint();
     }
 }
 
 NS_IMETHODIMP
 nsWindow::SetParent(nsIWidget *aNewParent)
 {
     if ((nsIWidget*)mParent == aNewParent)
         return NS_OK;
--- a/widget/nsIWidgetListener.h
+++ b/widget/nsIWidgetListener.h
@@ -129,16 +129,21 @@ public:
   virtual bool PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion, uint32_t aFlags) { return false; }
 
   /**
    * On some platforms, indicates that a paint occurred.
    */
   virtual void DidPaintWindow() { }
 
   /**
+   * Request that layout schedules a repaint on the next refresh driver tick.
+   */
+  virtual void RequestRepaint() { }
+
+  /**
    * Handle an event.
    */
   virtual nsEventStatus HandleEvent(nsGUIEvent* event, bool useAttachedEvents)
   {
     return nsEventStatus_eIgnore;
   }
 };