Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Implement CSS :modal pseudo class
https://bugs.webkit.org/show_bug.cgi?id=240109 Reviewed by Simon Fraser. LayoutTests/imported/w3c: Add and extend tests for :modal pseudo-class. * web-platform-tests/css/selectors/invalidation/modal-pseudo-class-in-has-expected.txt: Added. * web-platform-tests/css/selectors/invalidation/modal-pseudo-class-in-has.html: Added. * web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-show-modal.html: Source/WebCore: Test: imported/w3c/web-platform-tests/css/selectors/invalidation/modal-pseudo-class-in-has.html Renames :-internal-modal-dialog to :modal and adds :has() invalidation support. * css/CSSSelector.cpp: (WebCore::CSSSelector::selectorText const): * css/CSSSelector.h: * css/SelectorChecker.cpp: (WebCore::SelectorChecker::checkOne const): * css/SelectorCheckerTestFunctions.h: (WebCore::matchesModalPseudoClass): (WebCore::matchesModalDialogPseudoClass): Deleted. * css/SelectorPseudoClassAndCompatibilityElementMap.in: * css/dialog.css: (dialog:modal): (dialog:-internal-modal-dialog): Deleted. * css/parser/CSSSelectorParser.cpp: (WebCore::CSSSelectorParser::consumePseudo): * cssjit/SelectorCompiler.cpp: (WebCore::SelectorCompiler::JSC_DEFINE_JIT_OPERATION): (WebCore::SelectorCompiler::addPseudoClassType): * html/HTMLDialogElement.cpp: (WebCore::HTMLDialogElement::showModal): (WebCore::HTMLDialogElement::close): (WebCore::HTMLDialogElement::removedFromAncestor): (WebCore::HTMLDialogElement::setIsModal): * html/HTMLDialogElement.h: LayoutTests: Removes :-internal-modal-dialog from internal pseudo classes. * fast/css/pseudo-class-internal-expected.txt: * fast/css/pseudo-class-internal.html: Canonical link: https://commits.webkit.org/250424@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@293987 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
18 changed files
with
148 additions
and
28 deletions.
There are no files selected for viewing
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
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
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
| @@ -0,0 +1,6 @@ | ||
| 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 | ||
|
|
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
| @@ -0,0 +1,44 @@ | ||
| <!DOCTYPE html> | ||
| <meta charset="utf-8" /> | ||
| <title>CSS Selectors Invalidation: :modal pseudo class in :has()</title> | ||
| <link rel="author" title="Tim Nguyen" href="https://github.com/nt1m"> | ||
| <link rel="help" href="https://drafts.csswg.org/selectors/#relational"> | ||
| <script src="/resources/testharness.js"></script> | ||
| <script src="/resources/testharnessreport.js"></script> | ||
| <style> | ||
| #subject:has(#dialog:modal) { color: green } | ||
| </style> | ||
| <div id="subject"> | ||
| This is some text. | ||
| <dialog id="dialog">This is a dialog</dialog> | ||
| </div> | ||
| <script> | ||
| test(function() { | ||
| assert_equals(getComputedStyle(subject).color, "rgb(0, 0, 0)", | ||
| "ancestor should be black since dialog is not modal"); | ||
| dialog.show(); | ||
| assert_equals(getComputedStyle(subject).color, "rgb(0, 0, 0)", | ||
| "ancestor should be black since dialog is not modal"); | ||
| dialog.close(); | ||
| }, ":modal pseudo-class is not active with dialog.show()"); | ||
| test(function() { | ||
| assert_equals(getComputedStyle(subject).color, "rgb(0, 0, 0)", | ||
| "ancestor should be black"); | ||
| dialog.showModal(); | ||
| assert_equals(getComputedStyle(subject).color, "rgb(0, 128, 0)", | ||
| "ancestor should be green since dialog is shown modally"); | ||
| dialog.close(); | ||
| assert_equals(getComputedStyle(subject).color, "rgb(0, 0, 0)", | ||
| "ancestor should be black since dialog is closed"); | ||
| }, ":modal pseudo-class invalidation with showModal+close"); | ||
| test(function() { | ||
| assert_equals(getComputedStyle(subject).color, "rgb(0, 0, 0)", | ||
| "ancestor should be black"); | ||
| dialog.showModal(); | ||
| assert_equals(getComputedStyle(subject).color, "rgb(0, 128, 0)", | ||
| "ancestor should be green since dialog is shown modally"); | ||
| dialog.remove(); | ||
| assert_equals(getComputedStyle(subject).color, "rgb(0, 0, 0)", | ||
| "ancestor should be black since dialog is closed"); | ||
| }, ":modal pseudo-class invalidation with showModal+remove"); | ||
| </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
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
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
| @@ -185,7 +185,7 @@ namespace WebCore { | ||
| #if ENABLE(ATTACHMENT_ELEMENT) | ||
| PseudoClassHasAttachment, | ||
| #endif | ||
| PseudoClassModalDialog, | ||
| PseudoClassModal, | ||
| }; | ||
|
|
||
| enum PseudoElementType { | ||
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
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
| @@ -16,7 +16,7 @@ dialog[open] { | ||
| display: block; | ||
| } | ||
|
|
||
| dialog:-internal-modal-dialog { | ||
| dialog:modal { | ||
| position: fixed; | ||
| overflow: auto; | ||
| inset-block-start: 0; | ||
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
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