Bug 946449 - Remove unused MozBeforeResize event. r=bz
authorMats Palmgren <matspal@gmail.com>
Thu, 05 Dec 2013 20:03:15 +0000
changeset 173765 aebd77677855992dc918b4ca302ac070ee83de35
parent 173764 895031613c5021d5e796def2bf1e7c0250fa82e3
child 173766 1c645ff95f2c9db5339bcf5bf8df5f914edf8a5a
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs946449
milestone28.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 946449 - Remove unused MozBeforeResize event. r=bz
content/base/src/nsGkAtomList.h
content/events/public/nsEventNameList.h
content/events/test/test_bug602962.xul
layout/base/nsPresShell.cpp
layout/base/nsPresShell.h
widget/BasicEvents.h
--- a/content/base/src/nsGkAtomList.h
+++ b/content/base/src/nsGkAtomList.h
@@ -779,17 +779,16 @@ GK_ATOM(onreadystatechange, "onreadystat
 GK_ATOM(onreceived, "onreceived")
 GK_ATOM(onremoteheld, "onremoteheld")
 GK_ATOM(onremoteresumed, "onremoteresumed")
 GK_ATOM(onretrieving, "onretrieving")
 GK_ATOM(onRequest, "onRequest")
 GK_ATOM(onrequestmediaplaystatus, "onrequestmediaplaystatus")
 GK_ATOM(onreset, "onreset")
 GK_ATOM(onresuming, "onresuming")
-GK_ATOM(onMozBeforeResize, "onMozBeforeResize")
 GK_ATOM(onresize, "onresize")
 GK_ATOM(onscostatuschanged, "onscostatuschanged")
 GK_ATOM(onscroll, "onscroll")
 GK_ATOM(onselect, "onselect")
 GK_ATOM(onsending, "onsending")
 GK_ATOM(onsent, "onsent")
 GK_ATOM(onset, "onset")
 GK_ATOM(onshow, "onshow")
--- a/content/events/public/nsEventNameList.h
+++ b/content/events/public/nsEventNameList.h
@@ -625,20 +625,16 @@ NON_IDL_EVENT(DOMMouseScroll,
               NS_MOUSE_SCROLL,
               EventNameType_HTMLXUL,
               NS_MOUSE_SCROLL_EVENT)
 NON_IDL_EVENT(MozMousePixelScroll,
               NS_MOUSE_PIXEL_SCROLL,
               EventNameType_HTMLXUL,
               NS_MOUSE_SCROLL_EVENT)
                                                 
-NON_IDL_EVENT(MozBeforeResize,
-              NS_BEFORERESIZE_EVENT,
-              EventNameType_None,
-              NS_EVENT)
 NON_IDL_EVENT(open,
               NS_OPEN,
               EventNameType_None,
               NS_EVENT)
 
 NON_IDL_EVENT(dataavailable,
               NS_MEDIARECORDER_DATAAVAILABLE,
               EventNameType_None,
--- a/content/events/test/test_bug602962.xul
+++ b/content/events/test/test_bug602962.xul
@@ -17,17 +17,16 @@ https://bugzilla.mozilla.org/show_bug.cg
 </div>
 </body>
 
 <script class="testbody" type="application/javascript;version=1.8"><![CDATA[
 /** Test for Bug 602962 **/
 var scrollbox, sbo, content;
 var scrollX = 0, scrollY = 0;
 
-var mozBeforeResizeHasFired = false;
 var oldWidth = 0, oldHeight = 0;
 var win = null;
 
 function openWindow() {
   win = window.open("chrome://mochitests/content/chrome/content/events/test/bug602962.xul", "_blank", "width=600,height=600");
 }
 
 function doTest() {
@@ -44,26 +43,19 @@ function doTest() {
   }, false);
 
   oldWidth = win.outerWidth;
   oldHeight = win.outerHeight;
   win.resizeTo(200, 400);
 }
 
 function resize() {
-  win.addEventListener("MozBeforeResize", function() {
-    win.removeEventListener("MozBeforeResize", arguments.callee, false);
-    mozBeforeResizeHasFired = true;
-
-    let x = {}, y = {};
-    sbo.getPosition(x, y);
-    scrollX = x.value, scrollY = y.value;
-    is(scrollX, 200, "Scroll X should not have changed yet");
-    is(scrollY, 0, "Scroll Y should not have changed yet");
-  }, false);
+  let x = {}, y = {};
+  sbo.getPosition(x, y);
+  scrollX = x.value, scrollY = y.value;
 
   win.addEventListener("resize", function() {
     content.style.width = (oldWidth + 400) + "px";
     win.removeEventListener("resize", arguments.callee, true);
     
     setTimeout(function() {
       finish();
     }, 0);
@@ -74,17 +66,16 @@ function resize() {
 
 function finish() {
   if (win.outerWidth != oldWidth ||
       win.outerHeight != oldHeight) {
     // We should eventually get back to the original size.
     setTimeout(finish, 0);
     return;
   }
-  is(mozBeforeResizeHasFired, true, "The MozBeforeResize event should already have fired");
   sbo.scrollBy(scrollX, scrollY);
 
   let x = {}, y = {};
   sbo.getPosition(x, y);
   is(x.value, 200, "Scroll X should have been restored to the value before the resize");
   is(y.value, 0, "Scroll Y should have been restored to the value before the resize");
 
   is(win.outerWidth, oldWidth, "Width should be resized");
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -1912,41 +1912,34 @@ PresShell::ResizeReflowIgnoreOverride(ns
   NS_PRECONDITION(!mIsReflowing, "Shouldn't be in reflow here!");
   NS_PRECONDITION(aWidth != NS_UNCONSTRAINEDSIZE,
                   "shouldn't use unconstrained widths anymore");
   
   // If we don't have a root frame yet, that means we haven't had our initial
   // reflow... If that's the case, and aWidth or aHeight is unconstrained,
   // ignore them altogether.
   nsIFrame* rootFrame = mFrameConstructor->GetRootFrame();
-
   if (!rootFrame && aHeight == NS_UNCONSTRAINEDSIZE) {
     // We can't do the work needed for SizeToContent without a root
     // frame, and we want to return before setting the visible area.
     return NS_ERROR_NOT_AVAILABLE;
   }
 
+  mPresContext->SetVisibleArea(nsRect(0, 0, aWidth, aHeight));
+
+  // There isn't anything useful we can do if the initial reflow hasn't happened.
+  if (!rootFrame) {
+    return NS_OK;
+  }
+
   nsRefPtr<nsViewManager> viewManagerDeathGrip = mViewManager;
-  // Take this ref after viewManager so it'll make sure to go away first
+  // Take this ref after viewManager so it'll make sure to go away first.
   nsCOMPtr<nsIPresShell> kungFuDeathGrip(this);
 
-  if (!mIsDestroying && !mResizeEvent.IsPending() &&
-      !mAsyncResizeTimerIsActive) {
-    FireBeforeResizeEvent();
-  }
-
-  mPresContext->SetVisibleArea(nsRect(0, 0, aWidth, aHeight));
-
-  // There isn't anything useful we can do if the initial reflow hasn't happened
-  rootFrame = mFrameConstructor->GetRootFrame();
-  if (!rootFrame)
-    return NS_OK;
-
-  if (!GetPresContext()->SupressingResizeReflow())
-  {
+  if (!GetPresContext()->SupressingResizeReflow()) {
     // Have to make sure that the content notifications are flushed before we
     // start messing with the frame model; otherwise we can get content doubling.
     mDocument->FlushPendingNotifications(Flush_ContentAndNotify);
 
     // Make sure style is up to date
     {
       nsAutoScriptBlocker scriptBlocker;
       mFrameConstructor->CreateNeededFrames();
@@ -2001,32 +1994,16 @@ PresShell::ResizeReflowIgnoreOverride(ns
       }
     }
   }
 
   return NS_OK; //XXX this needs to be real. MMP
 }
 
 void
-PresShell::FireBeforeResizeEvent()
-{
-  if (mIsDocumentGone)
-    return;
-
-  // Send beforeresize event from here.
-  WidgetEvent event(true, NS_BEFORERESIZE_EVENT);
-
-  nsPIDOMWindow *window = mDocument->GetWindow();
-  if (window) {
-    nsCOMPtr<nsIPresShell> kungFuDeathGrip(this);
-    nsEventDispatcher::Dispatch(window, mPresContext, &event);
-  }
-}
-
-void
 PresShell::FireResizeEvent()
 {
   if (mAsyncResizeTimerIsActive) {
     mAsyncResizeTimerIsActive = false;
     mAsyncResizeEventTimer->Cancel();
   }
   mResizeEvent.Revoke();
 
--- a/layout/base/nsPresShell.h
+++ b/layout/base/nsPresShell.h
@@ -661,17 +661,16 @@ protected:
   // Get the selected item and coordinates in device pixels relative to root
   // document's root view for element, first ensuring the element is onscreen
   void GetCurrentItemAndPositionForElement(nsIDOMElement *aCurrentEl,
                                            nsIContent **aTargetToUse,
                                            mozilla::LayoutDeviceIntPoint& aTargetPt,
                                            nsIWidget *aRootWidget);
 
   void FireResizeEvent();
-  void FireBeforeResizeEvent();
   static void AsyncResizeEventCallback(nsITimer* aTimer, void* aPresShell);
 
   virtual void SynthesizeMouseMove(bool aFromScroll) MOZ_OVERRIDE;
 
   PresShell* GetRootPresShell();
 
   nscolor GetDefaultBackgroundColorToDraw();
 
--- a/widget/BasicEvents.h
+++ b/widget/BasicEvents.h
@@ -104,18 +104,17 @@ enum nsEventStructType
 // the window is active. In the latter case, the dispatcher of the event
 // is expected to ensure that the plugin's widget is focused beforehand.
 #define NS_PLUGIN_ACTIVATE               (NS_WINDOW_START + 62)
 #define NS_PLUGIN_FOCUS                  (NS_WINDOW_START + 63)
 
 #define NS_OFFLINE                       (NS_WINDOW_START + 64)
 #define NS_ONLINE                        (NS_WINDOW_START + 65)
 
-// Indicates a resize will occur
-#define NS_BEFORERESIZE_EVENT            (NS_WINDOW_START + 66)
+// NS_BEFORERESIZE_EVENT used to be here (NS_WINDOW_START + 66)
 
 // Indicates that the user is either idle or active
 #define NS_MOZ_USER_IDLE                 (NS_WINDOW_START + 67)
 #define NS_MOZ_USER_ACTIVE               (NS_WINDOW_START + 68)
 
 // The resolution at which a plugin should draw has changed, for
 // example as the result of changing from a HiDPI mode to a non-
 // HiDPI mode.