Diff
Modified: trunk/Source/WebCore/ChangeLog (277329 => 277330)
--- trunk/Source/WebCore/ChangeLog 2021-05-11 17:45:56 UTC (rev 277329)
+++ trunk/Source/WebCore/ChangeLog 2021-05-11 17:46:40 UTC (rev 277330)
@@ -1,3 +1,40 @@
+2021-05-11 Megan Gardner <[email protected]>
+
+ Factor out find bounce layer
+ https://bugs.webkit.org/show_bug.cgi?id=225557
+
+ Reviewed by Tim Horton.
+
+ Factor out the text indicator bounce layer in preparation of making this
+ compatable with iOS.
+
+ No behavior change.
+
+ * SourcesCocoa.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * page/mac/TextIndicatorWindow.h:
+ * page/mac/TextIndicatorWindow.mm:
+ (WebCore::TextIndicatorWindow::setAnimationProgress):
+ (WebCore::TextIndicatorWindow::clearTextIndicator):
+ (WebCore::TextIndicatorWindow::setTextIndicator):
+ (WebCore::TextIndicatorWindow::closeWindow):
+ (WebCore::TextIndicatorWindow::startFadeOut):
+ (indicatorWantsBounce): Deleted.
+ (indicatorWantsContentCrossfade): Deleted.
+ (indicatorWantsFadeIn): Deleted.
+ (indicatorWantsManualAnimation): Deleted.
+ (-[WebTextIndicatorView initWithFrame:textIndicator:margin:offset:]): Deleted.
+ (createBounceAnimation): Deleted.
+ (createContentCrossfadeAnimation): Deleted.
+ (createShadowFadeAnimation): Deleted.
+ (createFadeInAnimation): Deleted.
+ (-[WebTextIndicatorView _animationDuration]): Deleted.
+ (-[WebTextIndicatorView hasCompletedAnimation]): Deleted.
+ (-[WebTextIndicatorView present]): Deleted.
+ (-[WebTextIndicatorView hideWithCompletionHandler:]): Deleted.
+ (-[WebTextIndicatorView setAnimationProgress:]): Deleted.
+ (-[WebTextIndicatorView isFlipped]): Deleted.
+
2021-05-11 Antti Koivisto <[email protected]>
Don't allow :visited link style in subtrees that use mix-blend-mode
Modified: trunk/Source/WebCore/SourcesCocoa.txt (277329 => 277330)
--- trunk/Source/WebCore/SourcesCocoa.txt 2021-05-11 17:45:56 UTC (rev 277329)
+++ trunk/Source/WebCore/SourcesCocoa.txt 2021-05-11 17:46:40 UTC (rev 277330)
@@ -182,6 +182,7 @@
page/cocoa/ResourceUsageOverlayCocoa.mm
page/cocoa/ResourceUsageThreadCocoa.mm
page/cocoa/SettingsBaseCocoa.mm
+page/cocoa/WebTextIndicatorLayer.mm
page/ios/ContentChangeObserver.cpp
page/ios/DOMTimerHoldingTank.cpp
page/ios/EventHandlerIOS.mm
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (277329 => 277330)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-05-11 17:45:56 UTC (rev 277329)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2021-05-11 17:46:40 UTC (rev 277330)
@@ -1271,6 +1271,7 @@
44AE045C2579CFFB00C42E65 /* AppHighlightRangeData.h in Headers */ = {isa = PBXBuildFile; fileRef = 44AE045A2579CFFB00C42E65 /* AppHighlightRangeData.h */; settings = {ATTRIBUTES = (Private, ); }; };
44C991860F3D1EBE00586670 /* ScrollbarThemeIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 44C991850F3D1EBE00586670 /* ScrollbarThemeIOS.h */; };
44C9919F0F3D210E00586670 /* ThemeIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 44C9919D0F3D210E00586670 /* ThemeIOS.h */; };
+ 44CE2BBF264379AF007AE110 /* WebTextIndicatorLayer.h in Headers */ = {isa = PBXBuildFile; fileRef = 44CE2BBE2643799E007AE110 /* WebTextIndicatorLayer.h */; settings = {ATTRIBUTES = (Private, ); }; };
44E349F9246F4E190068479C /* LibWebRTCEnumTraits.h in Headers */ = {isa = PBXBuildFile; fileRef = 44E349F7246F4DC70068479C /* LibWebRTCEnumTraits.h */; settings = {ATTRIBUTES = (Private, ); }; };
450CEBF115073BBE002BB149 /* LabelableElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 450CEBEF15073BBE002BB149 /* LabelableElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
4512502315DCE37D002F84E2 /* SpinButtonElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 4512502115DCE37D002F84E2 /* SpinButtonElement.h */; };
@@ -8257,6 +8258,8 @@
44C9919D0F3D210E00586670 /* ThemeIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThemeIOS.h; sourceTree = "<group>"; };
44C9919E0F3D210E00586670 /* ThemeIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ThemeIOS.mm; sourceTree = "<group>"; };
44CA2843245FCA5000C94C7F /* LocalCurrentGraphicsContextIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalCurrentGraphicsContextIOS.mm; sourceTree = "<group>"; };
+ 44CE2BBC2643799D007AE110 /* WebTextIndicatorLayer.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebTextIndicatorLayer.mm; sourceTree = "<group>"; };
+ 44CE2BBE2643799E007AE110 /* WebTextIndicatorLayer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebTextIndicatorLayer.h; sourceTree = "<group>"; };
44D8DA98139545BE00337B75 /* SVGMPathElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SVGMPathElement.idl; sourceTree = "<group>"; };
44D8DA9A139545CD00337B75 /* SVGAnimateMotionElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SVGAnimateMotionElement.idl; sourceTree = "<group>"; };
44E349F7246F4DC70068479C /* LibWebRTCEnumTraits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LibWebRTCEnumTraits.h; path = libwebrtc/LibWebRTCEnumTraits.h; sourceTree = "<group>"; };
@@ -21843,6 +21846,8 @@
ADFE2B541BD5F41200DAB457 /* ResourceUsageOverlayCocoa.mm */,
A5071E881C56D4FA009951BE /* ResourceUsageThreadCocoa.mm */,
A182D5B61BE722620087A7CC /* SettingsBaseCocoa.mm */,
+ 44CE2BBE2643799E007AE110 /* WebTextIndicatorLayer.h */,
+ 44CE2BBC2643799D007AE110 /* WebTextIndicatorLayer.mm */,
);
path = cocoa;
sourceTree = "<group>";
@@ -35810,6 +35815,7 @@
93B38EC425821DB700198E63 /* WebSpeechRecognizerTaskMock.h in Headers */,
1F8756B21E22C3350042C40D /* WebSQLiteDatabaseTrackerClient.h in Headers */,
31DEA4561B39F4D900F77178 /* WebSystemBackdropLayer.h in Headers */,
+ 44CE2BBF264379AF007AE110 /* WebTextIndicatorLayer.h in Headers */,
0F580FA31496939100FB5BD8 /* WebTiledBackingLayer.h in Headers */,
1DAB3112251D6BF300FC9485 /* WebVideoContainerLayer.h in Headers */,
3F42B31D1881191B00278AAC /* WebVideoFullscreenControllerAVKit.h in Headers */,
Copied: trunk/Source/WebCore/page/cocoa/WebTextIndicatorLayer.h (from rev 277329, trunk/Source/WebCore/page/mac/TextIndicatorWindow.h) (0 => 277330)
--- trunk/Source/WebCore/page/cocoa/WebTextIndicatorLayer.h (rev 0)
+++ trunk/Source/WebCore/page/cocoa/WebTextIndicatorLayer.h 2021-05-11 17:46:40 UTC (rev 277330)
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#import "TextIndicator.h"
+#import <wtf/Noncopyable.h>
+#import <wtf/RefPtr.h>
+#import <wtf/RetainPtr.h>
+#import <wtf/RunLoop.h>
+
+@interface WebTextIndicatorLayer : CALayer {
+ RefPtr<WebCore::TextIndicator> _textIndicator;
+ RetainPtr<NSArray> _bounceLayers;
+ CGSize _margin;
+ bool _hasCompletedAnimation;
+ BOOL _fadingOut;
+}
+
+- (instancetype)initWithFrame:(CGRect)frame textIndicator:(WebCore::TextIndicator&)textIndicator margin:(CGSize)margin offset:(CGPoint)offset;
+
+- (bool)indicatorWantsManualAnimation:(const WebCore::TextIndicator&)indicator;
+- (bool)indicatorWantsBounce:(const WebCore::TextIndicator&)indicator;
+
+- (void)present;
+- (void)hideWithCompletionHandler:(void(^)(void))completionHandler;
+
+- (void)setAnimationProgress:(float)progress;
+- (BOOL)hasCompletedAnimation;
+
+@property (nonatomic, getter=isFadingOut) BOOL fadingOut;
+
+@end
Copied: trunk/Source/WebCore/page/cocoa/WebTextIndicatorLayer.mm (from rev 277329, trunk/Source/WebCore/page/mac/TextIndicatorWindow.mm) (0 => 277330)
--- trunk/Source/WebCore/page/cocoa/WebTextIndicatorLayer.mm (rev 0)
+++ trunk/Source/WebCore/page/cocoa/WebTextIndicatorLayer.mm 2021-05-11 17:46:40 UTC (rev 277330)
@@ -0,0 +1,392 @@
+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "WebTextIndicatorLayer.h"
+
+#import "GeometryUtilities.h"
+#import "GraphicsContext.h"
+#import "PathUtilities.h"
+#import "TextIndicator.h"
+#import "WebActionDisablingCALayerDelegate.h"
+#import <pal/spi/cg/CoreGraphicsSPI.h>
+#import <pal/spi/cocoa/QuartzCoreSPI.h>
+
+#if PLATFORM(MAC)
+#import <pal/spi/cocoa/NSColorSPI.h>
+#endif
+
+constexpr CFTimeInterval bounceAnimationDuration = 0.12;
+constexpr CFTimeInterval bounceWithCrossfadeAnimationDuration = 0.3;
+constexpr CFTimeInterval fadeInAnimationDuration = 0.15;
+constexpr CFTimeInterval timeBeforeFadeStarts = bounceAnimationDuration + 0.2;
+constexpr CFTimeInterval fadeOutAnimationDuration = 0.3;
+
+constexpr CGFloat midBounceScale = 1.25;
+constexpr CGFloat borderWidth = 0;
+constexpr CGFloat cornerRadius = 0;
+constexpr CGFloat dropShadowOffsetX = 0;
+constexpr CGFloat dropShadowOffsetY = 1;
+constexpr CGFloat dropShadowBlurRadius = 2;
+constexpr CGFloat rimShadowBlurRadius = 1;
+
+constexpr NSString * const textLayerKey = @"TextLayer";
+constexpr NSString * const dropShadowLayerKey = @"DropShadowLayer";
+constexpr NSString * const rimShadowLayerKey = @"RimShadowLayer";
+
+@implementation WebTextIndicatorLayer
+
+@synthesize fadingOut = _fadingOut;
+
+static bool indicatorWantsContentCrossfade(const WebCore::TextIndicator& indicator)
+{
+ if (!indicator.data().contentImageWithHighlight)
+ return false;
+
+ switch (indicator.presentationTransition()) {
+ case WebCore::TextIndicatorPresentationTransition::BounceAndCrossfade:
+ return true;
+
+ case WebCore::TextIndicatorPresentationTransition::Bounce:
+ case WebCore::TextIndicatorPresentationTransition::FadeIn:
+ case WebCore::TextIndicatorPresentationTransition::None:
+ return false;
+ }
+
+ ASSERT_NOT_REACHED();
+ return false;
+}
+
+static bool indicatorWantsFadeIn(const WebCore::TextIndicator& indicator)
+{
+ switch (indicator.presentationTransition()) {
+ case WebCore::TextIndicatorPresentationTransition::FadeIn:
+ return true;
+
+ case WebCore::TextIndicatorPresentationTransition::Bounce:
+ case WebCore::TextIndicatorPresentationTransition::BounceAndCrossfade:
+ case WebCore::TextIndicatorPresentationTransition::None:
+ return false;
+ }
+
+ ASSERT_NOT_REACHED();
+ return false;
+}
+
+- (bool)indicatorWantsBounce:(const WebCore::TextIndicator&)indicator
+{
+ switch (indicator.presentationTransition()) {
+ case WebCore::TextIndicatorPresentationTransition::BounceAndCrossfade:
+ case WebCore::TextIndicatorPresentationTransition::Bounce:
+ return true;
+
+ case WebCore::TextIndicatorPresentationTransition::FadeIn:
+ case WebCore::TextIndicatorPresentationTransition::None:
+ return false;
+ }
+
+ ASSERT_NOT_REACHED();
+ return false;
+}
+
+- (bool)indicatorWantsManualAnimation:(const WebCore::TextIndicator&)indicator
+{
+ switch (indicator.presentationTransition()) {
+ case WebCore::TextIndicatorPresentationTransition::FadeIn:
+ return true;
+
+ case WebCore::TextIndicatorPresentationTransition::Bounce:
+ case WebCore::TextIndicatorPresentationTransition::BounceAndCrossfade:
+ case WebCore::TextIndicatorPresentationTransition::None:
+ return false;
+ }
+
+ ASSERT_NOT_REACHED();
+ return false;
+}
+
+- (instancetype)initWithFrame:(CGRect)frame textIndicator:(WebCore::TextIndicator&)textIndicator margin:(CGSize)margin offset:(CGPoint)offset
+{
+ if (!(self = [super init]))
+ return nil;
+
+ self.frame = frame;
+
+ _textIndicator = &textIndicator;
+ _margin = margin;
+
+ self.anchorPoint = CGPointZero;
+
+ RefPtr<WebCore::NativeImage> contentsImage;
+ WebCore::FloatSize contentsImageLogicalSize { 1, 1 };
+ if (auto* contentImage = _textIndicator->contentImage()) {
+ contentsImageLogicalSize = contentImage->size();
+ contentsImageLogicalSize.scale(1 / _textIndicator->contentImageScaleFactor());
+ if (indicatorWantsContentCrossfade(*_textIndicator) && _textIndicator->contentImageWithHighlight())
+ contentsImage = _textIndicator->contentImageWithHighlight()->nativeImage();
+ else
+ contentsImage = contentImage->nativeImage();
+ }
+
+ auto bounceLayers = adoptNS([[NSMutableArray alloc] init]);
+
+ RetainPtr<CGColorRef> highlightColor;
+ auto rimShadowColor = adoptCF(CGColorCreateGenericGray(0, 0.35));
+ auto dropShadowColor = adoptCF(CGColorCreateGenericGray(0, 0.2));
+ auto borderColor = adoptCF(CGColorCreateSRGB(0.96, 0.9, 0, 1));
+#if PLATFORM(MAC)
+ highlightColor = [NSColor findHighlightColor].CGColor;
+#else
+ highlightColor = adoptCF(CGColorCreateSRGB(.99, .89, 0.22, 1.0));
+#endif
+
+ auto textRectsInBoundingRectCoordinates = _textIndicator->textRectsInBoundingRectCoordinates();
+
+ auto paths = WebCore::PathUtilities::pathsWithShrinkWrappedRects(textRectsInBoundingRectCoordinates, cornerRadius);
+
+ for (const auto& path : paths) {
+ WebCore::FloatRect pathBoundingRect = path.boundingRect();
+
+ WebCore::Path translatedPath;
+ WebCore::AffineTransform transform;
+ transform.translate(-pathBoundingRect.location());
+ translatedPath.addPath(path, transform);
+
+ WebCore::FloatRect offsetTextRect = pathBoundingRect;
+ offsetTextRect.move(offset.x, offset.y);
+
+ WebCore::FloatRect bounceLayerRect = offsetTextRect;
+ bounceLayerRect.move(_margin.width, _margin.height);
+
+ RetainPtr<CALayer> bounceLayer = adoptNS([[CALayer alloc] init]);
+ [bounceLayer setDelegate:[WebActionDisablingCALayerDelegate shared]];
+ [bounceLayer setFrame:bounceLayerRect];
+ [bounceLayer setOpacity:0];
+ [bounceLayers addObject:bounceLayer.get()];
+
+ WebCore::FloatRect yellowHighlightRect(WebCore::FloatPoint(), bounceLayerRect.size());
+
+#if PLATFORM(MAC)
+ RetainPtr<CALayer> dropShadowLayer = adoptNS([[CALayer alloc] init]);
+ [dropShadowLayer setDelegate:[WebActionDisablingCALayerDelegate shared]];
+ [dropShadowLayer setShadowColor:dropShadowColor.get()];
+ [dropShadowLayer setShadowRadius:dropShadowBlurRadius];
+ [dropShadowLayer setShadowOffset:CGSizeMake(dropShadowOffsetX, dropShadowOffsetY)];
+ [dropShadowLayer setShadowPath:translatedPath.platformPath()];
+ [dropShadowLayer setShadowOpacity:1];
+ [dropShadowLayer setFrame:yellowHighlightRect];
+ [bounceLayer addSublayer:dropShadowLayer.get()];
+ [bounceLayer setValue:dropShadowLayer.get() forKey:dropShadowLayerKey];
+
+ RetainPtr<CALayer> rimShadowLayer = adoptNS([[CALayer alloc] init]);
+ [rimShadowLayer setDelegate:[WebActionDisablingCALayerDelegate shared]];
+ [rimShadowLayer setFrame:yellowHighlightRect];
+ [rimShadowLayer setShadowColor:rimShadowColor.get()];
+ [rimShadowLayer setShadowRadius:rimShadowBlurRadius];
+ [rimShadowLayer setShadowPath:translatedPath.platformPath()];
+ [rimShadowLayer setShadowOffset:CGSizeZero];
+ [rimShadowLayer setShadowOpacity:1];
+ [rimShadowLayer setFrame:yellowHighlightRect];
+ [bounceLayer addSublayer:rimShadowLayer.get()];
+ [bounceLayer setValue:rimShadowLayer.get() forKey:rimShadowLayerKey];
+#endif // PLATFORM(MAC)
+
+ RetainPtr<CALayer> textLayer = adoptNS([[CALayer alloc] init]);
+ [textLayer setBackgroundColor:highlightColor.get()];
+ [textLayer setBorderColor:borderColor.get()];
+ [textLayer setBorderWidth:borderWidth];
+ [textLayer setDelegate:[WebActionDisablingCALayerDelegate shared]];
+ if (contentsImage)
+ [textLayer setContents:(__bridge id)contentsImage->platformImage().get()];
+
+ RetainPtr<CAShapeLayer> maskLayer = adoptNS([[CAShapeLayer alloc] init]);
+ [maskLayer setPath:translatedPath.platformPath()];
+ [textLayer setMask:maskLayer.get()];
+
+ WebCore::FloatRect imageRect = pathBoundingRect;
+ [textLayer setContentsRect:CGRectMake(imageRect.x() / contentsImageLogicalSize.width(), imageRect.y() / contentsImageLogicalSize.height(), imageRect.width() / contentsImageLogicalSize.width(), imageRect.height() / contentsImageLogicalSize.height())];
+ [textLayer setContentsGravity:kCAGravityCenter];
+ [textLayer setContentsScale:_textIndicator->contentImageScaleFactor()];
+ [textLayer setFrame:yellowHighlightRect];
+ [bounceLayer setValue:textLayer.get() forKey:textLayerKey];
+ [bounceLayer addSublayer:textLayer.get()];
+ }
+
+ self.sublayers = bounceLayers.get();
+ _bounceLayers = bounceLayers;
+
+ return self;
+}
+
+static RetainPtr<CAKeyframeAnimation> createBounceAnimation(CFTimeInterval duration)
+{
+ RetainPtr<CAKeyframeAnimation> bounceAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
+ [bounceAnimation setValues:@[
+ [NSValue valueWithCATransform3D:CATransform3DIdentity],
+ [NSValue valueWithCATransform3D:CATransform3DMakeScale(midBounceScale, midBounceScale, 1)],
+ [NSValue valueWithCATransform3D:CATransform3DIdentity]
+ ]];
+ [bounceAnimation setDuration:duration];
+
+ return bounceAnimation;
+}
+
+static RetainPtr<CABasicAnimation> createContentCrossfadeAnimation(CFTimeInterval duration, WebCore::TextIndicator& textIndicator)
+{
+ RetainPtr<CABasicAnimation> crossfadeAnimation = [CABasicAnimation animationWithKeyPath:@"contents"];
+ auto contentsImage = textIndicator.contentImage()->nativeImage();
+ [crossfadeAnimation setToValue:(__bridge id)contentsImage->platformImage().get()];
+ [crossfadeAnimation setFillMode:kCAFillModeForwards];
+ [crossfadeAnimation setRemovedOnCompletion:NO];
+ [crossfadeAnimation setDuration:duration];
+
+ return crossfadeAnimation;
+}
+
+static RetainPtr<CABasicAnimation> createShadowFadeAnimation(CFTimeInterval duration)
+{
+ RetainPtr<CABasicAnimation> fadeShadowInAnimation = [CABasicAnimation animationWithKeyPath:@"shadowOpacity"];
+ [fadeShadowInAnimation setFromValue:@0];
+ [fadeShadowInAnimation setToValue:@1];
+ [fadeShadowInAnimation setFillMode:kCAFillModeForwards];
+ [fadeShadowInAnimation setRemovedOnCompletion:NO];
+ [fadeShadowInAnimation setDuration:duration];
+
+ return fadeShadowInAnimation;
+}
+
+static RetainPtr<CABasicAnimation> createFadeInAnimation(CFTimeInterval duration)
+{
+ RetainPtr<CABasicAnimation> fadeInAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
+ [fadeInAnimation setFromValue:@0];
+ [fadeInAnimation setToValue:@1];
+ [fadeInAnimation setFillMode:kCAFillModeForwards];
+ [fadeInAnimation setRemovedOnCompletion:NO];
+ [fadeInAnimation setDuration:duration];
+
+ return fadeInAnimation;
+}
+
+- (CFTimeInterval)_animationDuration
+{
+ if ([self indicatorWantsBounce:*_textIndicator]) {
+ if (indicatorWantsContentCrossfade(*_textIndicator))
+ return bounceWithCrossfadeAnimationDuration;
+ return bounceAnimationDuration;
+ }
+
+ return fadeInAnimationDuration;
+}
+
+- (BOOL)hasCompletedAnimation
+{
+ return _hasCompletedAnimation;
+}
+
+- (void)present
+{
+ bool wantsBounce = [self indicatorWantsBounce:*_textIndicator];
+ bool wantsCrossfade = indicatorWantsContentCrossfade(*_textIndicator);
+ bool wantsFadeIn = indicatorWantsFadeIn(*_textIndicator);
+ CFTimeInterval animationDuration = [self _animationDuration];
+
+ _hasCompletedAnimation = false;
+
+ RetainPtr<CAAnimation> presentationAnimation;
+ if (wantsBounce)
+ presentationAnimation = createBounceAnimation(animationDuration);
+ else if (wantsFadeIn)
+ presentationAnimation = createFadeInAnimation(animationDuration);
+
+ RetainPtr<CABasicAnimation> crossfadeAnimation;
+ RetainPtr<CABasicAnimation> fadeShadowInAnimation;
+ if (wantsCrossfade) {
+ crossfadeAnimation = createContentCrossfadeAnimation(animationDuration, *_textIndicator);
+ fadeShadowInAnimation = createShadowFadeAnimation(animationDuration);
+ }
+
+ [CATransaction begin];
+ for (CALayer *bounceLayer in _bounceLayers.get()) {
+ if ([self indicatorWantsManualAnimation:*_textIndicator])
+ bounceLayer.speed = 0;
+
+ if (!wantsFadeIn)
+ bounceLayer.opacity = 1;
+
+ if (presentationAnimation)
+ [bounceLayer addAnimation:presentationAnimation.get() forKey:@"presentation"];
+
+ if (wantsCrossfade) {
+ [[bounceLayer valueForKey:textLayerKey] addAnimation:crossfadeAnimation.get() forKey:@"contentTransition"];
+ [[bounceLayer valueForKey:dropShadowLayerKey] addAnimation:fadeShadowInAnimation.get() forKey:@"fadeShadowIn"];
+ [[bounceLayer valueForKey:rimShadowLayerKey] addAnimation:fadeShadowInAnimation.get() forKey:@"fadeShadowIn"];
+ }
+ }
+ [CATransaction commit];
+}
+
+- (void)hideWithCompletionHandler:(void(^)(void))completionHandler
+{
+ RetainPtr<CABasicAnimation> fadeAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
+ [fadeAnimation setFromValue:@1];
+ [fadeAnimation setToValue:@0];
+ [fadeAnimation setFillMode:kCAFillModeForwards];
+ [fadeAnimation setRemovedOnCompletion:NO];
+ [fadeAnimation setDuration:fadeOutAnimationDuration];
+
+ [CATransaction begin];
+ [CATransaction setCompletionBlock:completionHandler];
+ [self addAnimation:fadeAnimation.get() forKey:@"fadeOut"];
+ [CATransaction commit];
+}
+
+- (void)setAnimationProgress:(float)progress
+{
+ if (_hasCompletedAnimation)
+ return;
+
+ if (progress == 1) {
+ _hasCompletedAnimation = true;
+
+ for (CALayer *bounceLayer in _bounceLayers.get()) {
+ // Continue the animation from wherever it had manually progressed to.
+ CFTimeInterval beginTime = bounceLayer.timeOffset;
+ bounceLayer.speed = 1;
+ beginTime = [bounceLayer convertTime:CACurrentMediaTime() fromLayer:nil] - beginTime;
+ bounceLayer.beginTime = beginTime;
+ }
+ } else {
+ CFTimeInterval animationDuration = [self _animationDuration];
+ for (CALayer *bounceLayer in _bounceLayers.get())
+ bounceLayer.timeOffset = progress * animationDuration;
+ }
+}
+
+- (BOOL)isFlipped
+{
+ return YES;
+}
+
+@end
Modified: trunk/Source/WebCore/page/mac/TextIndicatorWindow.h (277329 => 277330)
--- trunk/Source/WebCore/page/mac/TextIndicatorWindow.h 2021-05-11 17:45:56 UTC (rev 277329)
+++ trunk/Source/WebCore/page/mac/TextIndicatorWindow.h 2021-05-11 17:46:40 UTC (rev 277330)
@@ -32,7 +32,7 @@
#import <wtf/RunLoop.h>
OBJC_CLASS NSView;
-OBJC_CLASS WebTextIndicatorView;
+OBJC_CLASS WebTextIndicatorLayer;
namespace WebCore {
@@ -72,7 +72,8 @@
NSView *m_targetView;
RefPtr<TextIndicator> m_textIndicator;
RetainPtr<NSWindow> m_textIndicatorWindow;
- RetainPtr<WebTextIndicatorView> m_textIndicatorView;
+ RetainPtr<NSView> m_textIndicatorView;
+ RetainPtr<WebTextIndicatorLayer> m_textIndicatorLayer;
RunLoop::Timer<TextIndicatorWindow> m_temporaryTextIndicatorTimer;
};
Modified: trunk/Source/WebCore/page/mac/TextIndicatorWindow.mm (277329 => 277330)
--- trunk/Source/WebCore/page/mac/TextIndicatorWindow.mm 2021-05-11 17:45:56 UTC (rev 277329)
+++ trunk/Source/WebCore/page/mac/TextIndicatorWindow.mm 2021-05-11 17:46:40 UTC (rev 277330)
@@ -33,378 +33,19 @@
#import "PathUtilities.h"
#import "TextIndicator.h"
#import "WebActionDisablingCALayerDelegate.h"
+#import "WebTextIndicatorLayer.h"
#import <pal/spi/cg/CoreGraphicsSPI.h>
#import <pal/spi/cocoa/NSColorSPI.h>
#import <pal/spi/cocoa/QuartzCoreSPI.h>
const CFTimeInterval bounceAnimationDuration = 0.12;
-const CFTimeInterval bounceWithCrossfadeAnimationDuration = 0.3;
-const CFTimeInterval fadeInAnimationDuration = 0.15;
const CFTimeInterval timeBeforeFadeStarts = bounceAnimationDuration + 0.2;
-const CFTimeInterval fadeOutAnimationDuration = 0.3;
const CGFloat midBounceScale = 1.25;
-const CGFloat borderWidth = 0;
-const CGFloat cornerRadius = 0;
-const CGFloat dropShadowOffsetX = 0;
-const CGFloat dropShadowOffsetY = 1;
const CGFloat dropShadowBlurRadius = 2;
-const CGFloat rimShadowBlurRadius = 1;
-NSString *textLayerKey = @"TextLayer";
-NSString *dropShadowLayerKey = @"DropShadowLayer";
-NSString *rimShadowLayerKey = @"RimShadowLayer";
-
using namespace WebCore;
-@interface WebTextIndicatorView : NSView {
- RefPtr<TextIndicator> _textIndicator;
- RetainPtr<NSArray> _bounceLayers;
- NSSize _margin;
- bool _hasCompletedAnimation;
- BOOL _fadingOut;
-}
-
-- (instancetype)initWithFrame:(NSRect)frame textIndicator:(TextIndicator&)textIndicator margin:(NSSize)margin offset:(NSPoint)offset;
-
-- (void)present;
-- (void)hideWithCompletionHandler:(void(^)(void))completionHandler;
-
-- (void)setAnimationProgress:(float)progress;
-- (BOOL)hasCompletedAnimation;
-
-@property (nonatomic, getter=isFadingOut) BOOL fadingOut;
-
-@end
-
-@implementation WebTextIndicatorView
-
-@synthesize fadingOut = _fadingOut;
-
-static bool indicatorWantsBounce(const TextIndicator& indicator)
-{
- switch (indicator.presentationTransition()) {
- case TextIndicatorPresentationTransition::BounceAndCrossfade:
- case TextIndicatorPresentationTransition::Bounce:
- return true;
-
- case TextIndicatorPresentationTransition::FadeIn:
- case TextIndicatorPresentationTransition::None:
- return false;
- }
-
- ASSERT_NOT_REACHED();
- return false;
-}
-
-static bool indicatorWantsContentCrossfade(const TextIndicator& indicator)
-{
- if (!indicator.data().contentImageWithHighlight)
- return false;
-
- switch (indicator.presentationTransition()) {
- case TextIndicatorPresentationTransition::BounceAndCrossfade:
- return true;
-
- case TextIndicatorPresentationTransition::Bounce:
- case TextIndicatorPresentationTransition::FadeIn:
- case TextIndicatorPresentationTransition::None:
- return false;
- }
-
- ASSERT_NOT_REACHED();
- return false;
-}
-
-static bool indicatorWantsFadeIn(const TextIndicator& indicator)
-{
- switch (indicator.presentationTransition()) {
- case TextIndicatorPresentationTransition::FadeIn:
- return true;
-
- case TextIndicatorPresentationTransition::Bounce:
- case TextIndicatorPresentationTransition::BounceAndCrossfade:
- case TextIndicatorPresentationTransition::None:
- return false;
- }
-
- ASSERT_NOT_REACHED();
- return false;
-}
-
-static bool indicatorWantsManualAnimation(const TextIndicator& indicator)
-{
- switch (indicator.presentationTransition()) {
- case TextIndicatorPresentationTransition::FadeIn:
- return true;
-
- case TextIndicatorPresentationTransition::Bounce:
- case TextIndicatorPresentationTransition::BounceAndCrossfade:
- case TextIndicatorPresentationTransition::None:
- return false;
- }
-
- ASSERT_NOT_REACHED();
- return false;
-}
-
-- (instancetype)initWithFrame:(NSRect)frame textIndicator:(TextIndicator&)textIndicator margin:(NSSize)margin offset:(NSPoint)offset
-{
- if (!(self = [super initWithFrame:frame]))
- return nil;
-
- _textIndicator = &textIndicator;
- _margin = margin;
-
- self.wantsLayer = YES;
- self.layer.anchorPoint = CGPointZero;
-
- RefPtr<NativeImage> contentsImage;
- FloatSize contentsImageLogicalSize { 1, 1 };
- if (auto* contentImage = _textIndicator->contentImage()) {
- contentsImageLogicalSize = contentImage->size();
- contentsImageLogicalSize.scale(1 / _textIndicator->contentImageScaleFactor());
- if (indicatorWantsContentCrossfade(*_textIndicator) && _textIndicator->contentImageWithHighlight())
- contentsImage = _textIndicator->contentImageWithHighlight()->nativeImage();
- else
- contentsImage = contentImage->nativeImage();
- }
-
- RetainPtr<NSMutableArray> bounceLayers = adoptNS([[NSMutableArray alloc] init]);
-
- RetainPtr<CGColorRef> highlightColor = [NSColor findHighlightColor].CGColor;
- RetainPtr<CGColorRef> rimShadowColor = [NSColor colorWithDeviceWhite:0 alpha:0.35].CGColor;
- RetainPtr<CGColorRef> dropShadowColor = [NSColor colorWithDeviceWhite:0 alpha:0.2].CGColor;
-
- RetainPtr<CGColorRef> borderColor = [NSColor colorWithDeviceRed:.96 green:.90 blue:0 alpha:1].CGColor;
-
- Vector<FloatRect> textRectsInBoundingRectCoordinates = _textIndicator->textRectsInBoundingRectCoordinates();
-
- Vector<Path> paths = PathUtilities::pathsWithShrinkWrappedRects(textRectsInBoundingRectCoordinates, cornerRadius);
-
- for (const auto& path : paths) {
- FloatRect pathBoundingRect = path.boundingRect();
-
- Path translatedPath;
- AffineTransform transform;
- transform.translate(-pathBoundingRect.location());
- translatedPath.addPath(path, transform);
-
- FloatRect offsetTextRect = pathBoundingRect;
- offsetTextRect.move(offset.x, offset.y);
-
- FloatRect bounceLayerRect = offsetTextRect;
- bounceLayerRect.move(_margin.width, _margin.height);
-
- RetainPtr<CALayer> bounceLayer = adoptNS([[CALayer alloc] init]);
- [bounceLayer setDelegate:[WebActionDisablingCALayerDelegate shared]];
- [bounceLayer setFrame:bounceLayerRect];
- [bounceLayer setOpacity:0];
- [bounceLayers addObject:bounceLayer.get()];
-
- FloatRect yellowHighlightRect(FloatPoint(), bounceLayerRect.size());
-
- RetainPtr<CALayer> dropShadowLayer = adoptNS([[CALayer alloc] init]);
- [dropShadowLayer setDelegate:[WebActionDisablingCALayerDelegate shared]];
- [dropShadowLayer setShadowColor:dropShadowColor.get()];
- [dropShadowLayer setShadowRadius:dropShadowBlurRadius];
- [dropShadowLayer setShadowOffset:CGSizeMake(dropShadowOffsetX, dropShadowOffsetY)];
- [dropShadowLayer setShadowPath:translatedPath.platformPath()];
- [dropShadowLayer setShadowOpacity:1];
- [dropShadowLayer setFrame:yellowHighlightRect];
- [bounceLayer addSublayer:dropShadowLayer.get()];
- [bounceLayer setValue:dropShadowLayer.get() forKey:dropShadowLayerKey];
-
- RetainPtr<CALayer> rimShadowLayer = adoptNS([[CALayer alloc] init]);
- [rimShadowLayer setDelegate:[WebActionDisablingCALayerDelegate shared]];
- [rimShadowLayer setFrame:yellowHighlightRect];
- [rimShadowLayer setShadowColor:rimShadowColor.get()];
- [rimShadowLayer setShadowRadius:rimShadowBlurRadius];
- [rimShadowLayer setShadowPath:translatedPath.platformPath()];
- [rimShadowLayer setShadowOffset:CGSizeZero];
- [rimShadowLayer setShadowOpacity:1];
- [rimShadowLayer setFrame:yellowHighlightRect];
- [bounceLayer addSublayer:rimShadowLayer.get()];
- [bounceLayer setValue:rimShadowLayer.get() forKey:rimShadowLayerKey];
-
- RetainPtr<CALayer> textLayer = adoptNS([[CALayer alloc] init]);
- [textLayer setBackgroundColor:highlightColor.get()];
- [textLayer setBorderColor:borderColor.get()];
- [textLayer setBorderWidth:borderWidth];
- [textLayer setDelegate:[WebActionDisablingCALayerDelegate shared]];
- if (contentsImage)
- [textLayer setContents:(__bridge id)contentsImage->platformImage().get()];
-
- RetainPtr<CAShapeLayer> maskLayer = adoptNS([[CAShapeLayer alloc] init]);
- [maskLayer setPath:translatedPath.platformPath()];
- [textLayer setMask:maskLayer.get()];
-
- FloatRect imageRect = pathBoundingRect;
- [textLayer setContentsRect:CGRectMake(imageRect.x() / contentsImageLogicalSize.width(), imageRect.y() / contentsImageLogicalSize.height(), imageRect.width() / contentsImageLogicalSize.width(), imageRect.height() / contentsImageLogicalSize.height())];
- [textLayer setContentsGravity:kCAGravityCenter];
- [textLayer setContentsScale:_textIndicator->contentImageScaleFactor()];
- [textLayer setFrame:yellowHighlightRect];
- [bounceLayer setValue:textLayer.get() forKey:textLayerKey];
- [bounceLayer addSublayer:textLayer.get()];
- }
-
- self.layer.sublayers = bounceLayers.get();
- _bounceLayers = bounceLayers;
-
- return self;
-}
-
-static RetainPtr<CAKeyframeAnimation> createBounceAnimation(CFTimeInterval duration)
-{
- RetainPtr<CAKeyframeAnimation> bounceAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];
- [bounceAnimation setValues:@[
- [NSValue valueWithCATransform3D:CATransform3DIdentity],
- [NSValue valueWithCATransform3D:CATransform3DMakeScale(midBounceScale, midBounceScale, 1)],
- [NSValue valueWithCATransform3D:CATransform3DIdentity]
- ]];
- [bounceAnimation setDuration:duration];
-
- return bounceAnimation;
-}
-
-static RetainPtr<CABasicAnimation> createContentCrossfadeAnimation(CFTimeInterval duration, TextIndicator& textIndicator)
-{
- RetainPtr<CABasicAnimation> crossfadeAnimation = [CABasicAnimation animationWithKeyPath:@"contents"];
- auto contentsImage = textIndicator.contentImage()->nativeImage();
- [crossfadeAnimation setToValue:(__bridge id)contentsImage->platformImage().get()];
- [crossfadeAnimation setFillMode:kCAFillModeForwards];
- [crossfadeAnimation setRemovedOnCompletion:NO];
- [crossfadeAnimation setDuration:duration];
-
- return crossfadeAnimation;
-}
-
-static RetainPtr<CABasicAnimation> createShadowFadeAnimation(CFTimeInterval duration)
-{
- RetainPtr<CABasicAnimation> fadeShadowInAnimation = [CABasicAnimation animationWithKeyPath:@"shadowOpacity"];
- [fadeShadowInAnimation setFromValue:@0];
- [fadeShadowInAnimation setToValue:@1];
- [fadeShadowInAnimation setFillMode:kCAFillModeForwards];
- [fadeShadowInAnimation setRemovedOnCompletion:NO];
- [fadeShadowInAnimation setDuration:duration];
-
- return fadeShadowInAnimation;
-}
-
-static RetainPtr<CABasicAnimation> createFadeInAnimation(CFTimeInterval duration)
-{
- RetainPtr<CABasicAnimation> fadeInAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
- [fadeInAnimation setFromValue:@0];
- [fadeInAnimation setToValue:@1];
- [fadeInAnimation setFillMode:kCAFillModeForwards];
- [fadeInAnimation setRemovedOnCompletion:NO];
- [fadeInAnimation setDuration:duration];
-
- return fadeInAnimation;
-}
-
-- (CFTimeInterval)_animationDuration
-{
- if (indicatorWantsBounce(*_textIndicator)) {
- if (indicatorWantsContentCrossfade(*_textIndicator))
- return bounceWithCrossfadeAnimationDuration;
- return bounceAnimationDuration;
- }
-
- return fadeInAnimationDuration;
-}
-
-- (BOOL)hasCompletedAnimation
-{
- return _hasCompletedAnimation;
-}
-
-- (void)present
-{
- bool wantsBounce = indicatorWantsBounce(*_textIndicator);
- bool wantsCrossfade = indicatorWantsContentCrossfade(*_textIndicator);
- bool wantsFadeIn = indicatorWantsFadeIn(*_textIndicator);
- CFTimeInterval animationDuration = [self _animationDuration];
-
- _hasCompletedAnimation = false;
-
- RetainPtr<CAAnimation> presentationAnimation;
- if (wantsBounce)
- presentationAnimation = createBounceAnimation(animationDuration);
- else if (wantsFadeIn)
- presentationAnimation = createFadeInAnimation(animationDuration);
-
- RetainPtr<CABasicAnimation> crossfadeAnimation;
- RetainPtr<CABasicAnimation> fadeShadowInAnimation;
- if (wantsCrossfade) {
- crossfadeAnimation = createContentCrossfadeAnimation(animationDuration, *_textIndicator);
- fadeShadowInAnimation = createShadowFadeAnimation(animationDuration);
- }
-
- [CATransaction begin];
- for (CALayer *bounceLayer in _bounceLayers.get()) {
- if (indicatorWantsManualAnimation(*_textIndicator))
- bounceLayer.speed = 0;
-
- if (!wantsFadeIn)
- bounceLayer.opacity = 1;
-
- if (presentationAnimation)
- [bounceLayer addAnimation:presentationAnimation.get() forKey:@"presentation"];
-
- if (wantsCrossfade) {
- [[bounceLayer valueForKey:textLayerKey] addAnimation:crossfadeAnimation.get() forKey:@"contentTransition"];
- [[bounceLayer valueForKey:dropShadowLayerKey] addAnimation:fadeShadowInAnimation.get() forKey:@"fadeShadowIn"];
- [[bounceLayer valueForKey:rimShadowLayerKey] addAnimation:fadeShadowInAnimation.get() forKey:@"fadeShadowIn"];
- }
- }
- [CATransaction commit];
-}
-
-- (void)hideWithCompletionHandler:(void(^)(void))completionHandler
-{
- RetainPtr<CABasicAnimation> fadeAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
- [fadeAnimation setFromValue:@1];
- [fadeAnimation setToValue:@0];
- [fadeAnimation setFillMode:kCAFillModeForwards];
- [fadeAnimation setRemovedOnCompletion:NO];
- [fadeAnimation setDuration:fadeOutAnimationDuration];
-
- [CATransaction begin];
- [CATransaction setCompletionBlock:completionHandler];
- [self.layer addAnimation:fadeAnimation.get() forKey:@"fadeOut"];
- [CATransaction commit];
-}
-
-- (void)setAnimationProgress:(float)progress
-{
- if (_hasCompletedAnimation)
- return;
-
- if (progress == 1) {
- _hasCompletedAnimation = true;
-
- for (CALayer *bounceLayer in _bounceLayers.get()) {
- // Continue the animation from wherever it had manually progressed to.
- CFTimeInterval beginTime = bounceLayer.timeOffset;
- bounceLayer.speed = 1;
- beginTime = [bounceLayer convertTime:CACurrentMediaTime() fromLayer:nil] - beginTime;
- bounceLayer.beginTime = beginTime;
- }
- } else {
- CFTimeInterval animationDuration = [self _animationDuration];
- for (CALayer *bounceLayer in _bounceLayers.get())
- bounceLayer.timeOffset = progress * animationDuration;
- }
-}
-
-- (BOOL)isFlipped
-{
- return YES;
-}
-
-@end
-
namespace WebCore {
TextIndicatorWindow::TextIndicatorWindow(NSView *targetView)
@@ -423,7 +64,7 @@
if (!m_textIndicator)
return;
- [m_textIndicatorView setAnimationProgress:progress];
+ [m_textIndicatorLayer setAnimationProgress:progress];
}
void TextIndicatorWindow::clearTextIndicator(TextIndicatorWindowDismissalAnimation animation)
@@ -430,10 +71,10 @@
{
RefPtr<TextIndicator> textIndicator = WTFMove(m_textIndicator);
- if ([m_textIndicatorView isFadingOut])
+ if ([m_textIndicatorLayer isFadingOut])
return;
- if (textIndicator && indicatorWantsManualAnimation(*textIndicator) && [m_textIndicatorView hasCompletedAnimation] && animation == TextIndicatorWindowDismissalAnimation::FadeOut) {
+ if (textIndicator && [m_textIndicatorLayer indicatorWantsManualAnimation:*textIndicator] && [m_textIndicatorLayer hasCompletedAnimation] && animation == TextIndicatorWindowDismissalAnimation::FadeOut) {
startFadeOut();
return;
}
@@ -453,7 +94,7 @@
CGFloat horizontalMargin = dropShadowBlurRadius * 2 + TextIndicator::defaultHorizontalMargin;
CGFloat verticalMargin = dropShadowBlurRadius * 2 + TextIndicator::defaultVerticalMargin;
- if (indicatorWantsBounce(*m_textIndicator)) {
+ if ([m_textIndicatorLayer indicatorWantsBounce:*m_textIndicator]) {
horizontalMargin = std::max(horizontalMargin, textBoundingRectInScreenCoordinates.size.width * (midBounceScale - 1) + horizontalMargin);
verticalMargin = std::max(verticalMargin, textBoundingRectInScreenCoordinates.size.height * (midBounceScale - 1) + verticalMargin);
}
@@ -470,8 +111,12 @@
[m_textIndicatorWindow setOpaque:NO];
[m_textIndicatorWindow setIgnoresMouseEvents:YES];
- m_textIndicatorView = adoptNS([[WebTextIndicatorView alloc] initWithFrame:NSMakeRect(0, 0, [m_textIndicatorWindow frame].size.width, [m_textIndicatorWindow frame].size.height)
+ NSRect frame = NSMakeRect(0, 0, [m_textIndicatorWindow frame].size.width, [m_textIndicatorWindow frame].size.height);
+ m_textIndicatorLayer = adoptNS([[WebTextIndicatorLayer alloc] initWithFrame:frame
textIndicator:*m_textIndicator margin:NSMakeSize(horizontalMargin, verticalMargin) offset:fractionalTextOffset]);
+ m_textIndicatorView = adoptNS([[NSView alloc] initWithFrame:frame]);
+ [m_textIndicatorView setLayer:m_textIndicatorLayer.get()];
+ [m_textIndicatorView setWantsLayer:YES];
[m_textIndicatorWindow setContentView:m_textIndicatorView.get()];
[[m_targetView window] addChildWindow:m_textIndicatorWindow.get() ordered:NSWindowAbove];
@@ -478,7 +123,7 @@
[m_textIndicatorWindow setReleasedWhenClosed:NO];
if (m_textIndicator->presentationTransition() != TextIndicatorPresentationTransition::None)
- [m_textIndicatorView present];
+ [m_textIndicatorLayer present];
if (lifetime == TextIndicatorWindowLifetime::Temporary)
m_temporaryTextIndicatorTimer.startOneShot(1_s * timeBeforeFadeStarts);
@@ -489,7 +134,7 @@
if (!m_textIndicatorWindow)
return;
- if ([m_textIndicatorView isFadingOut])
+ if ([m_textIndicatorLayer isFadingOut])
return;
m_temporaryTextIndicatorTimer.stop();
@@ -501,9 +146,9 @@
void TextIndicatorWindow::startFadeOut()
{
- [m_textIndicatorView setFadingOut:YES];
+ [m_textIndicatorLayer setFadingOut:YES];
RetainPtr<NSWindow> indicatorWindow = m_textIndicatorWindow;
- [m_textIndicatorView hideWithCompletionHandler:[indicatorWindow] {
+ [m_textIndicatorLayer hideWithCompletionHandler:[indicatorWindow] {
[[indicatorWindow parentWindow] removeChildWindow:indicatorWindow.get()];
[indicatorWindow close];
}];
Modified: trunk/WebKit.xcworkspace/xcshareddata/xcschemes/All Source.xcscheme (277329 => 277330)
--- trunk/WebKit.xcworkspace/xcshareddata/xcschemes/All Source.xcscheme 2021-05-11 17:45:56 UTC (rev 277329)
+++ trunk/WebKit.xcworkspace/xcshareddata/xcschemes/All Source.xcscheme 2021-05-11 17:46:40 UTC (rev 277330)
@@ -127,8 +127,8 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1A50DB38110A3C13000D3FE5"
- BuildableName = "All"
- BlueprintName = "All"
+ BuildableName = "Framework & XPC Services"
+ BlueprintName = "Framework & XPC Services"
ReferencedContainer = "container:Source/WebKit/WebKit.xcodeproj">
</BuildableReference>
</BuildActionEntry>