Changeset 232544 in webkit
- Timestamp:
- Jun 6, 2018 9:32:26 AM (6 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 1 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r232535 r232544 1 2018-06-06 Tim Horton <timothy_horton@apple.com> 2 3 Move animated resize into the layer tree transaction, and make it asynchronous 4 https://bugs.webkit.org/show_bug.cgi?id=186130 5 <rdar://problem/38477288> 6 7 Reviewed by Simon Fraser. 8 9 * Shared/RemoteLayerTree/RemoteLayerTreeTransaction.h: 10 (WebKit::RemoteLayerTreeTransaction::setScrollPosition): 11 (WebKit::RemoteLayerTreeTransaction::dynamicViewportSizeUpdateID const): 12 (WebKit::RemoteLayerTreeTransaction::setDynamicViewportSizeUpdateID): 13 * Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm: 14 (WebKit::RemoteLayerTreeTransaction::encode const): 15 (WebKit::RemoteLayerTreeTransaction::decode): 16 * WebProcess/WebPage/WebPage.cpp: 17 (WebKit::WebPage::willCommitLayerTree): 18 Add scrollPosition to the transaction on all platforms, not just Mac. 19 Add the optional dynamicViewportSizeUpdateID to the transaction, representing 20 the most recent dynamicViewportSizeUpdate that commit contains, if any. 21 22 * Shared/ios/DynamicViewportSizeUpdate.h: 23 Added a typedef for DynamicViewportSizeUpdateID, and move the mode enum here. 24 25 * UIProcess/ios/PageClientImplIOS.h: 26 * UIProcess/ios/PageClientImplIOS.mm: 27 (WebKit::PageClientImpl::dynamicViewportUpdateChangedTarget): Deleted. 28 * UIProcess/PageClient.h: 29 * UIProcess/WebPageProxy.cpp: 30 (WebKit::WebPageProxy::resetState): 31 * UIProcess/WebPageProxy.h: 32 * UIProcess/WebPageProxy.messages.in: 33 * UIProcess/ios/WebPageProxyIOS.mm: 34 (WebKit::WebPageProxy::dynamicViewportSizeUpdate): 35 (WebKit::WebPageProxy::didCommitLayerTree): 36 (WebKit::WebPageProxy::synchronizeDynamicViewportUpdate): Deleted. 37 (WebKit::WebPageProxy::dynamicViewportUpdateChangedTarget): Deleted. 38 * WebProcess/WebPage/WebPage.h: 39 * WebProcess/WebPage/WebPage.messages.in: 40 * WebProcess/WebPage/ios/WebPageIOS.mm: 41 (WebKit::WebPage::dynamicViewportSizeUpdate): 42 (WebKit::WebPage::synchronizeDynamicViewportUpdate): Deleted. 43 Remove dynamicViewportUpdateChangedTarget and synchronizeDynamicViewportUpdate. 44 Move dynamicViewportSizeUpdateID maintenance into WKWebView. 45 46 * UIProcess/API/Cocoa/WKWebView.mm: 47 (-[WKWebView _processDidExit]): 48 Remove _resizeAnimationTransformTransactionID. We now instead pack 49 the resize ID inside the transaction, instead of separately sending 50 back a transaction ID to wait for. 51 52 (-[WKWebView _didCommitLayerTreeDuringAnimatedResize:]): 53 (-[WKWebView _didCommitLayerTree:]): 54 Added, factored out of _didCommitLayerTree:. 55 If the transaction includes the result of the most recently-sent resize, 56 store the requisite adjustments required to counter the new scale and 57 scroll offset, update the resizeAnimationView, and, if endAnimatedResize 58 has already been called, call _didCompleteAnimatedResize to tear down 59 the animation view and put things back together. 60 61 Add some code so that if a commit arrives before the resize, we update 62 the scale of the resize animation view to keep the width fitting. 63 64 (activeMaximumUnobscuredSize): 65 (activeOrientation): 66 Move these because the code that depends on them moved. 67 68 (-[WKWebView _didCompleteAnimatedResize]): 69 Broken out of _endAnimatedResize. This can now be called from 70 either endAnimatedResize or _didCommitLayerTreeDuringAnimatedResize, 71 depending on which is called first. 72 73 (-[WKWebView _beginAnimatedResizeWithUpdates:]): 74 Don't create a new resize view if we still have one. Otherwise, we'll 75 get the view ordering all wrong when making the second one. This 76 didn't previously cause trouble, because we don't have a lot of 77 WKScrollView subviews, but it totally could. 78 79 Adopt _initialContentOffsetForScrollView just to make this code more clear. 80 81 (-[WKWebView _endAnimatedResize]): 82 (-[WKWebView _dynamicViewportUpdateChangedTargetToScale:position:nextValidLayerTreeTransactionID:]): Deleted. 83 * UIProcess/API/Cocoa/WKWebViewInternal.h: 84 85 1 86 2018-06-05 Per Arne Vollan <pvollan@apple.com> 2 87 -
trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreeTransaction.h
r222233 r232544 26 26 #pragma once 27 27 28 #include "DynamicViewportSizeUpdate.h" 28 29 #include "EditorState.h" 29 30 #include "GenericCallback.h" … … 219 220 void setPageExtendedBackgroundColor(WebCore::Color color) { m_pageExtendedBackgroundColor = color; } 220 221 221 #if PLATFORM(MAC)222 222 WebCore::IntPoint scrollPosition() const { return m_scrollPosition; } 223 223 void setScrollPosition(WebCore::IntPoint p) { m_scrollPosition = p; } 224 #endif225 224 226 225 double pageScaleFactor() const { return m_pageScaleFactor; } … … 273 272 const EditorState& editorState() const { return m_editorState.value(); } 274 273 void setEditorState(const EditorState& editorState) { m_editorState = editorState; } 274 275 std::optional<DynamicViewportSizeUpdateID> dynamicViewportSizeUpdateID() const { return m_dynamicViewportSizeUpdateID; } 276 void setDynamicViewportSizeUpdateID(DynamicViewportSizeUpdateID resizeID) { m_dynamicViewportSizeUpdateID = resizeID; } 275 277 276 278 private: … … 291 293 WebCore::LayoutPoint m_minStableLayoutViewportOrigin; 292 294 WebCore::LayoutPoint m_maxStableLayoutViewportOrigin; 293 #if PLATFORM(MAC)294 295 WebCore::IntPoint m_scrollPosition; 295 #endif296 296 WebCore::Color m_pageExtendedBackgroundColor; 297 297 double m_pageScaleFactor { 1 }; … … 310 310 bool m_isInStableState { false }; 311 311 312 std::optional<EditorState> m_editorState { std::nullopt }; 312 std::optional<EditorState> m_editorState; 313 std::optional<DynamicViewportSizeUpdateID> m_dynamicViewportSizeUpdateID; 313 314 }; 314 315 -
trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm
r232246 r232544 534 534 encoder << m_maxStableLayoutViewportOrigin; 535 535 536 #if PLATFORM(MAC)537 536 encoder << m_scrollPosition; 538 #endif 537 539 538 encoder << m_pageExtendedBackgroundColor; 540 539 encoder << m_pageScaleFactor; … … 564 563 if (m_editorState) 565 564 encoder << *m_editorState; 565 566 encoder << m_dynamicViewportSizeUpdateID; 566 567 } 567 568 … … 625 626 if (!decoder.decode(result.m_maxStableLayoutViewportOrigin)) 626 627 return false; 627 628 #if PLATFORM(MAC) 628 629 629 if (!decoder.decode(result.m_scrollPosition)) 630 630 return false; 631 #endif632 631 633 632 if (!decoder.decode(result.m_pageExtendedBackgroundColor)) … … 692 691 result.setEditorState(editorState); 693 692 } 693 694 if (!decoder.decode(result.m_dynamicViewportSizeUpdateID)) 695 return false; 694 696 695 697 return true; -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
r232523 r232544 34 34 #import "CompletionHandlerCallChecker.h" 35 35 #import "DiagnosticLoggingClient.h" 36 #import "DynamicViewportSizeUpdate.h" 36 37 #import "FindClient.h" 37 38 #import "FrontBoardServicesSPI.h" … … 177 178 @end 178 179 179 enum class DynamicViewportUpdateMode {180 NotResizing,181 ResizingWithAnimation,182 ResizingWithDocumentHidden,183 };184 185 180 #endif // PLATFORM(IOS) 186 181 … … 312 307 BOOL _needsResetViewStateAfterCommitLoadForMainFrame; 313 308 uint64_t _firstPaintAfterCommitLoadTransactionID; 314 DynamicViewportUpdateMode _dynamicViewportUpdateMode; 309 WebKit::DynamicViewportUpdateMode _dynamicViewportUpdateMode; 310 WebKit::DynamicViewportSizeUpdateID _currentDynamicViewportSizeUpdateID; 315 311 CATransform3D _resizeAnimationTransformAdjustments; 316 std::optional<uint64_t> _resizeAnimationTransformTransactionID;312 CGFloat _animatedResizeOriginalContentWidth; 317 313 RetainPtr<UIView> _resizeAnimationView; 318 314 CGFloat _lastAdjustmentForScroller; … … 349 345 350 346 int _activeAnimatedResizeCount; 347 BOOL _waitingForEndAnimatedResize; 348 BOOL _waitingForCommitAfterAnimatedResize; 351 349 352 350 Vector<WTF::Function<void ()>> _snapshotsDeferredDuringResize; … … 358 356 BOOL _visibleContentRectUpdateScheduledFromScrollViewInStableState; 359 357 Vector<BlockPtr<void ()>> _visibleContentRectUpdateCallbacks; 358 359 _WKDragInteractionPolicy _dragInteractionPolicy; 360 360 #endif 361 361 #if PLATFORM(MAC) 362 362 std::unique_ptr<WebKit::WebViewImpl> _impl; 363 363 RetainPtr<WKTextFinderClient> _textFinderClient; 364 #endif365 366 #if PLATFORM(IOS)367 _WKDragInteractionPolicy _dragInteractionPolicy;368 364 #endif 369 365 } … … 1664 1660 { 1665 1661 [self _hidePasswordView]; 1666 if (!_customContentView && _dynamicViewportUpdateMode != DynamicViewportUpdateMode::NotResizing) {1662 if (!_customContentView && _dynamicViewportUpdateMode != WebKit::DynamicViewportUpdateMode::NotResizing) { 1667 1663 NSUInteger indexOfResizeAnimationView = [[_scrollView subviews] indexOfObject:_resizeAnimationView.get()]; 1668 1664 [_scrollView insertSubview:_contentView.get() atIndex:indexOfResizeAnimationView]; … … 1682 1678 _hasCommittedLoadForMainFrame = NO; 1683 1679 _needsResetViewStateAfterCommitLoadForMainFrame = NO; 1684 _dynamicViewportUpdateMode = DynamicViewportUpdateMode::NotResizing; 1680 _dynamicViewportUpdateMode = WebKit::DynamicViewportUpdateMode::NotResizing; 1681 _waitingForEndAnimatedResize = NO; 1682 _waitingForCommitAfterAnimatedResize = NO; 1683 _animatedResizeOriginalContentWidth = 0; 1685 1684 [_contentView setHidden:NO]; 1686 1685 _scrollOffsetToRestore = std::nullopt; … … 1698 1697 _firstPaintAfterCommitLoadTransactionID = 0; 1699 1698 _firstTransactionIDAfterPageRestore = std::nullopt; 1700 _resizeAnimationTransformTransactionID = std::nullopt;1701 1699 1702 1700 _hasScheduledVisibleRectUpdate = NO; … … 1754 1752 } 1755 1753 1754 - (void)_didCommitLayerTreeDuringAnimatedResize:(const WebKit::RemoteLayerTreeTransaction&)layerTreeTransaction 1755 { 1756 auto updateID = layerTreeTransaction.dynamicViewportSizeUpdateID(); 1757 if (updateID && *updateID == _currentDynamicViewportSizeUpdateID) { 1758 double pageScale = layerTreeTransaction.pageScaleFactor(); 1759 WebCore::IntPoint scrollPosition = layerTreeTransaction.scrollPosition(); 1760 1761 CGFloat animatingScaleTarget = [[_resizeAnimationView layer] transform].m11; 1762 double currentTargetScale = animatingScaleTarget * [[_contentView layer] transform].m11; 1763 double scale = pageScale / currentTargetScale; 1764 _resizeAnimationTransformAdjustments = CATransform3DMakeScale(scale, scale, 1); 1765 1766 CGPoint newContentOffset = [self _contentOffsetAdjustedForObscuredInset:CGPointMake(scrollPosition.x() * pageScale, scrollPosition.y() * pageScale)]; 1767 CGPoint currentContentOffset = [_scrollView contentOffset]; 1768 1769 _resizeAnimationTransformAdjustments.m41 = (currentContentOffset.x - newContentOffset.x) / animatingScaleTarget; 1770 _resizeAnimationTransformAdjustments.m42 = (currentContentOffset.y - newContentOffset.y) / animatingScaleTarget; 1771 1772 [_resizeAnimationView layer].sublayerTransform = _resizeAnimationTransformAdjustments; 1773 1774 // If we've already passed endAnimatedResize, immediately complete 1775 // the resize when we have an up-to-date layer tree. Otherwise, 1776 // we will defer completion until endAnimatedResize. 1777 _waitingForCommitAfterAnimatedResize = NO; 1778 if (!_waitingForEndAnimatedResize) 1779 [self _didCompleteAnimatedResize]; 1780 1781 return; 1782 } 1783 1784 // If a commit arrives during the live part of a resize but before the 1785 // layer tree takes the current resize into account, it could change the 1786 // WKContentView's size. Update the resizeAnimationView's scale to ensure 1787 // we continue to fill the width of the resize target. 1788 1789 if (_waitingForEndAnimatedResize) 1790 return; 1791 1792 auto newViewLayoutSize = [self activeViewLayoutSize:self.bounds]; 1793 CGFloat resizeAnimationViewScale = _animatedResizeOriginalContentWidth / newViewLayoutSize.width(); 1794 [[_resizeAnimationView layer] setSublayerTransform:CATransform3DMakeScale(resizeAnimationViewScale, resizeAnimationViewScale, 1)]; 1795 } 1796 1756 1797 - (void)_didCommitLayerTree:(const WebKit::RemoteLayerTreeTransaction&)layerTreeTransaction 1757 1798 { … … 1763 1804 bool needUpdateVisibleContentRects = _page->updateLayoutViewportParameters(layerTreeTransaction); 1764 1805 1765 if (_dynamicViewportUpdateMode != DynamicViewportUpdateMode::NotResizing) { 1766 if (_resizeAnimationTransformTransactionID && layerTreeTransaction.transactionID() >= _resizeAnimationTransformTransactionID.value()) { 1767 _resizeAnimationTransformTransactionID = std::nullopt; 1768 [_resizeAnimationView layer].sublayerTransform = _resizeAnimationTransformAdjustments; 1769 if (_dynamicViewportUpdateMode == DynamicViewportUpdateMode::ResizingWithDocumentHidden) { 1770 [_contentView setHidden:NO]; 1771 [self _endAnimatedResize]; 1772 } 1773 } 1806 if (_dynamicViewportUpdateMode != WebKit::DynamicViewportUpdateMode::NotResizing) { 1807 [self _didCommitLayerTreeDuringAnimatedResize:layerTreeTransaction]; 1774 1808 return; 1775 1809 } … … 1871 1905 } 1872 1906 1873 - (void)_dynamicViewportUpdateChangedTargetToScale:(double)newScale position:(CGPoint)newScrollPosition nextValidLayerTreeTransactionID:(uint64_t)nextValidLayerTreeTransactionID1874 {1875 LOG_WITH_STREAM(VisibleRects, stream << "-[WKWebView " << _page->pageID() << " _dynamicViewportUpdateChangedTargetToScale:] " << newScale << " _dynamicViewportUpdateMode " << (int)_dynamicViewportUpdateMode);1876 1877 if (_dynamicViewportUpdateMode != DynamicViewportUpdateMode::NotResizing) {1878 CGFloat animatingScaleTarget = [[_resizeAnimationView layer] transform].m11;1879 double currentTargetScale = animatingScaleTarget * [[_contentView layer] transform].m11;1880 double scale = newScale / currentTargetScale;1881 _resizeAnimationTransformAdjustments = CATransform3DMakeScale(scale, scale, 1);1882 1883 CGPoint newContentOffset = [self _contentOffsetAdjustedForObscuredInset:CGPointMake(newScrollPosition.x * newScale, newScrollPosition.y * newScale)];1884 CGPoint currentContentOffset = [_scrollView contentOffset];1885 1886 _resizeAnimationTransformAdjustments.m41 = (currentContentOffset.x - newContentOffset.x) / animatingScaleTarget;1887 _resizeAnimationTransformAdjustments.m42 = (currentContentOffset.y - newContentOffset.y) / animatingScaleTarget;1888 _resizeAnimationTransformTransactionID = nextValidLayerTreeTransactionID;1889 }1890 }1891 1892 1907 - (void)_couldNotRestorePageState 1893 1908 { … … 1902 1917 - (void)_restorePageScrollPosition:(std::optional<WebCore::FloatPoint>)scrollPosition scrollOrigin:(WebCore::FloatPoint)scrollOrigin previousObscuredInset:(WebCore::FloatBoxExtent)obscuredInsets scale:(double)scale 1903 1918 { 1904 if (_dynamicViewportUpdateMode != DynamicViewportUpdateMode::NotResizing)1919 if (_dynamicViewportUpdateMode != WebKit::DynamicViewportUpdateMode::NotResizing) 1905 1920 return; 1906 1921 … … 1920 1935 - (void)_restorePageStateToUnobscuredCenter:(std::optional<WebCore::FloatPoint>)center scale:(double)scale 1921 1936 { 1922 if (_dynamicViewportUpdateMode != DynamicViewportUpdateMode::NotResizing)1937 if (_dynamicViewportUpdateMode != WebKit::DynamicViewportUpdateMode::NotResizing) 1923 1938 return; 1924 1939 … … 2035 2050 - (void)_scrollToContentScrollPosition:(WebCore::FloatPoint)scrollPosition scrollOrigin:(WebCore::IntPoint)scrollOrigin 2036 2051 { 2037 if (_commitDidRestoreScrollPosition || _dynamicViewportUpdateMode != DynamicViewportUpdateMode::NotResizing)2052 if (_commitDidRestoreScrollPosition || _dynamicViewportUpdateMode != WebKit::DynamicViewportUpdateMode::NotResizing) 2038 2053 return; 2039 2054 … … 2615 2630 [_scrollView setFrame:bounds]; 2616 2631 2617 if (_dynamicViewportUpdateMode == DynamicViewportUpdateMode::NotResizing) {2632 if (_dynamicViewportUpdateMode == WebKit::DynamicViewportUpdateMode::NotResizing) { 2618 2633 if (!_overridesViewLayoutSize) 2619 2634 [self _dispatchSetViewLayoutSize:[self activeViewLayoutSize:self.bounds]]; … … 2777 2792 } 2778 2793 2779 if (_dynamicViewportUpdateMode != DynamicViewportUpdateMode::NotResizing2794 if (_dynamicViewportUpdateMode != WebKit::DynamicViewportUpdateMode::NotResizing 2780 2795 || (_needsResetViewStateAfterCommitLoadForMainFrame && ![_contentView sizeChangedSinceLastVisibleContentRectUpdate]) 2781 2796 || [_scrollView isZoomBouncing] … … 2833 2848 if (_gestureController) 2834 2849 _gestureController->didStartProvisionalLoadForMainFrame(); 2850 } 2851 2852 static WebCore::FloatSize activeMaximumUnobscuredSize(WKWebView *webView, const CGRect& bounds) 2853 { 2854 return WebCore::FloatSize(webView->_overridesMaximumUnobscuredSize ? webView->_maximumUnobscuredSizeOverride : bounds.size); 2855 } 2856 2857 static int32_t activeOrientation(WKWebView *webView) 2858 { 2859 return webView->_overridesInterfaceOrientation ? deviceOrientationForUIInterfaceOrientation(webView->_interfaceOrientationOverride) : webView->_page->deviceOrientation(); 2860 } 2861 2862 - (void)_didCompleteAnimatedResize 2863 { 2864 if (_dynamicViewportUpdateMode == WebKit::DynamicViewportUpdateMode::NotResizing) 2865 return; 2866 2867 [_contentView setHidden:NO]; 2868 2869 if (!_resizeAnimationView) { 2870 // Paranoia. If _resizeAnimationView is null we'll end up setting a zero scale on the content view. 2871 RELEASE_LOG_IF_ALLOWED("%p -[WKWebView _endAnimatedResize:] - _resizeAnimationView is nil", self); 2872 _dynamicViewportUpdateMode = WebKit::DynamicViewportUpdateMode::NotResizing; 2873 return; 2874 } 2875 2876 --_activeAnimatedResizeCount; 2877 NSUInteger indexOfResizeAnimationView = [[_scrollView subviews] indexOfObject:_resizeAnimationView.get()]; 2878 [_scrollView insertSubview:_contentView.get() atIndex:indexOfResizeAnimationView]; 2879 [_scrollView insertSubview:[_contentView unscaledView] atIndex:indexOfResizeAnimationView + 1]; 2880 2881 CALayer *contentLayer = [_contentView layer]; 2882 CGFloat adjustmentScale = _resizeAnimationTransformAdjustments.m11; 2883 contentLayer.sublayerTransform = CATransform3DIdentity; 2884 2885 CGFloat animatingScaleTarget = [[_resizeAnimationView layer] transform].m11; 2886 CATransform3D contentLayerTransform = contentLayer.transform; 2887 CGFloat currentScale = [[_resizeAnimationView layer] transform].m11 * contentLayerTransform.m11; 2888 2889 // We cannot use [UIScrollView setZoomScale:] directly because the UIScrollView delegate would get a callback with 2890 // an invalid contentOffset. The real content offset is only set below. 2891 // Since there is no public API for setting both the zoomScale and the contentOffset, we set the zoomScale manually 2892 // on the zoom layer and then only change the contentOffset. 2893 CGFloat adjustedScale = adjustmentScale * currentScale; 2894 contentLayerTransform.m11 = adjustedScale; 2895 contentLayerTransform.m22 = adjustedScale; 2896 contentLayer.transform = contentLayerTransform; 2897 2898 CGPoint currentScrollOffset = [_scrollView contentOffset]; 2899 double horizontalScrollAdjustement = _resizeAnimationTransformAdjustments.m41 * animatingScaleTarget; 2900 double verticalScrollAdjustment = _resizeAnimationTransformAdjustments.m42 * animatingScaleTarget; 2901 2902 [_scrollView setContentSize:roundScrollViewContentSize(*_page, [_contentView frame].size)]; 2903 [_scrollView setContentOffset:CGPointMake(currentScrollOffset.x - horizontalScrollAdjustement, currentScrollOffset.y - verticalScrollAdjustment)]; 2904 2905 [_resizeAnimationView removeFromSuperview]; 2906 _resizeAnimationView = nil; 2907 _resizeAnimationTransformAdjustments = CATransform3DIdentity; 2908 2909 _dynamicViewportUpdateMode = WebKit::DynamicViewportUpdateMode::NotResizing; 2910 [self _scheduleVisibleContentRectUpdate]; 2911 2912 CGRect newBounds = self.bounds; 2913 auto newViewLayoutSize = [self activeViewLayoutSize:newBounds]; 2914 auto newMaximumUnobscuredSize = activeMaximumUnobscuredSize(self, newBounds); 2915 int32_t newOrientation = activeOrientation(self); 2916 2917 if (!_lastSentViewLayoutSize || newViewLayoutSize != _lastSentViewLayoutSize.value()) 2918 [self _dispatchSetViewLayoutSize:newViewLayoutSize]; 2919 2920 if (!_lastSentMaximumUnobscuredSize || newMaximumUnobscuredSize != _lastSentMaximumUnobscuredSize.value()) 2921 [self _dispatchSetMaximumUnobscuredSize:WebCore::FloatSize(newMaximumUnobscuredSize)]; 2922 2923 if (!_lastSentDeviceOrientation || newOrientation != _lastSentDeviceOrientation.value()) 2924 [self _dispatchSetDeviceOrientation:newOrientation]; 2925 2926 while (!_snapshotsDeferredDuringResize.isEmpty()) 2927 _snapshotsDeferredDuringResize.takeLast()(); 2835 2928 } 2836 2929 … … 4217 4310 4218 4311 #if PLATFORM(IOS) 4219 static WebCore::FloatSize activeMaximumUnobscuredSize(WKWebView *webView, const CGRect& bounds)4220 {4221 return WebCore::FloatSize(webView->_overridesMaximumUnobscuredSize ? webView->_maximumUnobscuredSizeOverride : bounds.size);4222 }4223 4224 static int32_t activeOrientation(WKWebView *webView)4225 {4226 return webView->_overridesInterfaceOrientation ? deviceOrientationForUIInterfaceOrientation(webView->_interfaceOrientationOverride) : webView->_page->deviceOrientation();4227 }4228 4229 4312 - (void (^)(void))_retainActiveFocusedState 4230 4313 { … … 5008 5091 _viewLayoutSizeOverride = viewLayoutSizeOverride; 5009 5092 5010 if (_dynamicViewportUpdateMode == DynamicViewportUpdateMode::NotResizing)5093 if (_dynamicViewportUpdateMode == WebKit::DynamicViewportUpdateMode::NotResizing) 5011 5094 [self _dispatchSetViewLayoutSize:WebCore::FloatSize(viewLayoutSizeOverride)]; 5012 5095 … … 5084 5167 _interfaceOrientationOverride = interfaceOrientation; 5085 5168 5086 if (_dynamicViewportUpdateMode == DynamicViewportUpdateMode::NotResizing)5169 if (_dynamicViewportUpdateMode == WebKit::DynamicViewportUpdateMode::NotResizing) 5087 5170 [self _dispatchSetDeviceOrientation:deviceOrientationForUIInterfaceOrientation(_interfaceOrientationOverride)]; 5088 5171 } … … 5112 5195 _maximumUnobscuredSizeOverride = size; 5113 5196 5114 if (_dynamicViewportUpdateMode == DynamicViewportUpdateMode::NotResizing)5197 if (_dynamicViewportUpdateMode == WebKit::DynamicViewportUpdateMode::NotResizing) 5115 5198 [self _dispatchSetMaximumUnobscuredSize:WebCore::FloatSize(size)]; 5116 5199 } … … 5157 5240 } 5158 5241 5159 _dynamicViewportUpdateMode = DynamicViewportUpdateMode::ResizingWithAnimation;5242 _dynamicViewportUpdateMode = WebKit::DynamicViewportUpdateMode::ResizingWithAnimation; 5160 5243 5161 5244 auto oldViewLayoutSize = [self activeViewLayoutSize:self.bounds]; … … 5176 5259 ASSERT_WITH_MESSAGE(!(_overridesViewLayoutSize && newViewLayoutSize.isEmpty()), "Clients controlling the layout size should maintain a valid layout size to minimize layouts."); 5177 5260 if (CGRectIsEmpty(newBounds) || newViewLayoutSize.isEmpty() || CGRectIsEmpty(futureUnobscuredRectInSelfCoordinates) || CGRectIsEmpty(contentViewBounds)) { 5178 _dynamicViewportUpdateMode = DynamicViewportUpdateMode::NotResizing;5261 _dynamicViewportUpdateMode = WebKit::DynamicViewportUpdateMode::NotResizing; 5179 5262 [self _frameOrBoundsChanged]; 5180 5263 if (_overridesViewLayoutSize) … … 5194 5277 && oldOrientation == newOrientation 5195 5278 && UIEdgeInsetsEqualToEdgeInsets(oldObscuredInsets, newObscuredInsets)) { 5196 _dynamicViewportUpdateMode = DynamicViewportUpdateMode::NotResizing;5279 _dynamicViewportUpdateMode = WebKit::DynamicViewportUpdateMode::NotResizing; 5197 5280 [self _scheduleVisibleContentRectUpdate]; 5198 5281 return; … … 5202 5285 _resizeAnimationTransformAdjustments = CATransform3DIdentity; 5203 5286 5204 NSUInteger indexOfContentView = [[_scrollView subviews] indexOfObject:_contentView.get()]; 5205 _resizeAnimationView = adoptNS([[UIView alloc] init]); 5206 [_resizeAnimationView layer].name = @"ResizeAnimation"; 5207 [_scrollView insertSubview:_resizeAnimationView.get() atIndex:indexOfContentView]; 5208 [_resizeAnimationView addSubview:_contentView.get()]; 5209 [_resizeAnimationView addSubview:[_contentView unscaledView]]; 5287 if (!_resizeAnimationView) { 5288 NSUInteger indexOfContentView = [[_scrollView subviews] indexOfObject:_contentView.get()]; 5289 _resizeAnimationView = adoptNS([[UIView alloc] init]); 5290 [_resizeAnimationView layer].name = @"ResizeAnimation"; 5291 [_scrollView insertSubview:_resizeAnimationView.get() atIndex:indexOfContentView]; 5292 [_resizeAnimationView addSubview:_contentView.get()]; 5293 [_resizeAnimationView addSubview:[_contentView unscaledView]]; 5294 } 5210 5295 5211 5296 CGSize contentSizeInContentViewCoordinates = contentViewBounds.size; … … 5215 5300 // Compute the new scale to keep the current content width in the scrollview. 5216 5301 CGFloat oldWebViewWidthInContentViewCoordinates = oldUnobscuredContentRect.width(); 5217 CGFloat visibleContentViewWidthInContentCoordinates= std::min(contentSizeInContentViewCoordinates.width, oldWebViewWidthInContentViewCoordinates);5218 CGFloat targetScale = newViewLayoutSize.width() / visibleContentViewWidthInContentCoordinates;5302 _animatedResizeOriginalContentWidth = std::min(contentSizeInContentViewCoordinates.width, oldWebViewWidthInContentViewCoordinates); 5303 CGFloat targetScale = newViewLayoutSize.width() / _animatedResizeOriginalContentWidth; 5219 5304 CGFloat resizeAnimationViewAnimationScale = targetScale / contentZoomScale(self); 5220 5305 [_resizeAnimationView setTransform:CGAffineTransformMakeScale(resizeAnimationViewAnimationScale, resizeAnimationViewAnimationScale)]; … … 5244 5329 contentOffset.y = maxVerticalOffset; 5245 5330 if (oldUnobscuredContentRect.y() < 1) 5246 contentOffset.y = -_obscuredInsets.top;5331 contentOffset.y = [self _initialContentOffsetForScrollView].y; 5247 5332 5248 5333 // FIXME: if we have content centered after double tap to zoom, we should also try to keep that rect in view. … … 5260 5345 _lastSentDeviceOrientation = newOrientation; 5261 5346 5262 _page->dynamicViewportSizeUpdate(newViewLayoutSize, newMaximumUnobscuredSize, visibleRectInContentCoordinates, unobscuredRectInContentCoordinates, futureUnobscuredRectInSelfCoordinates, unobscuredSafeAreaInsetsExtent, targetScale, newOrientation );5347 _page->dynamicViewportSizeUpdate(newViewLayoutSize, newMaximumUnobscuredSize, visibleRectInContentCoordinates, unobscuredRectInContentCoordinates, futureUnobscuredRectInSelfCoordinates, unobscuredSafeAreaInsetsExtent, targetScale, newOrientation, ++_currentDynamicViewportSizeUpdateID); 5263 5348 if (WebKit::DrawingAreaProxy* drawingArea = _page->drawingArea()) 5264 5349 drawingArea->setSize(WebCore::IntSize(newBounds.size)); 5350 5351 _waitingForCommitAfterAnimatedResize = YES; 5352 _waitingForEndAnimatedResize = YES; 5265 5353 } 5266 5354 … … 5272 5360 [_customContentView web_endAnimatedResize]; 5273 5361 5274 if (_dynamicViewportUpdateMode == DynamicViewportUpdateMode::NotResizing) 5275 return; 5276 5277 _page->synchronizeDynamicViewportUpdate(); 5278 5279 // synchronizeDynamicViewportUpdate() may cause this function to re-enter via _didCommitLayerTree, so check _dynamicViewportUpdateMode again. 5280 if (_dynamicViewportUpdateMode == DynamicViewportUpdateMode::NotResizing) 5281 return; 5282 5283 if (!_resizeAnimationView) { 5284 // Paranoia. If _resizeAnimationView is null we'll end up setting a zero scale on the content view. 5285 RELEASE_LOG_IF_ALLOWED("%p -[WKWebView _endAnimatedResize:] - _resizeAnimationView is nil", self); 5286 _dynamicViewportUpdateMode = DynamicViewportUpdateMode::NotResizing; 5287 [_contentView setHidden:NO]; 5288 return; 5289 } 5290 5291 --_activeAnimatedResizeCount; 5292 NSUInteger indexOfResizeAnimationView = [[_scrollView subviews] indexOfObject:_resizeAnimationView.get()]; 5293 [_scrollView insertSubview:_contentView.get() atIndex:indexOfResizeAnimationView]; 5294 [_scrollView insertSubview:[_contentView unscaledView] atIndex:indexOfResizeAnimationView + 1]; 5295 5296 CALayer *contentViewLayer = [_contentView layer]; 5297 CGFloat adjustmentScale = _resizeAnimationTransformAdjustments.m11; 5298 contentViewLayer.sublayerTransform = CATransform3DIdentity; 5299 5300 CGFloat animatingScaleTarget = [[_resizeAnimationView layer] transform].m11; 5301 CALayer *contentLayer = [_contentView layer]; 5302 CATransform3D contentLayerTransform = contentLayer.transform; 5303 CGFloat currentScale = [[_resizeAnimationView layer] transform].m11 * contentLayerTransform.m11; 5304 5305 // We cannot use [UIScrollView setZoomScale:] directly because the UIScrollView delegate would get a callback with 5306 // an invalid contentOffset. The real content offset is only set below. 5307 // Since there is no public API for setting both the zoomScale and the contentOffset, we set the zoomScale manually 5308 // on the zoom layer and then only change the contentOffset. 5309 CGFloat adjustedScale = adjustmentScale * currentScale; 5310 contentLayerTransform.m11 = adjustedScale; 5311 contentLayerTransform.m22 = adjustedScale; 5312 contentLayer.transform = contentLayerTransform; 5313 5314 CGPoint currentScrollOffset = [_scrollView contentOffset]; 5315 double horizontalScrollAdjustement = _resizeAnimationTransformAdjustments.m41 * animatingScaleTarget; 5316 double verticalScrollAdjustment = _resizeAnimationTransformAdjustments.m42 * animatingScaleTarget; 5317 5318 [_scrollView setContentSize:roundScrollViewContentSize(*_page, [_contentView frame].size)]; 5319 [_scrollView setContentOffset:CGPointMake(currentScrollOffset.x - horizontalScrollAdjustement, currentScrollOffset.y - verticalScrollAdjustment)]; 5320 5321 [_resizeAnimationView removeFromSuperview]; 5322 _resizeAnimationView = nil; 5323 _resizeAnimationTransformAdjustments = CATransform3DIdentity; 5324 5325 _dynamicViewportUpdateMode = DynamicViewportUpdateMode::NotResizing; 5326 [_contentView setHidden:NO]; 5327 [self _scheduleVisibleContentRectUpdate]; 5328 5329 CGRect newBounds = self.bounds; 5330 auto newViewLayoutSize = [self activeViewLayoutSize:newBounds]; 5331 auto newMaximumUnobscuredSize = activeMaximumUnobscuredSize(self, newBounds); 5332 int32_t newOrientation = activeOrientation(self); 5333 5334 if (!_lastSentViewLayoutSize || newViewLayoutSize != _lastSentViewLayoutSize.value()) 5335 [self _dispatchSetViewLayoutSize:newViewLayoutSize]; 5336 if (!_lastSentMaximumUnobscuredSize || newMaximumUnobscuredSize != _lastSentMaximumUnobscuredSize.value()) 5337 [self _dispatchSetMaximumUnobscuredSize:WebCore::FloatSize(newMaximumUnobscuredSize)]; 5338 if (!_lastSentDeviceOrientation || newOrientation != _lastSentDeviceOrientation.value()) 5339 [self _dispatchSetDeviceOrientation:newOrientation]; 5340 5341 while (!_snapshotsDeferredDuringResize.isEmpty()) 5342 _snapshotsDeferredDuringResize.takeLast()(); 5362 // If we already have an up-to-date layer tree, immediately complete 5363 // the resize. Otherwise, we will defer completion until we do. 5364 _waitingForEndAnimatedResize = NO; 5365 if (!_waitingForCommitAfterAnimatedResize) 5366 [self _didCompleteAnimatedResize]; 5343 5367 } 5344 5368 … … 5347 5371 LOG_WITH_STREAM(VisibleRects, stream << "-[WKWebView " << _page->pageID() << " _resizeWhileHidingContentWithUpdates:]"); 5348 5372 [self _beginAnimatedResizeWithUpdates:updateBlock]; 5349 if (_dynamicViewportUpdateMode == DynamicViewportUpdateMode::ResizingWithAnimation) {5373 if (_dynamicViewportUpdateMode == WebKit::DynamicViewportUpdateMode::ResizingWithAnimation) { 5350 5374 [_contentView setHidden:YES]; 5351 _dynamicViewportUpdateMode = DynamicViewportUpdateMode::ResizingWithDocumentHidden;5375 _dynamicViewportUpdateMode = WebKit::DynamicViewportUpdateMode::ResizingWithDocumentHidden; 5352 5376 } 5353 5377 } … … 5360 5384 - (void)_snapshotRect:(CGRect)rectInViewCoordinates intoImageOfWidth:(CGFloat)imageWidth completionHandler:(void(^)(CGImageRef))completionHandler 5361 5385 { 5362 if (_dynamicViewportUpdateMode != DynamicViewportUpdateMode::NotResizing) {5386 if (_dynamicViewportUpdateMode != WebKit::DynamicViewportUpdateMode::NotResizing) { 5363 5387 // Defer snapshotting until after the current resize completes. 5364 5388 void (^copiedCompletionHandler)(CGImageRef) = [completionHandler copy]; -
trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h
r232416 r232544 83 83 - (void)_layerTreeCommitComplete; 84 84 85 - (void)_dynamicViewportUpdateChangedTargetToScale:(double)newScale position:(CGPoint)newScrollPosition nextValidLayerTreeTransactionID:(uint64_t)nextValidLayerTreeTransactionID;86 85 - (void)_couldNotRestorePageState; 87 86 - (void)_restorePageScrollPosition:(std::optional<WebCore::FloatPoint>)scrollPosition scrollOrigin:(WebCore::FloatPoint)scrollOrigin previousObscuredInset:(WebCore::FloatBoxExtent)insets scale:(double)scale; … … 105 104 106 105 - (void)_scheduleVisibleContentRectUpdate; 106 107 - (void)_didCompleteAnimatedResize; 107 108 108 109 - (void)_didStartProvisionalLoadForMainFrame; -
trunk/Source/WebKit/UIProcess/PageClient.h
r231242 r232544 285 285 virtual void layerTreeCommitComplete() = 0; 286 286 287 virtual void dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint& newScrollPosition, uint64_t transactionID) = 0;288 287 virtual void couldNotRestorePageState() = 0; 289 288 virtual void restorePageState(std::optional<WebCore::FloatPoint> scrollPosition, const WebCore::FloatPoint& scrollOrigin, const WebCore::FloatBoxExtent& obscuredInsetsOnSave, double scale) = 0; -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r232535 r232544 5964 5964 m_firstLayerTreeTransactionIdAfterDidCommitLoad = 0; 5965 5965 m_lastVisibleContentRectUpdate = VisibleContentRectUpdateInfo(); 5966 m_dynamicViewportSizeUpdateWaitingForTarget = false;5967 m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit = false;5968 m_dynamicViewportSizeUpdateLayerTreeTransactionID = 0;5969 5966 m_hasNetworkRequestsOnSuspended = false; 5970 5967 m_isKeyboardAnimatingIn = false; -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r232437 r232544 108 108 109 109 #if PLATFORM(COCOA) 110 #include "DynamicViewportSizeUpdate.h" 110 111 #include "LayerRepresentation.h" 111 112 #include "TouchBarMenuData.h" … … 552 553 void overflowScrollDidEndScroll(); 553 554 554 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); 555 void synchronizeDynamicViewportUpdate(); 555 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); 556 556 557 557 void setViewportConfigurationViewLayoutSize(const WebCore::FloatSize&); … … 1664 1664 float textAutosizingWidth(); 1665 1665 1666 void dynamicViewportUpdateChangedTarget(double newTargetScale, const WebCore::FloatPoint& newScrollPosition, uint64_t dynamicViewportSizeUpdateID);1667 1666 void couldNotRestorePageState(); 1668 1667 void restorePageState(std::optional<WebCore::FloatPoint> scrollPosition, const WebCore::FloatPoint& scrollOrigin, const WebCore::FloatBoxExtent& obscuredInsetsOnSave, double scale); … … 1845 1844 uint64_t m_firstLayerTreeTransactionIdAfterDidCommitLoad { 0 }; 1846 1845 int32_t m_deviceOrientation { 0 }; 1847 uint64_t m_dynamicViewportSizeUpdateLayerTreeTransactionID { 0 };1848 uint64_t m_currentDynamicViewportSizeUpdateID { 0 };1849 1846 bool m_hasReceivedLayerTreeTransactionAfterDidCommitLoad { true }; 1850 bool m_dynamicViewportSizeUpdateWaitingForTarget { false };1851 bool m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit { false };1852 1847 bool m_hasNetworkRequestsOnSuspended { false }; 1853 1848 bool m_isKeyboardAnimatingIn { false }; -
trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in
r231510 r232544 390 390 391 391 #if PLATFORM(IOS) 392 DynamicViewportUpdateChangedTarget(double newTargetScale, WebCore::FloatPoint newScrollPosition, uint64_t dynamicViewportSizeUpdateID)393 392 CouldNotRestorePageState() 394 393 RestorePageState(std::optional<WebCore::FloatPoint> scrollPosition, WebCore::FloatPoint scrollOrigin, WebCore::RectEdges<float> obscuredInsetsOnSave, double scale) -
trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h
r231242 r232544 121 121 void layerTreeCommitComplete() override; 122 122 123 void dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint& newScrollPosition, uint64_t transactionID) override;124 123 void couldNotRestorePageState() override; 125 124 void restorePageState(std::optional<WebCore::FloatPoint>, const WebCore::FloatPoint&, const WebCore::FloatBoxExtent&, double) override; -
trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm
r232416 r232544 516 516 } 517 517 518 void PageClientImpl::dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint& newScrollPosition, uint64_t nextValidLayerTreeTransactionID)519 {520 [m_webView _dynamicViewportUpdateChangedTargetToScale:newScale position:newScrollPosition nextValidLayerTreeTransactionID:nextValidLayerTreeTransactionID];521 }522 523 518 void PageClientImpl::couldNotRestorePageState() 524 519 { -
trunk/Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm
r231676 r232544 307 307 } 308 308 309 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 )309 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) 310 310 { 311 311 if (!isValid()) … … 314 314 hideValidationMessage(); 315 315 316 m_dynamicViewportSizeUpdateWaitingForTarget = true; 317 m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit = true; 318 m_process->send(Messages::WebPage::DynamicViewportSizeUpdate(viewLayoutSize, maximumUnobscuredSize, targetExposedContentRect, targetUnobscuredRect, targetUnobscuredRectInScrollViewCoordinates, unobscuredSafeAreaInsets, targetScale, deviceOrientation, ++m_currentDynamicViewportSizeUpdateID), m_pageID); 319 } 320 321 void WebPageProxy::synchronizeDynamicViewportUpdate() 322 { 323 if (!isValid()) 324 return; 325 326 if (m_dynamicViewportSizeUpdateWaitingForTarget) { 327 // We do not want the UIProcess to finish animated resize with the old content size, scale, etc. 328 // If that happens, the UIProcess would start pushing new VisibleContentRectUpdateInfo to the WebProcess with 329 // invalid informations. 330 // 331 // Ideally, the animated resize should just be transactional, and the UIProcess would remain in the "resize" state 332 // until both DynamicViewportUpdateChangedTarget and the associated commitLayerTree are finished. 333 // The tricky part with such implementation is if a second animated resize starts before the end of the previous one. 334 // In that case, the values used for the target state needs to be computed from the output of the previous animated resize. 335 // 336 // The following is a workaround to have the UIProcess in a consistent state. 337 // Instead of handling nested resize, we block the UIProcess until the animated resize finishes. 338 double newScale; 339 FloatPoint newScrollPosition; 340 uint64_t nextValidLayerTreeTransactionID; 341 if (m_process->sendSync(Messages::WebPage::SynchronizeDynamicViewportUpdate(), Messages::WebPage::SynchronizeDynamicViewportUpdate::Reply(newScale, newScrollPosition, nextValidLayerTreeTransactionID), m_pageID, 2_s)) { 342 m_dynamicViewportSizeUpdateWaitingForTarget = false; 343 m_dynamicViewportSizeUpdateLayerTreeTransactionID = nextValidLayerTreeTransactionID; 344 m_pageClient.dynamicViewportUpdateChangedTarget(newScale, newScrollPosition, nextValidLayerTreeTransactionID); 345 } 346 347 } 348 349 // If m_dynamicViewportSizeUpdateWaitingForTarget is false, we are waiting for the next valid frame with the hope it is the one for the new target. 350 // If m_dynamicViewportSizeUpdateWaitingForTarget is still true, this is a desperate attempt to get the valid frame before finishing the animation. 351 if (m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit) 352 m_drawingArea->waitForDidUpdateActivityState(); 353 354 m_dynamicViewportSizeUpdateWaitingForTarget = false; 355 m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit = false; 316 m_process->send(Messages::WebPage::DynamicViewportSizeUpdate(viewLayoutSize, 317 maximumUnobscuredSize, targetExposedContentRect, targetUnobscuredRect, 318 targetUnobscuredRectInScrollViewCoordinates, unobscuredSafeAreaInsets, 319 targetScale, deviceOrientation, dynamicViewportSizeUpdateID), m_pageID); 356 320 } 357 321 … … 408 372 } 409 373 410 if (!m_dynamicViewportSizeUpdateWaitingForTarget && m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit) {411 if (layerTreeTransaction.transactionID() >= m_dynamicViewportSizeUpdateLayerTreeTransactionID)412 m_dynamicViewportSizeUpdateWaitingForLayerTreeCommit = false;413 }414 415 374 m_pageClient.didCommitLayerTree(layerTreeTransaction); 416 375 … … 903 862 { 904 863 return WebCore::screenSize().width(); 905 }906 907 void WebPageProxy::dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint& newScrollPosition, uint64_t dynamicViewportSizeUpdateID)908 {909 if (dynamicViewportSizeUpdateID != m_currentDynamicViewportSizeUpdateID)910 return;911 912 if (m_dynamicViewportSizeUpdateWaitingForTarget) {913 m_dynamicViewportSizeUpdateLayerTreeTransactionID = downcast<RemoteLayerTreeDrawingAreaProxy>(*drawingArea()).nextLayerTreeTransactionID();914 m_dynamicViewportSizeUpdateWaitingForTarget = false;915 m_pageClient.dynamicViewportUpdateChangedTarget(newScale, newScrollPosition, m_dynamicViewportSizeUpdateLayerTreeTransactionID);916 }917 864 } 918 865 -
trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj
r232491 r232544 678 678 2DA1E4FE18C02B6A00DBC929 /* WKLegacyPDFView.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DA1E4FC18C02B6A00DBC929 /* WKLegacyPDFView.h */; }; 679 679 2DA1E4FF18C02B6A00DBC929 /* WKLegacyPDFView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DA1E4FD18C02B6A00DBC929 /* WKLegacyPDFView.mm */; }; 680 2DA6731A20C754B1003CB401 /* DynamicViewportSizeUpdate.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DA6731920C754B1003CB401 /* DynamicViewportSizeUpdate.h */; }; 680 681 2DA9449E1884E4F000ED86DB /* NativeWebKeyboardEventIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DA944971884E4F000ED86DB /* NativeWebKeyboardEventIOS.mm */; }; 681 682 2DA9449F1884E4F000ED86DB /* NativeWebTouchEventIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DA944981884E4F000ED86DB /* NativeWebTouchEventIOS.mm */; }; … … 3056 3057 2DA1E4FC18C02B6A00DBC929 /* WKLegacyPDFView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKLegacyPDFView.h; path = ios/WKLegacyPDFView.h; sourceTree = "<group>"; }; 3057 3058 2DA1E4FD18C02B6A00DBC929 /* WKLegacyPDFView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKLegacyPDFView.mm; path = ios/WKLegacyPDFView.mm; sourceTree = "<group>"; }; 3059 2DA6731920C754B1003CB401 /* DynamicViewportSizeUpdate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DynamicViewportSizeUpdate.h; path = ios/DynamicViewportSizeUpdate.h; sourceTree = "<group>"; }; 3058 3060 2DA7FDCB18F88625008DDED0 /* FindIndicatorOverlayClientIOS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FindIndicatorOverlayClientIOS.h; path = ios/FindIndicatorOverlayClientIOS.h; sourceTree = "<group>"; }; 3059 3061 2DA944971884E4F000ED86DB /* NativeWebKeyboardEventIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = NativeWebKeyboardEventIOS.mm; path = ios/NativeWebKeyboardEventIOS.mm; sourceTree = "<group>"; }; … … 5780 5782 children = ( 5781 5783 A7E93CEB192531AA00A1DC48 /* ChildProcessIOS.mm */, 5784 2DA6731920C754B1003CB401 /* DynamicViewportSizeUpdate.h */, 5782 5785 2DA9449D1884E4F000ED86DB /* GestureTypes.h */, 5783 5786 C5BCE5DA1C50761D00CDE3FA /* InteractionInformationAtPosition.h */, … … 8942 8945 BC2652171182608100243E12 /* DrawingAreaProxy.h in Headers */, 8943 8946 1A64230912DD09EB00CAAE2C /* DrawingAreaProxyMessages.h in Headers */, 8947 2DA6731A20C754B1003CB401 /* DynamicViewportSizeUpdate.h in Headers */, 8944 8948 E105FE5418D7B9DE008F57A8 /* EditingRange.h in Headers */, 8945 8949 1AA41AB512C02EC4002BE67B /* EditorState.h in Headers */, -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r232535 r232544 3223 3223 layerTransaction.setIsInStableState(m_isInStableState); 3224 3224 layerTransaction.setAllowsUserScaling(allowsUserScaling()); 3225 #endif 3226 3227 #if PLATFORM(MAC) 3225 if (m_pendingDynamicViewportSizeUpdateID) { 3226 layerTransaction.setDynamicViewportSizeUpdateID(*m_pendingDynamicViewportSizeUpdateID); 3227 m_pendingDynamicViewportSizeUpdateID = std::nullopt; 3228 } 3229 #endif 3230 3228 3231 layerTransaction.setScrollPosition(frameView->scrollPosition()); 3229 #endif3230 3232 3231 3233 if (m_hasPendingEditorStateUpdate) { -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.h
r232535 r232544 108 108 109 109 #if PLATFORM(COCOA) 110 #include "DynamicViewportSizeUpdate.h" 110 111 #include <WebCore/VisibleSelection.h> 111 112 #include <wtf/RetainPtr.h> … … 883 884 void setMaximumUnobscuredSize(const WebCore::FloatSize&); 884 885 void setDeviceOrientation(int32_t); 885 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); 886 void synchronizeDynamicViewportUpdate(double& newTargetScale, WebCore::FloatPoint& newScrollPosition, uint64_t& nextValidLayerTreeTransactionID); 886 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); 887 887 std::optional<float> scaleFromUIProcess(const VisibleContentRectUpdateInfo&) const; 888 888 void updateVisibleContentRects(const VisibleContentRectUpdateInfo&, MonotonicTime oldestTimestamp); … … 1651 1651 WebCore::FloatRect m_previousExposedContentRect; 1652 1652 uint64_t m_currentAssistedNodeIdentifier { 0 }; 1653 std::optional<DynamicViewportSizeUpdateID> m_pendingDynamicViewportSizeUpdateID; 1653 1654 #endif 1654 1655 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in
r232535 r232544 50 50 SetDeviceOrientation(int32_t deviceOrientation) 51 51 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) 52 SynchronizeDynamicViewportUpdate() -> (double newTargetScale, WebCore::FloatPoint newScrollPosition, uint64_t nextValidLayerTreeTransactionID)53 52 54 53 HandleTap(WebCore::IntPoint point, uint64_t lastLayerTreeTransactionId) -
trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
r232479 r232544 2496 2496 } 2497 2497 2498 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_tdynamicViewportSizeUpdateID)2498 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) 2499 2499 { 2500 2500 SetForScope<bool> dynamicSizeUpdateGuard(m_inDynamicSizeUpdate, true); … … 2673 2673 m_drawingArea->scheduleCompositingLayerFlush(); 2674 2674 2675 send(Messages::WebPageProxy::DynamicViewportUpdateChangedTarget(pageScaleFactor(), frameView.scrollPosition(), dynamicViewportSizeUpdateID)); 2676 } 2677 2678 void WebPage::synchronizeDynamicViewportUpdate(double& newTargetScale, FloatPoint& newScrollPosition, uint64_t& nextValidLayerTreeTransactionID) 2679 { 2680 newTargetScale = pageScaleFactor(); 2681 newScrollPosition = m_page->mainFrame().view()->scrollPosition(); 2682 nextValidLayerTreeTransactionID = downcast<RemoteLayerTreeDrawingArea>(*m_drawingArea).nextTransactionID(); 2675 m_pendingDynamicViewportSizeUpdateID = dynamicViewportSizeUpdateID; 2683 2676 } 2684 2677
Note: See TracChangeset
for help on using the changeset viewer.