Title: [280374] trunk
Revision
280374
Author
[email protected]
Date
2021-07-27 20:56:44 -0700 (Tue, 27 Jul 2021)

Log Message

[Modern Media Controls] [macOS] Overflow button still shows as `on` even after contextmenu is dismissed
https://bugs.webkit.org/show_bug.cgi?id=228310
<rdar://problem/81124786>

Reviewed by Wenson Hsieh.

Source/WebCore:

Test: media/modern-media-controls/overflow-support/button-state.html

* page/ContextMenuController.h:
* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::didDismissContextMenu): Added.
* page/ContextMenuProvider.h:
(WebCore::ContextMenuProvider::didDismissContextMenu): Added.
Add plumbing from WebKit to the `ContextMenuProvider` for when the contextmenu is dismissed.

* Modules/mediacontrols/MediaControlsHost.cpp:
(WebCore::MediaControlsContextMenuProvider::didDismissContextMenu): Added.
When the contextmenu is dismissed, invoke the callback provided to `MediaControlsHost::showMediaControlsContextMenu`
as that's the signal to the `MediaController` that the contextmenu interaction is over,
which adjusts the `on` state of the `Button`.

Source/WebKit:

Pipe along the `-[NSMenuDelegate menuDidClose:]` signal to the WebProcess so the `WebCore::ContextMenuProvider`
can handle it if needed.

* UIProcess/WebContextMenuProxy.cpp:
(WebKit::WebContextMenuProxy::useContextMenuItems):
* UIProcess/mac/WebContextMenuProxyMac.mm:
(-[WKMenuDelegate menuWillOpen:]):
(-[WKMenuDelegate menuDidClose:]):

* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::showContextMenu):
(WebKit::WebPageProxy::didShowContextMenu):
(WebKit::WebPageProxy::didDismissContextMenu): Added.

* WebProcess/WebPage/WebContextMenu.cpp:
(WebKit::WebContextMenu::show):

* WebProcess/WebPage/WebPage.messages.in:
* WebProcess/WebPage/WebPage.h:
(WebKit::WebPage::startWaitingForContextMenuToShow): Added.
(WebKit::WebPage::contextMenuShowing): Deleted.
(WebKit::WebPage::contextMenuHidden): Deleted.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::didShowContextMenu): Added.
(WebKit::WebPage::didDismissContextMenu): Added.
(WebKit::WebPage::mouseEvent):
Drive-by: Rename `m_contextMenuShowing` to `m_waitingForContextMenuToShow` for clarity.

Tools:

* WebKitTestRunner/cocoa/TestRunnerWKWebView.mm:
(-[TestRunnerWKWebView dismissActiveMenu]):
(-[TestRunnerWKWebView immediatelyDismissContextMenuIfNeeded]):
(-[TestRunnerWKWebView _dismissAllContextMenuInteractions]): Added.

LayoutTests:

* media/modern-media-controls/overflow-support/button-state.html: Added.
* media/modern-media-controls/overflow-support/button-state-expected.txt: Added.

* media/modern-media-controls/overflow-support/playback-speed.html:
* media/modern-media-controls/tracks-support/click-track-in-contextmenu.html:
Adjust how these tests wait for and dismiss the contextmenu.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (280373 => 280374)


--- trunk/LayoutTests/ChangeLog	2021-07-28 03:02:11 UTC (rev 280373)
+++ trunk/LayoutTests/ChangeLog	2021-07-28 03:56:44 UTC (rev 280374)
@@ -1,3 +1,18 @@
+2021-07-27  Devin Rousso  <[email protected]>
+
+        [Modern Media Controls] [macOS] Overflow button still shows as `on` even after contextmenu is dismissed
+        https://bugs.webkit.org/show_bug.cgi?id=228310
+        <rdar://problem/81124786>
+
+        Reviewed by Wenson Hsieh.
+
+        * media/modern-media-controls/overflow-support/button-state.html: Added.
+        * media/modern-media-controls/overflow-support/button-state-expected.txt: Added.
+
+        * media/modern-media-controls/overflow-support/playback-speed.html:
+        * media/modern-media-controls/tracks-support/click-track-in-contextmenu.html:
+        Adjust how these tests wait for and dismiss the contextmenu.
+
 2021-07-27  Amir Mark Jr  <[email protected]>
 
         [LayoutTests] Delete unused LayoutTests/inspector resources

Added: trunk/LayoutTests/media/modern-media-controls/overflow-support/button-state-expected.txt (0 => 280374)


--- trunk/LayoutTests/media/modern-media-controls/overflow-support/button-state-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/modern-media-controls/overflow-support/button-state-expected.txt	2021-07-28 03:56:44 UTC (rev 280374)
@@ -0,0 +1,15 @@
+Testing that the overflow button is properly marked as `on` only when the context menu is showing.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS shadowRoot.querySelector('button.overflow') became different from null
+PASS shadowRoot.querySelector('button.overflow').getBoundingClientRect().width became different from 0
+Tapping overflow button...
+PASS shadowRoot.querySelector('button.overflow').classList.contains('on') became true
+Dismissing contextmenu...
+PASS shadowRoot.querySelector('button.overflow').classList.contains('on') became false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/media/modern-media-controls/overflow-support/button-state.html (0 => 280374)


--- trunk/LayoutTests/media/modern-media-controls/overflow-support/button-state.html	                        (rev 0)
+++ trunk/LayoutTests/media/modern-media-controls/overflow-support/button-state.html	2021-07-28 03:56:44 UTC (rev 280374)
@@ -0,0 +1,45 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+<meta name="viewport" content="width=device-width">
+<script src=""
+<script src=""
+<script src=""
+<body>
+<video src="" style="position: absolute; left: 0; top: 0; width: 600px;" controls autoplay></video>
+<script type="text/_javascript_">
+
+window.jsTestIsAsync = true;
+
+description("Testing that the overflow button is properly marked as `on` only when the context menu is showing.");
+
+const media = document.querySelector("video");
+const shadowRoot = window.internals.shadowRoot(media);
+
+media.addEventListener("play", async function() {
+    media.pause();
+
+    await shouldBecomeDifferent("shadowRoot.querySelector('button.overflow')", "null");
+
+    await shouldBecomeDifferent("shadowRoot.querySelector('button.overflow').getBoundingClientRect().width", "0");
+
+    debug("Tapping overflow button...");
+    await pressOnElement(shadowRoot.querySelector("button.overflow"));
+    await UIHelper.waitForContextMenuToShow();
+    await shouldBecomeEqual("shadowRoot.querySelector('button.overflow').classList.contains('on')", "true");
+
+    debug("Dismissing contextmenu...");
+    await new Promise((resolve, reject) => {
+        testRunner.runUIScript(`
+            uiController.dismissMenu();
+            uiController.uiScriptComplete();
+        `, resolve);
+    });
+    await UIHelper.waitForContextMenuToHide();
+    await shouldBecomeEqual("shadowRoot.querySelector('button.overflow').classList.contains('on')", "false");
+
+    media.remove();
+    finishJSTest();
+});
+
+</script>
+<script src=""
+</body>

Modified: trunk/LayoutTests/media/modern-media-controls/overflow-support/playback-speed.html (280373 => 280374)


--- trunk/LayoutTests/media/modern-media-controls/overflow-support/playback-speed.html	2021-07-28 03:02:11 UTC (rev 280373)
+++ trunk/LayoutTests/media/modern-media-controls/overflow-support/playback-speed.html	2021-07-28 03:56:44 UTC (rev 280374)
@@ -30,6 +30,13 @@
             checkedItems = contextmenu[0].children.filter((item) => item.checked);
             shouldBe("checkedItems.length", "1");
             shouldBeEqualToString("checkedItems[0].title", `1${multiplicationSign}`);
+
+            await new Promise((resolve, reject) => {
+                testRunner.runUIScript(`
+                    uiController.dismissMenu();
+                    uiController.uiScriptComplete();
+                `, resolve);
+            });
             await UIHelper.waitForContextMenuToHide();
 
             debug("Changing playback speed via _javascript_...");

Modified: trunk/LayoutTests/media/modern-media-controls/tracks-support/click-track-in-contextmenu.html (280373 => 280374)


--- trunk/LayoutTests/media/modern-media-controls/tracks-support/click-track-in-contextmenu.html	2021-07-28 03:02:11 UTC (rev 280373)
+++ trunk/LayoutTests/media/modern-media-controls/tracks-support/click-track-in-contextmenu.html	2021-07-28 03:56:44 UTC (rev 280374)
@@ -43,7 +43,7 @@
 async function clickOnFrenchAudioTrack()
 {
     debug("Selecting 'French' track...");
-    await getTracksContextMenu();
+    await UIHelper.waitForContextMenuToShow();
     await UIHelper.chooseMenuAction("French Sound");
 }
 
@@ -50,7 +50,7 @@
 async function clickOnSpanishAudioTrack()
 {
     debug("Selecting 'Spanish' track...");
-    await getTracksContextMenu();
+    await UIHelper.waitForContextMenuToShow();
     await UIHelper.chooseMenuAction("Spanish Sound");
 }
 

Modified: trunk/Source/WebCore/ChangeLog (280373 => 280374)


--- trunk/Source/WebCore/ChangeLog	2021-07-28 03:02:11 UTC (rev 280373)
+++ trunk/Source/WebCore/ChangeLog	2021-07-28 03:56:44 UTC (rev 280374)
@@ -1,3 +1,26 @@
+2021-07-27  Devin Rousso  <[email protected]>
+
+        [Modern Media Controls] [macOS] Overflow button still shows as `on` even after contextmenu is dismissed
+        https://bugs.webkit.org/show_bug.cgi?id=228310
+        <rdar://problem/81124786>
+
+        Reviewed by Wenson Hsieh.
+
+        Test: media/modern-media-controls/overflow-support/button-state.html
+
+        * page/ContextMenuController.h:
+        * page/ContextMenuController.cpp:
+        (WebCore::ContextMenuController::didDismissContextMenu): Added.
+        * page/ContextMenuProvider.h:
+        (WebCore::ContextMenuProvider::didDismissContextMenu): Added.
+        Add plumbing from WebKit to the `ContextMenuProvider` for when the contextmenu is dismissed.
+
+        * Modules/mediacontrols/MediaControlsHost.cpp:
+        (WebCore::MediaControlsContextMenuProvider::didDismissContextMenu): Added.
+        When the contextmenu is dismissed, invoke the callback provided to `MediaControlsHost::showMediaControlsContextMenu`
+        as that's the signal to the `MediaController` that the contextmenu interaction is over,
+        which adjusts the `on` state of the `Button`.
+
 2021-07-27  Ryosuke Niwa  <[email protected]>
 
         [macOS] Stop away unpaired surrogate pair in findNextWordFromIndex:forward:

Modified: trunk/Source/WebCore/Modules/mediacontrols/MediaControlsHost.cpp (280373 => 280374)


--- trunk/Source/WebCore/Modules/mediacontrols/MediaControlsHost.cpp	2021-07-28 03:02:11 UTC (rev 280373)
+++ trunk/Source/WebCore/Modules/mediacontrols/MediaControlsHost.cpp	2021-07-28 03:56:44 UTC (rev 280374)
@@ -388,6 +388,12 @@
             menu->appendItem(item);
     }
 
