Backed out changeset 84303d94533c (bug 1328066) for bustage
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Mon, 13 Feb 2017 16:02:32 +0100
changeset 378409 896a380ebbe8889e78e2adbc92647c8738b5ab15
parent 378408 f039f3d3d0731522fc2e5143baadb160e34ab23e
child 378410 6b95aef1e86d730b646cdb43b7552760086b46ad
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1328066
milestone53.0a2
backs out84303d94533c9d5e52acc51b1534aa208e19426b
Backed out changeset 84303d94533c (bug 1328066) for bustage
browser/base/content/tabbrowser.xml
dom/ipc/TabParent.cpp
dom/ipc/TabParent.h
widget/cocoa/nsChildView.mm
widget/nsBaseWidget.cpp
widget/nsBaseWidget.h
widget/windows/nsWindow.cpp
xpfe/appshell/LiveResizeListener.h
xpfe/appshell/moz.build
xpfe/appshell/nsIXULWindow.idl
xpfe/appshell/nsXULWindow.cpp
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -87,16 +87,19 @@
         null
       </field>
       <field name="mCurrentBrowser">
         null
       </field>
       <field name="mProgressListeners">
         []
       </field>
+      <field name="mActiveResizeDisplayportSuppression">
+        null
+      </field>
       <field name="mTabsProgressListeners">
         []
       </field>
       <field name="_tabListeners">
         new Map()
       </field>
       <field name="_tabFilters">
         new Map()
@@ -4907,17 +4910,38 @@
         ]]></body>
       </method>
 
       <method name="observe">
         <parameter name="aSubject"/>
         <parameter name="aTopic"/>
         <parameter name="aData"/>
         <body><![CDATA[
+          let browser;
           switch (aTopic) {
+            case "live-resize-start": {
+              browser = this.mCurrentTab.linkedBrowser;
+              let fl = browser.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader;
+              if (fl && fl.tabParent && !this.mActiveResizeDisplayportSuppression) {
+                fl.tabParent.suppressDisplayport(true);
+                this.mActiveResizeDisplayportSuppression = browser;
+              }
+              break;
+            }
+            case "live-resize-end": {
+              browser = this.mActiveResizeDisplayportSuppression;
+              if (browser) {
+                let fl = browser.QueryInterface(Ci.nsIFrameLoaderOwner).frameLoader;
+                if (fl && fl.tabParent) {
+                  fl.tabParent.suppressDisplayport(false);
+                  this.mActiveResizeDisplayportSuppression = null;
+                }
+              }
+              break;
+            }
             case "contextual-identity-updated": {
               for (let tab of this.tabs) {
                 if (tab.getAttribute("usercontextid") == aData) {
                   ContextualIdentityService.setTabStyle(tab);
                 }
               }
               break;
             }
@@ -4930,16 +4954,18 @@
         ]]></body>
       </method>
 
       <constructor>
         <![CDATA[
           this.mCurrentBrowser = document.getAnonymousElementByAttribute(this, "anonid", "initialBrowser");
           this.mCurrentBrowser.permanentKey = {};
 
+          Services.obs.addObserver(this, "live-resize-start", false);
+          Services.obs.addObserver(this, "live-resize-end", false);
           Services.obs.addObserver(this, "contextual-identity-updated", false);
 
           this.mCurrentTab = this.tabContainer.firstChild;
           const nsIEventListenerService =
             Components.interfaces.nsIEventListenerService;
           let els = Components.classes["@mozilla.org/eventlistenerservice;1"]
                               .getService(nsIEventListenerService);
           els.addSystemEventListener(document, "keydown", this, false);
@@ -5032,16 +5058,18 @@
           // window ID. We switched to a monotonic counter as Date.now() lead
           // to random failures because of colliding IDs.
           return "panel-" + outerID + "-" + (++this._uniquePanelIDCounter);
         ]]></body>
       </method>
 
       <destructor>
         <![CDATA[
+          Services.obs.removeObserver(this, "live-resize-start");
+          Services.obs.removeObserver(this, "live-resize-end");
           Services.obs.removeObserver(this, "contextual-identity-updated");
 
           for (let tab of this.tabs) {
             let browser = tab.linkedBrowser;
             if (browser.registeredOpenURI) {
               this._unifiedComplete.unregisterOpenPage(browser.registeredOpenURI,
                                                        browser.getAttribute("usercontextid") || 0);
               delete browser.registeredOpenURI;
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -3277,28 +3277,16 @@ TabParent::RecvRequestCrossBrowserNaviga
   nsCOMPtr<nsISupports> promise;
   if (NS_FAILED(frameLoader->RequestGroupedHistoryNavigation(aGlobalIndex,
                                                              getter_AddRefs(promise)))) {
     return IPC_FAIL_NO_REASON(this);
   }
   return IPC_OK();
 }
 
-void
-TabParent::LiveResizeStarted()
-{
-  SuppressDisplayport(true);
-}
-
-void
-TabParent::LiveResizeStopped()
-{
-  SuppressDisplayport(false);
-}
-
 NS_IMETHODIMP
 FakeChannel::OnAuthAvailable(nsISupports *aContext, nsIAuthInformation *aAuthInfo)
 {
   nsAuthInformationHolder* holder =
     static_cast<nsAuthInformationHolder*>(aAuthInfo);
 
   if (!net::gNeckoChild->SendOnAuthAvailable(mCallbackId,
                                              holder->User(),
--- a/dom/ipc/TabParent.h
+++ b/dom/ipc/TabParent.h
@@ -3,17 +3,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_tabs_TabParent_h
 #define mozilla_tabs_TabParent_h
 
 #include "js/TypeDecls.h"
-#include "LiveResizeListener.h"
 #include "mozilla/ContentCache.h"
 #include "mozilla/dom/AudioChannelBinding.h"
 #include "mozilla/dom/ipc/IdType.h"
 #include "mozilla/dom/PBrowserParent.h"
 #include "mozilla/dom/PContent.h"
 #include "mozilla/dom/PFilePickerParent.h"
 #include "mozilla/dom/TabContext.h"
 #include "mozilla/EventForwards.h"
@@ -87,17 +86,16 @@ class TabParent final : public PBrowserP
                       , public nsITabParent
                       , public nsIAuthPromptProvider
                       , public nsISecureBrowserUI
                       , public nsIKeyEventInPluginCallback
                       , public nsSupportsWeakReference
                       , public TabContext
                       , public nsAPostRefreshObserver
                       , public nsIWebBrowserPersistable
-                      , public LiveResizeListener
 {
   typedef mozilla::dom::ClonedMessageData ClonedMessageData;
 
   virtual ~TabParent();
 
 public:
   // Helper class for ContentParent::RecvCreateWindow.
   struct AutoUseNewTab;
@@ -590,20 +588,16 @@ public:
                                       float aVolume,
                                       bool aMuted);
   bool SetRenderFrame(PRenderFrameParent* aRFParent);
   bool GetRenderFrameInfo(TextureFactoryIdentifier* aTextureFactoryIdentifier,
                           uint64_t* aLayersId);
 
   mozilla::ipc::IPCResult RecvEnsureLayersConnected() override;
 
-  // LiveResizeListener implementation
-  void LiveResizeStarted() override;
-  void LiveResizeStopped() override;
-
 protected:
   bool ReceiveMessage(const nsString& aMessage,
                       bool aSync,
                       ipc::StructuredCloneData* aData,
                       mozilla::jsipc::CpowHolder* aCpows,
                       nsIPrincipal* aPrincipal,
                       nsTArray<ipc::StructuredCloneData>* aJSONRetVal = nullptr);
 
--- a/widget/cocoa/nsChildView.mm
+++ b/widget/cocoa/nsChildView.mm
@@ -3645,34 +3645,34 @@ NSEvent* gLastDragMouseDownEvent = nil;
 {
   return [[self window] isKindOfClass:[BaseWindow class]] &&
          [(BaseWindow*)[self window] mainChildView] == self &&
          [(BaseWindow*)[self window] drawsContentsIntoWindowFrame];
 }
 
 - (void)viewWillStartLiveResize
 {
-  nsCocoaWindow* windowWidget = mGeckoChild ? mGeckoChild->GetXULWindowWidget() : nullptr;
-  if (windowWidget) {
-    windowWidget->NotifyLiveResizeStarted();
-  }
+  nsCOMPtr<nsIObserverService> observerService = mozilla::services::GetObserverService();
+
+  if (!observerService) {
+    return;
+  }
+
+  observerService->NotifyObservers(nullptr, "live-resize-start", nullptr);
 }
 
 - (void)viewDidEndLiveResize
 {
-  // mGeckoChild may legitimately be null here. It should also have been null
-  // in viewWillStartLiveResize, so there's no problem. However if we run into
-  // cases where the windowWidget was non-null in viewWillStartLiveResize but
-  // is null here, that might be problematic because we might get stuck with
-  // a content process that has the displayport suppressed. If that scenario
-  // arises (I'm not sure that it does) we will need to handle it gracefully.
-  nsCocoaWindow* windowWidget = mGeckoChild ? mGeckoChild->GetXULWindowWidget() : nullptr;
-  if (windowWidget) {
-    windowWidget->NotifyLiveResizeStopped();
-  }
+  nsCOMPtr<nsIObserverService> observerService = mozilla::services::GetObserverService();
+
+  if (!observerService) {
+    return;
+  }
+
+  observerService->NotifyObservers(nullptr, "live-resize-end", nullptr);
 }
 
 - (NSColor*)vibrancyFillColorForThemeGeometryType:(nsITheme::ThemeGeometryType)aThemeGeometryType
 {
   if (!mGeckoChild) {
     return [NSColor whiteColor];
   }
   return mGeckoChild->VibrancyFillColorForThemeGeometryType(aThemeGeometryType);
--- a/widget/nsBaseWidget.cpp
+++ b/widget/nsBaseWidget.cpp
@@ -7,17 +7,16 @@
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/UniquePtr.h"
 #include "mozilla/TextEventDispatcher.h"
 #include "mozilla/TextEventDispatcherListener.h"
 
 #include "mozilla/layers/CompositorBridgeChild.h"
 #include "mozilla/layers/CompositorBridgeParent.h"
 #include "mozilla/layers/ImageBridgeChild.h"
-#include "LiveResizeListener.h"
 #include "nsBaseWidget.h"
 #include "nsDeviceContext.h"
 #include "nsCOMPtr.h"
 #include "nsGfxCIID.h"
 #include "nsWidgetsCID.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIKeyEventInPluginCallback.h"
 #include "nsIScreenManager.h"
@@ -245,17 +244,16 @@ WidgetShutdownObserver::Unregister()
     nsContentUtils::UnregisterShutdownObserver(this);
     mRegistered = false;
   }
 }
 
 void
 nsBaseWidget::Shutdown()
 {
-  NotifyLiveResizeStopped();
   RevokeTransactionIdAllocator();
   DestroyCompositor();
   FreeShutdownObserver();
 #if defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
   if (sPluginWidgetList) {
     delete sPluginWidgetList;
     sPluginWidgetList = nullptr;
   }
@@ -2091,51 +2089,16 @@ nsBaseWidget::UpdateSynthesizedTouchStat
         (float)aPointerOrientation,
         (float)aPointerPressure));
   }
 
   return inputToDispatch;
 }
 
 void
-nsBaseWidget::NotifyLiveResizeStarted()
-{
-  // If we have mLiveResizeListeners already non-empty, we should notify those
-  // listeners that the resize stopped before starting anew. In theory this
-  // should never happen because we shouldn't get nested live resize actions.
-  NotifyLiveResizeStopped();
-  MOZ_ASSERT(mLiveResizeListeners.IsEmpty());
-
-  // If we can get the active tab parent for the current widget, suppress
-  // the displayport on it during the live resize.
-  if (!mWidgetListener) {
-    return;
-  }
-  nsCOMPtr<nsIXULWindow> xulWindow = mWidgetListener->GetXULWindow();
-  if (!xulWindow) {
-    return;
-  }
-  mLiveResizeListeners = xulWindow->GetLiveResizeListeners();
-  for (uint32_t i = 0; i < mLiveResizeListeners.Length(); i++) {
-    mLiveResizeListeners[i]->LiveResizeStarted();
-  }
-}
-
-void
-nsBaseWidget::NotifyLiveResizeStopped()
-{
-  if (!mLiveResizeListeners.IsEmpty()) {
-    for (uint32_t i = 0; i < mLiveResizeListeners.Length(); i++) {
-      mLiveResizeListeners[i]->LiveResizeStopped();
-    }
-    mLiveResizeListeners.Clear();
-  }
-}
-
-void
 nsBaseWidget::RegisterPluginWindowForRemoteUpdates()
 {
 #if !defined(XP_WIN) && !defined(MOZ_WIDGET_GTK)
   NS_NOTREACHED("nsBaseWidget::RegisterPluginWindowForRemoteUpdates not implemented!");
   return;
 #else
   MOZ_ASSERT(NS_IsMainThread());
   void* id = GetNativeData(NS_NATIVE_PLUGIN_ID);
--- a/widget/nsBaseWidget.h
+++ b/widget/nsBaseWidget.h
@@ -32,18 +32,16 @@ const mozilla::gfx::SurfaceFormat kScrol
 #endif
 
 class nsIContent;
 class nsAutoRollup;
 class gfxContext;
 
 namespace mozilla {
 class CompositorVsyncDispatcher;
-class LiveResizeListener;
-
 #ifdef ACCESSIBILITY
 namespace a11y {
 class Accessible;
 }
 #endif
 
 namespace gfx {
 class DrawTarget;
@@ -395,23 +393,16 @@ public:
   static nsIRollupListener* GetActiveRollupListener();
 
   void Shutdown();
 
 #if defined(XP_WIN)
   uint64_t CreateScrollCaptureContainer() override;
 #endif
 
-  // These functions should be called at the start and end of a "live" widget
-  // resize (i.e. when the window contents are repainting during the resize,
-  // such as when the user drags a window border). It will suppress the
-  // displayport during the live resize to avoid unneccessary overpainting.
-  void NotifyLiveResizeStarted();
-  void NotifyLiveResizeStopped();
-
 protected:
   // These are methods for CompositorWidgetWrapper, and should only be
   // accessed from that class. Derived widgets can choose which methods to
   // implement, or none if supporting out-of-process compositing.
   virtual bool PreRender(mozilla::widget::WidgetRenderingContext* aContext) {
     return true;
   }
   virtual void PostRender(mozilla::widget::WidgetRenderingContext* aContext)
@@ -713,21 +704,16 @@ protected:
 
     uint32_t mPresShellID;
     FrameMetrics::ViewID mViewID;
     ZoomConstraints mConstraints;
   };
 
   mozilla::Maybe<InitialZoomConstraints> mInitialZoomConstraints;
 
-  // This points to the resize listeners who have been notified that a live
-  // resize is in progress. This should always be empty when a live-resize is
-  // not in progress.
-  nsTArray<RefPtr<mozilla::LiveResizeListener>> mLiveResizeListeners;
-
 #ifdef DEBUG
 protected:
   static nsAutoString debug_GuiEventToString(mozilla::WidgetGUIEvent* aGuiEvent);
   static bool debug_WantPaintFlashing();
 
   static void debug_DumpInvalidate(FILE* aFileOut,
                                    nsIWidget* aWidget,
                                    const LayoutDeviceIntRect* aRect,
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -5639,17 +5639,23 @@ nsWindow::ProcessMessage(UINT msg, WPARA
 
     case WM_SIZING:
     {
       // When we get WM_ENTERSIZEMOVE we don't know yet if we're in a live
       // resize or move event. Instead we wait for first VM_SIZING message
       // within a ENTERSIZEMOVE to consider this a live resize event.
       if (mResizeState == IN_SIZEMOVE) {
         mResizeState = RESIZING;
-        NotifyLiveResizeStarted();
+        nsCOMPtr<nsIObserverService> observerService =
+          mozilla::services::GetObserverService();
+
+        if (observerService) {
+          observerService->NotifyObservers(nullptr, "live-resize-start",
+                                           nullptr);
+        }
       }
       break;
     }
 
     case WM_MOVING:
       FinishLiveResizing(MOVING);
       if (WinUtils::IsPerMonitorDPIAware()) {
         // Sometimes, we appear to miss a WM_DPICHANGED message while moving
@@ -6066,17 +6072,20 @@ nsWindow::ProcessMessage(UINT msg, WPARA
     return true;
   }
 }
 
 void
 nsWindow::FinishLiveResizing(ResizeState aNewState)
 {
   if (mResizeState == RESIZING) {
-    NotifyLiveResizeStopped();
+    nsCOMPtr<nsIObserverService> observerService = mozilla::services::GetObserverService();
+    if (observerService) {
+      observerService->NotifyObservers(nullptr, "live-resize-end", nullptr);
+    }
   }
   mResizeState = aNewState;
   ForcePresent();
 }
 
 /**************************************************************
  *
  * SECTION: Broadcast messaging
deleted file mode 100644
--- a/xpfe/appshell/LiveResizeListener.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef mozilla_LiveResizeListener_h
-#define mozilla_LiveResizeListener_h
-
-#include "nsISupportsImpl.h"
-
-namespace mozilla {
-
-class LiveResizeListener {
-public:
-  virtual void LiveResizeStarted() = 0;
-  virtual void LiveResizeStopped() = 0;
-
-  NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
-
-protected:
-  virtual ~LiveResizeListener() {}
-};
-
-} // namespace mozilla
-
-#endif // mozilla_LiveResizeListener_h
--- a/xpfe/appshell/moz.build
+++ b/xpfe/appshell/moz.build
@@ -14,17 +14,16 @@ XPIDL_SOURCES += [
     'nsIWindowMediatorListener.idl',
     'nsIXULBrowserWindow.idl',
     'nsIXULWindow.idl',
 ]
 
 XPIDL_MODULE = 'appshell'
 
 EXPORTS += [
-    'LiveResizeListener.h',
     'nsAppShellCID.h',
 ]
 
 UNIFIED_SOURCES += [
     'nsAppShellFactory.cpp',
     'nsAppShellService.cpp',
     'nsAppShellWindowEnumerator.cpp',
     'nsChromeTreeOwner.cpp',
@@ -35,9 +34,9 @@ UNIFIED_SOURCES += [
 ]
 
 LOCAL_INCLUDES += [
     '/dom/base',
 ]
 
 FINAL_LIBRARY = 'xul'
 
-include('/ipc/chromium/chromium-config.mozbuild')
+include('/ipc/chromium/chromium-config.mozbuild')
\ No newline at end of file
--- a/xpfe/appshell/nsIXULWindow.idl
+++ b/xpfe/appshell/nsIXULWindow.idl
@@ -8,29 +8,22 @@
 
 /**
  * The nsIXULWindow
  *
  * When the window is destroyed, it will fire a "xul-window-destroyed"
  * notification through the global observer service.
  */
 
-%{C++
-#include "LiveResizeListener.h"
-#include "nsTArray.h"
-%}
-
 interface nsIDocShell;
 interface nsIDocShellTreeItem;
 interface nsIXULBrowserWindow;
 interface nsITabParent;
 interface mozIDOMWindowProxy;
 
-native LiveResizeListenerArray(nsTArray<RefPtr<mozilla::LiveResizeListener>>);
-
 [scriptable, uuid(d6d7a014-e28d-4c9d-8727-1cf6d870619b)]
 interface nsIXULWindow : nsISupports
 {
   /**
    * The docshell owning the XUL for this window.
    */
   readonly attribute nsIDocShell docShell;
 
@@ -53,18 +46,16 @@ interface nsIXULWindow : nsISupports
    * In multiprocess case we may not have primaryContentShell but
    * primaryTabParent.
    */
   readonly attribute nsITabParent primaryTabParent;
 
   void tabParentAdded(in nsITabParent aTab, in boolean aPrimary);
   void tabParentRemoved(in nsITabParent aTab);
 
-  [noscript,notxpcom] LiveResizeListenerArray getLiveResizeListeners();
-
   /**
    * Tell this window that it has picked up a child XUL window
    * @param aChild the child window being added
    */
   void addChildWindow(in nsIXULWindow aChild);
 
   /**
    * Tell this window that it has lost a child XUL window
--- a/xpfe/appshell/nsXULWindow.cpp
+++ b/xpfe/appshell/nsXULWindow.cpp
@@ -339,27 +339,16 @@ nsXULWindow::TabParentRemoved(nsITabPare
 NS_IMETHODIMP
 nsXULWindow::GetPrimaryTabParent(nsITabParent** aTab)
 {
   nsCOMPtr<nsITabParent> tab = mPrimaryTabParent;
   tab.forget(aTab);
   return NS_OK;
 }
 
-nsTArray<RefPtr<mozilla::LiveResizeListener>>
-nsXULWindow::GetLiveResizeListeners()
-{
-  nsTArray<RefPtr<mozilla::LiveResizeListener>> listeners;
-  if (mPrimaryTabParent) {
-    TabParent* parent = static_cast<TabParent*>(mPrimaryTabParent.get());
-    listeners.AppendElement(parent);
-  }
-  return listeners;
-}
-
 NS_IMETHODIMP nsXULWindow::AddChildWindow(nsIXULWindow *aChild)
 {
   // we're not really keeping track of this right now
   return NS_OK;
 }
 
 NS_IMETHODIMP nsXULWindow::RemoveChildWindow(nsIXULWindow *aChild)
 {