Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 4ed2d20fb3ad4f99b9d92288b3e82b5f26e23b4b
https://github.com/WebKit/WebKit/commit/4ed2d20fb3ad4f99b9d92288b3e82b5f26e23b4b
Author: Chris Dumez <[email protected]>
Date: 2023-05-31 (Wed, 31 May 2023)
Changed paths:
M LayoutTests/TestExpectations
A
LayoutTests/imported/w3c/web-platform-tests/css/css-highlight-api/Highlight-setlike-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/css/css-highlight-api/Highlight-setlike.html
M
LayoutTests/imported/w3c/web-platform-tests/css/css-highlight-api/idlharness.window-expected.txt
M Source/WebCore/Modules/highlight/Highlight.cpp
M Source/WebCore/Modules/highlight/Highlight.h
M Source/WebCore/Modules/highlight/Highlight.idl
M Source/WebCore/Modules/highlight/HighlightRegister.cpp
M Source/WebCore/dom/Document.cpp
M Source/WebCore/dom/Document.h
M Source/WebCore/rendering/HighlightData.cpp
M Source/WebCore/rendering/HighlightData.h
Log Message:
-----------
Freshen up CSS Highlight implementation
https://bugs.webkit.org/show_bug.cgi?id=257520
Reviewed by Wenson Hsieh and Darin Adler.
Freshen up CSS Highlight implementation:
- https://drafts.csswg.org/css-highlight-api-1/#highlight
*
LayoutTests/imported/w3c/web-platform-tests/css/css-highlight-api/Highlight-setlike-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-highlight-api/Highlight-setlike.html:
Added.
Import test coverage for Hightlight's SetLike behavior.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-highlight-api/idlharness.window-expected.txt:
Rebaseline WPT test now that more checks are passing.
* Source/WebCore/Modules/highlight/Highlight.cpp:
(WebCore::repaintRange):
Take an AbstractRange instead of a SimpleRange for convenience, now that we
support all
AbstractRange types.
(WebCore::Highlight::create):
(WebCore::Highlight::Highlight):
Update constructor to take in a FixedVector of AbstractRanges, to match the
latest IDL.
(WebCore::Highlight::initializeSetLike):
Switch from StaticRange to AbstractRange to match the latest IDL.
(WebCore::Highlight::removeFromSetLike):
Do pointer comparison instead of using StaticRange's operator==(), to match
JS's behavior.
This was causing Highlight-setlike.html to crash in debug.
(WebCore::Highlight::clearFromSetLike):
(WebCore::Highlight::repaint):
Use range getter now that HighlightRangeData's data members are private.
(WebCore::Highlight::addToSetLike):
The implementation was incorrect:
- It failed to move the range to the end if already present (since SetLike is
an ordered set)
- It relies on StaticRange's operator==() instead of doing pointer comparison.
In JS 2 staticRange
objects are equal if they have the same pointer, no deep compare is
happening. Our C++
implementation needs to match this.
* Source/WebCore/Modules/highlight/Highlight.h:
(WebCore::HighlightRangeData::create):
(WebCore::HighlightRangeData::range const):
(WebCore::HighlightRangeData::startPosition const):
(WebCore::HighlightRangeData::endPosition const):
(WebCore::HighlightRangeData::HighlightRangeData):
- Make it a class instead of a struct, with a private constructor and private
data members, since this subclasses RefCounted. Refcounted classes should
never have a public constructor and it is too error-prone.
- Add public getters / setters now that the data members are private.
- Store an AbstractRange instead of a StaticRange to match the latest IDL.
(WebCore::Highlight::type const):
(WebCore::Highlight::setType):
(WebCore::Highlight::priority const):
(WebCore::Highlight::setPriority):
Add basic support for `type` and `priority` IDL attributes.
* Source/WebCore/Modules/highlight/Highlight.idl:
Synchronize with the specification:
- https://drafts.csswg.org/css-highlight-api-1/#highlight
In particular, we now use AbstractRange instead of StaticRange
and the `type` & `priority` attributes were added. Also, the
constructor can now take in several ranges, not just one.
* Source/WebCore/Modules/highlight/HighlightRegister.cpp:
(WebCore::HighlightRegister::addAnnotationHighlightWithRange):
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::updateHighlightPositions):
* Source/WebCore/dom/Document.h:
* Source/WebCore/rendering/HighlightData.cpp:
(WebCore::HighlightData::setRenderRange):
* Source/WebCore/rendering/HighlightData.h:
Canonical link: https://commits.webkit.org/264739@main
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes