Bug 91110

Summary: [Chromium] Call restrictScaleFactorToInitialScaleIfNotUserScalable unless/until userScalable is supported directly.
Product: WebKit Reporter: John Mellor <johnme>
Component: WebCore Misc.Assignee: Adam Barth <abarth>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, aelias, darin, fsamuel, peter, skyostil, tony, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 95952    
Bug Blocks: 66687    
Attachments:
Description Flags
Patch
none
Patch
none
Patch for landing abarth: commit-queue+

Description John Mellor 2012-07-12 09:49:18 PDT
Chromium should call restrictScaleFactorToInitialScaleIfNotUserScalable unless/until userScalable is supported directly.
Comment 1 John Mellor 2012-07-12 09:58:08 PDT
Created attachment 151981 [details]
Patch
Comment 2 John Mellor 2012-07-12 10:11:06 PDT
In bug 70609 comment 19 Fady factored out the following line from computeViewportAttributes:

    if (!args.userScalable) result.maximumScale = result.minimumScale = result.initialScale;

into a separate function, restrictScaleFactorToInitialScaleIfNotUserScalable, which wasn't called on Chromium. Instead at least on Android we used to handle userScalable separately. However Android dropped that separate handling in https://gerrit-int.chromium.org/12197 when it synchronized with upstream, and current upstream seems to completely ignore the value of userScalable!

This patch fixes the immediate issue, that we completely ignore user-scalable=no. But I seem to remember there was some subtle reason for not overwriting mininum-scale/maximum-scale with the initial-scale, and that it was better to handle it separately. Fady, can you remember what this was? And do any of you remember why we stopped handling userScalable separately? Was it just a casualty of upstreaming?
Comment 3 Adam Barth 2012-07-12 10:16:51 PDT
Comment on attachment 151981 [details]
Patch

You should be able to write a test for this along the lines of WebFrameTest.CanOverrideMaximumScaleFactor in http://trac.webkit.org/browser/trunk/Source/WebKit/chromium/tests/WebViewTest.cpp
Comment 4 Peter Beverloo 2012-07-13 02:22:58 PDT
Comment on attachment 151981 [details]
Patch

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

> Source/WebKit/chromium/ChangeLog:6
> +        Since https://gerrit-int.chromium.org/12197 the chromium-android port

We shouldn't refer to internal URLs in ChangeLog messages. They're meant to be informative for all parties, and this way only Googlers can get access to the context.
Comment 5 John Mellor 2012-07-30 11:17:04 PDT
(In reply to comment #2)
> But I seem to remember there was some subtle reason for not overwriting mininum-scale/maximum-scale with the initial-scale, and that it was better to handle it separately.

Ah yes - suppose the viewport tag doesn't have a min/max-scale, but does have user-scalable=no. The initial-scale computed at this point assumes that we will use the viewport width as our initial containing block [1]. But if the page has a CSS min-width larger than the viewport width, and the viewport tag didn't specify any scale information, we might later choose to set the initial containing block such that the entire page fits within it, and end up with a smaller initial-scale (I can't remember whether or not this is fully spec-compliant, but OTH some major browsers do it anyway). If we implement user-scalable by overwriting min/max-scale with our initial viewport-based guess at the initial-scale, then if we later do want to adjust the initial-scale, we can no longer tell whether we were banned from doing so (because of an explicit min/max-scale), or we are actually allowed to do so (because there was only a user-scalable directive).

Nevertheless, I still think this patch is useful in the short term, as it's better than not supporting user-scalable at all!

A test would be useful. I probably won't get round to that for a little while.

[1]: http://www.w3.org/TR/2004/CR-CSS21-20040225/visudet.html#containing-block-details
Comment 6 John Mellor 2012-07-30 11:38:44 PDT
(In reply to comment #4)
> (From update of attachment 151981 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=151981&action=review
> 
> > Source/WebKit/chromium/ChangeLog:6
> > +        Since https://gerrit-int.chromium.org/12197 the chromium-android port
> 
> We shouldn't refer to internal URLs in ChangeLog messages. They're meant to be informative for all parties, and this way only Googlers can get access to the context.

$ git grep -n 'rdar' -- '*ChangeLog*' | wc -l
13464

I agree in principle, but this is the chromium ChangeLog and there's no publicly accessible equivalent way of referencing our downstream history, so it seems worth keeping this useful piece of context...
Comment 7 Adam Barth 2012-07-30 12:08:35 PDT
(In reply to comment #6)
> (In reply to comment #4)
> > (From update of attachment 151981 [details] [details])
> > View in context: https://bugs.webkit.org/attachment.cgi?id=151981&action=review
> > 
> > > Source/WebKit/chromium/ChangeLog:6
> > > +        Since https://gerrit-int.chromium.org/12197 the chromium-android port
> > 
> > We shouldn't refer to internal URLs in ChangeLog messages. They're meant to be informative for all parties, and this way only Googlers can get access to the context.
> 
> $ git grep -n 'rdar' -- '*ChangeLog*' | wc -l
> 13464
> 
> I agree in principle, but this is the chromium ChangeLog and there's no publicly accessible equivalent way of referencing our downstream history, so it seems worth keeping this useful piece of context...

As a contributor to the project, I often become sad when my search for the "why" behind a piece of code ends in an rdar link.  I appreciate that you've taken the time to write a descriptive ChangeLog for this patch, which is very helpful and mitigates this issue to a large extent.

Unfortunately, any value that's added by the gerrit-int is only enjoyed by the small number of folks who can follow that link.  If that's a large amount of value, then the majority of the contributors to the project are missing out.  If it's a small amount of value, then it's probably not worth making the rest of the contributors feel sad that they can't follow the link
Comment 8 Adam Barth 2012-07-30 12:09:26 PDT
> A test would be useful. I probably won't get round to that for a little while.

I can try writing one for you.
Comment 9 John Mellor 2012-07-30 12:34:02 PDT
(In reply to comment #8)
> > A test would be useful. I probably won't get round to that for a little while.
> 
> I can try writing one for you.

Thanks Adam!
Comment 10 Adam Barth 2012-07-30 14:52:35 PDT
Turns out we can test this using a simple LayoutTest.
Comment 11 Adam Barth 2012-07-30 14:57:28 PDT
Created attachment 155372 [details]
Patch
Comment 12 John Mellor 2012-07-30 15:06:17 PDT
Comment on attachment 155372 [details]
Patch

Test looks good (though possibly a little implementation-specific?).
Comment 13 Adam Barth 2012-07-30 15:15:15 PDT
> Test looks good (though possibly a little implementation-specific?).

Yeah, that's a general problem with these fast/viewport tests.  However, as far as I can tell, this is the implementation used by the other ports that implement viewport in WebKit.
Comment 14 John Mellor 2012-09-05 11:40:36 PDT
Shall we try to get this landed then?
Comment 15 Adam Barth 2012-09-05 13:05:42 PDT
Sorry, this fell off my radar.
Comment 16 Adam Barth 2012-09-05 13:06:55 PDT
@tony: Would you be willing to review this patch?
Comment 17 Tony Chang 2012-09-05 13:13:55 PDT
Comment on attachment 155372 [details]
Patch

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

> LayoutTests/fast/viewport/viewport-limits-adjusted-for-no-user-scale-control.html:7
> +                alert(internals.configurationForViewport(document, 1, 320, 480, 320, 352));

Nit: It would be nice if the test said PASS or something so random people gardening can quickly tell if the test is correct or not.

> LayoutTests/fast/viewport/viewport-limits-adjusted-for-no-user-scale.html:7
> +                alert(internals.configurationForViewport(document, 1, 320, 480, 320, 352));

Ditto.
Comment 18 Adam Barth 2012-09-05 13:22:20 PDT
Comment on attachment 155372 [details]
Patch

Thanks!
Comment 19 Adam Barth 2012-09-05 13:35:27 PDT
Created attachment 162320 [details]
Patch for landing
Comment 20 Adam Barth 2012-09-06 00:35:12 PDT
Committed r127704: <http://trac.webkit.org/changeset/127704>