| Index: ios/chrome/browser/ui/toolbar/toolbar_tools_menu_button.mm
|
| diff --git a/ios/chrome/browser/ui/toolbar/toolbar_tools_menu_button.mm b/ios/chrome/browser/ui/toolbar/toolbar_tools_menu_button.mm
|
| index dff031ab80643357197193bb048d398b746cf5e2..7ea152c5911dd4a59b2a4b36be6d4ea04db7e641 100644
|
| --- a/ios/chrome/browser/ui/toolbar/toolbar_tools_menu_button.mm
|
| +++ b/ios/chrome/browser/ui/toolbar/toolbar_tools_menu_button.mm
|
| @@ -9,6 +9,10 @@
|
|
|
| #include "ios/chrome/browser/ui/toolbar/toolbar_button_tints.h"
|
|
|
| +#if !defined(__has_feature) || !__has_feature(objc_arc)
|
| +#error "This file requires ARC support."
|
| +#endif
|
| +
|
| namespace {
|
| // The number of dots drawn.
|
| const int kNumberOfDots = 3;
|
| @@ -48,7 +52,7 @@ const CGFloat kLineWidthAtApogee = 3;
|
| // Whether the reading list contains unseen items.
|
| BOOL readingListContainsUnseenItems_;
|
| // The CALayers containing the drawn dots.
|
| - base::scoped_nsobject<CAShapeLayer> pathLayers_[kNumberOfDots];
|
| + NSMutableArray<CAShapeLayer*>* pathLayers_;
|
| // Whether the CALayers are being animated.
|
| BOOL animationOnGoing_;
|
| }
|
| @@ -76,6 +80,7 @@ const CGFloat kLineWidthAtApogee = 3;
|
| style:(ToolbarControllerStyle)style {
|
| if (self = [super initWithFrame:frame]) {
|
| style_ = style;
|
| + pathLayers_ = [[NSMutableArray alloc] initWithCapacity:kNumberOfDots];
|
|
|
| [self setTintColor:toolbar::NormalButtonTint(style_)
|
| forState:UIControlStateNormal];
|
| @@ -112,12 +117,12 @@ const CGFloat kLineWidthAtApogee = 3;
|
| }
|
|
|
| - (void)initializeShapeLayers {
|
| - for (int i = 0; i < kNumberOfDots; i++) {
|
| - base::scoped_nsobject<CAShapeLayer>& pathLayer = pathLayers_[i];
|
| - if (pathLayer) {
|
| - [pathLayer removeFromSuperlayer];
|
| - }
|
| + for (NSUInteger i = 0; i < pathLayers_.count; i++) {
|
| + [pathLayers_[i] removeFromSuperlayer];
|
| + }
|
|
|
| + pathLayers_ = [[NSMutableArray alloc] initWithCapacity:kNumberOfDots];
|
| + for (NSUInteger i = 0; i < kNumberOfDots; i++) {
|
| const CGFloat x = kDotOffsetX;
|
| const CGFloat y = kDotOffsetY + kVerticalSpaceBetweenDots * i;
|
|
|
| @@ -125,7 +130,7 @@ const CGFloat kLineWidthAtApogee = 3;
|
| [path moveToPoint:CGPointMake(x - kMaxWidthOfSegment * 0.5, y)];
|
| [path addLineToPoint:CGPointMake(x + kMaxWidthOfSegment * 0.5, y)];
|
|
|
| - pathLayer.reset([[CAShapeLayer layer] retain]);
|
| + CAShapeLayer* pathLayer = [CAShapeLayer layer];
|
| [pathLayer setFrame:self.bounds];
|
| [pathLayer setPath:path.CGPath];
|
| [pathLayer setStrokeColor:[self.tintColor CGColor]];
|
| @@ -134,7 +139,8 @@ const CGFloat kLineWidthAtApogee = 3;
|
| [pathLayer setLineCap:kCALineCapRound];
|
| [pathLayer setStrokeStart:kStrokeStartAtRest];
|
| [pathLayer setStrokeEnd:kStrokeEndAtRest];
|
| - [self.layer addSublayer:pathLayer.get()];
|
| + [self.layer addSublayer:pathLayer];
|
| + [pathLayers_ addObject:pathLayer];
|
| }
|
| }
|
|
|
| @@ -204,10 +210,10 @@ const CGFloat kLineWidthAtApogee = 3;
|
| - (void)animateToColor:(UIColor*)targetColor {
|
| animationOnGoing_ = YES;
|
|
|
| + DCHECK(pathLayers_.count == kNumberOfDots);
|
| // Add four animations for each stroke.
|
| for (int i = 0; i < kNumberOfDots; i++) {
|
| - base::scoped_nsobject<CAShapeLayer>& pathLayer = pathLayers_[i];
|
| - DCHECK(pathLayer.get());
|
| + CAShapeLayer* pathLayer = pathLayers_[i];
|
| const int frameStart =
|
| (kNumberOfDots - i) * kFramesBetweenAnimationOfEachDot;
|
|
|
|
|