+    void didDismissContextMenu() override
+    {
+        if (m_callback)
+            m_callback(ContextMenuItemTagNoAction);
+    }
+
     void contextMenuItemSelected(ContextMenuAction action, const String&) override
     {
         m_callback(action - ContextMenuItemBaseCustomTag);
@@ -455,14 +461,8 @@
 bool MediaControlsHost::showMediaControlsContextMenu(HTMLElement& target, String&& optionsJSONString, Ref<VoidCallback>&& callback)
 {
 #if USE(UICONTEXTMENU) || (ENABLE(CONTEXT_MENUS) && USE(ACCESSIBILITY_CONTEXT_MENUS))
-    if (m_showMediaControlsContextMenuCallback) {
-#if USE(UICONTEXTMENU)
+    if (m_showMediaControlsContextMenuCallback)
         return false;
-#elif (ENABLE(CONTEXT_MENUS) && USE(ACCESSIBILITY_CONTEXT_MENUS))
-        // FIXME: `contextMenuCleared` is invoked between show and item selected so we may have a pending callback.
-        std::exchange(m_showMediaControlsContextMenuCallback, nullptr)->handleEvent();
-#endif
-    }
 
     m_showMediaControlsContextMenuCallback = WTFMove(callback);
 

Modified: trunk/Source/WebCore/page/ContextMenuController.cpp (280373 => 280374)


--- trunk/Source/WebCore/page/ContextMenuController.cpp	2021-07-28 03:02:11 UTC (rev 280373)
+++ trunk/Source/WebCore/page/ContextMenuController.cpp	2021-07-28 03:56:44 UTC (rev 280374)
@@ -172,6 +172,12 @@
     event.setDefaultHandled();
 }
 
+void ContextMenuController::didDismissContextMenu()
+{
+    if (m_menuProvider)
+        m_menuProvider->didDismissContextMenu();
+}
+
 static void openNewWindow(const URL& urlToLoad, Frame& frame, ShouldOpenExternalURLsPolicy shouldOpenExternalURLsPolicy)
 {
     Page* oldPage = frame.page();

Modified: trunk/Source/WebCore/page/ContextMenuController.h (280373 => 280374)


--- trunk/Source/WebCore/page/ContextMenuController.h	2021-07-28 03:02:11 UTC (rev 280373)
+++ trunk/Source/WebCore/page/ContextMenuController.h	2021-07-28 03:56:44 UTC (rev 280374)
@@ -56,6 +56,7 @@
     void showContextMenu(Event&, ContextMenuProvider&);
 
     void populate();
+    WEBCORE_EXPORT void didDismissContextMenu();
     WEBCORE_EXPORT void contextMenuItemSelected(ContextMenuAction, const String& title);
     void addInspectElementItem();
 

Modified: trunk/Source/WebCore/page/ContextMenuProvider.h (280373 => 280374)


--- trunk/Source/WebCore/page/ContextMenuProvider.h	2021-07-28 03:02:11 UTC (rev 280373)
+++ trunk/Source/WebCore/page/ContextMenuProvider.h	2021-07-28 03:56:44 UTC (rev 280374)
@@ -45,6 +45,7 @@
     virtual ~ContextMenuProvider() { };
 
     virtual void populateContextMenu(ContextMenu*) = 0;
+    virtual void didDismissContextMenu() { }
     virtual void contextMenuItemSelected(ContextMenuAction, const String& title) = 0;
     virtual void contextMenuCleared() = 0;
     virtual ContextMenuContext::Type contextMenuContextType() { return ContextMenuContext::Type::ContextMenu; };

Modified: trunk/Source/WebKit/ChangeLog (280373 => 280374)


--- trunk/Source/WebKit/ChangeLog	2021-07-28 03:02:11 UTC (rev 280373)
+++ trunk/Source/WebKit/ChangeLog	2021-07-28 03:56:44 UTC (rev 280374)
@@ -1,3 +1,40 @@
+2021-07-27  Devin Rousso  <[email protected]>
+
+        [Modern Media Controls] [macOS] Overflow button still shows as `on` even after contextmenu is dismissed
+        https://bugs.webkit.org/show_bug.cgi?id=228310
+        <rdar://problem/81124786>
+
+        Reviewed by Wenson Hsieh.
+
+        Pipe along the `-[NSMenuDelegate menuDidClose:]` signal to the WebProcess so the `WebCore::ContextMenuProvider`
+        can handle it if needed.
+
+        * UIProcess/WebContextMenuProxy.cpp:
+        (WebKit::WebContextMenuProxy::useContextMenuItems):
+        * UIProcess/mac/WebContextMenuProxyMac.mm:
+        (-[WKMenuDelegate menuWillOpen:]):
+        (-[WKMenuDelegate menuDidClose:]):
+
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::showContextMenu):
+        (WebKit::WebPageProxy::didShowContextMenu):
+        (WebKit::WebPageProxy::didDismissContextMenu): Added.
+
+        * WebProcess/WebPage/WebContextMenu.cpp:
+        (WebKit::WebContextMenu::show):
+
+        * WebProcess/WebPage/WebPage.messages.in:
+        * WebProcess/WebPage/WebPage.h:
+        (WebKit::WebPage::startWaitingForContextMenuToShow): Added.
+        (WebKit::WebPage::contextMenuShowing): Deleted.
+        (WebKit::WebPage::contextMenuHidden): Deleted.
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::didShowContextMenu): Added.
+        (WebKit::WebPage::didDismissContextMenu): Added.
+        (WebKit::WebPage::mouseEvent):
+        Drive-by: Rename `m_contextMenuShowing` to `m_waitingForContextMenuToShow` for clarity.
+
 2021-07-27  Myles C. Maxfield  <[email protected]>
 
         [GPU Process] Code cleanup after r280356

Modified: trunk/Source/WebKit/UIProcess/WebContextMenuProxy.cpp (280373 => 280374)


--- trunk/Source/WebKit/UIProcess/WebContextMenuProxy.cpp	2021-07-28 03:02:11 UTC (rev 280373)
+++ trunk/Source/WebKit/UIProcess/WebContextMenuProxy.cpp	2021-07-28 03:56:44 UTC (rev 280374)
@@ -73,7 +73,7 @@
     showContextMenuWithItems(WTFMove(items));
 
     // No matter the result of showContextMenuWithItems, always notify the WebProcess that the menu is hidden so it starts handling mouse events again.
