Title: [212459] trunk
Revision
212459
Author
[email protected]
Date
2017-02-16 13:09:40 -0800 (Thu, 16 Feb 2017)

Log Message

WKWebView inside a UICollectionView flashes when items are inserted above it
https://bugs.webkit.org/show_bug.cgi?id=168376
<rdar://problem/29322051>

Reviewed by Simon Fraser.

Previously, we would immediately send visible content rect updates
whenever we scrolled, or our frame or bounds changed, or ... a whole
bunch of other things. This message would be immediately sent to the
Web Content process, and coalesced at the whims of the Web Content process
main thread. However, if we received multiple such updates within the
same runloop cycle in the UI process, the Web Content process could
send back layer tree commits for intermediate states that would
never make it to the screen.

In the UICollectionView case, UIKit would first scroll to the new location
(potentially putting the WKWebView totally off-screen), and then update
our frame (back on screen), and we would get two layer tree commits;
one, with less tile coverage than needed to cover the area, and another
with full coverage.

Instead, wait until just before we commit the UI-side layer tree (and
thus everyone is done moving things around) to push the new visible 
rect info to the Web Content process.

So far, I have not found a way to test that reliably fails before
and reliably passes after without adding a ton of supporting code to WebKit.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _didInvokeUIScrollViewDelegateCallback]):
(-[WKWebView _didCommitLayerTree:]):
(-[WKWebView _didFinishScrolling]):
(-[WKWebView scrollViewDidScroll:]):
(-[WKWebView scrollViewDidZoom:]):
(-[WKWebView scrollViewDidEndZooming:withView:atScale:]):
(-[WKWebView _scrollViewDidInterruptDecelerating:]):
(-[WKWebView _didScroll]):
(-[WKWebView _enclosingScrollerScrollingEnded:]):
(-[WKWebView _frameOrBoundsChanged]):
(-[WKWebView _scheduleVisibleContentRectUpdate]):
(-[WKWebView _scrollViewIsInStableState:]):
(-[WKWebView _scheduleVisibleContentRectUpdateAfterScrollInView:]):
(-[WKWebView _keyboardChangedWithInfo:adjustScrollView:]):
(-[WKWebView _setObscuredInsets:]):
(-[WKWebView _endInteractiveObscuredInsetsChange]):
(-[WKWebView _beginAnimatedResizeWithUpdates:]):
(-[WKWebView _endAnimatedResize]):
(-[WKWebView _updateVisibleContentRects]): Deleted.
(-[WKWebView _updateVisibleContentRectAfterScrollInView:]): Deleted.
* UIProcess/API/Cocoa/WKWebViewInternal.h:
* UIProcess/ios/WKContentView.mm:
(-[WKContentView _didCommitLayerTree:]):
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _startAssistingNode:userIsInteracting:blurPreviousNode:userObject:]):
(-[WKContentView _stopAssistingNode]):
* UIProcess/ios/WKScrollView.mm:
(-[WKScrollView setContentInset:]):
Have existing callers of _updateVisibleContentRect* instead call
_scheduleVisibleContentRectUpdate*.

In _scheduleVisibleContentRectUpdate, schedule a pre-commit callback
in which we will compute the new visible content rect information
and send it to the Web Content process.

Keep track of the stable state of the scroll view which most recently
scheduled an update, and use that to inform _updateVisibleContentRects.
This matches the previous behavior where the updates might get coalesced
in the Web Content process, and the most recent update wins.

Make a few callers of _updateVisibleContentRectAfterScrollInView
that passed in our scroll view just use _scheduleVisibleContentRectUpdate instead.

* WebKitTestRunner/cocoa/TestRunnerWKWebView.mm:
(-[TestRunnerWKWebView _setStableStateOverride:]):
Update the one external caller of this internal method...

* DumpRenderTree/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptController::doAfterVisibleContentRectUpdate):
* DumpRenderTree/mac/UIScriptControllerMac.mm:
(WTR::UIScriptController::doAfterVisibleContentRectUpdate):
* TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
* TestRunnerShared/UIScriptContext/UIScriptController.cpp:
(WTR::UIScriptController::doAfterVisibleContentRectUpdate):
* TestRunnerShared/UIScriptContext/UIScriptController.h:
* WebKitTestRunner/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptController::doAfterVisibleContentRectUpdate):
* WebKitTestRunner/mac/UIScriptControllerMac.mm:
(WTR::UIScriptController::doAfterVisibleContentRectUpdate):
Expose doAfterVisibleContentRectUpdate to DRT and WKTR. It is called
back after we dispatch a visible content rect update from the UI process
to the Web Content process, so any messages sent from the block will arrive
after the visible content rect update.

* scrollingcoordinator/ios/sync-layer-positions-after-scroll.html:
* scrollingcoordinator/ios/sync-layer-positions-after-scroll-expected.txt:
Make use of doAfterVisibleContentRectUpdate; we previously were 
guaranteed by message ordering that our uiScriptComplete message
would arrive after the visible content rect update, but that is 
no longer the case.

Also, adjust to have a initial scale and flexible viewport in order
to work around https://bugs.webkit.org/show_bug.cgi?id=168403.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (212458 => 212459)


--- trunk/LayoutTests/ChangeLog	2017-02-16 21:04:25 UTC (rev 212458)
+++ trunk/LayoutTests/ChangeLog	2017-02-16 21:09:40 UTC (rev 212459)
@@ -1,3 +1,21 @@
+2017-02-16  Tim Horton  <[email protected]>
+
+        WKWebView inside a UICollectionView flashes when items are inserted above it
+        https://bugs.webkit.org/show_bug.cgi?id=168376
+        <rdar://problem/29322051>
+
+        Reviewed by Simon Fraser.
+
+        * scrollingcoordinator/ios/sync-layer-positions-after-scroll.html:
+        * scrollingcoordinator/ios/sync-layer-positions-after-scroll-expected.txt:
+        Make use of doAfterVisibleContentRectUpdate; we previously were 
+        guaranteed by message ordering that our uiScriptComplete message
+        would arrive after the visible content rect update, but that is 
+        no longer the case.
+
+        Also, adjust to have a initial scale and flexible viewport in order
+        to work around https://bugs.webkit.org/show_bug.cgi?id=168403.
+
 2017-02-16  Alex Christensen  <[email protected]>
 
         Remove EFL test expectations.

Modified: trunk/LayoutTests/scrollingcoordinator/ios/sync-layer-positions-after-scroll-expected.txt (212458 => 212459)


--- trunk/LayoutTests/scrollingcoordinator/ios/sync-layer-positions-after-scroll-expected.txt	2017-02-16 21:04:25 UTC (rev 212458)
+++ trunk/LayoutTests/scrollingcoordinator/ios/sync-layer-positions-after-scroll-expected.txt	2017-02-16 21:09:40 UTC (rev 212459)
@@ -1,4 +1,4 @@
-visibleRectAfterScroll: {"left":0,"top":190,"width":800,"height":600}
+visibleRectAfterScroll: {"left":0,"top":190,"width":320,"height":548}
 (GraphicsLayer
   (anchor 0.00 0.00)
   (bounds 1308.00 2021.00)

Modified: trunk/LayoutTests/scrollingcoordinator/ios/sync-layer-positions-after-scroll.html (212458 => 212459)


--- trunk/LayoutTests/scrollingcoordinator/ios/sync-layer-positions-after-scroll.html	2017-02-16 21:04:25 UTC (rev 212458)
+++ trunk/LayoutTests/scrollingcoordinator/ios/sync-layer-positions-after-scroll.html	2017-02-16 21:09:40 UTC (rev 212459)
@@ -1,7 +1,8 @@
-<!DOCTYPE html>
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
 
 <html>
 <head>
+    <meta name="viewport" content="initial-scale=1.0">
     <style>
         body {
             width: 1300px;
@@ -75,7 +76,9 @@
                 };
 
                 uiController.sendEventStream(JSON.stringify(movedFingerDownStream), function() {
-                    uiController.uiScriptComplete(JSON.stringify(uiController.contentVisibleRect));
+                    uiController.doAfterVisibleContentRectUpdate(function () {
+                        uiController.uiScriptComplete(JSON.stringify(uiController.contentVisibleRect));
+                    });
                 });
             })();`;
         }
@@ -102,7 +105,7 @@
                 testRunner.runUIScript(getDragUIScript(xPos, startY, xPos, endY), function(visibleRectAfterScroll) {
                     var result = 'visibleRectAfterScroll: ' + visibleRectAfterScroll + '\n' + internals.layerTreeAsText(document);
                     document.getElementById('layers').textContent = result;
-                    // Now send the finel touch up.
+                    // Now send the final touch up.
                     testRunner.runUIScript(getFingerUpUIScript(xPos, endY), function() {
                         testRunner.notifyDone();
                     });

Modified: trunk/Source/WebKit2/ChangeLog (212458 => 212459)


--- trunk/Source/WebKit2/ChangeLog	2017-02-16 21:04:25 UTC (rev 212458)
+++ trunk/Source/WebKit2/ChangeLog	2017-02-16 21:09:40 UTC (rev 212459)
@@ -1,3 +1,77 @@
+2017-02-16  Tim Horton  <[email protected]>
+
+        WKWebView inside a UICollectionView flashes when items are inserted above it
+        https://bugs.webkit.org/show_bug.cgi?id=168376
+        <rdar://problem/29322051>
+
+        Reviewed by Simon Fraser.
+
+        Previously, we would immediately send visible content rect updates
+        whenever we scrolled, or our frame or bounds changed, or ... a whole
+        bunch of other things. This message would be immediately sent to the
+        Web Content process, and coalesced at the whims of the Web Content process
+        main thread. However, if we received multiple such updates within the
+        same runloop cycle in the UI process, the Web Content process could
+        send back layer tree commits for intermediate states that would
+        never make it to the screen.
+
+        In the UICollectionView case, UIKit would first scroll to the new location
+        (potentially putting the WKWebView totally off-screen), and then update
+        our frame (back on screen), and we would get two layer tree commits;
+        one, with less tile coverage than needed to cover the area, and another
+        with full coverage.
+
+        Instead, wait until just before we commit the UI-side layer tree (and
+        thus everyone is done moving things around) to push the new visible 
+        rect info to the Web Content process.
+
+        So far, I have not found a way to test that reliably fails before
+        and reliably passes after without adding a ton of supporting code to WebKit.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _didInvokeUIScrollViewDelegateCallback]):
+        (-[WKWebView _didCommitLayerTree:]):
+        (-[WKWebView _didFinishScrolling]):
+        (-[WKWebView scrollViewDidScroll:]):
+        (-[WKWebView scrollViewDidZoom:]):
+        (-[WKWebView scrollViewDidEndZooming:withView:atScale:]):
+        (-[WKWebView _scrollViewDidInterruptDecelerating:]):
+        (-[WKWebView _didScroll]):
+        (-[WKWebView _enclosingScrollerScrollingEnded:]):
+        (-[WKWebView _frameOrBoundsChanged]):
+        (-[WKWebView _scheduleVisibleContentRectUpdate]):
+        (-[WKWebView _scrollViewIsInStableState:]):
+        (-[WKWebView _scheduleVisibleContentRectUpdateAfterScrollInView:]):
+        (-[WKWebView _keyboardChangedWithInfo:adjustScrollView:]):
+        (-[WKWebView _setObscuredInsets:]):
+        (-[WKWebView _endInteractiveObscuredInsetsChange]):
+        (-[WKWebView _beginAnimatedResizeWithUpdates:]):
+        (-[WKWebView _endAnimatedResize]):
+        (-[WKWebView _updateVisibleContentRects]): Deleted.
+        (-[WKWebView _updateVisibleContentRectAfterScrollInView:]): Deleted.
+        * UIProcess/API/Cocoa/WKWebViewInternal.h:
+        * UIProcess/ios/WKContentView.mm:
+        (-[WKContentView _didCommitLayerTree:]):
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _startAssistingNode:userIsInteracting:blurPreviousNode:userObject:]):
+        (-[WKContentView _stopAssistingNode]):
+        * UIProcess/ios/WKScrollView.mm:
+        (-[WKScrollView setContentInset:]):
+        Have existing callers of _updateVisibleContentRect* instead call
+        _scheduleVisibleContentRectUpdate*.
+
+        In _scheduleVisibleContentRectUpdate, schedule a pre-commit callback
+        in which we will compute the new visible content rect information
+        and send it to the Web Content process.
+
+        Keep track of the stable state of the scroll view which most recently
+        scheduled an update, and use that to inform _updateVisibleContentRects.
+        This matches the previous behavior where the updates might get coalesced
+        in the Web Content process, and the most recent update wins.
+
+        Make a few callers of _updateVisibleContentRectAfterScrollInView
+        that passed in our scroll view just use _scheduleVisibleContentRectUpdate instead.
+
 2017-02-16  Brent Fulgham  <[email protected]>
 
         [WebRTC][Mac] Conditionally add sandbox extensions to the Network Process

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (212458 => 212459)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2017-02-16 21:04:25 UTC (rev 212458)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2017-02-16 21:09:40 UTC (rev 212459)
@@ -286,6 +286,10 @@
     RetainPtr<NSMutableArray> _stableStatePresentationUpdateCallbacks;
 
     RetainPtr<WKPasswordView> _passwordView;
+
+    BOOL _hasInstalledPreCommitHandlerForVisibleRectUpdate;
+    BOOL _visibleContentRectUpdateScheduledFromScrollViewInStableState;
+    Vector<BlockPtr<void ()>> _visibleContentRectUpdateCallbacks;
 #endif
 #if PLATFORM(MAC)
     std::unique_ptr<WebKit::WebViewImpl> _impl;
@@ -1194,7 +1198,7 @@
     _delayUpdateVisibleContentRects = NO;
     if (_hadDelayedUpdateVisibleContentRects) {
         _hadDelayedUpdateVisibleContentRects = NO;
-        [self _updateVisibleContentRectAfterScrollInView:_scrollView.get()];
+        [self _scheduleVisibleContentRectUpdate];
     }
 }
 
@@ -1464,7 +1468,7 @@
     }
 
     if (needUpdateVisbleContentRects)
-        [self _updateVisibleContentRects];
+        [self _scheduleVisibleContentRectUpdate];
 
     if (WebKit::RemoteLayerTreeScrollingPerformanceData* scrollPerfData = _page->scrollingPerformanceData())
         scrollPerfData->didCommitLayerTree([self visibleRectInViewCoordinates]);
@@ -1992,7 +1996,7 @@
     if (![self usesStandardContentView])
         return;
 
-    [self _updateVisibleContentRectAfterScrollInView:_scrollView.get()];
+    [self _scheduleVisibleContentRectUpdate];
     [_contentView didFinishScrolling];
 }
 
@@ -2046,7 +2050,7 @@
     if (![self usesStandardContentView])
         [_customContentView scrollViewDidScroll:(UIScrollView *)scrollView];
 
-    [self _updateVisibleContentRectAfterScrollInView:scrollView];
+    [self _scheduleVisibleContentRectUpdateAfterScrollInView:scrollView];
     
     if (WebKit::RemoteLayerTreeScrollingPerformanceData* scrollPerfData = _page->scrollingPerformanceData())
         scrollPerfData->didScroll([self visibleRectInViewCoordinates]);
@@ -2055,13 +2059,13 @@
 - (void)scrollViewDidZoom:(UIScrollView *)scrollView
 {
     [self _updateScrollViewBackground];
-    [self _updateVisibleContentRectAfterScrollInView:scrollView];
+    [self _scheduleVisibleContentRectUpdateAfterScrollInView:scrollView];
 }
 
 - (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(CGFloat)scale
 {
     ASSERT(scrollView == _scrollView);
-    [self _updateVisibleContentRectAfterScrollInView:scrollView];
+    [self _scheduleVisibleContentRectUpdateAfterScrollInView:scrollView];
     [_contentView didZoomToScale:scale];
 }
 
@@ -2076,7 +2080,7 @@
         return;
 
     [_contentView didInterruptScrolling];
-    [self _updateVisibleContentRectAfterScrollInView:scrollView];
+    [self _scheduleVisibleContentRectUpdateAfterScrollInView:scrollView];
 }
 
 - (CGRect)_visibleRectInEnclosingScrollView:(UIScrollView *)enclosingScrollView
@@ -2107,7 +2111,7 @@
 // Called when some ancestor UIScrollView scrolls.
 - (void)_didScroll
 {
-    [self _updateVisibleContentRectAfterScrollInView:[self _scroller]];
+    [self _scheduleVisibleContentRectUpdateAfterScrollInView:[self _scroller]];
 
     const NSTimeInterval ScrollingEndedTimerInterval = 0.032;
     if (!_enclosingScrollViewScrollTimer) {
@@ -2125,7 +2129,7 @@
         return;
     }
 
-    [self _updateVisibleContentRects];
+    [self _scheduleVisibleContentRectUpdate];
     [_enclosingScrollViewScrollTimer invalidate];
     _enclosingScrollViewScrollTimer = nil;
 }
@@ -2150,7 +2154,7 @@
     }
 
     [_customContentView web_setMinimumSize:bounds.size];
-    [self _updateVisibleContentRects];
+    [self _scheduleVisibleContentRectUpdate];
 }
 
 // Unobscured content rect where the user can interact. When the keyboard is up, this should be the area above or below the keyboard, wherever there is enough space.
@@ -2173,23 +2177,22 @@
     return !pointsEqualInDevicePixels(contentOffset, boundedOffset, deviceScaleFactor);
 }
 
-- (void)_updateVisibleContentRects
+- (void)_scheduleVisibleContentRectUpdate
 {
-    // For visible rect updates not associated with a spefic UIScrollView, just consider our own scroller.
-    [self _updateVisibleContentRectAfterScrollInView:_scrollView.get()];
+    // For visible rect updates not associated with a specific UIScrollView, just consider our own scroller.
+    [self _scheduleVisibleContentRectUpdateAfterScrollInView:_scrollView.get()];
 }
 
-- (void)_updateVisibleContentRectAfterScrollInView:(UIScrollView *)scrollView
+- (BOOL)_scrollViewIsInStableState:(UIScrollView *)scrollView
 {
     BOOL isStableState = !([scrollView isDragging] || [scrollView isDecelerating] || [scrollView isZooming] || [scrollView _isAnimatingZoom] || [scrollView _isScrollingToTop]);
 
     if (isStableState && scrollView == _scrollView.get())
         isStableState = !_isChangingObscuredInsetsInteractively;
-    
+
     if (isStableState && scrollView == _scrollView.get())
         isStableState = ![self _scrollViewIsRubberBanding];
 
-    // FIXME: this can be made static after we stop supporting iOS 8.x.
     if (isStableState)
         isStableState = !scrollView._isInterruptingDeceleration;
 
@@ -2196,9 +2199,25 @@
     if (NSNumber *stableOverride = self._stableStateOverride)
         isStableState = stableOverride.boolValue;
 
-    [self _updateContentRectsWithState:isStableState];
+    return isStableState;
 }
 
+- (void)_scheduleVisibleContentRectUpdateAfterScrollInView:(UIScrollView *)scrollView
+{
+    _visibleContentRectUpdateScheduledFromScrollViewInStableState = [self _scrollViewIsInStableState:scrollView];
+
+    if (_hasInstalledPreCommitHandlerForVisibleRectUpdate)
+        return;
+
+    _hasInstalledPreCommitHandlerForVisibleRectUpdate = YES;
+
+    [CATransaction addCommitHandler:[retainedSelf = retainPtr(self)] {
+        WKWebView *webView = retainedSelf.get();
+        [webView _updateVisibleContentRects];
+        webView->_hasInstalledPreCommitHandlerForVisibleRectUpdate = NO;
+    } forPhase:kCATransactionPhasePreCommit];
+}
+
 static bool scrollViewCanScroll(UIScrollView *scrollView)
 {
     if (!scrollView)
@@ -2237,8 +2256,10 @@
     return extendedBounds;
 }
 
-- (void)_updateContentRectsWithState:(BOOL)inStableState
+- (void)_updateVisibleContentRects
 {
+    BOOL inStableState = _visibleContentRectUpdateScheduledFromScrollViewInStableState;
+
     if (![self usesStandardContentView]) {
         [_passwordView setFrame:self.bounds];
         [_customContentView web_computedContentInsetDidChange];
@@ -2297,6 +2318,11 @@
         inStableState:inStableState
         isChangingObscuredInsetsInteractively:_isChangingObscuredInsetsInteractively
         enclosedInScrollableAncestorView:scrollViewCanScroll([self _scroller])];
+
+    while (!_visibleContentRectUpdateCallbacks.isEmpty()) {
+        auto callback = _visibleContentRectUpdateCallbacks.takeLast();
+        callback();
+    }
 }
 
 - (void)_didFinishLoadForMainFrame
@@ -2342,7 +2368,7 @@
             _totalScrollViewBottomInsetAdjustmentForKeyboard += bottomInsetAfterAdjustment - bottomInsetBeforeAdjustment;
     }
 
-    [self _updateVisibleContentRects];
+    [self _scheduleVisibleContentRectUpdate];
 }
 
 - (BOOL)_shouldUpdateKeyboardWithInfo:(NSDictionary *)keyboardInfo
@@ -4299,7 +4325,7 @@
 
     _obscuredInsets = obscuredInsets;
 
-    [self _updateVisibleContentRects];
+    [self _scheduleVisibleContentRectUpdate];
 }
 
 - (void)_setInterfaceOrientationOverride:(UIInterfaceOrientation)interfaceOrientation
@@ -4372,7 +4398,7 @@
 {
     ASSERT(_isChangingObscuredInsetsInteractively);
     _isChangingObscuredInsetsInteractively = NO;
-    [self _updateVisibleContentRects];
+    [self _scheduleVisibleContentRectUpdate];
 }
 
 - (void)_hideContentUntilNextUpdate
@@ -4418,7 +4444,7 @@
             _page->setMaximumUnobscuredSize(WebCore::FloatSize(newMaximumUnobscuredSize));
         if (_overridesInterfaceOrientation)
             _page->setDeviceOrientation(newOrientation);
-        [self _updateVisibleContentRects];
+        [self _scheduleVisibleContentRectUpdate];
         return;
     }
 
@@ -4428,7 +4454,7 @@
         && oldOrientation == newOrientation
         && UIEdgeInsetsEqualToEdgeInsets(oldObscuredInsets, newObscuredInsets)) {
         _dynamicViewportUpdateMode = DynamicViewportUpdateMode::NotResizing;
-        [self _updateVisibleContentRects];
+        [self _scheduleVisibleContentRectUpdate];
         return;
     }
 
@@ -4546,7 +4572,7 @@
 
     _dynamicViewportUpdateMode = DynamicViewportUpdateMode::NotResizing;
     [_contentView setHidden:NO];
-    [self _updateVisibleContentRects];
+    [self _scheduleVisibleContentRectUpdate];
 
     while (!_snapshotsDeferredDuringResize.isEmpty())
         _snapshotsDeferredDuringResize.takeLast()();
@@ -5130,6 +5156,16 @@
     [self _doAfterNextPresentationUpdate:updateBlock];
 }
 
+- (void)_doAfterNextVisibleContentRectUpdate:(void (^)(void))updateBlock
+{
+#if PLATFORM(IOS)
+    _visibleContentRectUpdateCallbacks.append(makeBlockPtr(updateBlock));
+    [self _scheduleVisibleContentRectUpdate];
+#else
+    dispatch_async(dispatch_get_main_queue(), updateBlock);
+#endif
+}
+
 - (void)_disableBackForwardSnapshotVolatilityForTesting
 {
     WebKit::ViewSnapshotStore::singleton().setDisableSnapshotVolatilityForTesting(true);

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h (212458 => 212459)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h	2017-02-16 21:04:25 UTC (rev 212458)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewInternal.h	2017-02-16 21:09:40 UTC (rev 212459)
@@ -100,9 +100,7 @@
 - (void)_willInvokeUIScrollViewDelegateCallback;
 - (void)_didInvokeUIScrollViewDelegateCallback;
 
-- (void)_updateVisibleContentRects;
-- (void)_updateVisibleContentRectAfterScrollInView:(UIScrollView *)scrollView;
-- (void)_updateContentRectsWithState:(BOOL)inStableState;
+- (void)_scheduleVisibleContentRectUpdate;
 
 - (void)_didFinishLoadForMainFrame;
 - (void)_didFailLoadForMainFrame;

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h (212458 => 212459)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h	2017-02-16 21:04:25 UTC (rev 212458)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h	2017-02-16 21:09:40 UTC (rev 212459)
@@ -341,6 +341,7 @@
 
 - (void)_doAfterNextPresentationUpdate:(void (^)(void))updateBlock WK_API_AVAILABLE(macosx(10.12), ios(10.0));
 - (void)_doAfterNextPresentationUpdateWithoutWaitingForPainting:(void (^)(void))updateBlock WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+- (void)_doAfterNextVisibleContentRectUpdate:(void (^)(void))updateBlock WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 
 - (void)_disableBackForwardSnapshotVolatilityForTesting WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
 

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm (212458 => 212459)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm	2017-02-16 21:04:25 UTC (rev 212458)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentView.mm	2017-02-16 21:09:40 UTC (rev 212459)
@@ -573,7 +573,7 @@
         [self updateFixedClippingView:fixedPositionRect];
 
         // We need to push the new content bounds to the webview to update fixed position rects.
-        [_webView _updateVisibleContentRects];
+        [_webView _scheduleVisibleContentRectUpdate];
     }
     
     // Updating the selection requires a full editor state. If the editor state is missing post layout

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (212458 => 212459)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2017-02-16 21:04:25 UTC (rev 212458)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2017-02-16 21:09:40 UTC (rev 212459)
@@ -3814,7 +3814,7 @@
     
     // The custom fixed position rect behavior is affected by -isAssistingNode, so if that changes we need to recompute rects.
     if (editableChanged)
-        [_webView _updateVisibleContentRects];
+        [_webView _scheduleVisibleContentRectUpdate];
     
     [self _displayFormNodeInputView];
 
@@ -3848,7 +3848,7 @@
 
     // The custom fixed position rect behavior is affected by -isAssistingNode, so if that changes we need to recompute rects.
     if (editableChanged)
-        [_webView _updateVisibleContentRects];
+        [_webView _scheduleVisibleContentRectUpdate];
 
     [_webView didEndFormControlInteraction];
 }

Modified: trunk/Source/WebKit2/UIProcess/ios/WKScrollView.mm (212458 => 212459)


--- trunk/Source/WebKit2/UIProcess/ios/WKScrollView.mm	2017-02-16 21:04:25 UTC (rev 212458)
+++ trunk/Source/WebKit2/UIProcess/ios/WKScrollView.mm	2017-02-16 21:09:40 UTC (rev 212459)
@@ -224,7 +224,7 @@
 {
     [super setContentInset:contentInset];
 
-    [_internalDelegate _updateVisibleContentRects];
+    [_internalDelegate _scheduleVisibleContentRectUpdate];
 }
 
 // Fetch top/left rubberband amounts (as negative values).

Modified: trunk/Tools/ChangeLog (212458 => 212459)


--- trunk/Tools/ChangeLog	2017-02-16 21:04:25 UTC (rev 212458)
+++ trunk/Tools/ChangeLog	2017-02-16 21:09:40 UTC (rev 212459)
@@ -1,3 +1,32 @@
+2017-02-16  Tim Horton  <[email protected]>
+
+        WKWebView inside a UICollectionView flashes when items are inserted above it
+        https://bugs.webkit.org/show_bug.cgi?id=168376
+        <rdar://problem/29322051>
+
+        Reviewed by Simon Fraser.
+
+        * WebKitTestRunner/cocoa/TestRunnerWKWebView.mm:
+        (-[TestRunnerWKWebView _setStableStateOverride:]):
+        Update the one external caller of this internal method...
+
+        * DumpRenderTree/ios/UIScriptControllerIOS.mm:
+        (WTR::UIScriptController::doAfterVisibleContentRectUpdate):
+        * DumpRenderTree/mac/UIScriptControllerMac.mm:
+        (WTR::UIScriptController::doAfterVisibleContentRectUpdate):
+        * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
+        * TestRunnerShared/UIScriptContext/UIScriptController.cpp:
+        (WTR::UIScriptController::doAfterVisibleContentRectUpdate):
+        * TestRunnerShared/UIScriptContext/UIScriptController.h:
+        * WebKitTestRunner/ios/UIScriptControllerIOS.mm:
+        (WTR::UIScriptController::doAfterVisibleContentRectUpdate):
+        * WebKitTestRunner/mac/UIScriptControllerMac.mm:
+        (WTR::UIScriptController::doAfterVisibleContentRectUpdate):
+        Expose doAfterVisibleContentRectUpdate to DRT and WKTR. It is called
+        back after we dispatch a visible content rect update from the UI process
+        to the Web Content process, so any messages sent from the block will arrive
+        after the visible content rect update.
+
 2017-02-16  Carlos Alberto Lopez Perez  <[email protected]>
 
         [GTK] Add two new buildbots that build-only test on Debian stable and Ubuntu LTS.

Modified: trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm (212458 => 212459)


--- trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm	2017-02-16 21:04:25 UTC (rev 212458)
+++ trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm	2017-02-16 21:09:40 UTC (rev 212459)
@@ -63,6 +63,11 @@
     doAsyncTask(callback);
 }
 
+void UIScriptController::doAfterVisibleContentRectUpdate(JSValueRef callback)
+{
+    doAsyncTask(callback);
+}
+
 void UIScriptController::zoomToScale(double scale, JSValueRef callback)
 {
     RefPtr<UIScriptController> protectedThis(this);

Modified: trunk/Tools/DumpRenderTree/mac/UIScriptControllerMac.mm (212458 => 212459)


--- trunk/Tools/DumpRenderTree/mac/UIScriptControllerMac.mm	2017-02-16 21:04:25 UTC (rev 212458)
+++ trunk/Tools/DumpRenderTree/mac/UIScriptControllerMac.mm	2017-02-16 21:09:40 UTC (rev 212459)
@@ -59,6 +59,11 @@
     doAsyncTask(callback);
 }
 
+void UIScriptController::doAfterVisibleContentRectUpdate(JSValueRef callback)
+{
+    doAsyncTask(callback);
+}
+
 void UIScriptController::insertText(JSStringRef, int, int)
 {
 }

Modified: trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl (212458 => 212459)


--- trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl	2017-02-16 21:04:25 UTC (rev 212458)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl	2017-02-16 21:09:40 UTC (rev 212459)
@@ -31,6 +31,8 @@
     void doAfterPresentationUpdate(object callback); // Call the callback after sending a message to the WebProcess and receiving a subsequent update.
     void doAfterNextStablePresentationUpdate(object callback);
 
+    void doAfterVisibleContentRectUpdate(object callback);
+
     void simulateAccessibilitySettingsChangeNotification(object callback);
 
     // Interaction.

Modified: trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp (212458 => 212459)


--- trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp	2017-02-16 21:04:25 UTC (rev 212458)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp	2017-02-16 21:09:40 UTC (rev 212459)
@@ -74,6 +74,10 @@
 void UIScriptController::doAfterNextStablePresentationUpdate(JSValueRef)
 {
 }
+
+void UIScriptController::doAfterVisibleContentRectUpdate(JSValueRef)
+{
+}
 #endif
 
 void UIScriptController::setDidStartFormControlInteractionCallback(JSValueRef callback)

Modified: trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h (212458 => 212459)


--- trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h	2017-02-16 21:04:25 UTC (rev 212458)
+++ trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h	2017-02-16 21:09:40 UTC (rev 212459)
@@ -54,6 +54,7 @@
     void doAsyncTask(JSValueRef callback);
     void doAfterPresentationUpdate(JSValueRef callback);
     void doAfterNextStablePresentationUpdate(JSValueRef callback);
+    void doAfterVisibleContentRectUpdate(JSValueRef callback);
 
     void zoomToScale(double scale, JSValueRef callback);
 

Modified: trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm (212458 => 212459)


--- trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm	2017-02-16 21:04:25 UTC (rev 212458)
+++ trunk/Tools/WebKitTestRunner/cocoa/TestRunnerWKWebView.mm	2017-02-16 21:09:40 UTC (rev 212459)
@@ -38,7 +38,7 @@
 - (void)scrollViewWillBeginZooming:(UIScrollView *)scrollView withView:(UIView *)view;
 - (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(CGFloat)scale;
 - (void)_didFinishScrolling;
-- (void)_updateVisibleContentRects;
+- (void)_scheduleVisibleContentRectUpdate;
 
 @end
 #endif
@@ -187,7 +187,7 @@
 - (void)_setStableStateOverride:(NSNumber *)overrideBoolean
 {
     m_stableStateOverride = overrideBoolean;
-    [self _updateVisibleContentRects];
+    [self _scheduleVisibleContentRectUpdate];
 }
 
 - (void)_accessibilityDidGetSpeakSelectionContent:(NSString *)content

Modified: trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm (212458 => 212459)


--- trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm	2017-02-16 21:04:25 UTC (rev 212458)
+++ trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm	2017-02-16 21:09:40 UTC (rev 212459)
@@ -94,6 +94,18 @@
     }];
 }
 
+void UIScriptController::doAfterVisibleContentRectUpdate(JSValueRef callback)
+{
+    TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
+
+    unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent);
+    [webView _doAfterNextVisibleContentRectUpdate:^ {
+        if (!m_context)
+            return;
+        m_context->asyncTaskComplete(callbackID);
+    }];
+}
+
 void UIScriptController::zoomToScale(double scale, JSValueRef callback)
 {
     TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();

Modified: trunk/Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm (212458 => 212459)


--- trunk/Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm	2017-02-16 21:04:25 UTC (rev 212458)
+++ trunk/Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm	2017-02-16 21:09:40 UTC (rev 212459)
@@ -66,6 +66,11 @@
     doAsyncTask(callback);
 }
 
+void UIScriptController::doAfterVisibleContentRectUpdate(JSValueRef callback)
+{
+    doAsyncTask(callback);
+}
+
 void UIScriptController::insertText(JSStringRef text, int location, int length)
 {
 #if WK_API_ENABLED
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to