Bug 1653576 - Don't let dmanip events roll up popups if the events are inside the popup. r=tnikkel
authorKartikaya Gupta <kgupta@mozilla.com>
Tue, 11 Aug 2020 21:44:30 +0000
changeset 544333 510e2a73c290aaef08044b101fe65f2089c57cf7
parent 544332 15b0c4b2dbe858c102a77e36e821eb4d6d2130c7
child 544334 34d7e6da2825a98e1bdd10d657bc301247ed2808
push id123972
push userkgupta@mozilla.com
push dateTue, 11 Aug 2020 22:54:41 +0000
treeherderautoland@510e2a73c290 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstnikkel
bugs1653576
milestone81.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 1653576 - Don't let dmanip events roll up popups if the events are inside the popup. r=tnikkel The existing rollup-handling code in SendAnAPZEvent was mostly copied from the DealWithPopups function, so this patch removes that duplication and reuses the existing codepath. And it adds some extra checking for dmanip events that mirrors the checking we do for other events, so that events that are targeted inside the popup don't cause the popup to get rolled up. Differential Revision: https://phabricator.services.mozilla.com/D86603
widget/windows/WinMessages.h
widget/windows/nsWindow.cpp
--- a/widget/windows/WinMessages.h
+++ b/widget/windows/WinMessages.h
@@ -29,16 +29,19 @@
 // window with this message.
 #define MOZ_WM_REACTIVATE (WM_APP + 0x0314)
 // If TSFTextStore needs to notify TSF/TIP of layout change later, this
 // message is posted.
 #define MOZ_WM_NOTIY_TSF_OF_LAYOUT_CHANGE (WM_APP + 0x0315)
 // Internal message used in correcting backwards clock skew
 #define MOZ_WM_SKEWFIX (WM_APP + 0x0316)
 
+// Internal message used for rolling up popups for dmanip events
+#define MOZ_WM_DMANIP (WM_APP + 0x0317)
+
 // Following MOZ_WM_*KEY* messages are used by PluginInstanceChild and
 // NativeKey internally. (never posted to the queue)
 #define MOZ_WM_KEYDOWN (WM_APP + 0x0318)
 #define MOZ_WM_KEYUP (WM_APP + 0x0319)
 #define MOZ_WM_SYSKEYDOWN (WM_APP + 0x031A)
 #define MOZ_WM_SYSKEYUP (WM_APP + 0x031B)
 #define MOZ_WM_CHAR (WM_APP + 0x031C)
 #define MOZ_WM_SYSCHAR (WM_APP + 0x031D)
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -717,26 +717,20 @@ static bool ShouldCacheTitleBarInfo(nsWi
   return (aWindowType == eWindowType_toplevel) &&
          (aBorderStyle == eBorderStyle_default ||
           aBorderStyle == eBorderStyle_all) &&
          (!nsUXThemeData::sTitlebarInfoPopulatedThemed ||
           !nsUXThemeData::sTitlebarInfoPopulatedAero);
 }
 
 void nsWindow::SendAnAPZEvent(InputData& aEvent) {
-  RefPtr<nsWindow> strongThis(this);
-  if (::IsWindowVisible(mWnd)) {
-    nsIRollupListener* rollupListener = nsBaseWidget::GetActiveRollupListener();
-    if (rollupListener) {
-      nsCOMPtr<nsIWidget> popup = rollupListener->GetRollupWidget();
-      if (popup) {
-        uint32_t popupsToRollup = UINT32_MAX;
-        rollupListener->Rollup(popupsToRollup, true, nullptr, nullptr);
-      }
-    }
+  LRESULT popupHandlingResult;
+  if (DealWithPopups(mWnd, MOZ_WM_DMANIP, 0, 0, &popupHandlingResult)) {
+    // We need to consume the event after using it to roll up the popup(s).
+    return;
   }
 
   APZEventResult result;
   if (mAPZC) {
     result = mAPZC->InputBridge()->ReceiveInputEvent(aEvent);
   }
   if (result.mStatus == nsEventStatus_eConsumeNoDefault) {
     return;
@@ -8106,16 +8100,27 @@ bool nsWindow::DealWithPopups(HWND aWnd,
       if (!GetPopupsToRollup(rollupListener, &popupsToRollup, Some(pt))) {
         return false;
       }
       if (EventIsInsideWindow(popupWindow, Some(pt))) {
         // Don't roll up if the event is inside the popup window.
         return false;
       }
     } break;
+    case MOZ_WM_DMANIP: {
+      POINT pt;
+      ::GetCursorPos(&pt);
+      if (!GetPopupsToRollup(rollupListener, &popupsToRollup, Some(pt))) {
+        return false;
+      }
+      if (EventIsInsideWindow(popupWindow, Some(pt))) {
+        // Don't roll up if the event is inside the popup window
+        return false;
+      }
+    } break;
     case WM_MOUSEWHEEL:
     case WM_MOUSEHWHEEL:
       // We need to check if the popup thinks that it should cause closing
       // itself when mouse wheel events are fired outside the rollup widget.
       if (!EventIsInsideWindow(popupWindow)) {
         // Check if we should consume this event even if we don't roll-up:
         consumeRollupEvent = rollupListener->ShouldConsumeOnMouseWheelEvent();
         *aResult = MA_ACTIVATE;