Bug 1137944 - Simplify the api associated with hiding e10s plugin widgets. r=roc
authorJim Mathies <jmathies@mozilla.com>
Thu, 03 Sep 2015 10:01:33 -0500
changeset 293291 0325cf8f3cdab4bf1f682423a71bb21228a95cc5
parent 293290 174ee19829ecbd27412eb58fc808ef889fa34665
child 293292 b4711fa5f7348a391f19fbab240c16339d3001b1
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1137944
milestone43.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 1137944 - Simplify the api associated with hiding e10s plugin widgets. r=roc
gfx/layers/ipc/CompositorChild.cpp
gfx/layers/ipc/CompositorChild.h
gfx/layers/ipc/CompositorParent.cpp
gfx/layers/ipc/PCompositor.ipdl
widget/nsBaseWidget.cpp
widget/nsIWidget.h
--- a/gfx/layers/ipc/CompositorChild.cpp
+++ b/gfx/layers/ipc/CompositorChild.cpp
@@ -302,18 +302,16 @@ CompositorChild::RecvUpdatePluginConfigu
 
       // visible state - updated after clipping, prior to invalidating
       rv = widget->Show(isVisible);
       NS_ASSERTION(NS_SUCCEEDED(rv), "widget call failure");
 
       // Handle invalidation, this can be costly, avoid if it is not needed.
       if (isVisible) {
         // invalidate region (widget origin)
-        gfx::IntRect bounds = aPlugins[pluginsIdx].bounds();
-        gfx::IntRect rect(0, 0, bounds.width, bounds.height);
 #if defined(XP_WIN)
         // Work around for flash's crummy sandbox. See bug 762948. This call
         // digs down into the window hirearchy, invalidating regions on
         // windows owned by other processes.
         mozilla::widget::WinUtils::InvalidatePluginAsWorkaround(widget, visibleBounds);
 #else
         rv = widget->Invalidate(visibleBounds);
         NS_ASSERTION(NS_SUCCEEDED(rv), "widget call failure");
@@ -325,26 +323,26 @@ CompositorChild::RecvUpdatePluginConfigu
   // Any plugins we didn't update need to be hidden, as they are
   // not associated with visible content.
   nsIWidget::UpdateRegisteredPluginWindowVisibility((uintptr_t)parent, visiblePluginIds);
   return true;
 #endif // !defined(XP_WIN) && !defined(MOZ_WIDGET_GTK)
 }
 
 bool
-CompositorChild::RecvUpdatePluginVisibility(const uintptr_t& aOwnerWidget,
-                                            nsTArray<uintptr_t>&& aVisibleIdList)
+CompositorChild::RecvHideAllPlugins(const uintptr_t& aParentWidget)
 {
 #if !defined(XP_WIN) && !defined(MOZ_WIDGET_GTK)
-  NS_NOTREACHED("CompositorChild::RecvUpdatePluginVisibility calls "
+  NS_NOTREACHED("CompositorChild::RecvHideAllPlugins calls "
                 "unexpected on this platform.");
   return false;
 #else
   MOZ_ASSERT(NS_IsMainThread());
-  nsIWidget::UpdateRegisteredPluginWindowVisibility(aOwnerWidget, aVisibleIdList);
+  nsTArray<uintptr_t> list;
+  nsIWidget::UpdateRegisteredPluginWindowVisibility(aParentWidget, list);
   return true;
 #endif // !defined(XP_WIN) && !defined(MOZ_WIDGET_GTK)
 }
 
 bool
 CompositorChild::RecvDidComposite(const uint64_t& aId, const uint64_t& aTransactionId,
                                   const TimeStamp& aCompositeStart,
                                   const TimeStamp& aCompositeEnd)
--- a/gfx/layers/ipc/CompositorChild.h
+++ b/gfx/layers/ipc/CompositorChild.h
@@ -85,18 +85,17 @@ public:
   RecvOverfill(const uint32_t &aOverfill) override;
 
   virtual bool
   RecvUpdatePluginConfigurations(const nsIntPoint& aContentOffset,
                                  const nsIntRegion& aVisibleRegion,
                                  nsTArray<PluginWindowData>&& aPlugins) override;
 
   virtual bool
-  RecvUpdatePluginVisibility(const uintptr_t& aOwnerWidget,
-                             nsTArray<uintptr_t>&& aWindowList) override;
+  RecvHideAllPlugins(const uintptr_t& aParentWidget) override;
 
   /**
    * Request that the parent tell us when graphics are ready on GPU.
    * When we get that message, we bounce it to the TabParent via
    * the TabChild
    * @param tabChild The object to bounce the note to.  Non-NULL.
    */
   void RequestNotifyAfterRemotePaint(TabChild* aTabChild);
--- a/gfx/layers/ipc/CompositorParent.cpp
+++ b/gfx/layers/ipc/CompositorParent.cpp
@@ -1997,20 +1997,18 @@ UpdatePluginWindowState(uint64_t aId)
                           !lts.mRoot->GetParent();
 
   if (shouldComposePlugin) {
     if (!lts.mPluginData.Length()) {
       // We will pass through here in cases where the previous shadow layer
       // tree contained visible plugins and the new tree does not. All we need
       // to do here is hide the plugins for the old tree, so don't waste time
       // calculating clipping.
-      nsTArray<uintptr_t> aVisibleIdList;
       uintptr_t parentWidget = (uintptr_t)lts.mParent->GetWidget();
-      unused << lts.mParent->SendUpdatePluginVisibility(parentWidget,
-                                                        aVisibleIdList);
+      unused << lts.mParent->SendHideAllPlugins(parentWidget);
       lts.mUpdatedPluginDataAvailable = false;
       return;
     }
 
     // Retrieve the offset and visible region of the layer that hosts
     // the plugins, CompositorChild needs these in calculating proper
     // plugin clipping.
     LayerTransactionParent* layerTree = lts.mLayerTree;
@@ -2025,28 +2023,20 @@ UpdatePluginWindowState(uint64_t aId)
                                                       lts.mPluginData);
         lts.mUpdatedPluginDataAvailable = false;
       } else {
         shouldHidePlugin = true;
       }
     }
   }
 
