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