Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: c3c00a5e2ab494c742150d0373bb6920eb2863fb
https://github.com/WebKit/WebKit/commit/c3c00a5e2ab494c742150d0373bb6920eb2863fb
Author: Wenson Hsieh <[email protected]>
Date: 2026-06-21 (Sun, 21 Jun 2026)
Changed paths:
M Source/WebCore/page/text-extraction/TextExtraction.cpp
M Tools/TestWebKitAPI/Tests/WebKit/WKWebView/TextExtractionTests.mm
Log Message:
-----------
[Text Extraction] Fall back to `documentElement` if the body element is
missing
https://bugs.webkit.org/show_bug.cgi?id=317548
rdar://179365433
Reviewed by Richard Robinson.
It's possible for text extraction requests to fire on documents where the
`body` element is either
not yet created, or null due to being a non-`text/html` document; in these
cases, fall back to the
`documentElement` (e.g. `html` element) instead.
Test: TextExtractionTests.ExtractFromDocumentWithoutBody
* Source/WebCore/page/text-extraction/TextExtraction.cpp:
(WebCore::TextExtraction::extractItem):
(WebCore::TextExtraction::bodyOrDocumentElement):
(WebCore::TextExtraction::resolveNodeWithBodyOrDocumentElementAsFallback):
(WebCore::TextExtraction::selectText):
(WebCore::TextExtraction::highlightText):
(WebCore::TextExtraction::textDescription):
(WebCore::TextExtraction::scrollBy):
(WebCore::TextExtraction::scrollToNextPage):
(WebCore::TextExtraction::scrollToReveal):
(WebCore::TextExtraction::dispatchInteraction):
(WebCore::TextExtraction::containerElementForSearchTexts):
(WebCore::TextExtraction::rangeForExtractedText):
(WebCore::TextExtraction::documentBodyElement): Deleted.
(WebCore::TextExtraction::resolveNodeWithBodyAsFallback): Deleted.
* Tools/TestWebKitAPI/Tests/WebKit/WKWebView/TextExtractionTests.mm:
(TestWebKitAPI::TEST(TextExtractionTests, ExtractFromDocumentWithoutBody)):
Canonical link: https://commits.webkit.org/315572@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications