Title: [294305] branches/safari-613-branch
Revision
294305
Author
[email protected]
Date
2022-05-16 23:11:13 -0700 (Mon, 16 May 2022)

Log Message

Cherry-pick r294012. rdar://problem/92425915

    Fix inertness of pseudo-elements
    https://bugs.webkit.org/show_bug.cgi?id=239831

    Reviewed by Antti Koivisto.

    When we adjust style for a pseudo-element, `m_element` and `document().activeModalDialog()` are both null. So we accidentally reset inertness to false in those cases.

    Fix this by making checking for m_element's existence too.

    LayoutTests/imported/w3c:

    * web-platform-tests/inert/inert-pseudo-element-hittest-expected.txt: Added.
    * web-platform-tests/inert/inert-pseudo-element-hittest.html: Added.

    Source/WebCore:

    Test: imported/w3c/web-platform-tests/inert/inert-pseudo-element-hittest.html

    * style/StyleAdjuster.cpp:
    (WebCore::Style::Adjuster::adjust const):

    LayoutTests:

    * platform/ios-wk2/imported/w3c/web-platform-tests/inert/inert-pseudo-element-hittest-expected.txt: Added.

    Canonical link: https://commits.webkit.org/250446@main
    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294012 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Added Paths

Diff

Modified: branches/safari-613-branch/LayoutTests/ChangeLog (294304 => 294305)


--- branches/safari-613-branch/LayoutTests/ChangeLog	2022-05-17 06:11:08 UTC (rev 294304)
+++ branches/safari-613-branch/LayoutTests/ChangeLog	2022-05-17 06:11:13 UTC (rev 294305)
@@ -1,5 +1,50 @@
 2022-05-16  Alan Coon  <[email protected]>
 
+        Cherry-pick r294012. rdar://problem/92425915
+
+    Fix inertness of pseudo-elements
+    https://bugs.webkit.org/show_bug.cgi?id=239831
+    
+    Reviewed by Antti Koivisto.
+    
+    When we adjust style for a pseudo-element, `m_element` and `document().activeModalDialog()` are both null. So we accidentally reset inertness to false in those cases.
+    
+    Fix this by making checking for m_element's existence too.
+    
+    LayoutTests/imported/w3c:
+    
+    * web-platform-tests/inert/inert-pseudo-element-hittest-expected.txt: Added.
+    * web-platform-tests/inert/inert-pseudo-element-hittest.html: Added.
+    
+    Source/WebCore:
+    
+    Test: imported/w3c/web-platform-tests/inert/inert-pseudo-element-hittest.html
+    
+    * style/StyleAdjuster.cpp:
+    (WebCore::Style::Adjuster::adjust const):
+    
+    LayoutTests:
+    
+    * platform/ios-wk2/imported/w3c/web-platform-tests/inert/inert-pseudo-element-hittest-expected.txt: Added.
+    
+    Canonical link: https://commits.webkit.org/250446@main
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294012 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-05-10  Tim Nguyen  <[email protected]>
+
+            Fix inertness of pseudo-elements
+            https://bugs.webkit.org/show_bug.cgi?id=239831
+
+            Reviewed by Antti Koivisto.
+
+            When we adjust style for a pseudo-element, `m_element` and `document().activeModalDialog()` are both null. So we accidentally reset inertness to false in those cases.
+
+            Fix this by making checking for m_element's existence too.
+
+            * platform/ios-wk2/imported/w3c/web-platform-tests/inert/inert-pseudo-element-hittest-expected.txt: Added.
+
+2022-05-16  Alan Coon  <[email protected]>
+
         Cherry-pick r293987. rdar://problem/92775435
 
     Implement CSS :modal pseudo class

Modified: branches/safari-613-branch/LayoutTests/imported/w3c/ChangeLog (294304 => 294305)


--- branches/safari-613-branch/LayoutTests/imported/w3c/ChangeLog	2022-05-17 06:11:08 UTC (rev 294304)
+++ branches/safari-613-branch/LayoutTests/imported/w3c/ChangeLog	2022-05-17 06:11:13 UTC (rev 294305)
@@ -1,5 +1,51 @@
 2022-05-16  Alan Coon  <[email protected]>
 
