API Review: Custom context menu Spellcheck#5553
API Review: Custom context menu Spellcheck#5553anuragkumar878 wants to merge 17 commits intomainfrom
Conversation
|
@microsoft-github-policy-service agree company="Microsoft" |
There was a problem hiding this comment.
Pull request overview
This PR introduces a new API review spec to extend the existing WebView2 ContextMenuRequested customization flow with spellcheck support, enabling hosts that render custom context menus to surface and apply spellcheck suggestions.
Changes:
- Adds a new spec describing custom-context-menu spellcheck scenarios and motivation.
- Provides Win32 C++ and C# example flows for querying suggestions, handling async readiness, and applying a suggestion.
- Proposes new Win32 COM interfaces (
ICoreWebView2ContextMenuTarget2,ICoreWebView2ContextMenuRequestedEventArgs2) plus corresponding .NET/WinRT projections.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
shrinaths
left a comment
There was a problem hiding this comment.
Review Summary
The architecture and design are sound — DeferredCapabilityDiscovery, ContextMenuItemCollection return type, unified SelectedCommandId commanding, and always-async callback are all well done. The comments below focus on bringing the spec up to the polish expected for Windows API review board submission:
Must fix:
- Placeholder UUIDs (lines 260, 298, 320) — generate real values
- .NET projection should use [interface_name] pattern, not EventArgs2 class (line 363)
- Verify MIDL3 format requirement with SDK team (line 233)
Should fix:
- Rename title to "Spellcheck Support for Custom Context Menus"
- Complete the samples (both C++ and C# have undefined helpers / placeholder comments)
- Add CHECK_FAILURE() consistently in C++ sample
- Fix SelectedCommandId default value in error table (it's -1, not 0)
Nit:
- Consistent casing of "spellcheck" in prose
- Avoid contractions per Microsoft style guide
- Use /// doc comments in .NET projection
- Clean up casual language ("for example -")
shrinaths
left a comment
There was a problem hiding this comment.
Documentation style review - checking for Microsoft documentation guidelines adherence.
| // Asynchronously retrieve spellcheck suggestions. | ||
| CHECK_FAILURE(target2->GetSpellCheckSuggestions( | ||
| Callback< | ||
| ICoreWebView2GetSpellCheckSuggestionsCompletedHandler>( |
There was a problem hiding this comment.
Perhaps sample code has not been updated.
There was a problem hiding this comment.
It is updated, it's a completion callback, not an api call to get suggestions asynchronously.
|
|
||
| # API Details | ||
|
|
||
| ## Win32 COM IDL |
There was a problem hiding this comment.
We generally have both COM IDL first and WinRT MIDL3 second in the spec which looks like what we have here.
| /// Returns `E_POINTER` if `handler` is null. | ||
| /// Returns `E_ILLEGAL_METHOD_CALL` if a previous request is still pending. | ||
| HRESULT GetSpellCheckSuggestions( | ||
| [in] ICoreWebView2GetSpellCheckSuggestionsCompletedHandler* handler); |
There was a problem hiding this comment.
I was expecting this to be
IAsyncOperation<IVectorView> GetSpellCheckSuggestions();
There was a problem hiding this comment.
The WinRT version of the async method below looks like that. The COM version of an async API here looks like this kind of thing
Spellcheck Suggestions for Custom Context Menus
Enables host apps rendering custom context menus to discover, retrieve, and apply spellcheck suggestions for misspelled words in editable fields. Introduces a
deferred capability discovery pattern on EventArgs2 that is extensible to future async capabilities without additional EventArgs versions.
New Interfaces:
ICoreWebView2ContextMenuRequestedEventArgs2 extends ICoreWebView2ContextMenuRequestedEventArgs
ICoreWebView2ContextMenuSpellCheck (acquired via GetDeferredCapability)
Fires immediately (via PostTask) if suggestions are already resolved, or deferred until ready.
ICoreWebView2GetSpellCheckSuggestionsCompletedHandler
ICoreWebView2ContextMenuItem with Label (suggestion text) and CommandId (opaque identifier).
Usage flow:
Key design decisions: