Bug 109317

Summary: REGRESSION (r132422): Page content and scrollbars are incorrectly offset after restoring a page from the page cache
Product: WebKit Reporter: Tim Horton <thorton>
Component: Layout and RenderingAssignee: Tim Horton <thorton>
Status: RESOLVED FIXED    
Severity: Normal CC: bdakin, beidson, sam, simon.fraser
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
preliminary patch (breaks at least one test, needs a test of its own)
none
with a test
simon.fraser: review-
patch simon.fraser: review+

Description Tim Horton 2013-02-08 13:08:36 PST
There are a variety of codepaths that cause scrolling during layout, whether temporary or not. These scrolls are all programmatic, but many go through FrameView/ScrollableArea functions that don't have this knowledge. Since there's no chance a user-originated scroll can happen during layout, we should just mark all scrolls during layout as programmatic.

This fixes numerous bugs on builds that use ScrollingCoordinator, one of which has these steps to reproduce:

1. Load news.ycombinator.com
2. Scroll to the bottom of the page.
3. Click a link.
4. Click the back button.

Expected:

The scrollbar is in the right place relative to the content, and hovering over links hovers over the appropriate link (see the status bar).

Actual:

The scrollbar is at the top, but the content is scrolled. Hovering over links hovers over the wrong links.

<rdar://problem/12649131>
Comment 1 Tim Horton 2013-02-08 13:36:16 PST
Created attachment 187357 [details]
preliminary patch (breaks at least one test, needs a test of its own)
Comment 2 Tim Horton 2013-02-10 01:51:46 PST
Created attachment 187471 [details]
with a test
Comment 3 Tim Horton 2013-02-10 02:00:27 PST
Comment on attachment 187471 [details]
with a test

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

> LayoutTests/platform/mac-wk2/tiled-drawing/resources/scroll-and-load-page.html:17
> +                    log += internals.layerTreeAsText(window.document, internals.LAYER_TREE_INCLUDES_VISIBLE_RECTS | internals.LAYER_TREE_INCLUDES_TILE_CACHES);

Should check for internals' existence here.

> LayoutTests/platform/mac-wk2/tiled-drawing/tiled-drawing-scroll-position-page-cache-restoration.html:14
> +            if (window.internals)

Don't need this line.
Comment 4 Simon Fraser (smfr) 2013-02-10 09:49:20 PST
Comment on attachment 187471 [details]
with a test

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

> LayoutTests/platform/mac-wk2/tiled-drawing/tiled-drawing-scroll-position-page-cache-restoration.html:22
> +            window.open("resources/scroll-and-load-page.html");

Do you need to use window.open? Can't you just scroll, load another page that goes back, then finish the test?

> Tools/ChangeLog:9
> +        WebKitTestRunner should propagate window creation options to subwindows (so that children of tiled-drawing windows use tiled drawing, in this case).

This should really be a separate patch.

> Tools/WebKitTestRunner/PlatformWebView.h:98
> +    WKDictionaryRef options() { return m_options.get(); }

const?
Comment 5 Tim Horton 2013-02-10 10:26:14 PST
(In reply to comment #4)
> (From update of attachment 187471 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=187471&action=review
> 
> > LayoutTests/platform/mac-wk2/tiled-drawing/tiled-drawing-scroll-position-page-cache-restoration.html:22
> > +            window.open("resources/scroll-and-load-page.html");
> 
> Do you need to use window.open? Can't you just scroll, load another page that goes back, then finish the test?

I'm not sure why that didn't work; it looked like the first page (the one that turns on the page cache) wasn't getting put *into* the page cache. So I followed suit with the other page-cache-testing tests and turned it on, then opened a new window. Maybe Brady knows.

> > Tools/ChangeLog:9
> > +        WebKitTestRunner should propagate window creation options to subwindows (so that children of tiled-drawing windows use tiled drawing, in this case).
> 
> This should really be a separate patch.

Yerp.

> > Tools/WebKitTestRunner/PlatformWebView.h:98
> > +    WKDictionaryRef options() { return m_options.get(); }
> 
> const?

Sure.
Comment 6 Tim Horton 2013-02-10 11:59:13 PST
Created attachment 187490 [details]
patch
Comment 7 Tim Horton 2013-02-10 12:13:23 PST
http://trac.webkit.org/changeset/142416