Bug 234322

Summary: Add ModalContainerControlClassifier and use it to implement classifyModalContainerControls()
Product: WebKit Reporter: Wenson Hsieh <wenson_hsieh>
Component: PlatformAssignee: Wenson Hsieh <wenson_hsieh>
Status: RESOLVED FIXED    
Severity: Normal CC: akeerthi, bdakin, dino, graouts, hi, megan_gardner, thorton, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 234489    
Bug Blocks: 234440    
Attachments:
Description Flags
Patch
none
Rebase on trunk
ews-feeder: commit-queue-
Fix macOS 10.14 build
none
Style error is false positive
none
Ignore style error none

Wenson Hsieh
Reported 2021-12-14 15:46:42 PST
.
Attachments
Patch (23.23 KB, patch)
2021-12-17 12:42 PST, Wenson Hsieh
no flags
Rebase on trunk (19.26 KB, patch)
2021-12-20 14:38 PST, Wenson Hsieh
ews-feeder: commit-queue-
Fix macOS 10.14 build (18.71 KB, patch)
2021-12-20 15:00 PST, Wenson Hsieh
no flags
Style error is false positive (18.49 KB, patch)
2021-12-20 16:34 PST, Wenson Hsieh
no flags
Ignore style error (18.49 KB, patch)
2021-12-20 16:52 PST, Wenson Hsieh
no flags
Wenson Hsieh
Comment 1 2021-12-17 12:42:01 PST Comment hidden (obsolete)
Wenson Hsieh
Comment 2 2021-12-20 14:38:16 PST Comment hidden (obsolete)
Wenson Hsieh
Comment 3 2021-12-20 15:00:08 PST
Created attachment 447648 [details] Fix macOS 10.14 build
Devin Rousso
Comment 4 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`?
Wenson Hsieh
Comment 5 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.
Wenson Hsieh
Comment 6 2021-12-20 16:34:13 PST Comment hidden (obsolete)
Wenson Hsieh
Comment 7 2021-12-20 16:52:50 PST
Created attachment 447665 [details] Ignore style error
EWS
Comment 8 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].
Radar WebKit Bug Importer
Comment 9 2021-12-20 19:12:17 PST
Note You need to log in before you can comment on or make changes to this bug.