Title: [170335] trunk/Source
Revision
170335
Author
timothy_hor...@apple.com
Date
2014-06-23 17:03:15 -0700 (Mon, 23 Jun 2014)

Log Message

[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.

* WebCore.exp.in:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (170334 => 170335)


--- trunk/Source/WebCore/ChangeLog	2014-06-23 23:56:51 UTC (rev 170334)
+++ trunk/Source/WebCore/ChangeLog	2014-06-24 00:03:15 UTC (rev 170335)
@@ -1,3 +1,13 @@
+2014-06-23  Timothy Horton  <timothy_hor...@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.carl...@apple.com>
 
         [iOS] remove InbandTextTrackPrivateAVFIOS

Modified: trunk/Source/WebCore/WebCore.exp.in (170334 => 170335)


--- trunk/Source/WebCore/WebCore.exp.in	2014-06-23 23:56:51 UTC (rev 170334)
+++ trunk/Source/WebCore/WebCore.exp.in	2014-06-24 00:03:15 UTC (rev 170335)
@@ -315,6 +315,7 @@
 __ZN7WebCore13SelectionRectC1ERKNS_7IntRectEbi
 __ZN7WebCore13StyledElement22setInlineStylePropertyENS_13CSSPropertyIDERKN3WTF6StringEb
 __ZN7WebCore13StyledElement22setInlineStylePropertyENS_13CSSPropertyIDEdNS_17CSSPrimitiveValue9UnitTypesEb
+__ZN7WebCore13cachedCGColorERKNS_5ColorENS_10ColorSpaceE
 __ZN7WebCore13cookiesForDOMERKNS_21NetworkStorageSessionERKNS_3URLES5_
 __ZN7WebCore13createWrapperEPN3JSC9ExecStateEPNS_17JSDOMGlobalObjectEPNS_4NodeE
 __ZN7WebCore13createWrapperERNS_17JSDOMGlobalObjectERNS_8NodeListE
@@ -2726,6 +2727,7 @@
 __ZN7WebCore9FrameView36scheduleLayerFlushAllowingThrottlingEv
 __ZN7WebCore9PageGroup17removeVisitedLinkERKNS_3URLE
 __ZNK7WebCore10FloatPointcv7CGPointEv
+__ZNK7WebCore10ScrollView18exposedContentRectEv
 __ZNK7WebCore10ScrollView21unobscuredContentRectENS_14ScrollableArea36VisibleContentRectIncludesScrollbarsE
 __ZNK7WebCore14DocumentLoader16responseMIMETypeEv
 __ZNK7WebCore14FrameSelection17wordOffsetInRangeEPKNS_5RangeE
@@ -2779,7 +2781,6 @@
 __ZNK7WebCore9FrameView17wasScrolledByUserEv
 __ZNK7WebCore9FrameView30viewportConstrainedObjectsRectEv
 __ZNK7WebCore9RenderBox11borderRadiiEv
-__ZNK7WebCore10ScrollView18exposedContentRectEv
 _webThreadShouldYield
 _wkExecutableWasLinkedOnOrAfterIOSVersion
 _wkGetAvailableScreenSize

Modified: trunk/Source/WebKit2/ChangeLog (170334 => 170335)


--- trunk/Source/WebKit2/ChangeLog	2014-06-23 23:56:51 UTC (rev 170334)
+++ trunk/Source/WebKit2/ChangeLog	2014-06-24 00:03:15 UTC (rev 170335)
@@ -1,3 +1,26 @@
+2014-06-23  Timothy Horton  <timothy_hor...@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  <ander...@apple.com>
 
         Add -[WKBackForwardList _removeAllItems]

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


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2014-06-23 23:56:51 UTC (rev 170334)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2014-06-24 00:03:15 UTC (rev 170335)
@@ -674,7 +674,7 @@
 
     _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 @@
 
     snapshot.size = WebCore::expandedIntSize(WebCore::FloatSize(snapshotSize));
     snapshot.imageSizeInBytes = snapshotSize.width * snapshotSize.height * 4;
+    snapshot.backgroundColor = _page->pageExtendedBackgroundColor();
 
     return snapshot;
 }

Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (170334 => 170335)


--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm	2014-06-23 23:56:51 UTC (rev 170334)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm	2014-06-24 00:03:15 UTC (rev 170335)
@@ -3115,6 +3115,7 @@
     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;
 }

Modified: trunk/Source/WebKit2/UIProcess/ios/ViewGestureControllerIOS.mm (170334 => 170335)


--- trunk/Source/WebKit2/UIProcess/ios/ViewGestureControllerIOS.mm	2014-06-23 23:56:51 UTC (rev 170334)
+++ trunk/Source/WebKit2/UIProcess/ios/ViewGestureControllerIOS.mm	2014-06-24 00:03:15 UTC (rev 170335)
@@ -157,16 +157,20 @@
     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()];

Modified: trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h (170334 => 170335)


--- trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h	2014-06-23 23:56:51 UTC (rev 170334)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h	2014-06-24 00:03:15 UTC (rev 170335)
@@ -132,7 +132,7 @@
     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;

Modified: trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm (170334 => 170335)


--- trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm	2014-06-23 23:56:51 UTC (rev 170334)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm	2014-06-24 00:03:15 UTC (rev 170335)
@@ -451,11 +451,8 @@
     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 @@
     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"];

Modified: trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.h (170334 => 170335)


--- trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.h	2014-06-23 23:56:51 UTC (rev 170334)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewSnapshotStore.h	2014-06-24 00:03:15 UTC (rev 170335)
@@ -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 @@
     float deviceScaleFactor;
     WebCore::IntSize size;
     size_t imageSizeInBytes = 0;
+    WebCore::Color backgroundColor;
 
     void clearImage();
     bool hasImage() const;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to