Skip to content

Commit d672856

Browse files
Expose viewport-fit instead of clip-to-safe-area
https://bugs.webkit.org/show_bug.cgi?id=171503 <rdar://problem/31918249> Reviewed by Simon Fraser. Tests: fast/viewport/ios/viewport-fit-auto.html fast/viewport/ios/viewport-fit-contain.html fast/viewport/ios/viewport-fit-cover.html * dom/ConstantPropertyMap.cpp: (WebCore::ConstantPropertyMap::buildValues): (WebCore::ConstantPropertyMap::updateConstantsForUnobscuredSafeAreaInsets): (WebCore::ConstantPropertyMap::didChangeSafeAreaInsets): (WebCore::ConstantPropertyMap::updateConstantsForObscuredInsets): Deleted. (WebCore::ConstantPropertyMap::didChangeObscuredInsets): Deleted. * dom/ConstantPropertyMap.h: Retrieve the safe area insets from page, instead of assuming that we should just expose the entire obscured inset. Also, do some renames. * dom/ViewportArguments.cpp: (WebCore::ViewportArguments::resolve): (WebCore::parseViewportFitValue): (WebCore::setViewportFeature): * dom/ViewportArguments.h: (WebCore::ViewportArguments::operator==): * page/ChromeClient.h: * page/FrameView.cpp: (WebCore::FrameView::enableSpeculativeTilingIfNeeded): (WebCore::FrameView::calculateExtendedBackgroundMode): (WebCore::FrameView::setClipToSafeArea): Deleted. * page/FrameView.h: * page/ViewportConfiguration.cpp: (WebCore::ViewportConfiguration::updateConfiguration): (WebCore::operator<<): (WebCore::ViewportConfiguration::description): (WebCore::ViewportConfiguration::dump): * page/ViewportConfiguration.h: (WebCore::ViewportConfiguration::avoidsUnsafeArea): (WebCore::ViewportConfiguration::Parameters::Parameters): (WebCore::ViewportConfiguration::clipToSafeArea): Deleted. * rendering/RenderLayerCompositor.cpp: (WebCore::RenderLayerCompositor::updateRootContentLayerClipping): * rendering/RenderObject.cpp: (WebCore::RenderObject::repaintUsingContainer): Un-do changes to support clip-to-safe-area, and instead implement a new viewport-fit argument in the viewport meta tag, which takes "auto", "contain", and "cover". "auto" and "contain" cause web content to lay out excluding the safe area inset from the layout size, while "cover" causes web content to expand into the unsafe area. * page/Page.cpp: (WebCore::Page::setUnobscuredSafeAreaInsets): (WebCore::Page::setObscuredInsets): Deleted. * page/Page.h: (WebCore::Page::setObscuredInsets): (WebCore::Page::unobscuredSafeAreaInsets): Keep safe area and obscured insets separately. * Shared/VisibleContentRectUpdateInfo.cpp: (WebKit::VisibleContentRectUpdateInfo::encode): (WebKit::VisibleContentRectUpdateInfo::decode): (WebKit::operator<<): * Shared/VisibleContentRectUpdateInfo.h: (WebKit::VisibleContentRectUpdateInfo::VisibleContentRectUpdateInfo): (WebKit::VisibleContentRectUpdateInfo::unobscuredSafeAreaInsets): (WebKit::operator==): Plumb the safe area insets down from the UI process to the Web Content process inside the visible content rect update, alongside the obscured insets. * Shared/mac/RemoteLayerTreeTransaction.h: (WebKit::RemoteLayerTreeTransaction::avoidsUnsafeArea): (WebKit::RemoteLayerTreeTransaction::setAvoidsUnsafeArea): * Shared/mac/RemoteLayerTreeTransaction.mm: (WebKit::RemoteLayerTreeTransaction::encode): (WebKit::RemoteLayerTreeTransaction::decode): (WebKit::RemoteLayerTreeTransaction::description): * UIProcess/PageClient.h: * UIProcess/ios/PageClientImplIOS.h: * UIProcess/ios/PageClientImplIOS.mm: (WebKit::PageClientImpl::didChangeAvoidsUnsafeArea): (WebKit::PageClientImpl::didChangeClipToSafeArea): Deleted. * UIProcess/ios/WebPageProxyIOS.mm: (WebKit::WebPageProxy::didCommitLayerTree): * UIProcess/mac/PageClientImpl.h: * WebProcess/WebCoreSupport/WebChromeClient.cpp: (WebKit::WebChromeClient::didChangeClipToSafeArea): Deleted. * WebProcess/WebCoreSupport/WebChromeClient.h: * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::willCommitLayerTree): * WebProcess/WebPage/ios/WebPageIOS.mm: (WebKit::WebPage::viewportConfigurationChanged): (WebKit::WebPage::updateVisibleContentRects): * UIProcess/WebPageProxy.cpp: (WebKit::WebPageProxy::resetState): (WebKit::WebPageProxy::setAvoidsUnsafeArea): (WebKit::WebPageProxy::setClipToSafeArea): Deleted. * UIProcess/WebPageProxy.h: (WebKit::WebPageProxy::avoidsUnsafeArea): (WebKit::WebPageProxy::clipToSafeArea): Deleted. * UIProcess/WebPageProxy.messages.in: Plumb the effective value of viewport-fit (whether or not to avoid the safe area for layout purposes) from the Web Content process to the UI process inside the layer tree transaction. Also, remove clip-to-safe-area plumbing. * UIProcess/API/Cocoa/WKWebView.mm: (-[WKWebView _initializeWithConfiguration:]): (-[WKWebView _computedContentInset]): (-[WKWebView _computedUnobscuredSafeAreaInset]): (-[WKWebView _updateVisibleContentRects]): (-[WKWebView _updateScrollViewInsetAdjustmentBehavior]): (-[WKWebView _safeAreaShouldAffectObscuredInsets]): (-[WKWebView _unobscuredSafeAreaInsets]): (-[WKWebView _setUnobscuredSafeAreaInsets:]): (-[WKWebView _contentMayDrawInObscuredInsets]): Deleted. * UIProcess/API/Cocoa/WKWebViewInternal.h: * UIProcess/API/Cocoa/WKWebViewPrivate.h: Make use of the effective value of viewport-fit to decide whether to take the safe area into account when computing the obscured insets, and expose this to clients (in the case that they need to know because they push their own obscured insets down). Also expose a safe area inset setter for that case as well. * UIProcess/ios/WKContentView.h: * UIProcess/ios/WKContentView.mm: (-[WKContentView updateFixedClippingView:]): (-[WKContentView didUpdateVisibleRect:unobscuredRect:unobscuredRectInScrollViewCoordinates:obscuredInsets:unobscuredSafeAreaInsets:inputViewBounds:scale:minimumScale:inStableState:isChangingObscuredInsetsInteractively:enclosedInScrollableAncestorView:]): Remove a piece of the clip-to-safe-area implementation, and plumb safe area insets into the visible content rect update info. * UIProcess/ios/WKScrollView.h: * UIProcess/ios/WKScrollView.mm: (-[WKScrollView initWithFrame:]): (-[WKScrollView _contentInsetAdjustmentBehaviorWasExternallyOverridden]): (-[WKScrollView _setContentInsetAdjustmentBehavior:]): (-[WKScrollView _setContentInsetAdjustmentBehaviorInternal:]): Keep track of whether the client has ever touched the content inset adjustment behavior; if they have, we won't manage it ourselves. * DumpRenderTree/ios/UIScriptControllerIOS.mm: (WTR::UIScriptController::setSafeAreaInsets): (WTR::UIScriptController::setObscuredInsets): Deleted. * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl: * TestRunnerShared/UIScriptContext/UIScriptController.cpp: (WTR::UIScriptController::setSafeAreaInsets): (WTR::UIScriptController::setObscuredInsets): Deleted. * TestRunnerShared/UIScriptContext/UIScriptController.h: * WebKitTestRunner/cocoa/TestRunnerWKWebView.h: * WebKitTestRunner/cocoa/TestRunnerWKWebView.mm: (-[TestRunnerWKWebView setOverrideSafeAreaInsets:]): (-[TestRunnerWKWebView _safeAreaInsetsForFrame:inSuperview:]): * WebKitTestRunner/ios/TestControllerIOS.mm: (WTR::TestController::platformResetStateToConsistentValues): * WebKitTestRunner/ios/UIKitSPI.h: * WebKitTestRunner/ios/UIScriptControllerIOS.mm: (WTR::UIScriptController::setSafeAreaInsets): (WTR::UIScriptController::setObscuredInsets): Deleted. Expose a safe area inset setter instead of obscured insets. * TestExpectations: * fast/css/variables/constants/ios/safe-area-inset-set-expected.html: * fast/css/variables/constants/ios/safe-area-inset-set.html: * fast/viewport/ios/viewport-fit-auto-expected.txt: Added. * fast/viewport/ios/viewport-fit-auto.html: Added. * fast/viewport/ios/viewport-fit-contain-expected.txt: Added. * fast/viewport/ios/viewport-fit-contain.html: Added. * fast/viewport/ios/viewport-fit-cover-expected.txt: Added. * fast/viewport/ios/viewport-fit-cover.html: Added. * tiled-drawing/ios/viewport-clip-to-safe-area-no-gets-margin-tiles-expected.txt: Removed. * tiled-drawing/ios/viewport-clip-to-safe-area-no-gets-margin-tiles.html: Removed. * tiled-drawing/ios/viewport-clip-to-safe-area-yes-gets-no-margin-tiles-expected.txt: Removed. * tiled-drawing/ios/viewport-clip-to-safe-area-yes-gets-no-margin-tiles.html: Removed. Remove clip-to-safe-area tests and add some viewport-fit tests. Also, adjust safe-area-inset-set to use the new UIScriptController setSafeAreaInset method. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@216047 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 2f9efd2 commit d672856

