Changeset 168560 in webkit
- Timestamp:
- May 9, 2014 5:11:26 PM (10 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r168559 r168560 1 2014-05-09 Simon Fraser <simon.fraser@apple.com> 2 3 [iOS WK2] Fixed elements can go outside the document on pinching 4 https://bugs.webkit.org/show_bug.cgi?id=132759 5 <rdar://problem/16870835> 6 7 Reviewed by Benjamin Poulain. 8 9 Constrain the rect used to position fixed position objects when pinching (when 10 the scale goes below the minimumScale). Do so in such a way that there's a smooth 11 transition between rubber-banding and pinching. 12 13 * UIProcess/API/Cocoa/WKWebView.mm: 14 (-[WKWebView _updateScrollViewBackground]): Use a nicer form for std::max<>. 15 (-[WKWebView _updateVisibleContentRects]): Pass the minimum scale. 16 * UIProcess/API/ios/WKViewIOS.mm: 17 (-[WKView _updateVisibleContentRects]): Ditto. 18 * UIProcess/ios/WKContentView.h: 19 * UIProcess/ios/WKContentView.mm: 20 (adjustedUnexposedEdge): Helper to adjust the left/top. 21 (adjustedUnexposedMaxEdge): Helper to adjust the right/bottom. 22 (fixedPositionRectFromExposedRect): 23 (-[WKContentView didUpdateVisibleRect:unobscuredRect:scale:minimumScale:inStableState:]): 24 (-[WKContentView didUpdateVisibleRect:unobscuredRect:scale:inStableState:]): Deleted. 25 1 26 2014-05-09 Zalan Bujtas <zalan@apple.com> 2 27 -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
r168556 r168560 448 448 if (zoomScale < minimumZoomScale) { 449 449 CGFloat slope = 12; 450 CGFloat opacity = std::max (1 - slope * (minimumZoomScale - zoomScale), static_cast<CGFloat>(0));450 CGFloat opacity = std::max<CGFloat>(1 - slope * (minimumZoomScale - zoomScale), 0); 451 451 cgColor = adoptCF(CGColorCreateCopyWithAlpha(cgColor.get(), opacity)); 452 452 } … … 780 780 781 781 BOOL isStableState = !(_isChangingObscuredInsetsInteractively || [_scrollView isDragging] || [_scrollView isDecelerating] || [_scrollView isZooming] || [_scrollView isZoomBouncing] || [_scrollView _isAnimatingZoom]); 782 [_contentView didUpdateVisibleRect:visibleRectInContentCoordinates unobscuredRect:unobscuredRectInContentCoordinates unobscuredRectInScrollViewCoordinates:unobscuredRect scale:scaleFactor inStableState:isStableState isChangingObscuredInsetsInteractively:_isChangingObscuredInsetsInteractively]; 782 [_contentView didUpdateVisibleRect:visibleRectInContentCoordinates 783 unobscuredRect:unobscuredRectInContentCoordinates 784 unobscuredRectInScrollViewCoordinates:unobscuredRect 785 scale:scaleFactor minimumScale:[_scrollView minimumZoomScale] 786 inStableState:isStableState isChangingObscuredInsetsInteractively:_isChangingObscuredInsetsInteractively]; 783 787 } 784 788 -
trunk/Source/WebKit2/UIProcess/API/ios/WKViewIOS.mm
r168556 r168560 262 262 CGRect unobscuredRectInContentCoordinates = [self convertRect:unobscuredRect toView:_contentView.get()]; 263 263 264 CGFloat scaleFactor = [_scrollView zoomScale]; 265 266 [_contentView didUpdateVisibleRect:visibleRectInContentCoordinates unobscuredRect:unobscuredRectInContentCoordinates unobscuredRectInScrollViewCoordinates:unobscuredRect scale:scaleFactor inStableState:YES isChangingObscuredInsetsInteractively:NO]; 264 [_contentView didUpdateVisibleRect:visibleRectInContentCoordinates 265 unobscuredRect:unobscuredRectInContentCoordinates 266 unobscuredRectInScrollViewCoordinates:unobscuredRect 267 scale:[_scrollView zoomScale] minimumScale:[_scrollView minimumZoomScale] 268 inStableState:YES isChangingObscuredInsetsInteractively:NO]; 267 269 } 268 270 -
trunk/Source/WebKit2/UIProcess/ios/WKContentView.h
r168556 r168560 61 61 62 62 - (void)setMinimumSize:(CGSize)size; 63 - (void)didUpdateVisibleRect:(CGRect)visibleRect unobscuredRect:(CGRect)unobscuredRect unobscuredRectInScrollViewCoordinates:(CGRect)unobscuredRectInScrollViewCoordinates scale:(CGFloat)scale inStableState:(BOOL)isStableState isChangingObscuredInsetsInteractively:(BOOL)isChangingObscuredInsetsInteractively; 63 - (void)didUpdateVisibleRect:(CGRect)visibleRect unobscuredRect:(CGRect)unobscuredRect 64 unobscuredRectInScrollViewCoordinates:(CGRect)unobscuredRectInScrollViewCoordinates 65 scale:(CGFloat)scale minimumScale:(CGFloat)minimumScale 66 inStableState:(BOOL)isStableState isChangingObscuredInsetsInteractively:(BOOL)isChangingObscuredInsetsInteractively; 64 67 65 68 - (void)didFinishScrolling; -
trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm
r168556 r168560 293 293 } 294 294 295 static inline FloatRect fixedPositionRectFromExposedRect(CGRect unobscuredRect, CGSize documentSize, CGFloat scale) 296 { 297 return FrameView::rectForViewportConstrainedObjects(enclosingLayoutRect(unobscuredRect), roundedLayoutSize(FloatSize(documentSize)), scale, false, StickToViewportBounds); 298 } 299 300 - (void)didUpdateVisibleRect:(CGRect)visibleRect unobscuredRect:(CGRect)unobscuredRect unobscuredRectInScrollViewCoordinates:(CGRect)unobscuredRectInScrollViewCoordinates scale:(CGFloat)zoomScale inStableState:(BOOL)isStableState isChangingObscuredInsetsInteractively:(BOOL)isChangingObscuredInsetsInteractively 295 static inline float adjustedUnexposedEdge(float documentEdge, float exposedRectEdge, float factor) 296 { 297 if (exposedRectEdge < documentEdge) 298 return documentEdge - factor * (documentEdge - exposedRectEdge); 299 300 return exposedRectEdge; 301 } 302 303 static inline float adjustedUnexposedMaxEdge(float documentEdge, float exposedRectEdge, float factor) 304 { 305 if (exposedRectEdge > documentEdge) 306 return documentEdge + factor * (exposedRectEdge - documentEdge); 307 308 return exposedRectEdge; 309 } 310 311 static inline FloatRect fixedPositionRectFromExposedRect(CGRect unobscuredRect, CGSize documentSize, CGFloat scale, CGFloat minimumScale) 312 { 313 FloatRect constrainedUnobscuredRect = unobscuredRect; 314 FloatRect documentRect = FloatRect(FloatPoint(), FloatSize(documentSize)); 315 316 if (scale < minimumScale) { 317 const CGFloat slope = 12; 318 CGFloat factor = std::max<CGFloat>(1 - slope * (minimumScale - scale), 0); 319 320 constrainedUnobscuredRect.setX(adjustedUnexposedEdge(documentRect.x(), constrainedUnobscuredRect.x(), factor)); 321 constrainedUnobscuredRect.setY(adjustedUnexposedEdge(documentRect.y(), constrainedUnobscuredRect.y(), factor)); 322 constrainedUnobscuredRect.setWidth(adjustedUnexposedMaxEdge(documentRect.maxX(), constrainedUnobscuredRect.maxX(), factor) - constrainedUnobscuredRect.x()); 323 constrainedUnobscuredRect.setHeight(adjustedUnexposedMaxEdge(documentRect.maxY(), constrainedUnobscuredRect.maxY(), factor) - constrainedUnobscuredRect.y()); 324 } 325 326 return FrameView::rectForViewportConstrainedObjects(enclosingLayoutRect(constrainedUnobscuredRect), roundedLayoutSize(FloatSize(documentSize)), scale, false, StickToViewportBounds); 327 } 328 329 - (void)didUpdateVisibleRect:(CGRect)visibleRect unobscuredRect:(CGRect)unobscuredRect unobscuredRectInScrollViewCoordinates:(CGRect)unobscuredRectInScrollViewCoordinates 330 scale:(CGFloat)zoomScale minimumScale:(CGFloat)minimumScale inStableState:(BOOL)isStableState isChangingObscuredInsetsInteractively:(BOOL)isChangingObscuredInsetsInteractively 301 331 { 302 332 double timestamp = monotonicallyIncreasingTime(); … … 315 345 } 316 346 317 FloatRect customFixedPositionRect = fixedPositionRectFromExposedRect(unobscuredRect, [self bounds].size, zoomScale );347 FloatRect customFixedPositionRect = fixedPositionRectFromExposedRect(unobscuredRect, [self bounds].size, zoomScale, minimumScale); 318 348 _page->updateVisibleContentRects(VisibleContentRectUpdateInfo(_page->nextVisibleContentRectUpdateID(), visibleRect, unobscuredRect, unobscuredRectInScrollViewCoordinates, customFixedPositionRect, filteredScale, isStableState, isChangingObscuredInsetsInteractively, timestamp, velocityData.horizontalVelocity, velocityData.verticalVelocity, velocityData.scaleChangeRate)); 319 349 320 350 RemoteScrollingCoordinatorProxy* scrollingCoordinator = _page->scrollingCoordinatorProxy(); 321 scrollingCoordinator->viewportChangedViaDelegatedScrolling(scrollingCoordinator->rootScrollingNodeID(), unobscuredRect, zoomScale);351 scrollingCoordinator->viewportChangedViaDelegatedScrolling(scrollingCoordinator->rootScrollingNodeID(), customFixedPositionRect, zoomScale); 322 352 323 353 if (auto drawingArea = _page->drawingArea())
Note: See TracChangeset
for help on using the changeset viewer.