[webkit-reviews] review granted: [Bug 226858] [Live Text] Add a mechanism to regenerate text in an image element when it changes dimensions : [Attachment 431048] For EWS

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Jun 10 09:49:32 PDT 2021


Devin Rousso <drousso at apple.com> has granted Wenson Hsieh
<wenson_hsieh at apple.com>'s request for review:
Bug 226858: [Live Text] Add a mechanism to regenerate text in an image element
when it changes dimensions
https://bugs.webkit.org/show_bug.cgi?id=226858

Attachment 431048: For EWS

https://bugs.webkit.org/attachment.cgi?id=431048&action=review




--- Comment #3 from Devin Rousso <drousso at apple.com> ---
Comment on attachment 431048
  --> https://bugs.webkit.org/attachment.cgi?id=431048
For EWS

View in context: https://bugs.webkit.org/attachment.cgi?id=431048&action=review

r=me, nice!

> Source/WebCore/html/HTMLElement.cpp:1513
> +    if (auto* page = document().page(); page && cacheTextRecognitionResults
== CacheTextRecognitionResults::Yes)

NIT: Seems a bit odd to me that we always fetch `page` but then only use it
based on something completely unrelated to `page`.  I'd maybe restructure this
into two nested `if` so that if someone adds to this in the future they're less
likely to miss it.

> Source/WebCore/page/Page.cpp:3622
> +    m_textRecognitionResultsByElement.removeAllMatching([&](auto&
elementAndResult) {

NIT: Could this just be `[]` instead?

> Source/WebCore/page/Page.cpp:3626
> +    Vector<std::pair<Ref<HTMLElement>, TextRecognitionResult>>
elementsToUpdate;

unused

> Source/WebCore/page/Page.cpp:3627
> +    for (auto& [element, resultAndSize] : m_textRecognitionResultsByElement)
{

NIT: this would probably be a little uglier, but I wonder if you could move
this logic into `m_textRecognitionResultsByElement` so we don't have to iterate
twice

> Source/WebCore/page/Page.cpp:3660
> +    m_textRecognitionResultsByElement.removeAllMatching([&](auto&
elementAndResult) {

ditto (:3627)

> Source/WebCore/page/Page.h:1193
> +    Vector<std::pair<WeakPtr<HTMLElement>, std::pair<TextRecognitionResult,
IntSize>>> m_textRecognitionResultsByElement;

NIT: Maybe add a FIXME comment to change this to a `WeakHashMap` when
implemented?

> LayoutTests/fast/images/text-recognition/image-overlay-size-change.html:48
> +    await new Promise(resolve => shouldBecomeEqual("width", "50", resolve));

FYI `shouldBecomeEqual` now supports returning a `Promise` after r278678 :)


More information about the webkit-reviews mailing list