Bug 1302071 - Part 3: Remove flags parameter to NotifyInvalidation since it's unused. r?tnikkel draft
authorMatt Woodrow <mwoodrow@mozilla.com>
Fri, 17 Feb 2017 11:50:58 +1300
changeset 485814 2b25ffbf3bc1ea592da941dbc25406e633d1b19f
parent 485813 2248f1421d4c297f5b4329d084d4753bd6e4fd8e
child 485815 0b194b8ab70913183e61104854ad4a64b534cff6
push id45861
push usermwoodrow@mozilla.com
push dateFri, 17 Feb 2017 08:19:13 +0000
reviewerstnikkel
bugs1302071
milestone54.0a1
Bug 1302071 - Part 3: Remove flags parameter to NotifyInvalidation since it's unused. r?tnikkel MozReview-Commit-ID: 8hC1GglMhk2
dom/events/NotifyPaintEvent.cpp
dom/events/NotifyPaintEvent.h
dom/events/PaintRequest.cpp
dom/events/PaintRequest.h
layout/base/PresShell.cpp
layout/base/nsPresContext.cpp
layout/base/nsPresContext.h
layout/painting/nsDisplayList.cpp
--- a/dom/events/NotifyPaintEvent.cpp
+++ b/dom/events/NotifyPaintEvent.cpp
@@ -14,26 +14,26 @@
 
 namespace mozilla {
 namespace dom {
 
 NotifyPaintEvent::NotifyPaintEvent(EventTarget* aOwner,
                                    nsPresContext* aPresContext,
                                    WidgetEvent* aEvent,
                                    EventMessage aEventMessage,
-                                   nsInvalidateRequestList* aInvalidateRequests,
+                                   nsTArray<nsRect>* aInvalidateRequests,
                                    uint64_t aTransactionId,
                                    DOMHighResTimeStamp aTimeStamp)
   : Event(aOwner, aPresContext, aEvent)
 {
   if (mEvent) {
     mEvent->mMessage = aEventMessage;
   }
   if (aInvalidateRequests) {
-    mInvalidateRequests.AppendElements(Move(aInvalidateRequests->mRequests));
+    mInvalidateRequests.SwapElements(*aInvalidateRequests);
   }
 
   mTransactionId = aTransactionId;
   mTimeStamp = aTimeStamp;
 }
 
 NS_INTERFACE_MAP_BEGIN(NotifyPaintEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMNotifyPaintEvent)
@@ -42,17 +42,17 @@ NS_INTERFACE_MAP_END_INHERITING(Event)
 NS_IMPL_ADDREF_INHERITED(NotifyPaintEvent, Event)
 NS_IMPL_RELEASE_INHERITED(NotifyPaintEvent, Event)
 
 nsRegion
 NotifyPaintEvent::GetRegion(SystemCallerGuarantee)
 {
   nsRegion r;
   for (uint32_t i = 0; i < mInvalidateRequests.Length(); ++i) {
-    r.Or(r, mInvalidateRequests[i].mRect);
+    r.Or(r, mInvalidateRequests[i]);
     r.SimplifyOutward(10);
   }
   return r;
 }
 
 already_AddRefed<DOMRect>
 NotifyPaintEvent::BoundingClientRect(SystemCallerGuarantee aGuarantee)
 {
@@ -104,33 +104,31 @@ NotifyPaintEvent::Serialize(IPC::Message
     IPC::WriteParam(aMsg, NS_LITERAL_STRING("notifypaintevent"));
   }
 
   Event::Serialize(aMsg, false);
 
   uint32_t length = mInvalidateRequests.Length();
   IPC::WriteParam(aMsg, length);
   for (uint32_t i = 0; i < length; ++i) {
-    IPC::WriteParam(aMsg, mInvalidateRequests[i].mRect);
-    IPC::WriteParam(aMsg, mInvalidateRequests[i].mFlags);
+    IPC::WriteParam(aMsg, mInvalidateRequests[i]);
   }
 }
 
 NS_IMETHODIMP_(bool)
 NotifyPaintEvent::Deserialize(const IPC::Message* aMsg, PickleIterator* aIter)
 {
   NS_ENSURE_TRUE(Event::Deserialize(aMsg, aIter), false);
 
   uint32_t length = 0;
   NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &length), false);
   mInvalidateRequests.SetCapacity(length);
   for (uint32_t i = 0; i < length; ++i) {
-    nsInvalidateRequestList::Request req;
-    NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &req.mRect), false);
-    NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &req.mFlags), false);
+    nsRect req;
+    NS_ENSURE_TRUE(IPC::ReadParam(aMsg, aIter, &req), false);
     mInvalidateRequests.AppendElement(req);
   }
 
   return true;
 }
 
 uint64_t
 NotifyPaintEvent::TransactionId(SystemCallerGuarantee)
