Bug 66229

Summary: WebKit doesn't react to device scale factor changes
Product: WebKit Reporter: Adam Roben (:aroben) <aroben>
Component: Layout and RenderingAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: andersca, hyatt, jamesr, sam, 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:    
Bug Blocks: 66244    
Attachments:
Description Flags
Update pages' style and content scale when the window's backing scale factor changes
none
Update pages' style and content scale when the window's backing scale factor changes simon.fraser: review+

Description Adam Roben (:aroben) 2011-08-15 08:08:20 PDT
A window's scale factor can change over time, in a couple of different ways:

(1) it could be dragged from one monitor to another monitor that has a different scale factor
(2) the scale factor of the entire display could be changed (which, I believe, ripples across the individual windows)

We need to make sure that when this happens, WebKit responds appropriately.
Comment 1 Adam Roben (:aroben) 2011-08-15 08:08:38 PDT
<rdar://problem/9906269>
Comment 2 Adam Roben (:aroben) 2011-08-15 08:28:35 PDT
Created attachment 103915 [details]
Update pages' style and content scale when the window's backing scale factor changes
Comment 3 Simon Fraser (smfr) 2011-08-15 11:29:39 PDT
Comment on attachment 103915 [details]
Update pages' style and content scale when the window's backing scale factor changes

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

> Source/WebCore/page/Frame.h:172
> +#if USE(ACCELERATED_COMPOSITING)
> +        void deviceOrPageScaleFactorChanged();
> +#endif

I don't think this method should be #ifdeffed. In fact, it could be the one entry point that then calls setNeedsRecalcStyleInAllFrames().
Comment 4 Adam Roben (:aroben) 2011-08-15 11:31:16 PDT
Comment on attachment 103915 [details]
Update pages' style and content scale when the window's backing scale factor changes

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

>> Source/WebCore/page/Frame.h:172
>> +#endif
> 
> I don't think this method should be #ifdeffed. In fact, it could be the one entry point that then calls setNeedsRecalcStyleInAllFrames().

I can un-ifdef it. But I don't think it should call setNeedsRecalcStyleInAllFrames. Hyatt told me we don't want to call that function when pinch-zooming, as it will be too slow, and the page scale factor doesn't affect style anyway.
Comment 5 Adam Roben (:aroben) 2011-08-15 12:04:36 PDT
Simon and I decided that having a separate, public deviceScaleFactorChanged function that calls through to the private deviceOrPageScaleFactorChanged function would be clearest. Of course, all this logic should really be on Page, not Frame.
Comment 6 Adam Roben (:aroben) 2011-08-15 12:28:26 PDT
Created attachment 103943 [details]
Update pages' style and content scale when the window's backing scale factor changes
Comment 7 Simon Fraser (smfr) 2011-08-15 13:35:36 PDT
Comment on attachment 103943 [details]
Update pages' style and content scale when the window's backing scale factor changes

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

> Source/WebKit/mac/WebView/WebView.mm:3395
> +#if USE(ACCELERATED_COMPOSITING)
> +    _private->page->mainFrame()->deviceScaleFactorChanged();
> +#endif

This should not be inside #ifdefs now, right?

> Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.cpp:153
> +void LayerTreeHostCA::deviceScaleFactorDidChange()

Seems odd to have methods called deviceScaleFactorChanged() and deviceScaleFactorDidChange() in various places. Can they share the same name?
Comment 8 Adam Roben (:aroben) 2011-08-15 13:38:39 PDT
Comment on attachment 103943 [details]
Update pages' style and content scale when the window's backing scale factor changes

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

>> Source/WebKit/mac/WebView/WebView.mm:3395
>> +#endif
> 
> This should not be inside #ifdefs now, right?

Right! Removed.

>> Source/WebKit2/WebProcess/WebPage/ca/LayerTreeHostCA.cpp:153
>> +void LayerTreeHostCA::deviceScaleFactorDidChange()
> 
> Seems odd to have methods called deviceScaleFactorChanged() and deviceScaleFactorDidChange() in various places. Can they share the same name?

In each case I was trying to match other functions in the same class (specifically, Frame::deviceOrPageScaleFactorChanged and related functions in RenderLayerCompositor and GraphicsLayer, and LayerTreeHost::sizeDidChange). I agree it would be nice if we had a consistent "did change" vs. "changed" convention throughout our code, particularly for cases like this where the two clash.
Comment 9 Adam Roben (:aroben) 2011-08-15 14:07:21 PDT
Committed r93058: <http://trac.webkit.org/changeset/93058>