Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add priority for Highlight
https://bugs.webkit.org/show_bug.cgi?id=257611 rdar://110125853 Reviewed by Megan Gardner. Included implementation for priority and insertion order of css highlights. Fixed selection inconsistency to always have active selection painted the same, above all markedTexts. Fixed painting foreground color text so non-clashing styles of lower priority are still painted. Added implementation for repainting when priority changes. Added implementation for painting same semi-transparent overlapping highlight to be painted as a union. Added a check if users assigned text color to take text color of prioritized highlight. * LayoutTests/TestExpectations: * LayoutTests/imported/w3c/web-platform-tests/css/css-highlight-api/highlight-priority-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-highlight-api/highlight-priority-painting-expected.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-highlight-api/highlight-priority-painting-ref.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-highlight-api/highlight-priority-painting.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-highlight-api/highlight-priority.html: Added. * Source/WebCore/Modules/highlight/Highlight.cpp: (WebCore::Highlight::setPriority): * Source/WebCore/Modules/highlight/Highlight.h: (WebCore::Highlight::setPriority): Deleted. * Source/WebCore/Modules/highlight/HighlightRegister.cpp: (WebCore::HighlightRegister::setFromMapLike): (WebCore::HighlightRegister::clear): (WebCore::HighlightRegister::remove): * Source/WebCore/Modules/highlight/HighlightRegister.h: (WebCore::HighlightRegister::highlightNames const): * Source/WebCore/rendering/MarkedText.cpp: (WebCore::MarkedText::subdivide): (WebCore::MarkedText::collectForHighlights): * Source/WebCore/rendering/MarkedText.h: (WebCore::MarkedText::MarkedText): (WebCore::MarkedText::isHashTableDeletedValue const): (WTF::add): (WTF::HashTraits<WebCore::MarkedText>::constructDeletedValue): (WTF::HashTraits<WebCore::MarkedText>::isDeletedValue): (WTF::DefaultHash<WebCore::MarkedText>::hash): (WTF::DefaultHash<WebCore::MarkedText>::equal): (WebCore::MarkedText::operator== const): Deleted. * Source/WebCore/rendering/StyledMarkedText.cpp: (WebCore::resolveStyleForMarkedText): (WebCore::coalesceAdjacentWithSameRanges): (WebCore::orderHighlights): (WebCore::StyledMarkedText::subdivideAndResolve): (WebCore::StyledMarkedText::coalesceAdjacentWithEqualDecorations): * Source/WebCore/rendering/TextBoxPainter.cpp: (WebCore::TextBoxPainter<TextBoxPath>::paintForegroundAndDecorations): * Source/WebCore/rendering/TextPaintStyle.h: Canonical link: https://commits.webkit.org/265812@main
- Loading branch information
Showing
14 changed files
with
373 additions
and
27 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
4 changes: 4 additions & 0 deletions
4
...sts/imported/w3c/web-platform-tests/css/css-highlight-api/highlight-priority-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,4 @@ | ||
Green Yellow Blue Yellow-Blue | ||
|
||
PASS Highlight priority attribute is mutable | ||
|
23 changes: 23 additions & 0 deletions
23
...ed/w3c/web-platform-tests/css/css-highlight-api/highlight-priority-painting-expected.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,23 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Highlight priority attribute painting</title> | ||
<style> | ||
#green-highlight { | ||
background-color: green; | ||
} | ||
.yellow-highlight { | ||
background-color: yellow; | ||
} | ||
.blue-highlight { | ||
background-color: blue; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<span id="green-highlight">Green</span> | ||
<span class="yellow-highlight">Yellow</span> | ||
<span class="blue-highlight">Blue</span> | ||
<span class="yellow-highlight">Yellow</span><span class="blue-highlight">-Blue</span> | ||
</body> | ||
</html> |
23 changes: 23 additions & 0 deletions
23
...mported/w3c/web-platform-tests/css/css-highlight-api/highlight-priority-painting-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,23 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Highlight priority attribute painting</title> | ||
<style> | ||
#green-highlight { | ||
background-color: green; | ||
} | ||
.yellow-highlight { | ||
background-color: yellow; | ||
} | ||
.blue-highlight { | ||
background-color: blue; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<span id="green-highlight">Green</span> | ||
<span class="yellow-highlight">Yellow</span> | ||
<span class="blue-highlight">Blue</span> | ||
<span class="yellow-highlight">Yellow</span><span class="blue-highlight">-Blue</span> | ||
</body> | ||
</html> |
65 changes: 65 additions & 0 deletions
65
...ts/imported/w3c/web-platform-tests/css/css-highlight-api/highlight-priority-painting.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,65 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Highlight priority attribute painting correctness</title> | ||
<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/#priorities"> | ||
<link rel="match" href="highlight-priority-painting-ref.html"> | ||
<style> | ||
::highlight(yellow-highlight) { | ||
background-color: yellow; | ||
} | ||
::highlight(green-highlight) { | ||
background-color: green; | ||
} | ||
::highlight(blue-highlight) { | ||
background-color: blue; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<span id="green-highlight">Green</span> | ||
<span id="yellow-highlight">Yellow</span> | ||
<span id="blue-highlight">Blue</span> | ||
<span id="yellow-blue-highlight">Yellow-Blue</span> | ||
|
||
<script> | ||
let yellowBlue = document.getElementById("yellow-blue-highlight"); | ||
let green = document.getElementById("green-highlight"); | ||
let highlightGreen = new Highlight(new StaticRange({ | ||
startContainer: green.childNodes[0], | ||
startOffset: 0, | ||
endContainer: green.childNodes[0], | ||
endOffset: 5 | ||
})); | ||
let yellow = document.getElementById("yellow-highlight"); | ||
let highlightYellow = new Highlight(new StaticRange({ | ||
startContainer: yellow.childNodes[0], | ||
startOffset: 0, | ||
endContainer: yellow.childNodes[0], | ||
endOffset: 6 | ||
}), new StaticRange({ | ||
startContainer: yellowBlue.childNodes[0], | ||
startOffset: 0, | ||
endContainer: yellowBlue.childNodes[0], | ||
endOffset: 6 | ||
})); | ||
let blue = document.getElementById("blue-highlight"); | ||
let highlightBlue = new Highlight(new StaticRange({ | ||
startContainer: blue.childNodes[0], | ||
startOffset: 0, | ||
endContainer: blue.childNodes[0], | ||
endOffset: 4 | ||
}), new StaticRange({ | ||
startContainer: yellowBlue.childNodes[0], | ||
startOffset: 0, | ||
endContainer: yellowBlue.childNodes[0], | ||
endOffset: 11 | ||
})); | ||
CSS.highlights.set("yellow-highlight", highlightYellow); | ||
CSS.highlights.set("green-highlight", highlightGreen); | ||
CSS.highlights.set("blue-highlight", highlightBlue); | ||
highlightYellow.priority = 10; | ||
highlightBlue.priority = -1; | ||
</script> | ||
</body> | ||
</html> |
78 changes: 78 additions & 0 deletions
78
LayoutTests/imported/w3c/web-platform-tests/css/css-highlight-api/highlight-priority.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,78 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Highlight priority attribute is mutable</title> | ||
<link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/#priorities"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<style> | ||
::highlight(yellow-highlight) { | ||
background-color: yellow; | ||
} | ||
::highlight(green-highlight) { | ||
background-color: green; | ||
} | ||
::highlight(blue-highlight) { | ||
background-color: blue; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<span id="green-highlight">Green</span> | ||
<span id="yellow-highlight">Yellow</span> | ||
<span id="blue-highlight">Blue</span> | ||
<span id="yellow-blue-highlight">Yellow-Blue</span> | ||
|
||
<script> | ||
test(() => { | ||
let yellowBlue = document.getElementById("yellow-blue-highlight"); | ||
|
||
let green = document.getElementById("green-highlight"); | ||
let highlightGreen = new Highlight(new StaticRange({ | ||
startContainer: green.childNodes[0], | ||
startOffset: 0, | ||
endContainer: green.childNodes[0], | ||
endOffset: 6 | ||
})); | ||
|
||
let yellow = document.getElementById("yellow-highlight"); | ||
let highlightYellow = new Highlight(new StaticRange({ | ||
startContainer: yellow.childNodes[0], | ||
startOffset: 0, | ||
endContainer: yellow.childNodes[0], | ||
endOffset: 6 | ||
}), new StaticRange({ | ||
startContainer: yellowBlue.childNodes[0], | ||
startOffset: 0, | ||
endContainer: yellowBlue.childNodes[0], | ||
endOffset: 6 | ||
})); | ||
|
||
let blue = document.getElementById("blue-highlight"); | ||
let highlightBlue = new Highlight(new StaticRange({ | ||
startContainer: blue.childNodes[0], | ||
startOffset: 0, | ||
endContainer: blue.childNodes[0], | ||
endOffset: 4 | ||
}), new StaticRange({ | ||
startContainer: yellowBlue.childNodes[0], | ||
startOffset: 0, | ||
endContainer: yellowBlue.childNodes[0], | ||
endOffset: 11 | ||
})); | ||
|
||
CSS.highlights.set("yellow-highlight", highlightYellow); | ||
CSS.highlights.set("green-highlight", highlightGreen); | ||
CSS.highlights.set("blue-highlight", highlightBlue); | ||
|
||
highlightYellow.priority = 10; | ||
highlightBlue.priority = -1; | ||
|
||
assert_equals(highlightYellow.priority, 10); | ||
assert_equals(highlightGreen.priority, 0); | ||
assert_equals(highlightBlue.priority, -1); | ||
}); | ||
</script> | ||
|
||
</body> | ||
</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
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
Oops, something went wrong.