-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WebKit export: CSS Custom Highlights add WPT painting-prioritization (#…
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
css/css-highlight-api/painting/custom-highlight-painting-prioritization-003-ref.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,15 @@ | ||
<!DOCTYPE html> | ||
<meta charset="UTF-8"> | ||
<title>CSS Highlight API Test: Non-conflicting attributes</title> | ||
<style> | ||
#blue { | ||
background-color: blue; | ||
color: white; | ||
} | ||
#yellow { | ||
background-color: yellow; | ||
} | ||
</style> | ||
<body> | ||
<p>This <span id="blue">is an</span><span id="yellow"> example</span> of two overlapping highlights</p> | ||
</body> |
36 changes: 36 additions & 0 deletions
36
css/css-highlight-api/painting/custom-highlight-painting-prioritization-003.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,36 @@ | ||
<!DOCTYPE html> | ||
<meta charset="UTF-8"> | ||
<title>CSS Highlight API Test: Non-conflicting attributes</title> | ||
<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/#priorities"> | ||
<link rel="match" href="custom-highlight-painting-prioritization-003-ref.html"> | ||
<meta name="assert" value="Non-conflicting attributes for highlights will be painted even if lower priority"> | ||
<style> | ||
::highlight(highlight-1) { | ||
background-color: blue; | ||
color: white; | ||
} | ||
::highlight(highlight-2) { | ||
background-color: yellow; | ||
} | ||
</style> | ||
<body> | ||
<p>This is an example of two overlapping highlights</p> | ||
</body> | ||
<script> | ||
const text = document.querySelector("p").firstChild; | ||
|
||
// Create two overlapping highlights | ||
const range1 = new Range(); | ||
range1.setStart(text, 5); | ||
range1.setEnd(text, 10); | ||
|
||
const range2 = new Range(); | ||
range2.setStart(text, 10); | ||
range2.setEnd(text, 18); | ||
|
||
const highlight1 = new Highlight(range1); | ||
const highlight2 = new Highlight(range2); | ||
|
||
CSS.highlights.set("highlight-1", highlight1); | ||
CSS.highlights.set("highlight-2", highlight2); | ||
</script> |