Changeset 167836 in webkit
- Timestamp:
- Apr 25, 2014 5:12:29 PM (10 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r167835 r167836 1 2014-04-25 Benjamin Poulain <bpoulain@apple.com> 2 3 [iOS][WK2] Add an intermediary view to do the target transform and adjustment transform 4 https://bugs.webkit.org/show_bug.cgi?id=132175 5 6 Reviewed by Enrica Casucci. 7 8 Some utility views of WKContentView account for the transforms between the content view 9 and the utility view. 10 11 Since the dynamic resize relies on setting subLayerTransforms, it is getting in the way. 12 13 This patch adds a layer in between for the animation. That way the content view remains 14 unscaled. 15 16 * UIProcess/API/Cocoa/WKWebView.mm: 17 (-[WKWebView _didCommitLayerTree:WebKit::]): 18 (-[WKWebView _dynamicViewportUpdateChangedTargetToScale:position:]): 19 (-[WKWebView _beginAnimatedResizeWithUpdates:]): 20 (-[WKWebView _endAnimatedResize]): 21 1 22 2014-04-25 Enrica Casucci <enrica@apple.com> 2 23 -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
r167735 r167836 107 107 BOOL _isAnimatingResize; 108 108 CATransform3D _resizeAnimationTransformAdjustments; 109 RetainPtr<UIView> _resizeAnimationView; 109 110 CGFloat _lastAdjustmentForScroller; 110 111 CGFloat _keyboardVerticalOverlap; … … 459 460 460 461 if (_isAnimatingResize) { 461 [_ contentView layer].sublayerTransform = _resizeAnimationTransformAdjustments;462 [_resizeAnimationView layer].sublayerTransform = _resizeAnimationTransformAdjustments; 462 463 return; 463 464 } … … 484 485 { 485 486 if (_isAnimatingResize) { 486 double currentTargetScale = [[_contentView layer] affineTransform].a; 487 CGFloat animatingScaleTarget = [[_resizeAnimationView layer] transform].m11; 488 double currentTargetScale = animatingScaleTarget * [[_contentView layer] transform].m11; 487 489 double scale = newScale / currentTargetScale; 488 490 _resizeAnimationTransformAdjustments = CATransform3DMakeScale(scale, scale, 0); … … 493 495 CGPoint currentContentOffset = [_scrollView contentOffset]; 494 496 495 _resizeAnimationTransformAdjustments.m41 = (currentContentOffset.x - newContentOffset.x) / currentTargetScale;496 _resizeAnimationTransformAdjustments.m42 = (currentContentOffset.y - newContentOffset.y) / currentTargetScale;497 _resizeAnimationTransformAdjustments.m41 = (currentContentOffset.x - newContentOffset.x) / animatingScaleTarget; 498 _resizeAnimationTransformAdjustments.m42 = (currentContentOffset.y - newContentOffset.y) / animatingScaleTarget; 497 499 } 498 500 } … … 1330 1332 _resizeAnimationTransformAdjustments = CATransform3DIdentity; 1331 1333 1334 _resizeAnimationView = adoptNS([[UIView alloc] init]); 1335 [_scrollView addSubview:_resizeAnimationView.get()]; 1336 [_resizeAnimationView addSubview:_contentView.get()]; 1337 1332 1338 CGRect oldBounds = self.bounds; 1333 1339 CGSize oldMinimumLayoutSize = oldBounds.size; … … 1354 1360 1355 1361 // Compute the new scale to keep the current content width in the scrollview. 1356 CGFloat oldWebViewWidthInContentViewCoordinates = oldBounds.size.width / contentZoomScale(self); 1362 CGFloat currentScale = contentZoomScale(self); 1363 CGFloat oldWebViewWidthInContentViewCoordinates = oldBounds.size.width / currentScale; 1357 1364 CGFloat visibleContentViewWidthInContentCoordinates = std::min(contentSizeInContentViewCoordinates.width, oldWebViewWidthInContentViewCoordinates); 1358 1365 CGFloat targetScale = newBounds.size.width / visibleContentViewWidthInContentCoordinates; 1359 [_scrollView setZoomScale:targetScale]; 1366 CGFloat resizeAnimationViewAnimationScale = targetScale / currentScale; 1367 [_resizeAnimationView setTransform:CGAffineTransformMakeScale(resizeAnimationViewAnimationScale, resizeAnimationViewAnimationScale)]; 1360 1368 1361 1369 // Compute a new position to keep the content centered. … … 1400 1408 { 1401 1409 if (!_customContentView) { 1410 [_scrollView addSubview:_contentView.get()]; 1411 1402 1412 CALayer *contentViewLayer = [_contentView layer]; 1403 1413 CATransform3D resizeAnimationTransformAdjustements = _resizeAnimationTransformAdjustments; … … 1405 1415 contentViewLayer.sublayerTransform = CATransform3DIdentity; 1406 1416 1407 CGFloat currentScale = contentZoomScale(self); 1417 CGFloat animatingScaleTarget = [[_resizeAnimationView layer] transform].m11; 1418 CGFloat currentScale = [[_resizeAnimationView layer] transform].m11 * [[_contentView layer] transform].m11; 1408 1419 CGPoint currentScrollOffset = [_scrollView contentOffset]; 1409 1420 [_scrollView setZoomScale:adjustmentScale * currentScale]; 1410 1421 1411 double horizontalScrollAdjustement = _resizeAnimationTransformAdjustments.m41 * currentScale;1412 double verticalScrollAdjustment = _resizeAnimationTransformAdjustments.m42 * currentScale;1422 double horizontalScrollAdjustement = _resizeAnimationTransformAdjustments.m41 * animatingScaleTarget; 1423 double verticalScrollAdjustment = _resizeAnimationTransformAdjustments.m42 * animatingScaleTarget; 1413 1424 1414 1425 [_scrollView setContentOffset:CGPointMake(currentScrollOffset.x - horizontalScrollAdjustement, currentScrollOffset.y - verticalScrollAdjustment)]; 1426 1427 [_resizeAnimationView removeFromSuperview]; 1428 _resizeAnimationView = nil; 1415 1429 } 1416 1430
Note: See TracChangeset
for help on using the changeset viewer.