Title: [236286] trunk
Revision
236286
Author
[email protected]
Date
2018-09-20 15:05:49 -0700 (Thu, 20 Sep 2018)

Log Message

REGRESSION(r196265): WKWebView fires mouseover, mouseenter, and mouseleave events even when it's in a background window
https://bugs.webkit.org/show_bug.cgi?id=187545
<rdar://problem/42401575>

Reviewed by Ryosuke Niwa.

Source/WebCore:

When the window is not active, we should only update the scrollbar for mouse events. GTK
apps have different expectation on this behavior.

Test: fast/events/inactive-window-no-mouse-event.html

* page/EventHandler.cpp:
(WebCore::EventHandler::handleMouseMoveEvent):
(WebCore::EventHandler::shouldSendMouseEventsToInactiveWindows const):
* page/EventHandler.h:

LayoutTests:

* TestExpectations:
* fast/events/inactive-window-no-mouse-event-expected.txt: Added.
* fast/events/inactive-window-no-mouse-event.html: Added.
* platform/mac-wk2/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (236285 => 236286)


--- trunk/LayoutTests/ChangeLog	2018-09-20 21:36:57 UTC (rev 236285)
+++ trunk/LayoutTests/ChangeLog	2018-09-20 22:05:49 UTC (rev 236286)
@@ -1,3 +1,16 @@
+2018-09-20  Sihui Liu  <[email protected]>
+
+        REGRESSION(r196265): WKWebView fires mouseover, mouseenter, and mouseleave events even when it's in a background window
+        https://bugs.webkit.org/show_bug.cgi?id=187545
+        <rdar://problem/42401575>
+
+        Reviewed by Ryosuke Niwa.
+
+        * TestExpectations:
+        * fast/events/inactive-window-no-mouse-event-expected.txt: Added.
+        * fast/events/inactive-window-no-mouse-event.html: Added.
+        * platform/mac-wk2/TestExpectations:
+
 2018-09-20  Basuke Suzuki  <[email protected]>
 
         [Win] TestRunner::queueLoad() fails to generate correct url for some urls.

Modified: trunk/LayoutTests/TestExpectations (236285 => 236286)


--- trunk/LayoutTests/TestExpectations	2018-09-20 21:36:57 UTC (rev 236285)
+++ trunk/LayoutTests/TestExpectations	2018-09-20 22:05:49 UTC (rev 236286)
@@ -404,6 +404,9 @@
 
 fast/misc/valid-primary-screen-displayID.html [ Skip ]
 
+# This test currently only works for mac-wk2
+fast/events/inactive-window-no-mouse-event.html [ Skip ]
+
 #//////////////////////////////////////////////////////////////////////////////////////////
 # End platform-specific tests.
 #//////////////////////////////////////////////////////////////////////////////////////////

Added: trunk/LayoutTests/fast/events/inactive-window-no-mouse-event-expected.txt (0 => 236286)


--- trunk/LayoutTests/fast/events/inactive-window-no-mouse-event-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/inactive-window-no-mouse-event-expected.txt	2018-09-20 22:05:49 UTC (rev 236286)
@@ -0,0 +1,13 @@
+This test verifies no mouseenter, mouseleave or mousemove event sent to web page when window is inactive.
+To manually test, open another app to make window visible but inactive, then move mouse to red box area. On success, you should not see color change.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS mousemoveDetected is false
+PASS mouseenterCount is 0
+PASS mouseleaveCount is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/events/inactive-window-no-mouse-event.html (0 => 236286)


--- trunk/LayoutTests/fast/events/inactive-window-no-mouse-event.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/inactive-window-no-mouse-event.html	2018-09-20 22:05:49 UTC (rev 236286)
@@ -0,0 +1,65 @@
+<!DOCTYPE html>
+<html>
+<body>
+<div id="around" style="width:600px; height:600px; top:0px; left:0px; background-color:blue; position:absolute"></div>
+<div id="target" style="width:200px; height:200px; top:200px; left:200px; background-color:red; position:absolute"></div>
+
+<script src=""
+<script>
+jsTestIsAsync = true;
+
+var mouseenterCount = 0;
+var mouseleaveCount = 0;
+var mousemoveDetected = false;
+
+var target = document.getElementById("target");
+var around = document.getElementById("around");
+target.addEventListener('mouseenter',() => {
+    document.getElementById("target").style.backgroundColor = "yellow";
+
+    debug("Mouse enters target.");
+	mouseenterCount++;
+});
+target.addEventListener('mouseleave',() => {
+    document.getElementById("target").style.backgroundColor = "red";
+
+    debug("Mouse leaves target.");
+    mouseleaveCount++;
+});
+around.addEventListener('mousemove',() => {
+
+    shouldBeFalse("mousemoveDetected");
+    shouldBe("mouseenterCount", "0");
+    shouldBe("mouseleaveCount", "0");
+
+    mousemoveDetected = true;
+
+    finishJSTest();
+});
+
+description("This test verifies no mouseenter, mouseleave or mousemove event sent to web page when window is inactive.<br>\
+    To manually test, open another app to make window visible but inactive, then move mouse to red box area. On success, you should not see color change.");
+
+if (window.internals)
+    window.internals.setPageIsFocusedAndActive(false);
+
+if (window.eventSender) {
+    left = target.offsetLeft;
+    top = target.offsetTop;
+
+    eventSender.mouseMoveTo(around.offsetLeft, around.offsetTop);
+    eventSender.mouseMoveTo(target.offsetLeft, target.offsetTop);
+    eventSender.mouseMoveTo(around.offsetLeft, around.offsetTop);
+}
+
+setTimeout(() => {
+    if (window.internals)
+        window.internals.setPageIsFocusedAndActive(true);
+
+    if (window.eventSender) 
+        eventSender.mouseMoveTo(around.offsetLeft + 1, around.offsetTop + 1);
+}, 200);
+
+</script>
+</body>
+</html>

