Bug 234322 - Add ModalContainerControlClassifier and use it to implement classifyModalContainerControls()
Summary: Add ModalContainerControlClassifier and use it to implement classifyModalCont...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Platform (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Wenson Hsieh
URL:
Keywords: InRadar
Depends on: 234489
Blocks: 234440
  Show dependency treegraph
 
Reported: 2021-12-14 15:46 PST by Wenson Hsieh
Modified: 2021-12-20 19:12 PST (History)
8 users (show)

See Also:


Attachments
Patch (23.23 KB, patch)
2021-12-17 12:42 PST, Wenson Hsieh
no flags Details | Formatted Diff | Diff
Rebase on trunk (19.26 KB, patch)
2021-12-20 14:38 PST, Wenson Hsieh
ews-feeder: commit-queue-
Details | Formatted Diff | Diff
Fix macOS 10.14 build (18.71 KB, patch)
2021-12-20 15:00 PST, Wenson Hsieh
no flags Details | Formatted Diff | Diff
Style error is false positive (18.49 KB, patch)
2021-12-20 16:34 PST, Wenson Hsieh
no flags Details | Formatted Diff | Diff
Ignore style error (18.49 KB, patch)
2021-12-20 16:52 PST, Wenson Hsieh
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Wenson Hsieh 2021-12-14 15:46:42 PST
.
Comment 1 Wenson Hsieh 2021-12-17 12:42:01 PST Comment hidden (obsolete)
Comment 2 Wenson Hsieh 2021-12-20 14:38:16 PST Comment hidden (obsolete)
Comment 3 Wenson Hsieh 2021-12-20 15:00:08 PST
Created attachment 447648 [details]
Fix macOS 10.14 build
Comment 4 Devin Rousso 2021-12-20 15:40:10 PST
Comment on attachment 447648 [details]
Fix macOS 10.14 build

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

r=me, neato :)

> Source/WebKit/UIProcess/Cocoa/ModalContainerControlClassifier.h:28
> +#import <wtf/CompletionHandler.h>

NIT: Could/Should we use `<wtf/Forward.h>` for these instead?

> Source/WebKit/UIProcess/Cocoa/ModalContainerControlClassifier.h:46
> +    ModalContainerControlClassifier();

Should this be in `private:`?

> Source/WebKit/UIProcess/Cocoa/ModalContainerControlClassifier.h:48
> +    void classify(Vector<String>&&, CompletionHandler<void(Vector<WebCore::ModalContainerControlType>&&)>&&);

Style: I'd make this `Vector<String>&& texts` as it's not really clear what that parameter is supposed to be used for just by looking at the type.

> Source/WebKit/UIProcess/Cocoa/ModalContainerControlClassifier.mm:125
> +static std::unique_ptr<ModalContainerControlClassifier>& sharedModalContainerControlClassifier()

NIT: I'd inline this

> Source/WebKit/UIProcess/Cocoa/ModalContainerControlClassifier.mm:156
> +    for (NSInteger index = 0; index < [batch count]; ++index) {

Why not `[resultProvider count]`?

> Source/WebKit/UIProcess/Cocoa/ModalContainerControlClassifier.mm:175
> +    m_queue->dispatch([this, texts = texts.isolatedCopy(), completion = WTFMove(completion)]() mutable {

Are you doing `texts.isolatedCopy()` instead of `WTFMove(texts)` to avoid deallocing on a different thread?  Is that an issue for `Vector`/`String`?
Comment 5 Wenson Hsieh 2021-12-20 16:11:39 PST
Comment on attachment 447648 [details]
Fix macOS 10.14 build

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

Thanks for the review!

>> Source/WebKit/UIProcess/Cocoa/ModalContainerControlClassifier.h:28
>> +#import <wtf/CompletionHandler.h>
> 
> NIT: Could/Should we use `<wtf/Forward.h>` for these instead?

Sure.

>> Source/WebKit/UIProcess/Cocoa/ModalContainerControlClassifier.h:46
>> +    ModalContainerControlClassifier();
> 
> Should this be in `private:`?

Hm…I might be able to, if I `friend std::unique_ptr<~>`…

Will give that a try.

>> Source/WebKit/UIProcess/Cocoa/ModalContainerControlClassifier.h:48
>> +    void classify(Vector<String>&&, CompletionHandler<void(Vector<WebCore::ModalContainerControlType>&&)>&&);
> 
> Style: I'd make this `Vector<String>&& texts` as it's not really clear what that parameter is supposed to be used for just by looking at the type.

👍🏻

>> Source/WebKit/UIProcess/Cocoa/ModalContainerControlClassifier.mm:125
>> +static std::unique_ptr<ModalContainerControlClassifier>& sharedModalContainerControlClassifier()
> 
> NIT: I'd inline this

Good point. Moved into the implementation of `sharedClassifier()` below.

>> Source/WebKit/UIProcess/Cocoa/ModalContainerControlClassifier.mm:156
>> +    for (NSInteger index = 0; index < [batch count]; ++index) {
> 
> Why not `[resultProvider count]`?

Good point — changed to use `resultProvider.count` here.

>> Source/WebKit/UIProcess/Cocoa/ModalContainerControlClassifier.mm:175
>> +    m_queue->dispatch([this, texts = texts.isolatedCopy(), completion = WTFMove(completion)]() mutable {
> 
> Are you doing `texts.isolatedCopy()` instead of `WTFMove(texts)` to avoid deallocing on a different thread?  Is that an issue for `Vector`/`String`?

I believe it is. These strings passed into `classify()` were created on the main thread, so they should also be destroyed on the main thread…AFAICT.
Comment 6 Wenson Hsieh 2021-12-20 16:34:13 PST Comment hidden (obsolete)
Comment 7 Wenson Hsieh 2021-12-20 16:52:50 PST
Created attachment 447665 [details]
Ignore style error
Comment 8 EWS 2021-12-20 19:11:00 PST
Committed r287296 (245448@main): <https://commits.webkit.org/245448@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 447665 [details].
Comment 9 Radar WebKit Bug Importer 2021-12-20 19:12:17 PST
<rdar://problem/86750278>