+        Cherry-pick r294012. rdar://problem/92425915
+
+    Fix inertness of pseudo-elements
+    https://bugs.webkit.org/show_bug.cgi?id=239831
+    
+    Reviewed by Antti Koivisto.
+    
+    When we adjust style for a pseudo-element, `m_element` and `document().activeModalDialog()` are both null. So we accidentally reset inertness to false in those cases.
+    
+    Fix this by making checking for m_element's existence too.
+    
+    LayoutTests/imported/w3c:
+    
+    * web-platform-tests/inert/inert-pseudo-element-hittest-expected.txt: Added.
+    * web-platform-tests/inert/inert-pseudo-element-hittest.html: Added.
+    
+    Source/WebCore:
+    
+    Test: imported/w3c/web-platform-tests/inert/inert-pseudo-element-hittest.html
+    
+    * style/StyleAdjuster.cpp:
+    (WebCore::Style::Adjuster::adjust const):
+    
+    LayoutTests:
+    
+    * platform/ios-wk2/imported/w3c/web-platform-tests/inert/inert-pseudo-element-hittest-expected.txt: Added.
+    
+    Canonical link: https://commits.webkit.org/250446@main
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294012 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-05-10  Tim Nguyen  <[email protected]>
+
+            Fix inertness of pseudo-elements
+            https://bugs.webkit.org/show_bug.cgi?id=239831
+
+            Reviewed by Antti Koivisto.
+
+            When we adjust style for a pseudo-element, `m_element` and `document().activeModalDialog()` are both null. So we accidentally reset inertness to false in those cases.
+
+            Fix this by making checking for m_element's existence too.
+
+            * web-platform-tests/inert/inert-pseudo-element-hittest-expected.txt: Added.
+            * web-platform-tests/inert/inert-pseudo-element-hittest.html: Added.
+
+2022-05-16  Alan Coon  <[email protected]>
+
         Cherry-pick r293987. rdar://problem/92775435
 
     Implement CSS :modal pseudo class

Added: branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/inert/inert-pseudo-element-hittest-expected.txt (0 => 294305)


--- branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/inert/inert-pseudo-element-hittest-expected.txt	                        (rev 0)
+++ branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/inert/inert-pseudo-element-hittest-expected.txt	2022-05-17 06:11:13 UTC (rev 294305)
@@ -0,0 +1,6 @@
+Manual test: hover the green square, pass if it does not turn red.
+
+
+PASS Hit-testing cannot reach pseudo elements of inert nodes
+PASS Hit-testing can reach pseudo elements of non-inert nodes
+

Added: branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/inert/inert-pseudo-element-hittest.html (0 => 294305)


--- branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/inert/inert-pseudo-element-hittest.html	                        (rev 0)
+++ branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/inert/inert-pseudo-element-hittest.html	2022-05-17 06:11:13 UTC (rev 294305)
@@ -0,0 +1,65 @@
+<!DOCTYPE html>
+<meta charset="utf-8">
+<title>Hit-testing on pseudo elements of inert nodes</title>
+<link rel="author" title="Tim Nguyen" href=""
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+<script src=""
+<style>
+#target::before {
+    content: "";
+    width: 50px;
+    height: 50px;
+    background-color: green;
+    display: inline-block;
+}
+
+#target:hover::before,
+#target:active::before {
+    background-color: red;
+}
+</style>
+<p>Manual test: hover the green square, pass if it does not turn red.</p>
+<div id="target" inert></div>
+<script>
+const events = [
+    "mousedown", "mouseenter", "mousemove", "mouseover",
+    "pointerdown", "pointerenter", "pointermove", "pointerover",
+];
+async function mouseDownAndGetEvents(test) {
+    const receivedEvents = [];
+    for (let event of events) {
+        target.addEventListener(event, () => {
+            receivedEvents.push(event);
+        }, { once: true, capture: true });
+    }
+
+    await new test_driver.Actions()
+        .pointerMove(0, 0, { origin: target })
+        .pointerDown()
+        .send();
+    test.add_cleanup(() => test_driver.click(document.body));
+
+    // Exact order of events is not interoperable.
+    receivedEvents.sort();
+    return receivedEvents;
+}
+promise_test(async function() {
+    const receivedEvents = await mouseDownAndGetEvents(this);
+    assert_array_equals(receivedEvents, [], "target got no event");
+    assert_false(target.matches(":active"), "target is not active");
+    assert_false(target.matches(":hover"), "target is not hovered");
+    assert_equals(getComputedStyle(target, "::before").backgroundColor, "rgb(0, 128, 0)", "#target::before has no hover style");
+}, "Hit-testing cannot reach pseudo elements of inert nodes");
+
+promise_test(async function() {
+    target.inert = false;
+    const receivedEvents = await mouseDownAndGetEvents(this);
+    assert_array_equals(receivedEvents, events, "target got all events");
+    assert_true(target.matches(":active"), "target is active");
+    assert_true(target.matches(":hover"), "target is hovered");
+    assert_equals(getComputedStyle(target, "::before").backgroundColor, "rgb(255, 0, 0)", "#target::before has hover style");
+}, "Hit-testing can reach pseudo elements of non-inert nodes");
+</script>

Added: branches/safari-613-branch/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/inert/inert-pseudo-element-hittest-expected.txt (0 => 294305)