@@ -150,17 +148,17 @@ NotifyPaintEvent::PaintTimeStamp(SystemC
 using namespace mozilla;
 using namespace mozilla::dom;
 
 already_AddRefed<NotifyPaintEvent>
 NS_NewDOMNotifyPaintEvent(EventTarget* aOwner,
                           nsPresContext* aPresContext,
                           WidgetEvent* aEvent,
                           EventMessage aEventMessage,
-                          nsInvalidateRequestList* aInvalidateRequests,
+                          nsTArray<nsRect>* aInvalidateRequests,
                           uint64_t aTransactionId,
                           DOMHighResTimeStamp aTimeStamp)
 {
   RefPtr<NotifyPaintEvent> it =
     new NotifyPaintEvent(aOwner, aPresContext, aEvent, aEventMessage,
                          aInvalidateRequests, aTransactionId, aTimeStamp);
   return it.forget();
 }
--- a/dom/events/NotifyPaintEvent.h
+++ b/dom/events/NotifyPaintEvent.h
@@ -25,17 +25,17 @@ class NotifyPaintEvent : public Event,
                          public nsIDOMNotifyPaintEvent
 {
 
 public:
   NotifyPaintEvent(EventTarget* aOwner,
                    nsPresContext* aPresContext,
                    WidgetEvent* aEvent,
                    EventMessage aEventMessage,
-                   nsInvalidateRequestList* aInvalidateRequests,
+                   nsTArray<nsRect>* aInvalidateRequests,
                    uint64_t aTransactionId,
                    DOMHighResTimeStamp aTimeStamp);
 
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_DECL_NSIDOMNOTIFYPAINTEVENT
 
   // Forward to base class
@@ -63,29 +63,28 @@ public:
   DOMHighResTimeStamp PaintTimeStamp(SystemCallerGuarantee);
 
 protected:
   ~NotifyPaintEvent() {}
 
 private:
   nsRegion GetRegion(SystemCallerGuarantee);
 
-  nsTArray<nsInvalidateRequestList::Request> mInvalidateRequests;
+  nsTArray<nsRect> mInvalidateRequests;
   uint64_t mTransactionId;
   DOMHighResTimeStamp mTimeStamp;
 };
 
 } // namespace dom
 } // namespace mozilla
 
 // This empties aInvalidateRequests.
 already_AddRefed<mozilla::dom::NotifyPaintEvent>
 NS_NewDOMNotifyPaintEvent(mozilla::dom::EventTarget* aOwner,
                           nsPresContext* aPresContext,
                           mozilla::WidgetEvent* aEvent,
                           mozilla::EventMessage aEventMessage =
                             mozilla::eVoidEvent,
-                          nsInvalidateRequestList* aInvalidateRequests =
-                            nullptr,
+                          nsTArray<nsRect>* aInvalidateRequests = nullptr,
                           uint64_t aTransactionId = 0,
                           DOMHighResTimeStamp aTimeStamp = 0);
 
 #endif // mozilla_dom_NotifyPaintEvent_h_
