Changeset 167060 in webkit
- Timestamp:
- Apr 9, 2014 8:39:33 PM (10 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r167051 r167060 1 2014-04-09 Benjamin Poulain <bpoulain@apple.com> 2 3 [iOS][WK2] Add the initial WebProcess handling of animated resize for rotation 4 https://bugs.webkit.org/show_bug.cgi?id=131469 5 6 Reviewed by Tim Horton. 7 8 Add the basic handling of dynamic resize from the WebProcess. 9 10 On animated resize, the UIProcess decides new target rects and scale. The information 11 is then passed to the WebProcess to update the content. 12 13 For various reason, the target rects and scale computed by the UIProcess can be incorrect 14 (for example, if viewport constraints limit the scale). 15 16 In those cases, the WebProcess has all the information to compute a better target. This patch 17 adds such a basic update mechanism. 18 19 Once the new values are computed, they are sent back to the UIProcess. If the rotation animation 20 is still ongoing, we do not want mess with it. What we do is set a temporary transform on the subviews 21 and restore the real value after the animation. The key is to have the two matrix multiplying to the end 22 value so that there is no visual difference. 23 24 * UIProcess/API/Cocoa/WKWebView.mm: 25 (-[WKWebView _didCommitLayerTree:WebKit::]): 26 (-[WKWebView _dynamicViewportUpdateChangedTargetToScale:position:]): 27 (setViewportConfigurationMinimumLayoutSize): 28 (-[WKWebView _frameOrBoundsChanged]): 29 (-[WKWebView _setMinimumLayoutSizeOverride:]): 30 (-[WKWebView _beginAnimatedResizeToSize:obscuredInsets:minimumLayoutSizeOverride:]): 31 (-[WKWebView _endAnimatedResize]): 32 * UIProcess/API/Cocoa/WKWebViewInternal.h: 33 * UIProcess/API/ios/WKViewIOS.mm: 34 (-[WKView _frameOrBoundsChanged]): 35 (-[WKView setMinimumLayoutSizeOverride:]): 36 * UIProcess/PageClient.h: 37 * UIProcess/WebPageProxy.h: 38 * UIProcess/WebPageProxy.messages.in: 39 * UIProcess/ios/PageClientImplIOS.h: 40 * UIProcess/ios/PageClientImplIOS.mm: 41 (WebKit::PageClientImpl::dynamicViewportUpdateChangedTarget): 42 * UIProcess/ios/WKContentView.h: 43 * UIProcess/ios/WKContentView.mm: 44 (-[WKContentView setMinimumLayoutSize:]): Deleted. 45 * UIProcess/ios/WebPageProxyIOS.mm: 46 (WebKit::WebPageProxy::dynamicViewportSizeUpdate): 47 (WebKit::WebPageProxy::dynamicViewportUpdateChangedTarget): 48 * WebProcess/WebPage/WebPage.h: 49 * WebProcess/WebPage/WebPage.messages.in: 50 * WebProcess/WebPage/ios/WebPageIOS.mm: 51 (WebKit::WebPage::dynamicViewportSizeUpdate): 52 1 53 2014-04-09 Martin Robinson <mrobinson@igalia.com> 2 54 -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
r166933 r167060 65 65 #import "WKScrollView.h" 66 66 #import "WKWebViewContentProviderRegistry.h" 67 #import <CoreGraphics/CGFloat.h> 67 68 #import <UIKit/UIPeripheralHost_Private.h> 68 69 … … 101 102 bool _isChangingObscuredInsetsInteractively; 102 103 BOOL _isAnimatingResize; 104 CATransform3D _resizeAnimationTransformAdjustments; 103 105 CGFloat _lastAdjustmentForScroller; 104 106 CGFloat _keyboardVerticalOverlap; … … 451 453 ASSERT(!_customContentView); 452 454 453 if (_isAnimatingResize) 455 if (_isAnimatingResize) { 456 [_contentView layer].sublayerTransform = _resizeAnimationTransformAdjustments; 454 457 return; 458 } 455 459 456 460 [_scrollView setContentSize:[_contentView frame].size]; … … 471 475 _isWaitingForNewLayerTreeAfterDidCommitLoad = NO; 472 476 } 473 477 } 478 479 - (void)_dynamicViewportUpdateChangedTargetToScale:(double)newScale position:(CGPoint)newScrollPosition 480 { 481 if (_isAnimatingResize) { 482 double currentTargetScale = [[_contentView layer] affineTransform].a; 483 double scale = newScale / currentTargetScale; 484 _resizeAnimationTransformAdjustments = CATransform3DMakeScale(scale, scale, 0); 485 486 CGPoint newContentOffset = CGPointMake(newScrollPosition.x * newScale, newScrollPosition.y * newScale); 487 newContentOffset.x -= _obscuredInsets.left; 488 newContentOffset.y -= _obscuredInsets.top; 489 CGPoint currentContentOffset = [_scrollView contentOffset]; 490 491 _resizeAnimationTransformAdjustments.m41 = (currentContentOffset.x - newContentOffset.x) / currentTargetScale; 492 _resizeAnimationTransformAdjustments.m42 = (currentContentOffset.y - newContentOffset.y) / currentTargetScale; 493 } 474 494 } 475 495 … … 677 697 } 678 698 699 static inline void setViewportConfigurationMinimumLayoutSize(WebKit::WebPageProxy& page, const CGSize& size) 700 { 701 page.setViewportConfigurationMinimumLayoutSize(WebCore::IntSize(CGCeiling(size.width), CGCeiling(size.height))); 702 } 703 679 704 - (void)_frameOrBoundsChanged 680 705 { 681 706 CGRect bounds = self.bounds; 682 707 if (!_hasStaticMinimumLayoutSize && !_isAnimatingResize) 683 [_contentView setMinimumLayoutSize:bounds.size];708 setViewportConfigurationMinimumLayoutSize(*_page, bounds.size); 684 709 [_scrollView setFrame:bounds]; 685 710 [_contentView setMinimumSize:bounds.size]; … … 1165 1190 _hasStaticMinimumLayoutSize = YES; 1166 1191 _minimumLayoutSizeOverride = minimumLayoutSizeOverride; 1167 [_contentView setMinimumLayoutSize:minimumLayoutSizeOverride];1192 setViewportConfigurationMinimumLayoutSize(*_page, minimumLayoutSizeOverride); 1168 1193 } 1169 1194 … … 1209 1234 { 1210 1235 _isAnimatingResize = YES; 1236 _resizeAnimationTransformAdjustments = CATransform3DIdentity; 1211 1237 1212 1238 if (_customContentView) … … 1263 1289 [_scrollView setContentOffset:contentOffset]; 1264 1290 1265 // FIXME: Send a single message to the WebProcess to layout and repaint instead. 1266 // FIXME: Send resize event. 1267 [_contentView setMinimumLayoutSize:futureMinimumLayoutSize]; 1291 CGRect visibleRectInContentCoordinates = [self convertRect:futureBounds toView:_contentView.get()]; 1292 1293 CGRect unobscuredRect = UIEdgeInsetsInsetRect(futureBounds, _obscuredInsets); 1294 CGRect unobscuredRectInContentCoordinates = [self convertRect:unobscuredRect toView:_contentView.get()]; 1295 1296 _page->dynamicViewportSizeUpdate(WebCore::IntSize(CGCeiling(futureMinimumLayoutSize.width), CGCeiling(futureMinimumLayoutSize.height)), visibleRectInContentCoordinates, unobscuredRectInContentCoordinates, targetScale); 1268 1297 } 1269 1298 1270 1299 - (void)_endAnimatedResize 1271 1300 { 1301 if (!_customContentView) { 1302 CALayer *contentViewLayer = [_contentView layer]; 1303 CATransform3D resizeAnimationTransformAdjustements = _resizeAnimationTransformAdjustments; 1304 CGFloat adjustmentScale = resizeAnimationTransformAdjustements.m11; 1305 contentViewLayer.sublayerTransform = CATransform3DIdentity; 1306 1307 CGFloat currentScale = contentZoomScale(self); 1308 CGPoint currentScrollOffset = [_scrollView contentOffset]; 1309 [_scrollView setZoomScale:adjustmentScale * currentScale]; 1310 1311 double horizontalScrollAdjustement = _resizeAnimationTransformAdjustments.m41 * currentScale; 1312 double verticalScrollAdjustment = _resizeAnimationTransformAdjustments.m42 * currentScale; 1313 1314 [_scrollView setContentOffset:CGPointMake(currentScrollOffset.x - horizontalScrollAdjustement, currentScrollOffset.y - verticalScrollAdjustment)]; 1315 } 1316 1317 _resizeAnimationTransformAdjustments = CATransform3DIdentity; 1272 1318 _isAnimatingResize = NO; 1273 1319 [self _updateVisibleContentRects]; -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h
r166270 r167060 61 61 - (void)_didCommitLayerTree:(const WebKit::RemoteLayerTreeTransaction&)layerTreeTransaction; 62 62 63 - (void)_dynamicViewportUpdateChangedTargetToScale:(double)newScale position:(CGPoint)newScrollPosition; 64 63 65 - (RetainPtr<CGImageRef>)_takeViewSnapshot; 64 66 -
trunk/Source/WebKit2/UIProcess/API/ios/WKViewIOS.mm
r165454 r167060 249 249 { 250 250 CGRect bounds = [self bounds]; 251 if (!_hasStaticMinimumLayoutSize)252 [_contentView setMinimumLayoutSize:bounds.size];253 251 [_scrollView setFrame:bounds]; 254 252 [_contentView setMinimumSize:bounds.size]; … … 337 335 _hasStaticMinimumLayoutSize = YES; 338 336 _minimumLayoutSizeOverride = minimumLayoutSizeOverride; 339 [_contentView setMinimumLayoutSize:minimumLayoutSizeOverride];340 337 } 341 338 -
trunk/Source/WebKit2/UIProcess/PageClient.h
r166900 r167060 240 240 241 241 virtual void didCommitLayerTree(const RemoteLayerTreeTransaction&) = 0; 242 virtual void dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint& newScrollPosition) = 0; 242 243 243 244 virtual void startAssistingNode(const AssistedNodeInformation&, API::Object* userData) = 0; -
trunk/Source/WebKit2/UIProcess/WebPageProxy.h
r167040 r167060 577 577 uint64_t nextVisibleContentRectUpdateID() const { return m_lastVisibleContentRectUpdate.updateID() + 1; } 578 578 uint64_t lastVisibleContentRectUpdateID() const { return m_lastVisibleContentRectUpdate.updateID(); } 579 580 void dynamicViewportSizeUpdate(const WebCore::IntSize& minimumLayoutSize, const WebCore::FloatRect& targetExposedContentRect, const WebCore::FloatRect& targetUnobscuredRect, double targetScale); 579 581 580 582 void setViewportConfigurationMinimumLayoutSize(const WebCore::IntSize&); … … 1334 1336 WebCore::FloatSize viewportScreenSize(); 1335 1337 1338 void dynamicViewportUpdateChangedTarget(double newTargetScale, const WebCore::FloatPoint& newScrollPosition); 1336 1339 void didGetTapHighlightGeometries(uint64_t requestID, const WebCore::Color& color, const Vector<WebCore::FloatQuad>& geometries, const WebCore::IntSize& topLeftRadius, const WebCore::IntSize& topRightRadius, const WebCore::IntSize& bottomLeftRadius, const WebCore::IntSize& bottomRightRadius); 1337 1340 -
trunk/Source/WebKit2/UIProcess/WebPageProxy.messages.in
r166969 r167060 317 317 318 318 #if PLATFORM(IOS) 319 DynamicViewportUpdateChangedTarget(double newTargetScale, WebCore::FloatPoint newScrollPosition) 319 320 DidGetTapHighlightGeometries(uint64_t requestID, WebCore::Color color, Vector<WebCore::FloatQuad> geometries, WebCore::IntSize topLeftRadius, WebCore::IntSize topRightRadius, WebCore::IntSize bottomLeftRadius, WebCore::IntSize bottomRightRadius) 320 321 -
trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h
r166900 r167060 107 107 108 108 virtual void didCommitLayerTree(const RemoteLayerTreeTransaction&) override; 109 virtual void dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint& newScrollPosition) override; 109 110 110 111 virtual void startAssistingNode(const AssistedNodeInformation&, API::Object* userData) override; -
trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm
r166959 r167060 363 363 } 364 364 365 void PageClientImpl::dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint& newScrollPosition) 366 { 367 [m_webView _dynamicViewportUpdateChangedTargetToScale:newScale position:newScrollPosition]; 368 } 369 365 370 void PageClientImpl::startAssistingNode(const AssistedNodeInformation& nodeInformation, API::Object* userData) 366 371 { -
trunk/Source/WebKit2/UIProcess/ios/WKContentView.h
r166933 r167060 61 61 62 62 - (void)setMinimumSize:(CGSize)size; 63 - (void)setMinimumLayoutSize:(CGSize)size;64 63 - (void)didUpdateVisibleRect:(CGRect)visibleRect unobscuredRect:(CGRect)unobscuredRect scale:(CGFloat)scale inStableState:(BOOL)isStableState; 65 64 -
trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm
r166933 r167060 330 330 } 331 331 332 - (void)setMinimumLayoutSize:(CGSize)size333 {334 _page->setViewportConfigurationMinimumLayoutSize(IntSize(CGCeiling(size.width), CGCeiling(size.height)));335 }336 337 332 - (void)didFinishScrolling 338 333 { -
trunk/Source/WebKit2/UIProcess/ios/WebPageProxyIOS.mm
r166900 r167060 189 189 } 190 190 191 void WebPageProxy::dynamicViewportSizeUpdate(const IntSize& minimumLayoutSize, const FloatRect& targetExposedContentRect, const FloatRect& targetUnobscuredRect, double targetScale) 192 { 193 m_process->send(Messages::WebPage::DynamicViewportSizeUpdate(minimumLayoutSize, targetExposedContentRect, targetUnobscuredRect, targetScale), m_pageID); 194 } 195 191 196 void WebPageProxy::setViewportConfigurationMinimumLayoutSize(const WebCore::IntSize& size) 192 197 { … … 459 464 } 460 465 466 void WebPageProxy::dynamicViewportUpdateChangedTarget(double newScale, const WebCore::FloatPoint& newScrollPosition) 467 { 468 m_pageClient.dynamicViewportUpdateChangedTarget(newScale, newScrollPosition); 469 } 470 461 471 void WebPageProxy::didGetTapHighlightGeometries(uint64_t requestID, const WebCore::Color& color, const Vector<WebCore::FloatQuad>& highlightedQuads, const WebCore::IntSize& topLeftRadius, const WebCore::IntSize& topRightRadius, const WebCore::IntSize& bottomLeftRadius, const WebCore::IntSize& bottomRightRadius) 462 472 { -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h
r166975 r167060 693 693 #if PLATFORM(IOS) 694 694 void setViewportConfigurationMinimumLayoutSize(const WebCore::IntSize&); 695 void dynamicViewportSizeUpdate(const WebCore::IntSize& minimumLayoutSize, const WebCore::FloatRect& targetExposedContentRect, const WebCore::FloatRect& targetUnobscuredRect, double scale); 695 696 void viewportConfigurationChanged(); 696 697 void updateVisibleContentRects(const VisibleContentRectUpdateInfo&); -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
r166431 r167060 45 45 #if PLATFORM(IOS) 46 46 SetViewportConfigurationMinimumLayoutSize(WebCore::IntSize size) 47 DynamicViewportSizeUpdate(WebCore::IntSize minimumLayoutSize, WebCore::FloatRect targetExposedContentRect, WebCore::FloatRect targetUnobscuredRect, double scale) 47 48 48 49 HandleTap(WebCore::IntPoint point) -
trunk/Source/WebKit2/WebProcess/WebPage/ios/WebPageIOS.mm
r167038 r167060 1710 1710 } 1711 1711 1712 void WebPage::dynamicViewportSizeUpdate(const IntSize& minimumLayoutSize, const FloatRect& targetExposedContentRect, const FloatRect& targetUnobscuredRect, double targetScale) 1713 { 1714 // FIXME: this does not handle the cases where the content would change the content size or scroll position from JavaScript. 1715 // To handle those cases, we would need to redo this computation on every change until the next visible content rect update. 1716 1717 FrameView& frameView = *m_page->mainFrame().view(); 1718 IntSize oldContentSize = frameView.contentsSize(); 1719 1720 m_viewportConfiguration.setMinimumLayoutSize(minimumLayoutSize); 1721 IntSize newLayoutSize = m_viewportConfiguration.layoutSize(); 1722 setFixedLayoutSize(newLayoutSize); 1723 frameView.updateLayoutAndStyleIfNeededRecursive(); 1724 1725 IntSize newContentSize = frameView.contentsSize(); 1726 1727 double scale; 1728 if (!m_userHasChangedPageScaleFactor) 1729 scale = m_viewportConfiguration.initialScale(); 1730 else 1731 scale = std::max(std::min(targetScale, m_viewportConfiguration.maximumScale()), m_viewportConfiguration.minimumScale()); 1732 1733 FloatRect newUnobscuredContentRect = targetUnobscuredRect; 1734 FloatRect newExposedContentRect = targetExposedContentRect; 1735 1736 if (scale != targetScale) { 1737 // The target scale the UI is using cannot be reached by the content. We need to compute new targets based 1738 // on the viewport constraint and report everything back to the UIProcess. 1739 1740 // 1) Compute a new unobscured rect centered around the original one. 1741 double scaleDifference = targetScale / scale; 1742 double newUnobscuredRectWidth = targetUnobscuredRect.width() * scaleDifference; 1743 double newUnobscuredRectHeight = targetUnobscuredRect.height() * scaleDifference; 1744 double newUnobscuredRectX = targetUnobscuredRect.x() - (newUnobscuredRectWidth - targetUnobscuredRect.width()) / 2; 1745 double newUnobscuredRectY = targetUnobscuredRect.y() - (newUnobscuredRectHeight - targetUnobscuredRect.height()) / 2; 1746 newUnobscuredContentRect = FloatRect(newUnobscuredRectX, newUnobscuredRectY, newUnobscuredRectWidth, newUnobscuredRectHeight); 1747 1748 // 2) Extend our new unobscuredRect by the obscured margins to get a new exposed rect. 1749 double obscuredTopMargin = (targetUnobscuredRect.y() - targetExposedContentRect.y()) * scaleDifference; 1750 double obscuredLeftMargin = (targetUnobscuredRect.x() - targetExposedContentRect.x()) * scaleDifference; 1751 double obscuredBottomMargin = (targetExposedContentRect.maxY() - targetUnobscuredRect.maxY()) * scaleDifference; 1752 double obscuredRightMargin = (targetExposedContentRect.maxX() - targetUnobscuredRect.maxX()) * scaleDifference; 1753 newExposedContentRect = FloatRect(newUnobscuredRectX - obscuredLeftMargin, 1754 newUnobscuredRectY - obscuredTopMargin, 1755 newUnobscuredRectWidth + obscuredLeftMargin + obscuredRightMargin, 1756 newUnobscuredRectHeight + obscuredTopMargin + obscuredBottomMargin); 1757 1758 // FIXME: Adjust the rects based on the content. 1759 } 1760 1761 if (oldContentSize != newContentSize || scale != targetScale) { 1762 // Snap the new unobscured rect back into the content rect. 1763 newUnobscuredContentRect.setWidth(std::min(static_cast<float>(newContentSize.width()), newExposedContentRect.width())); 1764 newUnobscuredContentRect.setHeight(std::min(static_cast<float>(newContentSize.height()), newExposedContentRect.height())); 1765 1766 double horizontalAdjustment = 0; 1767 if (newExposedContentRect.maxX() > newContentSize.width()) 1768 horizontalAdjustment -= newExposedContentRect.maxX() - newContentSize.width(); 1769 double verticalAdjustment = 0; 1770 if (newExposedContentRect.maxY() > newContentSize.height()) 1771 verticalAdjustment -= newExposedContentRect.maxY() - newContentSize.height(); 1772 if (newExposedContentRect.x() < 0) 1773 horizontalAdjustment += - newExposedContentRect.x(); 1774 if (newExposedContentRect.y() < 0) 1775 verticalAdjustment += - newExposedContentRect.y(); 1776 1777 newUnobscuredContentRect.move(horizontalAdjustment, verticalAdjustment); 1778 newExposedContentRect.move(horizontalAdjustment, verticalAdjustment); 1779 } 1780 1781 frameView.setScrollVelocity(0, 0, 0, monotonicallyIncreasingTime()); 1782 1783 IntRect roundedUnobscuredContentRect = roundedIntRect(newUnobscuredContentRect); 1784 frameView.setScrollOffset(roundedUnobscuredContentRect.location()); 1785 frameView.setUnobscuredContentRect(roundedUnobscuredContentRect); 1786 m_drawingArea->setExposedContentRect(newExposedContentRect); 1787 1788 if (scale == targetScale) 1789 scalePage(scale, frameView.scrollPosition()); 1790 1791 if (scale != targetScale || roundedIntPoint(targetUnobscuredRect.location()) != roundedUnobscuredContentRect.location()) 1792 send(Messages::WebPageProxy::DynamicViewportUpdateChangedTarget(scale, frameView.scrollPosition())); 1793 } 1794 1712 1795 void WebPage::viewportConfigurationChanged() 1713 1796 {
Note: See TracChangeset
for help on using the changeset viewer.