Bug 1519546, part 4 - Wire up basic EffectsInfo updates in DOM IPC. r=farre
authorRyan Hunt <rhunt@eqrion.net>
Wed, 15 May 2019 15:26:25 -0500
changeset 476561 4658bf615f4b0b4f0979dbb0d4e8c0b4b3b1f3f8
parent 476560 b186cb12283e5293e98e21b1cb0d4ca6fcdb0776
child 476562 7eac769c7c134f53366f9195ecf15589b8d401ff
push id36100
push userapavel@mozilla.com
push dateSun, 02 Jun 2019 22:10:35 +0000
treeherdermozilla-central@6d71d3ca0124 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfarre
bugs1519546
milestone69.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 1519546, part 4 - Wire up basic EffectsInfo updates in DOM IPC. r=farre This commit adds RemoteBrowser::UpdateEffects for updating a remote browser's EffectsInfo over IPC. A following commit will actually use the EffectsInfo for enabling/disabling rendering for a remote browser, and another commit will actually use these IPDL methods. Differential Revision: https://phabricator.services.mozilla.com/D31472
dom/base/nsFrameLoader.cpp
dom/base/nsFrameLoader.h
dom/ipc/BrowserBridgeHost.cpp
dom/ipc/BrowserBridgeHost.h
dom/ipc/BrowserBridgeParent.cpp
dom/ipc/BrowserBridgeParent.h
dom/ipc/BrowserChild.cpp
dom/ipc/BrowserChild.h
dom/ipc/BrowserHost.cpp
dom/ipc/BrowserHost.h
dom/ipc/PBrowser.ipdl
dom/ipc/PBrowserBridge.ipdl
dom/ipc/RemoteBrowser.h
dom/ipc/TabMessageUtils.h
--- a/dom/base/nsFrameLoader.cpp
+++ b/dom/base/nsFrameLoader.cpp
@@ -2779,16 +2779,20 @@ bool nsFrameLoader::TryRemoteBrowser() {
 bool nsFrameLoader::IsRemoteFrame() {
   if (mIsRemoteFrame) {
     MOZ_ASSERT(!GetDocShell(), "Found a remote frame with a DocShell");
     return true;
   }
   return false;
 }
 
+RemoteBrowser* nsFrameLoader::GetRemoteBrowser() const {
+  return mRemoteBrowser;
+}
+
 BrowserParent* nsFrameLoader::GetBrowserParent() const {
   if (!mRemoteBrowser) {
     return nullptr;
   }
   RefPtr<BrowserHost> browserHost = mRemoteBrowser->AsBrowserHost();
   if (!browserHost) {
     return nullptr;
   }
--- a/dom/base/nsFrameLoader.h
+++ b/dom/base/nsFrameLoader.h
@@ -307,16 +307,18 @@ class nsFrameLoader final : public nsStu
   /**
    * Returns whether this frame is a remote frame.
    *
    * This is true for either a top-level remote browser in the parent process,
    * or a remote subframe in the child process.
    */
   bool IsRemoteFrame();
 
+  mozilla::dom::RemoteBrowser* GetRemoteBrowser() const;
+
   /**
    * Returns the IPDL actor used if this is a top-level remote browser, or null
    * otherwise.
    */
   BrowserParent* GetBrowserParent() const;
 
   /**
    * Returns the IPDL actor used if this is an out-of-process iframe, or null
--- a/dom/ipc/BrowserBridgeHost.cpp
+++ b/dom/ipc/BrowserBridgeHost.cpp
@@ -1,16 +1,18 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* 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/. */
 
 #include "mozilla/dom/BrowserBridgeHost.h"
 
+#include "mozilla/Unused.h"
+
 namespace mozilla {
 namespace dom {
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(BrowserBridgeHost)
   NS_INTERFACE_MAP_ENTRY(nsISupports)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTION(BrowserBridgeHost)
@@ -92,10 +94,18 @@ void BrowserBridgeHost::UpdateDimensions
   CSSSize unscaledSize = devicePixelSize / widgetScale;
   hal::ScreenOrientation orientation = hal::eScreenOrientation_Default;
   DimensionInfo di(unscaledRect, unscaledSize, orientation, clientOffset,
                    chromeOffset);
 
   Unused << mBridge->SendUpdateDimensions(di);
 }
 
+void BrowserBridgeHost::UpdateEffects(EffectsInfo aEffects) {
+  if (!mBridge || mEffectsInfo == aEffects) {
+    return;
+  }
+  mEffectsInfo = aEffects;
+  Unused << mBridge->SendUpdateEffects(mEffectsInfo);
+}
+
 }  // namespace dom
 }  // namespace mozilla
--- a/dom/ipc/BrowserBridgeHost.h
+++ b/dom/ipc/BrowserBridgeHost.h
@@ -45,19 +45,22 @@ class BrowserBridgeHost : public RemoteB
   void ResumeLoad(uint64_t aPendingSwitchId) override;
   void DestroyStart() override;
   void DestroyComplete() override;
 
   bool Show(const ScreenIntSize& aSize, bool aParentIsActive) override;
   void UpdateDimensions(const nsIntRect& aRect,
                         const ScreenIntSize& aSize) override;
 
+  void UpdateEffects(EffectsInfo aInfo) override;
+
  private:
   virtual ~BrowserBridgeHost() = default;
 
   // The IPDL actor for proxying browser operations
   RefPtr<BrowserBridgeChild> mBridge;
+  EffectsInfo mEffectsInfo;
 };
 
 }  // namespace dom
 }  // namespace mozilla
 
 #endif  // mozilla_dom_BrowserBridgeHost_h
