Changeset 167274 in webkit


Ignore:
Timestamp:
Apr 14, 2014 3:39:18 PM (10 years ago)
Author:
benjamin@webkit.org
Message:

[iOS][WK2] Change the SPI used when starting the rotation animation
https://bugs.webkit.org/show_bug.cgi?id=131638

Patch by Benjamin Poulain <bpoulain@apple.com> on 2014-04-14
Reviewed by Tim Horton.

Having an update block where all the properties are changed is more convenient for Safari.

  • UIProcess/API/Cocoa/WKWebView.mm:

(-[WKWebView _beginAnimatedResizeWithUpdates:]):
(-[WKWebView _beginAnimatedResizeToSize:obscuredInsets:minimumLayoutSizeOverride:]): Deleted.

  • UIProcess/API/Cocoa/WKWebViewPrivate.h:
Location:
trunk/Source/WebKit2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r167273 r167274  
     12014-04-14  Benjamin Poulain  <bpoulain@apple.com>
     2
     3        [iOS][WK2] Change the SPI used when starting the rotation animation
     4        https://bugs.webkit.org/show_bug.cgi?id=131638
     5
     6        Reviewed by Tim Horton.
     7
     8        Having an update block where all the properties are changed is more convenient for Safari.
     9
     10        * UIProcess/API/Cocoa/WKWebView.mm:
     11        (-[WKWebView _beginAnimatedResizeWithUpdates:]):
     12        (-[WKWebView _beginAnimatedResizeToSize:obscuredInsets:minimumLayoutSizeOverride:]): Deleted.
     13        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
     14
    1152014-04-14  Simon Fraser  <simon.fraser@apple.com>
    216
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm

    r167262 r167274  
    12431243}
    12441244
    1245 - (void)_beginAnimatedResizeToSize:(CGSize)futureSize obscuredInsets:(UIEdgeInsets)futureObscuredInsets minimumLayoutSizeOverride:(CGSize)futureMinimumLayoutSize
     1245- (void)_beginAnimatedResizeWithUpdates:(void (^)(void))updateBlock
    12461246{
    12471247    _isAnimatingResize = YES;
    12481248    _resizeAnimationTransformAdjustments = CATransform3DIdentity;
    12491249
     1250    CGRect oldBounds = self.bounds;
     1251    CGSize oldMinimumLayoutSize = oldBounds.size;
     1252    if (_hasStaticMinimumLayoutSize)
     1253        oldMinimumLayoutSize = _minimumLayoutSizeOverride;
     1254    WebCore::FloatRect oldUnobscuredContentRect = _page->unobscuredContentRect();
     1255
     1256    updateBlock();
     1257
    12501258    if (_customContentView)
    12511259        return;
    12521260
     1261    CGRect newBounds = self.bounds;
     1262    CGSize newMinimumLayoutSize = newBounds.size;
     1263    if (_hasStaticMinimumLayoutSize)
     1264        newMinimumLayoutSize = _minimumLayoutSizeOverride;
     1265
     1266    if (CGSizeEqualToSize(newMinimumLayoutSize, oldMinimumLayoutSize) && CGRectEqualToRect(newBounds, oldBounds))
     1267        return;
     1268
    12531269    CGSize contentSizeInContentViewCoordinates = [_contentView bounds].size;
    1254     [_scrollView setMinimumZoomScale:std::min(futureSize.width / contentSizeInContentViewCoordinates.width, [_scrollView minimumZoomScale])];
    1255 
    1256     _obscuredInsets = futureObscuredInsets;
    1257     if (_hasStaticMinimumLayoutSize)
    1258         _minimumLayoutSizeOverride = futureMinimumLayoutSize;
    1259 
    1260     CGRect oldBounds = self.bounds;
    1261     WebCore::FloatRect originalUnobscuredContentRect = _page->unobscuredContentRect();
    1262 
    1263     CGRect futureBounds = oldBounds;
    1264     futureBounds.size = futureSize;
    1265     [self setBounds:futureBounds];
     1270    [_scrollView setMinimumZoomScale:std::min(newBounds.size.width / contentSizeInContentViewCoordinates.width, [_scrollView minimumZoomScale])];
    12661271
    12671272    // Compute the new scale to keep the current content width in the scrollview.
    12681273    CGFloat oldWebViewWidthInContentViewCoordinates = oldBounds.size.width / contentZoomScale(self);
    12691274    CGFloat visibleContentViewWidthInContentCoordinates = std::min(contentSizeInContentViewCoordinates.width, oldWebViewWidthInContentViewCoordinates);
    1270     CGFloat targetScale = futureBounds.size.width / visibleContentViewWidthInContentCoordinates;
     1275    CGFloat targetScale = newBounds.size.width / visibleContentViewWidthInContentCoordinates;
    12711276    [_scrollView setZoomScale:targetScale];
    12721277
    12731278    // Compute a new position to keep the content centered.
    1274     CGPoint originalContentCenter = originalUnobscuredContentRect.center();
     1279    CGPoint originalContentCenter = oldUnobscuredContentRect.center();
    12751280    CGPoint originalContentCenterInSelfCoordinates = [self convertPoint:originalContentCenter fromView:_contentView.get()];
    1276     CGRect futureUnobscuredRectInSelfCoordinates = UIEdgeInsetsInsetRect(futureBounds, futureObscuredInsets);
     1281    CGRect futureUnobscuredRectInSelfCoordinates = UIEdgeInsetsInsetRect(newBounds, _obscuredInsets);
    12771282    CGPoint futureUnobscuredRectCenterInSelfCoordinates = CGPointMake(futureUnobscuredRectInSelfCoordinates.origin.x + futureUnobscuredRectInSelfCoordinates.size.width / 2, futureUnobscuredRectInSelfCoordinates.origin.y + futureUnobscuredRectInSelfCoordinates.size.height / 2);
    12781283
     
    12841289    // Limit the new offset within the scrollview, we do not want to rubber band programmatically.
    12851290    CGSize futureContentSizeInSelfCoordinates = CGSizeMake(contentSizeInContentViewCoordinates.width * targetScale, contentSizeInContentViewCoordinates.height * targetScale);
    1286     CGFloat maxHorizontalOffset = futureContentSizeInSelfCoordinates.width - futureBounds.size.width + _obscuredInsets.right;
     1291    CGFloat maxHorizontalOffset = futureContentSizeInSelfCoordinates.width - newBounds.size.width + _obscuredInsets.right;
    12871292    contentOffset.x = std::min(contentOffset.x, maxHorizontalOffset);
    1288     CGFloat maxVerticalOffset = futureContentSizeInSelfCoordinates.height - futureBounds.size.height + _obscuredInsets.bottom;
     1293    CGFloat maxVerticalOffset = futureContentSizeInSelfCoordinates.height - newBounds.size.height + _obscuredInsets.bottom;
    12891294    contentOffset.y = std::min(contentOffset.y, maxVerticalOffset);
    12901295
     
    12931298
    12941299    // Make the top/bottom edges "sticky" within 1 pixel.
    1295     if (originalUnobscuredContentRect.maxY() > contentSizeInContentViewCoordinates.height - 1)
     1300    if (oldUnobscuredContentRect.maxY() > contentSizeInContentViewCoordinates.height - 1)
    12961301        contentOffset.y = maxVerticalOffset;
    1297     if (originalUnobscuredContentRect.y() < 1)
     1302    if (oldUnobscuredContentRect.y() < 1)
    12981303        contentOffset.y = -_obscuredInsets.top;
    12991304
     
    13011306    [_scrollView setContentOffset:contentOffset];
    13021307
    1303     CGRect visibleRectInContentCoordinates = [self convertRect:futureBounds toView:_contentView.get()];
    1304 
    1305     CGRect unobscuredRect = UIEdgeInsetsInsetRect(futureBounds, _obscuredInsets);
     1308    CGRect visibleRectInContentCoordinates = [self convertRect:newBounds toView:_contentView.get()];
     1309
     1310    CGRect unobscuredRect = UIEdgeInsetsInsetRect(newBounds, _obscuredInsets);
    13061311    CGRect unobscuredRectInContentCoordinates = [self convertRect:unobscuredRect toView:_contentView.get()];
    13071312
    1308     _page->dynamicViewportSizeUpdate(WebCore::IntSize(CGCeiling(futureMinimumLayoutSize.width), CGCeiling(futureMinimumLayoutSize.height)), visibleRectInContentCoordinates, unobscuredRectInContentCoordinates, targetScale);
     1313    _page->dynamicViewportSizeUpdate(WebCore::IntSize(CGCeiling(newMinimumLayoutSize.width), CGCeiling(newMinimumLayoutSize.height)), visibleRectInContentCoordinates, unobscuredRectInContentCoordinates, targetScale);
    13091314}
    13101315
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h

    r166933 r167274  
    109109- (void)_endInteractiveObscuredInsetsChange;
    110110
    111 - (void)_beginAnimatedResizeToSize:(CGSize)futureSize obscuredInsets:(UIEdgeInsets)futureObscuredInsets minimumLayoutSizeOverride:(CGSize)futureMinimumLayoutSize;
     111- (void)_beginAnimatedResizeWithUpdates:(void (^)(void))updateBlock;
    112112- (void)_endAnimatedResize;
    113113
Note: See TracChangeset for help on using the changeset viewer.