Title: [221272] branches/safari-604-branch

Diff

Modified: branches/safari-604-branch/Source/WebKit/ChangeLog (221271 => 221272)


--- branches/safari-604-branch/Source/WebKit/ChangeLog	2017-08-28 21:14:44 UTC (rev 221271)
+++ branches/safari-604-branch/Source/WebKit/ChangeLog	2017-08-28 21:48:49 UTC (rev 221272)
@@ -1,5 +1,47 @@
 2017-08-28  Jason Marcell  <[email protected]>
 
+        Cherry-pick r221153. rdar://problem/34113728
+
+    2017-08-24  Tim Horton  <[email protected]>
+
+            Layout size override changes during in-flight animated resize are dropped on the floor forever
+            https://bugs.webkit.org/show_bug.cgi?id=175916
+            <rdar://problem/33887295>
+
+            Reviewed by Beth Dakin.
+
+            Layout size override changes that come in during an animated resize
+            are currently stored, but not sent in a separate message, because
+            they're sent as part of the resize. However, if a layout size override
+            change happens after the animated resize message was already sent, but
+            before the animated resize is ended, that change will be stored, but
+            not sent in the animated resize message (because it's too late), and
+            then subsequent calls with the same size will early-return, because
+            we're testing against the stored size, not the size we last actually
+            sent to the Web Content process.
+
+            Instead, store the last-sent size, so that subsequent layout size override
+            changes with the same size won't bail, and if it differs from the active
+            state after the animated resize completes, send an out-of-band update.
+
+            All of the above also applies to device orientation, which follows
+            exactly the same pattern.
+
+            * UIProcess/API/Cocoa/WKWebView.mm:
+            (-[WKWebView _initializeWithConfiguration:]):
+            (-[WKWebView _dispatchSetMinimumLayoutSize:]):
+            (-[WKWebView _dispatchSetMaximumUnobscuredSize:]):
+            (-[WKWebView _dispatchSetDeviceOrientation:]):
+            (-[WKWebView _frameOrBoundsChanged]):
+            (-[WKWebView _windowDidRotate:]):
+            (-[WKWebView _didRelaunchProcess]):
+            (-[WKWebView _setMinimumLayoutSizeOverride:]):
+            (-[WKWebView _setInterfaceOrientationOverride:]):
+            (-[WKWebView _setMaximumUnobscuredSizeOverride:]):
+            (-[WKWebView _beginAnimatedResizeWithUpdates:]):
+
+2017-08-28  Jason Marcell  <[email protected]>
+
         Cherry-pick r221138. rdar://problem/34113574
 
     2017-08-24  Chris Dumez  <[email protected]>

Modified: branches/safari-604-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (221271 => 221272)


--- branches/safari-604-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2017-08-28 21:14:44 UTC (rev 221271)
+++ branches/safari-604-branch/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm	2017-08-28 21:48:49 UTC (rev 221272)
@@ -230,8 +230,10 @@
 
     BOOL _overridesMinimumLayoutSize;
     CGSize _minimumLayoutSizeOverride;
+    std::optional<WebCore::FloatSize> _lastSentMinimumLayoutSize;
     BOOL _overridesMaximumUnobscuredSize;
     CGSize _maximumUnobscuredSizeOverride;
+    std::optional<WebCore::FloatSize> _lastSentMaximumUnobscuredSize;
     CGRect _inputViewBounds;
     CGFloat _viewportMetaTagWidth;
     BOOL _viewportMetaTagWidthWasExplicit;
@@ -252,6 +254,7 @@
 
     UIInterfaceOrientation _interfaceOrientationOverride;
     BOOL _overridesInterfaceOrientation;
+    std::optional<int32_t> _lastSentDeviceOrientation;
 
     BOOL _allowsViewportShrinkToFit;
 
@@ -536,7 +539,7 @@
     _contentView = adoptNS([[WKContentView alloc] initWithFrame:bounds processPool:processPool configuration:WTFMove(pageConfiguration) webView:self]);
 
     _page = [_contentView page];
-    _page->setDeviceOrientation(deviceOrientation());
+    [self _dispatchSetDeviceOrientation:deviceOrientation()];
     _page->setDrawsBackground(self.opaque);
 
     [_contentView layer].anchorPoint = CGPointZero;
@@ -2304,6 +2307,33 @@
 #endif
 }
 
