[webkit-changes] [WebKit/WebKit] 03e0d5: [Live Text] Avoid injecting recognized text consis...

Wenson Hsieh noreply at github.com
Tue Sep 20 07:06:16 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 03e0d55a928634777319de1b93a82558ab94bba7
      https://github.com/WebKit/WebKit/commit/03e0d55a928634777319de1b93a82558ab94bba7
  Author: Wenson Hsieh <wenson_hsieh at apple.com>
  Date:   2022-09-20 (Tue, 20 Sep 2022)

  Changed paths:
    A LayoutTests/fast/images/text-recognition/avoid-image-overlay-in-small-image-expected.txt
    A LayoutTests/fast/images/text-recognition/avoid-image-overlay-in-small-image.html
    M Source/WebCore/dom/ImageOverlay.cpp

  Log Message:
  -----------
  [Live Text] Avoid injecting recognized text consisting of single words 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




More information about the webkit-changes mailing list