File tree

63 files changed

+649
-340
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+649
-340
lines changed

LayoutTests/ChangeLog

+24
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
2017-05-01 Timothy Horton <[email protected]>
2+
3+
Expose viewport-fit instead of clip-to-safe-area
4+
https://bugs.webkit.org/show_bug.cgi?id=171503
5+
<rdar://problem/31918249>
6+
7+
Reviewed by Simon Fraser.
8+
9+
* TestExpectations:
10+
* fast/css/variables/constants/ios/safe-area-inset-set-expected.html:
11+
* fast/css/variables/constants/ios/safe-area-inset-set.html:
12+
* fast/viewport/ios/viewport-fit-auto-expected.txt: Added.
13+
* fast/viewport/ios/viewport-fit-auto.html: Added.
14+
* fast/viewport/ios/viewport-fit-contain-expected.txt: Added.
15+
* fast/viewport/ios/viewport-fit-contain.html: Added.
16+
* fast/viewport/ios/viewport-fit-cover-expected.txt: Added.
17+
* fast/viewport/ios/viewport-fit-cover.html: Added.
18+
* tiled-drawing/ios/viewport-clip-to-safe-area-no-gets-margin-tiles-expected.txt: Removed.
19+
* tiled-drawing/ios/viewport-clip-to-safe-area-no-gets-margin-tiles.html: Removed.
20+
* tiled-drawing/ios/viewport-clip-to-safe-area-yes-gets-no-margin-tiles-expected.txt: Removed.
21+
* tiled-drawing/ios/viewport-clip-to-safe-area-yes-gets-no-margin-tiles.html: Removed.
22+
Remove clip-to-safe-area tests and add some viewport-fit tests. Also, adjust
23+
safe-area-inset-set to use the new UIScriptController setSafeAreaInset method.
24+
125
2017-05-01 Chris Dumez <[email protected]>
226

327
Documents created using DOMParser.parseFromString should inherit their context document's origin / URL
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
1-
<style>
2-
#a {
3-
position: absolute;
4-
left: 100px;
5-
top: 200px;
6-
width: 100px;
7-
height: 100px;
8-
background-color: green;
9-
}
1+
<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
2+
<head>
3+
<meta name="viewport" content="initial-scale=1, viewport-fit=cover">
4+
<style>
5+
#a {
6+
position: absolute;
7+
left: 25px;
8+
top: 50px;
9+
width: 100px;
10+
height: 100px;
11+
background-color: green;
12+
}
1013

11-
#b {
12-
position: absolute;
13-
left: 300px;
14-
top: 250px;
15-
width: 100px;
16-
height: 100px;
17-
background-color: blue;
18-
}
19-
</style>
14+
#b {
15+
position: absolute;
16+
left: 75px;
17+
top: 100px;
18+
width: 100px;
19+
height: 100px;
20+
background-color: blue;
21+
}
22+
</style>
23+
</head>
2024
<body>
21-
<div id="a"></div>
22-
<div id="b"></div>
23-
<p>The boxes should be at 100, 200 and 300, 250.</p>
24-
25+
<div id="a"></div>
26+
<div id="b"></div>
27+
<p>The boxes should be at 25, 50 and 75, 100.</p>
28+
</body>
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,50 @@
1-
<style>
2-
#a {
3-
position: absolute;
4-
left: constant(safe-area-inset-right);
5-
top: constant(safe-area-inset-top);
6-
width: 100px;
7-
height: 100px;
8-
background-color: green;
9-
}
1+
<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
2+
<head>
3+
<meta name="viewport" content="initial-scale=1, viewport-fit=cover">
4+
<style>
5+
#a {
6+
position: absolute;
7+
left: constant(safe-area-inset-right);
8+
top: constant(safe-area-inset-top);
9+
width: 100px;
10+
height: 100px;
11+
background-color: green;
12+
}
1013

11-
#b {
12-
position: absolute;
13-
left: constant(safe-area-inset-bottom);
14-
top: constant(safe-area-inset-left);
15-
width: 100px;
16-
height: 100px;
17-
background-color: blue;
18-
}
19-
</style>
20-
<script>
21-
function getUIScript()
22-
{
23-
return `
24-
(function() {
25-
uiController.setObscuredInsets(200, 100, 300, 250);
26-
uiController.doAfterVisibleContentRectUpdate(function () {
27-
uiController.uiScriptComplete();
28-
});
29-
})();`
30-
}
14+
#b {
15+
position: absolute;
16+
left: constant(safe-area-inset-bottom);
17+
top: constant(safe-area-inset-left);
18+
width: 100px;
19+
height: 100px;
20+
background-color: blue;
21+
}
22+
</style>
23+
<script>
24+
function getUIScript()
25+
{
26+
return `
27+
(function() {
28+
uiController.setSafeAreaInsets(50, 25, 75, 100);
29+
uiController.doAfterVisibleContentRectUpdate(function () {
30+
uiController.uiScriptComplete();
31+
});
32+
})();`
33+
}
3134

32-
if (window.testRunner) {
33-
testRunner.waitUntilDone();
34-
testRunner.runUIScript(getUIScript(), function(result) {
35-
testRunner.notifyDone();
36-
});
37-
}
38-
</script>
35+
if (window.testRunner) {
36+
testRunner.waitUntilDone();
37+
window.onload = function () {
38+
testRunner.runUIScript(getUIScript(), function(result) {
39+
testRunner.notifyDone();
40+
});
41+
}
42+
}
43+
</script>
44+
</head>
3945
<body>
40-
<div id="a"></div>
41-
<div id="b"></div>
42-
<p>The boxes should be at 100, 200 and 300, 250.</p>
46+
<div id="a"></div>
47+
<div id="b"></div>
48+
<p>The boxes should be at 25, 50 and 75, 100.</p>
49+
</body>
4350

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Viewport: initial-scale=1, viewport-fit=auto
2+
3+
Window Size: 260 x 508
4+
5+
scale 1.00000
6+
maxScale 5.00000
7+
minScale 1.00000
8+
visibleRect {"left":"-40.00000","top":"-10.00000","width":"320.00000","height":"548.00000"}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
2+
3+
<html>
4+
<head>
5+
<meta name="viewport" content="initial-scale=1, viewport-fit=auto">
6+
<script src="resources/viewport-test-utils.js"></script>
7+
<script>
8+
function getSafeAreaUIScript()
9+
{
10+
return `
11+
(function() {
12+
uiController.setSafeAreaInsets(10, 20, 30, 40);
13+
uiController.doAfterVisibleContentRectUpdate(function () {
14+
uiController.uiScriptComplete();
15+
})
16+
})();`
17+
}
18+
19+
function doTest()
20+
{
21+
testRunner.runUIScript(getSafeAreaUIScript(), function(result) {
22+
document.getElementById('windowSize').textContent = window.innerWidth + " x " + window.innerHeight;
23+
runTest();
24+
});
25+
}
26+
window.addEventListener('load', doTest, false);
27+
</script>
28+
</head>
29+
30+
<body>
31+
<p>Viewport: <span id="viewport"></span></p>
32+
<p>Window Size: <span id="windowSize"></span></p>
33+
<div id="result"></div>
34+
</body>
35+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Viewport: initial-scale=1, viewport-fit=contain
2+
3+
Window Size: 260 x 508
4+
5+
scale 1.00000
6+
maxScale 5.00000
7+
minScale 1.00000
8+
visibleRect {"left":"-40.00000","top":"-10.00000","width":"320.00000","height":"548.00000"}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
2+
3+
<html>
4+
<head>
5+
<meta name="viewport" content="initial-scale=1, viewport-fit=contain">
6+
<script src="resources/viewport-test-utils.js"></script>
7+
<script>
8+
function getSafeAreaUIScript()
9+
{
10+
return `
11+
(function() {
12+
uiController.setSafeAreaInsets(10, 20, 30, 40);
13+
uiController.doAfterVisibleContentRectUpdate(function () {
14+
uiController.uiScriptComplete();
15+
})
16+
})();`
17+
}
18+
19+
function doTest()
20+
{
21+
testRunner.runUIScript(getSafeAreaUIScript(), function(result) {
22+
document.getElementById('windowSize').textContent = window.innerWidth + " x " + window.innerHeight;
23+
runTest();
24+
});
25+
}
26+
window.addEventListener('load', doTest, false);
27+
</script>
28+
</head>
29+
30+
<body>
31+
<p>Viewport: <span id="viewport"></span></p>
32+
<p>Window Size: <span id="windowSize"></span></p>
33+
<div id="result"></div>
34+
</body>
35+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Viewport: initial-scale=1, viewport-fit=cover
2+
3+
Window Size: 320 x 548
4+
5+
scale 1.00000
6+
maxScale 5.00000
7+
minScale 1.00000
8+
visibleRect {"left":"0.00000","top":"0.00000","width":"320.00000","height":"548.00000"}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
2+
3+
<html>
4+
<head>
5+
<meta name="viewport" content="initial-scale=1, viewport-fit=cover">
6+
<script src="resources/viewport-test-utils.js"></script>
7+
<script>
8+
function getSafeAreaUIScript()
9+
{
10+
return `
11+
(function() {
12+
uiController.setSafeAreaInsets(10, 20, 30, 40);
13+
uiController.doAfterVisibleContentRectUpdate(function () {
14+
uiController.uiScriptComplete();
15+
})
16+
})();`
17+
}
18+
19+
function doTest()
20+
{
21+
testRunner.runUIScript(getSafeAreaUIScript(), function(result) {
22+
document.getElementById('windowSize').textContent = window.innerWidth + " x " + window.innerHeight;
23+
runTest();
24+
});
25+
}
26+
window.addEventListener('load', doTest, false);
27+
</script>
28+
</head>
29+
30+
<body>
31+
<p>Viewport: <span id="viewport"></span></p>
32+
<p>Window Size: <span id="windowSize"></span></p>
33+
<div id="result"></div>
34+
</body>
35+
</html>

LayoutTests/platform/ios-wk2/TestExpectations

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ fast/visual-viewport/ios/ [ Pass ]
1414
scrollingcoordinator/ios [ Pass ]
1515
tiled-drawing/ios [ Pass ]
1616
editing/selection/character-granularity-rect.html [ Pass ]
17-
fast/css/variables/constants/ios [ Pass ]
1817

1918
fast/media/mq-inverted-colors-live-update.html [ Pass ]
2019
fast/media/mq-inverted-colors-live-update-in-subframes.html [ Pass ]
@@ -24,6 +23,11 @@ fast/media/mq-prefers-reduced-motion-live-update.html [ Pass ]
2423
fast/visual-viewport/rubberbanding-viewport-rects.html [ Pass ]
2524
fast/visual-viewport/rubberbanding-viewport-rects-header-footer.html [ Pass ]
2625

26+
# Pending SDK changes, re-skip these tests that are un-skipped above.
27+
fast/viewport/ios/viewport-fit-contain.html [ Skip ]
28+
fast/viewport/ios/viewport-fit-cover.html [ Skip ]
29+
fast/viewport/ios/viewport-fit-auto.html [ Skip ]
30+
2731
#//////////////////////////////////////////////////////////////////////////////////////////
2832
# End platform-specific directories.
2933
#//////////////////////////////////////////////////////////////////////////////////////////

LayoutTests/tiled-drawing/ios/viewport-clip-to-safe-area-no-gets-margin-tiles-expected.txt

-23
This file was deleted.

LayoutTests/tiled-drawing/ios/viewport-clip-to-safe-area-no-gets-margin-tiles.html

-43
This file was deleted.

0 commit comments

Comments
 (0)