Bug 103521 - Possible to resize out of bounds
Summary: Possible to resize out of bounds
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Allan Sandfeld Jensen
URL:
Keywords:
Depends on: 103875
Blocks:
  Show dependency treegraph
 
Reported: 2012-11-28 06:32 PST by Allan Sandfeld Jensen
Modified: 2012-12-03 03:45 PST (History)
4 users (show)

See Also:


Attachments
Patch (2.35 KB, patch)
2012-11-28 06:35 PST, Allan Sandfeld Jensen
no flags Details | Formatted Diff | Diff
Patch (8.40 KB, patch)
2012-11-28 09:06 PST, Allan Sandfeld Jensen
no flags Details | Formatted Diff | Diff
Patch (9.35 KB, patch)
2012-11-28 09:07 PST, Allan Sandfeld Jensen
no flags Details | Formatted Diff | Diff
Patch (9.90 KB, patch)
2012-11-29 06:17 PST, Allan Sandfeld Jensen
no flags Details | Formatted Diff | Diff
Patch (9.98 KB, patch)
2012-11-29 06:37 PST, Allan Sandfeld Jensen
jturcotte: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Allan Sandfeld Jensen 2012-11-28 06:32:58 PST
If you double-tap to zoom, and double-tap to zoom out, it is possible to resize the viewport while breaking the viewport zoom/resize bounds. 

While not problem for a full-screen application it could cause trouble for a QML application that resize the viewport to make room for keyboard or notifications. As soon as the user has performed a manual zoom, all the resize logic would act differently, even if the user has zoomed back to the initial state.
Comment 1 Allan Sandfeld Jensen 2012-11-28 06:35:11 PST
Created attachment 176476 [details]
Patch
Comment 2 Kenneth Rohde Christiansen 2012-11-28 06:36:38 PST
Comment on attachment 176476 [details]
Patch

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

> Source/WebKit2/UIProcess/PageViewportController.cpp:285
> +    bool wasMinimumScale = (m_effectiveScale == toViewportScale(m_minimumScaleToFit));

wasAt ?

> Source/WebKit2/UIProcess/PageViewportController.cpp:303
> -            applyScaleAfterRenderingContents(toViewportScale(minimumScale));
> +        if (!hasSuspendedContent()) {
> +            if (wasMinimumScale)
> +                applyScaleAfterRenderingContents(toViewportScale(m_minimumScaleToFit));
> +            else {
> +                float boundedScale = innerBoundedViewportScale(m_effectiveScale);
> +                if (boundedScale != m_effectiveScale)
> +                    applyScaleAfterRenderingContents(boundedScale);
> +            }
> +        }

Any QML test for this?
Comment 3 Allan Sandfeld Jensen 2012-11-28 09:06:47 PST
Created attachment 176494 [details]
Patch
Comment 4 Allan Sandfeld Jensen 2012-11-28 09:07:30 PST
Created attachment 176495 [details]
Patch

Forgot to update the commit before uploading.
Comment 5 Andras Becsi 2012-11-28 09:11:05 PST
Comment on attachment 176495 [details]
Patch

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

> Source/WebKit2/UIProcess/PageViewportController.cpp:286
> +    bool currentlyScaledToFit = (m_effectiveScale == toViewportScale(m_minimumScaleToFit));
> +

It might be better to use fuzzyCompare for these float values.

> Source/WebKit2/UIProcess/PageViewportController.cpp:302
> +                if (boundedScale != m_effectiveScale)

fuzzyCompare here as well?
Comment 6 Andras Becsi 2012-11-28 09:14:02 PST
Comment on attachment 176495 [details]
Patch

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

> Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_fitToView.qml:-94
> -
> -            // We had user interaction, size should change but not scale.
> -            setDisplay("target", "block")
> -            compare(documentSize(), "960x1440")
> -            compare(test.contentsScale, 1.0)

Why remove this?
Comment 7 Allan Sandfeld Jensen 2012-11-28 09:16:57 PST
(In reply to comment #6)
> (From update of attachment 176495 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=176495&action=review
> 
> > Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_fitToView.qml:-94
> > -
> > -            // We had user interaction, size should change but not scale.
> > -            setDisplay("target", "block")
> > -            compare(documentSize(), "960x1440")
> > -            compare(test.contentsScale, 1.0)
> 
> Why remove this?

Because it is no longer true. The since the viewport is scaled to fit, it will still resize to stay fit.
Comment 8 Allan Sandfeld Jensen 2012-11-28 09:19:53 PST
(In reply to comment #5)
> (From update of attachment 176495 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=176495&action=review
> 
> > Source/WebKit2/UIProcess/PageViewportController.cpp:286
> > +    bool currentlyScaledToFit = (m_effectiveScale == toViewportScale(m_minimumScaleToFit));
> > +
> 
> It might be better to use fuzzyCompare for these float values.
> 

Here it doesn't matter because the values are not calculated. It is testing if the effectiveScale has been specifically set to the this value.

> > Source/WebKit2/UIProcess/PageViewportController.cpp:302
> > +                if (boundedScale != m_effectiveScale)
> 
> fuzzyCompare here as well?

I guess that could make sense, but again. It is more about testing if the effective scale has been set to this value, not if the values are close.
Comment 9 Andras Becsi 2012-11-28 09:31:04 PST
Comment on attachment 176495 [details]
Patch

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

>>> Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_fitToView.qml:-94
>>> -            compare(test.contentsScale, 1.0)
>> 
>> Why remove this?
> 
> Because it is no longer true. The since the viewport is scaled to fit, it will still resize to stay fit.

Hmm, but we shouldn't change the scale if there was user interaction and the viewport size did not change, we should leave the scale to the value set by the user, no?
Comment 10 Andras Becsi 2012-11-29 02:43:08 PST
Comment on attachment 176495 [details]
Patch

I'm sorry, but this patch breaks expected behavior.
The above mentioned test should not be removed since it is still valid.
After a user interaction the scale should only be reset if the viewport size changes _and_ the current scale would result in the page being out of bounds eg. smaller than the allowed minimum-scale-to-fit.
Comment 11 Allan Sandfeld Jensen 2012-11-29 06:17:14 PST
Created attachment 176714 [details]
Patch

Only enforce fitness on viewport resize, not on content size change
Comment 12 Jocelyn Turcotte 2012-11-29 06:27:22 PST
Comment on attachment 176714 [details]
Patch

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

> Source/WebKit2/UIProcess/PageViewportController.cpp:296
> -        if (!m_hadUserInteraction && !hasSuspendedContent())
> -            applyScaleAfterRenderingContents(toViewportScale(minimumScale));
> +        if (!hasSuspendedContent()) {
> +            if (scaleToFit)

For the readability sake, could you try to put (!m_hadUserInteraction || userInitiatedUpdate) in the same statement?
I also liked the context that "currentlyFitToViewport" added in the previous patch, if that name can be preserved.
Comment 13 Allan Sandfeld Jensen 2012-11-29 06:37:10 PST
Created attachment 176716 [details]
Patch

Minor style changes
Comment 14 Jocelyn Turcotte 2012-11-29 06:48:57 PST
Comment on attachment 176716 [details]
Patch

Thanks, this is easier to read.
Comment 15 Allan Sandfeld Jensen 2012-11-29 07:01:57 PST
Committed r136129: <http://trac.webkit.org/changeset/136129>