--- a/dom/events/PaintRequest.cpp
+++ b/dom/events/PaintRequest.cpp
@@ -33,17 +33,17 @@ PaintRequest::WrapObject(JSContext* aCx,
 {
   return PaintRequestBinding::Wrap(aCx, this, aGivenProto);
 }
 
 already_AddRefed<DOMRect>
 PaintRequest::ClientRect()
 {
   RefPtr<DOMRect> clientRect = new DOMRect(this);
-  clientRect->SetLayoutRect(mRequest.mRect);
+  clientRect->SetLayoutRect(mRequest);
   return clientRect.forget();
 }
 
 NS_IMETHODIMP
 PaintRequest::GetClientRect(nsIDOMClientRect** aResult)
 {
   RefPtr<DOMRect> clientRect = ClientRect();
   clientRect.forget(aResult);
--- a/dom/events/PaintRequest.h
+++ b/dom/events/PaintRequest.h
@@ -20,17 +20,16 @@ class DOMRect;
 
 class PaintRequest final : public nsIDOMPaintRequest
                          , public nsWrapperCache
 {
 public:
   explicit PaintRequest(nsIDOMEvent* aParent)
     : mParent(aParent)
   {
-    mRequest.mFlags = 0;
   }
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(PaintRequest)
   NS_DECL_NSIDOMPAINTREQUEST
 
   virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
@@ -40,24 +39,24 @@ public:
   }
 
   already_AddRefed<DOMRect> ClientRect();
   void GetReason(nsAString& aResult) const
   {
     aResult.AssignLiteral("repaint");
   }
 
-  void SetRequest(const nsInvalidateRequestList::Request& aRequest)
+  void SetRequest(const nsRect& aRequest)
   { mRequest = aRequest; }
 
 private:
   ~PaintRequest() {}
 
   nsCOMPtr<nsIDOMEvent> mParent;
-  nsInvalidateRequestList::Request mRequest;
+  nsRect mRequest;
 };
 
 class PaintRequestList final : public nsISupports,
                                public nsWrapperCache
 {
 public:
   explicit PaintRequestList(nsIDOMEvent *aParent) : mParent(aParent)
   {
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -6409,17 +6409,17 @@ PresShell::Paint(nsView*        aViewToP
             nsIntRect bounds = invalid.GetBounds();
             nsRect rect(presContext->DevPixelsToAppUnits(bounds.x),
                         presContext->DevPixelsToAppUnits(bounds.y),
                         presContext->DevPixelsToAppUnits(bounds.width),
                         presContext->DevPixelsToAppUnits(bounds.height));
             if (shouldInvalidate) {
               aViewToPaint->GetViewManager()->InvalidateViewNoSuppression(aViewToPaint, rect);
             }
-            presContext->NotifyInvalidation(bounds, 0);
+            presContext->NotifyInvalidation(bounds);
           }
         } else if (shouldInvalidate) {
           aViewToPaint->GetViewManager()->InvalidateView(aViewToPaint);
         }
 
         frame->UpdatePaintCountForPaintedPresShells();
         return;
       }
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -160,17 +160,17 @@ nsPresContext::IsDOMPaintEventPending()
   if (mFireAfterPaintEvents) {
     return true;
   }
   nsRootPresContext* drpc = GetRootPresContext();
   if (drpc && drpc->mRefreshDriver->ViewManagerFlushIsPending()) {
     // Since we're promising that there will be a MozAfterPaint event
     // fired, we record an empty invalidation in case display list
     // invalidation doesn't invalidate anything further.
-    NotifyInvalidation(nsRect(0, 0, 0, 0), 0);
+    NotifyInvalidation(nsRect(0, 0, 0, 0));
     NS_ASSERTION(mFireAfterPaintEvents, "Why aren't we planning to fire the event?");
     return true;
   }
   return false;
 }
 
 void
 nsPresContext::PrefChangedCallback(const char* aPrefName, void* instance_data)
@@ -2308,17 +2308,17 @@ nsPresContext::EnsureSafeToHandOutCSSRul
     // Nothing to do.
     return;
   }
 
   RebuildAllStyleData(nsChangeHint(0), eRestyle_Subtree);
 }
 
 void