--- a/dom/ipc/BrowserBridgeParent.cpp
+++ b/dom/ipc/BrowserBridgeParent.cpp
@@ -149,16 +149,21 @@ IPCResult BrowserBridgeParent::RecvResum
 }
 
 IPCResult BrowserBridgeParent::RecvUpdateDimensions(
     const DimensionInfo& aDimensions) {
   Unused << mBrowserParent->SendUpdateDimensions(aDimensions);
   return IPC_OK();
 }
 
+IPCResult BrowserBridgeParent::RecvUpdateEffects(const EffectsInfo& aEffects) {
+  Unused << mBrowserParent->SendUpdateEffects(aEffects);
+  return IPC_OK();
+}
+
 IPCResult BrowserBridgeParent::RecvRenderLayers(
     const bool& aEnabled, const bool& aForceRepaint,
     const layers::LayersObserverEpoch& aEpoch) {
   Unused << mBrowserParent->SendRenderLayers(aEnabled, aForceRepaint, aEpoch);
   return IPC_OK();
 }
 
 IPCResult BrowserBridgeParent::RecvNavigateByKey(
--- a/dom/ipc/BrowserBridgeParent.h
+++ b/dom/ipc/BrowserBridgeParent.h
@@ -62,16 +62,17 @@ class BrowserBridgeParent : public PBrow
 
   mozilla::ipc::IPCResult RecvShow(const ScreenIntSize& aSize,
                                    const bool& aParentIsActive,
                                    const nsSizeMode& aSizeMode);
   mozilla::ipc::IPCResult RecvLoadURL(const nsCString& aUrl);
   mozilla::ipc::IPCResult RecvResumeLoad(uint64_t aPendingSwitchID);
   mozilla::ipc::IPCResult RecvUpdateDimensions(
       const DimensionInfo& aDimensions);
+  mozilla::ipc::IPCResult RecvUpdateEffects(const EffectsInfo& aEffects);
   mozilla::ipc::IPCResult RecvRenderLayers(const bool& aEnabled,
                                            const bool& aForceRepaint,
                                            const LayersObserverEpoch& aEpoch);
 
   mozilla::ipc::IPCResult RecvNavigateByKey(const bool& aForward,
                                             const bool& aForDocumentNavigation);
 
   mozilla::ipc::IPCResult RecvDispatchSynthesizedMouseEvent(
--- a/dom/ipc/BrowserChild.cpp
+++ b/dom/ipc/BrowserChild.cpp
@@ -2792,16 +2792,21 @@ void BrowserChild::NotifyPainted() {
     // Recording/replaying processes have a compositor but not a remote frame.
     if (!recordreplay::IsRecordingOrReplaying()) {
       SendNotifyCompositorTransaction();
     }
     mNotified = true;
   }
 }
 
+IPCResult BrowserChild::RecvUpdateEffects(const EffectsInfo& aEffects) {
+  mEffectsInfo = aEffects;
+  return IPC_OK();
+}
+
 void BrowserChild::MakeVisible() {
   if (IsVisible()) {
     return;
   }
 
   if (mPuppetWidget) {
     mPuppetWidget->Show(true);
   }
--- a/dom/ipc/BrowserChild.h
+++ b/dom/ipc/BrowserChild.h
@@ -469,16 +469,19 @@ class BrowserChild final : public Browse
   }
 
   hal::ScreenOrientation GetOrientation() const { return mOrientation; }
 
   void SetBackgroundColor(const nscolor& aColor);
 
   void NotifyPainted();
 
+  virtual mozilla::ipc::IPCResult RecvUpdateEffects(
+      const EffectsInfo& aEffects);
+
   void RequestEditCommands(nsIWidget::NativeKeyBindingsType aType,
                            const WidgetKeyboardEvent& aEvent,
                            nsTArray<CommandInt>& aCommands);
 
   /**
    * Signal to this BrowserChild that it should be made visible:
    * activated widget, retained layer tree, etc.  (Respectively,
    * made not visible.)
--- a/dom/ipc/BrowserHost.cpp
+++ b/dom/ipc/BrowserHost.cpp
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* 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/. */
 
 #include "mozilla/dom/BrowserHost.h"
 
+#include "mozilla/Unused.h"
 #include "mozilla/dom/CancelContentJSOptionsBinding.h"
 #include "mozilla/dom/WindowGlobalParent.h"
 
 namespace mozilla {
 namespace dom {
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(BrowserHost)
   NS_INTERFACE_MAP_ENTRY(nsIRemoteTab)
@@ -19,17 +20,19 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTION(BrowserHost, mRoot)
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(BrowserHost)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(BrowserHost)
 
 BrowserHost::BrowserHost(BrowserParent* aParent)
-    : mId(aParent->GetTabId()), mRoot(aParent) {
+    : mId(aParent->GetTabId()),
+      mRoot(aParent),
+      mEffectsInfo{EffectsInfo::FullyHidden()} {
   mRoot->SetBrowserHost(this);
 }
 
 BrowserHost* BrowserHost::GetFrom(nsIRemoteTab* aRemoteTab) {
   return static_cast<BrowserHost*>(aRemoteTab);
 }
 
 mozilla::layers::LayersId BrowserHost::GetLayersId() const {
@@ -70,16 +73,24 @@ bool BrowserHost::Show(const ScreenIntSi
   return mRoot->Show(aSize, aParentIsActive);
 }
 
 void BrowserHost::UpdateDimensions(const nsIntRect& aRect,
                                    const ScreenIntSize& aSize) {
   mRoot->UpdateDimensions(aRect, aSize);
 }
 
+void BrowserHost::UpdateEffects(EffectsInfo aEffects) {
+  if (!mRoot || mEffectsInfo == aEffects) {
+    return;
+  }
+  mEffectsInfo = aEffects;
+  Unused << mRoot->SendUpdateEffects(mEffectsInfo);
+}
+
 /* attribute boolean docShellIsActive; */
 NS_IMETHODIMP
 BrowserHost::GetDocShellIsActive(bool* aDocShellIsActive) {
   if (!mRoot) {
     *aDocShellIsActive = false;
     return NS_OK;
   }
   *aDocShellIsActive = mRoot->GetDocShellIsActive();
--- a/dom/ipc/BrowserHost.h
+++ b/dom/ipc/BrowserHost.h
@@ -84,22 +84,25 @@ class BrowserHost : public RemoteBrowser
   void ResumeLoad(uint64_t aPendingSwitchId) override;
   void DestroyStart() override;
   void DestroyComplete() override;
 
   bool Show(const ScreenIntSize& aSize, bool aParentIsActive) override;
   void UpdateDimensions(const nsIntRect& aRect,
                         const ScreenIntSize& aSize) override;
 
+  void UpdateEffects(EffectsInfo aInfo) override;
+
  private:
   virtual ~BrowserHost() = default;
 
   // The TabID for the root BrowserParent, we cache this so that we can access
   // it after the remote browser has been destroyed
   TabId mId;
   // The root BrowserParent of this remote browser
   RefPtr<BrowserParent> mRoot;
+  EffectsInfo mEffectsInfo;
 };
 
 }  // namespace dom
 }  // namespace mozilla
 
 #endif  // mozilla_dom_BrowserHost_h
--- a/dom/ipc/PBrowser.ipdl
+++ b/dom/ipc/PBrowser.ipdl
@@ -81,16 +81,17 @@ using nsEventStatus from "mozilla/EventF
 using mozilla::Modifiers from "mozilla/EventForwards.h";
 using nsSizeMode from "nsIWidgetListener.h";
 using mozilla::widget::CandidateWindowPosition from "ipc/nsGUIEventIPC.h";
 using class mozilla::NativeEventData from "ipc/nsGUIEventIPC.h";
 using mozilla::FontRange from "ipc/nsGUIEventIPC.h";
 using mozilla::a11y::IAccessibleHolder from "mozilla/a11y/IPCTypes.h";
 using mozilla::OriginAttributes from "mozilla/ipc/BackgroundUtils.h";
 using refcounted class mozilla::dom::BrowsingContext from "mozilla/dom/BrowsingContext.h";
+using mozilla::dom::EffectsInfo from "mozilla/dom/TabMessageUtils.h";
 
 namespace mozilla {
 namespace dom {
 
 struct ShowInfo
 {
   nsString name;
   bool fullscreenAllowed;
@@ -607,16 +608,25 @@ parent:
      */
     async RemoteIsReadyToHandleInputEvents();
 
     /**
      * Child informs the parent that the layer tree is already available.
      */
     async PaintWhileInterruptingJSNoOp(LayersObserverEpoch aEpoch);
 
+child:
+    /**
+     * Parent informs the child of graphical effects that are being applied
+     * to the child browser.
+     */
+    async UpdateEffects(EffectsInfo aEffects);
+
+parent:
+
     /**
      * Sent by the child to the parent to inform it that an update to the
      * dimensions has been requested, likely through win.moveTo or resizeTo
      */
     async SetDimensions(uint32_t aFlags, int32_t aX, int32_t aY, int32_t aCx, int32_t aCy);
 
     nested(inside_sync) sync DispatchWheelEvent(WidgetWheelEvent event);
     nested(inside_sync) sync DispatchMouseEvent(WidgetMouseEvent event);
--- a/dom/ipc/PBrowserBridge.ipdl
+++ b/dom/ipc/PBrowserBridge.ipdl
@@ -10,16 +10,17 @@ include protocol PDocAccessible;
 include DOMTypes;
 
 using ScreenIntSize from "Units.h";
 using nsSizeMode from "nsIWidgetListener.h";
 using mozilla::layers::LayersObserverEpoch from "mozilla/layers/LayersTypes.h";
 using mozilla::layers::LayersId from "mozilla/layers/LayersTypes.h";
 using mozilla::WidgetMouseEvent from "ipc/nsGUIEventIPC.h";
 using mozilla::a11y::IDispatchHolder from "mozilla/a11y/IPCTypes.h";
+using mozilla::dom::EffectsInfo from "mozilla/dom/TabMessageUtils.h";
 
 namespace mozilla {
 namespace dom {
 
 /**
  * A PBrowserBridge connects an iframe/browser in a content process to the
  * PBrowser that manages the embedded content.
  *
@@ -58,16 +59,18 @@ parent:
   async LoadURL(nsCString aSpec);
   async ResumeLoad(uint64_t aPendingSwitchID);
 
   // Out of process rendering.
   async Show(ScreenIntSize size, bool parentIsActive, nsSizeMode sizeMode);
   async UpdateDimensions(DimensionInfo dimensions) compressall;
   async RenderLayers(bool aEnabled, bool aForceRepaint, LayersObserverEpoch aEpoch);
 
+  async UpdateEffects(EffectsInfo aEffects);
+
   /**
    * Navigate by key (Tab/Shift+Tab/F6/Shift+f6).
    */
   async NavigateByKey(bool aForward, bool aForDocumentNavigation);
 
   /**
    * Dispatch the given synthesized mousemove event to the child.
    */
--- a/dom/ipc/RemoteBrowser.h
+++ b/dom/ipc/RemoteBrowser.h
@@ -4,16 +4,17 @@
  * 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_dom_ipc_RemoteBrowser_h
 #define mozilla_dom_ipc_RemoteBrowser_h
 
 #include "mozilla/dom/BrowsingContext.h"
 #include "mozilla/dom/ipc/IdType.h"
+#include "mozilla/dom/EffectsInfo.h"
 #include "mozilla/layers/LayersTypes.h"
 #include "nsILoadContext.h"
 #include "nsISupports.h"
 #include "nsISupportsImpl.h"
 #include "nsIURI.h"
 #include "nsRect.h"
 #include "Units.h"
 
@@ -50,14 +51,16 @@ class RemoteBrowser : public nsISupports
   virtual void LoadURL(nsIURI* aURI) = 0;
   virtual void ResumeLoad(uint64_t aPendingSwitchId) = 0;
   virtual void DestroyStart() = 0;
   virtual void DestroyComplete() = 0;
 
   virtual bool Show(const ScreenIntSize& aSize, bool aParentIsActive) = 0;
   virtual void UpdateDimensions(const nsIntRect& aRect,
                                 const ScreenIntSize& aSize) = 0;
+
+  virtual void UpdateEffects(EffectsInfo aInfo) = 0;
 };
 
 }  // namespace dom
 }  // namespace mozilla
 
 #endif  // mozilla_dom_ipc_RemoteBrowser_h
--- a/dom/ipc/TabMessageUtils.h
+++ b/dom/ipc/TabMessageUtils.h
@@ -9,16 +9,19 @@
 
 #include "ipc/IPCMessageUtils.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/dom/Event.h"
 #include "nsExceptionHandler.h"
 #include "nsIRemoteTab.h"
 #include "nsPIDOMWindow.h"
 #include "nsCOMPtr.h"
+#include "mozilla/dom/EffectsInfo.h"
+#include "mozilla/layers/LayersMessageUtils.h"
+#include "ipc/IPCMessageUtils.h"
 
 namespace mozilla {
 namespace dom {
 class Event;
 
 struct RemoteDOMEvent {
   // Make sure to set the owner after deserializing.
   RefPtr<Event> mEvent;
@@ -68,11 +71,25 @@ struct ParamTraits<UIStateChangeType>
 
 template <>
 struct ParamTraits<nsIRemoteTab::NavigationType>
     : public ContiguousEnumSerializerInclusive<
           nsIRemoteTab::NavigationType,
           nsIRemoteTab::NavigationType::NAVIGATE_BACK,
           nsIRemoteTab::NavigationType::NAVIGATE_URL> {};
 
+template <>
+struct ParamTraits<mozilla::dom::EffectsInfo> {
+  typedef mozilla::dom::EffectsInfo paramType;
+
+  static void Write(Message* aMsg, const paramType& aParam) {
+    WriteParam(aMsg, aParam.mVisible);
+  }
+
+  static bool Read(const Message* aMsg, PickleIterator* aIter,
+                   paramType* aResult) {
+    return ReadParam(aMsg, aIter, &aResult->mVisible);
+  }
+};
+
 }  // namespace IPC
 
 #endif  // TABMESSAGE_UTILS_H