Bug 1393116 - Only fire resize event if size actually changed draft
authorangelsl <angelsl@in04.sg>
Sat, 09 Sep 2017 00:49:43 +0800
changeset 676292 3013ce1655c253a0b43a3842e59496e74ccde8ec
parent 676291 3002b4077846d98c44df2db3159b0486bbb142dc
child 734910 7c0303da4e5c4a5efc889395c262129a1d10297f
push id83463
push userbmo:angelsl@in04.sg
push dateSat, 07 Oct 2017 08:11:25 +0000
bugs1393116
milestone57.0a1
Bug 1393116 - Only fire resize event if size actually changed MozReview-Commit-ID: 7ek1D9P81Gb
layout/base/PresShell.cpp
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -1972,16 +1972,17 @@ PresShell::ResizeReflowIgnoreOverride(ns
     if (wm.IsVertical()) {
       targetWidth = NS_UNCONSTRAINEDSIZE;
     } else {
       targetHeight = NS_UNCONSTRAINEDSIZE;
     }
     isBSizeChanging = true;
   }
 
+  nsRect oldVisArea = mPresContext->GetVisibleArea();
   mPresContext->SetVisibleArea(nsRect(0, 0, targetWidth, targetHeight));
 
   RefPtr<nsViewManager> viewManager = mViewManager;
   nsCOMPtr<nsIPresShell> kungFuDeathGrip(this);
 
   if (!GetPresContext()->SuppressingResizeReflow()) {
     // Have to make sure that the content notifications are flushed before we
     // start messing with the frame model; otherwise we can get content doubling.
@@ -2059,17 +2060,17 @@ PresShell::ResizeReflowIgnoreOverride(ns
         mAsyncResizeTimerIsActive = true;
         mAsyncResizeEventTimer->SetTarget(
             mDocument->EventTargetFor(TaskCategory::Other));
         mAsyncResizeEventTimer->InitWithNamedFuncCallback(AsyncResizeEventCallback,
                                                           this, 15,
                                                           nsITimer::TYPE_ONE_SHOT,
                                                           "AsyncResizeEventCallback");
       }
-    } else {
+    } else if (!mPresContext->GetVisibleArea().IsEqualEdges(oldVisArea)) {
       RefPtr<nsRunnableMethod<PresShell>> event = NewRunnableMethod(
         "PresShell::FireResizeEvent", this, &PresShell::FireResizeEvent);
       nsresult rv = mDocument->Dispatch(TaskCategory::Other,
                                         do_AddRef(event));
       if (NS_SUCCEEDED(rv)) {
         mResizeEvent = Move(event);
         SetNeedStyleFlush();
       }