+- (void)_dispatchSetMinimumLayoutSize:(WebCore::FloatSize)minimumLayoutSize
+{
+    if (_lastSentMinimumLayoutSize && CGSizeEqualToSize(_lastSentMinimumLayoutSize.value(), minimumLayoutSize))
+        return;
+
+    _page->setViewportConfigurationMinimumLayoutSize(minimumLayoutSize);
+    _lastSentMinimumLayoutSize = minimumLayoutSize;
+}
+
+- (void)_dispatchSetMaximumUnobscuredSize:(WebCore::FloatSize)maximumUnobscuredSize
+{
+    if (_lastSentMaximumUnobscuredSize && CGSizeEqualToSize(_lastSentMaximumUnobscuredSize.value(), maximumUnobscuredSize))
+        return;
+
+    _page->setMaximumUnobscuredSize(maximumUnobscuredSize);
+    _lastSentMaximumUnobscuredSize = maximumUnobscuredSize;
+}
+
+- (void)_dispatchSetDeviceOrientation:(int32_t)deviceOrientation
+{
+    if (_lastSentDeviceOrientation && _lastSentDeviceOrientation.value() == deviceOrientation)
+        return;
+
+    _page->setDeviceOrientation(deviceOrientation);
+    _lastSentDeviceOrientation = deviceOrientation;
+}
+
 - (void)_frameOrBoundsChanged
 {
     CGRect bounds = self.bounds;
@@ -2311,9 +2341,9 @@
 
     if (_dynamicViewportUpdateMode == DynamicViewportUpdateMode::NotResizing) {
         if (!_overridesMinimumLayoutSize)
-            _page->setViewportConfigurationMinimumLayoutSize(activeMinimumLayoutSize(self, self.bounds));
+            [self _dispatchSetMinimumLayoutSize:activeMinimumLayoutSize(self, self.bounds)];
         if (!_overridesMaximumUnobscuredSize)
-            _page->setMaximumUnobscuredSize(WebCore::FloatSize(bounds.size));
+            [self _dispatchSetMaximumUnobscuredSize:WebCore::FloatSize(bounds.size)];
 
         BOOL sizeChanged = NO;
         if (auto drawingArea = _page->drawingArea())
@@ -2619,7 +2649,7 @@
 - (void)_windowDidRotate:(NSNotification *)notification
 {
     if (!_overridesInterfaceOrientation)
-        _page->setDeviceOrientation(deviceOrientation());
+        [self _dispatchSetDeviceOrientation:deviceOrientation()];
 }
 
 - (void)_contentSizeCategoryDidChange:(NSNotification *)notification
@@ -3947,9 +3977,8 @@
 {
 #if PLATFORM(IOS)
     CGRect bounds = self.bounds;
-    WebCore::FloatSize minimalLayoutSize = activeMinimumLayoutSize(self, bounds);
-    _page->setViewportConfigurationMinimumLayoutSize(minimalLayoutSize);
-    _page->setMaximumUnobscuredSize(activeMaximumUnobscuredSize(self, bounds));
+    [self _dispatchSetMinimumLayoutSize:activeMinimumLayoutSize(self, bounds)];
+    [self _dispatchSetMaximumUnobscuredSize:activeMaximumUnobscuredSize(self, bounds)];
 #endif
 }
 
@@ -4610,12 +4639,11 @@
 - (void)_setMinimumLayoutSizeOverride:(CGSize)minimumLayoutSizeOverride
 {
     _overridesMinimumLayoutSize = YES;
-    if (CGSizeEqualToSize(_minimumLayoutSizeOverride, minimumLayoutSizeOverride))
-        return;
+    _minimumLayoutSizeOverride = minimumLayoutSizeOverride;
 
-    _minimumLayoutSizeOverride = minimumLayoutSizeOverride;
     if (_dynamicViewportUpdateMode == DynamicViewportUpdateMode::NotResizing)
-        _page->setViewportConfigurationMinimumLayoutSize(WebCore::FloatSize(minimumLayoutSizeOverride));
+        [self _dispatchSetMinimumLayoutSize:WebCore::FloatSize(minimumLayoutSizeOverride)];
+
 }
 
 - (UIEdgeInsets)_obscuredInsets
@@ -4687,14 +4715,10 @@
 - (void)_setInterfaceOrientationOverride:(UIInterfaceOrientation)interfaceOrientation
 {
     _overridesInterfaceOrientation = YES;
-
-    if (interfaceOrientation == _interfaceOrientationOverride)
-        return;
-
     _interfaceOrientationOverride = interfaceOrientation;
 
     if (_dynamicViewportUpdateMode == DynamicViewportUpdateMode::NotResizing)
-        _page->setDeviceOrientation(deviceOrientationForUIInterfaceOrientation(_interfaceOrientationOverride));
+        [self _dispatchSetDeviceOrientation:deviceOrientationForUIInterfaceOrientation(_interfaceOrientationOverride)];
 }
 
 - (UIInterfaceOrientation)_interfaceOrientationOverride
@@ -4719,12 +4743,10 @@
 {
     ASSERT(size.width <= self.bounds.size.width && size.height <= self.bounds.size.height);
     _overridesMaximumUnobscuredSize = YES;
-    if (CGSizeEqualToSize(_maximumUnobscuredSizeOverride, size))
-        return;
+    _maximumUnobscuredSizeOverride = size;
 
-    _maximumUnobscuredSizeOverride = size;
     if (_dynamicViewportUpdateMode == DynamicViewportUpdateMode::NotResizing)
-        _page->setMaximumUnobscuredSize(WebCore::FloatSize(size));
+        [self _dispatchSetMaximumUnobscuredSize:WebCore::FloatSize(size)];
 }
 
 - (void)_setBackgroundExtendsBeyondPage:(BOOL)backgroundExtends
@@ -4798,11 +4820,11 @@
         _dynamicViewportUpdateMode = DynamicViewportUpdateMode::NotResizing;
         [self _frameOrBoundsChanged];
         if (_overridesMinimumLayoutSize)
-            _page->setViewportConfigurationMinimumLayoutSize(WebCore::FloatSize(newMinimumLayoutSize));
+            [self _dispatchSetMinimumLayoutSize:WebCore::FloatSize(newMinimumLayoutSize)];
         if (_overridesMaximumUnobscuredSize)
-            _page->setMaximumUnobscuredSize(WebCore::FloatSize(newMaximumUnobscuredSize));
+            [self _dispatchSetMaximumUnobscuredSize:WebCore::FloatSize(newMaximumUnobscuredSize)];
         if (_overridesInterfaceOrientation)
-            _page->setDeviceOrientation(newOrientation);
+            [self _dispatchSetDeviceOrientation:newOrientation];
 
         [self _scheduleVisibleContentRectUpdate];
         return;
@@ -4875,6 +4897,10 @@
     UIEdgeInsets unobscuredSafeAreaInsets = [self _computedUnobscuredSafeAreaInset];
     WebCore::FloatBoxExtent unobscuredSafeAreaInsetsExtent(unobscuredSafeAreaInsets.top, unobscuredSafeAreaInsets.right, unobscuredSafeAreaInsets.bottom, unobscuredSafeAreaInsets.left);
 
+    _lastSentMinimumLayoutSize = newMinimumLayoutSize;
+    _lastSentMaximumUnobscuredSize = newMaximumUnobscuredSize;
+    _lastSentDeviceOrientation = newOrientation;
+
     _page->dynamicViewportSizeUpdate(newMinimumLayoutSize, newMaximumUnobscuredSize, visibleRectInContentCoordinates, unobscuredRectInContentCoordinates, futureUnobscuredRectInSelfCoordinates, unobscuredSafeAreaInsetsExtent, targetScale, newOrientation);
     if (WebKit::DrawingAreaProxy* drawingArea = _page->drawingArea())
         drawingArea->setSize(WebCore::IntSize(newBounds.size), WebCore::IntSize(), WebCore::IntSize());
@@ -4937,6 +4963,18 @@
     [_contentView setHidden:NO];
     [self _scheduleVisibleContentRectUpdate];
 
+    CGRect newBounds = self.bounds;
+    WebCore::FloatSize newMinimumLayoutSize = activeMinimumLayoutSize(self, newBounds);
+    WebCore::FloatSize newMaximumUnobscuredSize = activeMaximumUnobscuredSize(self, newBounds);
+    int32_t newOrientation = activeOrientation(self);
+
+    if (!_lastSentMinimumLayoutSize || newMinimumLayoutSize != _lastSentMinimumLayoutSize.value())
+        [self _dispatchSetMinimumLayoutSize:WebCore::FloatSize(newMinimumLayoutSize)];
+    if (!_lastSentMaximumUnobscuredSize || newMaximumUnobscuredSize != _lastSentMaximumUnobscuredSize.value())
+        [self _dispatchSetMaximumUnobscuredSize:WebCore::FloatSize(newMaximumUnobscuredSize)];
+    if (!_lastSentDeviceOrientation || newOrientation != _lastSentDeviceOrientation.value())
+        [self _dispatchSetDeviceOrientation:newOrientation];
+
     while (!_snapshotsDeferredDuringResize.isEmpty())
         _snapshotsDeferredDuringResize.takeLast()();
 }

Modified: branches/safari-604-branch/Tools/ChangeLog (221271 => 221272)


--- branches/safari-604-branch/Tools/ChangeLog	2017-08-28 21:14:44 UTC (rev 221271)
+++ branches/safari-604-branch/Tools/ChangeLog	2017-08-28 21:48:49 UTC (rev 221272)
@@ -1,3 +1,20 @@
+2017-08-28  Jason Marcell  <[email protected]>
+
+        Cherry-pick r221153. rdar://problem/34113728
+
+    2017-08-24  Tim Horton  <[email protected]>
+
+            Layout size override changes during in-flight animated resize are dropped on the floor forever
+            https://bugs.webkit.org/show_bug.cgi?id=175916
+            <rdar://problem/33887295>
+
+            Reviewed by Beth Dakin.
+
+            * TestWebKitAPI/Tests/WebKit2Cocoa/AnimatedResize.mm:
+            (TEST):
+            Add a test ensuring that override layout size changes
+            during an animated resize actually take effect.
+
 2017-08-15  Matthew Hanson  <[email protected]>
 
         Cherry-pick r220722. rdar://problem/33890577

Modified: branches/safari-604-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/AnimatedResize.mm (221271 => 221272)


--- branches/safari-604-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/AnimatedResize.mm	2017-08-28 21:14:44 UTC (rev 221271)
+++ branches/safari-604-branch/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/AnimatedResize.mm	2017-08-28 21:48:49 UTC (rev 221272)
@@ -130,4 +130,38 @@
     }
 }
 
