Bug 133159 - viewStateDidChange should always fully update ViewState
Summary: viewStateDidChange should always fully update ViewState
Status: ASSIGNED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Gavin Barraclough
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2014-05-21 15:34 PDT by Gavin Barraclough
Modified: 2014-05-29 14:51 PDT (History)
14 users (show)

See Also:


Attachments
Fix (32.65 KB, patch)
2014-05-26 17:50 PDT, Gavin Barraclough
no flags Details | Formatted Diff | Diff
gtk/efl fix (36.54 KB, patch)
2014-05-26 18:00 PDT, Gavin Barraclough
andersca: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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