Title: [243017] trunk
Revision
243017
Author
za...@apple.com
Date
2019-03-15 15:18:41 -0700 (Fri, 15 Mar 2019)

Log Message

[ContentChangeObserver] HTMLImageElement::willRespondToMouseClickEvents returns quirk value.
https://bugs.webkit.org/show_bug.cgi?id=195657
<rdar://problem/48834987>

Reviewed by Simon Fraser.

Source/WebCore:

Images should not trigger hover by default (only when they actually respond to mouse events).

Test: fast/events/touch/ios/content-observation/visibility-change-with-image-content.html

* page/ios/ContentChangeObserver.cpp:
(WebCore::ContentChangeObserver::StyleChangeScope::isConsideredClickable const):

LayoutTests:

* fast/events/touch/ios/content-observation/visibility-change-with-image-content-expected.txt: Added.
* fast/events/touch/ios/content-observation/visibility-change-with-image-content.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (243016 => 243017)


--- trunk/LayoutTests/ChangeLog	2019-03-15 22:18:21 UTC (rev 243016)
+++ trunk/LayoutTests/ChangeLog	2019-03-15 22:18:41 UTC (rev 243017)
@@ -1,3 +1,14 @@
+2019-03-15  Zalan Bujtas  <za...@apple.com>
+
+        [ContentChangeObserver] HTMLImageElement::willRespondToMouseClickEvents returns quirk value.
+        https://bugs.webkit.org/show_bug.cgi?id=195657
+        <rdar://problem/48834987>
+
+        Reviewed by Simon Fraser.
+
+        * fast/events/touch/ios/content-observation/visibility-change-with-image-content-expected.txt: Added.
+        * fast/events/touch/ios/content-observation/visibility-change-with-image-content.html: Added.
+
 2019-03-15  Dean Jackson  <d...@apple.com>
 
         Provide an option for an always-on fast click mode in iOS

Added: trunk/LayoutTests/fast/events/touch/ios/content-observation/visibility-change-with-image-content-expected.txt (0 => 243017)


--- trunk/LayoutTests/fast/events/touch/ios/content-observation/visibility-change-with-image-content-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/content-observation/visibility-change-with-image-content-expected.txt	2019-03-15 22:18:41 UTC (rev 243017)
@@ -0,0 +1,3 @@
+PASS if 'clicked' text is shown below.
+
+clicked

Added: trunk/LayoutTests/fast/events/touch/ios/content-observation/visibility-change-with-image-content.html (0 => 243017)


--- trunk/LayoutTests/fast/events/touch/ios/content-observation/visibility-change-with-image-content.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/content-observation/visibility-change-with-image-content.html	2019-03-15 22:18:41 UTC (rev 243017)
@@ -0,0 +1,53 @@
+<html>
+<head>
+<title>This tests the case when visible content change includes image content</title>
+<script src=""
+<style>
+#tapthis {
+    width: 400px;
+    height: 400px;
+    border: 1px solid green;
+}
+
+#becomesVisible {
+    display: none;
+    width: 100px;
+    height: 100px;
+    background-color: blue;
+}
+</style>
+<script>
+async function test() {
+    if (!window.testRunner || !testRunner.runUIScript)
+        return;
+    if (window.internals)
+        internals.settings.setContentChangeObserverEnabled(true);
+
+    testRunner.waitUntilDone();
+    testRunner.dumpAsText();
+
+    let rect = tapthis.getBoundingClientRect();
+    let x = rect.left + rect.width / 2;
+    let y = rect.top + rect.height / 2;
+
+    await tapAtPoint(x, y);
+}
+</script>
+</head>
+<body _onload_="test()">
+<div id=tapthis>PASS if 'clicked' text is shown below.</div>
+<img src="" id=becomesVisible>
+<pre id=result></pre>
+<script>
+tapthis.addEventListener("mousemove", function( event ) {
+    becomesVisible.style.display = "inline";
+}, false);
+
+tapthis.addEventListener("click", function( event ) {   
+    result.innerHTML = "clicked";
+    document.body.offsetHeight;
+    testRunner.notifyDone();
+}, false);
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (243016 => 243017)


--- trunk/Source/WebCore/ChangeLog	2019-03-15 22:18:21 UTC (rev 243016)
+++ trunk/Source/WebCore/ChangeLog	2019-03-15 22:18:41 UTC (rev 243017)
@@ -1,3 +1,18 @@
+2019-03-15  Zalan Bujtas  <za...@apple.com>
+
+        [ContentChangeObserver] HTMLImageElement::willRespondToMouseClickEvents returns quirk value.
+        https://bugs.webkit.org/show_bug.cgi?id=195657
+        <rdar://problem/48834987>
+
+        Reviewed by Simon Fraser.
+
+        Images should not trigger hover by default (only when they actually respond to mouse events).
+
+        Test: fast/events/touch/ios/content-observation/visibility-change-with-image-content.html
+
+        * page/ios/ContentChangeObserver.cpp:
+        (WebCore::ContentChangeObserver::StyleChangeScope::isConsideredClickable const):
+
 2019-03-15  Jer Noble  <jer.no...@apple.com>
 
         Add a "supportedConfiguration" dictionary to MediaCapabilitiesDecodingInfo and MediaCapabilitiesEncodingInfo

Modified: trunk/Source/WebCore/html/HTMLImageElement.cpp (243016 => 243017)


--- trunk/Source/WebCore/html/HTMLImageElement.cpp	2019-03-15 22:18:21 UTC (rev 243016)
+++ trunk/Source/WebCore/html/HTMLImageElement.cpp	2019-03-15 22:18:41 UTC (rev 243017)
@@ -790,7 +790,7 @@
 #endif // ENABLE(SERVICE_CONTROLS)
 
 #if PLATFORM(IOS_FAMILY)
-// FIXME: This is a workaround for <rdar://problem/7725158>. We should find a better place for the touchCalloutEnabled() logic.
+// FIXME: We should find a better place for the touch callout logic. See rdar://problem/48937767.
 bool HTMLImageElement::willRespondToMouseClickEvents()
 {
     auto renderer = this->renderer();

Modified: trunk/Source/WebCore/page/ios/ContentChangeObserver.cpp (243016 => 243017)


--- trunk/Source/WebCore/page/ios/ContentChangeObserver.cpp	2019-03-15 22:18:21 UTC (rev 243016)
+++ trunk/Source/WebCore/page/ios/ContentChangeObserver.cpp	2019-03-15 22:18:41 UTC (rev 243017)
@@ -30,6 +30,7 @@
 #include "ChromeClient.h"
 #include "DOMTimer.h"
 #include "Document.h"
+#include "HTMLImageElement.h"
 #include "Logging.h"
 #include "NodeRenderStyle.h"
 #include "Page.h"
@@ -393,13 +394,19 @@
 {
     if (m_element.isInUserAgentShadowTree())
         return false;
-    if (!m_hadRenderer)
-        return const_cast<Element&>(m_element).willRespondToMouseClickEvents();
+
+    auto& element = const_cast<Element&>(m_element);
+    if (is<HTMLImageElement>(element)) {
+        // This is required to avoid HTMLImageElement's touch callout override logic. See rdar://problem/48937767.
+        return element.Element::willRespondToMouseClickEvents();
+    }
+
+    auto willRespondToMouseClickEvents = element.willRespondToMouseClickEvents();
+    if (!m_hadRenderer || willRespondToMouseClickEvents)
+        return willRespondToMouseClickEvents;
+    // In case when the visible content already had renderers it's not sufficient to check the "newly visible" element only since it might just be the container for the clickable content.  
     ASSERT(m_element.renderer());
-    if (const_cast<Element&>(m_element).willRespondToMouseClickEvents())
-        return true;
-    // In case when the visible content already had renderers it's not sufficient to check the "newly visible" element only since it might just be the container for the clickable content.  
-    for (auto& descendant : descendantsOfType<RenderElement>(*m_element.renderer())) {
+    for (auto& descendant : descendantsOfType<RenderElement>(*element.renderer())) {
         if (descendant.element()->willRespondToMouseClickEvents())
             return true;
     }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to