[iOS][WK2] More animation madness for when the extendedBackground is modified in...
authorbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 May 2014 22:54:27 +0000 (22:54 +0000)
committerbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 2 May 2014 22:54:27 +0000 (22:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=132497

Patch by Benjamin Poulain <bpoulain@apple.com> on 2014-05-02
Reviewed by Beth Dakin.

* UIProcess/API/Cocoa/WKWebView.mm:
(updateTopAndBottomExtendedBackgroundExclusionIfNecessary):
Do not early return when _extendedBackgroundExclusionInsets.left is empty. That way, if executed in an animation block,
the top of bottom view will animate from their current size to an empty width.

When creating the layer, set up their height without animation. Otherwise it is possible to see the height animating
while the left inset is animating.

(-[WKWebView _setExtendedBackgroundExclusionInsets:]):
When replacing the scrollview, make sure the frame and color are not animated. Otherwise the transition between
scrollView and _mainExtendedBackgroundView can be visible if _setExtendedBackgroundExclusionInsets: is invoked
in an animation block.

(-[WKWebView _endAnimatedResize]):
Nuke the top and bottom insets when possible. [WKWebView _endAnimatedResize] is unfrequent, so it is a good opportunity
to free the memory.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@168203 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm

index 8dc7fde..63e756d 100644 (file)
@@ -1,3 +1,27 @@
+2014-05-02  Benjamin Poulain  <bpoulain@apple.com>
+
+        [iOS][WK2] More animation madness for when the extendedBackground is modified in an animation block
+        https://bugs.webkit.org/show_bug.cgi?id=132497
+
+        Reviewed by Beth Dakin.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (updateTopAndBottomExtendedBackgroundExclusionIfNecessary):
+        Do not early return when _extendedBackgroundExclusionInsets.left is empty. That way, if executed in an animation block,
+        the top of bottom view will animate from their current size to an empty width.
+
+        When creating the layer, set up their height without animation. Otherwise it is possible to see the height animating
+        while the left inset is animating.
+
+        (-[WKWebView _setExtendedBackgroundExclusionInsets:]):
+        When replacing the scrollview, make sure the frame and color are not animated. Otherwise the transition between
+        scrollView and _mainExtendedBackgroundView can be visible if _setExtendedBackgroundExclusionInsets: is invoked
+        in an animation block.
+
+        (-[WKWebView _endAnimatedResize]):
+        Nuke the top and bottom insets when possible. [WKWebView _endAnimatedResize] is unfrequent, so it is a good opportunity
+        to free the memory.
+
 2014-05-02  Alexey Proskuryakov  <ap@apple.com>
 
         Remove Blob contentDisposition handling
index 5fab627..f06ed19 100644 (file)
@@ -1298,15 +1298,15 @@ static inline WebKit::FindOptions toFindOptions(_WKFindOptions wkFindOptions)
 
 static void updateTopAndBottomExtendedBackgroundExclusionIfNecessary(WKWebView* webView)
 {
-    if (!webView->_extendedBackgroundExclusionInsets.left)
-        return;
-
     if (webView->_obscuredInsets.top && !webView->_extendedBackgroundExclusionInsets.top) {
         if (!webView->_extendedBackgroundLayerTopInset) {
             RetainPtr<UIView> backgroundView = adoptNS([[UIView alloc] init]);
             [backgroundView setBackgroundColor:webView->_mainExtendedBackgroundView.backgroundColor];
             [webView insertSubview:backgroundView.get() belowSubview:webView->_scrollView.get()];
             webView->_extendedBackgroundLayerTopInset = backgroundView.get();
+            [UIView performWithoutAnimation: ^{
+                [webView->_extendedBackgroundLayerTopInset setFrame:CGRectMake(0, 0, 0, webView->_obscuredInsets.top)];
+            }];
         }
 
         [webView->_extendedBackgroundLayerTopInset setFrame:CGRectMake(0, 0, webView->_extendedBackgroundExclusionInsets.left, webView->_obscuredInsets.top)];
@@ -1317,6 +1317,9 @@ static void updateTopAndBottomExtendedBackgroundExclusionIfNecessary(WKWebView*
             [backgroundView setBackgroundColor:webView->_mainExtendedBackgroundView.backgroundColor];
             [webView insertSubview:backgroundView.get() belowSubview:webView->_scrollView.get()];
             webView->_extendedBackgroundLayerBottomInset = backgroundView.get();
+            [UIView performWithoutAnimation: ^{
+                [webView->_extendedBackgroundLayerBottomInset setFrame:CGRectMake(0, webView.bounds.size.height - webView->_obscuredInsets.bottom, 0, webView->_obscuredInsets.bottom)];
+            }];
         }
         [webView->_extendedBackgroundLayerBottomInset setFrame:CGRectMake(0, webView.bounds.size.height - webView->_obscuredInsets.bottom, webView->_extendedBackgroundExclusionInsets.left, webView->_obscuredInsets.bottom)];
     }
@@ -1354,15 +1357,17 @@ static void updateTopAndBottomExtendedBackgroundExclusionIfNecessary(WKWebView*
     if (UIEdgeInsetsEqualToEdgeInsets(extendedBackgroundExclusionInsets, _extendedBackgroundExclusionInsets))
         return;
 
+    CGRect bounds = self.bounds;
     if (_mainExtendedBackgroundView == _scrollView) {
-        RetainPtr<UIView> backgroundView = adoptNS([[UIView alloc] init]);
-        _mainExtendedBackgroundView = backgroundView.get();
-        _mainExtendedBackgroundView.backgroundColor = [_scrollView backgroundColor];
-        [self insertSubview:_mainExtendedBackgroundView belowSubview:_scrollView.get()];
-        [_scrollView setBackgroundColor:nil];
+        [UIView performWithoutAnimation: ^{
+            RetainPtr<UIView> backgroundView = adoptNS([[UIView alloc] initWithFrame:bounds]);
+            _mainExtendedBackgroundView = backgroundView.get();
+            _mainExtendedBackgroundView.backgroundColor = [_scrollView backgroundColor];
+            [self insertSubview:_mainExtendedBackgroundView belowSubview:_scrollView.get()];
+            [_scrollView setBackgroundColor:nil];
+        }];
     }
 
-    CGRect bounds = self.bounds;
     _extendedBackgroundExclusionInsets = extendedBackgroundExclusionInsets;
     _mainExtendedBackgroundView.frame = UIEdgeInsetsInsetRect(bounds, _extendedBackgroundExclusionInsets);
 
@@ -1489,8 +1494,16 @@ static void updateTopAndBottomExtendedBackgroundExclusionIfNecessary(WKWebView*
         _resizeAnimationView = nil;
     }
 
-    _resizeAnimationTransformAdjustments = CATransform3DIdentity;
     _isAnimatingResize = NO;
+    _resizeAnimationTransformAdjustments = CATransform3DIdentity;
+
+    if (!_extendedBackgroundExclusionInsets.left) {
+        [_extendedBackgroundLayerTopInset removeFromSuperview];
+        _extendedBackgroundLayerTopInset = nil;
+        [_extendedBackgroundLayerBottomInset removeFromSuperview];
+        _extendedBackgroundLayerBottomInset = nil;
+    }
+
     [self _updateVisibleContentRects];
 }