Bug 1524240 - In EventStateManager::PostHandleKeyboardEvent look up TabParent by LayersId. r=masayuki
authorHenri Sivonen <hsivonen@hsivonen.fi>
Thu, 07 Mar 2019 08:14:45 +0000
changeset 520709 4f23a573e174f69c078fe647df4e7ee850d0b275
parent 520708 6070ee57c329f406355c5c8f9a858457168fc4f1
child 520710 6c2e00bcd2bb2a0534b3fc00b5f6a8c026785404
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)
reviewersmasayuki
bugs1524240
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 1524240 - In EventStateManager::PostHandleKeyboardEvent look up TabParent by LayersId. r=masayuki Differential Revision: https://phabricator.services.mozilla.com/D20654
dom/events/EventStateManager.cpp
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -2865,16 +2865,31 @@ void EventStateManager::PostHandleKeyboa
     return;
   }
 
   if (!aKeyboardEvent->HasBeenPostedToRemoteProcess()) {
     if (aKeyboardEvent->IsWaitingReplyFromRemoteProcess()) {
       RefPtr<TabParent> remote =
           aTargetFrame ? TabParent::GetFrom(aTargetFrame->GetContent())
                        : nullptr;
+      if (remote && aKeyboardEvent->mLayersId.IsValid()) {
+        // remote is null-checked above in order to let pre-existing event
+        // targeting code's chrome vs. content decision override APZ if they
+        // disagree in order not to disrupt non-Fission e10s mode in case
+        // there are still bugs in the Fission-mode code. That is, if remote
+        // is nullptr, the pre-existing event targeting code has deemed this
+        // event to belong to chrome rather than content.
+        TabParent* preciseRemote =
+            TabParent::GetTabParentFromLayersId(aKeyboardEvent->mLayersId);
+        if (preciseRemote) {
+          remote = preciseRemote;
+        }
+        // else there was a race between APZ and the chrome-process LayersId
+        // to TabParent mapping.
+      }
       if (remote && !remote->IsReadyToHandleInputEvents()) {
         // We need to dispatch the event to the browser element again if we were
         // waiting for the key reply but the event wasn't sent to the content
         // process due to the remote browser wasn't ready.
         WidgetKeyboardEvent keyEvent(*aKeyboardEvent);
         aKeyboardEvent->MarkAsHandledInRemoteProcess();
         EventDispatcher::Dispatch(remote->GetOwnerElement(), mPresContext,
                                   &keyEvent);