Commit 7b6016fb authored by vasilii's avatar vasilii Committed by Commit Bot

Rename the iVars in confirm_infobar_view.mm to match the style guide.

It's a follow-up to https://chromium-review.googlesource.com/c/chromium/src/+/1270922

Bug: 890336
Cq-Include-Trybots: luci.chromium.try:ios-simulator-cronet;luci.chromium.try:ios-simulator-full-configs
Change-Id: Iea3b7be1d588cdcdbdded5409927e18c069812b4
Reviewed-on: https://chromium-review.googlesource.com/c/1277287Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Commit-Queue: Vasilii Sukhanov <vasilii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#599156}
parent 2cc06f19
...@@ -201,32 +201,32 @@ UIImage* InfoBarCloseImage() { ...@@ -201,32 +201,32 @@ UIImage* InfoBarCloseImage() {
@end @end
@implementation SwitchView { @implementation SwitchView {
UISwitch* switch_; UISwitch* _switch;
CGFloat preferredTotalWidth_; CGFloat _preferredTotalWidth;
// Layout metrics for calculating item placement. // Layout metrics for calculating item placement.
const LayoutMetrics* metrics_; const LayoutMetrics* _metrics;
} }
- (instancetype)initWithText:(NSString*)labelText isOn:(BOOL)isOn { - (instancetype)initWithText:(NSString*)labelText isOn:(BOOL)isOn {
metrics_ = &kLayoutMetrics; _metrics = &kLayoutMetrics;
self = [super initWithText:labelText]; self = [super initWithText:labelText];
if (!self) if (!self)
return nil; return nil;
self.label.textColor = [UIColor blackColor]; self.label.textColor = [UIColor blackColor];
switch_ = [[UISwitch alloc] initWithFrame:CGRectZero]; _switch = [[UISwitch alloc] initWithFrame:CGRectZero];
switch_.exclusiveTouch = YES; _switch.exclusiveTouch = YES;
switch_.accessibilityLabel = labelText; _switch.accessibilityLabel = labelText;
switch_.onTintColor = [[MDCPalette cr_bluePalette] tint500]; _switch.onTintColor = [[MDCPalette cr_bluePalette] tint500];
switch_.on = isOn; _switch.on = isOn;
// Computes the size and initializes the view. // Computes the size and initializes the view.
CGSize labelSize = self.label.frame.size; CGSize labelSize = self.label.frame.size;
CGSize switchSize = switch_.frame.size; CGSize switchSize = _switch.frame.size;
CGRect frameRect = CGRectMake( CGRect frameRect = CGRectMake(
0, 0, 0, 0,
labelSize.width + metrics_->space_between_widgets + switchSize.width, labelSize.width + _metrics->space_between_widgets + switchSize.width,
std::max(labelSize.height, switchSize.height)); std::max(labelSize.height, switchSize.height));
[self setFrame:frameRect]; [self setFrame:frameRect];
...@@ -244,30 +244,30 @@ UIImage* InfoBarCloseImage() { ...@@ -244,30 +244,30 @@ UIImage* InfoBarCloseImage() {
switchFrame = AlignRectOriginAndSizeToPixels(switchFrame); switchFrame = AlignRectOriginAndSizeToPixels(switchFrame);
[self.label setFrame:labelFrame]; [self.label setFrame:labelFrame];
[switch_ setFrame:switchFrame]; [_switch setFrame:switchFrame];
preferredTotalWidth_ = CGRectGetMaxX(switchFrame); _preferredTotalWidth = CGRectGetMaxX(switchFrame);
self.preferredLabelWidth = CGRectGetMaxX(labelFrame); self.preferredLabelWidth = CGRectGetMaxX(labelFrame);
[self addSubview:self.label]; [self addSubview:self.label];
[self addSubview:switch_]; [self addSubview:_switch];
return self; return self;
} }
- (void)setTag:(NSInteger)tag target:(id)target action:(SEL)action { - (void)setTag:(NSInteger)tag target:(id)target action:(SEL)action {
[switch_ setTag:tag]; [_switch setTag:tag];
[switch_ addTarget:target [_switch addTarget:target
action:action action:action
forControlEvents:UIControlEventValueChanged]; forControlEvents:UIControlEventValueChanged];
} }
- (CGFloat)heightRequiredForFooterWithWidth:(CGFloat)width layout:(BOOL)layout { - (CGFloat)heightRequiredForFooterWithWidth:(CGFloat)width layout:(BOOL)layout {
CGFloat widthLeftForLabel = CGFloat widthLeftForLabel =
width - [switch_ frame].size.width - metrics_->space_between_widgets; width - [_switch frame].size.width - _metrics->space_between_widgets;
CGSize maxSize = CGSizeMake(widthLeftForLabel, CGFLOAT_MAX); CGSize maxSize = CGSizeMake(widthLeftForLabel, CGFLOAT_MAX);
CGSize labelSize = CGSize labelSize =
[[self.label text] cr_boundingSizeWithSize:maxSize [[self.label text] cr_boundingSizeWithSize:maxSize
font:[self.label font]]; font:[self.label font]];
CGFloat viewHeight = std::max(labelSize.height, [switch_ frame].size.height); CGFloat viewHeight = std::max(labelSize.height, [_switch frame].size.height);
if (layout) { if (layout) {
// Lays out the label and the switch to fit in {width, viewHeight}. // Lays out the label and the switch to fit in {width, viewHeight}.
CGRect newLabelFrame; CGRect newLabelFrame;
...@@ -278,17 +278,17 @@ UIImage* InfoBarCloseImage() { ...@@ -278,17 +278,17 @@ UIImage* InfoBarCloseImage() {
[self.label setFrame:newLabelFrame]; [self.label setFrame:newLabelFrame];
CGRect newSwitchFrame; CGRect newSwitchFrame;
newSwitchFrame.origin.x = newSwitchFrame.origin.x =
CGRectGetMaxX(newLabelFrame) + metrics_->space_between_widgets; CGRectGetMaxX(newLabelFrame) + _metrics->space_between_widgets;
newSwitchFrame.origin.y = (viewHeight - [switch_ frame].size.height) / 2; newSwitchFrame.origin.y = (viewHeight - [_switch frame].size.height) / 2;
newSwitchFrame.size = [switch_ frame].size; newSwitchFrame.size = [_switch frame].size;
newSwitchFrame = AlignRectOriginAndSizeToPixels(newSwitchFrame); newSwitchFrame = AlignRectOriginAndSizeToPixels(newSwitchFrame);
[switch_ setFrame:newSwitchFrame]; [_switch setFrame:newSwitchFrame];
} }
return viewHeight; return viewHeight;
} }
- (CGFloat)preferredWidth { - (CGFloat)preferredWidth {
return preferredTotalWidth_; return _preferredTotalWidth;
} }
@end @end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment