Bug 1095754 - Rather than apply geometry updates to plugins in the content process, collect updates and stash them in the shadow layer forwarder so that on the next composite, they update with the remote layer tree. r=roc
authorJim Mathies <jmathies@mozilla.com>
Thu, 29 Jan 2015 13:41:54 -0600
changeset 226584 69c19887d7874e97ae3411b288c6161056f02b71
parent 226583 55d0da4cbed3636454baf30667e3427877a6867e
child 226585 905d21993e31159406afa7aecfeb118e140a59b1
push id28200
push userkwierso@gmail.com
push dateThu, 29 Jan 2015 23:01:46 +0000
treeherdermozilla-central@4380ed39de3a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1095754
milestone38.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 1095754 - Rather than apply geometry updates to plugins in the content process, collect updates and stash them in the shadow layer forwarder so that on the next composite, they update with the remote layer tree. r=roc
layout/base/nsLayoutUtils.cpp
layout/base/nsPresContext.cpp
layout/base/nsPresContext.h
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -3247,17 +3247,27 @@ nsLayoutUtils::PaintFrame(nsRenderingCon
   if (builder.WillComputePluginGeometry()) {
     rootPresContext->ComputePluginGeometryUpdates(aFrame, &builder, &list);
 
     // We're not going to get a WillPaintWindow event here if we didn't do
     // widget invalidation, so just apply the plugin geometry update here instead.
     // We could instead have the compositor send back an equivalent to WillPaintWindow,
     // but it should be close enough to now not to matter.
     if (layerManager && !layerManager->NeedsWidgetInvalidation()) {
-      rootPresContext->ApplyPluginGeometryUpdates();
+#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK)
+      if (XRE_GetProcessType() == GeckoProcessType_Content) {
+        // If this is a remotely managed widget (PluginWidgetProxy in content)
+        // store this information in the compositor, which ships this
+        // over to chrome for application when we paint.
+        rootPresContext->CollectPluginGeometryUpdates(layerManager);
+      } else
+#endif
+      {
+        rootPresContext->ApplyPluginGeometryUpdates();
+      }
     }
 
     // We told the compositor thread not to composite when it received the transaction because
     // we wanted to update plugins first. Schedule the composite now.
     if (layerManager) {
       layerManager->Composite();
     }
   }
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -51,16 +51,17 @@
 #include "mozilla/dom/MediaQueryList.h"
 #include "nsSMILAnimationController.h"
 #include "mozilla/css/ImageLoader.h"
 #include "mozilla/dom/PBrowserParent.h"
 #include "mozilla/dom/TabChild.h"
 #include "mozilla/dom/TabParent.h"
 #include "nsRefreshDriver.h"
 #include "Layers.h"
+#include "ClientLayerManager.h"
 #include "nsIDOMEvent.h"
 #include "gfxPrefs.h"
 #include "nsIDOMChromeWindow.h"
 #include "nsFrameLoader.h"
 #include "mozilla/dom/FontFaceSet.h"
 #include "nsContentUtils.h"
 #include "nsPIWindowRoot.h"
 #include "mozilla/Preferences.h"
@@ -3077,16 +3078,38 @@ nsRootPresContext::ApplyPluginGeometryUp
     SortConfigurations(&closure.mConfigurations);
     widget->ConfigureChildren(closure.mConfigurations);
   }
 #endif  // #ifndef XP_MACOSX
 
   mRegisteredPlugins.EnumerateEntries(PluginDidSetGeometryEnumerator, nullptr);
 }
 
+void
+nsRootPresContext::CollectPluginGeometryUpdates(LayerManager* aLayerManager)
+{
+#ifndef XP_MACOSX
+  // Collect and pass plugin widget configurations down to the compositor
+  // for transmission to the chrome process.
+  NS_ASSERTION(aLayerManager, "layer manager is invalid!");
+  mozilla::layers::ClientLayerManager* clm = aLayerManager->AsClientLayerManager();
+  PluginGetGeometryUpdateClosure closure;
+  mRegisteredPlugins.EnumerateEntries(PluginGetGeometryUpdate, &closure);
+  if (closure.mConfigurations.IsEmpty()) {
+    mRegisteredPlugins.EnumerateEntries(PluginDidSetGeometryEnumerator, nullptr);
+    return;
+  }
+  SortConfigurations(&closure.mConfigurations);
+  if (clm) {
+    clm->StorePluginWidgetConfigurations(closure.mConfigurations);
+  }
+  mRegisteredPlugins.EnumerateEntries(PluginDidSetGeometryEnumerator, nullptr);
+#endif  // #ifndef XP_MACOSX
+}
+
 static void
 NotifyDidPaintForSubtreeCallback(nsITimer *aTimer, void *aClosure)
 {
   nsPresContext* presContext = (nsPresContext*)aClosure;
   nsAutoScriptBlocker blockScripts;
   // This is a fallback if we don't get paint events for some reason
   // so we'll just pretend both layer painting and compositing happened.
   presContext->NotifyDidPaintForSubtree(
--- a/layout/base/nsPresContext.h
+++ b/layout/base/nsPresContext.h
@@ -71,16 +71,17 @@ namespace mozilla {
 class EventStateManager;
 class RestyleManager;
 class CounterStyleManager;
 namespace dom {
 class FontFaceSet;
 }
 namespace layers {
 class ContainerLayer;
+class LayerManager;
 }
 }
 
 // supported values for cached bool types
 enum nsPresContext_CachedBoolPrefType {
   kPresContext_UseDocumentFonts = 1,
   kPresContext_UnderlineLinks
 };
@@ -1478,16 +1479,22 @@ public:
 
   /**
    * Apply the stored plugin geometry updates. This should normally be called
    * in DidPaint so the plugins are moved/clipped immediately after we've
    * updated our window, so they look in sync with our window.
    */
   void ApplyPluginGeometryUpdates();
 
+  /**
+   * Transfer stored plugin geometry updates to the compositor. Called during
+   * reflow, data is shipped over with layer updates. e10s specific.
+   */
+  void CollectPluginGeometryUpdates(mozilla::layers::LayerManager* aLayerManager);
+
   virtual bool IsRoot() MOZ_OVERRIDE { return true; }
 
   /**
    * Increment DOM-modification generation counter to indicate that
    * the DOM has changed in a way that might lead to style changes/
    * reflows/frame creation and destruction.
    */
   void IncrementDOMGeneration() { mDOMGeneration++; }