Diff
Modified: tags/Safari-606.1.20/Source/WebKit/ChangeLog (232599 => 232600)
--- tags/Safari-606.1.20/Source/WebKit/ChangeLog 2018-06-07 21:05:29 UTC (rev 232599)
+++ tags/Safari-606.1.20/Source/WebKit/ChangeLog 2018-06-07 21:16:16 UTC (rev 232600)
@@ -1,3 +1,7 @@
+2018-06-07 Kocsen Chung <[email protected]>
+
+ Revert r232556. rdar://problem/38477288
+
2018-06-06 Kocsen Chung <[email protected]>
Cherry-pick r232559. rdar://problem/39874167
Modified: tags/Safari-606.1.20/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreeTransaction.h (232599 => 232600)
--- tags/Safari-606.1.20/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreeTransaction.h 2018-06-07 21:05:29 UTC (rev 232599)
+++ tags/Safari-606.1.20/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreeTransaction.h 2018-06-07 21:16:16 UTC (rev 232600)
@@ -25,7 +25,6 @@
#pragma once
-#include "DynamicViewportSizeUpdate.h"
#include "EditorState.h"
#include "GenericCallback.h"
#include "PlatformCAAnimationRemote.h"
@@ -219,8 +218,10 @@
WebCore::Color pageExtendedBackgroundColor() const { return m_pageExtendedBackgroundColor; }
void setPageExtendedBackgroundColor(WebCore::Color color) { m_pageExtendedBackgroundColor = color; }
+#if PLATFORM(MAC)
WebCore::IntPoint scrollPosition() const { return m_scrollPosition; }
void setScrollPosition(WebCore::IntPoint p) { m_scrollPosition = p; }
+#endif
double pageScaleFactor() const { return m_pageScaleFactor; }
void setPageScaleFactor(double pageScaleFactor) { m_pageScaleFactor = pageScaleFactor; }
@@ -271,9 +272,6 @@
bool hasEditorState() const { return !!m_editorState; }
const EditorState& editorState() const { return m_editorState.value(); }
void setEditorState(const EditorState& editorState) { m_editorState = editorState; }
-
- std::optional<DynamicViewportSizeUpdateID> dynamicViewportSizeUpdateID() const { return m_dynamicViewportSizeUpdateID; }
- void setDynamicViewportSizeUpdateID(DynamicViewportSizeUpdateID resizeID) { m_dynamicViewportSizeUpdateID = resizeID; }
private:
WebCore::GraphicsLayer::PlatformLayerID m_rootLayerID;
@@ -292,7 +290,9 @@
WebCore::LayoutSize m_baseLayoutViewportSize;
WebCore::LayoutPoint m_minStableLayoutViewportOrigin;
WebCore::LayoutPoint m_maxStableLayoutViewportOrigin;
+#if PLATFORM(MAC)
WebCore::IntPoint m_scrollPosition;
+#endif
WebCore::Color m_pageExtendedBackgroundColor;
double m_pageScaleFactor { 1 };
double m_minimumScaleFactor { 1 };
@@ -309,8 +309,7 @@
bool m_viewportMetaTagCameFromImageDocument { false };
bool m_isInStableState { false };
- std::optional<EditorState> m_editorState;
- std::optional<DynamicViewportSizeUpdateID> m_dynamicViewportSizeUpdateID;
+ std::optional<EditorState> m_editorState { std::nullopt };
};
} // namespace WebKit
Modified: tags/Safari-606.1.20/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm (232599 => 232600)
--- tags/Safari-606.1.20/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm 2018-06-07 21:05:29 UTC (rev 232599)
+++ tags/Safari-606.1.20/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm 2018-06-07 21:16:16 UTC (rev 232600)
@@ -533,8 +533,9 @@
encoder << m_minStableLayoutViewportOrigin;
encoder << m_maxStableLayoutViewportOrigin;
+#if PLATFORM(MAC)
encoder << m_scrollPosition;
-
+#endif
encoder << m_pageExtendedBackgroundColor;
encoder << m_pageScaleFactor;
encoder << m_minimumScaleFactor;
@@ -562,8 +563,6 @@
encoder << hasEditorState();
if (m_editorState)
encoder << *m_editorState;
-
- encoder << m_dynamicViewportSizeUpdateID;
}
bool RemoteLayerTreeTransaction::decode(IPC::Decoder& decoder, RemoteLayerTreeTransaction& result)
@@ -625,9 +624,11 @@
if (!decoder.decode(result.m_maxStableLayoutViewportOrigin))
return false;
-
+
+#if PLATFORM(MAC)
if (!decoder.decode(result.m_scrollPosition))
return false;
+#endif
if (!decoder.decode(result.m_pageExtendedBackgroundColor))
return false;
@@ -691,9 +692,6 @@
result.setEditorState(editorState);
}
- if (!decoder.decode(result.m_dynamicViewportSizeUpdateID))
- return false;
-
return true;
}
Deleted: tags/Safari-606.1.20/Source/WebKit/Shared/ios/DynamicViewportSizeUpdate.h (232599 => 232600)
--- tags/Safari-606.1.20/Source/WebKit/Shared/ios/DynamicViewportSizeUpdate.h 2018-06-07 21:05:29 UTC (rev 232599)
+++ tags/Safari-606.1.20/Source/WebKit/Shared/ios/DynamicViewportSizeUpdate.h 2018-06-07 21:16:16 UTC (rev 232600)
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2018 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.
- */
-
-#pragma once
-
-namespace WebKit {
-
-typedef uint64_t DynamicViewportSizeUpdateID;
-
-enum class DynamicViewportUpdateMode {
- NotResizing,
- ResizingWithAnimation,
- ResizingWithDocumentHidden,
-};
-
-} // namespace WebKit
Modified: tags/Safari-606.1.20/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm (232599 => 232600)
--- tags/Safari-606.1.20/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2018-06-07 21:05:29 UTC (rev 232599)
+++ tags/Safari-606.1.20/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm 2018-06-07 21:16:16 UTC (rev 232600)
@@ -33,7 +33,6 @@
#import "APISerializedScriptValue.h"
#import "CompletionHandlerCallChecker.h"
#import "DiagnosticLoggingClient.h"
-#import "DynamicViewportSizeUpdate.h"
#import "FindClient.h"
#import "FrontBoardServicesSPI.h"
#import "FullscreenClient.h"
@@ -177,6 +176,12 @@
- (UIViewController *)_viewControllerForSupportedInterfaceOrientations;
@end
+enum class DynamicViewportUpdateMode {
+ NotResizing,
+ ResizingWithAnimation,
+ ResizingWithDocumentHidden,
+};
+
#endif // PLATFORM(IOS)
#if PLATFORM(IOS)
@@ -306,10 +311,9 @@
BOOL _hasCommittedLoadForMainFrame;
BOOL _needsResetViewStateAfterCommitLoadForMainFrame;
uint64_t _firstPaintAfterCommitLoadTransactionID;
- WebKit::DynamicViewportUpdateMode _dynamicViewportUpdateMode;
- WebKit::DynamicViewportSizeUpdateID _currentDynamicViewportSizeUpdateID;
+ DynamicViewportUpdateMode _dynamicViewportUpdateMode;
CATransform3D _resizeAnimationTransformAdjustments;
- CGFloat _animatedResizeOriginalContentWidth;
+ std::optional<uint64_t> _resizeAnimationTransformTransactionID;
RetainPtr<UIView> _resizeAnimationView;
CGFloat _lastAdjustmentForScroller;
std::optional<CGRect> _frozenVisibleContentRect;
@@ -344,8 +348,6 @@
BOOL _hadDelayedUpdateVisibleContentRects;
int _activeAnimatedResizeCount;
- BOOL _waitingForEndAnimatedResize;
- BOOL _waitingForCommitAfterAnimatedResize;
Vector<WTF::Function<void ()>> _snapshotsDeferredDuringResize;
RetainPtr<NSMutableArray> _stableStatePresentationUpdateCallbacks;
@@ -355,13 +357,15 @@
BOOL _hasScheduledVisibleRectUpdate;
BOOL _visibleContentRectUpdateScheduledFromScrollViewInStableState;
Vector<BlockPtr<void ()>> _visibleContentRectUpdateCallbacks;
-
- _WKDragInteractionPolicy _dragInteractionPolicy;
#endif
#if PLATFORM(MAC)
std::unique_ptr<WebKit::WebViewImpl> _impl;
RetainPtr<WKTextFinderClient> _textFinderClient;
#endif
+
+#if PLATFORM(IOS)
+ _WKDragInteractionPolicy _dragInteractionPolicy;
+#endif
}
- (instancetype)initWithFrame:(CGRect)frame
@@ -1661,7 +1665,7 @@
- (void)_processDidExit
{
[self _hidePasswordView];
- if (!_customContentView && _dynamicViewportUpdateMode != WebKit::DynamicViewportUpdateMode::NotResizing) {
+ if (!_customContentView && _dynamicViewportUpdateMode != DynamicViewportUpdateMode::NotResizing) {
NSUInteger indexOfResizeAnimationView = [[_scrollView subviews] indexOfObject:_resizeAnimationView.get()];
[_scrollView insertSubview:_contentView.get() atIndex:indexOfResizeAnimationView];
[_scrollView insertSubview:[_contentView unscaledView] atIndex:indexOfResizeAnimationView + 1];
@@ -1679,10 +1683,7 @@
_initialScaleFactor = 1;
_hasCommittedLoadForMainFrame = NO;
_needsResetViewStateAfterCommitLoadForMainFrame = NO;
- _dynamicViewportUpdateMode = WebKit::DynamicViewportUpdateMode::NotResizing;
- _waitingForEndAnimatedResize = NO;
- _waitingForCommitAfterAnimatedResize = NO;
- _animatedResizeOriginalContentWidth = 0;
+ _dynamicViewportUpdateMode = DynamicViewportUpdateMode::NotResizing;
[_contentView setHidden:NO];
_scrollOffsetToRestore = std::nullopt;
_unobscuredCenterToRestore = std::nullopt;
@@ -1698,6 +1699,7 @@
_firstPaintAfterCommitLoadTransactionID = 0;
_firstTransactionIDAfterPageRestore = std::nullopt;
+ _resizeAnimationTransformTransactionID = std::nullopt;
_hasScheduledVisibleRectUpdate = NO;
_commitDidRestoreScrollPosition = NO;
@@ -1753,49 +1755,6 @@
return WTF::areEssentiallyEqual(a, b);
}
-- (void)_didCommitLayerTreeDuringAnimatedResize:(const WebKit::RemoteLayerTreeTransaction&)layerTreeTransaction
-{
- auto updateID = layerTreeTransaction.dynamicViewportSizeUpdateID();
- if (updateID && *updateID == _currentDynamicViewportSizeUpdateID) {
- double pageScale = layerTreeTransaction.pageScaleFactor();
- WebCore::IntPoint scrollPosition = layerTreeTransaction.scrollPosition();
-
- CGFloat animatingScaleTarget = [[_resizeAnimationView layer] transform].m11;
- double currentTargetScale = animatingScaleTarget * [[_contentView layer] transform].m11;
- double scale = pageScale / currentTargetScale;
- _resizeAnimationTransformAdjustments = CATransform3DMakeScale(scale, scale, 1);
-
- CGPoint newContentOffset = [self _contentOffsetAdjustedForObscuredInset:CGPointMake(scrollPosition.x() * pageScale, scrollPosition.y() * pageScale)];
- CGPoint currentContentOffset = [_scrollView contentOffset];
-
- _resizeAnimationTransformAdjustments.m41 = (currentContentOffset.x - newContentOffset.x) / animatingScaleTarget;
- _resizeAnimationTransformAdjustments.m42 = (currentContentOffset.y - newContentOffset.y) / animatingScaleTarget;
-
- [_resizeAnimationView layer].sublayerTransform = _resizeAnimationTransformAdjustments;
-
- // If we've already passed endAnimatedResize, immediately complete
- // the resize when we have an up-to-date layer tree. Otherwise,
- // we will defer completion until endAnimatedResize.
- _waitingForCommitAfterAnimatedResize = NO;
- if (!_waitingForEndAnimatedResize)
- [self _didCompleteAnimatedResize];
-
- return;
- }
-
- // If a commit arrives during the live part of a resize but before the
- // layer tree takes the current resize into account, it could change the
- // WKContentView's size. Update the resizeAnimationView's scale to ensure
- // we continue to fill the width of the resize target.
-
- if (_waitingForEndAnimatedResize)
- return;
-
- auto newViewLayoutSize = [self activeViewLayoutSize:self.bounds];
- CGFloat resizeAnimationViewScale = _animatedResizeOriginalContentWidth / newViewLayoutSize.width();
- [[_resizeAnimationView layer] setSublayerTransform:CATransform3DMakeScale(resizeAnimationViewScale, resizeAnimationViewScale, 1)];
-}
-
- (void)_didCommitLayerTree:(const WebKit::RemoteLayerTreeTransaction&)layerTreeTransaction
{
if (![self usesStandardContentView])
@@ -1805,8 +1764,15 @@
bool needUpdateVisibleContentRects = _page->updateLayoutViewportParameters(layerTreeTransaction);
- if (_dynamicViewportUpdateMode != WebKit::DynamicViewportUpdateMode::NotResizing) {
- [self _didCommitLayerTreeDuringAnimatedResize:layerTreeTransaction];
+ if (_dynamicViewportUpdateMode != DynamicViewportUpdateMode::NotResizing) {
+ if (_resizeAnimationTransformTransactionID && layerTreeTransaction.transactionID() >= _resizeAnimationTransformTransactionID.value()) {
+ _resizeAnimationTransformTransactionID = std::nullopt;
+ [_resizeAnimationView layer].sublayerTransform = _resizeAnimationTransformAdjustments;
+ if (_dynamicViewportUpdateMode == DynamicViewportUpdateMode::ResizingWithDocumentHidden) {
+ [_contentView setHidden:NO];
+ [self _endAnimatedResize];
+ }
+ }
return;
}
@@ -1906,6 +1872,25 @@
_commitDidRestoreScrollPosition = NO;
}
+- (void)_dynamicViewportUpdateChangedTargetToScale:(double)newScale position:(CGPoint)newScrollPosition nextValidLayerTreeTransactionID:(uint64_t)nextValidLayerTreeTransactionID
+{
+ LOG_WITH_STREAM(VisibleRects, stream << "-[WKWebView " << _page->pageID() << " _dynamicViewportUpdateChangedTargetToScale:] " << newScale << " _dynamicViewportUpdateMode " << (int)_dynamicViewportUpdateMode);
+
+ if (_dynamicViewportUpdateMode != DynamicViewportUpdateMode::NotResizing) {
+ CGFloat animatingScaleTarget = [[_resizeAnimationView layer] transform].m11;
+ double currentTargetScale = animatingScaleTarget * [[_contentView layer] transform].m11;
+ double scale = newScale / currentTargetScale;
+ _resizeAnimationTransformAdjustments = CATransform3DMakeScale(scale, scale, 1);
+
+ CGPoint newContentOffset = [self _contentOffsetAdjustedForObscuredInset:CGPointMake(newScrollPosition.x * newScale, newScrollPosition.y * newScale)];
+ CGPoint currentContentOffset = [_scrollView contentOffset];
+
+ _resizeAnimationTransformAdjustments.m41 = (currentContentOffset.x - newContentOffset.x) / animatingScaleTarget;
+ _resizeAnimationTransformAdjustments.m42 = (currentContentOffset.y - newContentOffset.y) / animatingScaleTarget;
+ _resizeAnimationTransformTransactionID = nextValidLayerTreeTransactionID;
+ }
+}
+
- (void)_couldNotRestorePageState
{
// The gestureController may be waiting for the scroll position to be restored
@@ -1918,7 +1903,7 @@
- (void)_restorePageScrollPosition:(std::optional<WebCore::FloatPoint>)scrollPosition scrollOrigin:(WebCore::FloatPoint)scrollOrigin previousObscuredInset:(WebCore::FloatBoxExtent)obscuredInsets scale:(double)scale
{
- if (_dynamicViewportUpdateMode != WebKit::DynamicViewportUpdateMode::NotResizing)
+ if (_dynamicViewportUpdateMode != DynamicViewportUpdateMode::NotResizing)
return;
if (![self usesStandardContentView])
@@ -1936,7 +1921,7 @@
- (void)_restorePageStateToUnobscuredCenter:(std::optional<WebCore::FloatPoint>)center scale:(double)scale
{
- if (_dynamicViewportUpdateMode != WebKit::DynamicViewportUpdateMode::NotResizing)
+ if (_dynamicViewportUpdateMode != DynamicViewportUpdateMode::NotResizing)
return;
if (![self usesStandardContentView])
@@ -2051,7 +2036,7 @@
- (void)_scrollToContentScrollPosition:(WebCore::FloatPoint)scrollPosition scrollOrigin:(WebCore::IntPoint)scrollOrigin
{
- if (_commitDidRestoreScrollPosition || _dynamicViewportUpdateMode != WebKit::DynamicViewportUpdateMode::NotResizing)
+ if (_commitDidRestoreScrollPosition || _dynamicViewportUpdateMode != DynamicViewportUpdateMode::NotResizing)
return;
WebCore::FloatPoint contentOffset = WebCore::ScrollableArea::scrollOffsetFromPosition(scrollPosition, toFloatSize(scrollOrigin));
@@ -2631,7 +2616,7 @@
CGRect bounds = self.bounds;
[_scrollView setFrame:bounds];
- if (_dynamicViewportUpdateMode == WebKit::DynamicViewportUpdateMode::NotResizing) {
+ if (_dynamicViewportUpdateMode == DynamicViewportUpdateMode::NotResizing) {
if (!_overridesViewLayoutSize)
[self _dispatchSetViewLayoutSize:[self activeViewLayoutSize:self.bounds]];
if (!_overridesMaximumUnobscuredSize)
@@ -2793,7 +2778,7 @@
return;
}
- if (_dynamicViewportUpdateMode != WebKit::DynamicViewportUpdateMode::NotResizing
+ if (_dynamicViewportUpdateMode != DynamicViewportUpdateMode::NotResizing
|| (_needsResetViewStateAfterCommitLoadForMainFrame && ![_contentView sizeChangedSinceLastVisibleContentRectUpdate])
|| [_scrollView isZoomBouncing]
|| _currentlyAdjustingScrollViewInsetsForKeyboard)
@@ -2851,84 +2836,6 @@
_gestureController->didStartProvisionalLoadForMainFrame();
}
-static WebCore::FloatSize activeMaximumUnobscuredSize(WKWebView *webView, const CGRect& bounds)
-{
- return WebCore::FloatSize(webView->_overridesMaximumUnobscuredSize ? webView->_maximumUnobscuredSizeOverride : bounds.size);
-}
-
-static int32_t activeOrientation(WKWebView *webView)
-{
- return webView->_overridesInterfaceOrientation ? deviceOrientationForUIInterfaceOrientation(webView->_interfaceOrientationOverride) : webView->_page->deviceOrientation();
-}
-
-- (void)_didCompleteAnimatedResize
-{
- if (_dynamicViewportUpdateMode == WebKit::DynamicViewportUpdateMode::NotResizing)
- return;
-
- [_contentView setHidden:NO];
-
- if (!_resizeAnimationView) {
- // Paranoia. If _resizeAnimationView is null we'll end up setting a zero scale on the content view.
- RELEASE_LOG_IF_ALLOWED("%p -[WKWebView _endAnimatedResize:] - _resizeAnimationView is nil", self);
- _dynamicViewportUpdateMode = WebKit::DynamicViewportUpdateMode::NotResizing;
- return;
- }
-
- --_activeAnimatedResizeCount;
- NSUInteger indexOfResizeAnimationView = [[_scrollView subviews] indexOfObject:_resizeAnimationView.get()];
- [_scrollView insertSubview:_contentView.get() atIndex:indexOfResizeAnimationView];
- [_scrollView insertSubview:[_contentView unscaledView] atIndex:indexOfResizeAnimationView + 1];
-
- CALayer *contentLayer = [_contentView layer];
- CGFloat adjustmentScale = _resizeAnimationTransformAdjustments.m11;
- contentLayer.sublayerTransform = CATransform3DIdentity;
-
- CGFloat animatingScaleTarget = [[_resizeAnimationView layer] transform].m11;
- CATransform3D contentLayerTransform = contentLayer.transform;
- CGFloat currentScale = [[_resizeAnimationView layer] transform].m11 * contentLayerTransform.m11;
-
- // We cannot use [UIScrollView setZoomScale:] directly because the UIScrollView delegate would get a callback with
- // an invalid contentOffset. The real content offset is only set below.
- // Since there is no public API for setting both the zoomScale and the contentOffset, we set the zoomScale manually
- // on the zoom layer and then only change the contentOffset.
- CGFloat adjustedScale = adjustmentScale * currentScale;
- contentLayerTransform.m11 = adjustedScale;
- contentLayerTransform.m22 = adjustedScale;
- contentLayer.transform = contentLayerTransform;
-
- CGPoint currentScrollOffset = [_scrollView contentOffset];
- double horizontalScrollAdjustement = _resizeAnimationTransformAdjustments.m41 * animatingScaleTarget;
- double verticalScrollAdjustment = _resizeAnimationTransformAdjustments.m42 * animatingScaleTarget;
-
- [_scrollView setContentSize:roundScrollViewContentSize(*_page, [_contentView frame].size)];
- [_scrollView setContentOffset:CGPointMake(currentScrollOffset.x - horizontalScrollAdjustement, currentScrollOffset.y - verticalScrollAdjustment)];
-
- [_resizeAnimationView removeFromSuperview];
- _resizeAnimationView = nil;
- _resizeAnimationTransformAdjustments = CATransform3DIdentity;
-
- _dynamicViewportUpdateMode = WebKit::DynamicViewportUpdateMode::NotResizing;
- [self _scheduleVisibleContentRectUpdate];
-
- CGRect newBounds = self.bounds;
- auto newViewLayoutSize = [self activeViewLayoutSize:newBounds];
- auto newMaximumUnobscuredSize = activeMaximumUnobscuredSize(self, newBounds);
- int32_t newOrientation = activeOrientation(self);
-
- if (!_lastSentViewLayoutSize || newViewLayoutSize != _lastSentViewLayoutSize.value())
- [self _dispatchSetViewLayoutSize:newViewLayoutSize];
-
- if (!_lastSentMaximumUnobscuredSize || newMaximumUnobscuredSize != _lastSentMaximumUnobscuredSize.value())
- [self _dispatchSetMaximumUnobscuredSize:WebCore::FloatSize(newMaximumUnobscuredSize)];
-
- if (!_lastSentDeviceOrientation || newOrientation != _lastSentDeviceOrientation.value())
- [self _dispatchSetDeviceOrientation:newOrientation];
-
- while (!_snapshotsDeferredDuringResize.isEmpty())
- _snapshotsDeferredDuringResize.takeLast()();
-}
-
- (void)_didFinishLoadForMainFrame
{
if (_gestureController)
@@ -4311,6 +4218,16 @@
#endif
#if PLATFORM(IOS)
+static WebCore::FloatSize activeMaximumUnobscuredSize(WKWebView *webView, const CGRect& bounds)
+{
+ return WebCore::FloatSize(webView->_overridesMaximumUnobscuredSize ? webView->_maximumUnobscuredSizeOverride : bounds.size);
+}
+
+static int32_t activeOrientation(WKWebView *webView)
+{
+ return webView->_overridesInterfaceOrientation ? deviceOrientationForUIInterfaceOrientation(webView->_interfaceOrientationOverride) : webView->_page->deviceOrientation();
+}
+
- (void (^)(void))_retainActiveFocusedState
{
++_activeFocusedStateRetainCount;
@@ -5092,7 +5009,7 @@
_overridesViewLayoutSize = YES;
_viewLayoutSizeOverride = viewLayoutSizeOverride;
- if (_dynamicViewportUpdateMode == WebKit::DynamicViewportUpdateMode::NotResizing)
+ if (_dynamicViewportUpdateMode == DynamicViewportUpdateMode::NotResizing)
[self _dispatchSetViewLayoutSize:WebCore::FloatSize(viewLayoutSizeOverride)];
}
@@ -5168,7 +5085,7 @@
_overridesInterfaceOrientation = YES;
_interfaceOrientationOverride = interfaceOrientation;
- if (_dynamicViewportUpdateMode == WebKit::DynamicViewportUpdateMode::NotResizing)
+ if (_dynamicViewportUpdateMode == DynamicViewportUpdateMode::NotResizing)
[self _dispatchSetDeviceOrientation:deviceOrientationForUIInterfaceOrientation(_interfaceOrientationOverride)];
}
@@ -5196,7 +5113,7 @@
_overridesMaximumUnobscuredSize = YES;
_maximumUnobscuredSizeOverride = size;
- if (_dynamicViewportUpdateMode == WebKit::DynamicViewportUpdateMode::NotResizing)
+ if (_dynamicViewportUpdateMode == DynamicViewportUpdateMode::NotResizing)
[self _dispatchSetMaximumUnobscuredSize:WebCore::FloatSize(size)];
}
@@ -5241,7 +5158,7 @@
return;
}
- _dynamicViewportUpdateMode = WebKit::DynamicViewportUpdateMode::ResizingWithAnimation;
+ _dynamicViewportUpdateMode = DynamicViewportUpdateMode::ResizingWithAnimation;
auto oldViewLayoutSize = [self activeViewLayoutSize:self.bounds];
auto oldMaximumUnobscuredSize = activeMaximumUnobscuredSize(self, oldBounds);
@@ -5260,7 +5177,7 @@
ASSERT_WITH_MESSAGE(!(_overridesViewLayoutSize && newViewLayoutSize.isEmpty()), "Clients controlling the layout size should maintain a valid layout size to minimize layouts.");
if (CGRectIsEmpty(newBounds) || newViewLayoutSize.isEmpty() || CGRectIsEmpty(futureUnobscuredRectInSelfCoordinates) || CGRectIsEmpty(contentViewBounds)) {
- _dynamicViewportUpdateMode = WebKit::DynamicViewportUpdateMode::NotResizing;
+ _dynamicViewportUpdateMode = DynamicViewportUpdateMode::NotResizing;
[self _frameOrBoundsChanged];
if (_overridesViewLayoutSize)
[self _dispatchSetViewLayoutSize:newViewLayoutSize];
@@ -5278,7 +5195,7 @@
&& oldMaximumUnobscuredSize == newMaximumUnobscuredSize
&& oldOrientation == newOrientation
&& UIEdgeInsetsEqualToEdgeInsets(oldObscuredInsets, newObscuredInsets)) {
- _dynamicViewportUpdateMode = WebKit::DynamicViewportUpdateMode::NotResizing;
+ _dynamicViewportUpdateMode = DynamicViewportUpdateMode::NotResizing;
[self _scheduleVisibleContentRectUpdate];
return;
}
@@ -5286,14 +5203,12 @@
++_activeAnimatedResizeCount;
_resizeAnimationTransformAdjustments = CATransform3DIdentity;
- if (!_resizeAnimationView) {
- NSUInteger indexOfContentView = [[_scrollView subviews] indexOfObject:_contentView.get()];
- _resizeAnimationView = adoptNS([[UIView alloc] init]);
- [_resizeAnimationView layer].name = @"ResizeAnimation";
- [_scrollView insertSubview:_resizeAnimationView.get() atIndex:indexOfContentView];
- [_resizeAnimationView addSubview:_contentView.get()];
- [_resizeAnimationView addSubview:[_contentView unscaledView]];
- }
+ NSUInteger indexOfContentView = [[_scrollView subviews] indexOfObject:_contentView.get()];
+ _resizeAnimationView = adoptNS([[UIView alloc] init]);
+ [_resizeAnimationView layer].name = @"ResizeAnimation";
+ [_scrollView insertSubview:_resizeAnimationView.get() atIndex:indexOfContentView];
+ [_resizeAnimationView addSubview:_contentView.get()];
+ [_resizeAnimationView addSubview:[_contentView unscaledView]];
CGSize contentSizeInContentViewCoordinates = contentViewBounds.size;
[_scrollView setMinimumZoomScale:std::min(newViewLayoutSize.width() / contentSizeInContentViewCoordinates.width, [_scrollView minimumZoomScale])];
@@ -5301,8 +5216,8 @@
// Compute the new scale to keep the current content width in the scrollview.
CGFloat oldWebViewWidthInContentViewCoordinates = oldUnobscuredContentRect.width();
- _animatedResizeOriginalContentWidth = std::min(contentSizeInContentViewCoordinates.width, oldWebViewWidthInContentViewCoordinates);
- CGFloat targetScale = newViewLayoutSize.width() / _animatedResizeOriginalContentWidth;
+ CGFloat visibleContentViewWidthInContentCoordinates = std::min(contentSizeInContentViewCoordinates.width, oldWebViewWidthInContentViewCoordinates);
+ CGFloat targetScale = newViewLayoutSize.width() / visibleContentViewWidthInContentCoordinates;
CGFloat resizeAnimationViewAnimationScale = targetScale / contentZoomScale(self);
[_resizeAnimationView setTransform:CGAffineTransformMakeScale(resizeAnimationViewAnimationScale, resizeAnimationViewAnimationScale)];
@@ -5330,7 +5245,7 @@
if (oldUnobscuredContentRect.maxY() > contentSizeInContentViewCoordinates.height - 1)
contentOffset.y = maxVerticalOffset;
if (oldUnobscuredContentRect.y() < 1)
- contentOffset.y = [self _initialContentOffsetForScrollView].y;
+ contentOffset.y = -_obscuredInsets.top;
// FIXME: if we have content centered after double tap to zoom, we should also try to keep that rect in view.
[_scrollView setContentSize:roundScrollViewContentSize(*_page, futureContentSizeInSelfCoordinates)];
@@ -5346,12 +5261,9 @@
_lastSentMaximumUnobscuredSize = newMaximumUnobscuredSize;
_lastSentDeviceOrientation = newOrientation;
- _page->dynamicViewportSizeUpdate(newViewLayoutSize, newMaximumUnobscuredSize, visibleRectInContentCoordinates, unobscuredRectInContentCoordinates, futureUnobscuredRectInSelfCoordinates, unobscuredSafeAreaInsetsExtent, targetScale, newOrientation, ++_currentDynamicViewportSizeUpdateID);
+ _page->dynamicViewportSizeUpdate(newViewLayoutSize, newMaximumUnobscuredSize, visibleRectInContentCoordinates, unobscuredRectInContentCoordinates, futureUnobscuredRectInSelfCoordinates, unobscuredSafeAreaInsetsExtent, targetScale, newOrientation);
if (WebKit::DrawingAreaProxy* drawingArea = _page->drawingArea())
drawingArea->setSize(WebCore::IntSize(newBounds.size));
-
- _waitingForCommitAfterAnimatedResize = YES;
- _waitingForEndAnimatedResize = YES;
}
- (void)_endAnimatedResize
@@ -5361,11 +5273,75 @@
if ([_customContentView respondsToSelector:@selector(web_endAnimatedResize)])
[_customContentView web_endAnimatedResize];
- // If we already have an up-to-date layer tree, immediately complete
- // the resize. Otherwise, we will defer completion until we do.
- _waitingForEndAnimatedResize = NO;
- if (!_waitingForCommitAfterAnimatedResize)
- [self _didCompleteAnimatedResize];
+ if (_dynamicViewportUpdateMode == DynamicViewportUpdateMode::NotResizing)
+ return;
+
+ _page->synchronizeDynamicViewportUpdate();
+
+ // synchronizeDynamicViewportUpdate() may cause this function to re-enter via _didCommitLayerTree, so check _dynamicViewportUpdateMode again.
+ if (_dynamicViewportUpdateMode == DynamicViewportUpdateMode::NotResizing)
+ return;
+
+ if (!_resizeAnimationView) {
+ // Paranoia. If _resizeAnimationView is null we'll end up setting a zero scale on the content view.
+ RELEASE_LOG_IF_ALLOWED("%p -[WKWebView _endAnimatedResize:] - _resizeAnimationView is nil", self);
+ _dynamicViewportUpdateMode = DynamicViewportUpdateMode::NotResizing;
+ [_contentView setHidden:NO];
+ return;
+ }
+
+ --_activeAnimatedResizeCount;
+ NSUInteger indexOfResizeAnimationView = [[_scrollView subviews] indexOfObject:_resizeAnimationView.get()];
+ [_scrollView insertSubview:_contentView.get() atIndex:indexOfResizeAnimationView];
+ [_scrollView insertSubview:[_contentView unscaledView] atIndex:indexOfResizeAnimationView + 1];
+
+ CALayer *contentViewLayer = [_contentView layer];
+ CGFloat adjustmentScale = _resizeAnimationTransformAdjustments.m11;
+ contentViewLayer.sublayerTransform = CATransform3DIdentity;
+
+ CGFloat animatingScaleTarget = [[_resizeAnimationView layer] transform].m11;
+ CALayer *contentLayer = [_contentView layer];
+ CATransform3D contentLayerTransform = contentLayer.transform;
+ CGFloat currentScale = [[_resizeAnimationView layer] transform].m11 * contentLayerTransform.m11;
+
+ // We cannot use [UIScrollView setZoomScale:] directly because the UIScrollView delegate would get a callback with
+ // an invalid contentOffset. The real content offset is only set below.
+ // Since there is no public API for setting both the zoomScale and the contentOffset, we set the zoomScale manually
+ // on the zoom layer and then only change the contentOffset.
+ CGFloat adjustedScale = adjustmentScale * currentScale;
+ contentLayerTransform.m11 = adjustedScale;
+ contentLayerTransform.m22 = adjustedScale;
+ contentLayer.transform = contentLayerTransform;
+
+ CGPoint currentScrollOffset = [_scrollView contentOffset];
+ double horizontalScrollAdjustement = _resizeAnimationTransformAdjustments.m41 * animatingScaleTarget;
+ double verticalScrollAdjustment = _resizeAnimationTransformAdjustments.m42 * animatingScaleTarget;
+
+ [_scrollView setContentSize:roundScrollViewContentSize(*_page, [_contentView frame].size)];
+ [_scrollView setContentOffset:CGPointMake(currentScrollOffset.x - horizontalScrollAdjustement, currentScrollOffset.y - verticalScrollAdjustment)];
+
+ [_resizeAnimationView removeFromSuperview];
+ _resizeAnimationView = nil;
+ _resizeAnimationTransformAdjustments = CATransform3DIdentity;
+
+ _dynamicViewportUpdateMode = DynamicViewportUpdateMode::NotResizing;
+ [_contentView setHidden:NO];
+ [self _scheduleVisibleContentRectUpdate];
+
+ CGRect newBounds = self.bounds;
+ auto newViewLayoutSize = [self activeViewLayoutSize:newBounds];
+ auto newMaximumUnobscuredSize = activeMaximumUnobscuredSize(self, newBounds);
+ int32_t newOrientation = activeOrientation(self);
+
+ if (!_lastSentViewLayoutSize || newViewLayoutSize != _lastSentViewLayoutSize.value())
+ [self _dispatchSetViewLayoutSize:newViewLayoutSize];
+ if (!_lastSentMaximumUnobscuredSize || newMaximumUnobscuredSize != _lastSentMaximumUnobscuredSize.value())
+ [self _dispatchSetMaximumUnobscuredSize:WebCore::FloatSize(newMaximumUnobscuredSize)];
+ if (!_lastSentDeviceOrientation || newOrientation != _lastSentDeviceOrientation.value())
+ [self _dispatchSetDeviceOrientation:newOrientation];
+
+ while (!_snapshotsDeferredDuringResize.isEmpty())
+ _snapshotsDeferredDuringResize.takeLast()();
}
- (void)_resizeWhileHidingContentWithUpdates:(void (^)(void))updateBlock
@@ -5372,9 +5348,9 @@
{
LOG_WITH_STREAM(VisibleRects, stream << "-[WKWebView " << _page->pageID() << " _resizeWhileHidingContentWithUpdates:]");
[self _beginAnimatedResizeWithUpdates:updateBlock];
- if (_dynamicViewportUpdateMode == WebKit::DynamicViewportUpdateMode::ResizingWithAnimation) {
+ if (_dynamicViewportUpdateMode == DynamicViewportUpdateMode::ResizingWithAnimation) {
[_contentView setHidden:YES];
- _dynamicViewportUpdateMode = WebKit::DynamicViewportUpdateMode::ResizingWithDocumentHidden;
+ _dynamicViewportUpdateMode = DynamicViewportUpdateMode::ResizingWithDocumentHidden;
}
}
@@ -5385,7 +5361,7 @@
- (void)_snapshotRect:(CGRect)rectInViewCoordinates intoImageOfWidth:(CGFloat)imageWidth completionHandler:(void(^)(CGImageRef))completionHandler
{
- if (_dynamicViewportUpdateMode != WebKit::DynamicViewportUpdateMode::NotResizing) {
+ if (_dynamicViewportUpdateMode != DynamicViewportUpdateMode::NotResizing) {
// Defer snapshotting until after the current resize completes.
void (^copiedCompletionHandler)(CGImageRef) = [completionHandler copy];
RetainPtr<WKWebView> retainedSelf = self;
Modified: tags/Safari-606.1.20/Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h (232599 => 232600)
--- tags/Safari-606.1.20/Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h 2018-06-07 21:05:29 UTC (rev 232599)
+++ tags/Safari-606.1.20/Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h 2018-06-07 21:16:16 UTC (rev 232600)
@@ -82,6 +82,7 @@
- (void)_didCommitLayerTree:(const WebKit::RemoteLayerTreeTransaction&)layerTreeTransaction;
- (void)_layerTreeCommitComplete;
+- (void)_dynamicViewportUpdateChangedTargetToScale:(double)newScale position:(CGPoint)newScrollPosition nextValidLayerTreeTransactionID:(uint64_t)nextValidLayerTreeTransactionID;
- (void)_couldNotRestorePageState;
- (void)_restorePageScrollPosition:(std::optional<WebCore::FloatPoint>)scrollPosition scrollOrigin:(WebCore::FloatPoint)scrollOrigin previousObscuredInset:(WebCore::FloatBoxExtent)insets scale:(double)scale;
- (void)_restorePageStateToUnobscuredCenter:(std::optional<WebCore::FloatPoint>)center scale:(double)scale; // FIXME: needs scroll origin?
@@ -104,8 +105,6 @@
- (void)_scheduleVisibleContentRectUpdate;
-- (void)_didCompleteAnimatedResize;
-
- (void)_didStartProvisionalLoadForMainFrame;
- (void)_didFinishLoadForMainFrame;
- (void)_didFailLoadForMainFrame;
Modified: tags/Safari-606.1.20/Source/WebKit/UIProcess/PageClient.h (232599 => 232600)
--- tags/Safari-606.1.20/Source/WebKit/UIProcess/PageClient.h 2018-06-07 21:05:29 UTC (rev 232599)
+++ tags/Safari-606.1.20/Source/WebKit/UIProcess/PageClient.h 2018-06-07 21:16:16 UTC (rev 232600)
@@ -284,6 +284,7 @@
virtual void didCommitLayerTree(const RemoteLayerTreeTransaction&) = 0;
virtual void layerTreeCommitComplete() = 0;
+ virtual void dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint& newScrollPosition, uint64_t transactionID) = 0;
virtual void couldNotRestorePageState() = 0;
virtual void restorePageState(std::optional<WebCore::FloatPoint> scrollPosition, const WebCore::FloatPoint& scrollOrigin, const WebCore::FloatBoxExtent& obscuredInsetsOnSave, double scale) = 0;
virtual void restorePageCenterAndScale(std::optional<WebCore::FloatPoint> center, double scale) = 0;
Modified: tags/Safari-606.1.20/Source/WebKit/UIProcess/WebPageProxy.cpp (232599 => 232600)
--- tags/Safari-606.1.20/Source/WebKit/UIProcess/WebPageProxy.cpp 2018-06-07 21:05:29 UTC (rev 232599)
+++ tags/Safari-606.1.20/Source/WebKit/UIProcess/WebPageProxy.cpp 2018-06-07 21:16:16 UTC (rev 232600)
@@ -5963,6 +5963,9 @@
#if PLATFORM(IOS)
m_firstLayerTreeTransactionIdAfterDidCommitLoad = 0;
m_lastVisibleContentRectUpdate = VisibleContentRectUpdateInfo();
+ m_dynamicViewportSizeUpdateWaitingForTarget = false;
+ m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit = false;
+ m_dynamicViewportSizeUpdateLayerTreeTransactionID = 0;
m_hasNetworkRequestsOnSuspended = false;
m_isKeyboardAnimatingIn = false;
m_isScrollingOrZooming = false;
Modified: tags/Safari-606.1.20/Source/WebKit/UIProcess/WebPageProxy.h (232599 => 232600)
--- tags/Safari-606.1.20/Source/WebKit/UIProcess/WebPageProxy.h 2018-06-07 21:05:29 UTC (rev 232599)
+++ tags/Safari-606.1.20/Source/WebKit/UIProcess/WebPageProxy.h 2018-06-07 21:16:16 UTC (rev 232600)
@@ -107,7 +107,6 @@
#endif
#if PLATFORM(COCOA)
-#include "DynamicViewportSizeUpdate.h"
#include "LayerRepresentation.h"
#include "TouchBarMenuData.h"
#include "TouchBarMenuItemData.h"
@@ -552,7 +551,8 @@
void overflowScrollWillStartScroll();
void overflowScrollDidEndScroll();
- void dynamicViewportSizeUpdate(const WebCore::FloatSize& viewLayoutSize, const WebCore::FloatSize& maximumUnobscuredSize, const WebCore::FloatRect& targetExposedContentRect, const WebCore::FloatRect& targetUnobscuredRect, const WebCore::FloatRect& targetUnobscuredRectInScrollViewCoordinates, const WebCore::FloatBoxExtent& unobscuredSafeAreaInsets, double targetScale, int32_t deviceOrientation, DynamicViewportSizeUpdateID);
+ void dynamicViewportSizeUpdate(const WebCore::FloatSize& viewLayoutSize, const WebCore::FloatSize& maximumUnobscuredSize, const WebCore::FloatRect& targetExposedContentRect, const WebCore::FloatRect& targetUnobscuredRect, const WebCore::FloatRect& targetUnobscuredRectInScrollViewCoordinates, const WebCore::FloatBoxExtent& unobscuredSafeAreaInsets, double targetScale, int32_t deviceOrientation);
+ void synchronizeDynamicViewportUpdate();
void setViewportConfigurationViewLayoutSize(const WebCore::FloatSize&);
void setMaximumUnobscuredSize(const WebCore::FloatSize&);
@@ -1663,6 +1663,7 @@
WebCore::FloatSize overrideScreenSize();
float textAutosizingWidth();
+ void dynamicViewportUpdateChangedTarget(double newTargetScale, const WebCore::FloatPoint& newScrollPosition, uint64_t dynamicViewportSizeUpdateID);
void couldNotRestorePageState();
void restorePageState(std::optional<WebCore::FloatPoint> scrollPosition, const WebCore::FloatPoint& scrollOrigin, const WebCore::FloatBoxExtent& obscuredInsetsOnSave, double scale);
void restorePageCenterAndScale(std::optional<WebCore::FloatPoint>, double scale);
@@ -1843,7 +1844,11 @@
VisibleContentRectUpdateInfo m_lastVisibleContentRectUpdate;
uint64_t m_firstLayerTreeTransactionIdAfterDidCommitLoad { 0 };
int32_t m_deviceOrientation { 0 };
+ uint64_t m_dynamicViewportSizeUpdateLayerTreeTransactionID { 0 };
+ uint64_t m_currentDynamicViewportSizeUpdateID { 0 };
bool m_hasReceivedLayerTreeTransactionAfterDidCommitLoad { true };
+ bool m_dynamicViewportSizeUpdateWaitingForTarget { false };
+ bool m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit { false };
bool m_hasNetworkRequestsOnSuspended { false };
bool m_isKeyboardAnimatingIn { false };
bool m_isScrollingOrZooming { false };
Modified: tags/Safari-606.1.20/Source/WebKit/UIProcess/WebPageProxy.messages.in (232599 => 232600)
--- tags/Safari-606.1.20/Source/WebKit/UIProcess/WebPageProxy.messages.in 2018-06-07 21:05:29 UTC (rev 232599)
+++ tags/Safari-606.1.20/Source/WebKit/UIProcess/WebPageProxy.messages.in 2018-06-07 21:16:16 UTC (rev 232600)
@@ -389,6 +389,7 @@
#endif
#if PLATFORM(IOS)
+ DynamicViewportUpdateChangedTarget(double newTargetScale, WebCore::FloatPoint newScrollPosition, uint64_t dynamicViewportSizeUpdateID)
CouldNotRestorePageState()
RestorePageState(std::optional<WebCore::FloatPoint> scrollPosition, WebCore::FloatPoint scrollOrigin, WebCore::RectEdges<float> obscuredInsetsOnSave, double scale)
RestorePageCenterAndScale(std::optional<WebCore::FloatPoint> unobscuredCenter, double scale)
Modified: tags/Safari-606.1.20/Source/WebKit/UIProcess/ios/PageClientImplIOS.h (232599 => 232600)
--- tags/Safari-606.1.20/Source/WebKit/UIProcess/ios/PageClientImplIOS.h 2018-06-07 21:05:29 UTC (rev 232599)
+++ tags/Safari-606.1.20/Source/WebKit/UIProcess/ios/PageClientImplIOS.h 2018-06-07 21:16:16 UTC (rev 232600)
@@ -120,6 +120,7 @@
void didCommitLayerTree(const RemoteLayerTreeTransaction&) override;
void layerTreeCommitComplete() override;
+ void dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint& newScrollPosition, uint64_t transactionID) override;
void couldNotRestorePageState() override;
void restorePageState(std::optional<WebCore::FloatPoint>, const WebCore::FloatPoint&, const WebCore::FloatBoxExtent&, double) override;
void restorePageCenterAndScale(std::optional<WebCore::FloatPoint>, double) override;
Modified: tags/Safari-606.1.20/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm (232599 => 232600)
--- tags/Safari-606.1.20/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm 2018-06-07 21:05:29 UTC (rev 232599)
+++ tags/Safari-606.1.20/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm 2018-06-07 21:16:16 UTC (rev 232600)
@@ -515,6 +515,11 @@
[m_contentView _layerTreeCommitComplete];
}
+void PageClientImpl::dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint& newScrollPosition, uint64_t nextValidLayerTreeTransactionID)
+{
+ [m_webView _dynamicViewportUpdateChangedTargetToScale:newScale position:newScrollPosition nextValidLayerTreeTransactionID:nextValidLayerTreeTransactionID];
+}
+
void PageClientImpl::couldNotRestorePageState()
{
[m_webView _couldNotRestorePageState];
Modified: tags/Safari-606.1.20/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm (232599 => 232600)
--- tags/Safari-606.1.20/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm 2018-06-07 21:05:29 UTC (rev 232599)
+++ tags/Safari-606.1.20/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm 2018-06-07 21:16:16 UTC (rev 232600)
@@ -306,7 +306,7 @@
m_pageClient.overflowScrollDidEndScroll();
}
-void WebPageProxy::dynamicViewportSizeUpdate(const FloatSize& viewLayoutSize, const WebCore::FloatSize& maximumUnobscuredSize, const FloatRect& targetExposedContentRect, const FloatRect& targetUnobscuredRect, const FloatRect& targetUnobscuredRectInScrollViewCoordinates, const WebCore::FloatBoxExtent& unobscuredSafeAreaInsets, double targetScale, int32_t deviceOrientation, DynamicViewportSizeUpdateID dynamicViewportSizeUpdateID)
+void WebPageProxy::dynamicViewportSizeUpdate(const FloatSize& viewLayoutSize, const WebCore::FloatSize& maximumUnobscuredSize, const FloatRect& targetExposedContentRect, const FloatRect& targetUnobscuredRect, const FloatRect& targetUnobscuredRectInScrollViewCoordinates, const WebCore::FloatBoxExtent& unobscuredSafeAreaInsets, double targetScale, int32_t deviceOrientation)
{
if (!isValid())
return;
@@ -313,12 +313,48 @@
hideValidationMessage();
- m_process->send(Messages::WebPage::DynamicViewportSizeUpdate(viewLayoutSize,
- maximumUnobscuredSize, targetExposedContentRect, targetUnobscuredRect,
- targetUnobscuredRectInScrollViewCoordinates, unobscuredSafeAreaInsets,
- targetScale, deviceOrientation, dynamicViewportSizeUpdateID), m_pageID);
+ m_dynamicViewportSizeUpdateWaitingForTarget = true;
+ m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit = true;
+ m_process->send(Messages::WebPage::DynamicViewportSizeUpdate(viewLayoutSize, maximumUnobscuredSize, targetExposedContentRect, targetUnobscuredRect, targetUnobscuredRectInScrollViewCoordinates, unobscuredSafeAreaInsets, targetScale, deviceOrientation, ++m_currentDynamicViewportSizeUpdateID), m_pageID);
}
+void WebPageProxy::synchronizeDynamicViewportUpdate()
+{
+ if (!isValid())
+ return;
+
+ if (m_dynamicViewportSizeUpdateWaitingForTarget) {
+ // We do not want the UIProcess to finish animated resize with the old content size, scale, etc.
+ // If that happens, the UIProcess would start pushing new VisibleContentRectUpdateInfo to the WebProcess with
+ // invalid informations.
+ //
+ // Ideally, the animated resize should just be transactional, and the UIProcess would remain in the "resize" state
+ // until both DynamicViewportUpdateChangedTarget and the associated commitLayerTree are finished.
+ // The tricky part with such implementation is if a second animated resize starts before the end of the previous one.
+ // In that case, the values used for the target state needs to be computed from the output of the previous animated resize.
+ //
+ // The following is a workaround to have the UIProcess in a consistent state.
+ // Instead of handling nested resize, we block the UIProcess until the animated resize finishes.
+ double newScale;
+ FloatPoint newScrollPosition;
+ uint64_t nextValidLayerTreeTransactionID;
+ if (m_process->sendSync(Messages::WebPage::SynchronizeDynamicViewportUpdate(), Messages::WebPage::SynchronizeDynamicViewportUpdate::Reply(newScale, newScrollPosition, nextValidLayerTreeTransactionID), m_pageID, 2_s)) {
+ m_dynamicViewportSizeUpdateWaitingForTarget = false;
+ m_dynamicViewportSizeUpdateLayerTreeTransactionID = nextValidLayerTreeTransactionID;
+ m_pageClient.dynamicViewportUpdateChangedTarget(newScale, newScrollPosition, nextValidLayerTreeTransactionID);
+ }
+
+ }
+
+ // If m_dynamicViewportSizeUpdateWaitingForTarget is false, we are waiting for the next valid frame with the hope it is the one for the new target.
+ // If m_dynamicViewportSizeUpdateWaitingForTarget is still true, this is a desperate attempt to get the valid frame before finishing the animation.
+ if (m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit)
+ m_drawingArea->waitForDidUpdateActivityState();
+
+ m_dynamicViewportSizeUpdateWaitingForTarget = false;
+ m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit = false;
+}
+
void WebPageProxy::setViewportConfigurationViewLayoutSize(const WebCore::FloatSize& size)
{
m_viewportConfigurationViewLayoutSize = size;
@@ -371,6 +407,11 @@
}
}
+ if (!m_dynamicViewportSizeUpdateWaitingForTarget && m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit) {
+ if (layerTreeTransaction.transactionID() >= m_dynamicViewportSizeUpdateLayerTreeTransactionID)
+ m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit = false;
+ }
+
m_pageClient.didCommitLayerTree(layerTreeTransaction);
// FIXME: Remove this special mechanism and fold it into the transaction's layout milestones.
@@ -863,6 +904,18 @@
return WebCore::screenSize().width();
}
+void WebPageProxy::dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint& newScrollPosition, uint64_t dynamicViewportSizeUpdateID)
+{
+ if (dynamicViewportSizeUpdateID != m_currentDynamicViewportSizeUpdateID)
+ return;
+
+ if (m_dynamicViewportSizeUpdateWaitingForTarget) {
+ m_dynamicViewportSizeUpdateLayerTreeTransactionID = downcast<RemoteLayerTreeDrawingAreaProxy>(*drawingArea()).nextLayerTreeTransactionID();
+ m_dynamicViewportSizeUpdateWaitingForTarget = false;
+ m_pageClient.dynamicViewportUpdateChangedTarget(newScale, newScrollPosition, m_dynamicViewportSizeUpdateLayerTreeTransactionID);
+ }
+}
+
void WebPageProxy::couldNotRestorePageState()
{
m_pageClient.couldNotRestorePageState();
Modified: tags/Safari-606.1.20/Source/WebKit/WebKit.xcodeproj/project.pbxproj (232599 => 232600)
--- tags/Safari-606.1.20/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2018-06-07 21:05:29 UTC (rev 232599)
+++ tags/Safari-606.1.20/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2018-06-07 21:16:16 UTC (rev 232600)
@@ -677,7 +677,6 @@
2DA049B8180CCD0A00AAFA9E /* GraphicsLayerCARemote.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DA049B6180CCD0A00AAFA9E /* GraphicsLayerCARemote.h */; };
2DA1E4FE18C02B6A00DBC929 /* WKLegacyPDFView.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DA1E4FC18C02B6A00DBC929 /* WKLegacyPDFView.h */; };
2DA1E4FF18C02B6A00DBC929 /* WKLegacyPDFView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DA1E4FD18C02B6A00DBC929 /* WKLegacyPDFView.mm */; };
- 2DA6731A20C754B1003CB401 /* DynamicViewportSizeUpdate.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DA6731920C754B1003CB401 /* DynamicViewportSizeUpdate.h */; };
2DA9449E1884E4F000ED86DB /* NativeWebKeyboardEventIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DA944971884E4F000ED86DB /* NativeWebKeyboardEventIOS.mm */; };
2DA9449F1884E4F000ED86DB /* NativeWebTouchEventIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DA944981884E4F000ED86DB /* NativeWebTouchEventIOS.mm */; };
2DA944A01884E4F000ED86DB /* WebIOSEventFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DA944991884E4F000ED86DB /* WebIOSEventFactory.h */; };
@@ -3056,7 +3055,6 @@
2DA049B6180CCD0A00AAFA9E /* GraphicsLayerCARemote.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsLayerCARemote.h; sourceTree = "<group>"; };
2DA1E4FC18C02B6A00DBC929 /* WKLegacyPDFView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKLegacyPDFView.h; path = ios/WKLegacyPDFView.h; sourceTree = "<group>"; };
2DA1E4FD18C02B6A00DBC929 /* WKLegacyPDFView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKLegacyPDFView.mm; path = ios/WKLegacyPDFView.mm; sourceTree = "<group>"; };
- 2DA6731920C754B1003CB401 /* DynamicViewportSizeUpdate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DynamicViewportSizeUpdate.h; path = ios/DynamicViewportSizeUpdate.h; sourceTree = "<group>"; };
2DA7FDCB18F88625008DDED0 /* FindIndicatorOverlayClientIOS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FindIndicatorOverlayClientIOS.h; path = ios/FindIndicatorOverlayClientIOS.h; sourceTree = "<group>"; };
2DA944971884E4F000ED86DB /* NativeWebKeyboardEventIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = NativeWebKeyboardEventIOS.mm; path = ios/NativeWebKeyboardEventIOS.mm; sourceTree = "<group>"; };
2DA944981884E4F000ED86DB /* NativeWebTouchEventIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = NativeWebTouchEventIOS.mm; path = ios/NativeWebTouchEventIOS.mm; sourceTree = "<group>"; };
@@ -5781,7 +5779,6 @@
isa = PBXGroup;
children = (
A7E93CEB192531AA00A1DC48 /* ChildProcessIOS.mm */,
- 2DA6731920C754B1003CB401 /* DynamicViewportSizeUpdate.h */,
2DA9449D1884E4F000ED86DB /* GestureTypes.h */,
C5BCE5DA1C50761D00CDE3FA /* InteractionInformationAtPosition.h */,
C5BCE5DB1C50761D00CDE3FA /* InteractionInformationAtPosition.mm */,
@@ -8944,7 +8941,6 @@
1A64229A12DD029200CAAE2C /* DrawingAreaMessages.h in Headers */,
BC2652171182608100243E12 /* DrawingAreaProxy.h in Headers */,
1A64230912DD09EB00CAAE2C /* DrawingAreaProxyMessages.h in Headers */,
- 2DA6731A20C754B1003CB401 /* DynamicViewportSizeUpdate.h in Headers */,
E105FE5418D7B9DE008F57A8 /* EditingRange.h in Headers */,
1AA41AB512C02EC4002BE67B /* EditorState.h in Headers */,
BC032DA810F437D10058C15A /* Encoder.h in Headers */,
Modified: tags/Safari-606.1.20/Source/WebKit/WebProcess/WebPage/WebPage.cpp (232599 => 232600)
--- tags/Safari-606.1.20/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2018-06-07 21:05:29 UTC (rev 232599)
+++ tags/Safari-606.1.20/Source/WebKit/WebProcess/WebPage/WebPage.cpp 2018-06-07 21:16:16 UTC (rev 232600)
@@ -3222,13 +3222,11 @@
layerTransaction.setAvoidsUnsafeArea(m_viewportConfiguration.avoidsUnsafeArea());
layerTransaction.setIsInStableState(m_isInStableState);
layerTransaction.setAllowsUserScaling(allowsUserScaling());
- if (m_pendingDynamicViewportSizeUpdateID) {
- layerTransaction.setDynamicViewportSizeUpdateID(*m_pendingDynamicViewportSizeUpdateID);
- m_pendingDynamicViewportSizeUpdateID = std::nullopt;
- }
#endif
+#if PLATFORM(MAC)
layerTransaction.setScrollPosition(frameView->scrollPosition());
+#endif
if (m_hasPendingEditorStateUpdate) {
layerTransaction.setEditorState(editorState());
Modified: tags/Safari-606.1.20/Source/WebKit/WebProcess/WebPage/WebPage.h (232599 => 232600)
--- tags/Safari-606.1.20/Source/WebKit/WebProcess/WebPage/WebPage.h 2018-06-07 21:05:29 UTC (rev 232599)
+++ tags/Safari-606.1.20/Source/WebKit/WebProcess/WebPage/WebPage.h 2018-06-07 21:16:16 UTC (rev 232600)
@@ -107,7 +107,6 @@
#endif
#if PLATFORM(COCOA)
-#include "DynamicViewportSizeUpdate.h"
#include <WebCore/VisibleSelection.h>
#include <wtf/RetainPtr.h>
OBJC_CLASS CALayer;
@@ -883,7 +882,8 @@
void setViewportConfigurationViewLayoutSize(const WebCore::FloatSize&);
void setMaximumUnobscuredSize(const WebCore::FloatSize&);
void setDeviceOrientation(int32_t);
- void dynamicViewportSizeUpdate(const WebCore::FloatSize& viewLayoutSize, const WebCore::FloatSize& maximumUnobscuredSize, const WebCore::FloatRect& targetExposedContentRect, const WebCore::FloatRect& targetUnobscuredRect, const WebCore::FloatRect& targetUnobscuredRectInScrollViewCoordinates, const WebCore::FloatBoxExtent& targetUnobscuredSafeAreaInsets, double scale, int32_t deviceOrientation, DynamicViewportSizeUpdateID);
+ void dynamicViewportSizeUpdate(const WebCore::FloatSize& viewLayoutSize, const WebCore::FloatSize& maximumUnobscuredSize, const WebCore::FloatRect& targetExposedContentRect, const WebCore::FloatRect& targetUnobscuredRect, const WebCore::FloatRect& targetUnobscuredRectInScrollViewCoordinates, const WebCore::FloatBoxExtent& targetUnobscuredSafeAreaInsets, double scale, int32_t deviceOrientation, uint64_t dynamicViewportSizeUpdateID);
+ void synchronizeDynamicViewportUpdate(double& newTargetScale, WebCore::FloatPoint& newScrollPosition, uint64_t& nextValidLayerTreeTransactionID);
std::optional<float> scaleFromUIProcess(const VisibleContentRectUpdateInfo&) const;
void updateVisibleContentRects(const VisibleContentRectUpdateInfo&, MonotonicTime oldestTimestamp);
bool scaleWasSetByUIProcess() const { return m_scaleWasSetByUIProcess; }
@@ -1650,7 +1650,6 @@
WebCore::FloatPoint m_pendingSyntheticClickLocation;
WebCore::FloatRect m_previousExposedContentRect;
uint64_t m_currentAssistedNodeIdentifier { 0 };
- std::optional<DynamicViewportSizeUpdateID> m_pendingDynamicViewportSizeUpdateID;
#endif
WebCore::Timer m_layerVolatilityTimer;
Modified: tags/Safari-606.1.20/Source/WebKit/WebProcess/WebPage/WebPage.messages.in (232599 => 232600)
--- tags/Safari-606.1.20/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2018-06-07 21:05:29 UTC (rev 232599)
+++ tags/Safari-606.1.20/Source/WebKit/WebProcess/WebPage/WebPage.messages.in 2018-06-07 21:16:16 UTC (rev 232600)
@@ -49,6 +49,7 @@
SetMaximumUnobscuredSize(WebCore::FloatSize size)
SetDeviceOrientation(int32_t deviceOrientation)
DynamicViewportSizeUpdate(WebCore::FloatSize viewLayoutSize, WebCore::FloatSize maximumUnobscuredSize, WebCore::FloatRect targetExposedContentRect, WebCore::FloatRect targetUnobscuredRect, WebCore::FloatRect targetUnobscuredRectInScrollViewCoordinates, WebCore::RectEdges<float> targetUnobscuredSafeAreaInsets, double scale, int32_t deviceOrientation, uint64_t dynamicViewportSizeUpdateID)
+ SynchronizeDynamicViewportUpdate() -> (double newTargetScale, WebCore::FloatPoint newScrollPosition, uint64_t nextValidLayerTreeTransactionID)
HandleTap(WebCore::IntPoint point, uint64_t lastLayerTreeTransactionId)
PotentialTapAtPosition(uint64_t requestID, WebCore::FloatPoint point)
Modified: tags/Safari-606.1.20/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (232599 => 232600)
--- tags/Safari-606.1.20/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2018-06-07 21:05:29 UTC (rev 232599)
+++ tags/Safari-606.1.20/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm 2018-06-07 21:16:16 UTC (rev 232600)
@@ -2495,7 +2495,7 @@
}
}
-void WebPage::dynamicViewportSizeUpdate(const FloatSize& viewLayoutSize, const WebCore::FloatSize& maximumUnobscuredSize, const FloatRect& targetExposedContentRect, const FloatRect& targetUnobscuredRect, const WebCore::FloatRect& targetUnobscuredRectInScrollViewCoordinates, const WebCore::FloatBoxExtent& targetUnobscuredSafeAreaInsets, double targetScale, int32_t deviceOrientation, DynamicViewportSizeUpdateID dynamicViewportSizeUpdateID)
+void WebPage::dynamicViewportSizeUpdate(const FloatSize& viewLayoutSize, const WebCore::FloatSize& maximumUnobscuredSize, const FloatRect& targetExposedContentRect, const FloatRect& targetUnobscuredRect, const WebCore::FloatRect& targetUnobscuredRectInScrollViewCoordinates, const WebCore::FloatBoxExtent& targetUnobscuredSafeAreaInsets, double targetScale, int32_t deviceOrientation, uint64_t dynamicViewportSizeUpdateID)
{
SetForScope<bool> dynamicSizeUpdateGuard(m_inDynamicSizeUpdate, true);
// FIXME: this does not handle the cases where the content would change the content size or scroll position from _javascript_.
@@ -2672,9 +2672,16 @@
m_drawingArea->scheduleCompositingLayerFlush();
- m_pendingDynamicViewportSizeUpdateID = dynamicViewportSizeUpdateID;
+ send(Messages::WebPageProxy::DynamicViewportUpdateChangedTarget(pageScaleFactor(), frameView.scrollPosition(), dynamicViewportSizeUpdateID));
}
+void WebPage::synchronizeDynamicViewportUpdate(double& newTargetScale, FloatPoint& newScrollPosition, uint64_t& nextValidLayerTreeTransactionID)
+{
+ newTargetScale = pageScaleFactor();
+ newScrollPosition = m_page->mainFrame().view()->scrollPosition();
+ nextValidLayerTreeTransactionID = downcast<RemoteLayerTreeDrawingArea>(*m_drawingArea).nextTransactionID();
+}
+
void WebPage::resetViewportDefaultConfiguration(WebFrame* frame, bool hasMobileDocType)
{
LOG_WITH_STREAM(VisibleRects, stream << "WebPage " << m_pageID << " resetViewportDefaultConfiguration");