forked from WebKit/WebKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make fullscreen elements match the :modal pseudo-class
https://bugs.webkit.org/show_bug.cgi?id=246004 rdar://100782746 Reviewed by Antti Koivisto. https://w3c.github.io/csswg-drafts/selectors/#modal-state > For example, the dialog element is :modal when opened with the showModal() API. > Similarly, a :fullscreen element is also :modal when opened with the requestFullscreen() API, since this prevents interaction with the rest of the page. We implemented the "prevents interaction with the rest of the page" part in https://commits.webkit.org/253803@main Relevant CSSWG discussion: w3c/csswg-drafts#7311 Also, we don't need to worry about the modal dialog in fullscreen mode case, since the fullscreen API forbids <dialog> elements. * LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/css/selectors/modal-pseudo-class-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/modal-pseudo-class-in-has-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/selectors/invalidation/modal-pseudo-class-in-has.html: * LayoutTests/imported/w3c/web-platform-tests/css/selectors/modal-pseudo-class-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/css/selectors/modal-pseudo-class.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/selectors/w3c-import.log: * Source/WebCore/css/SelectorCheckerTestFunctions.h: (WebCore::matchesModalPseudoClass): * Source/WebCore/dom/Element.cpp: (WebCore::Element::setFullscreenFlag): Canonical link: https://commits.webkit.org/257572@main
- Loading branch information
Showing
8 changed files
with
120 additions
and
8 deletions.
There are no files selected for viewing
6 changes: 4 additions & 2 deletions
6
.../w3c/web-platform-tests/css/selectors/invalidation/modal-pseudo-class-in-has-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
This is some text. | ||
|
||
PASS :modal pseudo-class is not active with dialog.show() | ||
PASS :modal pseudo-class invalidation with showModal+close | ||
PASS :modal pseudo-class invalidation with showModal+remove | ||
PASS :modal pseudo-class invalidation with showModal + close | ||
PASS :modal pseudo-class invalidation with showModal + remove | ||
PASS :modal pseudo-class invalidation with requestFullscreen + exitFullscreen | ||
PASS :modal pseudo-class invalidation with requestFullscreen + remove | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
LayoutTests/imported/w3c/web-platform-tests/css/selectors/modal-pseudo-class-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
|
||
PASS Test that :modal matches modal <dialog> | ||
PASS Test that :modal matches the fullscreen element | ||
|
59 changes: 59 additions & 0 deletions
59
LayoutTests/imported/w3c/web-platform-tests/css/selectors/modal-pseudo-class.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"/> | ||
<title>:modal pseudo-class</title> | ||
<link rel="author" title="Tim Nguyen" href="https://github.com/nt1m"> | ||
<link rel="author" title="Jihwan Marc Kim" href="mailto:[email protected]" /> | ||
<link rel="help" href="https://drafts.csswg.org/selectors/#modal-state"> | ||
<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> | ||
|
||
<dialog id="dialog">Just another dialog.</dialog> | ||
<div id="container"> | ||
<button id="btn"/> | ||
</div> | ||
|
||
<script> | ||
test(() => { | ||
const dialog = document.getElementById("dialog"); | ||
assert_false(dialog.matches(":modal"), "dialog is initially closed (does not match :modal)"); | ||
|
||
dialog.showModal(); | ||
assert_true(dialog.matches(":modal"), "dialog should match :modal after showModal() call"); | ||
|
||
dialog.close(); | ||
assert_false(dialog.matches(":modal"), "dialog should no longer match :modal after close() call"); | ||
|
||
dialog.show(); | ||
assert_false(dialog.matches(":modal"), "dialog shouldn't match :modal after show() call"); | ||
|
||
dialog.close(); | ||
dialog.showModal(); | ||
assert_true(dialog.matches(":modal"), "dialog should match :modal after showModal() call"); | ||
|
||
dialog.remove(); | ||
assert_false(dialog.matches(":modal"), "dialog shouldn't match :modal after being removed from document"); | ||
document.body.append(dialog); | ||
assert_false(dialog.matches(":modal"), "dialog shouldn't match :modal after being re-appended to document"); | ||
|
||
dialog.close(); | ||
}, "Test that :modal matches modal <dialog>"); | ||
|
||
promise_test(async () => { | ||
const container = document.getElementById("container"); | ||
const btn = document.getElementById("btn"); | ||
|
||
assert_false(container.matches(":modal"), "before requestFullscreen (does not match :modal)"); | ||
|
||
await test_driver.click(btn); | ||
|
||
await container.requestFullscreen(); | ||
|
||
assert_true(container.matches(":modal"), ":fullscreen should match :modal"); | ||
|
||
await document.exitFullscreen(); | ||
|
||
assert_false(container.matches(":modal"), "after exitFullscreen (does not match :modal)"); | ||
}, "Test that :modal matches the fullscreen element"); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...orm/mac-wk1/imported/w3c/web-platform-tests/css/selectors/modal-pseudo-class-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
|
||
PASS Test that :modal matches modal <dialog> | ||
FAIL Test that :modal matches the fullscreen element assert_true: :fullscreen should match :modal expected true got false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters