Skip to content

Commit

Permalink
Cherry-pick r294012. rdar://problem/92425915
Browse files Browse the repository at this point in the history
    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

Canonical link: https://commits.webkit.org/245886.580@safari-613-branch
git-svn-id: https://svn.webkit.org/repository/webkit/branches/safari-613-branch@294305 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
alancoon committed May 18, 2022
1 parent 12eaea8 commit 6a5122b
Show file tree
Hide file tree
Showing 7 changed files with 222 additions and 7 deletions.
45 changes: 45 additions & 0 deletions LayoutTests/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,48 @@
2022-05-16 Alan Coon <alancoon@apple.com>

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 <ntim@apple.com>

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 <alancoon@apple.com>

Cherry-pick r293987. rdar://problem/92775435
Expand Down
46 changes: 46 additions & 0 deletions LayoutTests/imported/w3c/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,49 @@
2022-05-16 Alan Coon <alancoon@apple.com>

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 <ntim@apple.com>

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 <alancoon@apple.com>

Cherry-pick r293987. rdar://problem/92775435
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Original file line number Diff line number Diff line change
@@ -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="https://github.com/nt1m">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<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>
Original file line number Diff line number Diff line change
@@ -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

48 changes: 48 additions & 0 deletions Source/WebCore/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,51 @@
2022-05-16 Alan Coon <alancoon@apple.com>

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 <ntim@apple.com>

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 <alancoon@apple.com>

Cherry-pick r293987. rdar://problem/92775435
Expand Down
13 changes: 6 additions & 7 deletions Source/WebCore/style/StyleAdjuster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,19 +540,18 @@ void Adjuster::adjust(RenderStyle& style, const RenderStyle* userAgentAppearance
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);
Expand Down

0 comments on commit 6a5122b

Please sign in to comment.