Chromium Code Reviews| 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..12fbf0860e9bb12ca050e703d46c6bed7a0d2424 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,10 +117,9 @@ 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 < kNumberOfDots; i++) { |
| + if (i < pathLayers_.count) { |
| + [pathLayers_[i] removeFromSuperlayer]; |
| } |
| const CGFloat x = kDotOffsetX; |
| @@ -125,7 +129,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 +138,8 @@ const CGFloat kLineWidthAtApogee = 3; |
| [pathLayer setLineCap:kCALineCapRound]; |
| [pathLayer setStrokeStart:kStrokeStartAtRest]; |
| [pathLayer setStrokeEnd:kStrokeEndAtRest]; |
| - [self.layer addSublayer:pathLayer.get()]; |
| + [self.layer addSublayer:pathLayer]; |
| + pathLayers_[i] = pathLayer; |
|
sdefresne
2017/05/02 14:19:28
I don't think you can set objects past the NSArray
gambard
2017/05/02 15:19:02
It seemed to work but it makes more sense to do it
|
| } |
| } |
| @@ -204,10 +209,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; |