Modified: trunk/LayoutTests/platform/mac-wk2/TestExpectations (236285 => 236286)


--- trunk/LayoutTests/platform/mac-wk2/TestExpectations	2018-09-20 21:36:57 UTC (rev 236285)
+++ trunk/LayoutTests/platform/mac-wk2/TestExpectations	2018-09-20 22:05:49 UTC (rev 236286)
@@ -62,6 +62,8 @@
 webkit.org/b/184569 storage/indexeddb/modern/transactions-stop-on-navigation.html [ Pass Failure ]
 
 
+fast/events/inactive-window-no-mouse-event.html [ Pass ]
+
 #//////////////////////////////////////////////////////////////////////////////////////////
 # End platform-specific directories.
 #//////////////////////////////////////////////////////////////////////////////////////////

Modified: trunk/Source/WebCore/ChangeLog (236285 => 236286)


--- trunk/Source/WebCore/ChangeLog	2018-09-20 21:36:57 UTC (rev 236285)
+++ trunk/Source/WebCore/ChangeLog	2018-09-20 22:05:49 UTC (rev 236286)
@@ -1,3 +1,21 @@
+2018-09-20  Sihui Liu  <[email protected]>
+
+        REGRESSION(r196265): WKWebView fires mouseover, mouseenter, and mouseleave events even when it's in a background window
+        https://bugs.webkit.org/show_bug.cgi?id=187545
+        <rdar://problem/42401575>
+
+        Reviewed by Ryosuke Niwa.
+
+        When the window is not active, we should only update the scrollbar for mouse events. GTK
+        apps have different expectation on this behavior.
+
+        Test: fast/events/inactive-window-no-mouse-event.html
+
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::handleMouseMoveEvent):
+        (WebCore::EventHandler::shouldSendMouseEventsToInactiveWindows const):
+        * page/EventHandler.h:
+
 2018-09-20  Alex Christensen  <[email protected]>
 
         Unreviewed, rolling out r235976.

Modified: trunk/Source/WebCore/page/EventHandler.cpp (236285 => 236286)


--- trunk/Source/WebCore/page/EventHandler.cpp	2018-09-20 21:36:57 UTC (rev 236285)
+++ trunk/Source/WebCore/page/EventHandler.cpp	2018-09-20 22:05:49 UTC (rev 236286)
@@ -1965,7 +1965,9 @@
             scrollbar->mouseMoved(platformMouseEvent); // Handle hover effects on platforms that support visual feedback on scrollbar hovering.
 #endif
         if (onlyUpdateScrollbars) {
-            updateMouseEventTargetNode(mouseEvent.targetNode(), platformMouseEvent, true);
+            if (shouldSendMouseEventsToInactiveWindows())
+                updateMouseEventTargetNode(mouseEvent.targetNode(), platformMouseEvent, true);
+
             return true;
         }
     }
@@ -2008,6 +2010,14 @@
     return swallowEvent;
 }
 
+bool EventHandler::shouldSendMouseEventsToInactiveWindows() const
+{
+#if PLATFORM(GTK)
+    return true;
+#endif
+    return false;
+}
+
 void EventHandler::invalidateClick()
 {
     m_clickCount = 0;

Modified: trunk/Source/WebCore/page/EventHandler.h (236285 => 236286)


--- trunk/Source/WebCore/page/EventHandler.h	2018-09-20 21:36:57 UTC (rev 236285)
+++ trunk/Source/WebCore/page/EventHandler.h	2018-09-20 22:05:49 UTC (rev 236286)
@@ -493,6 +493,8 @@
     void clearOrScheduleClearingLatchedStateIfNeeded(const PlatformWheelEvent&);
     void clearLatchedState();
 
+    bool shouldSendMouseEventsToInactiveWindows() const;
+
     Frame& m_frame;
 
     bool m_mousePressed { false };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to