Bug 1524980 - Use RemoteFrameChild if present in nsFocusManager::Focus(). r=nika
authorHenri Sivonen <hsivonen@hsivonen.fi>
Tue, 05 Mar 2019 19:33:52 +0000
changeset 520367 627cd6785c62546797d2859a6ff3ea2a50c61df0
parent 520366 ed8a0908ddf00371f6f629954116fcf2bc6950b1
child 520368 273f979acb0629be9ad8783b488921ba9e92554d
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnika
bugs1524980
milestone67.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 1524980 - Use RemoteFrameChild if present in nsFocusManager::Focus(). r=nika Depends on D21913 Differential Revision: https://phabricator.services.mozilla.com/D21927
dom/base/nsFocusManager.cpp
dom/ipc/PRemoteFrame.ipdl
dom/ipc/RemoteFrameChild.cpp
dom/ipc/RemoteFrameChild.h
dom/ipc/RemoteFrameParent.cpp
dom/ipc/RemoteFrameParent.h
--- a/dom/base/nsFocusManager.cpp
+++ b/dom/base/nsFocusManager.cpp
@@ -1847,16 +1847,22 @@ void nsFocusManager::Focus(nsPIDOMWindow
           objectFrameWidget->SetFocus(false);
 
         // if the object being focused is a remote browser, activate remote
         // content
         if (TabParent* remote = TabParent::GetFrom(aElement)) {
           remote->Activate();
           LOGFOCUS(("Remote browser activated"));
         }
+
+        // Same as above but for out-of-process iframes
+        if (RemoteFrameChild* rfc = RemoteFrameChild::GetFrom(aElement)) {
+          rfc->Activate();
+          LOGFOCUS(("Out-of-process iframe activated"));
+        }
       }
 
       IMEStateManager::OnChangeFocus(presContext, aElement,
                                      GetFocusMoveActionCause(aFlags));
 
       // as long as this focus wasn't because a window was raised, update the
       // commands
       // XXXndeakin P2 someone could adjust the focus during the update
--- a/dom/ipc/PRemoteFrame.ipdl
+++ b/dom/ipc/PRemoteFrame.ipdl
@@ -37,12 +37,17 @@ parent:
   async UpdateDimensions(DimensionInfo dimensions) compressall;
   async RenderLayers(bool aEnabled, bool aForceRepaint, LayersObserverEpoch aEpoch);
 
   /**
    * Navigate by key (Tab/Shift+Tab/F6/Shift+f6).
    */
   async NavigateByKey(bool aForward, bool aForDocumentNavigation);
 
+  /**
+   * Sending an activate message moves focus to the iframe.
+   */
+  async Activate();
+
 };
 
 }  // namespace dom
 }  // namespace mozilla
--- a/dom/ipc/RemoteFrameChild.cpp
+++ b/dom/ipc/RemoteFrameChild.cpp
@@ -75,16 +75,18 @@ void RemoteFrameChild::UpdateDimensions(
   Unused << SendUpdateDimensions(di);
 }
 
 void RemoteFrameChild::NavigateByKey(bool aForward,
                                      bool aForDocumentNavigation) {
   Unused << SendNavigateByKey(aForward, aForDocumentNavigation);
 }
 
+void RemoteFrameChild::Activate() { Unused << SendActivate(); }
+
 /*static*/
 RemoteFrameChild* RemoteFrameChild::GetFrom(nsFrameLoader* aFrameLoader) {
   if (!aFrameLoader) {
     return nullptr;
   }
   return aFrameLoader->GetRemoteFrameChild();
 }
 
--- a/dom/ipc/RemoteFrameChild.h
+++ b/dom/ipc/RemoteFrameChild.h
@@ -31,16 +31,18 @@ class RemoteFrameChild : public PRemoteF
                                                    const TabContext& aContext,
                                                    const nsString& aRemoteType);
 
   void UpdateDimensions(const nsIntRect& aRect,
                         const mozilla::ScreenIntSize& aSize);
 
   void NavigateByKey(bool aForward, bool aForDocumentNavigation);
 
+  void Activate();
+
   static RemoteFrameChild* GetFrom(nsFrameLoader* aFrameLoader);
 
   static RemoteFrameChild* GetFrom(nsIContent* aContent);
 
  protected:
   friend class PRemoteFrameChild;
 
   mozilla::ipc::IPCResult RecvSetLayersId(
--- a/dom/ipc/RemoteFrameParent.cpp
+++ b/dom/ipc/RemoteFrameParent.cpp
@@ -112,14 +112,19 @@ IPCResult RemoteFrameParent::RecvRenderL
 }
 
 IPCResult RemoteFrameParent::RecvNavigateByKey(
     const bool& aForward, const bool& aForDocumentNavigation) {
   Unused << mTabParent->SendNavigateByKey(aForward, aForDocumentNavigation);
   return IPC_OK();
 }
 
+IPCResult RemoteFrameParent::RecvActivate() {
+  mTabParent->Activate();
+  return IPC_OK();
+}
+
 void RemoteFrameParent::ActorDestroy(ActorDestroyReason aWhy) {
   mIPCOpen = false;
 }
 
 }  // namespace dom
 }  // namespace mozilla
--- a/dom/ipc/RemoteFrameParent.h
+++ b/dom/ipc/RemoteFrameParent.h
@@ -41,16 +41,18 @@ class RemoteFrameParent : public PRemote
       const DimensionInfo& aDimensions);
   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 RecvActivate();
+
   void ActorDestroy(ActorDestroyReason aWhy) override;
 
  private:
   ~RemoteFrameParent();
 
   RefPtr<TabParent> mTabParent;
   bool mIPCOpen;
 };