- Revision
- 266290
- Author
- [email protected]
- Date
- 2020-08-28 13:21:18 -0700 (Fri, 28 Aug 2020)
Log Message
[iOS] Vertical text's logical width calculation is stale from the previous height of the WKWebView
https://bugs.webkit.org/show_bug.cgi?id=215910
Reviewed by Simon Fraser.
Source/WebCore:
When there is vertical text (really: orthogonal flows) in the content, the available width of the vertical
text is the height of its containing block. However, the height of the containing block (indeed: all ancestors)
may be "auto", in which case the CSS spec says the available width of the element should be "the initial
containing block's size."[1]
Previously, we were using the FrameView's visibleHeight as this metric. However, the visibleHeight is calculated
asynchronously, after layout, after a round-trip from the Web Process to the UI Process and back to the Web
Process. Therefore, if content changes the WKWebView's size and the web view immediatey re-lays-out, this
visibleHeight metric is stale from whatever the previous height of the WKWebView was. In addition, the
visibleHeight metric isn't even supposed to be used inside layout; it's instead only supposed to be used for
things like position: fixed elements.
Instead, we should use FrameView::layoutSize(), which is set before layout to the size of the WKWebView. The
name even indicates that it should be used for layout purposes.
[1] https://drafts.csswg.org/css-writing-modes-4/#orthogonal-auto
Test: WebKit.OrthogonalFlowAvailableSize
* rendering/RenderBox.cpp:
(WebCore::RenderBox::perpendicularContainingBlockLogicalHeight const):
* rendering/RenderView.cpp:
(WebCore::RenderView::availableLogicalHeight const):
Tools:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit/OrthogonalFlowAvailableSize.mm: Added.
(TEST):
* TestWebKitAPI/Tests/WebKit/orthogonal-flow-available-size.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (266289 => 266290)
--- trunk/Source/WebCore/ChangeLog 2020-08-28 18:52:53 UTC (rev 266289)
+++ trunk/Source/WebCore/ChangeLog 2020-08-28 20:21:18 UTC (rev 266290)
@@ -1,3 +1,34 @@
+2020-08-28 Myles C. Maxfield <[email protected]>
+
+ [iOS] Vertical text's logical width calculation is stale from the previous height of the WKWebView
+ https://bugs.webkit.org/show_bug.cgi?id=215910
+
+ Reviewed by Simon Fraser.
+
+ When there is vertical text (really: orthogonal flows) in the content, the available width of the vertical
+ text is the height of its containing block. However, the height of the containing block (indeed: all ancestors)
+ may be "auto", in which case the CSS spec says the available width of the element should be "the initial
+ containing block's size."[1]
+
+ Previously, we were using the FrameView's visibleHeight as this metric. However, the visibleHeight is calculated
+ asynchronously, after layout, after a round-trip from the Web Process to the UI Process and back to the Web
+ Process. Therefore, if content changes the WKWebView's size and the web view immediatey re-lays-out, this
+ visibleHeight metric is stale from whatever the previous height of the WKWebView was. In addition, the
+ visibleHeight metric isn't even supposed to be used inside layout; it's instead only supposed to be used for
+ things like position: fixed elements.
+
+ Instead, we should use FrameView::layoutSize(), which is set before layout to the size of the WKWebView. The
+ name even indicates that it should be used for layout purposes.
+
+ [1] https://drafts.csswg.org/css-writing-modes-4/#orthogonal-auto
+
+ Test: WebKit.OrthogonalFlowAvailableSize
+
+ * rendering/RenderBox.cpp:
+ (WebCore::RenderBox::perpendicularContainingBlockLogicalHeight const):
+ * rendering/RenderView.cpp:
+ (WebCore::RenderView::availableLogicalHeight const):
+
2020-08-28 Tyler Wilcock <[email protected]>
Fix text-transform inheritance to ::marker
Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (266289 => 266290)
--- trunk/Source/WebCore/rendering/RenderBox.cpp 2020-08-28 18:52:53 UTC (rev 266289)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp 2020-08-28 20:21:18 UTC (rev 266290)
@@ -2036,7 +2036,7 @@
// FIXME: For now just support fixed heights. Eventually should support percentage heights as well.
if (!logicalHeightLength.isFixed()) {
- LayoutUnit fillFallbackExtent = containingBlockStyle.isHorizontalWritingMode() ? view().frameView().visibleHeight() : view().frameView().visibleWidth();
+ LayoutUnit fillFallbackExtent = containingBlockStyle.isHorizontalWritingMode() ? view().frameView().layoutSize().height() : view().frameView().layoutSize().width();
LayoutUnit fillAvailableExtent = containingBlock()->availableLogicalHeight(ExcludeMarginBorderPadding);
view().addPercentHeightDescendant(const_cast<RenderBox&>(*this));
// FIXME: https://bugs.webkit.org/show_bug.cgi?id=158286 We also need to perform the same percentHeightDescendant treatment to the element which dictates the return value for containingBlock()->availableLogicalHeight() above.
Modified: trunk/Source/WebCore/rendering/RenderView.cpp (266289 => 266290)
--- trunk/Source/WebCore/rendering/RenderView.cpp 2020-08-28 18:52:53 UTC (rev 266289)
+++ trunk/Source/WebCore/rendering/RenderView.cpp 2020-08-28 20:21:18 UTC (rev 266290)
@@ -138,7 +138,7 @@
if (document().isPluginDocument() && frameView().useFixedLayout())
return frameView().fixedLayoutSize().height();
#endif
- return isHorizontalWritingMode() ? frameView().visibleHeight() : frameView().visibleWidth();
+ return isHorizontalWritingMode() ? frameView().layoutSize().height() : frameView().layoutSize().width();
}
bool RenderView::isChildAllowed(const RenderObject& child, const RenderStyle&) const
Modified: trunk/Tools/ChangeLog (266289 => 266290)
--- trunk/Tools/ChangeLog 2020-08-28 18:52:53 UTC (rev 266289)
+++ trunk/Tools/ChangeLog 2020-08-28 20:21:18 UTC (rev 266290)
@@ -1,3 +1,15 @@
+2020-08-28 Myles C. Maxfield <[email protected]>
+
+ [iOS] Vertical text's logical width calculation is stale from the previous height of the WKWebView
+ https://bugs.webkit.org/show_bug.cgi?id=215910
+
+ Reviewed by Simon Fraser.
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WebKit/OrthogonalFlowAvailableSize.mm: Added.
+ (TEST):
+ * TestWebKitAPI/Tests/WebKit/orthogonal-flow-available-size.html: Added.
+
2020-08-28 Jonathan Bedard <[email protected]>
[webkitcorepy] Move Timeout to webkitcorepy (Part 3)
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (266289 => 266290)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2020-08-28 18:52:53 UTC (rev 266289)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2020-08-28 20:21:18 UTC (rev 266290)
@@ -110,6 +110,8 @@
1C90420C2326E03C00BEF91E /* SelectionByWord.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C90420B2326E03C00BEF91E /* SelectionByWord.mm */; };
1C9EB8411E380DA1005C6442 /* ComplexTextController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C9EB8401E380DA1005C6442 /* ComplexTextController.cpp */; };
1CACADA1230620AE0007D54C /* WKWebViewOpaque.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1CACADA0230620AD0007D54C /* WKWebViewOpaque.mm */; };
+ 1CB2F27C24F88379000A5BC1 /* OrthogonalFlowAvailableSize.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1CB2F27B24F88379000A5BC1 /* OrthogonalFlowAvailableSize.mm */; };
+ 1CB2F27E24F88A52000A5BC1 /* orthogonal-flow-available-size.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1CB2F27D24F883BE000A5BC1 /* orthogonal-flow-available-size.html */; };
1CC80CEA2474F249004DC489 /* idempotent-mode-autosizing-only-honors-percentages.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1CC80CE92474F1F7004DC489 /* idempotent-mode-autosizing-only-honors-percentages.html */; };
1CE6FAC32320267C00E48F6E /* rich-color-filtered.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 1CE6FAC12320264F00E48F6E /* rich-color-filtered.html */; };
1CF59AE221E68925006E37EC /* ForceLightAppearanceInBundle_Bundle.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1CF59AE021E68925006E37EC /* ForceLightAppearanceInBundle_Bundle.mm */; };
@@ -1540,6 +1542,7 @@
41848F4424891879000E2588 /* open-window-with-file-url-with-host.html in Copy Resources */,
931C281E22BC579A001D98C4 /* opendatabase-always-exists.html in Copy Resources */,
290A9BB91735F63800D71BBC /* OpenNewWindow.html in Copy Resources */,
+ 1CB2F27E24F88A52000A5BC1 /* orthogonal-flow-available-size.html in Copy Resources */,
F49992C6248DABFD00034167 /* overflow-hidden.html in Copy Resources */,
0F340779230382870060A1A0 /* overflow-scroll.html in Copy Resources */,
83148B09202AC78D00BADE99 /* override-builtins-test.html in Copy Resources */,
@@ -1751,6 +1754,8 @@
1C90420B2326E03C00BEF91E /* SelectionByWord.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SelectionByWord.mm; sourceTree = "<group>"; };
1C9EB8401E380DA1005C6442 /* ComplexTextController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ComplexTextController.cpp; sourceTree = "<group>"; };
1CACADA0230620AD0007D54C /* WKWebViewOpaque.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewOpaque.mm; sourceTree = "<group>"; };
+ 1CB2F27B24F88379000A5BC1 /* OrthogonalFlowAvailableSize.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = OrthogonalFlowAvailableSize.mm; sourceTree = "<group>"; };
+ 1CB2F27D24F883BE000A5BC1 /* orthogonal-flow-available-size.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "orthogonal-flow-available-size.html"; sourceTree = "<group>"; };
1CB9BC371A67482300FE5678 /* WeakPtr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WeakPtr.cpp; sourceTree = "<group>"; };
1CC80CE92474F1F7004DC489 /* idempotent-mode-autosizing-only-honors-percentages.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "idempotent-mode-autosizing-only-honors-percentages.html"; sourceTree = "<group>"; };
1CE6FAC12320264F00E48F6E /* rich-color-filtered.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "rich-color-filtered.html"; sourceTree = "<group>"; };
@@ -4064,6 +4069,7 @@
93F7E86B14DC8E4D00C84A99 /* NewFirstVisuallyNonEmptyLayoutFrames.cpp */,
93F7E86E14DC8E5B00C84A99 /* NewFirstVisuallyNonEmptyLayoutFrames_Bundle.cpp */,
0F5651F61FCE4DDB00310FBC /* NoHistoryItemScrollToFragment.mm */,
+ 1CB2F27B24F88379000A5BC1 /* OrthogonalFlowAvailableSize.mm */,
7CCB4DA71C83AE7300CC6918 /* PageGroup.cpp */,
BC909779125571AB00083756 /* PageLoadBasic.cpp */,
BC2D004812A9FDFA00E732A3 /* PageLoadDidChangeLocationWithinPageForFrame.cpp */,
@@ -4294,6 +4300,7 @@
CEA6CF2719CCF69D0064F5A7 /* open-and-close-window.html */,
468BC454226539C800A36C96 /* open-window-then-write-to-it.html */,
41848F4324891815000E2588 /* open-window-with-file-url-with-host.html */,
+ 1CB2F27D24F883BE000A5BC1 /* orthogonal-flow-available-size.html */,
83148B08202AC76800BADE99 /* override-builtins-test.html */,
0EBBCC651FFF9DCE00FA42AB /* pop-up-check.html */,
F6FDDDD514241C48004F1729 /* push-state.html */,
@@ -4402,8 +4409,8 @@
C9E6DD311EA972D800DD78AA /* FirstResponderSuppression.mm */,
F456AB1B213EDBA300CB2CEF /* FontManagerTests.mm */,
1A7E8B33181208DE00AEB74A /* FragmentNavigation.mm */,
+ CDB213BC24EF522800FDE301 /* FullscreenFocus.mm */,
CDBFCC431A9FF44800A7B691 /* FullscreenZoomInitialFrame.mm */,
- CDB213BC24EF522800FDE301 /* FullscreenFocus.mm */,
51EB125824C68589000CB030 /* HIDGamepads.mm */,
9B4F8FA3159D52B1002D9F94 /* HTMLCollectionNamedItem.mm */,
9B26FC6B159D061000CC3765 /* HTMLFormCollectionNamedItem.mm */,
@@ -5054,7 +5061,6 @@
46A911592108E6780078D40D /* CustomUserAgent.mm in Sources */,
751B05D61F8EAC410028A09E /* DatabaseTrackerTest.mm in Sources */,
2DC4CF771D2D9DD800ECCC94 /* DataDetection.mm in Sources */,
- CDB213BD24EF522800FDE301 /* FullscreenFocus.mm in Sources */,
44077BB123144B5000179E2D /* DataDetectorsTestIOS.mm in Sources */,
9BAD7F3E22690F2000F8DA66 /* DeallocWebViewInEventListener.mm in Sources */,
518EE51D20A78D3600E024F3 /* DecidePolicyForNavigationAction.mm in Sources */,
@@ -5133,6 +5139,7 @@
7CCE7EF71A411AE600447C4C /* FrameMIMETypePNG.cpp in Sources */,
CDCF78A8244A32F700480311 /* FullscreenAlert.mm in Sources */,
CD78E11D1DB7EA660014A2DE /* FullscreenDelegate.mm in Sources */,
+ CDB213BD24EF522800FDE301 /* FullscreenFocus.mm in Sources */,
CDBFCC451A9FF45300A7B691 /* FullscreenZoomInitialFrame.mm in Sources */,
83DB79691EF63B3C00BFA5E5 /* Function.cpp in Sources */,
7CCE7EF81A411AE600447C4C /* Geolocation.cpp in Sources */,
@@ -5261,6 +5268,7 @@
37A22AA71DCAA27200AFBFC4 /* ObservedRenderingProgressEventsAfterCrash.mm in Sources */,
2D70059921EDA4D0003463CB /* OffscreenWindow.mm in Sources */,
7CCE7F251A411AF600447C4C /* OpenAndCloseWindow.mm in Sources */,
+ 1CB2F27C24F88379000A5BC1 /* OrthogonalFlowAvailableSize.mm in Sources */,
0F34077623037FDC0060A1A0 /* OverflowScrollViewTests.mm in Sources */,
CEBCA12F1E3A660100C73293 /* OverrideContentSecurityPolicy.mm in Sources */,
2DA2586F225C67DC00B45C1C /* OverrideViewportArguments.mm in Sources */,
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit/OrthogonalFlowAvailableSize.mm (0 => 266290)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit/OrthogonalFlowAvailableSize.mm (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit/OrthogonalFlowAvailableSize.mm 2020-08-28 20:21:18 UTC (rev 266290)
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#import "PlatformUtilities.h"
+#import "TestNavigationDelegate.h"
+#import <WebKit/WKPreferences.h>
+#import <WebKit/WKWebViewPrivate.h>
+#import <wtf/RetainPtr.h>
+
+TEST(WebKit, OrthogonalFlowAvailableSize)
+{
+ CGPoint origin = CGPointMake(0, 0);
+ RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(origin.x, origin.y, 500, 500)]);
+
+ NSURLRequest *request = [NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"orthogonal-flow-available-size" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]];
+ [webView loadRequest:request];
+ [webView _test_waitForDidFinishNavigation];
+
+ __block bool done = false;
+ [webView evaluateJavaScript:@"runTest()" completionHandler:^(NSNumber *result, NSError *error) {
+ EXPECT_EQ(500, result.intValue);
+ done = true;
+ }];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+
+ [webView setFrame:CGRectMake(origin.x, origin.y, 500, 400)];
+ [webView evaluateJavaScript:@"runTest()" completionHandler:^(NSNumber *result, NSError *error) {
+ EXPECT_EQ(400, result.intValue);
+ done = true;
+ }];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+
+ [webView setFrame:CGRectMake(origin.x, origin.y, 500, 600)];
+ [webView evaluateJavaScript:@"runTest()" completionHandler:^(NSNumber *result, NSError *error) {
+ EXPECT_EQ(600, result.intValue);
+ done = true;
+ }];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+}
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit/orthogonal-flow-available-size.html (0 => 266290)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit/orthogonal-flow-available-size.html (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit/orthogonal-flow-available-size.html 2020-08-28 20:21:18 UTC (rev 266290)
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<style>
+body {
+ -webkit-text-size-adjust: none;
+ background: green;
+ margin: 0px;
+}
+
+#target {
+ writing-mode: vertical-lr;
+}
+</style>
+<script>
+function runTest() {
+ let target = document.getElementById("target");
+ return target.offsetHeight;
+}
+</script>
+</head>
+<body>
+<div>Hello<span id="target">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Leo urna molestie at elementum eu. Et egestas quis ipsum suspendisse ultrices gravida dictum. Faucibus in ornare quam viverra orci. Urna porttitor rhoncus dolor purus non. Hendrerit dolor magna eget est lorem ipsum dolor sit amet. Vitae nunc sed velit dignissim sodales ut eu sem integer. Lorem sed risus ultricies tristique nulla aliquet enim tortor at. Egestas pretium aenean pharetra magna. Mattis vulputate enim nulla aliquet porttitor lacus luctus accumsan tortor. Eget nullam non nisi est sit. Velit scelerisque in dictum non consectetur a erat nam at. Pretium aenean pharetra magna ac placerat vestibulum lectus mauris ultrices. Tortor condimentum lacinia quis vel eros donec. Nullam non nisi est sit amet facilisis magna. Dapibus ultrices in iaculis nunc.</span>point</div>
+</body>
+</html>