-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
LibWeb: Match selectors against the live DOM from Rust #10795
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 26 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
ba4481a
LibWeb: Read selector identifiers through live DOM wrappers
awesomekling 15be6d8
LibWeb: Match common tag selectors through live DOM wrappers
awesomekling 38d943e
LibWeb: Read root selector state from the live DOM wrapper
awesomekling 0c75a93
LibWeb: Compare selector element types through live wrappers
awesomekling 8cb51e7
LibWeb: Read selector element facts through live accessors
awesomekling e99c1dc
LibWeb: Resolve selector namespaces through live accessors
awesomekling c575bb9
LibWeb: Match tag names through live DOM string views
awesomekling 3a652c9
LibWeb: Match quirks classes through live DOM views
awesomekling 710ea51
LibWeb: Match attributes through live DOM views
awesomekling 82b59ee
LibWeb: Match link states through live DOM facts
awesomekling afbde3f
LibWeb: Match focus states through live DOM facts
awesomekling eaa6da1
LibWeb: Match fullscreen through a live DOM fact
awesomekling 001df3b
LibWeb: Match headings through a live DOM fact
awesomekling 89bd83b
LibWeb: Match open popovers through live DOM facts
awesomekling 8ba821e
LibWeb: Match direction through a live DOM fact
awesomekling 426605c
LibWeb: Match custom states through a live DOM query
awesomekling 00adcea
LibWeb: Match language ranges in Rust
awesomekling f87c6ac
LibWeb: Match common states through live DOM facts
awesomekling 31de365
LibWeb: Match media states through live DOM facts
awesomekling c50b632
LibWeb: Match remaining states through live DOM facts
awesomekling e50a76d
LibWeb: Treat selector navigation as live DOM reads
awesomekling 5ad6954
LibWeb: Remove the retired selector callback counter
awesomekling a9b1d47
LibWeb: Remove redundant selector DOM wrapper state
awesomekling f71e80b
LibWeb: Remove the unused open-state parameter
awesomekling 94681bc
LibWeb: Match foreign type selectors case-sensitively
awesomekling 5f9a9c2
LibWeb: Match ID selectors case-insensitively in quirks mode
awesomekling c1a7fd1
LibWeb: Strengthen foreign type selector coverage
awesomekling File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
1,437 changes: 1,252 additions & 185 deletions
1,437
Libraries/LibWeb/CSS/Rust/src/selector_engine.rs
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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
13 changes: 13 additions & 0 deletions
13
Tests/LibWeb/Text/expected/css/live-media-state-selectors.txt
This file contains hidden or 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,13 @@ | ||
| video:buffering: true | ||
| video:muted: false | ||
| video:paused: true | ||
| video:playing: false | ||
| video:seeking: false | ||
| video:stalled: false | ||
| video:muted after mutation: true | ||
| div:buffering: false | ||
| div:muted: false | ||
| div:paused: false | ||
| div:playing: false | ||
| div:seeking: false | ||
| div:stalled: false |
10 changes: 10 additions & 0 deletions
10
Tests/LibWeb/Text/expected/css/live-selector-identifiers.txt
This file contains hidden or 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,10 @@ | ||
| initial match: true | ||
| initial color: rgb(1, 2, 3) | ||
| mutated match: true | ||
| stale match: false | ||
| mutated color: rgb(4, 5, 6) | ||
| disconnected match: true | ||
| shadow initial match: true | ||
| shadow mutated match: true | ||
| document root: true | ||
| disconnected html root: true |
This file contains hidden or 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 hidden or 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
1 change: 1 addition & 0 deletions
1
Tests/LibWeb/Text/expected/quirks-mode-case-insensitive-id-selector.txt
This file contains hidden or 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 @@ | ||
| ParentNode.querySelector matches ID selectors case-insensitively in quirks mode: true |
19 changes: 19 additions & 0 deletions
19
Tests/LibWeb/Text/input/css/live-media-state-selectors.html
This file contains hidden or 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,19 @@ | ||
| <!DOCTYPE html> | ||
| <script src="../include.js"></script> | ||
| <video></video> | ||
| <div></div> | ||
| <script> | ||
| test(() => { | ||
| const video = document.querySelector("video"); | ||
| const div = document.querySelector("div"); | ||
|
|
||
| for (const pseudoClass of ["buffering", "muted", "paused", "playing", "seeking", "stalled"]) | ||
| println(`video:${pseudoClass}: ${video.matches(`:${pseudoClass}`)}`); | ||
|
|
||
| video.muted = true; | ||
| println(`video:muted after mutation: ${video.matches(":muted")}`); | ||
|
|
||
| for (const pseudoClass of ["buffering", "muted", "paused", "playing", "seeking", "stalled"]) | ||
| println(`div:${pseudoClass}: ${div.matches(`:${pseudoClass}`)}`); | ||
| }); | ||
| </script> |
51 changes: 51 additions & 0 deletions
51
Tests/LibWeb/Text/input/css/live-selector-identifiers.html
This file contains hidden or 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,51 @@ | ||
| <!DOCTYPE html> | ||
| <script src="../include.js"></script> | ||
| <style> | ||
| #old-parent.old-parent-class #target.old-target-class { | ||
| color: rgb(1, 2, 3); | ||
| } | ||
|
|
||
| #new-parent.new-parent-class #target.new-target-class { | ||
| color: rgb(4, 5, 6); | ||
| } | ||
| </style> | ||
| <div id="old-parent" class="old-parent-class"> | ||
| <span id="target" class="old-target-class"></span> | ||
| </div> | ||
| <div id="host"></div> | ||
| <script> | ||
| test(() => { | ||
| const target = document.querySelector("span"); | ||
| const parent = target.parentElement; | ||
|
|
||
| println(`initial match: ${target.matches("#target.old-target-class")}`); | ||
| println(`initial color: ${getComputedStyle(target).color}`); | ||
|
|
||
| parent.id = "new-parent"; | ||
| parent.className = "new-parent-class"; | ||
| target.className = "new-target-class"; | ||
|
|
||
| println(`mutated match: ${target.matches("#target.new-target-class")}`); | ||
| println(`stale match: ${target.matches("#target.old-target-class")}`); | ||
| println(`mutated color: ${getComputedStyle(target).color}`); | ||
|
|
||
| const disconnected = document.createElement("div"); | ||
| disconnected.id = "a-long-disconnected-identifier"; | ||
| disconnected.className = "short a-long-disconnected-class-name"; | ||
| println(`disconnected match: ${disconnected.matches("#a-long-disconnected-identifier.a-long-disconnected-class-name")}`); | ||
|
|
||
| const shadow_root = document.querySelector("#host").attachShadow({ mode: "open" }); | ||
| const shadow_target = document.createElement("span"); | ||
| shadow_target.id = "shadow-old"; | ||
| shadow_target.className = "shadow-old-class"; | ||
| shadow_root.appendChild(shadow_target); | ||
| println(`shadow initial match: ${shadow_target.matches("#shadow-old.shadow-old-class")}`); | ||
| shadow_target.id = "shadow-new"; | ||
| shadow_target.className = "shadow-new-class"; | ||
| println(`shadow mutated match: ${shadow_target.matches("#shadow-new.shadow-new-class")}`); | ||
|
|
||
| const disconnected_html = document.createElement("html"); | ||
| println(`document root: ${document.documentElement.matches(":root")}`); | ||
| println(`disconnected html root: ${disconnected_html.matches(":root")}`); | ||
| }); | ||
| </script> |
This file contains hidden or 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 hidden or 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
2 changes: 1 addition & 1 deletion
2
Tests/LibWeb/Text/input/quirks-mode-case-insensitive-class-selector.html
This file contains hidden or 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
9 changes: 9 additions & 0 deletions
9
Tests/LibWeb/Text/input/quirks-mode-case-insensitive-id-selector.html
This file contains hidden or 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,9 @@ | ||
| <!DOCTYPE quirks> | ||
| <script src="include.js"></script> | ||
| <div id="tEsT"></div> | ||
| <script> | ||
| test(() => { | ||
| let divElement = document.querySelector("#test"); | ||
| println(`ParentNode.querySelector matches ID selectors case-insensitively in quirks mode: ${divElement instanceof Element}`); | ||
| }); | ||
| </script> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.