Changeset 277469 in webkit
- Timestamp:
- May 13, 2021, 6:02:03 PM (5 years ago)
- Location:
- branches/safari-612.1.12-branch
- Files:
-
- 6 edited
- 2 copied
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/SourcesCocoa.txt (modified) (1 diff)
-
Source/WebCore/WebCore.xcodeproj/project.pbxproj (modified) (4 diffs)
-
Source/WebCore/page/cocoa/WebTextIndicatorLayer.h (copied) (copied from branches/safari-612.1.12-branch/Source/WebCore/page/mac/TextIndicatorWindow.h ) (2 diffs)
-
Source/WebCore/page/cocoa/WebTextIndicatorLayer.mm (copied) (copied from branches/safari-612.1.12-branch/Source/WebCore/page/mac/TextIndicatorWindow.mm ) (18 diffs)
-
Source/WebCore/page/mac/TextIndicatorWindow.h (modified) (2 diffs)
-
Source/WebCore/page/mac/TextIndicatorWindow.mm (modified) (9 diffs)
-
WebKit.xcworkspace/xcshareddata/xcschemes/All Source.xcscheme (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-612.1.12-branch/Source/WebCore/ChangeLog
r277288 r277469 1 2021-05-13 Russell Epstein <repstein@apple.com> 2 3 Cherry-pick r277330. rdar://problem/77996680 4 5 Factor out find bounce layer 6 https://bugs.webkit.org/show_bug.cgi?id=225557 7 8 Reviewed by Tim Horton. 9 10 Factor out the text indicator bounce layer in preparation of making this 11 compatable with iOS. 12 13 No behavior change. 14 15 * SourcesCocoa.txt: 16 * WebCore.xcodeproj/project.pbxproj: 17 * page/mac/TextIndicatorWindow.h: 18 * page/mac/TextIndicatorWindow.mm: 19 (WebCore::TextIndicatorWindow::setAnimationProgress): 20 (WebCore::TextIndicatorWindow::clearTextIndicator): 21 (WebCore::TextIndicatorWindow::setTextIndicator): 22 (WebCore::TextIndicatorWindow::closeWindow): 23 (WebCore::TextIndicatorWindow::startFadeOut): 24 (indicatorWantsBounce): Deleted. 25 (indicatorWantsContentCrossfade): Deleted. 26 (indicatorWantsFadeIn): Deleted. 27 (indicatorWantsManualAnimation): Deleted. 28 (-[WebTextIndicatorView initWithFrame:textIndicator:margin:offset:]): Deleted. 29 (createBounceAnimation): Deleted. 30 (createContentCrossfadeAnimation): Deleted. 31 (createShadowFadeAnimation): Deleted. 32 (createFadeInAnimation): Deleted. 33 (-[WebTextIndicatorView _animationDuration]): Deleted. 34 (-[WebTextIndicatorView hasCompletedAnimation]): Deleted. 35 (-[WebTextIndicatorView present]): Deleted. 36 (-[WebTextIndicatorView hideWithCompletionHandler:]): Deleted. 37 (-[WebTextIndicatorView setAnimationProgress:]): Deleted. 38 (-[WebTextIndicatorView isFlipped]): Deleted. 39 40 41 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@277330 268f45cc-cd09-0410-ab3c-d52691b4dbfc 42 43 2021-05-11 Megan Gardner <megan_gardner@apple.com> 44 45 Factor out find bounce layer 46 https://bugs.webkit.org/show_bug.cgi?id=225557 47 48 Reviewed by Tim Horton. 49 50 Factor out the text indicator bounce layer in preparation of making this 51 compatable with iOS. 52 53 No behavior change. 54 55 * SourcesCocoa.txt: 56 * WebCore.xcodeproj/project.pbxproj: 57 * page/mac/TextIndicatorWindow.h: 58 * page/mac/TextIndicatorWindow.mm: 59 (WebCore::TextIndicatorWindow::setAnimationProgress): 60 (WebCore::TextIndicatorWindow::clearTextIndicator): 61 (WebCore::TextIndicatorWindow::setTextIndicator): 62 (WebCore::TextIndicatorWindow::closeWindow): 63 (WebCore::TextIndicatorWindow::startFadeOut): 64 (indicatorWantsBounce): Deleted. 65 (indicatorWantsContentCrossfade): Deleted. 66 (indicatorWantsFadeIn): Deleted. 67 (indicatorWantsManualAnimation): Deleted. 68 (-[WebTextIndicatorView initWithFrame:textIndicator:margin:offset:]): Deleted. 69 (createBounceAnimation): Deleted. 70 (createContentCrossfadeAnimation): Deleted. 71 (createShadowFadeAnimation): Deleted. 72 (createFadeInAnimation): Deleted. 73 (-[WebTextIndicatorView _animationDuration]): Deleted. 74 (-[WebTextIndicatorView hasCompletedAnimation]): Deleted. 75 (-[WebTextIndicatorView present]): Deleted. 76 (-[WebTextIndicatorView hideWithCompletionHandler:]): Deleted. 77 (-[WebTextIndicatorView setAnimationProgress:]): Deleted. 78 (-[WebTextIndicatorView isFlipped]): Deleted. 79 1 80 2021-05-10 Russell Epstein <repstein@apple.com> 2 81 -
branches/safari-612.1.12-branch/Source/WebCore/SourcesCocoa.txt
r276331 r277469 183 183 page/cocoa/ResourceUsageThreadCocoa.mm 184 184 page/cocoa/SettingsBaseCocoa.mm 185 page/cocoa/WebTextIndicatorLayer.mm 185 186 page/ios/ContentChangeObserver.cpp 186 187 page/ios/DOMTimerHoldingTank.cpp -
branches/safari-612.1.12-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r276992 r277469 1270 1270 44C991860F3D1EBE00586670 /* ScrollbarThemeIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 44C991850F3D1EBE00586670 /* ScrollbarThemeIOS.h */; }; 1271 1271 44C9919F0F3D210E00586670 /* ThemeIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 44C9919D0F3D210E00586670 /* ThemeIOS.h */; }; 1272 44CE2BBF264379AF007AE110 /* WebTextIndicatorLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 44CE2BBE2643799E007AE110 /* WebTextIndicatorLayer.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1272 1273 44E349F9246F4E190068479C /* LibWebRTCEnumTraits.h in Headers */ = {isa = PBXBuildFile; fileRef = 44E349F7246F4DC70068479C /* LibWebRTCEnumTraits.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1273 1274 450CEBF115073BBE002BB149 /* LabelableElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 450CEBEF15073BBE002BB149 /* LabelableElement.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 8250 8251 44C9919E0F3D210E00586670 /* ThemeIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ThemeIOS.mm; sourceTree = "<group>"; }; 8251 8252 44CA2843245FCA5000C94C7F /* LocalCurrentGraphicsContextIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalCurrentGraphicsContextIOS.mm; sourceTree = "<group>"; }; 8253 44CE2BBC2643799D007AE110 /* WebTextIndicatorLayer.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebTextIndicatorLayer.mm; sourceTree = "<group>"; }; 8254 44CE2BBE2643799E007AE110 /* WebTextIndicatorLayer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebTextIndicatorLayer.h; sourceTree = "<group>"; }; 8252 8255 44D8DA98139545BE00337B75 /* SVGMPathElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SVGMPathElement.idl; sourceTree = "<group>"; }; 8253 8256 44D8DA9A139545CD00337B75 /* SVGAnimateMotionElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SVGAnimateMotionElement.idl; sourceTree = "<group>"; }; … … 21837 21840 A5071E881C56D4FA009951BE /* ResourceUsageThreadCocoa.mm */, 21838 21841 A182D5B61BE722620087A7CC /* SettingsBaseCocoa.mm */, 21842 44CE2BBE2643799E007AE110 /* WebTextIndicatorLayer.h */, 21843 44CE2BBC2643799D007AE110 /* WebTextIndicatorLayer.mm */, 21839 21844 ); 21840 21845 path = cocoa; … … 35790 35795 1F8756B21E22C3350042C40D /* WebSQLiteDatabaseTrackerClient.h in Headers */, 35791 35796 31DEA4561B39F4D900F77178 /* WebSystemBackdropLayer.h in Headers */, 35797 44CE2BBF264379AF007AE110 /* WebTextIndicatorLayer.h in Headers */, 35792 35798 0F580FA31496939100FB5BD8 /* WebTiledBackingLayer.h in Headers */, 35793 35799 1DAB3112251D6BF300FC9485 /* WebVideoContainerLayer.h in Headers */, -
branches/safari-612.1.12-branch/Source/WebCore/page/cocoa/WebTextIndicatorLayer.h
r277466 r277469 1 1 /* 2 * Copyright (C) 20 10Apple Inc. All rights reserved.2 * Copyright (C) 2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 32 32 #import <wtf/RunLoop.h> 33 33 34 OBJC_CLASS NSView; 35 OBJC_CLASS WebTextIndicatorView; 34 @interface WebTextIndicatorLayer : CALayer { 35 RefPtr<WebCore::TextIndicator> _textIndicator; 36 RetainPtr<NSArray> _bounceLayers; 37 CGSize _margin; 38 bool _hasCompletedAnimation; 39 BOOL _fadingOut; 40 } 36 41 37 namespace WebCore { 42 - (instancetype)initWithFrame:(CGRect)frame textIndicator:(WebCore::TextIndicator&)textIndicator margin:(CGSize)margin offset:(CGPoint)offset; 38 43 39 enum class TextIndicatorWindowLifetime : uint8_t { 40 // The TextIndicator should indicate the text until dismissed. 41 Permanent, 44 - (bool)indicatorWantsManualAnimation:(const WebCore::TextIndicator&)indicator; 45 - (bool)indicatorWantsBounce:(const WebCore::TextIndicator&)indicator; 42 46 43 // The TextIndicator should briefly indicate the text and then automatically dismiss. 44 Temporary 45 }; 47 - (void)present; 48 - (void)hideWithCompletionHandler:(void(^)(void))completionHandler; 46 49 47 enum class TextIndicatorWindowDismissalAnimation : uint8_t { 48 None, 49 FadeOut 50 }; 50 - (void)setAnimationProgress:(float)progress; 51 - (BOOL)hasCompletedAnimation; 51 52 52 #if PLATFORM(MAC) 53 @property (nonatomic, getter=isFadingOut) BOOL fadingOut; 53 54 54 class TextIndicatorWindow { 55 WTF_MAKE_FAST_ALLOCATED; 56 WTF_MAKE_NONCOPYABLE(TextIndicatorWindow); 57 58 public: 59 WEBCORE_EXPORT explicit TextIndicatorWindow(NSView *); 60 WEBCORE_EXPORT ~TextIndicatorWindow(); 61 62 WEBCORE_EXPORT void setTextIndicator(Ref<TextIndicator>, CGRect contentRect, TextIndicatorWindowLifetime); 63 WEBCORE_EXPORT void clearTextIndicator(TextIndicatorWindowDismissalAnimation); 64 65 WEBCORE_EXPORT void setAnimationProgress(float); 66 67 private: 68 void closeWindow(); 69 70 void startFadeOut(); 71 72 NSView *m_targetView; 73 RefPtr<TextIndicator> m_textIndicator; 74 RetainPtr<NSWindow> m_textIndicatorWindow; 75 RetainPtr<WebTextIndicatorView> m_textIndicatorView; 76 77 RunLoop::Timer<TextIndicatorWindow> m_temporaryTextIndicatorTimer; 78 }; 79 80 #endif // PLATFORM(MAC) 81 82 } // namespace WebCore 55 @end -
branches/safari-612.1.12-branch/Source/WebCore/page/cocoa/WebTextIndicatorLayer.mm
r277466 r277469 1 1 /* 2 * Copyright (C) 20 10Apple Inc. All rights reserved.2 * Copyright (C) 2021 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 25 25 26 26 #import "config.h" 27 #import "TextIndicatorWindow.h" 28 29 #if PLATFORM(MAC) 27 #import "WebTextIndicatorLayer.h" 30 28 31 29 #import "GeometryUtilities.h" … … 35 33 #import "WebActionDisablingCALayerDelegate.h" 36 34 #import <pal/spi/cg/CoreGraphicsSPI.h> 35 #import <pal/spi/cocoa/QuartzCoreSPI.h> 36 37 #if PLATFORM(MAC) 37 38 #import <pal/spi/cocoa/NSColorSPI.h> 38 #import <pal/spi/cocoa/QuartzCoreSPI.h> 39 40 const CFTimeInterval bounceAnimationDuration = 0.12; 41 const CFTimeInterval bounceWithCrossfadeAnimationDuration = 0.3; 42 const CFTimeInterval fadeInAnimationDuration = 0.15; 43 const CFTimeInterval timeBeforeFadeStarts = bounceAnimationDuration + 0.2; 44 const CFTimeInterval fadeOutAnimationDuration = 0.3; 45 46 const CGFloat midBounceScale = 1.25; 47 const CGFloat borderWidth = 0; 48 const CGFloat cornerRadius = 0; 49 const CGFloat dropShadowOffsetX = 0; 50 const CGFloat dropShadowOffsetY = 1; 51 const CGFloat dropShadowBlurRadius = 2; 52 const CGFloat rimShadowBlurRadius = 1; 53 54 NSString *textLayerKey = @"TextLayer"; 55 NSString *dropShadowLayerKey = @"DropShadowLayer"; 56 NSString *rimShadowLayerKey = @"RimShadowLayer"; 57 58 using namespace WebCore; 59 60 @interface WebTextIndicatorView : NSView { 61 RefPtr<TextIndicator> _textIndicator; 62 RetainPtr<NSArray> _bounceLayers; 63 NSSize _margin; 64 bool _hasCompletedAnimation; 65 BOOL _fadingOut; 66 } 67 68 - (instancetype)initWithFrame:(NSRect)frame textIndicator:(TextIndicator&)textIndicator margin:(NSSize)margin offset:(NSPoint)offset; 69 70 - (void)present; 71 - (void)hideWithCompletionHandler:(void(^)(void))completionHandler; 72 73 - (void)setAnimationProgress:(float)progress; 74 - (BOOL)hasCompletedAnimation; 75 76 @property (nonatomic, getter=isFadingOut) BOOL fadingOut; 77 78 @end 79 80 @implementation WebTextIndicatorView 39 #endif 40 41 constexpr CFTimeInterval bounceAnimationDuration = 0.12; 42 constexpr CFTimeInterval bounceWithCrossfadeAnimationDuration = 0.3; 43 constexpr CFTimeInterval fadeInAnimationDuration = 0.15; 44 constexpr CFTimeInterval timeBeforeFadeStarts = bounceAnimationDuration + 0.2; 45 constexpr CFTimeInterval fadeOutAnimationDuration = 0.3; 46 47 constexpr CGFloat midBounceScale = 1.25; 48 constexpr CGFloat borderWidth = 0; 49 constexpr CGFloat cornerRadius = 0; 50 constexpr CGFloat dropShadowOffsetX = 0; 51 constexpr CGFloat dropShadowOffsetY = 1; 52 constexpr CGFloat dropShadowBlurRadius = 2; 53 constexpr CGFloat rimShadowBlurRadius = 1; 54 55 constexpr NSString * const textLayerKey = @"TextLayer"; 56 constexpr NSString * const dropShadowLayerKey = @"DropShadowLayer"; 57 constexpr NSString * const rimShadowLayerKey = @"RimShadowLayer"; 58 59 @implementation WebTextIndicatorLayer 81 60 82 61 @synthesize fadingOut = _fadingOut; 83 62 84 static bool indicatorWantsBounce(const TextIndicator& indicator) 85 { 63 static bool indicatorWantsContentCrossfade(const WebCore::TextIndicator& indicator) 64 { 65 if (!indicator.data().contentImageWithHighlight) 66 return false; 67 86 68 switch (indicator.presentationTransition()) { 87 case TextIndicatorPresentationTransition::BounceAndCrossfade: 88 case TextIndicatorPresentationTransition::Bounce: 69 case WebCore::TextIndicatorPresentationTransition::BounceAndCrossfade: 89 70 return true; 90 71 91 case TextIndicatorPresentationTransition::FadeIn: 92 case TextIndicatorPresentationTransition::None: 72 case WebCore::TextIndicatorPresentationTransition::Bounce: 73 case WebCore::TextIndicatorPresentationTransition::FadeIn: 74 case WebCore::TextIndicatorPresentationTransition::None: 93 75 return false; 94 76 } … … 98 80 } 99 81 100 static bool indicatorWantsContentCrossfade(const TextIndicator& indicator) 101 { 102 if (!indicator.data().contentImageWithHighlight) 103 return false; 104 82 static bool indicatorWantsFadeIn(const WebCore::TextIndicator& indicator) 83 { 105 84 switch (indicator.presentationTransition()) { 106 case TextIndicatorPresentationTransition::BounceAndCrossfade:85 case WebCore::TextIndicatorPresentationTransition::FadeIn: 107 86 return true; 108 87 109 case TextIndicatorPresentationTransition::Bounce:110 case TextIndicatorPresentationTransition::FadeIn:111 case TextIndicatorPresentationTransition::None:88 case WebCore::TextIndicatorPresentationTransition::Bounce: 89 case WebCore::TextIndicatorPresentationTransition::BounceAndCrossfade: 90 case WebCore::TextIndicatorPresentationTransition::None: 112 91 return false; 113 92 } … … 117 96 } 118 97 119 static bool indicatorWantsFadeIn(const TextIndicator& indicator) 98 - (bool)indicatorWantsBounce:(const WebCore::TextIndicator&)indicator 120 99 { 121 100 switch (indicator.presentationTransition()) { 122 case TextIndicatorPresentationTransition::FadeIn: 101 case WebCore::TextIndicatorPresentationTransition::BounceAndCrossfade: 102 case WebCore::TextIndicatorPresentationTransition::Bounce: 123 103 return true; 124 104 125 case TextIndicatorPresentationTransition::Bounce: 126 case TextIndicatorPresentationTransition::BounceAndCrossfade: 127 case TextIndicatorPresentationTransition::None: 105 case WebCore::TextIndicatorPresentationTransition::FadeIn: 106 case WebCore::TextIndicatorPresentationTransition::None: 128 107 return false; 129 108 } … … 133 112 } 134 113 135 static bool indicatorWantsManualAnimation(const TextIndicator& indicator) 114 - (bool)indicatorWantsManualAnimation:(const WebCore::TextIndicator&)indicator 136 115 { 137 116 switch (indicator.presentationTransition()) { 138 case TextIndicatorPresentationTransition::FadeIn:117 case WebCore::TextIndicatorPresentationTransition::FadeIn: 139 118 return true; 140 119 141 case TextIndicatorPresentationTransition::Bounce:142 case TextIndicatorPresentationTransition::BounceAndCrossfade:143 case TextIndicatorPresentationTransition::None:120 case WebCore::TextIndicatorPresentationTransition::Bounce: 121 case WebCore::TextIndicatorPresentationTransition::BounceAndCrossfade: 122 case WebCore::TextIndicatorPresentationTransition::None: 144 123 return false; 145 124 } … … 149 128 } 150 129 151 - (instancetype)initWithFrame:( NSRect)frame textIndicator:(TextIndicator&)textIndicator margin:(NSSize)margin offset:(NSPoint)offset152 { 153 if (!(self = [super init WithFrame:frame]))130 - (instancetype)initWithFrame:(CGRect)frame textIndicator:(WebCore::TextIndicator&)textIndicator margin:(CGSize)margin offset:(CGPoint)offset 131 { 132 if (!(self = [super init])) 154 133 return nil; 134 135 self.frame = frame; 155 136 156 137 _textIndicator = &textIndicator; 157 138 _margin = margin; 158 139 159 self.wantsLayer = YES; 160 self.layer.anchorPoint = CGPointZero; 161 162 RefPtr<NativeImage> contentsImage; 163 FloatSize contentsImageLogicalSize { 1, 1 }; 140 self.anchorPoint = CGPointZero; 141 142 RefPtr<WebCore::NativeImage> contentsImage; 143 WebCore::FloatSize contentsImageLogicalSize { 1, 1 }; 164 144 if (auto* contentImage = _textIndicator->contentImage()) { 165 145 contentsImageLogicalSize = contentImage->size(); … … 171 151 } 172 152 173 RetainPtr<NSMutableArray> bounceLayers = adoptNS([[NSMutableArray alloc] init]); 174 175 RetainPtr<CGColorRef> highlightColor = [NSColor findHighlightColor].CGColor; 176 RetainPtr<CGColorRef> rimShadowColor = [NSColor colorWithDeviceWhite:0 alpha:0.35].CGColor; 177 RetainPtr<CGColorRef> dropShadowColor = [NSColor colorWithDeviceWhite:0 alpha:0.2].CGColor; 178 179 RetainPtr<CGColorRef> borderColor = [NSColor colorWithDeviceRed:.96 green:.90 blue:0 alpha:1].CGColor; 180 181 Vector<FloatRect> textRectsInBoundingRectCoordinates = _textIndicator->textRectsInBoundingRectCoordinates(); 182 183 Vector<Path> paths = PathUtilities::pathsWithShrinkWrappedRects(textRectsInBoundingRectCoordinates, cornerRadius); 153 auto bounceLayers = adoptNS([[NSMutableArray alloc] init]); 154 155 RetainPtr<CGColorRef> highlightColor; 156 auto rimShadowColor = adoptCF(CGColorCreateGenericGray(0, 0.35)); 157 auto dropShadowColor = adoptCF(CGColorCreateGenericGray(0, 0.2)); 158 auto borderColor = adoptCF(CGColorCreateSRGB(0.96, 0.9, 0, 1)); 159 #if PLATFORM(MAC) 160 highlightColor = [NSColor findHighlightColor].CGColor; 161 #else 162 highlightColor = adoptCF(CGColorCreateSRGB(.99, .89, 0.22, 1.0)); 163 #endif 164 165 auto textRectsInBoundingRectCoordinates = _textIndicator->textRectsInBoundingRectCoordinates(); 166 167 auto paths = WebCore::PathUtilities::pathsWithShrinkWrappedRects(textRectsInBoundingRectCoordinates, cornerRadius); 184 168 185 169 for (const auto& path : paths) { 186 FloatRect pathBoundingRect = path.boundingRect();187 188 Path translatedPath;189 AffineTransform transform;170 WebCore::FloatRect pathBoundingRect = path.boundingRect(); 171 172 WebCore::Path translatedPath; 173 WebCore::AffineTransform transform; 190 174 transform.translate(-pathBoundingRect.location()); 191 175 translatedPath.addPath(path, transform); 192 176 193 FloatRect offsetTextRect = pathBoundingRect;177 WebCore::FloatRect offsetTextRect = pathBoundingRect; 194 178 offsetTextRect.move(offset.x, offset.y); 195 179 196 FloatRect bounceLayerRect = offsetTextRect;180 WebCore::FloatRect bounceLayerRect = offsetTextRect; 197 181 bounceLayerRect.move(_margin.width, _margin.height); 198 182 … … 203 187 [bounceLayers addObject:bounceLayer.get()]; 204 188 205 FloatRect yellowHighlightRect(FloatPoint(), bounceLayerRect.size()); 206 189 WebCore::FloatRect yellowHighlightRect(WebCore::FloatPoint(), bounceLayerRect.size()); 190 191 #if PLATFORM(MAC) 207 192 RetainPtr<CALayer> dropShadowLayer = adoptNS([[CALayer alloc] init]); 208 193 [dropShadowLayer setDelegate:[WebActionDisablingCALayerDelegate shared]]; … … 227 212 [bounceLayer addSublayer:rimShadowLayer.get()]; 228 213 [bounceLayer setValue:rimShadowLayer.get() forKey:rimShadowLayerKey]; 229 214 #endif // PLATFORM(MAC) 215 230 216 RetainPtr<CALayer> textLayer = adoptNS([[CALayer alloc] init]); 231 217 [textLayer setBackgroundColor:highlightColor.get()]; … … 240 226 [textLayer setMask:maskLayer.get()]; 241 227 242 FloatRect imageRect = pathBoundingRect;228 WebCore::FloatRect imageRect = pathBoundingRect; 243 229 [textLayer setContentsRect:CGRectMake(imageRect.x() / contentsImageLogicalSize.width(), imageRect.y() / contentsImageLogicalSize.height(), imageRect.width() / contentsImageLogicalSize.width(), imageRect.height() / contentsImageLogicalSize.height())]; 244 230 [textLayer setContentsGravity:kCAGravityCenter]; … … 249 235 } 250 236 251 self. layer.sublayers = bounceLayers.get();237 self.sublayers = bounceLayers.get(); 252 238 _bounceLayers = bounceLayers; 253 239 … … 268 254 } 269 255 270 static RetainPtr<CABasicAnimation> createContentCrossfadeAnimation(CFTimeInterval duration, TextIndicator& textIndicator)256 static RetainPtr<CABasicAnimation> createContentCrossfadeAnimation(CFTimeInterval duration, WebCore::TextIndicator& textIndicator) 271 257 { 272 258 RetainPtr<CABasicAnimation> crossfadeAnimation = [CABasicAnimation animationWithKeyPath:@"contents"]; … … 306 292 - (CFTimeInterval)_animationDuration 307 293 { 308 if ( indicatorWantsBounce(*_textIndicator)) {294 if ([self indicatorWantsBounce:*_textIndicator]) { 309 295 if (indicatorWantsContentCrossfade(*_textIndicator)) 310 296 return bounceWithCrossfadeAnimationDuration; … … 322 308 - (void)present 323 309 { 324 bool wantsBounce = indicatorWantsBounce(*_textIndicator);310 bool wantsBounce = [self indicatorWantsBounce:*_textIndicator]; 325 311 bool wantsCrossfade = indicatorWantsContentCrossfade(*_textIndicator); 326 312 bool wantsFadeIn = indicatorWantsFadeIn(*_textIndicator); … … 344 330 [CATransaction begin]; 345 331 for (CALayer *bounceLayer in _bounceLayers.get()) { 346 if ( indicatorWantsManualAnimation(*_textIndicator))332 if ([self indicatorWantsManualAnimation:*_textIndicator]) 347 333 bounceLayer.speed = 0; 348 334 … … 373 359 [CATransaction begin]; 374 360 [CATransaction setCompletionBlock:completionHandler]; 375 [self .layeraddAnimation:fadeAnimation.get() forKey:@"fadeOut"];361 [self addAnimation:fadeAnimation.get() forKey:@"fadeOut"]; 376 362 [CATransaction commit]; 377 363 } … … 405 391 406 392 @end 407 408 namespace WebCore {409 410 TextIndicatorWindow::TextIndicatorWindow(NSView *targetView)411 : m_targetView(targetView)412 , m_temporaryTextIndicatorTimer(RunLoop::main(), this, &TextIndicatorWindow::startFadeOut)413 {414 }415 416 TextIndicatorWindow::~TextIndicatorWindow()417 {418 clearTextIndicator(TextIndicatorWindowDismissalAnimation::FadeOut);419 }420 421 void TextIndicatorWindow::setAnimationProgress(float progress)422 {423 if (!m_textIndicator)424 return;425 426 [m_textIndicatorView setAnimationProgress:progress];427 }428 429 void TextIndicatorWindow::clearTextIndicator(TextIndicatorWindowDismissalAnimation animation)430 {431 RefPtr<TextIndicator> textIndicator = WTFMove(m_textIndicator);432 433 if ([m_textIndicatorView isFadingOut])434 return;435 436 if (textIndicator && indicatorWantsManualAnimation(*textIndicator) && [m_textIndicatorView hasCompletedAnimation] && animation == TextIndicatorWindowDismissalAnimation::FadeOut) {437 startFadeOut();438 return;439 }440 441 closeWindow();442 }443 444 void TextIndicatorWindow::setTextIndicator(Ref<TextIndicator> textIndicator, CGRect textBoundingRectInScreenCoordinates, TextIndicatorWindowLifetime lifetime)445 {446 if (m_textIndicator == textIndicator.ptr())447 return;448 449 closeWindow();450 451 m_textIndicator = textIndicator.ptr();452 453 CGFloat horizontalMargin = dropShadowBlurRadius * 2 + TextIndicator::defaultHorizontalMargin;454 CGFloat verticalMargin = dropShadowBlurRadius * 2 + TextIndicator::defaultVerticalMargin;455 456 if (indicatorWantsBounce(*m_textIndicator)) {457 horizontalMargin = std::max(horizontalMargin, textBoundingRectInScreenCoordinates.size.width * (midBounceScale - 1) + horizontalMargin);458 verticalMargin = std::max(verticalMargin, textBoundingRectInScreenCoordinates.size.height * (midBounceScale - 1) + verticalMargin);459 }460 461 horizontalMargin = CGCeiling(horizontalMargin);462 verticalMargin = CGCeiling(verticalMargin);463 464 CGRect contentRect = CGRectInset(textBoundingRectInScreenCoordinates, -horizontalMargin, -verticalMargin);465 NSRect windowContentRect = [NSWindow contentRectForFrameRect:NSRectFromCGRect(contentRect) styleMask:NSWindowStyleMaskBorderless];466 NSRect integralWindowContentRect = NSIntegralRect(windowContentRect);467 NSPoint fractionalTextOffset = NSMakePoint(windowContentRect.origin.x - integralWindowContentRect.origin.x, windowContentRect.origin.y - integralWindowContentRect.origin.y);468 m_textIndicatorWindow = adoptNS([[NSWindow alloc] initWithContentRect:integralWindowContentRect styleMask:NSWindowStyleMaskBorderless backing:NSBackingStoreBuffered defer:NO]);469 [m_textIndicatorWindow setBackgroundColor:[NSColor clearColor]];470 [m_textIndicatorWindow setOpaque:NO];471 [m_textIndicatorWindow setIgnoresMouseEvents:YES];472 473 m_textIndicatorView = adoptNS([[WebTextIndicatorView alloc] initWithFrame:NSMakeRect(0, 0, [m_textIndicatorWindow frame].size.width, [m_textIndicatorWindow frame].size.height)474 textIndicator:*m_textIndicator margin:NSMakeSize(horizontalMargin, verticalMargin) offset:fractionalTextOffset]);475 [m_textIndicatorWindow setContentView:m_textIndicatorView.get()];476 477 [[m_targetView window] addChildWindow:m_textIndicatorWindow.get() ordered:NSWindowAbove];478 [m_textIndicatorWindow setReleasedWhenClosed:NO];479 480 if (m_textIndicator->presentationTransition() != TextIndicatorPresentationTransition::None)481 [m_textIndicatorView present];482 483 if (lifetime == TextIndicatorWindowLifetime::Temporary)484 m_temporaryTextIndicatorTimer.startOneShot(1_s * timeBeforeFadeStarts);485 }486 487 void TextIndicatorWindow::closeWindow()488 {489 if (!m_textIndicatorWindow)490 return;491 492 if ([m_textIndicatorView isFadingOut])493 return;494 495 m_temporaryTextIndicatorTimer.stop();496 497 [[m_textIndicatorWindow parentWindow] removeChildWindow:m_textIndicatorWindow.get()];498 [m_textIndicatorWindow close];499 m_textIndicatorWindow = nullptr;500 }501 502 void TextIndicatorWindow::startFadeOut()503 {504 [m_textIndicatorView setFadingOut:YES];505 RetainPtr<NSWindow> indicatorWindow = m_textIndicatorWindow;506 [m_textIndicatorView hideWithCompletionHandler:[indicatorWindow] {507 [[indicatorWindow parentWindow] removeChildWindow:indicatorWindow.get()];508 [indicatorWindow close];509 }];510 }511 512 } // namespace WebCore513 514 #endif // PLATFORM(MAC) -
branches/safari-612.1.12-branch/Source/WebCore/page/mac/TextIndicatorWindow.h
r248762 r277469 33 33 34 34 OBJC_CLASS NSView; 35 OBJC_CLASS WebTextIndicator View;35 OBJC_CLASS WebTextIndicatorLayer; 36 36 37 37 namespace WebCore { … … 73 73 RefPtr<TextIndicator> m_textIndicator; 74 74 RetainPtr<NSWindow> m_textIndicatorWindow; 75 RetainPtr<WebTextIndicatorView> m_textIndicatorView; 75 RetainPtr<NSView> m_textIndicatorView; 76 RetainPtr<WebTextIndicatorLayer> m_textIndicatorLayer; 76 77 77 78 RunLoop::Timer<TextIndicatorWindow> m_temporaryTextIndicatorTimer; -
branches/safari-612.1.12-branch/Source/WebCore/page/mac/TextIndicatorWindow.mm
r271694 r277469 34 34 #import "TextIndicator.h" 35 35 #import "WebActionDisablingCALayerDelegate.h" 36 #import "WebTextIndicatorLayer.h" 36 37 #import <pal/spi/cg/CoreGraphicsSPI.h> 37 38 #import <pal/spi/cocoa/NSColorSPI.h> … … 39 40 40 41 const CFTimeInterval bounceAnimationDuration = 0.12; 41 const CFTimeInterval bounceWithCrossfadeAnimationDuration = 0.3;42 const CFTimeInterval fadeInAnimationDuration = 0.15;43 42 const CFTimeInterval timeBeforeFadeStarts = bounceAnimationDuration + 0.2; 44 const CFTimeInterval fadeOutAnimationDuration = 0.3;45 43 46 44 const CGFloat midBounceScale = 1.25; 47 const CGFloat borderWidth = 0;48 const CGFloat cornerRadius = 0;49 const CGFloat dropShadowOffsetX = 0;50 const CGFloat dropShadowOffsetY = 1;51 45 const CGFloat dropShadowBlurRadius = 2; 52 const CGFloat rimShadowBlurRadius = 1;53 54 NSString *textLayerKey = @"TextLayer";55 NSString *dropShadowLayerKey = @"DropShadowLayer";56 NSString *rimShadowLayerKey = @"RimShadowLayer";57 46 58 47 using namespace WebCore; 59 60 @interface WebTextIndicatorView : NSView {61 RefPtr<TextIndicator> _textIndicator;62 RetainPtr<NSArray> _bounceLayers;63 NSSize _margin;64 bool _hasCompletedAnimation;65 BOOL _fadingOut;66 }67 68 - (instancetype)initWithFrame:(NSRect)frame textIndicator:(TextIndicator&)textIndicator margin:(NSSize)margin offset:(NSPoint)offset;69 70 - (void)present;71 - (void)hideWithCompletionHandler:(void(^)(void))completionHandler;72 73 - (void)setAnimationProgress:(float)progress;74 - (BOOL)hasCompletedAnimation;75 76 @property (nonatomic, getter=isFadingOut) BOOL fadingOut;77 78 @end79 80 @implementation WebTextIndicatorView81 82 @synthesize fadingOut = _fadingOut;83 84 static bool indicatorWantsBounce(const TextIndicator& indicator)85 {86 switch (indicator.presentationTransition()) {87 case TextIndicatorPresentationTransition::BounceAndCrossfade:88 case TextIndicatorPresentationTransition::Bounce:89 return true;90 91 case TextIndicatorPresentationTransition::FadeIn:92 case TextIndicatorPresentationTransition::None:93 return false;94 }95 96 ASSERT_NOT_REACHED();97 return false;98 }99 100 static bool indicatorWantsContentCrossfade(const TextIndicator& indicator)101 {102 if (!indicator.data().contentImageWithHighlight)103 return false;104 105 switch (indicator.presentationTransition()) {106 case TextIndicatorPresentationTransition::BounceAndCrossfade:107 return true;108 109 case TextIndicatorPresentationTransition::Bounce:110 case TextIndicatorPresentationTransition::FadeIn:111 case TextIndicatorPresentationTransition::None:112 return false;113 }114 115 ASSERT_NOT_REACHED();116 return false;117 }118 119 static bool indicatorWantsFadeIn(const TextIndicator& indicator)120 {121 switch (indicator.presentationTransition()) {122 case TextIndicatorPresentationTransition::FadeIn:123 return true;124 125 case TextIndicatorPresentationTransition::Bounce:126 case TextIndicatorPresentationTransition::BounceAndCrossfade:127 case TextIndicatorPresentationTransition::None:128 return false;129 }130 131 ASSERT_NOT_REACHED();132 return false;133 }134 135 static bool indicatorWantsManualAnimation(const TextIndicator& indicator)136 {137 switch (indicator.presentationTransition()) {138 case TextIndicatorPresentationTransition::FadeIn:139 return true;140 141 case TextIndicatorPresentationTransition::Bounce:142 case TextIndicatorPresentationTransition::BounceAndCrossfade:143 case TextIndicatorPresentationTransition::None:144 return false;145 }146 147 ASSERT_NOT_REACHED();148 return false;149 }150 151 - (instancetype)initWithFrame:(NSRect)frame textIndicator:(TextIndicator&)textIndicator margin:(NSSize)margin offset:(NSPoint)offset152 {153 if (!(self = [super initWithFrame:frame]))154 return nil;155 156 _textIndicator = &textIndicator;157 _margin = margin;158 159 self.wantsLayer = YES;160 self.layer.anchorPoint = CGPointZero;161 162 RefPtr<NativeImage> contentsImage;163 FloatSize contentsImageLogicalSize { 1, 1 };164 if (auto* contentImage = _textIndicator->contentImage()) {165 contentsImageLogicalSize = contentImage->size();166 contentsImageLogicalSize.scale(1 / _textIndicator->contentImageScaleFactor());167 if (indicatorWantsContentCrossfade(*_textIndicator) && _textIndicator->contentImageWithHighlight())168 contentsImage = _textIndicator->contentImageWithHighlight()->nativeImage();169 else170 contentsImage = contentImage->nativeImage();171 }172 173 RetainPtr<NSMutableArray> bounceLayers = adoptNS([[NSMutableArray alloc] init]);174 175 RetainPtr<CGColorRef> highlightColor = [NSColor findHighlightColor].CGColor;176 RetainPtr<CGColorRef> rimShadowColor = [NSColor colorWithDeviceWhite:0 alpha:0.35].CGColor;177 RetainPtr<CGColorRef> dropShadowColor = [NSColor colorWithDeviceWhite:0 alpha:0.2].CGColor;178 179 RetainPtr<CGColorRef> borderColor = [NSColor colorWithDeviceRed:.96 green:.90 blue:0 alpha:1].CGColor;180 181 Vector<FloatRect> textRectsInBoundingRectCoordinates = _textIndicator->textRectsInBoundingRectCoordinates();182 183 Vector<Path> paths = PathUtilities::pathsWithShrinkWrappedRects(textRectsInBoundingRectCoordinates, cornerRadius);184 185 for (const auto& path : paths) {186 FloatRect pathBoundingRect = path.boundingRect();187 188 Path translatedPath;189 AffineTransform transform;190 transform.translate(-pathBoundingRect.location());191 translatedPath.addPath(path, transform);192 193 FloatRect offsetTextRect = pathBoundingRect;194 offsetTextRect.move(offset.x, offset.y);195 196 FloatRect bounceLayerRect = offsetTextRect;197 bounceLayerRect.move(_margin.width, _margin.height);198 199 RetainPtr<CALayer> bounceLayer = adoptNS([[CALayer alloc] init]);200 [bounceLayer setDelegate:[WebActionDisablingCALayerDelegate shared]];201 [bounceLayer setFrame:bounceLayerRect];202 [bounceLayer setOpacity:0];203 [bounceLayers addObject:bounceLayer.get()];204 205 FloatRect yellowHighlightRect(FloatPoint(), bounceLayerRect.size());206 207 RetainPtr<CALayer> dropShadowLayer = adoptNS([[CALayer alloc] init]);208 [dropShadowLayer setDelegate:[WebActionDisablingCALayerDelegate shared]];209 [dropShadowLayer setShadowColor:dropShadowColor.get()];210 [dropShadowLayer setShadowRadius:dropShadowBlurRadius];211 [dropShadowLayer setShadowOffset:CGSizeMake(dropShadowOffsetX, dropShadowOffsetY)];212 [dropShadowLayer setShadowPath:translatedPath.platformPath()];213 [dropShadowLayer setShadowOpacity:1];214 [dropShadowLayer setFrame:yellowHighlightRect];215 [bounceLayer addSublayer:dropShadowLayer.get()];216 [bounceLayer setValue:dropShadowLayer.get() forKey:dropShadowLayerKey];217 218 RetainPtr<CALayer> rimShadowLayer = adoptNS([[CALayer alloc] init]);219 [rimShadowLayer setDelegate:[WebActionDisablingCALayerDelegate shared]];220 [rimShadowLayer setFrame:yellowHighlightRect];221 [rimShadowLayer setShadowColor:rimShadowColor.get()];222 [rimShadowLayer setShadowRadius:rimShadowBlurRadius];223 [rimShadowLayer setShadowPath:translatedPath.platformPath()];224 [rimShadowLayer setShadowOffset:CGSizeZero];225 [rimShadowLayer setShadowOpacity:1];226 [rimShadowLayer setFrame:yellowHighlightRect];227 [bounceLayer addSublayer:rimShadowLayer.get()];228 [bounceLayer setValue:rimShadowLayer.get() forKey:rimShadowLayerKey];229 230 RetainPtr<CALayer> textLayer = adoptNS([[CALayer alloc] init]);231 [textLayer setBackgroundColor:highlightColor.get()];232 [textLayer setBorderColor:borderColor.get()];233 [textLayer setBorderWidth:borderWidth];234 [textLayer setDelegate:[WebActionDisablingCALayerDelegate shared]];235 if (contentsImage)236 [textLayer setContents:(__bridge id)contentsImage->platformImage().get()];237 238 RetainPtr<CAShapeLayer> maskLayer = adoptNS([[CAShapeLayer alloc] init]);239 [maskLayer setPath:translatedPath.platformPath()];240 [textLayer setMask:maskLayer.get()];241 242 FloatRect imageRect = pathBoundingRect;243 [textLayer setContentsRect:CGRectMake(imageRect.x() / contentsImageLogicalSize.width(), imageRect.y() / contentsImageLogicalSize.height(), imageRect.width() / contentsImageLogicalSize.width(), imageRect.height() / contentsImageLogicalSize.height())];244 [textLayer setContentsGravity:kCAGravityCenter];245 [textLayer setContentsScale:_textIndicator->contentImageScaleFactor()];246 [textLayer setFrame:yellowHighlightRect];247 [bounceLayer setValue:textLayer.get() forKey:textLayerKey];248 [bounceLayer addSublayer:textLayer.get()];249 }250 251 self.layer.sublayers = bounceLayers.get();252 _bounceLayers = bounceLayers;253 254 return self;255 }256 257 static RetainPtr<CAKeyframeAnimation> createBounceAnimation(CFTimeInterval duration)258 {259 RetainPtr<CAKeyframeAnimation> bounceAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];260 [bounceAnimation setValues:@[261 [NSValue valueWithCATransform3D:CATransform3DIdentity],262 [NSValue valueWithCATransform3D:CATransform3DMakeScale(midBounceScale, midBounceScale, 1)],263 [NSValue valueWithCATransform3D:CATransform3DIdentity]264 ]];265 [bounceAnimation setDuration:duration];266 267 return bounceAnimation;268 }269 270 static RetainPtr<CABasicAnimation> createContentCrossfadeAnimation(CFTimeInterval duration, TextIndicator& textIndicator)271 {272 RetainPtr<CABasicAnimation> crossfadeAnimation = [CABasicAnimation animationWithKeyPath:@"contents"];273 auto contentsImage = textIndicator.contentImage()->nativeImage();274 [crossfadeAnimation setToValue:(__bridge id)contentsImage->platformImage().get()];275 [crossfadeAnimation setFillMode:kCAFillModeForwards];276 [crossfadeAnimation setRemovedOnCompletion:NO];277 [crossfadeAnimation setDuration:duration];278 279 return crossfadeAnimation;280 }281 282 static RetainPtr<CABasicAnimation> createShadowFadeAnimation(CFTimeInterval duration)283 {284 RetainPtr<CABasicAnimation> fadeShadowInAnimation = [CABasicAnimation animationWithKeyPath:@"shadowOpacity"];285 [fadeShadowInAnimation setFromValue:@0];286 [fadeShadowInAnimation setToValue:@1];287 [fadeShadowInAnimation setFillMode:kCAFillModeForwards];288 [fadeShadowInAnimation setRemovedOnCompletion:NO];289 [fadeShadowInAnimation setDuration:duration];290 291 return fadeShadowInAnimation;292 }293 294 static RetainPtr<CABasicAnimation> createFadeInAnimation(CFTimeInterval duration)295 {296 RetainPtr<CABasicAnimation> fadeInAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];297 [fadeInAnimation setFromValue:@0];298 [fadeInAnimation setToValue:@1];299 [fadeInAnimation setFillMode:kCAFillModeForwards];300 [fadeInAnimation setRemovedOnCompletion:NO];301 [fadeInAnimation setDuration:duration];302 303 return fadeInAnimation;304 }305 306 - (CFTimeInterval)_animationDuration307 {308 if (indicatorWantsBounce(*_textIndicator)) {309 if (indicatorWantsContentCrossfade(*_textIndicator))310 return bounceWithCrossfadeAnimationDuration;311 return bounceAnimationDuration;312 }313 314 return fadeInAnimationDuration;315 }316 317 - (BOOL)hasCompletedAnimation318 {319 return _hasCompletedAnimation;320 }321 322 - (void)present323 {324 bool wantsBounce = indicatorWantsBounce(*_textIndicator);325 bool wantsCrossfade = indicatorWantsContentCrossfade(*_textIndicator);326 bool wantsFadeIn = indicatorWantsFadeIn(*_textIndicator);327 CFTimeInterval animationDuration = [self _animationDuration];328 329 _hasCompletedAnimation = false;330 331 RetainPtr<CAAnimation> presentationAnimation;332 if (wantsBounce)333 presentationAnimation = createBounceAnimation(animationDuration);334 else if (wantsFadeIn)335 presentationAnimation = createFadeInAnimation(animationDuration);336 337 RetainPtr<CABasicAnimation> crossfadeAnimation;338 RetainPtr<CABasicAnimation> fadeShadowInAnimation;339 if (wantsCrossfade) {340 crossfadeAnimation = createContentCrossfadeAnimation(animationDuration, *_textIndicator);341 fadeShadowInAnimation = createShadowFadeAnimation(animationDuration);342 }343 344 [CATransaction begin];345 for (CALayer *bounceLayer in _bounceLayers.get()) {346 if (indicatorWantsManualAnimation(*_textIndicator))347 bounceLayer.speed = 0;348 349 if (!wantsFadeIn)350 bounceLayer.opacity = 1;351 352 if (presentationAnimation)353 [bounceLayer addAnimation:presentationAnimation.get() forKey:@"presentation"];354 355 if (wantsCrossfade) {356 [[bounceLayer valueForKey:textLayerKey] addAnimation:crossfadeAnimation.get() forKey:@"contentTransition"];357 [[bounceLayer valueForKey:dropShadowLayerKey] addAnimation:fadeShadowInAnimation.get() forKey:@"fadeShadowIn"];358 [[bounceLayer valueForKey:rimShadowLayerKey] addAnimation:fadeShadowInAnimation.get() forKey:@"fadeShadowIn"];359 }360 }361 [CATransaction commit];362 }363 364 - (void)hideWithCompletionHandler:(void(^)(void))completionHandler365 {366 RetainPtr<CABasicAnimation> fadeAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];367 [fadeAnimation setFromValue:@1];368 [fadeAnimation setToValue:@0];369 [fadeAnimation setFillMode:kCAFillModeForwards];370 [fadeAnimation setRemovedOnCompletion:NO];371 [fadeAnimation setDuration:fadeOutAnimationDuration];372 373 [CATransaction begin];374 [CATransaction setCompletionBlock:completionHandler];375 [self.layer addAnimation:fadeAnimation.get() forKey:@"fadeOut"];376 [CATransaction commit];377 }378 379 - (void)setAnimationProgress:(float)progress380 {381 if (_hasCompletedAnimation)382 return;383 384 if (progress == 1) {385 _hasCompletedAnimation = true;386 387 for (CALayer *bounceLayer in _bounceLayers.get()) {388 // Continue the animation from wherever it had manually progressed to.389 CFTimeInterval beginTime = bounceLayer.timeOffset;390 bounceLayer.speed = 1;391 beginTime = [bounceLayer convertTime:CACurrentMediaTime() fromLayer:nil] - beginTime;392 bounceLayer.beginTime = beginTime;393 }394 } else {395 CFTimeInterval animationDuration = [self _animationDuration];396 for (CALayer *bounceLayer in _bounceLayers.get())397 bounceLayer.timeOffset = progress * animationDuration;398 }399 }400 401 - (BOOL)isFlipped402 {403 return YES;404 }405 406 @end407 48 408 49 namespace WebCore { … … 424 65 return; 425 66 426 [m_textIndicator ViewsetAnimationProgress:progress];67 [m_textIndicatorLayer setAnimationProgress:progress]; 427 68 } 428 69 … … 431 72 RefPtr<TextIndicator> textIndicator = WTFMove(m_textIndicator); 432 73 433 if ([m_textIndicator ViewisFadingOut])74 if ([m_textIndicatorLayer isFadingOut]) 434 75 return; 435 76 436 if (textIndicator && indicatorWantsManualAnimation(*textIndicator) && [m_textIndicatorViewhasCompletedAnimation] && animation == TextIndicatorWindowDismissalAnimation::FadeOut) {77 if (textIndicator && [m_textIndicatorLayer indicatorWantsManualAnimation:*textIndicator] && [m_textIndicatorLayer hasCompletedAnimation] && animation == TextIndicatorWindowDismissalAnimation::FadeOut) { 437 78 startFadeOut(); 438 79 return; … … 454 95 CGFloat verticalMargin = dropShadowBlurRadius * 2 + TextIndicator::defaultVerticalMargin; 455 96 456 if ( indicatorWantsBounce(*m_textIndicator)) {97 if ([m_textIndicatorLayer indicatorWantsBounce:*m_textIndicator]) { 457 98 horizontalMargin = std::max(horizontalMargin, textBoundingRectInScreenCoordinates.size.width * (midBounceScale - 1) + horizontalMargin); 458 99 verticalMargin = std::max(verticalMargin, textBoundingRectInScreenCoordinates.size.height * (midBounceScale - 1) + verticalMargin); … … 471 112 [m_textIndicatorWindow setIgnoresMouseEvents:YES]; 472 113 473 m_textIndicatorView = adoptNS([[WebTextIndicatorView alloc] initWithFrame:NSMakeRect(0, 0, [m_textIndicatorWindow frame].size.width, [m_textIndicatorWindow frame].size.height) 114 NSRect frame = NSMakeRect(0, 0, [m_textIndicatorWindow frame].size.width, [m_textIndicatorWindow frame].size.height); 115 m_textIndicatorLayer = adoptNS([[WebTextIndicatorLayer alloc] initWithFrame:frame 474 116 textIndicator:*m_textIndicator margin:NSMakeSize(horizontalMargin, verticalMargin) offset:fractionalTextOffset]); 117 m_textIndicatorView = adoptNS([[NSView alloc] initWithFrame:frame]); 118 [m_textIndicatorView setLayer:m_textIndicatorLayer.get()]; 119 [m_textIndicatorView setWantsLayer:YES]; 475 120 [m_textIndicatorWindow setContentView:m_textIndicatorView.get()]; 476 121 … … 479 124 480 125 if (m_textIndicator->presentationTransition() != TextIndicatorPresentationTransition::None) 481 [m_textIndicator Viewpresent];126 [m_textIndicatorLayer present]; 482 127 483 128 if (lifetime == TextIndicatorWindowLifetime::Temporary) … … 490 135 return; 491 136 492 if ([m_textIndicator ViewisFadingOut])137 if ([m_textIndicatorLayer isFadingOut]) 493 138 return; 494 139 … … 502 147 void TextIndicatorWindow::startFadeOut() 503 148 { 504 [m_textIndicator ViewsetFadingOut:YES];149 [m_textIndicatorLayer setFadingOut:YES]; 505 150 RetainPtr<NSWindow> indicatorWindow = m_textIndicatorWindow; 506 [m_textIndicator ViewhideWithCompletionHandler:[indicatorWindow] {151 [m_textIndicatorLayer hideWithCompletionHandler:[indicatorWindow] { 507 152 [[indicatorWindow parentWindow] removeChildWindow:indicatorWindow.get()]; 508 153 [indicatorWindow close]; -
branches/safari-612.1.12-branch/WebKit.xcworkspace/xcshareddata/xcschemes/All Source.xcscheme
r264234 r277469 128 128 BuildableIdentifier = "primary" 129 129 BlueprintIdentifier = "1A50DB38110A3C13000D3FE5" 130 BuildableName = " All"131 BlueprintName = " All"130 BuildableName = "Framework & XPC Services" 131 BlueprintName = "Framework & XPC Services" 132 132 ReferencedContainer = "container:Source/WebKit/WebKit.xcodeproj"> 133 133 </BuildableReference>
Note:
See TracChangeset
for help on using the changeset viewer.