Branch: refs/heads/main Home: https://github.com/WebKit/WebKit Commit: f2b8d72e13c34c2d1c00d57ee729628a29dd440d https://github.com/WebKit/WebKit/commit/f2b8d72e13c34c2d1c00d57ee729628a29dd440d Author: Wenson Hsieh <wenson_hs...@apple.com> Date: 2024-05-31 (Fri, 31 May 2024)
Changed paths: M Source/WebCore/page/ElementTargetingController.cpp M Source/WebCore/page/ElementTargetingTypes.h M Source/WebCore/page/text-extraction/TextExtraction.cpp M Source/WebCore/page/text-extraction/TextExtraction.h M Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in M Source/WebKit/UIProcess/API/APITargetedElementInfo.h M Source/WebKit/UIProcess/API/Cocoa/_WKTargetedElementInfo.h M Source/WebKit/UIProcess/API/Cocoa/_WKTargetedElementInfo.mm M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj M Tools/TestWebKitAPI/Tests/WebKitCocoa/ElementTargetingTests.mm A Tools/TestWebKitAPI/Tests/WebKitCocoa/element-targeting-9.html Log Message: ----------- [Remote Inspection] Refactor some code for copying rendered text from selected elements https://bugs.webkit.org/show_bug.cgi?id=274995 rdar://129079086 Reviewed by Richard Robinson. Refactor some code for extracting rendered text from targeted elements, and expose a new property to indicate that a targeted element contains a large replaced renderer. See below for more details. * Source/WebCore/page/ElementTargetingController.cpp: (WebCore::targetedElementInfo): (WebCore::ElementTargetingController::snapshotIgnoringVisibilityAdjustment): Drive-by fix: use `snapshotFrameRect()` here, passing in an element rect in absolute coordinates that respects transforms. * Source/WebCore/page/ElementTargetingTypes.h: * Source/WebCore/page/text-extraction/TextExtraction.cpp: (WebCore::TextExtraction::extractRenderedTokens): Refactor this logic to return both the "rendered text" representation with and without `{W,H}` at once, along with a flag indicating whether any individual replaced renderer was large enough to fill most of the targeted element (90% of the width and height). This is an improvement over the current code, which performs the entire render tree traversal twice to compute both versions of rendered text. This refactoring allows us to instead collect a series of "tokens" (either a rounded size representing a replaced renderer or background image, or a piece of rendered text) with a single traversal, and then produce both versions of the string while iterating once over all the tokens. (WebCore::TextExtraction::extractRenderedText): * Source/WebCore/page/text-extraction/TextExtraction.h: * Source/WebKit/Shared/WebCoreArgumentCoders.serialization.in: * Source/WebKit/UIProcess/API/APITargetedElementInfo.h: * Source/WebKit/UIProcess/API/Cocoa/_WKTargetedElementInfo.h: * Source/WebKit/UIProcess/API/Cocoa/_WKTargetedElementInfo.mm: (-[_WKTargetedElementInfo hasLargeReplacedDescendant]): * Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * Tools/TestWebKitAPI/Tests/WebKitCocoa/ElementTargetingTests.mm: (TestWebKitAPI::TEST(ElementTargeting, ReplacedRendererSizeIgnoresPageScaleAndZoom)): (TestWebKitAPI::TEST(ElementTargeting, TargetedElementWithLargeImage)): (TestWebKitAPI::TEST(ElementTargeting, TargetedElementScreenReaderText)): Deleted. * Tools/TestWebKitAPI/Tests/WebKitCocoa/element-targeting-9.html: Added. Canonical link: https://commits.webkit.org/279606@main To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications _______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-changes