Changeset 171201 in webkit
- Timestamp:
- Jul 17, 2014 3:08:41 PM (10 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r171197 r171201 1 2014-07-17 Benjamin Poulain <benjamin@webkit.org> 2 3 [iOS][WK2] Add SPI to do a dynamic viewport update without showing any content 4 https://bugs.webkit.org/show_bug.cgi?id=135010 5 6 Reviewed by Darin Adler. 7 8 This patch add a new SPI, [WKWebView _resizeWhileHidingContentWithUpdates:] to perform all the work 9 of a dynamic viewport size update, but instead of animating the old content, it is hidden. 10 11 The patch is built on top of the animated resize mechanism. Instead of having an animation driving 12 the beginning and end, we let the content do that. The dynamic resize begins, it runs for as long as 13 the WebProcess needs, and it ends when first layer tree commit with the new content is processed. 14 15 The attribute "_isAnimatingResize" is generalized to support two modes of resizing: animated and 16 hiding content. 17 18 The attribute "_hasCommittedLoadForMainFrame" is rather silly. It is only needed because 19 [WKWebView _resizeWhileHidingContentWithUpdates:] is intended to be called a lot before the page 20 is initialized, and doing an animated resize would trash the WebProcess state. 21 I wish I had a better solution, this is not great. 22 23 * UIProcess/API/Cocoa/WKWebView.mm: 24 (-[WKWebView _processDidExit]): 25 (-[WKWebView _didCommitLoadForMainFrame]): 26 (-[WKWebView _didCommitLayerTree:]): 27 This is the key to make this work properly. We want _resizeWhileHidingContentWithUpdates: to behave 28 exactly like an animated resize to avoid bugs. So we went to the whole update mechanism using 29 _resizeAnimationTransformAdjustments to accumulate the adjustments, now we need to restore a correct 30 view state. 31 32 Calling [WKWebView _endAnimatedResize] will do exactly that, but we need to make sure we do not hit 33 the synchronization path or we would be blocked there for a while, which is what we are trying to avoid. 34 35 After r171154, WebPageProxy keeps track of what stage of dynamic viewport update we are in. Since we are 36 executing the layer tree update stage, with the right transaction ID, WebPageProxy already knows we have 37 everything we need and does not use any synchronous messages. 38 39 (-[WKWebView _dynamicViewportUpdateChangedTargetToScale:position:nextValidLayerTreeTransactionID:]): 40 (-[WKWebView _restorePageStateToExposedRect:scale:]): 41 (-[WKWebView _restorePageStateToUnobscuredCenter:scale:]): 42 (-[WKWebView _scrollToContentOffset:]): 43 (-[WKWebView _frameOrBoundsChanged]): 44 (-[WKWebView _updateVisibleContentRects]): 45 (-[WKWebView _setMinimumLayoutSizeOverride:]): 46 (-[WKWebView _setMinimumLayoutSizeOverrideForMinimalUI:]): 47 (-[WKWebView _setInterfaceOrientationOverride:]): 48 (-[WKWebView _setMaximumUnobscuredSizeOverride:]): 49 (-[WKWebView _beginAnimatedResizeWithUpdates:]): 50 (-[WKWebView _endAnimatedResize]): 51 (-[WKWebView _resizeWhileHidingContentWithUpdates:]): 52 * UIProcess/API/Cocoa/WKWebViewPrivate.h: 53 1 54 2014-07-17 Brent Fulgham <bfulgham@apple.com> 2 55 -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
r171154 r171201 119 119 - (UIViewController *)_viewControllerForSupportedInterfaceOrientations; 120 120 @end 121 122 enum class DynamicViewportUpdateMode { 123 NotResizing, 124 ResizingWithAnimation, 125 ResizingWithDocumentHidden, 126 }; 127 121 128 #endif 122 129 … … 167 174 BOOL _overridesInterfaceOrientation; 168 175 176 BOOL _hasCommittedLoadForMainFrame; 169 177 BOOL _needsResetViewStateAfterCommitLoadForMainFrame; 170 178 uint64_t _firstPaintAfterCommitLoadTransactionID; 171 BOOL _isAnimatingResize;179 DynamicViewportUpdateMode _dynamicViewportUpdateMode; 172 180 CATransform3D _resizeAnimationTransformAdjustments; 173 181 uint64_t _resizeAnimationTransformTransactionID; … … 741 749 - (void)_processDidExit 742 750 { 743 if (!_customContentView && _ isAnimatingResize) {751 if (!_customContentView && _dynamicViewportUpdateMode != DynamicViewportUpdateMode::NotResizing) { 744 752 NSUInteger indexOfResizeAnimationView = [[_scrollView subviews] indexOfObject:_resizeAnimationView.get()]; 745 753 [_scrollView insertSubview:_contentView.get() atIndex:indexOfResizeAnimationView]; … … 748 756 _resizeAnimationView = nil; 749 757 750 _isAnimatingResize = NO;751 758 _resizeAnimationTransformAdjustments = CATransform3DIdentity; 752 759 } … … 757 764 758 765 _viewportMetaTagWidth = -1; 766 _hasCommittedLoadForMainFrame = NO; 759 767 _needsResetViewStateAfterCommitLoadForMainFrame = NO; 768 _dynamicViewportUpdateMode = DynamicViewportUpdateMode::NotResizing; 769 [_contentView setHidden:NO]; 760 770 _needsToRestoreExposedRect = NO; 761 771 _needsToRestoreUnobscuredCenter = NO; … … 769 779 _firstPaintAfterCommitLoadTransactionID = toRemoteLayerTreeDrawingAreaProxy(_page->drawingArea())->nextLayerTreeTransactionID(); 770 780 781 _hasCommittedLoadForMainFrame = YES; 771 782 _needsResetViewStateAfterCommitLoadForMainFrame = YES; 772 783 _usesMinimalUI = NO; … … 805 816 return; 806 817 807 if (_ isAnimatingResize) {808 if (layerTreeTransaction.transactionID() >= _resizeAnimationTransformTransactionID) 818 if (_dynamicViewportUpdateMode != DynamicViewportUpdateMode::NotResizing) { 819 if (layerTreeTransaction.transactionID() >= _resizeAnimationTransformTransactionID) { 809 820 [_resizeAnimationView layer].sublayerTransform = _resizeAnimationTransformAdjustments; 821 if (_dynamicViewportUpdateMode == DynamicViewportUpdateMode::ResizingWithDocumentHidden) { 822 [_contentView setHidden:NO]; 823 [self _endAnimatedResize]; 824 } 825 } 810 826 return; 811 827 } … … 870 886 - (void)_dynamicViewportUpdateChangedTargetToScale:(double)newScale position:(CGPoint)newScrollPosition nextValidLayerTreeTransactionID:(uint64_t)nextValidLayerTreeTransactionID 871 887 { 872 if (_ isAnimatingResize) {888 if (_dynamicViewportUpdateMode != DynamicViewportUpdateMode::NotResizing) { 873 889 CGFloat animatingScaleTarget = [[_resizeAnimationView layer] transform].m11; 874 890 double currentTargetScale = animatingScaleTarget * [[_contentView layer] transform].m11; … … 887 903 - (void)_restorePageStateToExposedRect:(WebCore::FloatRect)exposedRect scale:(double)scale 888 904 { 889 if (_ isAnimatingResize)905 if (_dynamicViewportUpdateMode != DynamicViewportUpdateMode::NotResizing) 890 906 return; 891 907 … … 902 918 - (void)_restorePageStateToUnobscuredCenter:(WebCore::FloatPoint)center scale:(double)scale 903 919 { 904 if (_ isAnimatingResize)920 if (_dynamicViewportUpdateMode != DynamicViewportUpdateMode::NotResizing) 905 921 return; 906 922 … … 988 1004 - (void)_scrollToContentOffset:(WebCore::FloatPoint)contentOffset 989 1005 { 990 if (_ isAnimatingResize)1006 if (_dynamicViewportUpdateMode != DynamicViewportUpdateMode::NotResizing) 991 1007 return; 992 1008 … … 1333 1349 [_scrollView setFrame:bounds]; 1334 1350 1335 if ( !_isAnimatingResize) {1351 if (_dynamicViewportUpdateMode == DynamicViewportUpdateMode::NotResizing) { 1336 1352 if (!_overridesMinimumLayoutSize) 1337 1353 _page->setViewportConfigurationMinimumLayoutSize(WebCore::FloatSize(bounds.size)); … … 1369 1385 } 1370 1386 1371 if (_ isAnimatingResize)1387 if (_dynamicViewportUpdateMode != DynamicViewportUpdateMode::NotResizing) 1372 1388 return; 1373 1389 … … 2028 2044 2029 2045 _minimumLayoutSizeOverride = minimumLayoutSizeOverride; 2030 if ( !_isAnimatingResize)2046 if (_dynamicViewportUpdateMode == DynamicViewportUpdateMode::NotResizing) 2031 2047 _page->setViewportConfigurationMinimumLayoutSize(WebCore::FloatSize(minimumLayoutSizeOverride)); 2032 2048 } … … 2045 2061 2046 2062 _minimumLayoutSizeOverrideForMinimalUI = size; 2047 if ( !_isAnimatingResize)2063 if (_dynamicViewportUpdateMode == DynamicViewportUpdateMode::NotResizing) 2048 2064 _page->setViewportConfigurationMinimumLayoutSizeForMinimalUI(WebCore::FloatSize(size)); 2049 2065 } … … 2081 2097 _interfaceOrientationOverride = interfaceOrientation; 2082 2098 2083 if ( !_isAnimatingResize)2099 if (_dynamicViewportUpdateMode == DynamicViewportUpdateMode::NotResizing) 2084 2100 _page->setDeviceOrientation(deviceOrientationForUIInterfaceOrientation(_interfaceOrientationOverride)); 2085 2101 } … … 2105 2121 2106 2122 _maximumUnobscuredSizeOverride = size; 2107 if ( !_isAnimatingResize)2123 if (_dynamicViewportUpdateMode == DynamicViewportUpdateMode::NotResizing) 2108 2124 _page->setMaximumUnobscuredSize(WebCore::FloatSize(size)); 2109 2125 } … … 2134 2150 - (void)_beginAnimatedResizeWithUpdates:(void (^)(void))updateBlock 2135 2151 { 2136 if (_customContentView ) {2152 if (_customContentView || !_hasCommittedLoadForMainFrame) { 2137 2153 updateBlock(); 2138 2154 return; 2139 2155 } 2140 2156 2141 _ isAnimatingResize = YES;2157 _dynamicViewportUpdateMode = DynamicViewportUpdateMode::ResizingWithAnimation; 2142 2158 2143 2159 CGRect oldBounds = self.bounds; … … 2164 2180 && oldOrientation == newOrientation 2165 2181 && UIEdgeInsetsEqualToEdgeInsets(oldObscuredInsets, newObscuredInsets)) { 2166 _ isAnimatingResize = NO;2182 _dynamicViewportUpdateMode = DynamicViewportUpdateMode::NotResizing; 2167 2183 [self _updateVisibleContentRects]; 2168 2184 return; … … 2228 2244 - (void)_endAnimatedResize 2229 2245 { 2230 if ( !_isAnimatingResize)2246 if (_dynamicViewportUpdateMode == DynamicViewportUpdateMode::NotResizing) 2231 2247 return; 2232 2248 … … 2266 2282 _resizeAnimationTransformAdjustments = CATransform3DIdentity; 2267 2283 2268 _isAnimatingResize = NO; 2284 _dynamicViewportUpdateMode = DynamicViewportUpdateMode::NotResizing; 2285 [_contentView setHidden:NO]; 2269 2286 [self _updateVisibleContentRects]; 2287 } 2288 2289 - (void)_resizeWhileHidingContentWithUpdates:(void (^)(void))updateBlock 2290 { 2291 [self _beginAnimatedResizeWithUpdates:updateBlock]; 2292 if (_dynamicViewportUpdateMode == DynamicViewportUpdateMode::ResizingWithAnimation) { 2293 [_contentView setHidden:YES]; 2294 _dynamicViewportUpdateMode = DynamicViewportUpdateMode::ResizingWithDocumentHidden; 2295 } 2270 2296 } 2271 2297 -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h
r171050 r171201 138 138 - (void)_beginAnimatedResizeWithUpdates:(void (^)(void))updateBlock; 139 139 - (void)_endAnimatedResize; 140 - (void)_resizeWhileHidingContentWithUpdates:(void (^)(void))updateBlock; 140 141 141 142 - (void)_snapshotRect:(CGRect)rectInViewCoordinates intoImageOfWidth:(CGFloat)imageWidth completionHandler:(void(^)(CGImageRef))completionHandler;
Note: See TracChangeset
for help on using the changeset viewer.