Skip to content
Permalink
Browse files
[iOS] Adjust initial scale zooming heuristics when changing view scale
https://bugs.webkit.org/show_bug.cgi?id=194995

Reviewed by Tim Horton.

Source/WebKit:

Currently, we only zoom to the new initial scale iff we're exactly at initial scale before changing the view
scale. This was done so that if a user zoomed in really far and then increased the view scale, we wouldn't end
up zooming out as a result. However, this leads to confusing behavior in the case where the user has manually
changed the zoom scale to something close to (but not exactly) initial scale, and then attempts to zoom in
further using view scale. In this case, we'll end up keeping page scale the same, so it looks like nothing is
happening.

To fix this, we tweak our heuristics for determining whether to jump to initial scale; if the view scale is
increasing and the new initial scale is greater than the current scale, zoom to initial scale. Likewise, if the
view scale is decreasing and the new initial scale is less than the current scale, zoom to initial scale.

Test: fast/viewport/ios/initial-scale-after-changing-view-scale.html

* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::setViewportConfigurationViewLayoutSize):

LayoutTests:

Rebaseline and adjust an existing layout test.

* fast/viewport/ios/initial-scale-after-changing-view-scale-expected.txt:
* fast/viewport/ios/initial-scale-after-changing-view-scale.html:
* platform/ipad/fast/viewport/ios/initial-scale-after-changing-view-scale-expected.txt: Removed.

Removed an iPad-specific test expectation, since initial scale zooming behavior should be the same now at both
device dimensions.


Canonical link: https://commits.webkit.org/209383@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242059 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
whsieh committed Feb 26, 2019
1 parent ede42b8 commit 05d01d098257ba81754eb831df74b0f472c38354
Showing 6 changed files with 60 additions and 30 deletions.
@@ -1,3 +1,19 @@
2019-02-25 Wenson Hsieh <wenson_hsieh@apple.com>

[iOS] Adjust initial scale zooming heuristics when changing view scale
https://bugs.webkit.org/show_bug.cgi?id=194995

Reviewed by Tim Horton.

Rebaseline and adjust an existing layout test.

* fast/viewport/ios/initial-scale-after-changing-view-scale-expected.txt:
* fast/viewport/ios/initial-scale-after-changing-view-scale.html:
* platform/ipad/fast/viewport/ios/initial-scale-after-changing-view-scale-expected.txt: Removed.

Removed an iPad-specific test expectation, since initial scale zooming behavior should be the same now at both
device dimensions.

2019-02-25 Frederic Wang <fwang@igalia.com>

Split iOS tests for hit testing in iframes
@@ -5,12 +5,12 @@ Initial page scale factor : 1.00

Page scale after double tapping to zoom in : 1.60
- Page scale after setViewScale(1.25) : 1.60
- Page scale after setViewScale(0.75) : 1.60
- Page scale after setViewScale(1) : 1.60

Page scale after double tapping to zoom out : 1.00
- Page scale after setViewScale(1.25) : 1.25
- Page scale after setViewScale(0.75) : 0.75
- Page scale after setViewScale(1) : 1.00

Page scale after double tapping to zoom in again : 1.60
- Page scale after setViewScale(0.75) : 0.75
- Page scale after setViewScale(1.25) : 1.25
- Page scale after setViewScale(1) : 1.00

