| Summary: | Add ModalContainerControlClassifier and use it to implement classifyModalContainerControls() | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Wenson Hsieh <wenson_hsieh> | ||||||||||||
| Component: | Platform | Assignee: | 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
Wenson Hsieh
2021-12-14 15:46:42 PST
Created attachment 447469 [details]
Patch
Created attachment 447640 [details]
Rebase on trunk
Created attachment 447648 [details]
Fix macOS 10.14 build
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 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. Created attachment 447663 [details]
Style error is false positive
Created attachment 447665 [details]
Ignore style error
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]. |