Skip to content
Permalink
Browse files
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
  • Loading branch information
nt1m committed May 10, 2022
1 parent 09604eb commit 6032dcf56c00ffd13afb426fe8984d3ef0e3e8ed
Showing 7 changed files with 126 additions and 7 deletions.
@@ -1,3 +1,16 @@
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-10 Brent Fulgham <bfulgham@apple.com>

Remove abandoned CSSDeferredParser implementation and feature flag
@@ -1,3 +1,17 @@
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-09 Oriol Brufau <obrufau@igalia.com>

[cssom] Don't index perspective/transform-origin-* in computed styles
@@ -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

@@ -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>
@@ -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

@@ -1,3 +1,19 @@
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-10 Simon Fraser <simon.fraser@apple.com>

Optimize Replayer::applyItem() slightly
@@ -551,19 +551,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);

0 comments on commit 6032dcf

Please sign in to comment.