Changeset 169109 in webkit
- Timestamp:
- May 20, 2014 6:56:27 AM (10 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r169095 r169109 1 2014-05-20 Antti Koivisto <antti@apple.com> 2 3 Double-tap zoom does not take obscuring insets into account 4 https://bugs.webkit.org/show_bug.cgi?id=133116 5 <rdar://problem/16765604> 6 7 Reviewed by Anders Carlsson. 8 9 * UIProcess/API/Cocoa/WKWebView.mm: 10 (-[WKWebView _zoomToRect:WebCore::atScale:origin:WebCore::]): 11 12 Compute the zoom target taking insets into account. 13 1 14 2014-05-19 Gavin Barraclough <baraclough@apple.com> 2 15 -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
r169023 r169109 597 597 - (void)_zoomToRect:(WebCore::FloatRect)targetRect atScale:(double)scale origin:(WebCore::FloatPoint)origin 598 598 { 599 WebCore::FloatSize unobscuredContentSize([self _contentRectForUserInteraction].size); 600 WebCore::FloatSize targetRectSizeAfterZoom = targetRect.size(); 601 targetRectSizeAfterZoom.scale(scale); 602 603 // Center the target rect in the scroll view. 604 // If the target doesn't fit in the scroll view, center on the gesture location instead. 605 WebCore::FloatPoint zoomCenter = targetRect.center(); 606 607 if (targetRectSizeAfterZoom.width() > unobscuredContentSize.width()) 608 zoomCenter.setX(origin.x()); 609 if (targetRectSizeAfterZoom.height() > unobscuredContentSize.height()) 610 zoomCenter.setY(origin.y()); 611 612 [self _zoomToPoint:zoomCenter atScale:scale]; 599 // FIMXE: Some of this could be shared with _scrollToRect. 600 const double visibleRectScaleChange = contentZoomScale(self) / scale; 601 const WebCore::FloatRect visibleRect([self convertRect:self.bounds toView:_contentView.get()]); 602 const WebCore::FloatRect unobscuredRect([self _contentRectForUserInteraction]); 603 604 const WebCore::FloatSize topLeftObscuredInsetAfterZoom((unobscuredRect.minXMinYCorner() - visibleRect.minXMinYCorner()) * visibleRectScaleChange); 605 const WebCore::FloatSize bottomRightObscuredInsetAfterZoom((visibleRect.maxXMaxYCorner() - unobscuredRect.maxXMaxYCorner()) * visibleRectScaleChange); 606 607 const WebCore::FloatSize unobscuredRectSizeAfterZoom(unobscuredRect.size() * visibleRectScaleChange); 608 609 // Center to the target rect. 610 WebCore::FloatPoint unobscuredRectLocationAfterZoom = targetRect.location() - (unobscuredRectSizeAfterZoom - targetRect.size()) * 0.5; 611 612 // Center to the tap point instead in case the target rect won't fit in a direction. 613 if (targetRect.width() > unobscuredRectSizeAfterZoom.width()) 614 unobscuredRectLocationAfterZoom.setX(origin.x() - unobscuredRectSizeAfterZoom.width() / 2); 615 if (targetRect.height() > unobscuredRectSizeAfterZoom.height()) 616 unobscuredRectLocationAfterZoom.setY(origin.y() - unobscuredRectSizeAfterZoom.height() / 2); 617 618 // We have computed where we want the unobscured rect to be. Now adjust for the obscuring insets. 619 WebCore::FloatRect visibleRectAfterZoom(unobscuredRectLocationAfterZoom, unobscuredRectSizeAfterZoom); 620 visibleRectAfterZoom.move(-topLeftObscuredInsetAfterZoom); 621 visibleRectAfterZoom.expand(topLeftObscuredInsetAfterZoom + bottomRightObscuredInsetAfterZoom); 622 623 [self _zoomToPoint:visibleRectAfterZoom.center() atScale:scale]; 613 624 } 614 625
Note: See TracChangeset
for help on using the changeset viewer.