+TEST(WebKit2, OverrideLayoutSizeChangesDuringAnimatedResizeSucceed)
+{
+    auto webView = createAnimatedResizeWebView();
+    [webView setUIDelegate:webView.get()];
+
+    [webView _overrideLayoutParametersWithMinimumLayoutSize:CGSizeMake(200, 50) maximumUnobscuredSizeOverride:CGSizeMake(200, 50)];
+
+    [webView loadHTMLString:@"<head><meta name='viewport' content='initial-scale=1' /></head>" baseURL:nil];
+    [webView _test_waitForDidFinishNavigation];
+
+    RetainPtr<UIWindow> window = adoptNS([[UIWindow alloc] initWithFrame:CGRectMake(0, 0, 800, 600)]);
+    [window addSubview:webView.get()];
+    [window setHidden:NO];
+
+    [webView _beginAnimatedResizeWithUpdates:^ {
+        [webView setFrame:CGRectMake(0, 0, [webView frame].size.width + 100, 400)];
+    }];
+
+    [webView _overrideLayoutParametersWithMinimumLayoutSize:CGSizeMake(100, 200) maximumUnobscuredSizeOverride:CGSizeMake(100, 200)];
+    [webView _endAnimatedResize];
+
+    __block bool didReadLayoutSize = false;
+    [webView evaluateJavaScript:@"[window.innerWidth, window.innerHeight]" completionHandler:^(id value, NSError *error) {
+        CGFloat innerWidth = [[value objectAtIndex:0] floatValue];
+        CGFloat innerHeight = [[value objectAtIndex:1] floatValue];
+
+        EXPECT_EQ(innerWidth, 100);
+        EXPECT_EQ(innerHeight, 200);
+
+        didReadLayoutSize = true;
+    }];
+    TestWebKitAPI::Util::run(&didReadLayoutSize);
+}
+
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to