[WK2] Use the page background color instead of white when swipe snapshots were purged...
authortimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Jun 2014 00:03:15 +0000 (00:03 +0000)
committertimothy_horton@apple.com <timothy_horton@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Jun 2014 00:03:15 +0000 (00:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=134218
<rdar://problem/17426454>

Reviewed by Benjamin Poulain.

* UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _updateScrollViewBackground]):
(-[WKWebView WebKit::]):
* UIProcess/API/mac/WKView.mm:
(-[WKView _takeViewSnapshot]):
* UIProcess/ios/ViewGestureControllerIOS.mm:
(WebKit::ViewGestureController::beginSwipeGesture):
* UIProcess/mac/ViewGestureControllerMac.mm:
(WebKit::ViewGestureController::shouldUseSnapshotForSize):
(WebKit::ViewGestureController::beginSwipeGesture):
(WebKit::ViewGestureController::retrieveSnapshotForItem): Deleted.
* UIProcess/mac/ViewSnapshotStore.h:
Store a color along with each snapshot.
Set the background color of the swipe snapshot layer accordingly.

* WebCore.exp.in:

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

Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm
Source/WebKit2/UIProcess/API/mac/WKView.mm
Source/WebKit2/UIProcess/ios/ViewGestureControllerIOS.mm
Source/WebKit2/UIProcess/mac/ViewGestureController.h
Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm
Source/WebKit2/UIProcess/mac/ViewSnapshotStore.h

index ba320efa7efd6fff62480a146e9922200f679111..ff72de1b936220f59a2fb1bf463968b90b610380 100644 (file)
@@ -1,3 +1,13 @@
+2014-06-23  Timothy Horton  <timothy_horton@apple.com>
+
+        [WK2] Use the page background color instead of white when swipe snapshots were purged (134218)
+        https://bugs.webkit.org/show_bug.cgi?id=134218
+        <rdar://problem/17426454>
+
+        Reviewed by Benjamin Poulain.
+
+        * WebCore.exp.in:
+
 2014-06-23  Eric Carlson  <eric.carlson@apple.com>
 
         [iOS] remove InbandTextTrackPrivateAVFIOS
index 10c2a9b0cd3c1da34cba167a0362e27c62af9e9e..be0600a00dc63a9dd1aea6b6bd3c1b3d38732fcf 100644 (file)
@@ -315,6 +315,7 @@ __ZN7WebCore13SQLResultDoneE
 __ZN7WebCore13SelectionRectC1ERKNS_7IntRectEbi
 __ZN7WebCore13StyledElement22setInlineStylePropertyENS_13CSSPropertyIDERKN3WTF6StringEb
 __ZN7WebCore13StyledElement22setInlineStylePropertyENS_13CSSPropertyIDEdNS_17CSSPrimitiveValue9UnitTypesEb
+__ZN7WebCore13cachedCGColorERKNS_5ColorENS_10ColorSpaceE
 __ZN7WebCore13cookiesForDOMERKNS_21NetworkStorageSessionERKNS_3URLES5_
 __ZN7WebCore13createWrapperEPN3JSC9ExecStateEPNS_17JSDOMGlobalObjectEPNS_4NodeE
 __ZN7WebCore13createWrapperERNS_17JSDOMGlobalObjectERNS_8NodeListE
@@ -2726,6 +2727,7 @@ __ZN7WebCore9FrameView33rectForViewportConstrainedObjectsERKNS_10LayoutRectERKNS
 __ZN7WebCore9FrameView36scheduleLayerFlushAllowingThrottlingEv
 __ZN7WebCore9PageGroup17removeVisitedLinkERKNS_3URLE
 __ZNK7WebCore10FloatPointcv7CGPointEv
+__ZNK7WebCore10ScrollView18exposedContentRectEv
 __ZNK7WebCore10ScrollView21unobscuredContentRectENS_14ScrollableArea36VisibleContentRectIncludesScrollbarsE
 __ZNK7WebCore14DocumentLoader16responseMIMETypeEv
 __ZNK7WebCore14FrameSelection17wordOffsetInRangeEPKNS_5RangeE
@@ -2779,7 +2781,6 @@ __ZNK7WebCore9FloatSizecv6CGSizeEv
 __ZNK7WebCore9FrameView17wasScrolledByUserEv
 __ZNK7WebCore9FrameView30viewportConstrainedObjectsRectEv
 __ZNK7WebCore9RenderBox11borderRadiiEv
-__ZNK7WebCore10ScrollView18exposedContentRectEv
 _webThreadShouldYield
 _wkExecutableWasLinkedOnOrAfterIOSVersion
 _wkGetAvailableScreenSize
index ed0b6e1801c0eee2f9a40bf019ece8c76adc9ad0..a6dab693680880f568c1a8bceeb6acd708d2f55d 100644 (file)
@@ -1,3 +1,26 @@
+2014-06-23  Timothy Horton  <timothy_horton@apple.com>
+
+        [WK2] Use the page background color instead of white when swipe snapshots were purged (134218)
+        https://bugs.webkit.org/show_bug.cgi?id=134218
+        <rdar://problem/17426454>
+
+        Reviewed by Benjamin Poulain.
+
+        * UIProcess/API/Cocoa/WKWebView.mm:
+        (-[WKWebView _updateScrollViewBackground]):
+        (-[WKWebView WebKit::]):
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView _takeViewSnapshot]):
+        * UIProcess/ios/ViewGestureControllerIOS.mm:
+        (WebKit::ViewGestureController::beginSwipeGesture):
+        * UIProcess/mac/ViewGestureControllerMac.mm:
+        (WebKit::ViewGestureController::shouldUseSnapshotForSize):
+        (WebKit::ViewGestureController::beginSwipeGesture):
+        (WebKit::ViewGestureController::retrieveSnapshotForItem): Deleted.
+        * UIProcess/mac/ViewSnapshotStore.h:
+        Store a color along with each snapshot.
+        Set the background color of the swipe snapshot layer accordingly.
+
 2014-06-23  Anders Carlsson  <andersca@apple.com>
 
         Add -[WKBackForwardList _removeAllItems]
index d5c45dd888ba9bd36067903c983b7c22c9459dc1..cbd881f0a814301c421c2ca26567b45ca6155314 100644 (file)
@@ -674,7 +674,7 @@ static CGFloat contentZoomScale(WKWebView* webView)
 
     _scrollViewBackgroundColor = color;
 
-    RetainPtr<UIColor*> uiBackgroundColor = adoptNS([[UIColor alloc] initWithCGColor:cachedCGColor(color, WebCore::ColorSpaceDeviceRGB)]);
+    auto uiBackgroundColor = adoptNS([[UIColor alloc] initWithCGColor:cachedCGColor(color, WebCore::ColorSpaceDeviceRGB)]);
     [_scrollView setBackgroundColor:uiBackgroundColor.get()];
 }
 
@@ -874,6 +874,7 @@ static void changeContentOffsetBoundedInValidRange(UIScrollView *scrollView, Web
 
     snapshot.size = WebCore::expandedIntSize(WebCore::FloatSize(snapshotSize));
     snapshot.imageSizeInBytes = snapshotSize.width * snapshotSize.height * 4;
+    snapshot.backgroundColor = _page->pageExtendedBackgroundColor();
 
     return snapshot;
 }
index df497ad0ae9be1350df7f5d8e65bc2e0e63e9673..de4105457eaf469f458cb364effaa081334826ab 100644 (file)
@@ -3115,6 +3115,7 @@ static void createSandboxExtensionsForFileUpload(NSPasteboard *pasteboard, Sandb
     IntSize imageSize(CGImageGetWidth(croppedSnapshotImage.get()), CGImageGetHeight(croppedSnapshotImage.get()));
     snapshot.size = imageSize;
     snapshot.imageSizeInBytes = imageSize.width() * imageSize.height() * 4;
+    snapshot.backgroundColor = _data->_page->pageExtendedBackgroundColor();
 
     return snapshot;
 }
index b87bb75d303107a6eb527584d97728e8ed3dc004..1fb5eda7ce9bed29e92d96171d03feaf49baa284 100644 (file)
@@ -157,16 +157,20 @@ void ViewGestureController::beginSwipeGesture(_UINavigationInteractiveTransition
     RetainPtr<UIViewController> snapshotViewController = adoptNS([[UIViewController alloc] init]);
     m_snapshotView = adoptNS([[UIView alloc] initWithFrame:liveSwipeViewFrame]);
 
+    RetainPtr<UIColor> backgroundColor = [UIColor whiteColor];
     ViewSnapshot snapshot;
-    if (ViewSnapshotStore::shared().getSnapshot(targetItem, snapshot) && snapshot.hasImage()) {
+    if (ViewSnapshotStore::shared().getSnapshot(targetItem, snapshot)) {
         float deviceScaleFactor = m_webPageProxy.deviceScaleFactor();
         FloatSize swipeLayerSizeInDeviceCoordinates(liveSwipeViewFrame.size);
         swipeLayerSizeInDeviceCoordinates.scale(deviceScaleFactor);
-        if (snapshot.size == swipeLayerSizeInDeviceCoordinates && deviceScaleFactor == snapshot.deviceScaleFactor)
+        if (snapshot.hasImage() && snapshot.size == swipeLayerSizeInDeviceCoordinates && deviceScaleFactor == snapshot.deviceScaleFactor)
             [m_snapshotView layer].contents = snapshot.asLayerContents();
+        Color coreColor = snapshot.backgroundColor;
+        if (coreColor.isValid())
+            backgroundColor = adoptNS([[UIColor alloc] initWithCGColor:cachedCGColor(coreColor, ColorSpaceDeviceRGB)]);
     }
 
-    [m_snapshotView setBackgroundColor:[UIColor whiteColor]];
+    [m_snapshotView setBackgroundColor:backgroundColor.get()];
     [m_snapshotView layer].contentsGravity = kCAGravityTopLeft;
     [m_snapshotView layer].contentsScale = m_liveSwipeView.window.screen.scale;
     [snapshotViewController setView:m_snapshotView.get()];
index 72d682e70bb8e41a730e93489dc1e6fe22235ade..c16ff3231aff035b9722d67f51d26a477a451e29 100644 (file)
@@ -132,7 +132,7 @@ private:
     void endSwipeGesture(WebBackForwardListItem* targetItem, bool cancelled);
     bool deltaIsSufficientToBeginSwipe(NSEvent *);
     bool scrollEventCanBecomeSwipe(NSEvent *, SwipeDirection&);
-    bool retrieveSnapshotForItem(WebBackForwardListItem* targetItem, WebCore::FloatSize swipeLayerSize, float topContentInset, ViewSnapshot&);
+    bool shouldUseSnapshotForSize(ViewSnapshot&, WebCore::FloatSize swipeLayerSize, float topContentInset);
 
     CALayer *determineSnapshotLayerParent() const;
     CALayer *determineLayerAdjacentToSnapshotForParent(SwipeDirection, CALayer *snapshotLayerParent) const;
index 9a6b846fe53e78978aff0a8c1d50e84f10cdafba..15492913727018544b216d73dcc6edd3bf57e9fd 100644 (file)
@@ -451,11 +451,8 @@ CALayer *ViewGestureController::determineLayerAdjacentToSnapshotForParent(SwipeD
     return layerAdjacentToSnapshot;
 }
 
-bool ViewGestureController::retrieveSnapshotForItem(WebBackForwardListItem* targetItem, FloatSize swipeLayerSize, float topContentInset, ViewSnapshot& snapshot)
+bool ViewGestureController::shouldUseSnapshotForSize(ViewSnapshot& snapshot, FloatSize swipeLayerSize, float topContentInset)
 {
-    if (!ViewSnapshotStore::shared().getSnapshot(targetItem, snapshot))
-        return false;
-
     float deviceScaleFactor = m_webPageProxy.deviceScaleFactor();
     if (snapshot.deviceScaleFactor != deviceScaleFactor)
         return false;
@@ -528,15 +525,21 @@ void ViewGestureController::beginSwipeGesture(WebBackForwardListItem* targetItem
     CALayer *snapshotLayerParent = determineSnapshotLayerParent();
     bool geometryIsFlippedToRoot = layerGeometryFlippedToRoot(snapshotLayerParent);
 
+    RetainPtr<CGColorRef> backgroundColor = CGColorGetConstantColor(kCGColorWhite);
     ViewSnapshot snapshot;
-    if (retrieveSnapshotForItem(targetItem, swipeArea.size(), topContentInset, snapshot)) {
-        [m_swipeSnapshotLayer setContents:snapshot.asLayerContents()];
+    if (ViewSnapshotStore::shared().getSnapshot(targetItem, snapshot)) {
+        if (shouldUseSnapshotForSize(snapshot, swipeArea.size(), topContentInset))
+            [m_swipeSnapshotLayer setContents:snapshot.asLayerContents()];
+
+        Color coreColor = snapshot.backgroundColor;
+        if (coreColor.isValid())
+            backgroundColor = cachedCGColor(coreColor, ColorSpaceDeviceRGB);
 #if USE_IOSURFACE_VIEW_SNAPSHOTS
         m_currentSwipeSnapshotSurface = snapshot.surface;
 #endif
     }
 
-    [m_swipeLayer setBackgroundColor:CGColorGetConstantColor(kCGColorWhite)];
+    [m_swipeLayer setBackgroundColor:backgroundColor.get()];
     [m_swipeLayer setAnchorPoint:CGPointZero];
     [m_swipeLayer setFrame:swipeArea];
     [m_swipeLayer setName:@"Gesture Swipe Root Layer"];
index 1d7b391beb9706a49851aca999a3df35821b9213..3fbaa4e2ac32aa31855372767f13acb1f6a3eca2 100644 (file)
@@ -26,6 +26,7 @@
 #ifndef ViewSnapshotStore_h
 #define ViewSnapshotStore_h
 
+#include <WebCore/Color.h>
 #include <WebCore/IntSize.h>
 #include <WebCore/IOSurface.h>
 #include <chrono>
@@ -70,6 +71,7 @@ struct ViewSnapshot {
     float deviceScaleFactor;
     WebCore::IntSize size;
     size_t imageSizeInBytes = 0;
+    WebCore::Color backgroundColor;
 
     void clearImage();
     bool hasImage() const;