⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 277469 in webkit


Ignore:
Timestamp:
May 13, 2021, 6:02:03 PM (5 years ago)
Author:
Russell Epstein
Message:

Cherry-pick r277330. rdar://problem/77996680

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.

git-svn-id: ​https://svn.webkit.org/repository/webkit/trunk@277330 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
branches/safari-612.1.12-branch
Files:
6 edited
2 copied

Legend:

Unmodified
Added
Removed
  • branches/safari-612.1.12-branch/Source/WebCore/ChangeLog

    r277288 r277469  
     12021-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
    1802021-05-10  Russell Epstein  <repstein@apple.com>
    281
  • branches/safari-612.1.12-branch/Source/WebCore/SourcesCocoa.txt

    r276331 r277469  
    183183page/cocoa/ResourceUsageThreadCocoa.mm
    184184page/cocoa/SettingsBaseCocoa.mm
     185page/cocoa/WebTextIndicatorLayer.mm
    185186page/ios/ContentChangeObserver.cpp
    186187page/ios/DOMTimerHoldingTank.cpp
  • branches/safari-612.1.12-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r276992 r277469  
    12701270                44C991860F3D1EBE00586670 /* ScrollbarThemeIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 44C991850F3D1EBE00586670 /* ScrollbarThemeIOS.h */; };
    12711271                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, ); }; };
    12721273                44E349F9246F4E190068479C /* LibWebRTCEnumTraits.h in Headers */ = {isa = PBXBuildFile; fileRef = 44E349F7246F4DC70068479C /* LibWebRTCEnumTraits.h */; settings = {ATTRIBUTES = (Private, ); }; };
    12731274                450CEBF115073BBE002BB149 /* LabelableElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 450CEBEF15073BBE002BB149 /* LabelableElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
    … …  
    82508251                44C9919E0F3D210E00586670 /* ThemeIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ThemeIOS.mm; sourceTree = "<group>"; };
    82518252                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>"; };
    82528255                44D8DA98139545BE00337B75 /* SVGMPathElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SVGMPathElement.idl; sourceTree = "<group>"; };
    82538256                44D8DA9A139545CD00337B75 /* SVGAnimateMotionElement.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SVGAnimateMotionElement.idl; sourceTree = "<group>"; };
    … …  
    2183721840                                A5071E881C56D4FA009951BE /* ResourceUsageThreadCocoa.mm */,
    2183821841                                A182D5B61BE722620087A7CC /* SettingsBaseCocoa.mm */,
     21842                                44CE2BBE2643799E007AE110 /* WebTextIndicatorLayer.h */,
     21843                                44CE2BBC2643799D007AE110 /* WebTextIndicatorLayer.mm */,
    2183921844                        );
    2184021845                        path = cocoa;
    … …  
    3579035795                                1F8756B21E22C3350042C40D /* WebSQLiteDatabaseTrackerClient.h in Headers */,
    3579135796                                31DEA4561B39F4D900F77178 /* WebSystemBackdropLayer.h in Headers */,
     35797                                44CE2BBF264379AF007AE110 /* WebTextIndicatorLayer.h in Headers */,
    3579235798                                0F580FA31496939100FB5BD8 /* WebTiledBackingLayer.h in Headers */,
    3579335799                                1DAB3112251D6BF300FC9485 /* WebVideoContainerLayer.h in Headers */,
  • branches/safari-612.1.12-branch/Source/WebCore/page/cocoa/WebTextIndicatorLayer.h

    r277466 r277469  
    11/*
    2  * Copyright (C) 2010 Apple Inc. All rights reserved.
     2 * Copyright (C) 2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
    … …  
    3232#import <wtf/RunLoop.h>
    3333
    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}
    3641
    37 namespace WebCore {
     42- (instancetype)initWithFrame:(CGRect)frame textIndicator:(WebCore::TextIndicator&)textIndicator margin:(CGSize)margin offset:(CGPoint)offset;
    3843
    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;
    4246
    43     // The TextIndicator should briefly indicate the text and then automatically dismiss.
    44     Temporary
    45 };
     47- (void)present;
     48- (void)hideWithCompletionHandler:(void(^)(void))completionHandler;
    4649
    47 enum class TextIndicatorWindowDismissalAnimation : uint8_t {
    48     None,
    49     FadeOut
    50 };
     50- (void)setAnimationProgress:(float)progress;
     51- (BOOL)hasCompletedAnimation;
    5152
    52 #if PLATFORM(MAC)
     53@property (nonatomic, getter=isFadingOut) BOOL fadingOut;
    5354
    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  
    11/*
    2  * Copyright (C) 2010 Apple Inc. All rights reserved.
     2 * Copyright (C) 2021 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
    … …  
    2525
    2626#import "config.h"
    27 #import "TextIndicatorWindow.h"
    28 
    29 #if PLATFORM(MAC)
     27#import "WebTextIndicatorLayer.h"
    3028
    3129#import "GeometryUtilities.h"
    … …  
    3533#import "WebActionDisablingCALayerDelegate.h"
    3634#import <pal/spi/cg/CoreGraphicsSPI.h>
     35#import <pal/spi/cocoa/QuartzCoreSPI.h>
     36
     37#if PLATFORM(MAC)
    3738#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
     41constexpr CFTimeInterval bounceAnimationDuration = 0.12;
     42constexpr CFTimeInterval bounceWithCrossfadeAnimationDuration = 0.3;
     43constexpr CFTimeInterval fadeInAnimationDuration = 0.15;
     44constexpr CFTimeInterval timeBeforeFadeStarts = bounceAnimationDuration + 0.2;
     45constexpr CFTimeInterval fadeOutAnimationDuration = 0.3;
     46
     47constexpr CGFloat midBounceScale = 1.25;
     48constexpr CGFloat borderWidth = 0;
     49constexpr CGFloat cornerRadius = 0;
     50constexpr CGFloat dropShadowOffsetX = 0;
     51constexpr CGFloat dropShadowOffsetY = 1;
     52constexpr CGFloat dropShadowBlurRadius = 2;
     53constexpr CGFloat rimShadowBlurRadius = 1;
     54
     55constexpr NSString * const textLayerKey = @"TextLayer";
     56constexpr NSString * const dropShadowLayerKey = @"DropShadowLayer";
     57constexpr NSString * const rimShadowLayerKey = @"RimShadowLayer";
     58
     59@implementation WebTextIndicatorLayer
    8160
    8261@synthesize fadingOut = _fadingOut;
    8362
    84 static bool indicatorWantsBounce(const TextIndicator& indicator)
    85 {
     63static bool indicatorWantsContentCrossfade(const WebCore::TextIndicator& indicator)
     64{
     65    if (!indicator.data().contentImageWithHighlight)
     66        return false;
     67
    8668    switch (indicator.presentationTransition()) {
    87     case TextIndicatorPresentationTransition::BounceAndCrossfade:
    88     case TextIndicatorPresentationTransition::Bounce:
     69    case WebCore::TextIndicatorPresentationTransition::BounceAndCrossfade:
    8970        return true;
    9071
    91     case TextIndicatorPresentationTransition::FadeIn:
    92     case TextIndicatorPresentationTransition::None:
     72    case WebCore::TextIndicatorPresentationTransition::Bounce:
     73    case WebCore::TextIndicatorPresentationTransition::FadeIn:
     74    case WebCore::TextIndicatorPresentationTransition::None:
    9375        return false;
    9476    }
    … …  
    9880}
    9981
    100 static bool indicatorWantsContentCrossfade(const TextIndicator& indicator)
    101 {
    102     if (!indicator.data().contentImageWithHighlight)
    103         return false;
    104 
     82static bool indicatorWantsFadeIn(const WebCore::TextIndicator& indicator)
     83{
    10584    switch (indicator.presentationTransition()) {
    106     case TextIndicatorPresentationTransition::BounceAndCrossfade:
     85    case WebCore::TextIndicatorPresentationTransition::FadeIn:
    10786        return true;
    10887
    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:
    11291        return false;
    11392    }
    … …  
    11796}
    11897
    119 static bool indicatorWantsFadeIn(const TextIndicator& indicator)
     98- (bool)indicatorWantsBounce:(const WebCore::TextIndicator&)indicator
    12099{
    121100    switch (indicator.presentationTransition()) {
    122     case TextIndicatorPresentationTransition::FadeIn:
     101    case WebCore::TextIndicatorPresentationTransition::BounceAndCrossfade:
     102    case WebCore::TextIndicatorPresentationTransition::Bounce:
    123103        return true;
    124104
    125     case TextIndicatorPresentationTransition::Bounce:
    126     case TextIndicatorPresentationTransition::BounceAndCrossfade:
    127     case TextIndicatorPresentationTransition::None:
     105    case WebCore::TextIndicatorPresentationTransition::FadeIn:
     106    case WebCore::TextIndicatorPresentationTransition::None:
    128107        return false;
    129108    }
    … …  
    133112}
    134113
    135 static bool indicatorWantsManualAnimation(const TextIndicator& indicator)
     114- (bool)indicatorWantsManualAnimation:(const WebCore::TextIndicator&)indicator
    136115{
    137116    switch (indicator.presentationTransition()) {
    138     case TextIndicatorPresentationTransition::FadeIn:
     117    case WebCore::TextIndicatorPresentationTransition::FadeIn:
    139118        return true;
    140119
    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:
    144123        return false;
    145124    }
    … …  
    149128}
    150129
    151 - (instancetype)initWithFrame:(NSRect)frame textIndicator:(TextIndicator&)textIndicator margin:(NSSize)margin offset:(NSPoint)offset
    152 {
    153     if (!(self = [super initWithFrame:frame]))
     130- (instancetype)initWithFrame:(CGRect)frame textIndicator:(WebCore::TextIndicator&)textIndicator margin:(CGSize)margin offset:(CGPoint)offset
     131{
     132    if (!(self = [super init]))
    154133        return nil;
     134   
     135    self.frame = frame;
    155136
    156137    _textIndicator = &textIndicator;
    157138    _margin = margin;
    158139
    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 };
    164144    if (auto* contentImage = _textIndicator->contentImage()) {
    165145        contentsImageLogicalSize = contentImage->size();
    … …  
    171151    }
    172152
    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);
    184168
    185169    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;
    190174        transform.translate(-pathBoundingRect.location());
    191175        translatedPath.addPath(path, transform);
    192176
    193         FloatRect offsetTextRect = pathBoundingRect;
     177        WebCore::FloatRect offsetTextRect = pathBoundingRect;
    194178        offsetTextRect.move(offset.x, offset.y);
    195179
    196         FloatRect bounceLayerRect = offsetTextRect;
     180        WebCore::FloatRect bounceLayerRect = offsetTextRect;
    197181        bounceLayerRect.move(_margin.width, _margin.height);
    198182
    … …  
    203187        [bounceLayers addObject:bounceLayer.get()];
    204188
    205         FloatRect yellowHighlightRect(FloatPoint(), bounceLayerRect.size());
    206 
     189        WebCore::FloatRect yellowHighlightRect(WebCore::FloatPoint(), bounceLayerRect.size());
     190
     191#if PLATFORM(MAC)
    207192        RetainPtr<CALayer> dropShadowLayer = adoptNS([[CALayer alloc] init]);
    208193        [dropShadowLayer setDelegate:[WebActionDisablingCALayerDelegate shared]];
    … …  
    227212        [bounceLayer addSublayer:rimShadowLayer.get()];
    228213        [bounceLayer setValue:rimShadowLayer.get() forKey:rimShadowLayerKey];
    229 
     214#endif // PLATFORM(MAC)
     215       
    230216        RetainPtr<CALayer> textLayer = adoptNS([[CALayer alloc] init]);
    231217        [textLayer setBackgroundColor:highlightColor.get()];
    … …  
    240226        [textLayer setMask:maskLayer.get()];
    241227
    242         FloatRect imageRect = pathBoundingRect;
     228        WebCore::FloatRect imageRect = pathBoundingRect;
    243229        [textLayer setContentsRect:CGRectMake(imageRect.x() / contentsImageLogicalSize.width(), imageRect.y() / contentsImageLogicalSize.height(), imageRect.width() / contentsImageLogicalSize.width(), imageRect.height() / contentsImageLogicalSize.height())];
    244230        [textLayer setContentsGravity:kCAGravityCenter];
    … …  
    249235    }
    250236
    251     self.layer.sublayers = bounceLayers.get();
     237    self.sublayers = bounceLayers.get();
    252238    _bounceLayers = bounceLayers;
    253239
    … …  
    268254}
    269255
    270 static RetainPtr<CABasicAnimation> createContentCrossfadeAnimation(CFTimeInterval duration, TextIndicator& textIndicator)
     256static RetainPtr<CABasicAnimation> createContentCrossfadeAnimation(CFTimeInterval duration, WebCore::TextIndicator& textIndicator)
    271257{
    272258    RetainPtr<CABasicAnimation> crossfadeAnimation = [CABasicAnimation animationWithKeyPath:@"contents"];
    … …  
    306292- (CFTimeInterval)_animationDuration
    307293{
    308     if (indicatorWantsBounce(*_textIndicator)) {
     294    if ([self indicatorWantsBounce:*_textIndicator]) {
    309295        if (indicatorWantsContentCrossfade(*_textIndicator))
    310296            return bounceWithCrossfadeAnimationDuration;
    … …  
    322308- (void)present
    323309{
    324     bool wantsBounce = indicatorWantsBounce(*_textIndicator);
     310    bool wantsBounce = [self indicatorWantsBounce:*_textIndicator];
    325311    bool wantsCrossfade = indicatorWantsContentCrossfade(*_textIndicator);
    326312    bool wantsFadeIn = indicatorWantsFadeIn(*_textIndicator);
    … …  
    344330    [CATransaction begin];
    345331    for (CALayer *bounceLayer in _bounceLayers.get()) {
    346         if (indicatorWantsManualAnimation(*_textIndicator))
     332        if ([self indicatorWantsManualAnimation:*_textIndicator])
    347333            bounceLayer.speed = 0;
    348334
    … …  
    373359    [CATransaction begin];
    374360    [CATransaction setCompletionBlock:completionHandler];
    375     [self.layer addAnimation:fadeAnimation.get() forKey:@"fadeOut"];
     361    [self addAnimation:fadeAnimation.get() forKey:@"fadeOut"];
    376362    [CATransaction commit];
    377363}
    … …  
    405391
    406392@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 WebCore
    513 
    514 #endif // PLATFORM(MAC)
  • branches/safari-612.1.12-branch/Source/WebCore/page/mac/TextIndicatorWindow.h

    r248762 r277469  
    3333
    3434OBJC_CLASS NSView;
    35 OBJC_CLASS WebTextIndicatorView;
     35OBJC_CLASS WebTextIndicatorLayer;
    3636
    3737namespace WebCore {
    … …  
    7373    RefPtr<TextIndicator> m_textIndicator;
    7474    RetainPtr<NSWindow> m_textIndicatorWindow;
    75     RetainPtr<WebTextIndicatorView> m_textIndicatorView;
     75    RetainPtr<NSView> m_textIndicatorView;
     76    RetainPtr<WebTextIndicatorLayer> m_textIndicatorLayer;
    7677
    7778    RunLoop::Timer<TextIndicatorWindow> m_temporaryTextIndicatorTimer;
  • branches/safari-612.1.12-branch/Source/WebCore/page/mac/TextIndicatorWindow.mm

    r271694 r277469  
    3434#import "TextIndicator.h"
    3535#import "WebActionDisablingCALayerDelegate.h"
     36#import "WebTextIndicatorLayer.h"
    3637#import <pal/spi/cg/CoreGraphicsSPI.h>
    3738#import <pal/spi/cocoa/NSColorSPI.h>
    … …  
    3940
    4041const CFTimeInterval bounceAnimationDuration = 0.12;
    41 const CFTimeInterval bounceWithCrossfadeAnimationDuration = 0.3;
    42 const CFTimeInterval fadeInAnimationDuration = 0.15;
    4342const CFTimeInterval timeBeforeFadeStarts = bounceAnimationDuration + 0.2;
    44 const CFTimeInterval fadeOutAnimationDuration = 0.3;
    4543
    4644const CGFloat midBounceScale = 1.25;
    47 const CGFloat borderWidth = 0;
    48 const CGFloat cornerRadius = 0;
    49 const CGFloat dropShadowOffsetX = 0;
    50 const CGFloat dropShadowOffsetY = 1;
    5145const CGFloat dropShadowBlurRadius = 2;
    52 const CGFloat rimShadowBlurRadius = 1;
    53 
    54 NSString *textLayerKey = @"TextLayer";
    55 NSString *dropShadowLayerKey = @"DropShadowLayer";
    56 NSString *rimShadowLayerKey = @"RimShadowLayer";
    5746
    5847using 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
    81 
    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)offset
    152 {
    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         else
    170             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)_animationDuration
    307 {
    308     if (indicatorWantsBounce(*_textIndicator)) {
    309         if (indicatorWantsContentCrossfade(*_textIndicator))
    310             return bounceWithCrossfadeAnimationDuration;
    311         return bounceAnimationDuration;
    312     }
    313 
    314     return fadeInAnimationDuration;
    315 }
    316 
    317 - (BOOL)hasCompletedAnimation
    318 {
    319     return _hasCompletedAnimation;
    320 }
    321 
    322 - (void)present
    323 {
    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))completionHandler
    365 {
    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)progress
    380 {
    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)isFlipped
    402 {
    403     return YES;
    404 }
    405 
    406 @end
    40748
    40849namespace WebCore {
    … …  
    42465        return;
    42566
    426     [m_textIndicatorView setAnimationProgress:progress];
     67    [m_textIndicatorLayer setAnimationProgress:progress];
    42768}
    42869
    … …  
    43172    RefPtr<TextIndicator> textIndicator = WTFMove(m_textIndicator);
    43273
    433     if ([m_textIndicatorView isFadingOut])
     74    if ([m_textIndicatorLayer isFadingOut])
    43475        return;
    43576
    436     if (textIndicator && indicatorWantsManualAnimation(*textIndicator) && [m_textIndicatorView hasCompletedAnimation] && animation == TextIndicatorWindowDismissalAnimation::FadeOut) {
     77    if (textIndicator && [m_textIndicatorLayer indicatorWantsManualAnimation:*textIndicator] && [m_textIndicatorLayer hasCompletedAnimation] && animation == TextIndicatorWindowDismissalAnimation::FadeOut) {
    43778        startFadeOut();
    43879        return;
    … …  
    45495    CGFloat verticalMargin = dropShadowBlurRadius * 2 + TextIndicator::defaultVerticalMargin;
    45596   
    456     if (indicatorWantsBounce(*m_textIndicator)) {
     97    if ([m_textIndicatorLayer indicatorWantsBounce:*m_textIndicator]) {
    45798        horizontalMargin = std::max(horizontalMargin, textBoundingRectInScreenCoordinates.size.width * (midBounceScale - 1) + horizontalMargin);
    45899        verticalMargin = std::max(verticalMargin, textBoundingRectInScreenCoordinates.size.height * (midBounceScale - 1) + verticalMargin);
    … …  
    471112    [m_textIndicatorWindow setIgnoresMouseEvents:YES];
    472113
    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
    474116        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];
    475120    [m_textIndicatorWindow setContentView:m_textIndicatorView.get()];
    476121
    … …  
    479124
    480125    if (m_textIndicator->presentationTransition() != TextIndicatorPresentationTransition::None)
    481         [m_textIndicatorView present];
     126        [m_textIndicatorLayer present];
    482127
    483128    if (lifetime == TextIndicatorWindowLifetime::Temporary)
    … …  
    490135        return;
    491136
    492     if ([m_textIndicatorView isFadingOut])
     137    if ([m_textIndicatorLayer isFadingOut])
    493138        return;
    494139
    … …  
    502147void TextIndicatorWindow::startFadeOut()
    503148{
    504     [m_textIndicatorView setFadingOut:YES];
     149    [m_textIndicatorLayer setFadingOut:YES];
    505150    RetainPtr<NSWindow> indicatorWindow = m_textIndicatorWindow;
    506     [m_textIndicatorView hideWithCompletionHandler:[indicatorWindow] {
     151    [m_textIndicatorLayer hideWithCompletionHandler:[indicatorWindow] {
    507152        [[indicatorWindow parentWindow] removeChildWindow:indicatorWindow.get()];
    508153        [indicatorWindow close];
  • branches/safari-612.1.12-branch/WebKit.xcworkspace/xcshareddata/xcschemes/All Source.xcscheme

    r264234 r277469  
    128128               BuildableIdentifier = "primary"
    129129               BlueprintIdentifier = "1A50DB38110A3C13000D3FE5"
    130                BuildableName = "All"
    131                BlueprintName = "All"
     130               BuildableName = "Framework &amp; XPC Services"
     131               BlueprintName = "Framework &amp; XPC Services"
    132132               ReferencedContainer = "container:Source/WebKit/WebKit.xcodeproj">
    133133            </BuildableReference>
Note: See TracChangeset for help on using the changeset viewer.