Bug 66244

Summary: Cached pages don't fully update when going back after changing the display scale factor
Product: WebKit Reporter: Adam Roben (:aroben) <aroben>
Component: Layout and RenderingAssignee: Beth Dakin <bdakin>
Severity: Normal CC: bdakin, hyatt, simon.fraser, sullivan, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Mac (Intel)   
OS: OS X 10.7   
Bug Depends on: 66229    
Bug Blocks:    
Description Flags
Patch darin: review+

Description Adam Roben (:aroben) 2011-08-15 11:58:53 PDT
To reproduce:

1. Go to data:text/html,This%20is%20some%20text
2. Go to about:blank
3. Change your display's scale factor
4. Click Back

The text is blurry because it hasn't been redrawn at the new scale factor. Ew!
Comment 1 Radar WebKit Bug Importer 2011-08-15 11:59:20 PDT
Comment 2 Beth Dakin 2011-08-23 15:36:36 PDT
Adam's original steps actually don't reproduce a bug any more, but there is still a bug here. Re-titling to reflect the remaining issues. Here are steps to reproduce the remaining issue:

1. Go to data:text/html,%3C!DOCTYPEhtml%3E%3Cstyle%3E@media(-webkit-min-device-pixel-ratio:2)%7Bspan::after%7Bcontent:'2'!important;%7D%7Dspan::after%7Bcontent:'1';%7D%3C/style%3EDevice%20pixel%20ratio:%20%3Cspan%3E%3C/span%3E
2. Go to about:blank
3. Change your display's scale factor
4. Click Back

The displayed scale factor is not appropriately updated to reflect the new scale factor.
Comment 3 Beth Dakin 2011-08-23 16:01:19 PDT
Created attachment 104923 [details]

Here's a patch!
Comment 4 Darin Adler 2011-08-23 16:10:59 PDT
Comment on attachment 104923 [details]

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

Patch seems OK. Could be improved a bit.

> Source/WebCore/page/Frame.cpp:1068
> +    pageCache()->markPagesForFullStyleRecalc();

This will run a bit too often. It runs for the top level frame and then runs again for each subframe. That means we’ll run through the page cache over and over again. No need to do that.

Also, this does more work than needed as I mention below.

> Source/WebCore/page/Page.cpp:601
> +    pageCache()->markPagesForFullStyleRecalc();

This does more work than it has to. Items in the page cache might be for the back/forward in other windows that have a different scale factor. It’s overkill to do it on all the pages in the page cache. Instead we could iterate the back/forward list and do it only for the history items found there.
Comment 5 Beth Dakin 2011-08-23 17:30:20 PDT
I revised the patch to address Darin's comments and got an in-person review. Committed with revision 93669.
Comment 6 Adam Roben (:aroben) 2011-08-24 07:46:56 PDT
Nice! It would be great to write a regression test for this. You could probably base it on this one: <http://trac.webkit.org/browser/trunk/Tools/TestWebKitAPI/Tests/mac/DynamicDeviceScaleFactor.mm?rev=93451>. I'd be happy to help with writing such a test.