Bug 102970 - [WK1] REGRESSION (r129545): Main frame doesn't rubberband unless WebFrameLoadDelegate implements -webView:didFirstLayoutInFrame:
Summary: [WK1] REGRESSION (r129545): Main frame doesn't rubberband unless WebFrameLoad...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac (Intel) OS X 10.8
: P1 Normal
Assignee: Beth Dakin
URL:
Keywords: Regression
Depends on:
Blocks:
 
Reported: 2012-11-21 12:33 PST by Adam Roben (:aroben)
Modified: 2012-11-29 11:36 PST (History)
2 users (show)

See Also:


Attachments
Patch (1.60 KB, patch)
2012-11-26 17:45 PST, Beth Dakin
no flags Details | Formatted Diff | Diff
Stork-free patch (1.57 KB, patch)
2012-11-27 14:15 PST, Beth Dakin
sam: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Roben (:aroben) 2012-11-21 12:33:50 PST
Starting in r129545, the main frame no longer rubberbands in WebKit1 apps. It's easy to see this with any long content.
Comment 1 Adam Roben (:aroben) 2012-11-21 12:45:47 PST
I think I see the bug. In -[WebView _cacheFrameLoadDelegateImplementations] we have this code:

http://trac.webkit.org/browser/trunk/Source/WebKit/mac/WebView/WebView.mm?rev=129545#L1653

    // It would be nice to get rid of this code and transition all clients to using didLayout instead of
    // didFirstLayoutInFrame and didFirstVisuallyNonEmptyLayoutInFrame. In the meantime, this is required
    // for backwards compatibility.
    Page* page = core(self);
    if (page) {
        unsigned milestones = 0;
        if (cache->didFirstLayoutInFrameFunc)
            milestones |= DidFirstLayout;
        if (cache->didFirstVisuallyNonEmptyLayoutInFrameFunc)
            milestones |= DidFirstVisuallyNonEmptyLayout;
        page->addLayoutMilestones(static_cast<LayoutMilestones>(milestones));
    }

This means that we'll only listen for the DidFirstLayout milestone if the WebFrameLoadDelegate responds to -webView:didFirstLayoutInFrame:.

In WebFrameLoaderClient::dispatchDidLayout, we have this code:

http://trac.webkit.org/browser/trunk/Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm?rev=129545#L673

    if (milestones & DidFirstLayout) {
        // FIXME: We should consider removing the old didFirstLayout API since this is doing double duty with the
        // new didLayout API.
        if (implementations->didFirstLayoutInFrameFunc)
            CallFrameLoadDelegate(implementations->didFirstLayoutInFrameFunc, webView, @selector(webView:didFirstLayoutInFrame:), m_webFrame.get());

        // See WebFrameLoaderClient::provisionalLoadStarted.
        WebDynamicScrollBarsView *scrollView = [m_webFrame->_private->webFrameView _scrollView];
        if ([getWebView(m_webFrame.get()) drawsBackground])
            [scrollView setDrawsBackground:YES];
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
        [scrollView setVerticalScrollElasticity:NSScrollElasticityAutomatic];
        [scrollView setHorizontalScrollElasticity:NSScrollElasticityAutomatic];
#endif
    }

So we'll only set the scroll view's elasticity if we get a DidFirstLayout milestone, but we'll only get that if the WebFrameLoadDelegate responds to -webView:didFirstLayoutInFrame:. (Note that not even implementing the new -webView:didLayout: method will get elasticity to work.)
Comment 2 Adam Roben (:aroben) 2012-11-21 13:08:21 PST
A simple fix would be to always ask for DidFirstLayout in WK1.
Comment 3 Beth Dakin 2012-11-26 17:18:20 PST
(In reply to comment #2)
> A simple fix would be to always ask for DidFirstLayout in WK1.

I think this fix makes sense. I did something similar for other ports that were doing necessary work when those events fire. I will post a patch in a minute!
Comment 4 Beth Dakin 2012-11-26 17:45:07 PST
Created attachment 176127 [details]
Patch
Comment 5 Adam Roben (:aroben) 2012-11-26 18:52:40 PST
Comment on attachment 176127 [details]
Patch

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

> Source/WebKit/mac/ChangeLog:9
> +        We should always register for DidFirstLayout in WK1 since we do stork 

stork!
Comment 6 Beth Dakin 2012-11-27 14:15:21 PST
Created attachment 176337 [details]
Stork-free patch
Comment 7 Adam Roben (:aroben) 2012-11-27 14:16:58 PST
Comment on attachment 176337 [details]
Stork-free patch

This looks great to me. Probably worth having someone else take a look since I suggested the approach though. Thanks for jumping on it!
Comment 8 Sam Weinig 2012-11-28 10:36:41 PST
Comment on attachment 176337 [details]
Stork-free patch

Looks good to me too. r=me.
Comment 9 Beth Dakin 2012-11-28 11:38:26 PST
Excellent! Thanks, guys.

http://trac.webkit.org/changeset/136033
Comment 10 Adam Roben (:aroben) 2012-11-28 11:39:32 PST
Yay!
Comment 11 Adam Roben (:aroben) 2012-11-29 11:36:54 PST
I can confirm this is fixed in the r136085 nightly build.