Title: [293188] trunk
Revision
293188
Author
simon.fra...@apple.com
Date
2022-04-21 14:03:05 -0700 (Thu, 21 Apr 2022)

Log Message

<body> with overflow:hidden CSS is scrollable on iOS standalone web app
https://bugs.webkit.org/show_bug.cgi?id=220908
<rdar://73574797>

Reviewed by Devin Rousso.

Source/WebKit:

`overflow:hidden` failed to make the primary scroll view unscrollable in a home screen web
app because of logic in _updateScrollViewForTransaction: that was intended to ensure that if
the current unobscured rect is equal to the max unobscured rect (i.e. testing for collapsed
UI in MobileSafari), the user could scroll to expand the UI.

This failed in Web.app because there is no collapsible UI there, i.e.
minUnobscuredSize == maxUnobscuredSize. So test for that scenario.

Tested by new API tests.

* UIProcess/API/ios/WKWebViewIOS.mm:
(-[WKWebView _updateScrollViewForTransaction:]):

Tools:

New API tests for various configurations of insets and size overrides.

* TestWebKitAPI/Tests/ios/ScrollViewInsetTests.mm:
(TestWebKitAPI::TEST):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (293187 => 293188)


--- trunk/Source/WebKit/ChangeLog	2022-04-21 20:57:31 UTC (rev 293187)
+++ trunk/Source/WebKit/ChangeLog	2022-04-21 21:03:05 UTC (rev 293188)
@@ -1,3 +1,24 @@
+2022-04-21  Simon Fraser  <simon.fra...@apple.com>
+
+        <body> with overflow:hidden CSS is scrollable on iOS standalone web app
+        https://bugs.webkit.org/show_bug.cgi?id=220908
+        <rdar://73574797>
+
+        Reviewed by Devin Rousso.
+
+        `overflow:hidden` failed to make the primary scroll view unscrollable in a home screen web
+        app because of logic in _updateScrollViewForTransaction: that was intended to ensure that if
+        the current unobscured rect is equal to the max unobscured rect (i.e. testing for collapsed
+        UI in MobileSafari), the user could scroll to expand the UI.
+
+        This failed in Web.app because there is no collapsible UI there, i.e.
+        minUnobscuredSize == maxUnobscuredSize. So test for that scenario.
+
+        Tested by new API tests.
+
+        * UIProcess/API/ios/WKWebViewIOS.mm:
+        (-[WKWebView _updateScrollViewForTransaction:]):
+
 2022-04-21  Youenn Fablet  <you...@apple.com>
 
         A suspended remote shared worker should resume when a new SharedWorker is added

Modified: trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm (293187 => 293188)


--- trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm	2022-04-21 20:57:31 UTC (rev 293187)
+++ trunk/Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm	2022-04-21 21:03:05 UTC (rev 293188)
@@ -880,7 +880,8 @@
     if (_maximumUnobscuredSizeOverride) {
         auto unobscuredContentRect = _page->unobscuredContentRect();
         auto maxUnobscuredSize = _page->maximumUnobscuredSize();
-        scrollingNeededToRevealUI = maxUnobscuredSize.width() == unobscuredContentRect.width() && maxUnobscuredSize.height() == unobscuredContentRect.height();
+        auto minUnobscuredSize = _page->minimumUnobscuredSize();
+        scrollingNeededToRevealUI = minUnobscuredSize != maxUnobscuredSize && maxUnobscuredSize == unobscuredContentRect.size();
     }
 
     bool scrollingEnabled = _page->scrollingCoordinatorProxy()->hasScrollableOrZoomedMainFrame() || hasDockedInputView || isZoomed || scrollingNeededToRevealUI;

Modified: trunk/Tools/ChangeLog (293187 => 293188)


--- trunk/Tools/ChangeLog	2022-04-21 20:57:31 UTC (rev 293187)
+++ trunk/Tools/ChangeLog	2022-04-21 21:03:05 UTC (rev 293188)
@@ -1,3 +1,16 @@
+2022-04-21  Simon Fraser  <simon.fra...@apple.com>
+
+        <body> with overflow:hidden CSS is scrollable on iOS standalone web app
+        https://bugs.webkit.org/show_bug.cgi?id=220908
+        <rdar://73574797>
+
+        Reviewed by Devin Rousso.
+
+        New API tests for various configurations of insets and size overrides.
+
+        * TestWebKitAPI/Tests/ios/ScrollViewInsetTests.mm:
+        (TestWebKitAPI::TEST):
+
 2022-04-21  Jonathan Bedard  <jbed...@apple.com>
 
         [git-webkit] Allow caller to specify remote for PR

Modified: trunk/Tools/TestWebKitAPI/Tests/ios/ScrollViewInsetTests.mm (293187 => 293188)


