Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2188)

Unified Diff: chrome/browser/ui/views/tabs/tab_strip.cc

Issue 1543963002: Refactor layout constants in preparation for adding support for Material Hybrid. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tab_drag_height
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/tabs/tab.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/tabs/tab_strip.cc
diff --git a/chrome/browser/ui/views/tabs/tab_strip.cc b/chrome/browser/ui/views/tabs/tab_strip.cc
index 7778f84893e5c9bddb5cb7f64aa6d062ea4fe46f..7bc9c341b686a3930ce2dff18afb9d6a55b7ba96 100644
--- a/chrome/browser/ui/views/tabs/tab_strip.cc
+++ b/chrome/browser/ui/views/tabs/tab_strip.cc
@@ -79,8 +79,6 @@ using ui::DropTargetEvent;
namespace {
-const int kNewTabButtonHeight = 18;
-
const int kTabStripAnimationVSlop = 40;
// Inverse ratio of the width of a tab edge to the width of the tab. When
@@ -122,16 +120,9 @@ const int kPinnedToNonPinnedOffset = 3;
// The vertical offset of the tab strip button.
const int kNewTabButtonVerticalOffset = 7;
-// Returns the size of the new tab button, not including any bounds extension to
-// enlarge the clickable area.
-gfx::Size GetNewTabButtonSize() {
- return gfx::Size(GetLayoutConstant(NEW_TAB_BUTTON_WIDTH),
- kNewTabButtonHeight);
-}
-
// Returns the width needed for the new tab button (and padding).
int GetNewTabButtonWidth() {
- return GetLayoutConstant(NEW_TAB_BUTTON_WIDTH) -
+ return GetLayoutSize(NEW_TAB_BUTTON).width() -
GetLayoutConstant(TABSTRIP_NEW_TAB_BUTTON_OVERLAP);
}
@@ -372,7 +363,8 @@ void NewTabButton::OnGestureEvent(ui::GestureEvent* event) {
void NewTabButton::OnPaint(gfx::Canvas* canvas) {
gfx::ScopedCanvas scoped_canvas(canvas);
- canvas->Translate(gfx::Vector2d(0, height() - kNewTabButtonHeight));
+ const int visible_height = GetLayoutSize(NEW_TAB_BUTTON).height();
+ canvas->Translate(gfx::Vector2d(0, height() - visible_height));
const bool pressed = state() == views::CustomButton::STATE_PRESSED;
double hover_value =
@@ -425,7 +417,8 @@ void NewTabButton::OnPaint(gfx::Canvas* canvas) {
// The canvas and mask have to use the same scale factor.
const float fill_canvas_scale = mask->HasRepresentation(scale) ?
scale : ui::GetScaleForScaleFactor(ui::SCALE_FACTOR_100P);
- gfx::Canvas fill_canvas(GetNewTabButtonSize(), fill_canvas_scale, false);
+ gfx::Canvas fill_canvas(GetLayoutSize(NEW_TAB_BUTTON), fill_canvas_scale,
+ false);
PaintFill(pressed, hover_value, fill_canvas_scale, fill, &fill_canvas);
gfx::ImageSkia image(fill_canvas.ExtractImageRep());
canvas->DrawImageInt(
@@ -552,7 +545,7 @@ void NewTabButton::PaintFill(bool pressed,
}
// Draw the fill background image.
- const gfx::Size size(GetNewTabButtonSize());
+ const gfx::Size size(GetLayoutSize(NEW_TAB_BUTTON));
if (custom_image || !md) {
const ui::ThemeProvider* theme_provider = GetThemeProvider();
gfx::ImageSkia* background = theme_provider->GetImageSkiaNamed(bg_id);
@@ -1668,7 +1661,7 @@ void TabStrip::Init() {
// So we get enter/exit on children to switch stacked layout on and off.
set_notify_enter_exit_on_child(true);
- newtab_button_bounds_.set_size(GetNewTabButtonSize());
+ newtab_button_bounds_.set_size(GetLayoutSize(NEW_TAB_BUTTON));
newtab_button_bounds_.Inset(0, 0, 0, -kNewTabButtonVerticalOffset);
newtab_button_ = new NewTabButton(this, this);
newtab_button_->SetTooltipText(
« no previous file with comments | « chrome/browser/ui/views/tabs/tab.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698