https://bugs.webkit.org/show_bug.cgi?id=188772.
<rdar://problem/
43538892>.
Patch by James Savage <james.savage@apple.com> on 2018-09-26
Reviewed by Simon Fraser.
Source/WebCore:
* page/Settings.yaml:
* page/ViewportConfiguration.cpp:
(WebCore::ViewportConfiguration::nativeWebpageParameters): Provide a viewport configuration
similar to width=device-width, with initial scale set to 1.
* page/ViewportConfiguration.h:
Source/WebKit:
* Shared/WebPreferences.yaml:
* UIProcess/API/Cocoa/WKPreferences.mm:
(-[WKPreferences _setShouldIgnoreMetaViewport:]):
(-[WKPreferences _shouldIgnoreMetaViewport]):
* UIProcess/API/Cocoa/WKPreferencesPrivate.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::viewportPropertiesDidChange): If we are ignoring the
<meta> viewport, short circuit calling setViewportArguments() and do not
do any updates.
(WebKit::WebPage::didCommitLoad): Ditto.
* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::resetViewportDefaultConfiguration): Select the default
configuration based on UIProcess setting.
Tools:
* WebKitTestRunner/TestController.cpp:
(WTR::updateTestOptionsFromTestHeader): Parse new test option key from comments.
* WebKitTestRunner/TestOptions.h:
* WebKitTestRunner/ios/TestControllerIOS.mm:
(WTR::TestController::platformConfigureViewForTest): Handle new test option by
modifying the web view's preferences accordingly.
LayoutTests:
Add test proving that a document without a meta viewport specifying
width=device-width still gets a layout when this setting is enabled. I also
added a baseline case to prove that without this setting we do not layout
at device width.
* fast/viewport/ios/ipad/empty-viewport-expected.txt: Added.
* fast/viewport/ios/ipad/empty-viewport.html: Added.
* fast/viewport/ios/ipad/meta-viewport-disabled-expected.txt: Added.
* fast/viewport/ios/ipad/meta-viewport-disabled.html: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236530
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2018-09-26 James Savage <james.savage@apple.com>
+
+ Allow override of viewport configuration.
+ https://bugs.webkit.org/show_bug.cgi?id=188772.
+ <rdar://problem/43538892>.
+
+ Reviewed by Simon Fraser.
+
+ Add test proving that a document without a meta viewport specifying
+ width=device-width still gets a layout when this setting is enabled. I also
+ added a baseline case to prove that without this setting we do not layout
+ at device width.
+
+ * fast/viewport/ios/ipad/empty-viewport-expected.txt: Added.
+ * fast/viewport/ios/ipad/empty-viewport.html: Added.
+ * fast/viewport/ios/ipad/meta-viewport-disabled-expected.txt: Added.
+ * fast/viewport/ios/ipad/meta-viewport-disabled.html: Added.
+
2018-09-26 Alex Christensen <achristensen@webkit.org>
uidna_nameToASCII only needs a buffer capacity of 64
--- /dev/null
+Viewport:
+
+scale 0.78376
+maxScale 5.00000
+minScale 0.78376
+visibleRect {"left":"0.00000","top":"0.00000","width":"979.88843","height":"1281.00000"}
--- /dev/null
+<!DOCTYPE html>
+
+<html>
+<head>
+ <script src="../resources/viewport-test-utils.js"></script>
+</head>
+<body onload="runTest()">
+
+<p>Viewport: <span id="viewport"></span></p>
+<div id="result"></div>
+
+</body>
+</html>
--- /dev/null
+Viewport:
+
+scale 1.00000
+maxScale 5.00000
+minScale 1.00000
+visibleRect {"left":"0.00000","top":"0.00000","width":"768.00000","height":"1004.00000"}
--- /dev/null
+<!DOCTYPE html> <!-- webkit-test-runner [ shouldIgnoreMetaViewport=true ] -->
+
+<html>
+<head>
+ <script src="../resources/viewport-test-utils.js"></script>
+</head>
+<body onload="runTest()">
+
+<p>Viewport: <span id="viewport"></span></p>
+<div id="result"></div>
+
+</body>
+</html>
function getViewport()
{
- var metaTag = document.head.querySelectorAll('meta')[0];
+ var metaTags = document.head.querySelectorAll('meta');
+ if (!metaTags.length)
+ return;
+
+ var metaTag = metaTags[0];
document.getElementById('viewport').textContent = metaTag.getAttribute('content');
}
+2018-09-26 James Savage <james.savage@apple.com>
+
+ Allow override of viewport configuration.
+ https://bugs.webkit.org/show_bug.cgi?id=188772.
+ <rdar://problem/43538892>.
+
+ Reviewed by Simon Fraser.
+
+ * page/Settings.yaml:
+ * page/ViewportConfiguration.cpp:
+ (WebCore::ViewportConfiguration::nativeWebpageParameters): Provide a viewport configuration
+ similar to width=device-width, with initial scale set to 1.
+ * page/ViewportConfiguration.h:
+
2018-09-26 Alex Christensen <achristensen@webkit.org>
URLs with mismatched surrogate pairs in the host should fail to parse
shouldDeferAsynchronousScriptsUntilAfterDocumentLoad:
initial: false
+
+shouldIgnoreMetaViewport:
+ initial: false
return shouldIgnoreScalingConstraints() || m_configuration.allowsUserScaling;
}
+ViewportConfiguration::Parameters ViewportConfiguration::nativeWebpageParameters()
+{
+ Parameters parameters;
+ parameters.width = ViewportArguments::ValueDeviceWidth;
+ parameters.widthIsSet = true;
+ parameters.allowsUserScaling = true;
+ parameters.allowsShrinkToFit = false;
+ parameters.minimumScale = 1;
+ parameters.maximumScale = 5;
+ parameters.initialScale = 1;
+ parameters.initialScaleIsSet = true;
+ return parameters;
+}
+
ViewportConfiguration::Parameters ViewportConfiguration::webpageParameters()
{
Parameters parameters;
bool allowsShrinkToFit() const;
bool avoidsUnsafeArea() const { return m_configuration.avoidsUnsafeArea; }
+ // Matches a width=device-width, initial-scale=1 viewport.
+ WEBCORE_EXPORT static Parameters nativeWebpageParameters();
WEBCORE_EXPORT static Parameters webpageParameters();
WEBCORE_EXPORT static Parameters textDocumentParameters();
WEBCORE_EXPORT static Parameters imageDocumentParameters();
+2018-09-26 James Savage <james.savage@apple.com>
+
+ Allow override of viewport configuration.
+ https://bugs.webkit.org/show_bug.cgi?id=188772.
+ <rdar://problem/43538892>.
+
+ Reviewed by Simon Fraser.
+
+ * Shared/WebPreferences.yaml:
+ * UIProcess/API/Cocoa/WKPreferences.mm:
+ (-[WKPreferences _setShouldIgnoreMetaViewport:]):
+ (-[WKPreferences _shouldIgnoreMetaViewport]):
+ * UIProcess/API/Cocoa/WKPreferencesPrivate.h:
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::viewportPropertiesDidChange): If we are ignoring the
+ <meta> viewport, short circuit calling setViewportArguments() and do not
+ do any updates.
+ (WebKit::WebPage::didCommitLoad): Ditto.
+ * WebProcess/WebPage/ios/WebPageIOS.mm:
+ (WebKit::WebPage::resetViewportDefaultConfiguration): Select the default
+ configuration based on UIProcess setting.
+
2018-09-26 Chris Dumez <cdumez@apple.com>
Regression(r236512): WKWebViewCandidateTests.SoftSpaceReplacementAfterCandidateInsertionWithoutReplacement API test is failing
defaultValue: defaultPassiveTouchListenersAsDefaultOnDocument()
webcoreName: passiveTouchListenersAsDefaultOnDocument
+ShouldIgnoreMetaViewport:
+ type: bool
+ defaultValue: false
+
# Debug Preferences
AcceleratedDrawingEnabled:
return _preferences->lowPowerVideoAudioBufferSizeEnabled();
}
+- (void)_setShouldIgnoreMetaViewport:(BOOL)ignoreMetaViewport
+{
+ return _preferences->setShouldIgnoreMetaViewport(ignoreMetaViewport);
+}
+
+- (BOOL)_shouldIgnoreMetaViewport
+{
+ return _preferences->shouldIgnoreMetaViewport();
+}
+
#if PLATFORM(MAC)
- (void)_setJavaEnabledForLocalFiles:(BOOL)enabled
{
@property (nonatomic, setter=_setColorFilterEnabled:) BOOL _colorFilterEnabled WK_API_AVAILABLE(macosx(10.14), ios(12.0));
@property (nonatomic, setter=_setPunchOutWhiteBackgroundsInDarkMode:) BOOL _punchOutWhiteBackgroundsInDarkMode WK_API_AVAILABLE(macosx(10.14), ios(12.0));
@property (nonatomic, setter=_setLowPowerVideoAudioBufferSizeEnabled:) BOOL _lowPowerVideoAudioBufferSizeEnabled WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+@property (nonatomic, setter=_setShouldIgnoreMetaViewport:) BOOL _shouldIgnoreMetaViewport WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
#if !TARGET_OS_IPHONE
@property (nonatomic, setter=_setWebGLEnabled:) BOOL _webGLEnabled WK_API_AVAILABLE(macosx(10.13.4));
void WebPage::viewportPropertiesDidChange(const ViewportArguments& viewportArguments)
{
#if PLATFORM(IOS)
- if (m_viewportConfiguration.setViewportArguments(viewportArguments))
+ if (!m_page->settings().shouldIgnoreMetaViewport() && m_viewportConfiguration.setViewportArguments(viewportArguments))
viewportConfigurationChanged();
#endif
if (m_viewportConfiguration.setContentsSize(coreFrame->view()->contentsSize()))
viewportChanged = true;
- if (m_viewportConfiguration.setViewportArguments(coreFrame->document()->viewportArguments()))
+ if (!m_page->settings().shouldIgnoreMetaViewport() && m_viewportConfiguration.setViewportArguments(coreFrame->document()->viewportArguments()))
viewportChanged = true;
if (viewportChanged)
return;
}
+ auto parametersForStandardFrame = [&] {
+ if (m_page->settings().shouldIgnoreMetaViewport())
+ return ViewportConfiguration::nativeWebpageParameters();
+
+ return ViewportConfiguration::webpageParameters();
+ };
+
if (!frame) {
- m_viewportConfiguration.setDefaultConfiguration(ViewportConfiguration::webpageParameters());
+ m_viewportConfiguration.setDefaultConfiguration(parametersForStandardFrame());
return;
}
else if (document->isTextDocument())
m_viewportConfiguration.setDefaultConfiguration(ViewportConfiguration::textDocumentParameters());
else
- m_viewportConfiguration.setDefaultConfiguration(ViewportConfiguration::webpageParameters());
+ m_viewportConfiguration.setDefaultConfiguration(parametersForStandardFrame());
}
void WebPage::viewportConfigurationChanged()
+2018-09-26 James Savage <james.savage@apple.com>
+
+ Allow override of viewport configuration.
+ https://bugs.webkit.org/show_bug.cgi?id=188772.
+ <rdar://problem/43538892>.
+
+ Reviewed by Simon Fraser.
+
+ * WebKitTestRunner/TestController.cpp:
+ (WTR::updateTestOptionsFromTestHeader): Parse new test option key from comments.
+ * WebKitTestRunner/TestOptions.h:
+ * WebKitTestRunner/ios/TestControllerIOS.mm:
+ (WTR::TestController::platformConfigureViewForTest): Handle new test option by
+ modifying the web view's preferences accordingly.
+
2018-09-26 Alex Christensen <achristensen@webkit.org>
URLs with mismatched surrogate pairs in the host should fail to parse
testOptions.jscOptions = value;
else if (key == "runSingly")
testOptions.runSingly = parseBooleanTestHeaderValue(value);
+ else if (key == "shouldIgnoreMetaViewport")
+ testOptions.shouldIgnoreMetaViewport = parseBooleanTestHeaderValue(value);
pairStart = pairEnd + 1;
}
}
bool punchOutWhiteBackgroundsInDarkMode { false };
bool runSingly { false };
bool checkForWorldLeaks { false };
+ bool shouldIgnoreMetaViewport { false };
float deviceScaleFactor { 1 };
Vector<String> overrideLanguages;
#import "UIKitTestSPI.h"
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
+#import <WebKit/WKPreferencesPrivate.h>
#import <WebKit/WKPreferencesRefPrivate.h>
#import <WebKit/WKProcessPoolPrivate.h>
#import <WebKit/WKStringCF.h>
return;
TestRunnerWKWebView *webView = mainWebView()->platformView();
+
+ if (test.options().shouldIgnoreMetaViewport)
+ webView.configuration.preferences._shouldIgnoreMetaViewport = YES;
+
CGRect screenBounds = [UIScreen mainScreen].bounds;
-
CGSize oldSize = webView.bounds.size;
mainWebView()->resizeTo(screenBounds.size.width, screenBounds.size.height, PlatformWebView::WebViewSizingMode::HeightRespectsStatusBar);
CGSize newSize = webView.bounds.size;