-    page->send(Messages::WebPage::ContextMenuHidden());
+    page->send(Messages::WebPage::DidShowContextMenu());
 }
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (280373 => 280374)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-07-28 03:02:11 UTC (rev 280373)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-07-28 03:56:44 UTC (rev 280374)
@@ -6828,7 +6828,7 @@
     // can hang the page / WebDriver test. Pretend to show and immediately dismiss the context menu.
     if (auto* automationSession = process().processPool().automationSession()) {
         if (m_controlledByAutomation && automationSession->isSimulatingUserInteraction()) {
-            send(Messages::WebPage::ContextMenuHidden());
+            send(Messages::WebPage::DidShowContextMenu());
             return;
         }
     }
@@ -6844,6 +6844,21 @@
     m_activeContextMenu->show();
 }
 
+void WebPageProxy::didShowContextMenu()
+{
+    // Don't send `Messages::WebPage::DidShowContextMenu` as that should've already been eagerly
+    // sent when requesting the context menu to show, regardless of the result of that request.
+
+    pageClient().didShowContextMenu();
+}
+
+void WebPageProxy::didDismissContextMenu()
+{
+    send(Messages::WebPage::DidDismissContextMenu());
+
+    pageClient().didDismissContextMenu();
+}
+
 void WebPageProxy::contextMenuItemSelected(const WebContextMenuItemData& item)
 {
     // Application custom items don't need to round-trip through to WebCore in the WebProcess.

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (280373 => 280374)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2021-07-28 03:02:11 UTC (rev 280373)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2021-07-28 03:56:44 UTC (rev 280374)
@@ -1314,6 +1314,8 @@
 
 #if ENABLE(CONTEXT_MENUS)
     // Called by the WebContextMenuProxy.
+    void didShowContextMenu();
+    void didDismissContextMenu();
     void contextMenuItemSelected(const WebContextMenuItemData&);
     void handleContextMenuKeyEvent();
 #endif

Modified: trunk/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm (280373 => 280374)


--- trunk/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm	2021-07-28 03:02:11 UTC (rev 280373)
+++ trunk/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm	2021-07-28 03:56:44 UTC (rev 280374)
@@ -171,12 +171,12 @@
 
 - (void)menuWillOpen:(NSMenu *)menu
 {
-    _menuProxy->page()->pageClient().didShowContextMenu();
+    _menuProxy->page()->didShowContextMenu();
 }
 
 - (void)menuDidClose:(NSMenu *)menu
 {
-    _menuProxy->page()->pageClient().didDismissContextMenu();
+    _menuProxy->page()->didDismissContextMenu();
 }
 
 @end

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebContextMenu.cpp (280373 => 280374)


--- trunk/Source/WebKit/WebProcess/WebPage/WebContextMenu.cpp	2021-07-28 03:02:11 UTC (rev 280373)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebContextMenu.cpp	2021-07-28 03:56:44 UTC (rev 280374)
@@ -68,7 +68,7 @@
     ContextMenuContextData contextMenuContextData(menuLocation, menuItems, controller.context());
 
     // Mark the WebPage has having a shown context menu then notify the UIProcess.
-    m_page->contextMenuShowing();
+    m_page->startWaitingForContextMenuToShow();
     m_page->flushPendingEditorStateUpdate();
     m_page->send(Messages::WebPageProxy::ShowContextMenu(contextMenuContextData, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
 }

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (280373 => 280374)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2021-07-28 03:02:11 UTC (rev 280373)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2021-07-28 03:56:44 UTC (rev 280374)
@@ -2857,6 +2857,20 @@
     const WebEvent* m_previousCurrentEvent;
 };
 
+#if ENABLE(CONTEXT_MENUS)
+
+void WebPage::didShowContextMenu()
+{
+    m_waitingForContextMenuToShow = false;
+}
+
+void WebPage::didDismissContextMenu()
+{
+    corePage()->contextMenuController().didDismissContextMenu();
+}
+
+#endif // ENABLE(CONTEXT_MENUS)
+
 #if ENABLE(CONTEXT_MENU_EVENT)
 static bool isContextClick(const PlatformMouseEvent& event)
 {
@@ -2962,7 +2976,7 @@
 
 #if ENABLE(CONTEXT_MENUS)
     // Don't try to handle any pending mouse events if a context menu is showing.
-    if (m_isShowingContextMenu)
+    if (m_waitingForContextMenuToShow)
         shouldHandleEvent = false;
 #endif
 #if ENABLE(DRAG_SUPPORT)

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (280373 => 280374)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2021-07-28 03:02:11 UTC (rev 280373)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2021-07-28 03:56:44 UTC (rev 280374)
@@ -1050,7 +1050,7 @@
     void simulateMouseMotion(WebCore::IntPoint, WallTime);
 
 #if ENABLE(CONTEXT_MENUS)
-    void contextMenuShowing() { m_isShowingContextMenu = true; }
+    void startWaitingForContextMenuToShow() { m_waitingForContextMenuToShow = true; }
 #endif
 
     bool wheelEvent(const WebWheelEvent&, OptionSet<WebCore::WheelEventProcessingSteps>);
@@ -1620,7 +1620,8 @@
     void touchWithIdentifierWasRemoved(WebCore::PointerID);
 
 #if ENABLE(CONTEXT_MENUS)
-    void contextMenuHidden() { m_isShowingContextMenu = false; }
+    void didShowContextMenu();
+    void didDismissContextMenu();
 #endif
 #if ENABLE(CONTEXT_MENU_EVENT)
     void contextMenuForKeyEvent();
@@ -2172,7 +2173,7 @@
     OptionSet<WebCore::ActivityState::Flag> m_lastActivityStateChanges;
 
 #if ENABLE(CONTEXT_MENUS)
-    bool m_isShowingContextMenu { false };
+    bool m_waitingForContextMenuToShow { false };
 #endif
 
     RefPtr<WebCore::Element> m_focusedElement;

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (280373 => 280374)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2021-07-28 03:02:11 UTC (rev 280373)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in	2021-07-28 03:56:44 UTC (rev 280374)
@@ -164,11 +164,6 @@
     DidEndDateTimePicker();
 #endif
 
-#if ENABLE(CONTEXT_MENUS)
-    ContextMenuHidden()
-    ContextMenuForKeyEvent()
-#endif
-
     ScrollBy(uint32_t scrollDirection, uint32_t scrollGranularity)
     CenterSelectionInVisibleArea()
 
@@ -345,7 +340,10 @@
 
 #if ENABLE(CONTEXT_MENUS)
     # Context menu.
+    DidShowContextMenu()
+    DidDismissContextMenu()
     DidSelectItemFromActiveContextMenu(WebKit::WebContextMenuItemData menuItem)
+    ContextMenuForKeyEvent()
 #endif
 
     # Open panel.

Modified: trunk/Tools/ChangeLog (280373 => 280374)


--- trunk/Tools/ChangeLog	2021-07-28 03:02:11 UTC (rev 280373)
+++ trunk/Tools/ChangeLog	2021-07-28 03:56:44 UTC (rev 280374)
@@ -1,3 +1,16 @@
+2021-07-27  Devin Rousso  <[email protected]>
+
+        [Modern Media Controls] [macOS] Overflow button still shows as `on` even after contextmenu is dismissed
+        https://bugs.webkit.org/show_bug.cgi?id=228310
+        <rdar://problem/81124786>
+
+        Reviewed by Wenson Hsieh.
+
+        * WebKitTestRunner/cocoa/TestRunnerWKWebView.mm:
+        (-[TestRunnerWKWebView dismissActiveMenu]):
+        (-[TestRunnerWKWebView immediatelyDismissContextMenuIfNeeded]):
+        (-[TestRunnerWKWebView _dismissAllContextMenuInteractions]): Added.
+
 2021-07-27  Diego Pino Garcia  <[email protected]>
 
         [GTK][WPE] Fix wrong path to GLIB dependencies introduced in r280354.

Modified: trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm (280373 => 280374)


--- trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm	2021-07-28 03:02:11 UTC (rev 280373)
+++ trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm	2021-07-28 03:56:44 UTC (rev 280374)
@@ -185,6 +185,7 @@
 - (void)dismissActiveMenu
 {
 #if PLATFORM(IOS_FAMILY)
+    [self _dismissAllContextMenuInteractions];
     [self resignFirstResponder];
 #else
     auto menu = retainPtr(self._activeMenu);
@@ -253,6 +254,11 @@
 
     self.showingContextMenu = NO;
 
+    [self _dismissAllContextMenuInteractions];
+}
+
+- (void)_dismissAllContextMenuInteractions
+{
 #if PLATFORM(IOS)
     for (id <UIInteraction> interaction in self.contentView.interactions) {
         if ([interaction isKindOfClass:UIContextMenuInteraction.class])
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to