-nsPresContext::FireDOMPaintEvent(nsInvalidateRequestList* aList, uint64_t aTransactionId,
+nsPresContext::FireDOMPaintEvent(nsTArray<nsRect>* aList, uint64_t aTransactionId,
                                  mozilla::TimeStamp aTimeStamp /* = mozilla::TimeStamp() */)
 {
   nsPIDOMWindowInner* ourWindow = mDocument->GetInnerWindow();
   if (!ourWindow)
     return;
 
   nsCOMPtr<EventTarget> dispatchTarget = do_QueryInterface(ourWindow);
   nsCOMPtr<EventTarget> eventTarget = dispatchTarget;
@@ -2440,38 +2440,38 @@ nsPresContext::MayHavePaintEventListener
   }
 
   bool result = false;
   mDocument->EnumerateSubDocuments(MayHavePaintEventListenerSubdocumentCallback, &result);
   return result;
 }
 
 void
-nsPresContext::NotifyInvalidation(const nsIntRect& aRect, uint32_t aFlags)
+nsPresContext::NotifyInvalidation(const nsIntRect& aRect)
 {
   // Prevent values from overflow after DevPixelsToAppUnits().
   //
   // DevPixelsTopAppUnits() will multiple a factor (60) to the value,
   // it may make the result value over the edge (overflow) of max or
   // min value of int32_t. Compute the max sized dev pixel rect that
   // we can support and intersect with it.
   nsIntRect clampedRect = nsIntRect::MaxIntRect();
   clampedRect.ScaleInverseRoundIn(AppUnitsPerDevPixel());
 
   clampedRect = clampedRect.Intersect(aRect);
 
   nsRect rect(DevPixelsToAppUnits(clampedRect.x),
               DevPixelsToAppUnits(clampedRect.y),
               DevPixelsToAppUnits(clampedRect.width),
               DevPixelsToAppUnits(clampedRect.height));
-  NotifyInvalidation(rect, aFlags);
+  NotifyInvalidation(rect);
 }
 
 void