This test verifies that changing the view scale zooms the page to initial scale, but only if the page was already at initial scale. To manually test, (1) change the zoom scale without changing the page scale in any way, and check that the page zooms to initial scale; (2) now double tap on the box to zoom in, and check that changing zoom levels does not change the page scale; (3) finally, double tap on the box again to zoom back out to initial scale, and check that changing zoom levels automatically zooms the page to initial scale once again.
@@ -70,10 +70,10 @@
appendOutput(` - Page scale after setViewScale(0.75) : ${await pageScaleAfterSettingViewScale(0.75)}`);
appendOutput(` - Page scale after setViewScale(1) : ${await pageScaleAfterSettingViewScale(1)}`);
appendOutput("");
appendOutput(`Page scale after double tapping to zoom out : ${await pageScaleAfterDoubleTappingOnSquare()}`);
appendOutput(` - Page scale after setViewScale(1.25) : ${await pageScaleAfterSettingViewScale(1.25)}`);
appendOutput(` - Page scale after setViewScale(0.75) : ${await pageScaleAfterSettingViewScale(0.75)}`);
appendOutput(` - Page scale after setViewScale(1) : ${await pageScaleAfterSettingViewScale(1)}`);
appendOutput(`Page scale after double tapping to zoom in again : ${await pageScaleAfterDoubleTappingOnSquare()}`);
appendOutput(` - Page scale after setViewScale(0.75) : ${await pageScaleAfterSettingViewScale(0.75)}`);
appendOutput(` - Page scale after setViewScale(1.25) : ${await pageScaleAfterSettingViewScale(1.25)}`);
appendOutput(` - Page scale after setViewScale(1) : ${await pageScaleAfterSettingViewScale(1)}`);
appendOutput("");

testRunner.notifyDone();

This file was deleted.

@@ -1,3 +1,26 @@
2019-02-25 Wenson Hsieh <wenson_hsieh@apple.com>

[iOS] Adjust initial scale zooming heuristics when changing view scale
https://bugs.webkit.org/show_bug.cgi?id=194995

Reviewed by Tim Horton.

Currently, we only zoom to the new initial scale iff we're exactly at initial scale before changing the view
scale. This was done so that if a user zoomed in really far and then increased the view scale, we wouldn't end
up zooming out as a result. However, this leads to confusing behavior in the case where the user has manually
changed the zoom scale to something close to (but not exactly) initial scale, and then attempts to zoom in
further using view scale. In this case, we'll end up keeping page scale the same, so it looks like nothing is
happening.

To fix this, we tweak our heuristics for determining whether to jump to initial scale; if the view scale is
increasing and the new initial scale is greater than the current scale, zoom to initial scale. Likewise, if the
view scale is decreasing and the new initial scale is less than the current scale, zoom to initial scale.

Test: fast/viewport/ios/initial-scale-after-changing-view-scale.html

* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::setViewportConfigurationViewLayoutSize):

2019-02-25 John Wilander <wilander@apple.com>

Introduce and adopt new class RegistrableDomain for eTLD+1
@@ -2676,12 +2676,19 @@ static inline bool areEssentiallyEqualAsFloat(float a, float b)
{
LOG_WITH_STREAM(VisibleRects, stream << "WebPage " << m_pageID << " setViewportConfigurationViewLayoutSize " << size << " scaleFactor " << scaleFactor << " minimumEffectiveDeviceWidth " << minimumEffectiveDeviceWidth);

ZoomToInitialScale shouldZoomToInitialScale = ZoomToInitialScale::No;
if (m_viewportConfiguration.layoutSizeScaleFactor() != scaleFactor && areEssentiallyEqualAsFloat(m_viewportConfiguration.initialScale(), pageScaleFactor()))
shouldZoomToInitialScale = ZoomToInitialScale::Yes;
auto previousLayoutSizeScaleFactor = m_viewportConfiguration.layoutSizeScaleFactor();
if (!m_viewportConfiguration.setViewLayoutSize(size, scaleFactor, minimumEffectiveDeviceWidth))
return;

auto zoomToInitialScale = ZoomToInitialScale::No;
auto newInitialScale = m_viewportConfiguration.initialScale();
auto currentPageScaleFactor = pageScaleFactor();
if (scaleFactor > previousLayoutSizeScaleFactor && newInitialScale > currentPageScaleFactor)
zoomToInitialScale = ZoomToInitialScale::Yes;
else if (scaleFactor < previousLayoutSizeScaleFactor && newInitialScale < currentPageScaleFactor)
zoomToInitialScale = ZoomToInitialScale::Yes;

if (m_viewportConfiguration.setViewLayoutSize(size, scaleFactor, minimumEffectiveDeviceWidth))
viewportConfigurationChanged(shouldZoomToInitialScale);
viewportConfigurationChanged(zoomToInitialScale);
}

void WebPage::setMaximumUnobscuredSize(const FloatSize& maximumUnobscuredSize)

0 comments on commit 05d01d0

Please sign in to comment.