[webkit-changes] [WebKit/WebKit] 884b0d: [Text Extraction] Retrieved items should be report...

Wenson Hsieh noreply at github.com
Thu Mar 14 20:30:37 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 884b0d2472da61ab72615727088039ab05e998a6
      https://github.com/WebKit/WebKit/commit/884b0d2472da61ab72615727088039ab05e998a6
  Author: Wenson Hsieh <wenson_hsieh at apple.com>
  Date:   2024-03-14 (Thu, 14 Mar 2024)

  Changed paths:
    A LayoutTests/fast/text-extraction/text-extraction-when-scrolled-expected.txt
    A LayoutTests/fast/text-extraction/text-extraction-when-scrolled.html
    M LayoutTests/resources/ui-helper.js
    M Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
    M Source/WebKit/UIProcess/Cocoa/WKTextExtractionItem.h
    M Source/WebKit/UIProcess/Cocoa/WKTextExtractionUtilities.h
    M Source/WebKit/UIProcess/Cocoa/WKTextExtractionUtilities.mm
    M Source/WebKit/WebKitSwift/TextExtraction/WKTextExtractionItem.swift
    M Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl
    M Tools/TestRunnerShared/UIScriptContext/UIScriptController.h
    M Tools/TestRunnerShared/UIScriptContext/UIScriptControllerShared.cpp
    M Tools/WebKitTestRunner/cocoa/UIScriptControllerCocoa.h
    M Tools/WebKitTestRunner/cocoa/UIScriptControllerCocoa.mm
    M Tools/WebKitTestRunner/cocoa/WKTextExtractionTestingHelpers.h
    M Tools/WebKitTestRunner/cocoa/WKTextExtractionTestingHelpers.mm

  Log Message:
  -----------
  [Text Extraction] Retrieved items should be reported in the coordinate space of the web view
https://bugs.webkit.org/show_bug.cgi?id=270994
rdar://124557587

Reviewed by Abrar Rahman Protyasha.

`WKTextExtractionItem`'s rect should be in web view coordinates, rather than root view coordinates.
Fix this by refactoring the text extraction item conversion code, so that we can pass in a function
to convert from root view coordinates to web view coordinates if needed (i.e. on iOS).

Test: fast/text-extraction/text-extraction-when-scrolled.html

* LayoutTests/fast/text-extraction/text-extraction-when-scrolled-expected.txt: Added.
* LayoutTests/fast/text-extraction/text-extraction-when-scrolled.html: Added.

Add a new layout test to exercise the change:
1.  Only the bottom link should be extracted
2.  The y-offset of the extracted link should be closer to 0 than 10000 (roughly the full height of
    the view).
3.  The y-offset of the root should be a large negative number close to 10000.

* LayoutTests/resources/ui-helper.js:
(window.UIHelper.requestTextExtraction):
* Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _requestTextExtraction:completionHandler:]):
* Source/WebKit/UIProcess/Cocoa/WKTextExtractionItem.h:
* Source/WebKit/UIProcess/Cocoa/WKTextExtractionUtilities.h:
* Source/WebKit/UIProcess/Cocoa/WKTextExtractionUtilities.mm:
(WebKit::createWKTextItem):
(WebKit::createItemWithChildren):
(WebKit::createItemRecursive):
(WebKit::createItem):
* Source/WebKit/WebKitSwift/TextExtraction/WKTextExtractionItem.swift:
* Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
* Tools/TestRunnerShared/UIScriptContext/UIScriptController.h:
(WTR::UIScriptController::requestTextExtraction):
* Tools/TestRunnerShared/UIScriptContext/UIScriptControllerShared.cpp:
(WTR::toTextExtractionOptions):
* Tools/WebKitTestRunner/cocoa/UIScriptControllerCocoa.h:
* Tools/WebKitTestRunner/cocoa/UIScriptControllerCocoa.mm:
(WTR::UIScriptControllerCocoa::requestTextExtraction):

Add new test options to allow layout tests to:
- Clip text extraction to the visible bounds of the web view.
- Additionally print rects for each of the extracted items.

* Tools/WebKitTestRunner/cocoa/WKTextExtractionTestingHelpers.h:
* Tools/WebKitTestRunner/cocoa/WKTextExtractionTestingHelpers.mm:
(WTR::buildDescriptionIgnoringChildren):
(WTR::buildRecursiveDescription):
(WTR::recursiveDescription):

Canonical link: https://commits.webkit.org/276133@main



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list