| 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 5152b5547335e5d091ec6383af2fb87d97fd42b4..ea3c1456245c0403bcd71469add180650720da23 100644
|
| --- a/chrome/browser/ui/views/tabs/tab_strip.cc
|
| +++ b/chrome/browser/ui/views/tabs/tab_strip.cc
|
| @@ -22,6 +22,7 @@
|
| #include "chrome/browser/ui/host_desktop.h"
|
| #include "chrome/browser/ui/tabs/tab_strip_model.h"
|
| #include "chrome/browser/ui/view_ids.h"
|
| +#include "chrome/browser/ui/views/layout_constants.h"
|
| #include "chrome/browser/ui/views/tabs/stacked_tab_strip_layout.h"
|
| #include "chrome/browser/ui/views/tabs/tab.h"
|
| #include "chrome/browser/ui/views/tabs/tab_drag_controller.h"
|
| @@ -113,13 +114,6 @@ const int kMouseMoveCountBeforeConsiderReal = 3;
|
| // Amount of time we delay before resizing after a close from a touch.
|
| const int kTouchResizeLayoutTimeMS = 2000;
|
|
|
| -// Amount of overlap between two adjacent tabs.
|
| -#if defined(OS_MACOSX)
|
| -const int kTabOverlap = 19;
|
| -#else
|
| -const int kTabOverlap = 26;
|
| -#endif
|
| -
|
| // Amount to adjust the clip by when the tab is stacked before the active index.
|
| const int kStackedTabLeftClip = 20;
|
|
|
| @@ -810,7 +804,7 @@ void TabStrip::PrepareForCloseAt(int model_index, CloseTabSource source) {
|
| Tab* last_tab = tab_at(model_count - 1);
|
| Tab* tab_being_removed = tab_at(model_index);
|
| available_width_for_tabs_ = last_tab->x() + last_tab->width() -
|
| - tab_being_removed->width() + GetTabOverlap();
|
| + tab_being_removed->width() + GetLayoutConstant(TABSTRIP_TAB_OVERLAP);
|
| if (model_index == 0 && tab_being_removed->data().pinned &&
|
| !tab_at(1)->data().pinned) {
|
| available_width_for_tabs_ -= kPinnedToNonPinnedGap;
|
| @@ -1214,7 +1208,8 @@ bool TabStrip::ShouldPaintTab(const Tab* tab, gfx::Rect* clip) {
|
| if (tab_bounds.x() < previous_tab_bounds.x())
|
| return true; // Can happen during dragging.
|
|
|
| - if (previous_tab_bounds.right() - GetTabOverlap() != tab_bounds.x()) {
|
| + if (previous_tab_bounds.right() - GetLayoutConstant(TABSTRIP_TAB_OVERLAP) !=
|
| + tab_bounds.x()) {
|
| int x = previous_tab_bounds.right() - tab_bounds.x() -
|
| kStackedTabRightClip;
|
| clip->SetRect(x, 0, tab_bounds.width() - x, tab_bounds.height());
|
| @@ -1330,15 +1325,15 @@ void TabStrip::PaintChildren(const ui::PaintContext& context) {
|
| paint.setXfermodeMode(SkXfermode::kDstIn_Mode);
|
| paint.setStyle(SkPaint::kFill_Style);
|
|
|
| - // The tab graphics include some shadows at the top, so the actual
|
| - // tabstrip top is 4 px. above the apparent top of the tab, to provide room
|
| - // to draw these. Exclude this region when trying to make tabs transparent
|
| - // as it's transparent enough already, and drawing in this region can
|
| - // overlap the avatar button, leading to visual artifacts.
|
| - const int kTopOffset = 4;
|
| - // The tabstrip area overlaps the toolbar area by 2 px.
|
| - recorder.canvas()->DrawRect(
|
| - gfx::Rect(0, kTopOffset, width(), height() - kTopOffset - 2), paint);
|
| + gfx::Rect bounds(GetLocalBounds());
|
| + // The tab graphics include some shadows at the top, plus a 1 pixel top
|
| + // stroke. Exclude this region when trying to make tabs transparent as it's
|
| + // transparent enough already, and drawing in this region can overlap the
|
| + // avatar button, leading to visual artifacts. Also exclude the toolbar
|
| + // overlap region at the bottom.
|
| + bounds.Inset(0, GetLayoutConstant(TABSTRIP_TOP_SHADOW_HEIGHT) + 1, 0,
|
| + GetLayoutConstant(TABSTRIP_TOOLBAR_OVERLAP));
|
| + recorder.canvas()->DrawRect(bounds, paint);
|
| }
|
|
|
| // Now selected but not active. We don't want these dimmed if using native
|
| @@ -1387,7 +1382,7 @@ gfx::Size TabStrip::GetPreferredSize() const {
|
| needed_tab_width += kPinnedToNonPinnedGap + min_selected_width +
|
| ((remaining_tab_count - 1) * min_unselected_width);
|
| }
|
| - const int tab_overlap = GetTabOverlap();
|
| + const int tab_overlap = GetLayoutConstant(TABSTRIP_TAB_OVERLAP);
|
| if (tab_count() > 1)
|
| needed_tab_width -= (tab_count() - 1) * tab_overlap;
|
|
|
| @@ -1555,9 +1550,9 @@ void TabStrip::StartInsertTabAnimation(int model_index) {
|
| ideal_bounds(model_index).height());
|
| } else {
|
| Tab* last_tab = tab_at(model_index - 1);
|
| - tab->SetBounds(last_tab->bounds().right() - GetTabOverlap(),
|
| - ideal_bounds(model_index).y(), 0,
|
| - ideal_bounds(model_index).height());
|
| + tab->SetBounds(
|
| + last_tab->bounds().right() - GetLayoutConstant(TABSTRIP_TAB_OVERLAP),
|
| + ideal_bounds(model_index).y(), 0, ideal_bounds(model_index).height());
|
| }
|
|
|
| AnimateToIdealBounds();
|
| @@ -1806,7 +1801,7 @@ void TabStrip::CalculateBoundsForDraggedTabs(const Tabs& tabs,
|
| gfx::Rect new_bounds = tab->bounds();
|
| new_bounds.set_origin(gfx::Point(x, 0));
|
| bounds->push_back(new_bounds);
|
| - x += tab->width() - GetTabOverlap();
|
| + x += tab->width() - GetLayoutConstant(TABSTRIP_TAB_OVERLAP);
|
| }
|
| }
|
|
|
| @@ -1818,15 +1813,11 @@ int TabStrip::GetSizeNeededForTabs(const Tabs& tabs) {
|
| if (i > 0 && tab->data().pinned != tabs[i - 1]->data().pinned)
|
| width += kPinnedToNonPinnedGap;
|
| }
|
| - if (tabs.size() > 0)
|
| - width -= GetTabOverlap() * static_cast<int>(tabs.size() - 1);
|
| + if (!tabs.empty())
|
| + width -= GetLayoutConstant(TABSTRIP_TAB_OVERLAP) * (tabs.size() - 1);
|
| return width;
|
| }
|
|
|
| -int TabStrip::GetTabOverlap() const {
|
| - return kTabOverlap;
|
| -}
|
| -
|
| int TabStrip::GetPinnedTabCount() const {
|
| int pinned_count = 0;
|
| while (pinned_count < tab_count() && tab_at(pinned_count)->data().pinned)
|
| @@ -2113,7 +2104,7 @@ void TabStrip::GetDesiredTabWidths(int tab_count,
|
| // Determine how much space we can actually allocate to tabs.
|
| int available_width = (available_width_for_tabs_ < 0) ?
|
| tab_area_width() : available_width_for_tabs_;
|
| - const int tab_overlap = GetTabOverlap();
|
| + const int tab_overlap = GetLayoutConstant(TABSTRIP_TAB_OVERLAP);
|
| if (pinned_tab_count > 0) {
|
| available_width -=
|
| pinned_tab_count * (Tab::GetPinnedWidth() - tab_overlap);
|
| @@ -2226,7 +2217,7 @@ gfx::Rect TabStrip::GetDropBounds(int drop_index,
|
| bool* is_beneath) {
|
| DCHECK_NE(drop_index, -1);
|
| int center_x;
|
| - const int tab_overlap = GetTabOverlap();
|
| + const int tab_overlap = GetLayoutConstant(TABSTRIP_TAB_OVERLAP);
|
| if (drop_index < tab_count()) {
|
| Tab* tab = tab_at(drop_index);
|
| center_x = tab->x() + ((drop_before ? tab_overlap : tab->width()) / 2);
|
| @@ -2392,7 +2383,7 @@ void TabStrip::GenerateIdealBounds() {
|
| int tab_height = Tab::GetStandardSize().height();
|
| int first_non_pinned_index = 0;
|
| double tab_x = GenerateIdealBoundsForPinnedTabs(&first_non_pinned_index);
|
| - const int tab_overlap = GetTabOverlap();
|
| + const int tab_overlap = GetLayoutConstant(TABSTRIP_TAB_OVERLAP);
|
| for (int i = first_non_pinned_index; i < tab_count(); ++i) {
|
| Tab* tab = tab_at(i);
|
| DCHECK(!tab->data().pinned);
|
| @@ -2430,7 +2421,7 @@ int TabStrip::GenerateIdealBoundsForPinnedTabs(int* first_non_pinned_index) {
|
| for (; index < tab_count() && tab_at(index)->data().pinned; ++index) {
|
| tabs_.set_ideal_bounds(index,
|
| gfx::Rect(next_x, 0, pinned_width, tab_height));
|
| - next_x += pinned_width - GetTabOverlap();
|
| + next_x += pinned_width - GetLayoutConstant(TABSTRIP_TAB_OVERLAP);
|
| }
|
| if (index > 0 && index < tab_count())
|
| next_x += kPinnedToNonPinnedGap;
|
| @@ -2459,7 +2450,7 @@ void TabStrip::StartMouseInitiatedRemoveTabAnimation(int model_index) {
|
| // The user initiated the close. We want to persist the bounds of all the
|
| // existing tabs, so we manually shift ideal_bounds then animate.
|
| Tab* tab_closing = tab_at(model_index);
|
| - int delta = tab_closing->width() - GetTabOverlap();
|
| + int delta = tab_closing->width() - GetLayoutConstant(TABSTRIP_TAB_OVERLAP);
|
| // If the tab being closed is a pinned tab next to a non-pinned tab, be sure
|
| // to add the extra padding.
|
| DCHECK_LT(model_index, tab_count() - 1);
|
| @@ -2512,7 +2503,8 @@ int TabStrip::GetStartXForNormalTabs() const {
|
| int pinned_tab_count = GetPinnedTabCount();
|
| if (pinned_tab_count == 0)
|
| return 0;
|
| - return pinned_tab_count * (Tab::GetPinnedWidth() - GetTabOverlap()) +
|
| + const int overlap = GetLayoutConstant(TABSTRIP_TAB_OVERLAP);
|
| + return pinned_tab_count * (Tab::GetPinnedWidth() - overlap) +
|
| kPinnedToNonPinnedGap;
|
| }
|
|
|
| @@ -2583,7 +2575,7 @@ void TabStrip::SwapLayoutIfNecessary() {
|
| tab_size.set_width(Tab::GetTouchWidth());
|
| touch_layout_.reset(new StackedTabStripLayout(
|
| tab_size,
|
| - GetTabOverlap(),
|
| + GetLayoutConstant(TABSTRIP_TAB_OVERLAP),
|
| kStackedPadding,
|
| kMaxStackedCount,
|
| &tabs_));
|
| @@ -2614,10 +2606,9 @@ bool TabStrip::NeedsTouchLayout() const {
|
| int normal_count = tab_count() - pinned_tab_count;
|
| if (normal_count <= 1 || normal_count == pinned_tab_count)
|
| return false;
|
| - int x = GetStartXForNormalTabs();
|
| - int available_width = tab_area_width() - x;
|
| - return (Tab::GetTouchWidth() * normal_count -
|
| - GetTabOverlap() * (normal_count - 1)) > available_width;
|
| + const int overlap = GetLayoutConstant(TABSTRIP_TAB_OVERLAP);
|
| + return (Tab::GetTouchWidth() * normal_count - overlap * (normal_count - 1)) >
|
| + tab_area_width() - GetStartXForNormalTabs();
|
| }
|
|
|
| void TabStrip::SetResetToShrinkOnExit(bool value) {
|
|
|