Commit 388bce86 authored by Daniel Bratell's avatar Daniel Bratell Committed by Commit Bot

Manually inline the IsTouchOptimized method to avoid jumbo clashes

There is a common helper method IsTouchOptimized() that is a shortening
of ui::MaterialDesignController::IsTouchOptimizedUiEnabled(). That
helper method is placed in anonymous namespaces which are merged in
jumbo builds, causing clashes.

Alternatives are to find a shared location for this method (maybe in
//ui?) or inline it. This patch inlines it.

Bug: 803406
Change-Id: Ia389432bfdb506d27b625c916a9baf73b7b70f30
Reviewed-on: https://chromium-review.googlesource.com/966204Reviewed-by: default avatarBret Sepulveda <bsep@chromium.org>
Commit-Queue: Daniel Bratell <bratell@opera.com>
Cr-Commit-Position: refs/heads/master@{#543939}
parent 26b852aa
...@@ -165,12 +165,8 @@ gfx::ImageSkia* GetImageSkiaNamed(int id) { ...@@ -165,12 +165,8 @@ gfx::ImageSkia* GetImageSkiaNamed(int id) {
return ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(id); return ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(id);
} }
bool IsTouchOptimized() {
return ui::MaterialDesignController::IsTouchOptimizedUiEnabled();
}
int GetInkDropCornerRadius() { int GetInkDropCornerRadius() {
return IsTouchOptimized() ? 4 : 2; return ui::MaterialDesignController::IsTouchOptimizedUiEnabled() ? 4 : 2;
} }
gfx::Insets GetInkDropInsets() { gfx::Insets GetInkDropInsets() {
...@@ -178,11 +174,13 @@ gfx::Insets GetInkDropInsets() { ...@@ -178,11 +174,13 @@ gfx::Insets GetInkDropInsets() {
// vertically so that they do not touch the bookmark bar borders. // vertically so that they do not touch the bookmark bar borders.
// TODO(estade): currently this is used as DIP rather than pixels. This // TODO(estade): currently this is used as DIP rather than pixels. This
// should be fixed: see https://crbug.com/706228 // should be fixed: see https://crbug.com/706228
return IsTouchOptimized() ? gfx::Insets(3, 3) : gfx::Insets(1, 0); return ui::MaterialDesignController::IsTouchOptimizedUiEnabled()
? gfx::Insets(3, 3)
: gfx::Insets(1, 0);
} }
SkColor GetBookmarkButtonInkDropBaseColor(const ui::ThemeProvider* tp) { SkColor GetBookmarkButtonInkDropBaseColor(const ui::ThemeProvider* tp) {
if (IsTouchOptimized()) { if (ui::MaterialDesignController::IsTouchOptimizedUiEnabled()) {
return color_utils::BlendTowardOppositeLuma( return color_utils::BlendTowardOppositeLuma(
tp->GetColor(ThemeProperties::COLOR_TOOLBAR), SK_AlphaOPAQUE); tp->GetColor(ThemeProperties::COLOR_TOOLBAR), SK_AlphaOPAQUE);
} }
...@@ -217,7 +215,7 @@ std::unique_ptr<views::InkDropHighlight> CreateBookmarkButtonInkDropHighlight( ...@@ -217,7 +215,7 @@ std::unique_ptr<views::InkDropHighlight> CreateBookmarkButtonInkDropHighlight(
host_view->size(), GetInkDropCornerRadius(), host_view->size(), GetInkDropCornerRadius(),
gfx::RectF(gfx::Rect(host_view->size())).CenterPoint(), gfx::RectF(gfx::Rect(host_view->size())).CenterPoint(),
GetBookmarkButtonInkDropBaseColor(host_view->GetThemeProvider()))); GetBookmarkButtonInkDropBaseColor(host_view->GetThemeProvider())));
if (IsTouchOptimized()) if (ui::MaterialDesignController::IsTouchOptimizedUiEnabled())
highlight->set_visible_opacity(kTouchToolbarHighlightVisibleOpacity); highlight->set_visible_opacity(kTouchToolbarHighlightVisibleOpacity);
return highlight; return highlight;
} }
...@@ -236,7 +234,7 @@ class BookmarkButtonBase : public views::LabelButton { ...@@ -236,7 +234,7 @@ class BookmarkButtonBase : public views::LabelButton {
SetElideBehavior(kElideBehavior); SetElideBehavior(kElideBehavior);
SetInkDropMode(InkDropMode::ON); SetInkDropMode(InkDropMode::ON);
set_has_ink_drop_action_on_click(true); set_has_ink_drop_action_on_click(true);
if (IsTouchOptimized()) if (ui::MaterialDesignController::IsTouchOptimizedUiEnabled())
set_ink_drop_visible_opacity(kTouchToolbarInkDropVisibleOpacity); set_ink_drop_visible_opacity(kTouchToolbarInkDropVisibleOpacity);
SetFocusPainter(nullptr); SetFocusPainter(nullptr);
show_animation_.reset(new gfx::SlideAnimation(this)); show_animation_.reset(new gfx::SlideAnimation(this));
...@@ -373,7 +371,7 @@ class BookmarkMenuButtonBase : public views::MenuButton { ...@@ -373,7 +371,7 @@ class BookmarkMenuButtonBase : public views::MenuButton {
SetImageLabelSpacing(ChromeLayoutProvider::Get()->GetDistanceMetric( SetImageLabelSpacing(ChromeLayoutProvider::Get()->GetDistanceMetric(
DISTANCE_RELATED_LABEL_HORIZONTAL_LIST)); DISTANCE_RELATED_LABEL_HORIZONTAL_LIST));
SetInkDropMode(InkDropMode::ON); SetInkDropMode(InkDropMode::ON);
if (IsTouchOptimized()) if (ui::MaterialDesignController::IsTouchOptimizedUiEnabled())
set_ink_drop_visible_opacity(kTouchToolbarInkDropVisibleOpacity); set_ink_drop_visible_opacity(kTouchToolbarInkDropVisibleOpacity);
SetFocusPainter(nullptr); SetFocusPainter(nullptr);
} }
...@@ -1739,7 +1737,8 @@ void BookmarkBarView::ConfigureButton(const BookmarkNode* node, ...@@ -1739,7 +1737,8 @@ void BookmarkBarView::ConfigureButton(const BookmarkNode* node,
bool themify_icon = node->url().SchemeIs(content::kChromeUIScheme); bool themify_icon = node->url().SchemeIs(content::kChromeUIScheme);
gfx::ImageSkia favicon = model_->GetFavicon(node).AsImageSkia(); gfx::ImageSkia favicon = model_->GetFavicon(node).AsImageSkia();
if (favicon.isNull()) { if (favicon.isNull()) {
if (IsTouchOptimized() && GetThemeProvider()) { if (ui::MaterialDesignController::IsTouchOptimizedUiEnabled() &&
GetThemeProvider()) {
// This favicon currently does not match the default favicon icon used // This favicon currently does not match the default favicon icon used
// elsewhere in the codebase. // elsewhere in the codebase.
// See https://crbug/814447 // See https://crbug/814447
...@@ -2067,9 +2066,11 @@ void BookmarkBarView::UpdateAppearanceForTheme() { ...@@ -2067,9 +2066,11 @@ void BookmarkBarView::UpdateAppearanceForTheme() {
theme_provider->GetColor(ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON); theme_provider->GetColor(ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON);
overflow_button_->SetImage( overflow_button_->SetImage(
views::Button::STATE_NORMAL, views::Button::STATE_NORMAL,
gfx::CreateVectorIcon(IsTouchOptimized() ? kBookmarkbarTouchOverflowIcon gfx::CreateVectorIcon(
: kOverflowChevronIcon, ui::MaterialDesignController::IsTouchOptimizedUiEnabled()
overflow_color)); ? kBookmarkbarTouchOverflowIcon
: kOverflowChevronIcon,
overflow_color));
// Redraw the background. // Redraw the background.
SchedulePaint(); SchedulePaint();
......
...@@ -61,11 +61,6 @@ sk_sp<SkDrawLooper> CreateShadowDrawLooper(SkColor color) { ...@@ -61,11 +61,6 @@ sk_sp<SkDrawLooper> CreateShadowDrawLooper(SkColor color) {
return looper_builder.detach(); return looper_builder.detach();
} }
// Returns true if the touch-optimized UI is enabled.
bool IsTouchOptimized() {
return ui::MaterialDesignController::IsTouchOptimizedUiEnabled();
}
} // namespace } // namespace
NewTabButton::NewTabButton(TabStrip* tab_strip, views::ButtonListener* listener) NewTabButton::NewTabButton(TabStrip* tab_strip, views::ButtonListener* listener)
...@@ -78,7 +73,7 @@ NewTabButton::NewTabButton(TabStrip* tab_strip, views::ButtonListener* listener) ...@@ -78,7 +73,7 @@ NewTabButton::NewTabButton(TabStrip* tab_strip, views::ButtonListener* listener)
ui::EF_MIDDLE_MOUSE_BUTTON); ui::EF_MIDDLE_MOUSE_BUTTON);
#endif #endif
if (IsTouchOptimized()) { if (ui::MaterialDesignController::IsTouchOptimizedUiEnabled()) {
// Initialize the ink drop mode for a ripple highlight on button press. // Initialize the ink drop mode for a ripple highlight on button press.
ink_drop_container_ = new views::InkDropContainerView(); ink_drop_container_ = new views::InkDropContainerView();
AddChildView(ink_drop_container_); AddChildView(ink_drop_container_);
...@@ -104,7 +99,7 @@ int NewTabButton::GetTopOffset() { ...@@ -104,7 +99,7 @@ int NewTabButton::GetTopOffset() {
// In touch-optimized UI, the button is placed vertically exactly in the // In touch-optimized UI, the button is placed vertically exactly in the
// center of the tabstrip. // center of the tabstrip.
if (IsTouchOptimized()) if (ui::MaterialDesignController::IsTouchOptimizedUiEnabled())
return extra_vertical_space / 2; return extra_vertical_space / 2;
// In the non-touch-optimized UI, the new tab button is placed at a fixed // In the non-touch-optimized UI, the new tab button is placed at a fixed
...@@ -220,7 +215,8 @@ void NewTabButton::PaintButtonContents(gfx::Canvas* canvas) { ...@@ -220,7 +215,8 @@ void NewTabButton::PaintButtonContents(gfx::Canvas* canvas) {
// Fill. // Fill.
SkPath fill; SkPath fill;
const bool is_touch_ui = IsTouchOptimized(); const bool is_touch_ui =
ui::MaterialDesignController::IsTouchOptimizedUiEnabled();
if (is_touch_ui) { if (is_touch_ui) {
fill = GetTouchOptimizedButtonPath(0 /* button_y */, scale, fill = GetTouchOptimizedButtonPath(0 /* button_y */, scale,
true /* for_fill */); true /* for_fill */);
...@@ -316,7 +312,7 @@ void NewTabButton::PaintButtonContents(gfx::Canvas* canvas) { ...@@ -316,7 +312,7 @@ void NewTabButton::PaintButtonContents(gfx::Canvas* canvas) {
void NewTabButton::Layout() { void NewTabButton::Layout() {
ImageButton::Layout(); ImageButton::Layout();
if (IsTouchOptimized()) { if (ui::MaterialDesignController::IsTouchOptimizedUiEnabled()) {
// If icons are not initialized, initialize them now. Icons are always // If icons are not initialized, initialize them now. Icons are always
// initialized together so it's enough to check the |plus_icon_|. // initialized together so it's enough to check the |plus_icon_|.
if (plus_icon_.isNull()) if (plus_icon_.isNull())
...@@ -331,7 +327,7 @@ void NewTabButton::Layout() { ...@@ -331,7 +327,7 @@ void NewTabButton::Layout() {
void NewTabButton::OnThemeChanged() { void NewTabButton::OnThemeChanged() {
ImageButton::OnThemeChanged(); ImageButton::OnThemeChanged();
if (!IsTouchOptimized()) if (!ui::MaterialDesignController::IsTouchOptimizedUiEnabled())
return; return;
InitButtonIcons(); InitButtonIcons();
...@@ -380,7 +376,7 @@ void NewTabButton::GetBorderPath(float button_y, ...@@ -380,7 +376,7 @@ void NewTabButton::GetBorderPath(float button_y,
float scale, float scale,
bool extend_to_top, bool extend_to_top,
SkPath* path) const { SkPath* path) const {
if (IsTouchOptimized()) { if (ui::MaterialDesignController::IsTouchOptimizedUiEnabled()) {
*path = GetTouchOptimizedButtonPath(button_y, scale, false /* for_fill */); *path = GetTouchOptimizedButtonPath(button_y, scale, false /* for_fill */);
return; return;
} }
...@@ -433,7 +429,8 @@ void NewTabButton::PaintFill(bool pressed, ...@@ -433,7 +429,8 @@ void NewTabButton::PaintFill(bool pressed,
// For unpressed buttons, draw the fill and its shadow. // For unpressed buttons, draw the fill and its shadow.
// Note that for touch-optimized UI, we always draw the fill since the button // Note that for touch-optimized UI, we always draw the fill since the button
// has a flat design with no hover highlight. // has a flat design with no hover highlight.
const bool is_touch_ui = IsTouchOptimized(); const bool is_touch_ui =
ui::MaterialDesignController::IsTouchOptimizedUiEnabled();
if (is_touch_ui || !pressed) { if (is_touch_ui || !pressed) {
// First we compute the background image coordinates and scale, in case we // First we compute the background image coordinates and scale, in case we
// need to draw a custom background image. // need to draw a custom background image.
...@@ -510,7 +507,7 @@ SkColor NewTabButton::GetButtonFillColor() const { ...@@ -510,7 +507,7 @@ SkColor NewTabButton::GetButtonFillColor() const {
} }
void NewTabButton::InitButtonIcons() { void NewTabButton::InitButtonIcons() {
DCHECK(IsTouchOptimized()); DCHECK(ui::MaterialDesignController::IsTouchOptimizedUiEnabled());
const ui::ThemeProvider* theme_provider = GetThemeProvider(); const ui::ThemeProvider* theme_provider = GetThemeProvider();
DCHECK(theme_provider); DCHECK(theme_provider);
...@@ -526,7 +523,7 @@ void NewTabButton::InitButtonIcons() { ...@@ -526,7 +523,7 @@ void NewTabButton::InitButtonIcons() {
SkPath NewTabButton::GetTouchOptimizedButtonPath(float button_y, SkPath NewTabButton::GetTouchOptimizedButtonPath(float button_y,
float scale, float scale,
bool for_fill) const { bool for_fill) const {
DCHECK(IsTouchOptimized()); DCHECK(ui::MaterialDesignController::IsTouchOptimizedUiEnabled());
const float radius = kButtonCornerRadius * scale; const float radius = kButtonCornerRadius * scale;
const float rect_width = const float rect_width =
...@@ -549,7 +546,7 @@ SkPath NewTabButton::GetTouchOptimizedButtonPath(float button_y, ...@@ -549,7 +546,7 @@ SkPath NewTabButton::GetTouchOptimizedButtonPath(float button_y,
} }
void NewTabButton::UpdateInkDropBaseColor() { void NewTabButton::UpdateInkDropBaseColor() {
DCHECK(IsTouchOptimized()); DCHECK(ui::MaterialDesignController::IsTouchOptimizedUiEnabled());
set_ink_drop_base_color(color_utils::BlendTowardOppositeLuma( set_ink_drop_base_color(color_utils::BlendTowardOppositeLuma(
GetButtonFillColor(), SK_AlphaOPAQUE)); GetButtonFillColor(), SK_AlphaOPAQUE));
......
...@@ -45,11 +45,6 @@ namespace { ...@@ -45,11 +45,6 @@ namespace {
constexpr base::TimeDelta kDelayTime = base::TimeDelta::FromMilliseconds(1500); constexpr base::TimeDelta kDelayTime = base::TimeDelta::FromMilliseconds(1500);
// Returns true if the touch-optimized UI is enabled.
bool IsTouchOptimized() {
return ui::MaterialDesignController::IsTouchOptimizedUiEnabled();
}
} // namespace } // namespace
// static // static
...@@ -75,7 +70,7 @@ AppMenuButton::AppMenuButton(ToolbarView* toolbar_view) ...@@ -75,7 +70,7 @@ AppMenuButton::AppMenuButton(ToolbarView* toolbar_view)
features::kAnimatedAppMenuIcon, "HasDelay", false); features::kAnimatedAppMenuIcon, "HasDelay", false);
} }
if (IsTouchOptimized()) if (ui::MaterialDesignController::IsTouchOptimizedUiEnabled())
set_ink_drop_visible_opacity(kTouchToolbarInkDropVisibleOpacity); set_ink_drop_visible_opacity(kTouchToolbarInkDropVisibleOpacity);
} }
...@@ -160,7 +155,8 @@ void AppMenuButton::RemoveMenuListener(views::MenuListener* listener) { ...@@ -160,7 +155,8 @@ void AppMenuButton::RemoveMenuListener(views::MenuListener* listener) {
} }
gfx::Size AppMenuButton::CalculatePreferredSize() const { gfx::Size AppMenuButton::CalculatePreferredSize() const {
const int icon_size = IsTouchOptimized() ? 24 : 16; const int icon_size =
ui::MaterialDesignController::IsTouchOptimizedUiEnabled() ? 24 : 16;
gfx::Rect rect(gfx::Size(icon_size, icon_size)); gfx::Rect rect(gfx::Size(icon_size, icon_size));
rect.Inset(-GetLayoutInsets(TOOLBAR_BUTTON)); rect.Inset(-GetLayoutInsets(TOOLBAR_BUTTON));
...@@ -235,7 +231,8 @@ void AppMenuButton::UpdateIcon(bool should_animate) { ...@@ -235,7 +231,8 @@ void AppMenuButton::UpdateIcon(bool should_animate) {
return; return;
} }
const bool is_touch = IsTouchOptimized(); const bool is_touch =
ui::MaterialDesignController::IsTouchOptimizedUiEnabled();
const gfx::VectorIcon* icon_id = nullptr; const gfx::VectorIcon* icon_id = nullptr;
switch (type_) { switch (type_) {
case AppMenuIconController::IconType::NONE: case AppMenuIconController::IconType::NONE:
......
...@@ -32,13 +32,8 @@ const int kReloadMenuItems[] = { ...@@ -32,13 +32,8 @@ const int kReloadMenuItems[] = {
IDS_RELOAD_MENU_EMPTY_AND_HARD_RELOAD_ITEM, IDS_RELOAD_MENU_EMPTY_AND_HARD_RELOAD_ITEM,
}; };
// Returns true if the touch-optimized UI is enabled.
bool IsTouchOptimized() {
return ui::MaterialDesignController::IsTouchOptimizedUiEnabled();
}
const gfx::VectorIcon& GetIconForMode(bool is_reload) { const gfx::VectorIcon& GetIconForMode(bool is_reload) {
if (IsTouchOptimized()) if (ui::MaterialDesignController::IsTouchOptimizedUiEnabled())
return is_reload ? kReloadTouchIcon : kNavigateStopTouchIcon; return is_reload ? kReloadTouchIcon : kNavigateStopTouchIcon;
return is_reload ? vector_icons::kReloadIcon : kNavigateStopIcon; return is_reload ? vector_icons::kReloadIcon : kNavigateStopIcon;
......
...@@ -25,15 +25,6 @@ ...@@ -25,15 +25,6 @@
#include "ui/views/controls/menu/menu_runner.h" #include "ui/views/controls/menu/menu_runner.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
namespace {
// Returns true if the touch-optimized UI is enabled.
bool IsTouchOptimized() {
return ui::MaterialDesignController::IsTouchOptimizedUiEnabled();
}
} // namespace
ToolbarButton::ToolbarButton(Profile* profile, ToolbarButton::ToolbarButton(Profile* profile,
views::ButtonListener* listener, views::ButtonListener* listener,
std::unique_ptr<ui::MenuModel> model) std::unique_ptr<ui::MenuModel> model)
...@@ -47,7 +38,7 @@ ToolbarButton::ToolbarButton(Profile* profile, ...@@ -47,7 +38,7 @@ ToolbarButton::ToolbarButton(Profile* profile,
SetFocusPainter(nullptr); SetFocusPainter(nullptr);
SetLeadingMargin(0); SetLeadingMargin(0);
if (IsTouchOptimized()) if (ui::MaterialDesignController::IsTouchOptimizedUiEnabled())
set_ink_drop_visible_opacity(kTouchToolbarInkDropVisibleOpacity); set_ink_drop_visible_opacity(kTouchToolbarInkDropVisibleOpacity);
} }
......
...@@ -97,11 +97,6 @@ int GetToolbarHorizontalPadding() { ...@@ -97,11 +97,6 @@ int GetToolbarHorizontalPadding() {
return kPaddings[Md::GetMode()]; return kPaddings[Md::GetMode()];
} }
// Returns true if the touch-optimized UI is enabled.
bool IsTouchOptimized() {
return ui::MaterialDesignController::IsTouchOptimizedUiEnabled();
}
} // namespace } // namespace
// static // static
...@@ -702,7 +697,8 @@ gfx::Size ToolbarView::SizeForContentSize(gfx::Size size) const { ...@@ -702,7 +697,8 @@ gfx::Size ToolbarView::SizeForContentSize(gfx::Size size) const {
location_bar_->GetPreferredSize().height()); location_bar_->GetPreferredSize().height());
// In the touch-optimized UI, the toolbar buttons are big and occupy the // In the touch-optimized UI, the toolbar buttons are big and occupy the
// entire view's height, we don't need to add any extra vertical space. // entire view's height, we don't need to add any extra vertical space.
const int extra_vertical_space = IsTouchOptimized() ? 0 : 9; const int extra_vertical_space =
ui::MaterialDesignController::IsTouchOptimizedUiEnabled() ? 0 : 9;
size.SetToMax(gfx::Size(0, content_height + extra_vertical_space)); size.SetToMax(gfx::Size(0, content_height + extra_vertical_space));
} }
return size; return size;
...@@ -716,7 +712,8 @@ void ToolbarView::LoadImages() { ...@@ -716,7 +712,8 @@ void ToolbarView::LoadImages() {
const SkColor disabled_color = const SkColor disabled_color =
tp->GetColor(ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON_INACTIVE); tp->GetColor(ThemeProperties::COLOR_TOOLBAR_BUTTON_ICON_INACTIVE);
const bool is_touch = IsTouchOptimized(); const bool is_touch =
ui::MaterialDesignController::IsTouchOptimizedUiEnabled();
const gfx::VectorIcon& back_image = const gfx::VectorIcon& back_image =
is_touch ? kBackArrowTouchIcon : vector_icons::kBackArrowIcon; is_touch ? kBackArrowTouchIcon : vector_icons::kBackArrowIcon;
back_->SetImage(views::Button::STATE_NORMAL, back_->SetImage(views::Button::STATE_NORMAL,
......
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