--- branches/safari-613-branch/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/inert/inert-pseudo-element-hittest-expected.txt	                        (rev 0)
+++ branches/safari-613-branch/LayoutTests/platform/ios-wk2/imported/w3c/web-platform-tests/inert/inert-pseudo-element-hittest-expected.txt	2022-05-17 06:11:13 UTC (rev 294305)
@@ -0,0 +1,6 @@
+Manual test: hover the green square, pass if it does not turn red.
+
+
+PASS Hit-testing cannot reach pseudo elements of inert nodes
+FAIL Hit-testing can reach pseudo elements of non-inert nodes assert_array_equals: target got all events lengths differ, expected array ["mousedown", "mouseenter", "mousemove", "mouseover", "pointerdown", "pointerenter", "pointermove", "pointerover"] length 8, got [] length 0
+

Modified: branches/safari-613-branch/Source/WebCore/ChangeLog (294304 => 294305)


--- branches/safari-613-branch/Source/WebCore/ChangeLog	2022-05-17 06:11:08 UTC (rev 294304)
+++ branches/safari-613-branch/Source/WebCore/ChangeLog	2022-05-17 06:11:13 UTC (rev 294305)
@@ -1,5 +1,53 @@
 2022-05-16  Alan Coon  <[email protected]>
 
+        Cherry-pick r294012. rdar://problem/92425915
+
+    Fix inertness of pseudo-elements
+    https://bugs.webkit.org/show_bug.cgi?id=239831
+    
+    Reviewed by Antti Koivisto.
+    
+    When we adjust style for a pseudo-element, `m_element` and `document().activeModalDialog()` are both null. So we accidentally reset inertness to false in those cases.
+    
+    Fix this by making checking for m_element's existence too.
+    
+    LayoutTests/imported/w3c:
+    
+    * web-platform-tests/inert/inert-pseudo-element-hittest-expected.txt: Added.
+    * web-platform-tests/inert/inert-pseudo-element-hittest.html: Added.
+    
+    Source/WebCore:
+    
+    Test: imported/w3c/web-platform-tests/inert/inert-pseudo-element-hittest.html
+    
+    * style/StyleAdjuster.cpp:
+    (WebCore::Style::Adjuster::adjust const):
+    
+    LayoutTests:
+    
+    * platform/ios-wk2/imported/w3c/web-platform-tests/inert/inert-pseudo-element-hittest-expected.txt: Added.
+    
+    Canonical link: https://commits.webkit.org/250446@main
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294012 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-05-10  Tim Nguyen  <[email protected]>
+
+            Fix inertness of pseudo-elements
+            https://bugs.webkit.org/show_bug.cgi?id=239831
+
+            Reviewed by Antti Koivisto.
+
+            When we adjust style for a pseudo-element, `m_element` and `document().activeModalDialog()` are both null. So we accidentally reset inertness to false in those cases.
+
+            Fix this by making checking for m_element's existence too.
+
+            Test: imported/w3c/web-platform-tests/inert/inert-pseudo-element-hittest.html
+
+            * style/StyleAdjuster.cpp:
+            (WebCore::Style::Adjuster::adjust const):
+
+2022-05-16  Alan Coon  <[email protected]>
+
         Cherry-pick r293987. rdar://problem/92775435
 
     Implement CSS :modal pseudo class

Modified: branches/safari-613-branch/Source/WebCore/style/StyleAdjuster.cpp (294304 => 294305)


--- branches/safari-613-branch/Source/WebCore/style/StyleAdjuster.cpp	2022-05-17 06:11:08 UTC (rev 294304)
+++ branches/safari-613-branch/Source/WebCore/style/StyleAdjuster.cpp	2022-05-17 06:11:13 UTC (rev 294305)
@@ -540,19 +540,18 @@
     if (isInertSubtreeRoot(m_element))
         style.setEffectiveInert(true);
 
-    // Make sure the active dialog is interactable when the whole document is blocked by the modal dialog
-    if (m_element == m_document.activeModalDialog() && !hasInertAttribute(m_element))
-        style.setEffectiveInert(false);
+    if (m_element) {
+        // Make sure the active dialog is interactable when the whole document is blocked by the modal dialog
+        if (m_element == m_document.activeModalDialog() && !hasInertAttribute(m_element))
+            style.setEffectiveInert(false);
 
-    if (m_element)
         style.setEventListenerRegionTypes(computeEventListenerRegionTypes(*m_element, m_parentStyle.eventListenerRegionTypes()));
 
 #if ENABLE(TEXT_AUTOSIZING)
-    if (m_element && m_document.settings().textAutosizingUsesIdempotentMode())
-        adjustForTextAutosizing(style, *m_element);
+        if (m_document.settings().textAutosizingUsesIdempotentMode())
+            adjustForTextAutosizing(style, *m_element);
 #endif
 
-    if (m_element) {
         if (auto observer = m_element->document().modalContainerObserverIfExists()) {
             if (observer->shouldHide(*m_element))
                 style.setDisplay(DisplayType::None);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to