Bug 1535282 - Add logging of content process-level focus changes. r=nika
authorHenri Sivonen <hsivonen@hsivonen.fi>
Thu, 14 Mar 2019 15:55:35 +0000
changeset 521908 ec16cfd2ee8e2998a8d07e8fd3dd5215ba8b4d55
parent 521907 1e165cd680b96372e6eeeea01a9ad3e78a219b01
child 521909 e10b87be35ad65154b1458366ae8c2d929670393
push id10870
push usernbeleuzu@mozilla.com
push dateFri, 15 Mar 2019 20:00:07 +0000
treeherdermozilla-beta@c594aee5b7a4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnika
bugs1535282
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 1535282 - Add logging of content process-level focus changes. r=nika Depends on D22468 Differential Revision: https://phabricator.services.mozilla.com/D23479
dom/base/nsFocusManager.cpp
dom/ipc/TabParent.cpp
--- a/dom/base/nsFocusManager.cpp
+++ b/dom/base/nsFocusManager.cpp
@@ -1630,23 +1630,23 @@ bool nsFocusManager::Blur(nsPIDOMWindowO
         }
       }
     }
 
     // if the object being blurred is a remote browser, deactivate remote
     // content
     if (TabParent* remote = TabParent::GetFrom(element)) {
       remote->Deactivate();
-      LOGFOCUS(("Remote browser deactivated"));
+      LOGFOCUS(("Remote browser deactivated %p", remote));
     }
 
     // Same as above but for out-of-process iframes
     if (BrowserBridgeChild* bbc = BrowserBridgeChild::GetFrom(element)) {
       bbc->Deactivate();
-      LOGFOCUS(("Out-of-process iframe deactivated"));
+      LOGFOCUS(("Out-of-process iframe deactivated %p", bbc));
     }
   }
 
   bool result = true;
   if (sendBlurEvent) {
     // if there is an active window, update commands. If there isn't an active
     // window, then this was a blur caused by the active window being lowered,
     // so there is no need to update the commands
@@ -1851,23 +1851,23 @@ void nsFocusManager::Focus(nsPIDOMWindow
       if (presShell->GetDocument() == aElement->GetComposedDoc()) {
         if (aAdjustWidgets && objectFrameWidget && !sTestMode)
           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"));
+          LOGFOCUS(("Remote browser activated %p", remote));
         }
 
         // Same as above but for out-of-process iframes
         if (BrowserBridgeChild* bbc = BrowserBridgeChild::GetFrom(aElement)) {
           bbc->Activate();
-          LOGFOCUS(("Out-of-process iframe activated"));
+          LOGFOCUS(("Out-of-process iframe activated %p", bbc));
         }
       }
 
       IMEStateManager::OnChangeFocus(presContext, aElement,
                                      GetFocusMoveActionCause(aFlags));
 
       // as long as this focus wasn't because a window was raised, update the
       // commands
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -126,16 +126,21 @@ using namespace mozilla::layers;
 using namespace mozilla::layout;
 using namespace mozilla::services;
 using namespace mozilla::widget;
 using namespace mozilla::jsipc;
 using namespace mozilla::gfx;
 
 using mozilla::Unused;
 
+LazyLogModule gBrowserFocusLog("BrowserFocus");
+
+#define LOGBROWSERFOCUS(args) \
+  MOZ_LOG(gBrowserFocusLog, mozilla::LogLevel::Debug, args)
+
 // The flags passed by the webProgress notifications are 16 bits shifted
 // from the ones registered by webProgressListeners.
 #define NOTIFY_FLAG_SHIFT 16
 
 namespace mozilla {
 namespace dom {
 
 TabParent::LayerToTabParentTable* TabParent::sLayerToTabParentTable = nullptr;
@@ -477,16 +482,18 @@ void TabParent::ActorDestroy(ActorDestro
   if (os) {
     os->NotifyObservers(NS_ISUPPORTS_CAST(nsITabParent*, this),
                         "ipc:browser-destroyed", nullptr);
   }
 }
 
 mozilla::ipc::IPCResult TabParent::RecvMoveFocus(
     const bool& aForward, const bool& aForDocumentNavigation) {
+  LOGBROWSERFOCUS(("RecvMoveFocus %p, aForward: %d, aForDocumentNavigation: %d",
+                   this, aForward, aForDocumentNavigation));
   BrowserBridgeParent* bridgeParent = GetBrowserBridgeParent();
   if (bridgeParent) {
     mozilla::Unused << bridgeParent->SendMoveFocus(aForward,
                                                    aForDocumentNavigation);
     return IPC_OK();
   }
 
   nsCOMPtr<nsIFocusManager> fm = nsFocusManager::GetFocusManager();
@@ -821,22 +828,24 @@ void TabParent::HandleAccessKey(const Wi
     // because the event may be dispatched to it as normal keyboard event.
     // Therefore, we should use local copy to send it.
     WidgetKeyboardEvent localEvent(aEvent);
     Unused << SendHandleAccessKey(localEvent, aCharCodes);
   }
 }
 
 void TabParent::Activate() {
+  LOGBROWSERFOCUS(("Activate %p", this));
   if (!mIsDestroyed) {
     Unused << Manager()->SendActivate(this);
   }
 }
 
 void TabParent::Deactivate() {
+  LOGBROWSERFOCUS(("Deactivate %p", this));
   if (!mIsDestroyed) {
     Unused << Manager()->SendDeactivate(this);
   }
 }
 
 a11y::PDocAccessibleParent* TabParent::AllocPDocAccessibleParent(
     PDocAccessibleParent* aParent, const uint64_t&, const uint32_t&,
     const IAccessibleHolder&) {
@@ -1897,16 +1906,17 @@ mozilla::ipc::IPCResult TabParent::RecvO
   // plugin process of the key event's result.
   bool consumed = (rv == NS_SUCCESS_EVENT_CONSUMED);
   HandledWindowedPluginKeyEvent(aKeyEventData, consumed);
 
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult TabParent::RecvRequestFocus(const bool& aCanRaise) {
+  LOGBROWSERFOCUS(("RecvRequestFocus %p, aCanRaise: %d", this, aCanRaise));
   BrowserBridgeParent* bridgeParent = GetBrowserBridgeParent();
   if (bridgeParent) {
     mozilla::Unused << bridgeParent->SendRequestFocus(aCanRaise);
     return IPC_OK();
   }
 
   nsCOMPtr<nsIFocusManager> fm = nsFocusManager::GetFocusManager();
   if (!fm) {