| OLD | NEW |
| 1 | 1 |
| 2 // Copyright 2012 The Chromium Authors. All rights reserved. | 2 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
| 4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
| 5 | 5 |
| 6 #import "ios/chrome/browser/ui/tabs/tab_view.h" | 6 #import "ios/chrome/browser/ui/tabs/tab_view.h" |
| 7 | 7 |
| 8 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
| 9 #include "base/ios/ios_util.h" | 9 #include "base/ios/ios_util.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/mac/objc_release_properties.h" | 11 #include "base/mac/objc_property_releaser.h" |
| 12 #include "base/strings/sys_string_conversions.h" | 12 #include "base/strings/sys_string_conversions.h" |
| 13 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" | 13 #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" |
| 14 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" | 14 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" |
| 15 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" | 15 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" |
| 16 #import "ios/chrome/browser/ui/image_util.h" | 16 #import "ios/chrome/browser/ui/image_util.h" |
| 17 #include "ios/chrome/browser/ui/rtl_geometry.h" | 17 #include "ios/chrome/browser/ui/rtl_geometry.h" |
| 18 #include "ios/chrome/browser/ui/ui_util.h" | 18 #include "ios/chrome/browser/ui/ui_util.h" |
| 19 #import "ios/chrome/browser/ui/uikit_ui_util.h" | 19 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
| 20 #include "ios/chrome/grit/ios_strings.h" | 20 #include "ios/chrome/grit/ios_strings.h" |
| 21 #import "ios/third_party/material_components_ios/src/components/ActivityIndicato
r/src/MaterialActivityIndicator.h" | 21 #import "ios/third_party/material_components_ios/src/components/ActivityIndicato
r/src/MaterialActivityIndicator.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 // Set to YES when the layout constraints have been initialized. | 65 // Set to YES when the layout constraints have been initialized. |
| 66 BOOL _layoutConstraintsInitialized; | 66 BOOL _layoutConstraintsInitialized; |
| 67 | 67 |
| 68 // Image view used to draw the favicon and spinner. | 68 // Image view used to draw the favicon and spinner. |
| 69 base::scoped_nsobject<UIImageView> _faviconView; | 69 base::scoped_nsobject<UIImageView> _faviconView; |
| 70 | 70 |
| 71 // If |YES|, this view will adjust its appearance and draw as a collapsed tab. | 71 // If |YES|, this view will adjust its appearance and draw as a collapsed tab. |
| 72 BOOL _collapsed; | 72 BOOL _collapsed; |
| 73 | 73 |
| 74 base::scoped_nsobject<MDCActivityIndicator> _activityIndicator; | 74 base::scoped_nsobject<MDCActivityIndicator> _activityIndicator; |
| 75 |
| 76 base::mac::ObjCPropertyReleaser _propertyReleaser_TabView; |
| 75 } | 77 } |
| 76 @end | 78 @end |
| 77 | 79 |
| 78 @interface TabView (Private) | 80 @interface TabView (Private) |
| 79 | 81 |
| 80 // Creates the close button, favicon button, and title. | 82 // Creates the close button, favicon button, and title. |
| 81 - (void)createButtonsAndLabel; | 83 - (void)createButtonsAndLabel; |
| 82 | 84 |
| 83 // Updates this tab's line separator color based on the current incognito style. | 85 // Updates this tab's line separator color based on the current incognito style. |
| 84 - (void)updateLineSeparator; | 86 - (void)updateLineSeparator; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 106 @implementation TabView | 108 @implementation TabView |
| 107 | 109 |
| 108 @synthesize closeButton = _closeButton; | 110 @synthesize closeButton = _closeButton; |
| 109 @synthesize titleLabel = _titleLabel; | 111 @synthesize titleLabel = _titleLabel; |
| 110 @synthesize collapsed = _collapsed; | 112 @synthesize collapsed = _collapsed; |
| 111 @synthesize background = background_; | 113 @synthesize background = background_; |
| 112 @synthesize incognitoStyle = _incognitoStyle; | 114 @synthesize incognitoStyle = _incognitoStyle; |
| 113 | 115 |
| 114 - (id)initWithEmptyView:(BOOL)emptyView selected:(BOOL)selected { | 116 - (id)initWithEmptyView:(BOOL)emptyView selected:(BOOL)selected { |
| 115 if ((self = [super initWithFrame:CGRectZero])) { | 117 if ((self = [super initWithFrame:CGRectZero])) { |
| 118 _propertyReleaser_TabView.Init(self, [TabView class]); |
| 116 [self setOpaque:NO]; | 119 [self setOpaque:NO]; |
| 117 [self createCommonViews]; | 120 [self createCommonViews]; |
| 118 // -setSelected only calls -updateBackgroundImage if the selected state | 121 // -setSelected only calls -updateBackgroundImage if the selected state |
| 119 // changes. |isSelected| defaults to NO, so if |selected| is also NO, | 122 // changes. |isSelected| defaults to NO, so if |selected| is also NO, |
| 120 // -updateBackgroundImage needs to be called explicitly. | 123 // -updateBackgroundImage needs to be called explicitly. |
| 121 [self setSelected:selected]; | 124 [self setSelected:selected]; |
| 122 [self updateLineSeparator]; | 125 [self updateLineSeparator]; |
| 123 [self updateBackgroundImage:selected]; | 126 [self updateBackgroundImage:selected]; |
| 124 if (!emptyView) | 127 if (!emptyView) |
| 125 [self createButtonsAndLabel]; | 128 [self createButtonsAndLabel]; |
| 126 } | 129 } |
| 127 return self; | 130 return self; |
| 128 } | 131 } |
| 129 | 132 |
| 130 - (void)dealloc { | |
| 131 base::mac::ReleaseProperties(self); | |
| 132 [super dealloc]; | |
| 133 } | |
| 134 | |
| 135 - (void)setSelected:(BOOL)selected { | 133 - (void)setSelected:(BOOL)selected { |
| 136 BOOL wasSelected = [self isSelected]; | 134 BOOL wasSelected = [self isSelected]; |
| 137 [super setSelected:selected]; | 135 [super setSelected:selected]; |
| 138 | 136 |
| 139 [_lineSeparator setHidden:selected]; | 137 [_lineSeparator setHidden:selected]; |
| 140 | 138 |
| 141 if (selected != wasSelected) | 139 if (selected != wasSelected) |
| 142 [self updateBackgroundImage:selected]; | 140 [self updateBackgroundImage:selected]; |
| 143 | 141 |
| 144 // It would make more sense to set active/inactive on tab_view itself, but | 142 // It would make more sense to set active/inactive on tab_view itself, but |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 [_closeButton setImage:normalImage forState:UIControlStateNormal]; | 370 [_closeButton setImage:normalImage forState:UIControlStateNormal]; |
| 373 [_closeButton setImage:pressedImage forState:UIControlStateHighlighted]; | 371 [_closeButton setImage:pressedImage forState:UIControlStateHighlighted]; |
| 374 } | 372 } |
| 375 | 373 |
| 376 - (UIImage*)defaultFaviconImage { | 374 - (UIImage*)defaultFaviconImage { |
| 377 return self.incognitoStyle ? [UIImage imageNamed:@"default_favicon_incognito"] | 375 return self.incognitoStyle ? [UIImage imageNamed:@"default_favicon_incognito"] |
| 378 : [UIImage imageNamed:@"default_favicon"]; | 376 : [UIImage imageNamed:@"default_favicon"]; |
| 379 } | 377 } |
| 380 | 378 |
| 381 @end | 379 @end |
| OLD | NEW |