-  // Hide all plugins, this remote layer tree is no longer active
+  // Hide all of our plugins, this remote layer tree is no longer active.
   if (shouldHidePlugin) {
-    // hide all the plugins
-    for (uint32_t pluginsIdx = 0; pluginsIdx < lts.mPluginData.Length();
-         pluginsIdx++) {
-      lts.mPluginData[pluginsIdx].visible() = false;
-    }
-    nsIntPoint offset;
-    nsIntRegion region;
-    unused << lts.mParent->SendUpdatePluginConfigurations(offset,
-                                                          region,
-                                                          lts.mPluginData);
+    uintptr_t parentWidget = (uintptr_t)lts.mParent->GetWidget();
+    unused << lts.mParent->SendHideAllPlugins(parentWidget);
     // Clear because there's no recovering from this until we receive
     // new shadow layer plugin data in ShadowLayersUpdated.
     lts.mPluginData.Clear();
   }
 }
 #endif // #if defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
 
 void
--- a/gfx/layers/ipc/PCompositor.ipdl
+++ b/gfx/layers/ipc/PCompositor.ipdl
@@ -65,21 +65,20 @@ child:
    * application on the widgets. Used on Windows and Linux in managing
    * plugin widgets.
    */
   async UpdatePluginConfigurations(IntPoint aContentOffset,
                                    nsIntRegion aVisibleRegion,
                                    PluginWindowData[] aPlugins);
 
   /**
-   * Sets the list of currently visible plugin windows based on a
-   * list of plugin window ids.
+   * Hides all registered plugin widgets associated with a particular chrome
+   * widget.
    */
-  async UpdatePluginVisibility(uintptr_t aOwnerWidget,
-                               uintptr_t[] aVisibleIdList);
+  async HideAllPlugins(uintptr_t aParentWidget);
 
   /**
    * Drop any buffers that might be retained on the child compositor
    * side.
    */
   async ClearCachedResources(uint64_t id);
 
 parent:
--- a/widget/nsBaseWidget.cpp
+++ b/widget/nsBaseWidget.cpp
@@ -1865,52 +1865,52 @@ nsIWidget::LookupRegisteredPluginWindow(
   return widget;
 #endif
 }
 
 #if defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
 struct VisEnumContext {
   uintptr_t parentWidget;
   const nsTArray<uintptr_t>* list;
+  bool widgetVisibilityFlag;
 };
 
 static PLDHashOperator
 RegisteredPluginEnumerator(const void* aWindowId, nsIWidget* aWidget, void* aUserArg)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(aWindowId);
   MOZ_ASSERT(aWidget);
   MOZ_ASSERT(aUserArg);
 
   if (!aWidget->Destroyed()) {
     VisEnumContext* pctx = static_cast<VisEnumContext*>(aUserArg);
-    if ((uintptr_t)aWidget->GetParent() == pctx->parentWidget &&
-        !pctx->list->Contains((uintptr_t)aWindowId)) {
-      aWidget->Show(false);
+    if ((uintptr_t)aWidget->GetParent() == pctx->parentWidget) {
+      aWidget->Show(pctx->list->Contains((uintptr_t)aWindowId));
     }
   }
   return PLDHashOperator::PL_DHASH_NEXT;
 }
 #endif
 
 // static
 void
 nsIWidget::UpdateRegisteredPluginWindowVisibility(uintptr_t aOwnerWidget,
-                                                  nsTArray<uintptr_t>& aVisibleList)
+                                                  nsTArray<uintptr_t>& aPluginIds)
 {
 #if !defined(XP_WIN) && !defined(MOZ_WIDGET_GTK)
   NS_NOTREACHED("nsBaseWidget::UpdateRegisteredPluginWindowVisibility not implemented!");
   return;
 #else
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_ASSERT(sPluginWidgetList);
   // Our visible list is associated with a compositor which is associated with
   // a specific top level window. We hand the parent widget in here so the
   // enumerator can skip the plugin widgets owned by other top level windows.
-  VisEnumContext ctx = { aOwnerWidget, &aVisibleList };
+  VisEnumContext ctx = { aOwnerWidget, &aPluginIds };
   sPluginWidgetList->EnumerateRead(RegisteredPluginEnumerator, static_cast<void*>(&ctx));
 #endif
 }
 
 already_AddRefed<mozilla::gfx::SourceSurface>
 nsIWidget::SnapshotWidgetOnScreen()
 {
   // This is only supported on a widget with a compositor.
--- a/widget/nsIWidget.h
+++ b/widget/nsIWidget.h
@@ -1019,17 +1019,17 @@ class nsIWidget : public nsISupports {
      * Iterates across the list of registered plugin widgets and updates thier
      * visibility based on which plugins are included in the 'visible' list.
      *
      * The compositor knows little about tabs, but it does know which plugin
      * widgets are currently included in the visible layer tree. It calls this
      * helper to hide widgets it knows nothing about.
      */
     static void UpdateRegisteredPluginWindowVisibility(uintptr_t aOwnerWidget,
-                                                       nsTArray<uintptr_t>& aVisibleList);
+                                                       nsTArray<uintptr_t>& aPluginIds);
 
     /**
      * Set the shadow style of the window.
      *
      * Ignored on child widgets and on non-Mac platforms.
      */
     NS_IMETHOD SetWindowShadowStyle(int32_t aStyle) = 0;