WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
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
Summary
[Live Text] Add a mechanism to regenerate text in an image element when it ch...
Wenson Hsieh
Reported
2021-06-09 16:31:30 PDT
rdar://77522786
Attachments
For EWS
(19.63 KB, patch)
2021-06-09 19:30 PDT
,
Wenson Hsieh
no flags
Details
Formatted Diff
Diff
For EWS
(19.09 KB, patch)
2021-06-09 21:06 PDT
,
Wenson Hsieh
no flags
Details
Formatted Diff
Diff
Patch
(19.04 KB, patch)
2021-06-10 13:12 PDT
,
Wenson Hsieh
no flags
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Wenson Hsieh
Comment 1
2021-06-09 19:30:04 PDT
Comment hidden (obsolete)
Created
attachment 431043
[details]
For EWS
Wenson Hsieh
Comment 2
2021-06-09 21:06:27 PDT
Created
attachment 431048
[details]
For EWS
Devin Rousso
Comment 3
2021-06-10 09:49:32 PDT
Comment on
attachment 431048
[details]
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
:)
Wenson Hsieh
Comment 4
2021-06-10 11:39:21 PDT
Comment on
attachment 431048
[details]
For EWS View in context:
https://bugs.webkit.org/attachment.cgi?id=431048&action=review
Thanks for the review!
>> 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.
That's a good point — changed this to wrap inside an `if (cacheTextRecognitionResults == CacheTextRecognitionResults::Yes)`.
>> 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
Whoops, good catch!
>> 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
I'll leave it as-is for now; this is going to be removed once we use a weak hashmap anyways.
>> 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
:)
V. nice
Wenson Hsieh
Comment 5
2021-06-10 13:12:56 PDT
Created
attachment 431116
[details]
Patch
EWS
Comment 6
2021-06-10 18:22:59 PDT
Committed
r278747
(
238708@main
): <
https://commits.webkit.org/238708@main
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 431116
[details]
.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug