diff --git a/view/src/nsViewManager.cpp b/view/src/nsViewManager.cpp index e339e90a2b66..50e7970cf03e 100644 --- a/view/src/nsViewManager.cpp +++ b/view/src/nsViewManager.cpp @@ -23,6 +23,7 @@ #include "nsEventStateManager.h" #include "mozilla/StartupTimeline.h" #include "sampler.h" +#include "nsRefreshDriver.h" /** XXX TODO XXX @@ -377,7 +378,9 @@ void nsViewManager::ProcessPendingUpdatesForView(nsView* aView, // damage is applied based on the final widget geometry if (aFlushDirtyRegion) { nsIWidget *widget = aView->GetWidget(); - if (widget) { + if (widget && widget->NeedsPaint() && aView->HasNonEmptyDirtyRegion()) { + FlushDirtyRegionToWidget(aView); + SetPainting(true); #ifdef DEBUG_INVALIDATIONS printf("---- PAINT START ----PresShell(%p), nsView(%p), nsIWidget(%p)\n", mPresShell, aView, widget); #endif @@ -386,8 +389,8 @@ void nsViewManager::ProcessPendingUpdatesForView(nsView* aView, #ifdef DEBUG_INVALIDATIONS printf("---- PAINT END ----\n"); #endif + SetPainting(false); } - FlushDirtyRegionToWidget(aView); } } diff --git a/widget/nsIWidget.h b/widget/nsIWidget.h index e03aaca87462..b4bfb119f865 100644 --- a/widget/nsIWidget.h +++ b/widget/nsIWidget.h @@ -409,6 +409,7 @@ class nsIWidget : public nsISupports { nsIWidget() : mLastChild(nullptr) , mPrevSibling(nullptr) + , mNeedsPaint(false) {} @@ -1593,6 +1594,9 @@ class nsIWidget : public nsISupports { */ virtual bool WidgetPaintsBackground() { return false; } + bool NeedsPaint() { + return true; + } /** * Get the natural bounds of this widget. This method is only * meaningful for widgets for which Gecko implements screen @@ -1643,6 +1647,7 @@ protected: nsIWidget* mLastChild; nsCOMPtr mNextSibling; nsIWidget* mPrevSibling; + bool mNeedsPaint; }; NS_DEFINE_STATIC_IID_ACCESSOR(nsIWidget, NS_IWIDGET_IID)