Skip to content

Commit

Permalink
CSS Custom Highlights WPT painting-invalidation 003 & 006, painting-i…
Browse files Browse the repository at this point in the history
…frame 006 failing due to not updating positions correctly

https://bugs.webkit.org/show_bug.cgi?id=259521
rdar://112907577

Reviewed by Richard Robinson and Ryosuke Niwa.

Added check for live range in Document::collectRangeDataFromRegister because
we do not want to skip if a live range is already set.
Live ranges are able to change.
Took out null checks in Document::updateHighlightPositions to support that
live ranges can change and there are already existing null checks before setting positions.
Updated TestExpectations due to three passing tests.

* LayoutTests/TestExpectations:
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::collectRangeDataFromRegister):
(WebCore::Document::updateHighlightPositions):
* Source/WebCore/dom/Range.h:
* Source/WebCore/dom/StaticRange.h:

Canonical link: https://commits.webkit.org/266349@main
  • Loading branch information
jesxilin authored and rniwa committed Jul 27, 2023
1 parent 2669db2 commit 0ef0801
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
3 changes: 0 additions & 3 deletions LayoutTests/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -4900,11 +4900,8 @@ webkit.org/b/220325 http/wpt/css/css-highlight-api/highlight-text-cascade.html [
imported/w3c/web-platform-tests/css/css-highlight-api/painting/custom-highlight-painting-008.html [ Skip ]
imported/w3c/web-platform-tests/css/css-highlight-api/painting/css-target-text-decoration-001.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-highlight-api/painting/custom-highlight-painting-below-target-text.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-highlight-api/painting/custom-highlight-painting-iframe-006.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-highlight-api/painting/custom-highlight-painting-inheritance-001.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-highlight-api/painting/custom-highlight-painting-inheritance-002.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-highlight-api/painting/custom-highlight-painting-invalidation-003.html [ ImageOnlyFailure ]
imported/w3c/web-platform-tests/css/css-highlight-api/painting/custom-highlight-painting-invalidation-006.html [ ImageOnlyFailure ]

http/tests/webgl/1.0.x/conformance/textures/misc/origin-clean-conformance-offscreencanvas.html [ Skip ]
http/tests/webgl/2.0.y/conformance/textures/misc/origin-clean-conformance-offscreencanvas.html [ Skip ]
Expand Down
11 changes: 4 additions & 7 deletions Source/WebCore/dom/Document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2988,7 +2988,8 @@ void Document::collectRangeDataFromRegister(Vector<WeakPtr<HighlightRangeData>>&
{
for (auto& highlight : highlightRegister.map()) {
for (auto& rangeData : highlight.value->rangesData()) {
if (rangeData->startPosition().isNotNull() && rangeData->endPosition().isNotNull())
// FIXME: For live ranges, we can optimize by only performing this when the range changed.
if (rangeData->startPosition().isNotNull() && rangeData->endPosition().isNotNull() && !rangeData->range().isLiveRange())
continue;
auto simpleRange = makeSimpleRange(rangeData->range());
if (&simpleRange.startContainer().treeScope() != &simpleRange.endContainer().treeScope())
Expand All @@ -3013,12 +3014,8 @@ void Document::updateHighlightPositions()
for (auto& weakRangeData : rangesData) {
if (auto* rangeData = weakRangeData.get()) {
VisibleSelection visibleSelection(makeSimpleRange(rangeData->range()));
Position startPosition;
Position endPosition;
if (rangeData->startPosition().isNull())
startPosition = visibleSelection.visibleStart().deepEquivalent();
if (rangeData->endPosition().isNull())
endPosition = visibleSelection.visibleEnd().deepEquivalent();
auto startPosition = visibleSelection.visibleStart().deepEquivalent();
auto endPosition = visibleSelection.visibleEnd().deepEquivalent();
if (!weakRangeData.get())
continue;
if (!startPosition.isNull())
Expand Down

0 comments on commit 0ef0801

Please sign in to comment.