Bug 133159

Summary: viewStateDidChange should always fully update ViewState
Product: WebKit Reporter: Gavin Barraclough <barraclough>
Component: WebKit2Assignee: Gavin Barraclough <barraclough>
Status: ASSIGNED ---    
Severity: Normal CC: berto, bshafiei, bunhere, cgarcia, cmarcelo, commit-queue, gustavo, luiz, mrobinson, noam, sam, sergio, webkit-bug-importer, zeno
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Fix
none
gtk/efl fix andersca: review+

Description Gavin Barraclough 2014-05-21 15:34:04 PDT
Currently WebPageProxy::viewStateDidChange is passed a mask of bits to update.

This has the following negative consequences:
 – WKWebView implicitly requires more detailed knowledge of the internal implementation of the PageClient.
 – Updates may unnecessarily be split over multiple IPC messages.
 – In order to support partial updates we make multiple virtual function calls to PageClient, which then makes duplicate objc calls.

Better to just always update the entire ViewState.
Comment 1 Gavin Barraclough 2014-05-26 17:50:50 PDT
Created attachment 232099 [details]
Fix
Comment 2 WebKit Commit Bot 2014-05-26 17:52:31 PDT
Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See http://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API
Comment 3 Sam Weinig 2014-05-26 17:59:58 PDT
Look good to me, but I would like Anders to review it as well.
Comment 4 Gavin Barraclough 2014-05-26 18:00:34 PDT
Created attachment 232100 [details]
gtk/efl fix
Comment 5 Carlos Garcia Campos 2014-05-27 00:06:48 PDT
Comment on attachment 232100 [details]
gtk/efl fix

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

Thanks for fixing the GTK+ port too.

> Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp:110
> +    if (webkitWebViewBaseIsFocused(WEBKIT_WEB_VIEW_BASE(m_viewWidget)))
> +        viewState |= ViewState::IsFocused;
> +    if (webkitWebViewBaseIsInWindowActive(WEBKIT_WEB_VIEW_BASE(m_viewWidget)))
> +        viewState |= ViewState::WindowIsActive;
> +    if (webkitWebViewBaseIsInWindow(WEBKIT_WEB_VIEW_BASE(m_viewWidget)))
> +        viewState |= ViewState::IsInWindow;
> +    if (webkitWebViewBaseIsVisible(WEBKIT_WEB_VIEW_BASE(m_viewWidget)))

Now that all these are in the same function, I would use a local variable to avoid casting all the time.
WebKitWebViewBase* webView = WEBKIT_WEB_VIEW_BASE(m_viewWidget);

if (webkitWebViewBaseIsFocused(webView))
....

I think it also improves a bit the readability.

> Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h:70
> +    bool isViewVisible();

Why re-adding this as non-virtual?
Comment 6 Anders Carlsson 2014-05-28 16:04:25 PDT
Comment on attachment 232100 [details]
gtk/efl fix

This looks really great, but please address the comments from Carlos.
Comment 7 Gavin Barraclough 2014-05-28 18:17:03 PDT
(In reply to comment #5)
> (From update of attachment 232100 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=232100&action=review
> 
> Thanks for fixing the GTK+ port too.
> 
> > Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp:110
> > +    if (webkitWebViewBaseIsFocused(WEBKIT_WEB_VIEW_BASE(m_viewWidget)))
> > +        viewState |= ViewState::IsFocused;
> > +    if (webkitWebViewBaseIsInWindowActive(WEBKIT_WEB_VIEW_BASE(m_viewWidget)))
> > +        viewState |= ViewState::WindowIsActive;
> > +    if (webkitWebViewBaseIsInWindow(WEBKIT_WEB_VIEW_BASE(m_viewWidget)))
> > +        viewState |= ViewState::IsInWindow;
> > +    if (webkitWebViewBaseIsVisible(WEBKIT_WEB_VIEW_BASE(m_viewWidget)))
> 
> Now that all these are in the same function, I would use a local variable to avoid casting all the time.
> WebKitWebViewBase* webView = WEBKIT_WEB_VIEW_BASE(m_viewWidget);
> 
> if (webkitWebViewBaseIsFocused(webView))
> ....
> 
> I think it also improves a bit the readability.
> 

Ah – yes, good point. Done.

> > Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h:70
> > +    bool isViewVisible();
> 
> Why re-adding this as non-virtual?

Ooops, remnants of a partial refactor – that's gone now, removed.
Comment 8 Gavin Barraclough 2014-05-28 18:42:06 PDT
Transmitting file data .................
Committed revision 169439.
Comment 9 Radar WebKit Bug Importer 2014-05-29 13:48:25 PDT
<rdar://problem/17069364>
Comment 10 Babak Shafiei 2014-05-29 14:50:33 PDT
Roll out on trunk in https://trac.webkit.org/r169465