"display: contents" Content click does not trigger
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Jun 2019 16:05:27 +0000 (16:05 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Jun 2019 16:05:27 +0000 (16:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=198559
<rdar://problem/51488524>

Patch by Antoine Quint <graouts@apple.com> on 2019-06-13
Reviewed by Antti Koivisto.

Source/WebCore:

Test: fast/events/ios/click-event-and-display-contents.html

* dom/Element.h:

Source/WebKit:

* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::commitPotentialTap):

LayoutTests:

Add a new test that checks that tapping on an element with "display: contents" correctly gets a "click" event.

* fast/events/ios/click-event-and-display-contents-expected.txt: Added.
* fast/events/ios/click-event-and-display-contents.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@246404 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/events/ios/click-event-and-display-contents-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/ios/click-event-and-display-contents.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/Element.h
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

index 3d68309..6a8c64e 100644 (file)
@@ -1,3 +1,16 @@
+2019-06-13  Antoine Quint  <graouts@apple.com>
+
+        "display: contents" Content click does not trigger
+        https://bugs.webkit.org/show_bug.cgi?id=198559
+        <rdar://problem/51488524>
+
+        Reviewed by Antti Koivisto.
+
+        Add a new test that checks that tapping on an element with "display: contents" correctly gets a "click" event.
+
+        * fast/events/ios/click-event-and-display-contents-expected.txt: Added.
+        * fast/events/ios/click-event-and-display-contents.html: Added.
+
 2019-06-13  Youenn Fablet  <youenn@apple.com>
 
         Update service worker test and expectation after revision 246363
diff --git a/LayoutTests/fast/events/ios/click-event-and-display-contents-expected.txt b/LayoutTests/fast/events/ios/click-event-and-display-contents-expected.txt
new file mode 100644 (file)
index 0000000..69cfc5a
--- /dev/null
@@ -0,0 +1,2 @@
+PASS
+
diff --git a/LayoutTests/fast/events/ios/click-event-and-display-contents.html b/LayoutTests/fast/events/ios/click-event-and-display-contents.html
new file mode 100644 (file)
index 0000000..73bd2dd
--- /dev/null
@@ -0,0 +1,41 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>This tests that a tap on an element with display: contents dispatches a "click" event.</title>
+<script src="../../../resources/basic-gestures.js"></script>
+<style>
+#target {
+    width: 100px;
+    height: 100px;
+    background-color: black;
+    display: contents;
+}
+</style>
+</head>
+<body>
+<div id="target">FAIL</div>
+<script>
+
+(function() {
+    if (!window.testRunner || !testRunner.runUIScript)
+        return;
+
+    testRunner.waitUntilDone();
+    testRunner.dumpAsText();
+
+    const target = document.getElementById("target");
+
+    target.addEventListener("click", event => {
+        document.getElementById("target").innerText = "PASS";
+        testRunner.notifyDone();
+    });
+
+    const bounds = target.getBoundingClientRect();
+    const x = bounds.left + bounds.width / 2;
+    const y = bounds.top + bounds.height / 2;
+    tapAtPoint(x, y);
+})();
+
+</script>
+</body>
+</html>
index 4ff3a5c..b27cc75 100644 (file)
@@ -1,3 +1,15 @@
+2019-06-13  Antoine Quint  <graouts@apple.com>
+
+        "display: contents" Content click does not trigger
+        https://bugs.webkit.org/show_bug.cgi?id=198559
+        <rdar://problem/51488524>
+
+        Reviewed by Antti Koivisto.
+
+        Test: fast/events/ios/click-event-and-display-contents.html
+
+        * dom/Element.h:
+
 2019-06-13  Takashi Komori  <Takashi.Komori@sony.com>
 
         [curl] Remove member objects of CurlRequest not to share by different threads.
index 8ded545..784e3cd 100644 (file)
@@ -540,7 +540,7 @@ public:
     LayoutRect absoluteEventHandlerBounds(bool& includesFixedPositionElements) override;
 
     const RenderStyle* existingComputedStyle() const;
-    const RenderStyle* renderOrDisplayContentsStyle() const;
+    WEBCORE_EXPORT const RenderStyle* renderOrDisplayContentsStyle() const;
 
     void setBeforePseudoElement(Ref<PseudoElement>&&);
     void setAfterPseudoElement(Ref<PseudoElement>&&);
index 8a0f7b3..5cf5890 100644 (file)
@@ -1,3 +1,14 @@
+2019-06-13  Antoine Quint  <graouts@apple.com>
+
+        "display: contents" Content click does not trigger
+        https://bugs.webkit.org/show_bug.cgi?id=198559
+        <rdar://problem/51488524>
+
+        Reviewed by Antti Koivisto.
+
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::commitPotentialTap):
+
 2019-06-13  Takashi Komori  <Takashi.Komori@sony.com>
 
         [curl] Remove member objects of CurlRequest not to share by different threads.
index 0887027..075a86a 100644 (file)
@@ -1058,7 +1058,13 @@ void WebPage::commitPotentialTap(OptionSet<WebEvent::Modifier> modifiers, uint64
         m_lastCommittedTapLocation = currentPotentialTapLocation;
     };
 
-    auto invalidTargetForSingleClick = !m_potentialTapNode || (!m_potentialTapNode->renderer() && !is<HTMLAreaElement>(m_potentialTapNode.get()));
+    auto invalidTargetForSingleClick = !m_potentialTapNode;
+    if (!invalidTargetForSingleClick) {
+        bool targetRenders = m_potentialTapNode->renderer();
+        if (!targetRenders && is<Element>(m_potentialTapNode.get()))
+            targetRenders = downcast<Element>(*m_potentialTapNode).renderOrDisplayContentsStyle();
+        invalidTargetForSingleClick = !targetRenders && !is<HTMLAreaElement>(m_potentialTapNode.get());
+    }
     if (invalidTargetForSingleClick) {
         // When the node has no click eventlistener, but it may have a dblclick one.
         handlePotentialDoubleTapForDoubleClickAtPoint(modifiers, lastLayerTreeTransactionId);