Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 03a4ccf4165da8ea0669e72c23f4ad4f9462d335
https://github.com/WebKit/WebKit/commit/03a4ccf4165da8ea0669e72c23f4ad4f9462d335
Author: Wenson Hsieh <[email protected]>
Date: 2025-10-28 (Tue, 28 Oct 2025)
Changed paths:
A
LayoutTests/fast/text-extraction/debug-text-extraction-highlight-text-expected.txt
A LayoutTests/fast/text-extraction/debug-text-extraction-highlight-text.html
M Source/WebCore/dom/Document.cpp
M Source/WebCore/dom/Document.h
M Source/WebCore/page/LocalFrameView.cpp
M Source/WebCore/page/LocalFrameView.h
M Source/WebCore/page/text-extraction/TextExtraction.cpp
M Source/WebCore/page/text-extraction/TextExtractionTypes.h
M Source/WebCore/rendering/MarkedText.cpp
M Source/WebCore/rendering/MarkedText.h
M Source/WebCore/rendering/StyledMarkedText.cpp
M Source/WebCore/testing/Internals.cpp
M Source/WebCore/testing/Internals.h
M Source/WebCore/testing/Internals.idl
M Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in
M Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
M Source/WebKit/UIProcess/API/Cocoa/_WKTextExtraction.h
M Source/WebKit/UIProcess/API/Cocoa/_WKTextExtraction.mm
M Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl
M Tools/TestRunnerShared/UIScriptContext/UIScriptController.h
M Tools/TestRunnerShared/UIScriptContext/UIScriptControllerShared.cpp
M Tools/TestWebKitAPI/Tests/WebCore/MarkedText.cpp
M Tools/WebKitTestRunner/cocoa/UIScriptControllerCocoa.mm
Log Message:
-----------
[AutoFill Debugging] Add support for an interaction type to highlight and
reveal text
https://bugs.webkit.org/show_bug.cgi?id=301552
rdar://160326206
Reviewed by Abrar Rahman Protyasha.
Add support for `_WKTextExtractionActionHighlightText`, which highlights text
on the page (using an
internal, non-exposed CSS highlight registry) and optionally scrolls to reveal
the range. See below
for more details.
Tests: fast/text-extraction/debug-text-extraction-highlight-text.html
*
LayoutTests/fast/text-extraction/debug-text-extraction-highlight-text-expected.txt:
Added.
* LayoutTests/fast/text-extraction/debug-text-extraction-highlight-text.html:
Added.
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::commonTeardown):
(WebCore::Document::hasHighlight const):
(WebCore::Document::textExtractionHighlightRegistry):
(WebCore::Document::updateHighlightPositions):
Add `m_textExtractionHighlightRegistry` to `Document`, which exists alongside
other internal CSS
highlight registries on the document.
* Source/WebCore/dom/Document.h:
(WebCore::Document::highlightRegistryIfExists const):
(WebCore::Document::fragmentHighlightRegistryIfExists const):
Drive-by fix: make this getter `const`.
(WebCore::Document::textExtractionHighlightRegistryIfExists const):
(WebCore::Document::highlightRegistryIfExists): Deleted.
(WebCore::Document::fragmentHighlightRegistryIfExists): Deleted.
* Source/WebCore/page/LocalFrameView.cpp:
(WebCore::LocalFrameView::scrollToTextFragment):
Pull common logic to scroll to the given `SimpleRange` out into a separate
helper method,
`revealRangeWithTemporarySelection`, and use it in a few places here to avoid
code duplication. This
also allows us to use it from text extraction code below.
(WebCore::LocalFrameView::textFragmentIndicatorTimerFired):
(WebCore::LocalFrameView::revealRangeWithTemporarySelection):
(WebCore::LocalFrameView::scrollToPendingTextFragmentRange):
* Source/WebCore/page/LocalFrameView.h:
* Source/WebCore/page/text-extraction/TextExtraction.cpp:
(WebCore::TextExtraction::searchForText):
(WebCore::TextExtraction::invalidNodeIdentifierDescription):
(WebCore::TextExtraction::resolveNodeWithBodyAsFallback):
(WebCore::TextExtraction::rangeForTextInContainer):
Pull common functionality to map text and node IDs to a range in the DOM out
into separate helper
methods, so that we can use it for both the `SelectText` and new
`HighlightText` interactions.
(WebCore::TextExtraction::selectText):
Use the above helpers.
(WebCore::TextExtraction::highlightText):
Add a helper method to handle this new interaction type, by finding the target
range in the DOM,
adding a new highlight via the new highlight registry, and then (optionally)
scrolling to reveal the
range using the new `LocalFrameView` method above.
(WebCore::TextExtraction::handleInteraction):
(WebCore::TextExtraction::interactionDescription):
* Source/WebCore/page/text-extraction/TextExtractionTypes.h:
* Source/WebCore/rendering/MarkedText.cpp:
(WebCore::MarkedText::collectForHighlights):
Pull common logic out into a separate lambda, `appendMarkedTextHighlights`, and
then additionally
deploy it for this new CSS highlight registry.
* Source/WebCore/rendering/MarkedText.h:
* Source/WebCore/rendering/StyledMarkedText.cpp:
(WebCore::resolveStyleForMarkedText):
Add painting support for this new `TextExtraction` highlight marker type.
* Source/WebCore/testing/Internals.cpp:
(WebCore::Internals::textExtractionHighlightRanges const):
* Source/WebCore/testing/Internals.h:
* Source/WebCore/testing/Internals.idl:
* Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in:
* Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _convertToWebCoreInteraction:]):
Add an optional `scrollToVisible` argument to the interaction object, which
scrolls the target range
into view for `.selectText` and `.highlightText`. We may want to apply this to
some of the other
types (clicking, typing) in the future.
* Source/WebKit/UIProcess/API/Cocoa/_WKTextExtraction.h:
* Source/WebKit/UIProcess/API/Cocoa/_WKTextExtraction.mm:
* Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
* Tools/TestRunnerShared/UIScriptContext/UIScriptController.h:
* Tools/TestRunnerShared/UIScriptContext/UIScriptControllerShared.cpp:
(WTR::toTextExtractionInteractionOptions):
* Tools/TestWebKitAPI/Tests/WebCore/MarkedText.cpp:
(WebCore::operator<<):
* Tools/WebKitTestRunner/cocoa/UIScriptControllerCocoa.mm:
(WTR::UIScriptControllerCocoa::performTextExtractionInteraction):
Canonical link: https://commits.webkit.org/302234@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications