- Revision
- 182822
- Author
- timothy_hor...@apple.com
- Date
- 2015-04-14 17:02:53 -0700 (Tue, 14 Apr 2015)
Log Message
Update gesture swipe shadow style
https://bugs.webkit.org/show_bug.cgi?id=143616
<rdar://problem/19295843>
Reviewed by Darin Adler.
* UIProcess/mac/ViewGestureController.h:
* UIProcess/mac/ViewGestureControllerMac.mm:
(WebKit::ViewGestureController::beginSwipeGesture):
For the modern shadow style, use a layer stretched along the edge of the swiping content
with the newly added PNGs as the layer contents.
Add a dimming layer over the lower layer of content which fades in/out
during the swipe.
(WebKit::ViewGestureController::handleSwipeGesture):
Fade the dimming layer in and out during the entire swipe.
Fade the shadow layer out during the last few pixels of the swipe.
(WebKit::ViewGestureController::removeSwipeSnapshot):
Unparent the new layers.
* WebKit2.xcodeproj/project.pbxproj:
* Resources/SwipeShadow.png:
* Resources/swipesha...@2x.png:
Add the new resources.
Modified Paths
Added Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (182821 => 182822)
--- trunk/Source/WebKit2/ChangeLog 2015-04-14 23:48:00 UTC (rev 182821)
+++ trunk/Source/WebKit2/ChangeLog 2015-04-15 00:02:53 UTC (rev 182822)
@@ -1,3 +1,32 @@
+2015-04-14 Tim Horton <timothy_hor...@apple.com>
+
+ Update gesture swipe shadow style
+ https://bugs.webkit.org/show_bug.cgi?id=143616
+ <rdar://problem/19295843>
+
+ Reviewed by Darin Adler.
+
+ * UIProcess/mac/ViewGestureController.h:
+ * UIProcess/mac/ViewGestureControllerMac.mm:
+ (WebKit::ViewGestureController::beginSwipeGesture):
+ For the modern shadow style, use a layer stretched along the edge of the swiping content
+ with the newly added PNGs as the layer contents.
+
+ Add a dimming layer over the lower layer of content which fades in/out
+ during the swipe.
+
+ (WebKit::ViewGestureController::handleSwipeGesture):
+ Fade the dimming layer in and out during the entire swipe.
+ Fade the shadow layer out during the last few pixels of the swipe.
+
+ (WebKit::ViewGestureController::removeSwipeSnapshot):
+ Unparent the new layers.
+
+ * WebKit2.xcodeproj/project.pbxproj:
+ * Resources/SwipeShadow.png:
+ * Resources/swipesha...@2x.png:
+ Add the new resources.
+
2015-04-14 Brian Weinstein <bweinst...@apple.com>
Add SPI to clear HSTS hosts added since a date.
Added: trunk/Source/WebKit2/Resources/SwipeShadow.png
(Binary files differ)
Property changes on: trunk/Source/WebKit2/Resources/SwipeShadow.png
___________________________________________________________________
Added: svn:mime-type
Added: trunk/Source/WebKit2/Resources/swipesha...@2x.png
(Binary files differ)
Property changes on: trunk/Source/WebKit2/Resources/swipesha...@2x.png
___________________________________________________________________
Added: svn:mime-type
Modified: trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h (182821 => 182822)
--- trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h 2015-04-14 23:48:00 UTC (rev 182821)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h 2015-04-15 00:02:53 UTC (rev 182822)
@@ -186,6 +186,8 @@
RetainPtr<WKSwipeCancellationTracker> m_swipeCancellationTracker;
RetainPtr<CALayer> m_swipeLayer;
RetainPtr<CALayer> m_swipeSnapshotLayer;
+ RetainPtr<CALayer> m_swipeShadowLayer;
+ RetainPtr<CALayer> m_swipeDimmingLayer;
Vector<RetainPtr<CALayer>> m_currentSwipeLiveLayers;
SwipeTransitionStyle m_swipeTransitionStyle { SwipeTransitionStyle::Overlap };
Modified: trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm (182821 => 182822)
--- trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm 2015-04-14 23:48:00 UTC (rev 182821)
+++ trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm 2015-04-15 00:02:53 UTC (rev 182822)
@@ -46,6 +46,12 @@
using namespace WebCore;
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101000
+#define ENABLE_LEGACY_SWIPE_SHADOW_STYLE 1
+#else
+#define ENABLE_LEGACY_SWIPE_SHADOW_STYLE 0
+#endif
+
static const double minMagnification = 1;
static const double maxMagnification = 3;
@@ -58,8 +64,13 @@
static const float smartMagnificationElementPadding = 0.05;
static const float smartMagnificationPanScrollThreshold = 100;
+#if ENABLE(LEGACY_SWIPE_SHADOW_STYLE)
static const double swipeOverlayShadowOpacity = 0.66;
static const double swipeOverlayShadowRadius = 3;
+#else
+static const double swipeOverlayShadowOpacity = 0.47;
+static const double swipeOverlayDimmingOpacity = 0.12;
+#endif
static const CGFloat minimumHorizontalSwipeDistance = 15;
static const float minimumScrollEventRatioForSwipe = 0.5;
@@ -564,8 +575,9 @@
[m_swipeLayer setGeometryFlipped:geometryIsFlippedToRoot];
[m_swipeLayer setDelegate:[WebActionDisablingCALayerDelegate shared]];
+ float deviceScaleFactor = m_webPageProxy.deviceScaleFactor();
[m_swipeSnapshotLayer setContentsGravity:kCAGravityTopLeft];
- [m_swipeSnapshotLayer setContentsScale:m_webPageProxy.deviceScaleFactor()];
+ [m_swipeSnapshotLayer setContentsScale:deviceScaleFactor];
[m_swipeSnapshotLayer setAnchorPoint:CGPointZero];
[m_swipeSnapshotLayer setFrame:CGRectMake(0, 0, swipeArea.width(), swipeArea.height() - topContentInset)];
[m_swipeSnapshotLayer setName:@"Gesture Swipe Snapshot Layer"];
@@ -576,8 +588,16 @@
if (m_webPageProxy.preferences().viewGestureDebuggingEnabled())
applyDebuggingPropertiesToSwipeViews();
+
+ CALayer *layerAdjacentToSnapshot = determineLayerAdjacentToSnapshotForParent(direction, snapshotLayerParent);
+ if (direction == SwipeDirection::Back)
+ [snapshotLayerParent insertSublayer:m_swipeLayer.get() below:layerAdjacentToSnapshot];
+ else
+ [snapshotLayerParent insertSublayer:m_swipeLayer.get() above:layerAdjacentToSnapshot];
+
// We don't know enough about the custom views' hierarchy to apply a shadow.
if (m_swipeTransitionStyle == SwipeTransitionStyle::Overlap && m_customSwipeViews.isEmpty()) {
+#if ENABLE(LEGACY_SWIPE_SHADOW_STYLE)
if (direction == SwipeDirection::Back) {
float topContentInset = m_webPageProxy.topContentInset();
FloatRect shadowRect(FloatPoint(0, topContentInset), m_webPageProxy.viewSize() - FloatSize(0, topContentInset));
@@ -593,13 +613,37 @@
[m_swipeLayer setShadowRadius:swipeOverlayShadowRadius];
[m_swipeLayer setShadowPath:shadowPath.get()];
}
+#else
+ FloatRect dimmingRect(FloatPoint(), m_webPageProxy.viewSize());
+ m_swipeDimmingLayer = adoptNS([[CALayer alloc] init]);
+ [m_swipeDimmingLayer setName:@"Gesture Swipe Dimming Layer"];
+ [m_swipeDimmingLayer setBackgroundColor:[NSColor blackColor].CGColor];
+ [m_swipeDimmingLayer setOpacity:swipeOverlayDimmingOpacity];
+ [m_swipeDimmingLayer setAnchorPoint:CGPointZero];
+ [m_swipeDimmingLayer setFrame:dimmingRect];
+ [m_swipeDimmingLayer setGeometryFlipped:geometryIsFlippedToRoot];
+ [m_swipeDimmingLayer setDelegate:[WebActionDisablingCALayerDelegate shared]];
+
+ NSImage *shadowImage = [[NSBundle bundleForClass:[WKSwipeCancellationTracker class]] imageForResource:@"SwipeShadow"];
+ FloatRect shadowRect(-shadowImage.size.width, topContentInset, shadowImage.size.width, m_webPageProxy.viewSize().height() - topContentInset);
+ m_swipeShadowLayer = adoptNS([[CALayer alloc] init]);
+ [m_swipeShadowLayer setName:@"Gesture Swipe Shadow Layer"];
+ [m_swipeShadowLayer setBackgroundColor:[NSColor colorWithPatternImage:shadowImage].CGColor];
+ [m_swipeShadowLayer setContentsScale:deviceScaleFactor];
+ [m_swipeShadowLayer setOpacity:swipeOverlayShadowOpacity];
+ [m_swipeShadowLayer setAnchorPoint:CGPointZero];
+ [m_swipeShadowLayer setFrame:shadowRect];
+ [m_swipeShadowLayer setGeometryFlipped:geometryIsFlippedToRoot];
+ [m_swipeShadowLayer setDelegate:[WebActionDisablingCALayerDelegate shared]];
+
+ if (direction == SwipeDirection::Back)
+ [snapshotLayerParent insertSublayer:m_swipeDimmingLayer.get() above:m_swipeLayer.get()];
+ else
+ [snapshotLayerParent insertSublayer:m_swipeDimmingLayer.get() below:m_swipeLayer.get()];
+
+ [snapshotLayerParent insertSublayer:m_swipeShadowLayer.get() above:m_swipeLayer.get()];
+#endif
}
-
- CALayer *layerAdjacentToSnapshot = determineLayerAdjacentToSnapshotForParent(direction, snapshotLayerParent);
- if (direction == SwipeDirection::Back)
- [snapshotLayerParent insertSublayer:m_swipeLayer.get() below:layerAdjacentToSnapshot];
- else
- [snapshotLayerParent insertSublayer:m_swipeLayer.get() above:layerAdjacentToSnapshot];
}
void ViewGestureController::handleSwipeGesture(WebBackForwardListItem* targetItem, double progress, SwipeDirection direction)
@@ -617,6 +661,23 @@
double swipingLayerOffset = floor(width * progress);
+#if !ENABLE(LEGACY_SWIPE_SHADOW_STYLE)
+ double dimmingProgress = (direction == SwipeDirection::Back) ? 1 - progress : -progress;
+ dimmingProgress = std::min(1., std::max(dimmingProgress, 0.));
+ [m_swipeDimmingLayer setOpacity:dimmingProgress * swipeOverlayDimmingOpacity];
+
+ double absoluteProgress = fabs(progress);
+ double remainingSwipeDistance = width - fabs(absoluteProgress * width);
+ double shadowFadeDistance = [m_swipeShadowLayer bounds].size.width;
+ if (remainingSwipeDistance < shadowFadeDistance)
+ [m_swipeShadowLayer setOpacity:(remainingSwipeDistance / shadowFadeDistance) * swipeOverlayShadowOpacity];
+ else
+ [m_swipeShadowLayer setOpacity:swipeOverlayShadowOpacity];
+
+ if (m_swipeTransitionStyle == SwipeTransitionStyle::Overlap)
+ [m_swipeShadowLayer setTransform:CATransform3DMakeTranslation((direction == SwipeDirection::Back ? 0 : width) + swipingLayerOffset, 0, 0)];
+#endif
+
if (m_swipeTransitionStyle == SwipeTransitionStyle::Overlap) {
if (direction == SwipeDirection::Forward) {
[m_swipeLayer setTransform:CATransform3DMakeTranslation(width + swipingLayerOffset, 0, 0)];
@@ -790,6 +851,14 @@
[m_swipeLayer removeFromSuperlayer];
m_swipeLayer = nullptr;
+#if !ENABLE(LEGACY_SWIPE_SHADOW_STYLE)
+ [m_swipeShadowLayer removeFromSuperlayer];
+ m_swipeShadowLayer = nullptr;
+
+ [m_swipeDimmingLayer removeFromSuperlayer];
+ m_swipeDimmingLayer = nullptr;
+#endif
+
m_currentSwipeLiveLayers.clear();
m_activeGestureType = ViewGestureType::None;
Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (182821 => 182822)
--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2015-04-14 23:48:00 UTC (rev 182821)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2015-04-15 00:02:53 UTC (rev 182822)
@@ -667,6 +667,8 @@
2DACE64E18ADBFF000E4CA76 /* _WKThumbnailViewInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DACE64D18ADBFF000E4CA76 /* _WKThumbnailViewInternal.h */; };
2DAF06D618BD1A470081CEB1 /* SmartMagnificationController.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DAF06D418BD1A470081CEB1 /* SmartMagnificationController.h */; };
2DAF06D718BD1A470081CEB1 /* SmartMagnificationController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DAF06D518BD1A470081CEB1 /* SmartMagnificationController.mm */; };
+ 2DC658351AD7237600D44508 /* SwipeShadow.png in Resources */ = {isa = PBXBuildFile; fileRef = 2DC658331AD7237600D44508 /* SwipeShadow.png */; };
+ 2DC658361AD7237600D44508 /* swipesha...@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 2DC658341AD7237600D44508 /* swipesha...@2x.png */; };
2DC6D9C318C44A610043BAD4 /* WKWebViewContentProviderRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DC6D9C118C44A610043BAD4 /* WKWebViewContentProviderRegistry.h */; };
2DC6D9C418C44A610043BAD4 /* WKWebViewContentProviderRegistry.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DC6D9C218C44A610043BAD4 /* WKWebViewContentProviderRegistry.mm */; };
2DD12A081A8177F3002C74E6 /* WKPageRenderingProgressEvents.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DD12A071A8177F3002C74E6 /* WKPageRenderingProgressEvents.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -2837,6 +2839,8 @@
2DAF06D418BD1A470081CEB1 /* SmartMagnificationController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SmartMagnificationController.h; path = ios/SmartMagnificationController.h; sourceTree = "<group>"; };
2DAF06D518BD1A470081CEB1 /* SmartMagnificationController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = SmartMagnificationController.mm; path = ios/SmartMagnificationController.mm; sourceTree = "<group>"; };
2DAF06D818BD23BA0081CEB1 /* SmartMagnificationController.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; name = SmartMagnificationController.messages.in; path = ios/SmartMagnificationController.messages.in; sourceTree = "<group>"; };
+ 2DC658331AD7237600D44508 /* SwipeShadow.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = SwipeShadow.png; path = Resources/SwipeShadow.png; sourceTree = "<group>"; };
+ 2DC658341AD7237600D44508 /* swipesha...@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "swipesha...@2x.png"; path = "Resources/swipesha...@2x.png"; sourceTree = "<group>"; };
2DC6D9C118C44A610043BAD4 /* WKWebViewContentProviderRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebViewContentProviderRegistry.h; sourceTree = "<group>"; };
2DC6D9C218C44A610043BAD4 /* WKWebViewContentProviderRegistry.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewContentProviderRegistry.mm; sourceTree = "<group>"; };
2DD12A071A8177F3002C74E6 /* WKPageRenderingProgressEvents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKPageRenderingProgressEvents.h; sourceTree = "<group>"; };
@@ -4322,6 +4326,8 @@
1C8AE75F1992F62F00ABF6EC /* DockBottomLegacy.pdf */,
1CB75C931701E880009F809F /* DockRight.pdf */,
1C8AE7601992F62F00ABF6EC /* DockRightLegacy.pdf */,
+ 2DC658331AD7237600D44508 /* SwipeShadow.png */,
+ 2DC658341AD7237600D44508 /* swipesha...@2x.png */,
8DC2EF5A0486A6940098B216 /* Info.plist */,
089C1666FE841158C02AAC07 /* InfoPlist.strings */,
E1D26A4C1759634E0095BFD1 /* WebContentProcess.xib */,
@@ -8935,7 +8941,9 @@
1C8AE7611992F63A00ABF6EC /* DockBottomLegacy.pdf in Resources */,
1CB75C941701E880009F809F /* DockRight.pdf in Resources */,
1C8AE7621992F63C00ABF6EC /* DockRightLegacy.pdf in Resources */,
+ 2DC658361AD7237600D44508 /* swipesha...@2x.png in Resources */,
8DC2EF530486A6940098B216 /* InfoPlist.strings in Resources */,
+ 2DC658351AD7237600D44508 /* SwipeShadow.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};