-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add spec for NestedFrame.md #4950
Conversation
specs/NestedFrame.md
Outdated
{ | ||
//! [AddFrameCreated] | ||
frame7->add_FrameCreated( | ||
Callback<ICoreWebView2FrameNestedFrameCreatedEventHandler>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strictly by our usual rules of I{interface name}{event name}EventHandler
this would be ICoreWebView2FrameFrameCreatedEventHandler
. If we think it looks weird then perhaps ICoreWebView2FrameChildFrameCreatedEventHandler
specs/NestedFrame.md
Outdated
void ScenarioWebViewEventMonitor::InitializeEventView(ICoreWebView2* webviewEventView) | ||
{ | ||
auto webviewEventView4 = webviewEventView.try_query<ICoreWebView2_4>(); | ||
webviewEventView4->add_FrameCreated( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at InitializeEventView and InitializeFrameEventView the functions look almost identical. Can we add a property like CoreWebView2Frame CoreWebView2.TopLevelFrame {get;};
that is the main ICoreWebView2 object as an ICoreWebView2Frame? That would make lives easier for end devs for cases like these where they want to run the same code on the child frames and the top level CoreWebView2. In the sample code you could remove the first InitislizeEventView method and instead run InitializeFrameEventView on the CoreWebView2.TopLevelFrame
specs/NestedFrame.md
Outdated
std::wstring message = | ||
L"{ \"kind\": \"event\", \"name\": \"FrameCreated\", \"args\": {"; | ||
|
||
message += L"\"frame\": " + EncodeQuote(name.get()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a real-world sort of scenario where we would want to use this event? We want samples that demonstrates why an API is useful via a sample that an end dev could want to put in their app.
} | ||
} | ||
} | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC we had discussed that this addition would have impact on existing WebView2 APIs where various events can now sort of bubble from one corewebview2frame to their parent to their parent ... to the corewebview2. And how that interacts with event args for cancellation. This should probably be discussed somehow in this API spec. If it doesn't make sense to include in the API ref docs for CoreWebView2Frame.FrameCreated then perhaps you can add it to a new 'Appendix' section at the bottom that lists the other changes you plan to make to the other ref docs of impacted APIs.
As far as I can tell, with this approach, we have to subscribe to The existing solution seems managemeable for us, but it would be nice if the Frame object's (Alternatively, there was always the option of just passing in more data into the existing navigation events which do fire for nested iframes; assumed that'd be easier to fix but don't know: #4604 ) |
For your case, you can subscribe the void TrackFrames(wil::com_ptr<ICoreWebView2Frame> webviewFrame) {
auto frame7 = webviewFrame.try_query<ICoreWebView2Frame7>();
if (frame7)
{
//! [AddFrameCreated]
frame7->add_FrameCreated(
Callback<ICoreWebView2FrameNestedFrameCreatedEventHandler>(
[this](
ICoreWebView2Frame* sender,
ICoreWebView2FrameCreatedEventArgs* args) -> HRESULT
{
wil::com_ptr<ICoreWebView2Frame> webviewFrame;
CHECK_FAILURE(args->get_Frame(&webviewFrame));
// Make a recursive call to track all nested webview frame events.
TrackFrames(webviewFrame);
return S_OK;
})
.Get(),
&m_frameCreatedToken);
//! [AddFrameCreated]
}
// Manage the current webview frame.
webviewFrame->add_Destroyed(
...
} We have developers who know the frame structure they are loading and are only interested in specific groups of iframes. For instance, they may only be concerned with second-level iframes. Therefore, tracking all iframes directly, especially for those who prioritize performance, is not an ideal approach. Our design decisions aim to accommodate the needs of a broad range of customers. We believe that enabling this feature will provide more comprehensive functionality and support for various nested iframe use cases. |
This is a review for the new
CoreWebView2Frame::FrameCreated
API.