--- trunk/Tools/TestWebKitAPI/Tests/ios/ScrollViewInsetTests.mm	2022-04-21 20:57:31 UTC (rev 293187)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/ScrollViewInsetTests.mm	2022-04-21 21:03:05 UTC (rev 293188)
@@ -275,6 +275,78 @@
     EXPECT_EQ(-100, contentOffsetAfterNavigation.y);
 }
 
+TEST(ScrollViewInsetTests, ScrollabilityWithInsets)
+{
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 320, 500)]);
+    [webView scrollView].contentInset = UIEdgeInsetsMake(50, 0, 50, 0);
+
+    [webView synchronouslyLoadHTMLString:@"<meta name='viewport' content='width=device-width, initial-scale=1'><style> body { overflow: hidden; height: 2000px; } </style>"];
+    [webView waitForNextPresentationUpdate];
+    // Insets result in the visual viewport being smaller than the layout viewport, making the main frame scrollable.
+    EXPECT_TRUE([webView scrollView].scrollEnabled);
+
+    [webView synchronouslyLoadHTMLString:@"<meta name='viewport' content='width=device-width, initial-scale=1'><style> body { overflow: visible; height: 2000px; } </style>"];
+    [webView waitForNextPresentationUpdate];
+    EXPECT_TRUE([webView scrollView].scrollEnabled);
+}
+
+TEST(ScrollViewInsetTests, ScrollabilityWithObscuredInsets)
+{
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 390, 844)]);
+    auto insets = UIEdgeInsetsMake(47, 0, 133, 0);
+    [webView scrollView].contentInset = insets;
+    [webView _setObscuredInsets:insets];
+
+    [webView synchronouslyLoadHTMLString:@"<meta name='viewport' content='width=device-width, initial-scale=1'><style> body { overflow: hidden; height: 2000px; } </style>"];
+    [webView waitForNextPresentationUpdate];
+    // Insets result in the visual viewport being smaller than the layout viewport, making the main frame scrollable.
+    EXPECT_TRUE([webView scrollView].scrollEnabled);
+
+    [webView synchronouslyLoadHTMLString:@"<meta name='viewport' content='width=device-width, initial-scale=1'><style> body { overflow: visible; height: 2000px; } </style>"];
+    [webView waitForNextPresentationUpdate];
+    EXPECT_TRUE([webView scrollView].scrollEnabled);
+}
+
+TEST(ScrollViewInsetTests, ScrollabilityWithObscuredInsetsAndOverrideSizes)
+{
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 390, 844)]);
+    auto insets = UIEdgeInsetsMake(47, 0, 133, 0);
+    [webView scrollView].contentInset = insets;
+    [webView _setObscuredInsets:insets];
+
+    auto minimumLayoutSize = CGSizeMake(390, 664);
+    auto maxUnobscuredLayoutSize = CGSizeMake(390, 745);
+    [webView _overrideLayoutParametersWithMinimumLayoutSize:minimumLayoutSize maximumUnobscuredSizeOverride:maxUnobscuredLayoutSize];
+
+    [webView synchronouslyLoadHTMLString:@"<meta name='viewport' content='width=device-width, initial-scale=1'><style> body { overflow: hidden; height: 2000px; } </style>"];
+    [webView waitForNextPresentationUpdate];
+    EXPECT_FALSE([webView scrollView].scrollEnabled);
+
+    [webView synchronouslyLoadHTMLString:@"<meta name='viewport' content='width=device-width, initial-scale=1'><style> body { overflow: visible; height: 2000px; } </style>"];
+    [webView waitForNextPresentationUpdate];
+    EXPECT_TRUE([webView scrollView].scrollEnabled);
+}
+
+TEST(ScrollViewInsetTests, ScrollabilityWithMaxOverrideSize)
+{
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 390, 844)]);
+
+    auto insets = UIEdgeInsetsMake(47, 0, 0, 0);
+    [webView scrollView].contentInset = insets;
+    [webView _setObscuredInsets:insets];
+
+    auto unobscuredLayoutSize = CGSizeMake(390, 797);
+    [webView _overrideLayoutParametersWithMinimumLayoutSize:unobscuredLayoutSize maximumUnobscuredSizeOverride:unobscuredLayoutSize];
+
+    [webView synchronouslyLoadHTMLString:@"<meta name='viewport' content='width=device-width, initial-scale=1'><style> body { overflow: hidden; height: 2000px; } </style>"];
+    [webView waitForNextPresentationUpdate];
+    EXPECT_FALSE([webView scrollView].scrollEnabled);
+
+    [webView synchronouslyLoadHTMLString:@"<meta name='viewport' content='width=device-width, initial-scale=1'><style> body { overflow: visible; height: 2000px; } </style>"];
+    [webView waitForNextPresentationUpdate];
+    EXPECT_TRUE([webView scrollView].scrollEnabled);
+}
+
 } // namespace TestWebKitAPI
 
 #endif // PLATFORM(IOS_FAMILY)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to