-nsPresContext::NotifyInvalidation(const nsRect& aRect, uint32_t aFlags)
+nsPresContext::NotifyInvalidation(const nsRect& aRect)
 {
   MOZ_ASSERT(GetContainerWeak(), "Invalidation in detached pres context");
 
   // If there is no paint event listener, then we don't need to fire
   // the asynchronous event. We don't even need to record invalidation.
   // MayHavePaintEventListener is pretty cheap and we could make it
   // even cheaper by providing a more efficient
   // nsPIDOMWindow::GetListenerManager.
@@ -2484,23 +2484,17 @@ nsPresContext::NotifyInvalidation(const 
   }
   if (!pc) {
     nsRootPresContext* rpc = GetRootPresContext();
     if (rpc) {
       rpc->EnsureEventualDidPaintEvent();
     }
   }
 
-  nsInvalidateRequestList::Request* request =
-    mInvalidateRequestsSinceLastPaint.mRequests.AppendElement();
-  if (!request)
-    return;
-
-  request->mRect = aRect;
-  request->mFlags = aFlags;
+  mInvalidateRequestsSinceLastPaint.AppendElement(aRect);
 }
 
 /* static */ void
 nsPresContext::NotifySubDocInvalidation(ContainerLayer* aContainer,
                                         const nsIntRegion& aRegion)
 {
   ContainerLayerPresContext *data =
     static_cast<ContainerLayerPresContext*>(
@@ -2512,17 +2506,17 @@ nsPresContext::NotifySubDocInvalidation(
   nsIntPoint topLeft = aContainer->GetVisibleRegion().ToUnknownRegion().GetBounds().TopLeft();
 
   for (auto iter = aRegion.RectIter(); !iter.Done(); iter.Next()) {
     nsIntRect rect(iter.Get());
     //PresContext coordinate space is relative to the start of our visible
     // region. Is this really true? This feels like the wrong way to get the right
     // answer.
     rect.MoveBy(-topLeft);
-    data->mPresContext->NotifyInvalidation(rect, 0);
+    data->mPresContext->NotifyInvalidation(rect);
   }
 }
 
 void
 nsPresContext::SetNotifySubDocInvalidationData(ContainerLayer* aContainer)
 {
   ContainerLayerPresContext* pres = new ContainerLayerPresContext;
   pres->mPresContext = this;
@@ -2558,41 +2552,41 @@ NotifyDidPaintSubdocumentCallback(nsIDoc
     }
   }
   return true;
 }
 
 class DelayedFireDOMPaintEvent : public Runnable {
 public:
   DelayedFireDOMPaintEvent(nsPresContext* aPresContext,
-                           nsInvalidateRequestList* aList,
+                           nsTArray<nsRect>* aList,
                            uint64_t aTransactionId,
                            const mozilla::TimeStamp& aTimeStamp = mozilla::TimeStamp())
     : mPresContext(aPresContext)
     , mTransactionId(aTransactionId)
     , mTimeStamp(aTimeStamp)
   {
     MOZ_ASSERT(mPresContext->GetContainerWeak(),
                "DOMPaintEvent requested for a detached pres context");
-    mList.TakeFrom(aList);
+    mList.SwapElements(*aList);
   }
   NS_IMETHOD Run() override
   {
     // The pres context might have been detached during the delay -
     // that's fine, just don't fire the event.
     if (mPresContext->GetContainerWeak()) {
       mPresContext->FireDOMPaintEvent(&mList, mTransactionId, mTimeStamp);
     }
     return NS_OK;
   }
 
   RefPtr<nsPresContext> mPresContext;
   uint64_t mTransactionId;
   const mozilla::TimeStamp mTimeStamp;
-  nsInvalidateRequestList mList;
+  nsTArray<nsRect> mList;
 };
 
 void
 nsPresContext::NotifyDidPaintForSubtree(uint32_t aFlags, uint64_t aTransactionId,
                                         const mozilla::TimeStamp& aTimeStamp)
 {
   if (IsRoot()) {
     static_cast<nsRootPresContext*>(this)->CancelDidPaintTimer();
@@ -2608,18 +2602,17 @@ nsPresContext::NotifyDidPaintForSubtree(
 
   // Non-root prescontexts fire MozAfterPaint to all their descendants
   // unconditionally, even if no invalidations have been collected. This is
   // because we don't want to eat the cost of collecting invalidations for
   // every subdocument (which would require putting every subdocument in its
   // own layer).
 
   if (aFlags & nsIPresShell::PAINT_LAYERS) {
-    mUndeliveredInvalidateRequestsBeforeLastPaint.TakeFrom(
-        &mInvalidateRequestsSinceLastPaint);
+    mUndeliveredInvalidateRequestsBeforeLastPaint.AppendElements(mozilla::Move(mInvalidateRequestsSinceLastPaint));
   }
   if (aFlags & nsIPresShell::PAINT_COMPOSITE) {
     nsCOMPtr<nsIRunnable> ev =
       new DelayedFireDOMPaintEvent(this, &mUndeliveredInvalidateRequestsBeforeLastPaint,
                                    aTransactionId, aTimeStamp);
     nsContentUtils::AddScriptRunner(ev);
   }
 
--- a/layout/base/nsPresContext.h
+++ b/layout/base/nsPresContext.h
@@ -105,32 +105,16 @@ struct nsAutoLayoutPhase;
 enum nsLayoutPhase {
   eLayoutPhase_Paint,
   eLayoutPhase_Reflow,
   eLayoutPhase_FrameC,
   eLayoutPhase_COUNT
 };
 #endif
 
-class nsInvalidateRequestList {
-public:
-  struct Request {
-    nsRect   mRect;
-    uint32_t mFlags;
-  };
-
-  void TakeFrom(nsInvalidateRequestList* aList)
-  {
-    mRequests.AppendElements(mozilla::Move(aList->mRequests));
-  }
-  bool IsEmpty() { return mRequests.IsEmpty(); }
-
-  nsTArray<Request> mRequests;
-};
-
 /* Used by nsPresContext::HasAuthorSpecifiedRules */
 #define NS_AUTHOR_SPECIFIED_BACKGROUND      (1 << 0)
 #define NS_AUTHOR_SPECIFIED_BORDER          (1 << 1)
 #define NS_AUTHOR_SPECIFIED_PADDING         (1 << 2)
 #define NS_AUTHOR_SPECIFIED_TEXT_SHADOW     (1 << 3)
 
 class nsRootPresContext;
 
@@ -966,23 +950,23 @@ public:
   void FlushCounterStyles();
   void RebuildCounterStyles(); // asynchronously
 
   // Ensure that it is safe to hand out CSS rules outside the layout
   // engine by ensuring that all CSS style sheets have unique inners
   // and, if necessary, synchronously rebuilding all style data.
   void EnsureSafeToHandOutCSSRules();
 
-  void NotifyInvalidation(const nsRect& aRect, uint32_t aFlags);
+  void NotifyInvalidation(const nsRect& aRect);
   // aRect is in device pixels
-  void NotifyInvalidation(const nsIntRect& aRect, uint32_t aFlags);
+  void NotifyInvalidation(const nsIntRect& aRect);
   // aFlags are nsIPresShell::PAINT_ flags
   void NotifyDidPaintForSubtree(uint32_t aFlags, uint64_t aTransactionId = 0,
                                 const mozilla::TimeStamp& aTimeStamp = mozilla::TimeStamp());
-  void FireDOMPaintEvent(nsInvalidateRequestList* aList, uint64_t aTransactionId,
+  void FireDOMPaintEvent(nsTArray<nsRect>* aList, uint64_t aTransactionId,
                          mozilla::TimeStamp aTimeStamp = mozilla::TimeStamp());
 
   // Callback for catching invalidations in ContainerLayers
   // Passed to LayerProperties::ComputeDifference
   static void NotifySubDocInvalidation(mozilla::layers::ContainerLayer* aContainer,
                                        const nsIntRegion& aRegion);
   void SetNotifySubDocInvalidationData(mozilla::layers::ContainerLayer* aContainer);
   static void ClearNotifySubDocInvalidationData(mozilla::layers::ContainerLayer* aContainer);
@@ -1298,18 +1282,18 @@ protected:
 
   nsCOMPtr<nsITheme> mTheme;
   nsCOMPtr<nsILanguageAtomService> mLangService;
   nsCOMPtr<nsIPrintSettings> mPrintSettings;
   nsCOMPtr<nsITimer>    mPrefChangedTimer;
 
   FramePropertyTable    mPropertyTable;
 
-  nsInvalidateRequestList mInvalidateRequestsSinceLastPaint;
-  nsInvalidateRequestList mUndeliveredInvalidateRequestsBeforeLastPaint;
+  nsTArray<nsRect> mInvalidateRequestsSinceLastPaint;
+  nsTArray<nsRect> mUndeliveredInvalidateRequestsBeforeLastPaint;
 
   // text performance metrics
   nsAutoPtr<gfxTextPerfMetrics>   mTextPerf;
 
   nsAutoPtr<gfxMissingFontRecorder> mMissingFonts;
 
   nsRect                mVisibleArea;
   nsSize                mPageSize;
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -2252,17 +2252,17 @@ already_AddRefed<LayerManager> nsDisplay
         nsIntRect bounds = invalid.GetBounds();
         nsRect rect(presContext->DevPixelsToAppUnits(bounds.x),
                     presContext->DevPixelsToAppUnits(bounds.y),
                     presContext->DevPixelsToAppUnits(bounds.width),
                     presContext->DevPixelsToAppUnits(bounds.height));
         if (shouldInvalidate) {
           view->GetViewManager()->InvalidateViewNoSuppression(view, rect);
         }
-        presContext->NotifyInvalidation(bounds, 0);
+        presContext->NotifyInvalidation(bounds);
       }
     } else if (shouldInvalidate) {
       view->GetViewManager()->InvalidateView(view);
     }
   }
 
   layerManager->SetUserData(&gLayerManagerLayerBuilder, oldBuilder);
   return layerManager.forget();