Commit 2d2bc27e authored by Sylvain Defresne's avatar Sylvain Defresne Committed by Commit Bot

Remove dependency of //ios/chrome on GTMFadeTruncatingLabel

The omnibox already had a reimplentation of GTMFadeTruncatingLabel
that used NSAttributedText property to perform the fade-truncation
as OmniboxPopupTruncatingLabel.

Move it to a shared location and rename it to FadeTruncatingLabel
and convert TabView to use the new class thus removing another
dependency on third_party/google_toolbox_for_mac.

Before: https://drive.google.com/file/d/1YeEL6jkm-P9cNeEgS0vJxlPu-HIEo3_r/view
After:  https://drive.google.com/file/d/1U1jAVeXYg4RFiw98UzZ-yoBBoOG2e1MD/view

Bug: none
Change-Id: Ic43f0973d36ba6b74c0ad0a2fa9068d5a3be9bb1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1901082
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Auto-Submit: Sylvain Defresne <sdefresne@chromium.org>
Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713397}
parent 2c112e7e
...@@ -115,9 +115,9 @@ std::unique_ptr<net::test_server::HttpResponse> StandardResponse( ...@@ -115,9 +115,9 @@ std::unique_ptr<net::test_server::HttpResponse> StandardResponse(
// Open the suggestion. The suggestion needs to be the first suggestion to // Open the suggestion. The suggestion needs to be the first suggestion to
// have the prerenderer activated. // have the prerenderer activated.
[[EarlGrey [[EarlGrey
selectElementWithMatcher:grey_allOf(grey_accessibilityLabel(pageString), selectElementWithMatcher:grey_allOf(
grey_kindOfClassName( grey_accessibilityLabel(pageString),
@"OmniboxPopupTruncatingLabel"), grey_kindOfClassName(@"FadeTruncatingLabel"),
grey_ancestor(grey_accessibilityID( grey_ancestor(grey_accessibilityID(
@"omnibox suggestion 0")), @"omnibox suggestion 0")),
grey_sufficientlyVisible(), nil)] grey_sufficientlyVisible(), nil)]
......
...@@ -7,6 +7,8 @@ source_set("elements") { ...@@ -7,6 +7,8 @@ source_set("elements") {
sources = [ sources = [
"extended_touch_target_button.h", "extended_touch_target_button.h",
"extended_touch_target_button.mm", "extended_touch_target_button.mm",
"fade_truncating_label.h",
"fade_truncating_label.mm",
"gray_highlight_button.h", "gray_highlight_button.h",
"gray_highlight_button.mm", "gray_highlight_button.mm",
"selector_coordinator.h", "selector_coordinator.h",
......
...@@ -2,30 +2,28 @@ ...@@ -2,30 +2,28 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_OMNIBOX_POPUP_OMNIBOX_POPUP_TRUNCATING_LABEL_H_ #ifndef IOS_CHROME_BROWSER_UI_ELEMENTS_FADE_TRUNCATING_LABEL_H_
#define IOS_CHROME_BROWSER_UI_OMNIBOX_POPUP_OMNIBOX_POPUP_TRUNCATING_LABEL_H_ #define IOS_CHROME_BROWSER_UI_ELEMENTS_FADE_TRUNCATING_LABEL_H_
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
typedef enum { typedef enum {
OmniboxPopupTruncatingTail = 0x1, FadeTruncatingTail = 0x1,
OmniboxPopupTruncatingHead = 0x2, FadeTruncatingHead = 0x2,
OmniboxPopupTruncatingHeadAndTail = FadeTruncatingHeadAndTail = FadeTruncatingHead | FadeTruncatingTail
OmniboxPopupTruncatingHead | OmniboxPopupTruncatingTail } FadeTruncatingMode;
} OmniboxPopupTruncatingMode;
// A label which applies a fade-to-background color gradient to one or both ends // A label which applies a fade-to-background color gradient to one or both ends
// of the string if it is too large to fit the available area. It is based on // of the string if it is too large to fit the available area. It uses the
// GTMFadeTruncatingLabel but uses the attributedText property of UILabel rather // attributedText property of UILabel to implement the fading.
// than the text and font properties. @interface FadeTruncatingLabel : UILabel
@interface OmniboxPopupTruncatingLabel : UILabel
// Which side(s) to truncate. // Which side(s) to truncate.
@property(nonatomic, assign) OmniboxPopupTruncatingMode truncateMode; @property(nonatomic, assign) FadeTruncatingMode truncateMode;
// Whether the text being displayed should be treated as a URL. // Whether the text being displayed should be treated as a URL.
@property(nonatomic, assign) BOOL displayAsURL; @property(nonatomic, assign) BOOL displayAsURL;
@end @end
#endif // IOS_CHROME_BROWSER_UI_OMNIBOX_POPUP_OMNIBOX_POPUP_TRUNCATING_LABEL_H_ #endif // IOS_CHROME_BROWSER_UI_ELEMENTS_FADE_TRUNCATING_LABEL_H_
...@@ -2,28 +2,28 @@ ...@@ -2,28 +2,28 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#import "ios/chrome/browser/ui/omnibox/popup/omnibox_popup_truncating_label.h" #import "ios/chrome/browser/ui/elements/fade_truncating_label.h"
#include <algorithm> #include <algorithm>
#include "base/mac/scoped_cftyperef.h" #include "base/logging.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support." #error "This file requires ARC support."
#endif #endif
@interface OmniboxPopupTruncatingLabel () @interface FadeTruncatingLabel ()
// Gradient used to create fade effect. Changes based on view.frame size. // Gradient used to create fade effect. Changes based on view.frame size.
@property(nonatomic, strong) UIImage* gradient; @property(nonatomic, strong) UIImage* gradient;
@end @end
@implementation OmniboxPopupTruncatingLabel @implementation FadeTruncatingLabel
- (void)setup { - (void)setup {
self.backgroundColor = [UIColor clearColor]; self.backgroundColor = [UIColor clearColor];
_truncateMode = OmniboxPopupTruncatingTail; _truncateMode = FadeTruncatingTail;
} }
- (id)initWithFrame:(CGRect)frame { - (id)initWithFrame:(CGRect)frame {
...@@ -83,11 +83,11 @@ ...@@ -83,11 +83,11 @@
- (void)setTextAlignment:(NSTextAlignment)textAlignment { - (void)setTextAlignment:(NSTextAlignment)textAlignment {
if (textAlignment == NSTextAlignmentLeft) { if (textAlignment == NSTextAlignmentLeft) {
self.truncateMode = OmniboxPopupTruncatingTail; self.truncateMode = FadeTruncatingTail;
} else if (textAlignment == NSTextAlignmentRight) { } else if (textAlignment == NSTextAlignmentRight) {
self.truncateMode = OmniboxPopupTruncatingHead; self.truncateMode = FadeTruncatingHead;
} else if (textAlignment == NSTextAlignmentNatural) { } else if (textAlignment == NSTextAlignmentNatural) {
self.truncateMode = OmniboxPopupTruncatingTail; self.truncateMode = FadeTruncatingTail;
} else { } else {
NOTREACHED(); NOTREACHED();
} }
...@@ -103,7 +103,7 @@ ...@@ -103,7 +103,7 @@
// Create an opaque context. // Create an opaque context.
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray(); CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray();
CGContextRef context = CGContextRef context =
CGBitmapContextCreate(NULL, rect.size.width, rect.size.height, 8, CGBitmapContextCreate(nullptr, rect.size.width, rect.size.height, 8,
4 * rect.size.width, colorSpace, kCGImageAlphaNone); 4 * rect.size.width, colorSpace, kCGImageAlphaNone);
// White background will mask opaque, black gradient will mask transparent. // White background will mask opaque, black gradient will mask transparent.
...@@ -122,13 +122,13 @@ ...@@ -122,13 +122,13 @@
std::min(rect.size.height * 2, (CGFloat)floor(rect.size.width / 4)); std::min(rect.size.height * 2, (CGFloat)floor(rect.size.width / 4));
CGFloat minX = CGRectGetMinX(rect); CGFloat minX = CGRectGetMinX(rect);
CGFloat maxX = CGRectGetMaxX(rect); CGFloat maxX = CGRectGetMaxX(rect);
if (self.truncateMode & OmniboxPopupTruncatingTail) { if (self.truncateMode & FadeTruncatingTail) {
CGFloat startX = maxX - fadeWidth; CGFloat startX = maxX - fadeWidth;
CGPoint startPoint = CGPointMake(startX, CGRectGetMidY(rect)); CGPoint startPoint = CGPointMake(startX, CGRectGetMidY(rect));
CGPoint endPoint = CGPointMake(maxX, CGRectGetMidY(rect)); CGPoint endPoint = CGPointMake(maxX, CGRectGetMidY(rect));
CGContextDrawLinearGradient(context, gradient, startPoint, endPoint, 0); CGContextDrawLinearGradient(context, gradient, startPoint, endPoint, 0);
} }
if (self.truncateMode & OmniboxPopupTruncatingHead) { if (self.truncateMode & FadeTruncatingHead) {
CGFloat startX = minX + fadeWidth; CGFloat startX = minX + fadeWidth;
CGPoint startPoint = CGPointMake(startX, CGRectGetMidY(rect)); CGPoint startPoint = CGPointMake(startX, CGRectGetMidY(rect));
CGPoint endPoint = CGPointMake(minX, CGRectGetMidY(rect)); CGPoint endPoint = CGPointMake(minX, CGRectGetMidY(rect));
......
...@@ -74,8 +74,6 @@ source_set("popup_ui") { ...@@ -74,8 +74,6 @@ source_set("popup_ui") {
"omnibox_popup_row.mm", "omnibox_popup_row.mm",
"omnibox_popup_row_cell.h", "omnibox_popup_row_cell.h",
"omnibox_popup_row_cell.mm", "omnibox_popup_row_cell.mm",
"omnibox_popup_truncating_label.h",
"omnibox_popup_truncating_label.mm",
"omnibox_popup_view_controller.h", "omnibox_popup_view_controller.h",
"omnibox_popup_view_controller.mm", "omnibox_popup_view_controller.mm",
"self_sizing_table_view.h", "self_sizing_table_view.h",
......
...@@ -9,10 +9,10 @@ ...@@ -9,10 +9,10 @@
#include "base/ios/ios_util.h" #include "base/ios/ios_util.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#import "ios/chrome/browser/ui/elements/fade_truncating_label.h"
#import "ios/chrome/browser/ui/omnibox/omnibox_constants.h" #import "ios/chrome/browser/ui/omnibox/omnibox_constants.h"
#import "ios/chrome/browser/ui/omnibox/popup/image_retriever.h" #import "ios/chrome/browser/ui/omnibox/popup/image_retriever.h"
#import "ios/chrome/browser/ui/omnibox/popup/omnibox_popup_row.h" #import "ios/chrome/browser/ui/omnibox/popup/omnibox_popup_row.h"
#import "ios/chrome/browser/ui/omnibox/popup/omnibox_popup_truncating_label.h"
#import "ios/chrome/browser/ui/omnibox/popup/self_sizing_table_view.h" #import "ios/chrome/browser/ui/omnibox/popup/self_sizing_table_view.h"
#import "ios/chrome/browser/ui/toolbar/buttons/toolbar_configuration.h" #import "ios/chrome/browser/ui/toolbar/buttons/toolbar_configuration.h"
#include "ios/chrome/browser/ui/util/animation_util.h" #include "ios/chrome/browser/ui/util/animation_util.h"
...@@ -214,7 +214,7 @@ const CGFloat kAnswerRowHeight = 64.0; ...@@ -214,7 +214,7 @@ const CGFloat kAnswerRowHeight = 64.0;
[detailTextLabel setNeedsDisplay]; [detailTextLabel setNeedsDisplay];
OmniboxPopupTruncatingLabel* textLabel = row.textTruncatingLabel; FadeTruncatingLabel* textLabel = row.textTruncatingLabel;
[textLabel setTextAlignment:self.alignment]; [textLabel setTextAlignment:self.alignment];
LayoutRect textLabelLayout = LayoutRect textLabelLayout =
LayoutRectMake(kTextCellLeadingPadding, CGRectGetWidth(rowBounds), 0, LayoutRectMake(kTextCellLeadingPadding, CGRectGetWidth(rowBounds), 0,
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
@class OmniboxPopupTruncatingLabel; @class FadeTruncatingLabel;
@class OmniboxPopupRow; @class OmniboxPopupRow;
...@@ -23,11 +23,10 @@ ...@@ -23,11 +23,10 @@
@interface OmniboxPopupRow : UITableViewCell @interface OmniboxPopupRow : UITableViewCell
// A truncate-by-fading version of the textLabel of a UITableViewCell. // A truncate-by-fading version of the textLabel of a UITableViewCell.
@property(nonatomic, readonly, strong) @property(nonatomic, readonly, strong) FadeTruncatingLabel* textTruncatingLabel;
OmniboxPopupTruncatingLabel* textTruncatingLabel;
// A truncate-by-fading version of the detailTextLabel of a UITableViewCell. // A truncate-by-fading version of the detailTextLabel of a UITableViewCell.
@property(nonatomic, readonly, strong) @property(nonatomic, readonly, strong)
OmniboxPopupTruncatingLabel* detailTruncatingLabel; FadeTruncatingLabel* detailTruncatingLabel;
// A standard UILabel for answers, which truncates with ellipses to support // A standard UILabel for answers, which truncates with ellipses to support
// multi-line text. // multi-line text.
@property(nonatomic, readonly, strong) UILabel* detailAnswerLabel; @property(nonatomic, readonly, strong) UILabel* detailAnswerLabel;
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
#include "base/feature_list.h" #include "base/feature_list.h"
#include "base/logging.h" #include "base/logging.h"
#include "components/omnibox/common/omnibox_features.h" #include "components/omnibox/common/omnibox_features.h"
#import "ios/chrome/browser/ui/elements/fade_truncating_label.h"
#import "ios/chrome/browser/ui/omnibox/popup/omnibox_popup_accessibility_identifier_constants.h" #import "ios/chrome/browser/ui/omnibox/popup/omnibox_popup_accessibility_identifier_constants.h"
#import "ios/chrome/browser/ui/omnibox/popup/omnibox_popup_truncating_label.h"
#import "ios/chrome/browser/ui/toolbar/public/toolbar_constants.h" #import "ios/chrome/browser/ui/toolbar/public/toolbar_constants.h"
#include "ios/chrome/browser/ui/util/rtl_geometry.h" #include "ios/chrome/browser/ui/util/rtl_geometry.h"
#include "ios/chrome/browser/ui/util/ui_util.h" #include "ios/chrome/browser/ui/util/ui_util.h"
...@@ -63,12 +63,12 @@ const CGFloat kLeadingPaddingIpadCompact = 71; ...@@ -63,12 +63,12 @@ const CGFloat kLeadingPaddingIpadCompact = 71;
[UIColor colorNamed:kTableViewRowHighlightDarkColor]); [UIColor colorNamed:kTableViewRowHighlightDarkColor]);
_textTruncatingLabel = _textTruncatingLabel =
[[OmniboxPopupTruncatingLabel alloc] initWithFrame:CGRectZero]; [[FadeTruncatingLabel alloc] initWithFrame:CGRectZero];
_textTruncatingLabel.userInteractionEnabled = NO; _textTruncatingLabel.userInteractionEnabled = NO;
[self.contentView addSubview:_textTruncatingLabel]; [self.contentView addSubview:_textTruncatingLabel];
_detailTruncatingLabel = _detailTruncatingLabel =
[[OmniboxPopupTruncatingLabel alloc] initWithFrame:CGRectZero]; [[FadeTruncatingLabel alloc] initWithFrame:CGRectZero];
_detailTruncatingLabel.userInteractionEnabled = NO; _detailTruncatingLabel.userInteractionEnabled = NO;
[self.contentView addSubview:_detailTruncatingLabel]; [self.contentView addSubview:_detailTruncatingLabel];
......
...@@ -9,9 +9,9 @@ ...@@ -9,9 +9,9 @@
#include "components/omnibox/common/omnibox_features.h" #include "components/omnibox/common/omnibox_features.h"
#import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h" #import "ios/chrome/browser/ui/colors/MDCPalette+CrAdditions.h"
#import "ios/chrome/browser/ui/elements/extended_touch_target_button.h" #import "ios/chrome/browser/ui/elements/extended_touch_target_button.h"
#import "ios/chrome/browser/ui/elements/fade_truncating_label.h"
#import "ios/chrome/browser/ui/omnibox/popup/autocomplete_suggestion.h" #import "ios/chrome/browser/ui/omnibox/popup/autocomplete_suggestion.h"
#import "ios/chrome/browser/ui/omnibox/popup/omnibox_icon_view.h" #import "ios/chrome/browser/ui/omnibox/popup/omnibox_icon_view.h"
#import "ios/chrome/browser/ui/omnibox/popup/omnibox_popup_truncating_label.h"
#import "ios/chrome/browser/ui/toolbar/public/toolbar_constants.h" #import "ios/chrome/browser/ui/toolbar/public/toolbar_constants.h"
#import "ios/chrome/browser/ui/util/named_guide.h" #import "ios/chrome/browser/ui/util/named_guide.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h" #import "ios/chrome/browser/ui/util/uikit_ui_util.h"
...@@ -45,9 +45,9 @@ NSString* const kOmniboxPopupRowSwitchTabAccessibilityIdentifier = ...@@ -45,9 +45,9 @@ NSString* const kOmniboxPopupRowSwitchTabAccessibilityIdentifier =
// Stack view containing all text labels. // Stack view containing all text labels.
@property(nonatomic, strong) UIStackView* textStackView; @property(nonatomic, strong) UIStackView* textStackView;
// Truncating label for the main text. // Truncating label for the main text.
@property(nonatomic, strong) OmniboxPopupTruncatingLabel* textTruncatingLabel; @property(nonatomic, strong) FadeTruncatingLabel* textTruncatingLabel;
// Truncating label for the detail text. // Truncating label for the detail text.
@property(nonatomic, strong) OmniboxPopupTruncatingLabel* detailTruncatingLabel; @property(nonatomic, strong) FadeTruncatingLabel* detailTruncatingLabel;
// Regular UILabel for the detail text when the suggestion is an answer. // Regular UILabel for the detail text when the suggestion is an answer.
// Answers have slightly different display requirements, like possibility of // Answers have slightly different display requirements, like possibility of
// multiple lines and truncating with ellipses instead of a fade gradient. // multiple lines and truncating with ellipses instead of a fade gradient.
...@@ -74,7 +74,7 @@ NSString* const kOmniboxPopupRowSwitchTabAccessibilityIdentifier = ...@@ -74,7 +74,7 @@ NSString* const kOmniboxPopupRowSwitchTabAccessibilityIdentifier =
[UIColor colorNamed:kTableViewRowHighlightDarkColor]); [UIColor colorNamed:kTableViewRowHighlightDarkColor]);
_textTruncatingLabel = _textTruncatingLabel =
[[OmniboxPopupTruncatingLabel alloc] initWithFrame:CGRectZero]; [[FadeTruncatingLabel alloc] initWithFrame:CGRectZero];
_textTruncatingLabel.translatesAutoresizingMaskIntoConstraints = NO; _textTruncatingLabel.translatesAutoresizingMaskIntoConstraints = NO;
[_textTruncatingLabel [_textTruncatingLabel
setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh + 1 setContentCompressionResistancePriority:UILayoutPriorityDefaultHigh + 1
...@@ -87,7 +87,7 @@ NSString* const kOmniboxPopupRowSwitchTabAccessibilityIdentifier = ...@@ -87,7 +87,7 @@ NSString* const kOmniboxPopupRowSwitchTabAccessibilityIdentifier =
_textStackView.alignment = UIStackViewAlignmentLeading; _textStackView.alignment = UIStackViewAlignmentLeading;
_detailTruncatingLabel = _detailTruncatingLabel =
[[OmniboxPopupTruncatingLabel alloc] initWithFrame:CGRectZero]; [[FadeTruncatingLabel alloc] initWithFrame:CGRectZero];
_detailTruncatingLabel.translatesAutoresizingMaskIntoConstraints = NO; _detailTruncatingLabel.translatesAutoresizingMaskIntoConstraints = NO;
// Answers use a UILabel with NSLineBreakByTruncatingTail to produce a // Answers use a UILabel with NSLineBreakByTruncatingTail to produce a
......
...@@ -48,6 +48,7 @@ source_set("tabs") { ...@@ -48,6 +48,7 @@ source_set("tabs") {
"//ios/chrome/browser/ui/bubble", "//ios/chrome/browser/ui/bubble",
"//ios/chrome/browser/ui/colors", "//ios/chrome/browser/ui/colors",
"//ios/chrome/browser/ui/commands", "//ios/chrome/browser/ui/commands",
"//ios/chrome/browser/ui/elements",
"//ios/chrome/browser/ui/favicon/resources:default_world_favicon", "//ios/chrome/browser/ui/favicon/resources:default_world_favicon",
"//ios/chrome/browser/ui/fullscreen", "//ios/chrome/browser/ui/fullscreen",
"//ios/chrome/browser/ui/image_util", "//ios/chrome/browser/ui/image_util",
...@@ -64,7 +65,6 @@ source_set("tabs") { ...@@ -64,7 +65,6 @@ source_set("tabs") {
"//ios/chrome/common/ui_util", "//ios/chrome/common/ui_util",
"//ios/third_party/material_components_ios", "//ios/third_party/material_components_ios",
"//ios/web", "//ios/web",
"//third_party/google_toolbox_for_mac",
"//ui/base", "//ui/base",
"//ui/gfx", "//ui/gfx",
] ]
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "ios/chrome/browser/drag_and_drop/drop_and_navigate_delegate.h" #include "ios/chrome/browser/drag_and_drop/drop_and_navigate_delegate.h"
#include "ios/chrome/browser/drag_and_drop/drop_and_navigate_interaction.h" #include "ios/chrome/browser/drag_and_drop/drop_and_navigate_interaction.h"
#include "ios/chrome/browser/system_flags.h" #include "ios/chrome/browser/system_flags.h"
#import "ios/chrome/browser/ui/elements/fade_truncating_label.h"
#import "ios/chrome/browser/ui/image_util/image_util.h" #import "ios/chrome/browser/ui/image_util/image_util.h"
#include "ios/chrome/browser/ui/util/rtl_geometry.h" #include "ios/chrome/browser/ui/util/rtl_geometry.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h" #import "ios/chrome/browser/ui/util/uikit_ui_util.h"
...@@ -22,7 +23,6 @@ ...@@ -22,7 +23,6 @@
#import "ios/chrome/common/ui_util/constraints_ui_util.h" #import "ios/chrome/common/ui_util/constraints_ui_util.h"
#include "ios/chrome/grit/ios_strings.h" #include "ios/chrome/grit/ios_strings.h"
#import "ios/third_party/material_components_ios/src/components/ActivityIndicator/src/MaterialActivityIndicator.h" #import "ios/third_party/material_components_ios/src/components/ActivityIndicator/src/MaterialActivityIndicator.h"
#include "third_party/google_toolbox_for_mac/src/iPhone/GTMFadeTruncatingLabel.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/l10n/l10n_util_mac.h" #include "ui/base/l10n/l10n_util_mac.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
...@@ -70,7 +70,7 @@ UIImage* DefaultFaviconImage() { ...@@ -70,7 +70,7 @@ UIImage* DefaultFaviconImage() {
UIButton* _closeButton; UIButton* _closeButton;
// View that draws the tab title. // View that draws the tab title.
GTMFadeTruncatingLabel* _titleLabel; FadeTruncatingLabel* _titleLabel;
// Background image for this tab. // Background image for this tab.
UIImageView* _backgroundImageView; UIImageView* _backgroundImageView;
...@@ -157,9 +157,9 @@ UIImage* DefaultFaviconImage() { ...@@ -157,9 +157,9 @@ UIImage* DefaultFaviconImage() {
return; return;
if (base::i18n::GetStringDirection(base::SysNSStringToUTF16(title)) == if (base::i18n::GetStringDirection(base::SysNSStringToUTF16(title)) ==
base::i18n::RIGHT_TO_LEFT) { base::i18n::RIGHT_TO_LEFT) {
[_titleLabel setTruncateMode:GTMFadeTruncatingHead]; _titleLabel.truncateMode = FadeTruncatingHead;
} else { } else {
[_titleLabel setTruncateMode:GTMFadeTruncatingTail]; _titleLabel.truncateMode = FadeTruncatingTail;
} }
_titleLabel.text = title; _titleLabel.text = title;
[_closeButton setAccessibilityValue:title]; [_closeButton setAccessibilityValue:title];
...@@ -301,15 +301,8 @@ UIImage* DefaultFaviconImage() { ...@@ -301,15 +301,8 @@ UIImage* DefaultFaviconImage() {
[self addSubview:_closeButton]; [self addSubview:_closeButton];
// Add fade truncating label. // Add fade truncating label.
_titleLabel = [[GTMFadeTruncatingLabel alloc] initWithFrame:CGRectZero]; _titleLabel = [[FadeTruncatingLabel alloc] initWithFrame:CGRectZero];
[_titleLabel setTranslatesAutoresizingMaskIntoConstraints:NO]; [_titleLabel setTranslatesAutoresizingMaskIntoConstraints:NO];
// Setting NSLineBreakByCharWrapping fixes an issue where the beginning of the
// text is truncated for RTL text writing direction. Anyway since the label is
// only one line and the end of the text is faded behind a gradient mask, it
// is visually almost equivalent to NSLineBreakByClipping.
[_titleLabel setLineBreakMode:NSLineBreakByCharWrapping];
[_titleLabel setTextAlignment:NSTextAlignmentNatural]; [_titleLabel setTextAlignment:NSTextAlignmentNatural];
[self addSubview:_titleLabel]; [self addSubview:_titleLabel];
......
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