Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Live Text] Avoid injecting recognized text consisting of single words or letters in tiny images #4512

Merged
merged 1 commit into from
Sep 20, 2022

Commits on Sep 20, 2022

  1. [Live Text] Avoid injecting recognized text consisting of single word…

    …s or letters in tiny images
    
    https://bugs.webkit.org/show_bug.cgi?id=245404
    rdar://99490753
    
    Reviewed by Tim Horton.
    
    Add a basic heuristic to avoid injecting Live Text in small images, if the recognized text consists
    of only a single word or letter. Currently, this causes images to become selectable in many
    instances where there's little to no utility in being able to select text — for instance, in image
    buttons or links that consist of an icon, such as an "x".
    
    Test: fast/images/text-recognition/avoid-image-overlay-in-small-image.html
    
    * LayoutTests/fast/images/text-recognition/avoid-image-overlay-in-small-image-expected.txt: Added.
    * LayoutTests/fast/images/text-recognition/avoid-image-overlay-in-small-image.html: Added.
    * Source/WebCore/dom/ImageOverlay.cpp:
    (WebCore::ImageOverlay::updateWithTextRecognitionResult):
    
    To do this, we shuffle around some logic for creating and appending the UA shadow DOM elements used
    to implement Live Text, such that we exit early and avoid installing a shadow root altogether in the
    case where the image is smaller than an arbitrary threshold (64px), and the text we're about to
    inject consists of a single piece of child text.
    
    Canonical link: https://commits.webkit.org/254671@main
    whsieh committed Sep 20, 2022
    Configuration menu
    Copy the full SHA
    03e0d55 View commit details
    Browse the repository at this point in the history