Skip to content
Permalink
Browse files
scalableNativeWebpageParameters() is not preserved on new page naviga…
…tion.

https://bugs.webkit.org/show_bug.cgi?id=194892
<rdar://problem/47538280>

Source/WebCore:

If a page's current default viewport configuration is scalableNativeWebpageParameters due to
the fact that m_canIgnoreScalingConstraints is true, loading a new page should preserve this
configuration until we derive the right values from viewport meta-tag.

Patch by Yongjun Zhang <yongjun_zhang@apple.com> on 2019-02-25
Reviewed by Wenson Hsieh.

Test: fast/viewport/ios/viewport-shrink-to-fit-on-new-navigation.html

* page/ViewportConfiguration.cpp:
(WebCore::ViewportConfiguration::canOverrideConfigurationParameters const): Use fixedNativeWebpageParameters().
(WebCore::ViewportConfiguration::updateDefaultConfiguration): Use nativeWebpageParameters.
(WebCore::ViewportConfiguration::nativeWebpageParameters): Return the appropriate default configuration
    based on m_canIgnoreScalingConstraints and shouldIgnoreMinimumEffectiveDeviceWidth().
(WebCore::ViewportConfiguration::fixedNativeWebpageParameters): Renamed from nativeWebpageParameters()
(WebCore::ViewportConfiguration::scalableNativeWebpageParameters): Use fixedNativeWebpageParameters.
* page/ViewportConfiguration.h: Make nativeWebpageParameters() an instance method and change the old
    static method to fixedNativeWebpageParameters which better reflects the actual behavior.

Source/WebKit:

If a page's current default viewport configuration is scalableNativeWebpageParameters due to
the fact that m_canIgnoreScalingConstraints is true, loading a new page should preserve this
configuration until we derive the right values from viewport meta-tag.

Patch by Yongjun Zhang <yongjun_zhang@apple.com> on 2019-02-25
Reviewed by Wenson Hsieh.

* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::resetViewportDefaultConfiguration): Use nativeWebpageParameters() instance method to
    get the appropriate default configuration.

Tools:

Patch by Yongjun Zhang <yongjun_zhang@apple.com> on 2019-02-25
Reviewed by Wenson Hsieh.

Allow UIScriptController to set WKWebView's _allowsViewportShrinkToFit property with a new `setAllowsViewportShrinkToFit` method.

* DumpRenderTree/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptController::setAllowsViewportShrinkToFit):
* DumpRenderTree/mac/UIScriptControllerMac.mm:
(WTR::UIScriptController::allowsViewportShrinkToFit):
* TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
* TestRunnerShared/UIScriptContext/UIScriptController.cpp:
(WTR::UIScriptController::setAllowsViewportShrinkToFit):
* TestRunnerShared/UIScriptContext/UIScriptController.h:
* WebKitTestRunner/UIScriptControllerCocoa.mm:
(WTR::UIScriptController::setAllowsViewportShrinkToFit):

LayoutTests:

Patch by Yongjun Zhang <yongjun_zhang@apple.com> on 2019-02-25
Reviewed by Wenson Hsieh.

* fast/viewport/ios/resources/go-back.html: Added.
* fast/viewport/ios/viewport-shrink-to-fit-on-new-navigation-expected.txt: Added.
* fast/viewport/ios/viewport-shrink-to-fit-on-new-navigation.html: Added.
* fast/viewport/ios/minimum-scale-after-changing-view-scale.html: When shouldIgnoreMetaViewport
    setting is on, for pages don't have viewport meta-tag, the default configuration is now
    changed to scalableNativeWebpageParameters(). The original test was under the assumption
    that the default configuration is always fixedNativeWebpageParameters(). To keep the test
    still valid, add a viewport meta-tag to it.
* resources/ui-helper.js:
(window.UIHelper.setAllowsViewportShrinkToFit):

Canonical link: https://commits.webkit.org/209392@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242069 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Yongjun Zhang authored and webkit-commit-queue committed Feb 26, 2019
1 parent 88fd784 commit 4d6c96eb00a3557152b584b127abeca0749e13f0
Showing 18 changed files with 208 additions and 15 deletions.
@@ -1,3 +1,22 @@
2019-02-25 Yongjun Zhang <yongjun_zhang@apple.com>

scalableNativeWebpageParameters() is not preserved on new page navigation.
https://bugs.webkit.org/show_bug.cgi?id=194892
<rdar://problem/47538280>

Reviewed by Wenson Hsieh.

* fast/viewport/ios/resources/go-back.html: Added.
* fast/viewport/ios/viewport-shrink-to-fit-on-new-navigation-expected.txt: Added.
* fast/viewport/ios/viewport-shrink-to-fit-on-new-navigation.html: Added.
* fast/viewport/ios/minimum-scale-after-changing-view-scale.html: When shouldIgnoreMetaViewport
setting is on, for pages don't have viewport meta-tag, the default configuration is now
changed to scalableNativeWebpageParameters(). The original test was under the assumption
that the default configuration is always fixedNativeWebpageParameters(). To keep the test
still valid, add a viewport meta-tag to it.
* resources/ui-helper.js:
(window.UIHelper.setAllowsViewportShrinkToFit):

2019-02-25 Wenson Hsieh <wenson_hsieh@apple.com>

[iOS] Adjust initial scale zooming heuristics when changing view scale
@@ -1,6 +1,7 @@
<!DOCTYPE html> <!-- webkit-test-runner [ shouldIgnoreMetaViewport=true ] -->
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
margin: 0;
@@ -0,0 +1,10 @@
<!DOCTYPE html> <!-- webkit-test-runner [ shouldIgnoreMetaViewport=true ] -->

This page should go back.
<script>
window.addEventListener("load", function() {
setTimeout(function() {
history.back();
}, 0);
}, false);
</script>
@@ -0,0 +1,6 @@
ALERT: pageshow - not from cache
ALERT: pageshow - from cache
window size: [1008, 1726]
zoom scale: 0.32


@@ -0,0 +1,64 @@
<!DOCTYPE html> <!-- webkit-test-runner [ shouldIgnoreMetaViewport=true ] -->

<html>
<head>
<script src="../../../resources/ui-helper.js"></script>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}

async function finishTest() {
const appendOutput = message => {
output.appendChild(document.createTextNode(message));
output.appendChild(document.createElement("br"));
};

appendOutput(`window size: [${innerWidth}, ${innerHeight}]`);
appendOutput(`zoom scale: ${(await UIHelper.zoomScale()).toFixed(2)}`);
appendOutput("");

await UIHelper.setAllowsViewportShrinkToFit(false);
await Promise.all([UIHelper.ensureVisibleContentRectUpdate(), UIHelper.ensurePresentationUpdate()]);

testRunner.notifyDone();
}

async function setUp() {
await UIHelper.setAllowsViewportShrinkToFit(true);
await Promise.all([UIHelper.ensureVisibleContentRectUpdate(), UIHelper.ensurePresentationUpdate()]);
}

window.addEventListener("pageshow", function(event) {
alert("pageshow - " + (event.persisted ? "" : "not ") + "from cache");
if (event.persisted)
setTimeout(finishTest, 0);
else
setUp();

}, false);

// Force a back navigation back to this page.
window.addEventListener("load", function(event) {
setTimeout(function() {
window.testRunner.overridePreference("WebKitUsesPageCachePreferenceKey", 1);
window.location.href = "resources/go-back.html";
}, 0);
}, false);
</script>

<style>
.wide {
height: 1px;
width: 1000px;
background-color: gray;
}
</style>
</head>

<body>
<div class="wide"></div>
<pre id="output"></pre>
</body>
</html>
@@ -636,6 +636,14 @@ window.UIHelper = class UIHelper {
return new Promise(resolve => testRunner.runUIScript(`uiController.setMinimumEffectiveWidth(${effectiveWidth})`, resolve));
}

static setAllowsViewportShrinkToFit(allows)
{
if (!this.isWebKit2())
return Promise.resolve();

return new Promise(resolve => testRunner.runUIScript(`uiController.setAllowsViewportShrinkToFit(${allows})`, resolve));
}

static setKeyboardInputModeIdentifier(identifier)
{
if (!this.isWebKit2())
@@ -1,3 +1,27 @@
2019-02-25 Yongjun Zhang <yongjun_zhang@apple.com>

scalableNativeWebpageParameters() is not preserved on new page navigation.
https://bugs.webkit.org/show_bug.cgi?id=194892
<rdar://problem/47538280>

If a page's current default viewport configuration is scalableNativeWebpageParameters due to
the fact that m_canIgnoreScalingConstraints is true, loading a new page should preserve this
configuration until we derive the right values from viewport meta-tag.

Reviewed by Wenson Hsieh.

Test: fast/viewport/ios/viewport-shrink-to-fit-on-new-navigation.html

* page/ViewportConfiguration.cpp:
(WebCore::ViewportConfiguration::canOverrideConfigurationParameters const): Use fixedNativeWebpageParameters().
(WebCore::ViewportConfiguration::updateDefaultConfiguration): Use nativeWebpageParameters.
(WebCore::ViewportConfiguration::nativeWebpageParameters): Return the appropriate default configuration
based on m_canIgnoreScalingConstraints and shouldIgnoreMinimumEffectiveDeviceWidth().
(WebCore::ViewportConfiguration::fixedNativeWebpageParameters): Renamed from nativeWebpageParameters()
(WebCore::ViewportConfiguration::scalableNativeWebpageParameters): Use fixedNativeWebpageParameters.
* page/ViewportConfiguration.h: Make nativeWebpageParameters() an instance method and change the old
static method to fixedNativeWebpageParameters which better reflects the actual behavior.

2019-02-25 Zalan Bujtas <zalan@apple.com>

[ContentChangeObserver] Move observing logic from DOMWindow::clearTimeout to ContentChangeObserver
@@ -145,23 +145,15 @@ bool ViewportConfiguration::setDisabledAdaptations(const OptionSet<DisabledAdapt

bool ViewportConfiguration::canOverrideConfigurationParameters() const
{
return m_defaultConfiguration == ViewportConfiguration::nativeWebpageParameters() || m_defaultConfiguration == ViewportConfiguration::scalableNativeWebpageParameters();
return m_defaultConfiguration == ViewportConfiguration::nativeWebpageParametersWithoutShrinkToFit() || m_defaultConfiguration == ViewportConfiguration::nativeWebpageParametersWithShrinkToFit();
}

void ViewportConfiguration::updateDefaultConfiguration()
{
if (!canOverrideConfigurationParameters())
return;

if (m_canIgnoreScalingConstraints) {
m_defaultConfiguration = ViewportConfiguration::scalableNativeWebpageParameters();
return;
}

if (shouldIgnoreMinimumEffectiveDeviceWidth())
m_defaultConfiguration = ViewportConfiguration::nativeWebpageParameters();
else
m_defaultConfiguration = ViewportConfiguration::scalableNativeWebpageParameters();
m_defaultConfiguration = nativeWebpageParameters();
}

bool ViewportConfiguration::setViewportArguments(const ViewportArguments& viewportArguments)
@@ -334,6 +326,14 @@ bool ViewportConfiguration::allowsUserScalingIgnoringAlwaysScalable() const
}

ViewportConfiguration::Parameters ViewportConfiguration::nativeWebpageParameters()
{
if (m_canIgnoreScalingConstraints || !shouldIgnoreMinimumEffectiveDeviceWidth())
return ViewportConfiguration::nativeWebpageParametersWithShrinkToFit();

return ViewportConfiguration::nativeWebpageParametersWithoutShrinkToFit();
}

ViewportConfiguration::Parameters ViewportConfiguration::nativeWebpageParametersWithoutShrinkToFit()
{
Parameters parameters;
parameters.width = ViewportArguments::ValueDeviceWidth;
@@ -348,9 +348,9 @@ ViewportConfiguration::Parameters ViewportConfiguration::nativeWebpageParameters
return parameters;
}

ViewportConfiguration::Parameters ViewportConfiguration::scalableNativeWebpageParameters()
ViewportConfiguration::Parameters ViewportConfiguration::nativeWebpageParametersWithShrinkToFit()
{
Parameters parameters = ViewportConfiguration::nativeWebpageParameters();
Parameters parameters = ViewportConfiguration::nativeWebpageParametersWithoutShrinkToFit();
parameters.allowsShrinkToFit = true;
parameters.minimumScale = 0.25;
return parameters;
@@ -102,8 +102,9 @@ class ViewportConfiguration {
bool avoidsUnsafeArea() const { return m_configuration.avoidsUnsafeArea; }

// Matches a width=device-width, initial-scale=1 viewport.
WEBCORE_EXPORT static Parameters nativeWebpageParameters();
static Parameters scalableNativeWebpageParameters();
WEBCORE_EXPORT Parameters nativeWebpageParameters();
static Parameters nativeWebpageParametersWithoutShrinkToFit();
static Parameters nativeWebpageParametersWithShrinkToFit();
WEBCORE_EXPORT static Parameters webpageParameters();
WEBCORE_EXPORT static Parameters textDocumentParameters();
WEBCORE_EXPORT static Parameters imageDocumentParameters();
@@ -1,3 +1,19 @@
2019-02-25 Yongjun Zhang <yongjun_zhang@apple.com>

scalableNativeWebpageParameters() is not preserved on new page navigation.
https://bugs.webkit.org/show_bug.cgi?id=194892
<rdar://problem/47538280>

If a page's current default viewport configuration is scalableNativeWebpageParameters due to
the fact that m_canIgnoreScalingConstraints is true, loading a new page should preserve this
configuration until we derive the right values from viewport meta-tag.

Reviewed by Wenson Hsieh.

* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::resetViewportDefaultConfiguration): Use nativeWebpageParameters() instance method to
get the appropriate default configuration.

2019-02-25 Wenson Hsieh <wenson_hsieh@apple.com>

[iOS] Adjust initial scale zooming heuristics when changing view scale
@@ -2906,7 +2906,7 @@ static inline bool areEssentiallyEqualAsFloat(float a, float b)

auto parametersForStandardFrame = [&] {
if (m_page->settings().shouldIgnoreMetaViewport())
return ViewportConfiguration::nativeWebpageParameters();
return m_viewportConfiguration.nativeWebpageParameters();

return ViewportConfiguration::webpageParameters();
};
@@ -1,3 +1,24 @@
2019-02-25 Yongjun Zhang <yongjun_zhang@apple.com>

scalableNativeWebpageParameters() is not preserved on new page navigation.
https://bugs.webkit.org/show_bug.cgi?id=194892
<rdar://problem/47538280>

Reviewed by Wenson Hsieh.

Allow UIScriptController to set WKWebView's _allowsViewportShrinkToFit property with a new `setAllowsViewportShrinkToFit` method.

* DumpRenderTree/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptController::setAllowsViewportShrinkToFit):
* DumpRenderTree/mac/UIScriptControllerMac.mm:
(WTR::UIScriptController::allowsViewportShrinkToFit):
* TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
* TestRunnerShared/UIScriptContext/UIScriptController.cpp:
(WTR::UIScriptController::setAllowsViewportShrinkToFit):
* TestRunnerShared/UIScriptContext/UIScriptController.h:
* WebKitTestRunner/UIScriptControllerCocoa.mm:
(WTR::UIScriptController::setAllowsViewportShrinkToFit):

2019-02-25 Aakash Jain <aakash_jain@apple.com>

[ews-app] Add model for handling multiple Buildbot instances
@@ -94,6 +94,10 @@
{
}

void UIScriptController::setAllowsViewportShrinkToFit(bool)
{
}

void UIScriptController::simulateAccessibilitySettingsChangeNotification(JSValueRef)
{
}
@@ -101,6 +101,10 @@
{
}

void UIScriptController::setAllowsViewportShrinkToFit(bool)
{
}

void UIScriptController::simulateAccessibilitySettingsChangeNotification(JSValueRef)
{
}
@@ -236,6 +236,7 @@ interface UIScriptController {

void setViewScale(double scale);
void setMinimumEffectiveWidth(double effectiveWidth);
void setAllowsViewportShrinkToFit(boolean allows);

void resignFirstResponder();
readonly attribute boolean isPresentingModally;
@@ -241,6 +241,10 @@ void UIScriptController::setMinimumEffectiveWidth(double)
{
}

void UIScriptController::setAllowsViewportShrinkToFit(bool)
{
}

void UIScriptController::resignFirstResponder()
{
}
@@ -72,6 +72,7 @@ class UIScriptController : public JSWrappable {
void zoomToScale(double scale, JSValueRef callback);
void setViewScale(double);
void setMinimumEffectiveWidth(double);
void setAllowsViewportShrinkToFit(bool);

void resignFirstResponder();

@@ -54,6 +54,15 @@
#endif
}

void UIScriptController::setAllowsViewportShrinkToFit(bool allows)
{
#if WK_API_ENABLED && PLATFORM(IOS_FAMILY)
TestController::singleton().mainWebView()->platformView()._allowsViewportShrinkToFit = allows;
#else
UNUSED_PARAM(allows);
#endif
}

void UIScriptController::resignFirstResponder()
{
#if WK_API_ENABLED

0 comments on commit 4d6c96e

Please sign in to comment.