Changeset 182822 in webkit
- Timestamp:
- Apr 14, 2015, 5:02:53 PM (10 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r182815 r182822 1 2015-04-14 Tim Horton <timothy_horton@apple.com> 2 3 Update gesture swipe shadow style 4 https://bugs.webkit.org/show_bug.cgi?id=143616 5 <rdar://problem/19295843> 6 7 Reviewed by Darin Adler. 8 9 * UIProcess/mac/ViewGestureController.h: 10 * UIProcess/mac/ViewGestureControllerMac.mm: 11 (WebKit::ViewGestureController::beginSwipeGesture): 12 For the modern shadow style, use a layer stretched along the edge of the swiping content 13 with the newly added PNGs as the layer contents. 14 15 Add a dimming layer over the lower layer of content which fades in/out 16 during the swipe. 17 18 (WebKit::ViewGestureController::handleSwipeGesture): 19 Fade the dimming layer in and out during the entire swipe. 20 Fade the shadow layer out during the last few pixels of the swipe. 21 22 (WebKit::ViewGestureController::removeSwipeSnapshot): 23 Unparent the new layers. 24 25 * WebKit2.xcodeproj/project.pbxproj: 26 * Resources/SwipeShadow.png: 27 * Resources/SwipeShadow@2x.png: 28 Add the new resources. 29 1 30 2015-04-14 Brian Weinstein <bweinstein@apple.com> 2 31 -
trunk/Source/WebKit2/UIProcess/mac/ViewGestureController.h
r182216 r182822 187 187 RetainPtr<CALayer> m_swipeLayer; 188 188 RetainPtr<CALayer> m_swipeSnapshotLayer; 189 RetainPtr<CALayer> m_swipeShadowLayer; 190 RetainPtr<CALayer> m_swipeDimmingLayer; 189 191 Vector<RetainPtr<CALayer>> m_currentSwipeLiveLayers; 190 192 -
trunk/Source/WebKit2/UIProcess/mac/ViewGestureControllerMac.mm
r182245 r182822 47 47 using namespace WebCore; 48 48 49 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101000 50 #define ENABLE_LEGACY_SWIPE_SHADOW_STYLE 1 51 #else 52 #define ENABLE_LEGACY_SWIPE_SHADOW_STYLE 0 53 #endif 54 49 55 static const double minMagnification = 1; 50 56 static const double maxMagnification = 3; … … 59 65 static const float smartMagnificationPanScrollThreshold = 100; 60 66 67 #if ENABLE(LEGACY_SWIPE_SHADOW_STYLE) 61 68 static const double swipeOverlayShadowOpacity = 0.66; 62 69 static const double swipeOverlayShadowRadius = 3; 70 #else 71 static const double swipeOverlayShadowOpacity = 0.47; 72 static const double swipeOverlayDimmingOpacity = 0.12; 73 #endif 63 74 64 75 static const CGFloat minimumHorizontalSwipeDistance = 15; … … 565 576 [m_swipeLayer setDelegate:[WebActionDisablingCALayerDelegate shared]]; 566 577 578 float deviceScaleFactor = m_webPageProxy.deviceScaleFactor(); 567 579 [m_swipeSnapshotLayer setContentsGravity:kCAGravityTopLeft]; 568 [m_swipeSnapshotLayer setContentsScale: m_webPageProxy.deviceScaleFactor()];580 [m_swipeSnapshotLayer setContentsScale:deviceScaleFactor]; 569 581 [m_swipeSnapshotLayer setAnchorPoint:CGPointZero]; 570 582 [m_swipeSnapshotLayer setFrame:CGRectMake(0, 0, swipeArea.width(), swipeArea.height() - topContentInset)]; … … 577 589 applyDebuggingPropertiesToSwipeViews(); 578 590 591 592 CALayer *layerAdjacentToSnapshot = determineLayerAdjacentToSnapshotForParent(direction, snapshotLayerParent); 593 if (direction == SwipeDirection::Back) 594 [snapshotLayerParent insertSublayer:m_swipeLayer.get() below:layerAdjacentToSnapshot]; 595 else 596 [snapshotLayerParent insertSublayer:m_swipeLayer.get() above:layerAdjacentToSnapshot]; 597 579 598 // We don't know enough about the custom views' hierarchy to apply a shadow. 580 599 if (m_swipeTransitionStyle == SwipeTransitionStyle::Overlap && m_customSwipeViews.isEmpty()) { 600 #if ENABLE(LEGACY_SWIPE_SHADOW_STYLE) 581 601 if (direction == SwipeDirection::Back) { 582 602 float topContentInset = m_webPageProxy.topContentInset(); … … 594 614 [m_swipeLayer setShadowPath:shadowPath.get()]; 595 615 } 596 } 597 598 CALayer *layerAdjacentToSnapshot = determineLayerAdjacentToSnapshotForParent(direction, snapshotLayerParent); 599 if (direction == SwipeDirection::Back) 600 [snapshotLayerParent insertSublayer:m_swipeLayer.get() below:layerAdjacentToSnapshot]; 601 else 602 [snapshotLayerParent insertSublayer:m_swipeLayer.get() above:layerAdjacentToSnapshot]; 616 #else 617 FloatRect dimmingRect(FloatPoint(), m_webPageProxy.viewSize()); 618 m_swipeDimmingLayer = adoptNS([[CALayer alloc] init]); 619 [m_swipeDimmingLayer setName:@"Gesture Swipe Dimming Layer"]; 620 [m_swipeDimmingLayer setBackgroundColor:[NSColor blackColor].CGColor]; 621 [m_swipeDimmingLayer setOpacity:swipeOverlayDimmingOpacity]; 622 [m_swipeDimmingLayer setAnchorPoint:CGPointZero]; 623 [m_swipeDimmingLayer setFrame:dimmingRect]; 624 [m_swipeDimmingLayer setGeometryFlipped:geometryIsFlippedToRoot]; 625 [m_swipeDimmingLayer setDelegate:[WebActionDisablingCALayerDelegate shared]]; 626 627 NSImage *shadowImage = [[NSBundle bundleForClass:[WKSwipeCancellationTracker class]] imageForResource:@"SwipeShadow"]; 628 FloatRect shadowRect(-shadowImage.size.width, topContentInset, shadowImage.size.width, m_webPageProxy.viewSize().height() - topContentInset); 629 m_swipeShadowLayer = adoptNS([[CALayer alloc] init]); 630 [m_swipeShadowLayer setName:@"Gesture Swipe Shadow Layer"]; 631 [m_swipeShadowLayer setBackgroundColor:[NSColor colorWithPatternImage:shadowImage].CGColor]; 632 [m_swipeShadowLayer setContentsScale:deviceScaleFactor]; 633 [m_swipeShadowLayer setOpacity:swipeOverlayShadowOpacity]; 634 [m_swipeShadowLayer setAnchorPoint:CGPointZero]; 635 [m_swipeShadowLayer setFrame:shadowRect]; 636 [m_swipeShadowLayer setGeometryFlipped:geometryIsFlippedToRoot]; 637 [m_swipeShadowLayer setDelegate:[WebActionDisablingCALayerDelegate shared]]; 638 639 if (direction == SwipeDirection::Back) 640 [snapshotLayerParent insertSublayer:m_swipeDimmingLayer.get() above:m_swipeLayer.get()]; 641 else 642 [snapshotLayerParent insertSublayer:m_swipeDimmingLayer.get() below:m_swipeLayer.get()]; 643 644 [snapshotLayerParent insertSublayer:m_swipeShadowLayer.get() above:m_swipeLayer.get()]; 645 #endif 646 } 603 647 } 604 648 … … 617 661 618 662 double swipingLayerOffset = floor(width * progress); 663 664 #if !ENABLE(LEGACY_SWIPE_SHADOW_STYLE) 665 double dimmingProgress = (direction == SwipeDirection::Back) ? 1 - progress : -progress; 666 dimmingProgress = std::min(1., std::max(dimmingProgress, 0.)); 667 [m_swipeDimmingLayer setOpacity:dimmingProgress * swipeOverlayDimmingOpacity]; 668 669 double absoluteProgress = fabs(progress); 670 double remainingSwipeDistance = width - fabs(absoluteProgress * width); 671 double shadowFadeDistance = [m_swipeShadowLayer bounds].size.width; 672 if (remainingSwipeDistance < shadowFadeDistance) 673 [m_swipeShadowLayer setOpacity:(remainingSwipeDistance / shadowFadeDistance) * swipeOverlayShadowOpacity]; 674 else 675 [m_swipeShadowLayer setOpacity:swipeOverlayShadowOpacity]; 676 677 if (m_swipeTransitionStyle == SwipeTransitionStyle::Overlap) 678 [m_swipeShadowLayer setTransform:CATransform3DMakeTranslation((direction == SwipeDirection::Back ? 0 : width) + swipingLayerOffset, 0, 0)]; 679 #endif 619 680 620 681 if (m_swipeTransitionStyle == SwipeTransitionStyle::Overlap) { … … 791 852 m_swipeLayer = nullptr; 792 853 854 #if !ENABLE(LEGACY_SWIPE_SHADOW_STYLE) 855 [m_swipeShadowLayer removeFromSuperlayer]; 856 m_swipeShadowLayer = nullptr; 857 858 [m_swipeDimmingLayer removeFromSuperlayer]; 859 m_swipeDimmingLayer = nullptr; 860 #endif 861 793 862 m_currentSwipeLiveLayers.clear(); 794 863 -
trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
r182803 r182822 668 668 2DAF06D618BD1A470081CEB1 /* SmartMagnificationController.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DAF06D418BD1A470081CEB1 /* SmartMagnificationController.h */; }; 669 669 2DAF06D718BD1A470081CEB1 /* SmartMagnificationController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DAF06D518BD1A470081CEB1 /* SmartMagnificationController.mm */; }; 670 2DC658351AD7237600D44508 /* SwipeShadow.png in Resources */ = {isa = PBXBuildFile; fileRef = 2DC658331AD7237600D44508 /* SwipeShadow.png */; }; 671 2DC658361AD7237600D44508 /* SwipeShadow@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 2DC658341AD7237600D44508 /* SwipeShadow@2x.png */; }; 670 672 2DC6D9C318C44A610043BAD4 /* WKWebViewContentProviderRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DC6D9C118C44A610043BAD4 /* WKWebViewContentProviderRegistry.h */; }; 671 673 2DC6D9C418C44A610043BAD4 /* WKWebViewContentProviderRegistry.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2DC6D9C218C44A610043BAD4 /* WKWebViewContentProviderRegistry.mm */; }; … … 2838 2840 2DAF06D518BD1A470081CEB1 /* SmartMagnificationController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = SmartMagnificationController.mm; path = ios/SmartMagnificationController.mm; sourceTree = "<group>"; }; 2839 2841 2DAF06D818BD23BA0081CEB1 /* SmartMagnificationController.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; name = SmartMagnificationController.messages.in; path = ios/SmartMagnificationController.messages.in; sourceTree = "<group>"; }; 2842 2DC658331AD7237600D44508 /* SwipeShadow.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = SwipeShadow.png; path = Resources/SwipeShadow.png; sourceTree = "<group>"; }; 2843 2DC658341AD7237600D44508 /* SwipeShadow@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "SwipeShadow@2x.png"; path = "Resources/SwipeShadow@2x.png"; sourceTree = "<group>"; }; 2840 2844 2DC6D9C118C44A610043BAD4 /* WKWebViewContentProviderRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebViewContentProviderRegistry.h; sourceTree = "<group>"; }; 2841 2845 2DC6D9C218C44A610043BAD4 /* WKWebViewContentProviderRegistry.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewContentProviderRegistry.mm; sourceTree = "<group>"; }; … … 4323 4327 1CB75C931701E880009F809F /* DockRight.pdf */, 4324 4328 1C8AE7601992F62F00ABF6EC /* DockRightLegacy.pdf */, 4329 2DC658331AD7237600D44508 /* SwipeShadow.png */, 4330 2DC658341AD7237600D44508 /* SwipeShadow@2x.png */, 4325 4331 8DC2EF5A0486A6940098B216 /* Info.plist */, 4326 4332 089C1666FE841158C02AAC07 /* InfoPlist.strings */, … … 8936 8942 1CB75C941701E880009F809F /* DockRight.pdf in Resources */, 8937 8943 1C8AE7621992F63C00ABF6EC /* DockRightLegacy.pdf in Resources */, 8944 2DC658361AD7237600D44508 /* SwipeShadow@2x.png in Resources */, 8938 8945 8DC2EF530486A6940098B216 /* InfoPlist.strings in Resources */, 8946 2DC658351AD7237600D44508 /* SwipeShadow.png in Resources */, 8939 8947 ); 8940 8948 runOnlyForDeploymentPostprocessing = 0;
Note:
See TracChangeset
for help on using the changeset viewer.