Commit b407c35c authored by Thomas Lukaszewicz's avatar Thomas Lukaszewicz Committed by Commit Bot

Tab Search: Remove the non-fixed Tab Search entry point.

The tab search feature will only support a fixed entry point in the
tab strip region view going forward. This change removes the
implementation of the tab search button that sits flush with the new
tab button in the tab strip.

This reverts most of the changes introduced in the following CLs:
https://crrev.com/c/2333341
https://crrev.com/c/2377550

Bug: 1099917
Change-Id: I4013e3724968374b8616550c54d562da1366d0af
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2487252
Commit-Queue: Thomas Lukaszewicz <tluk@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#819136}
parent b6e2dc2b
...@@ -736,16 +736,9 @@ int BrowserView::GetTabStripHeight() const { ...@@ -736,16 +736,9 @@ int BrowserView::GetTabStripHeight() const {
} }
TabSearchButton* BrowserView::GetTabSearchButton() { TabSearchButton* BrowserView::GetTabSearchButton() {
if (!base::FeatureList::IsEnabled(features::kTabSearch)) return base::FeatureList::IsEnabled(features::kTabSearch)
return nullptr;
// If kTabSearchFixedEntrypoint is enabled then the tab search button is
// defined in the tab strip region view.
// TODO(tluk): Consolidate these once Tab Scrolling successfully moves the
// tab controls container to the tab strip region view.
return base::FeatureList::IsEnabled(features::kTabSearchFixedEntrypoint)
? tab_strip_region_view_->tab_search_button() ? tab_strip_region_view_->tab_search_button()
: tabstrip_->tab_search_button(); : nullptr;
} }
bool BrowserView::IsTabStripVisible() const { bool BrowserView::IsTabStripVisible() const {
......
...@@ -107,7 +107,6 @@ TabStripRegionView::TabStripRegionView(std::unique_ptr<TabStrip> tab_strip) { ...@@ -107,7 +107,6 @@ TabStripRegionView::TabStripRegionView(std::unique_ptr<TabStrip> tab_strip) {
views::MaximumFlexSizeRule::kUnbounded)); views::MaximumFlexSizeRule::kUnbounded));
if (base::FeatureList::IsEnabled(features::kTabSearch) && if (base::FeatureList::IsEnabled(features::kTabSearch) &&
base::FeatureList::IsEnabled(features::kTabSearchFixedEntrypoint) &&
!tab_strip_->controller()->GetProfile()->IsIncognitoProfile()) { !tab_strip_->controller()->GetProfile()->IsIncognitoProfile()) {
auto tab_search_button = std::make_unique<TabSearchButton>(tab_strip_); auto tab_search_button = std::make_unique<TabSearchButton>(tab_strip_);
tab_search_button->SetTooltipText( tab_search_button->SetTooltipText(
......
...@@ -28,11 +28,9 @@ class TabStripRegionViewBrowserTest ...@@ -28,11 +28,9 @@ class TabStripRegionViewBrowserTest
void SetUp() override { void SetUp() override {
// Run the test with both kTabSearchFixedEntrypoint enabled and disabled. // Run the test with both kTabSearchFixedEntrypoint enabled and disabled.
if (GetParam()) { if (GetParam()) {
scoped_feature_list_.InitWithFeatures( scoped_feature_list_.InitWithFeatures({features::kTabSearch}, {});
{features::kTabSearch, features::kTabSearchFixedEntrypoint}, {});
} else { } else {
scoped_feature_list_.InitWithFeatures( scoped_feature_list_.InitWithFeatures({}, {features::kTabSearch});
{}, {features::kTabSearch, features::kTabSearchFixedEntrypoint});
} }
InProcessBrowserTest::SetUp(); InProcessBrowserTest::SetUp();
} }
...@@ -178,8 +176,7 @@ IN_PROC_BROWSER_TEST_P(TabStripRegionViewBrowserTest, TestBeginEndFocus) { ...@@ -178,8 +176,7 @@ IN_PROC_BROWSER_TEST_P(TabStripRegionViewBrowserTest, TestBeginEndFocus) {
IN_PROC_BROWSER_TEST_P(TabStripRegionViewBrowserTest, IN_PROC_BROWSER_TEST_P(TabStripRegionViewBrowserTest,
TestSearchButtonIsEndAligned) { TestSearchButtonIsEndAligned) {
if (base::FeatureList::IsEnabled(features::kTabSearch) && if (base::FeatureList::IsEnabled(features::kTabSearch)) {
base::FeatureList::IsEnabled(features::kTabSearchFixedEntrypoint)) {
EXPECT_EQ(tab_strip_region_view()->GetLocalBounds().right(), EXPECT_EQ(tab_strip_region_view()->GetLocalBounds().right(),
tab_search_button()->bounds().right()); tab_search_button()->bounds().right());
} }
......
...@@ -65,10 +65,7 @@ IN_PROC_BROWSER_TEST_F(TabSearchBubbleBrowserTest, ShowTriggersTimer) { ...@@ -65,10 +65,7 @@ IN_PROC_BROWSER_TEST_F(TabSearchBubbleBrowserTest, ShowTriggersTimer) {
class TabSearchBubbleBrowserUITest : public DialogBrowserTest { class TabSearchBubbleBrowserUITest : public DialogBrowserTest {
public: public:
TabSearchBubbleBrowserUITest() { TabSearchBubbleBrowserUITest() {
feature_list_.InitWithFeatures( feature_list_.InitAndEnableFeature(features::kTabSearch);
/*enabled_features=*/{features::kTabSearch,
features::kTabSearchFixedEntrypoint},
/*disabled_features=*/{});
} }
TabSearchBubbleBrowserUITest(TabSearchBubbleBrowserUITest&) = delete; TabSearchBubbleBrowserUITest(TabSearchBubbleBrowserUITest&) = delete;
TabSearchBubbleBrowserUITest& operator=(TabSearchBubbleBrowserUITest&) = TabSearchBubbleBrowserUITest& operator=(TabSearchBubbleBrowserUITest&) =
......
...@@ -58,7 +58,6 @@ void TabSearchButton::OnWidgetClosing(views::Widget* widget) { ...@@ -58,7 +58,6 @@ void TabSearchButton::OnWidgetClosing(views::Widget* widget) {
observed_bubble_widget_.Remove(bubble_); observed_bubble_widget_.Remove(bubble_);
bubble_ = nullptr; bubble_ = nullptr;
pressed_lock_.reset(); pressed_lock_.reset();
tab_strip()->OnTabSearchBubbleClosed();
} }
bool TabSearchButton::ShowTabSearchBubble() { bool TabSearchButton::ShowTabSearchBubble() {
......
...@@ -25,22 +25,11 @@ ui::MouseEvent GetDummyEvent() { ...@@ -25,22 +25,11 @@ ui::MouseEvent GetDummyEvent() {
} }
} // namespace } // namespace
class TabSearchButtonBrowserTest : public InProcessBrowserTest, class TabSearchButtonBrowserTest : public InProcessBrowserTest {
public ::testing::WithParamInterface<bool> {
public: public:
// InProcessBrowserTest: // InProcessBrowserTest:
void SetUp() override { void SetUp() override {
// Run the test with both kTabSearchFixedEntrypoint enabled and disabled. scoped_feature_list_.InitAndEnableFeature(features::kTabSearch);
if (GetParam()) {
scoped_feature_list_.InitWithFeatures(
/*enabled_features=*/{features::kTabSearch,
features::kTabSearchFixedEntrypoint},
/*disabled_features=*/{});
} else {
scoped_feature_list_.InitWithFeatures(
/*enabled_features=*/{features::kTabSearch},
/*disabled_features=*/{features::kTabSearchFixedEntrypoint});
}
InProcessBrowserTest::SetUp(); InProcessBrowserTest::SetUp();
} }
...@@ -56,7 +45,7 @@ class TabSearchButtonBrowserTest : public InProcessBrowserTest, ...@@ -56,7 +45,7 @@ class TabSearchButtonBrowserTest : public InProcessBrowserTest,
base::test::ScopedFeatureList scoped_feature_list_; base::test::ScopedFeatureList scoped_feature_list_;
}; };
IN_PROC_BROWSER_TEST_P(TabSearchButtonBrowserTest, CreateAndClose) { IN_PROC_BROWSER_TEST_F(TabSearchButtonBrowserTest, CreateAndClose) {
ASSERT_EQ(nullptr, tab_search_button()->bubble_for_testing()); ASSERT_EQ(nullptr, tab_search_button()->bubble_for_testing());
views::test::ButtonTestApi(tab_search_button()).NotifyClick(GetDummyEvent()); views::test::ButtonTestApi(tab_search_button()).NotifyClick(GetDummyEvent());
ASSERT_NE(nullptr, tab_search_button()->bubble_for_testing()); ASSERT_NE(nullptr, tab_search_button()->bubble_for_testing());
...@@ -68,7 +57,7 @@ IN_PROC_BROWSER_TEST_P(TabSearchButtonBrowserTest, CreateAndClose) { ...@@ -68,7 +57,7 @@ IN_PROC_BROWSER_TEST_P(TabSearchButtonBrowserTest, CreateAndClose) {
ASSERT_EQ(nullptr, tab_search_button()->bubble_for_testing()); ASSERT_EQ(nullptr, tab_search_button()->bubble_for_testing());
} }
IN_PROC_BROWSER_TEST_P(TabSearchButtonBrowserTest, TestBubbleVisible) { IN_PROC_BROWSER_TEST_F(TabSearchButtonBrowserTest, TestBubbleVisible) {
EXPECT_FALSE(tab_search_button()->IsBubbleVisible()); EXPECT_FALSE(tab_search_button()->IsBubbleVisible());
ASSERT_EQ(nullptr, tab_search_button()->bubble_for_testing()); ASSERT_EQ(nullptr, tab_search_button()->bubble_for_testing());
...@@ -92,7 +81,7 @@ IN_PROC_BROWSER_TEST_P(TabSearchButtonBrowserTest, TestBubbleVisible) { ...@@ -92,7 +81,7 @@ IN_PROC_BROWSER_TEST_P(TabSearchButtonBrowserTest, TestBubbleVisible) {
ASSERT_EQ(nullptr, tab_search_button()->bubble_for_testing()); ASSERT_EQ(nullptr, tab_search_button()->bubble_for_testing());
} }
IN_PROC_BROWSER_TEST_P(TabSearchButtonBrowserTest, BubbleNotVisibleIncognito) { IN_PROC_BROWSER_TEST_F(TabSearchButtonBrowserTest, BubbleNotVisibleIncognito) {
Browser* incognito_browser = CreateIncognitoBrowser(); Browser* incognito_browser = CreateIncognitoBrowser();
BrowserView* incognito_browser_view = BrowserView* incognito_browser_view =
BrowserView::GetBrowserViewForBrowser(incognito_browser); BrowserView::GetBrowserViewForBrowser(incognito_browser);
...@@ -103,7 +92,7 @@ IN_PROC_BROWSER_TEST_P(TabSearchButtonBrowserTest, BubbleNotVisibleIncognito) { ...@@ -103,7 +92,7 @@ IN_PROC_BROWSER_TEST_P(TabSearchButtonBrowserTest, BubbleNotVisibleIncognito) {
// On macOS, most accelerators are handled by CommandDispatcher. // On macOS, most accelerators are handled by CommandDispatcher.
#if !defined(OS_MAC) #if !defined(OS_MAC)
IN_PROC_BROWSER_TEST_P(TabSearchButtonBrowserTest, TestBubbleKeyboardShortcut) { IN_PROC_BROWSER_TEST_F(TabSearchButtonBrowserTest, TestBubbleKeyboardShortcut) {
ASSERT_EQ(nullptr, tab_search_button()->bubble_for_testing()); ASSERT_EQ(nullptr, tab_search_button()->bubble_for_testing());
auto accelerator = ui::Accelerator( auto accelerator = ui::Accelerator(
...@@ -120,7 +109,3 @@ IN_PROC_BROWSER_TEST_P(TabSearchButtonBrowserTest, TestBubbleKeyboardShortcut) { ...@@ -120,7 +109,3 @@ IN_PROC_BROWSER_TEST_P(TabSearchButtonBrowserTest, TestBubbleKeyboardShortcut) {
ASSERT_EQ(nullptr, tab_search_button()->bubble_for_testing()); ASSERT_EQ(nullptr, tab_search_button()->bubble_for_testing());
} }
#endif #endif
INSTANTIATE_TEST_SUITE_P(All,
TabSearchButtonBrowserTest,
::testing::Values(true, false));
...@@ -39,7 +39,6 @@ ...@@ -39,7 +39,6 @@
#include "chrome/browser/ui/ui_features.h" #include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/view_ids.h" #include "chrome/browser/ui/view_ids.h"
#include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/tab_search/tab_search_bubble_view.h"
#include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h" #include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h"
#include "chrome/browser/ui/views/tabs/new_tab_button.h" #include "chrome/browser/ui/views/tabs/new_tab_button.h"
#include "chrome/browser/ui/views/tabs/stacked_tab_strip_layout.h" #include "chrome/browser/ui/views/tabs/stacked_tab_strip_layout.h"
...@@ -50,7 +49,6 @@ ...@@ -50,7 +49,6 @@
#include "chrome/browser/ui/views/tabs/tab_group_underline.h" #include "chrome/browser/ui/views/tabs/tab_group_underline.h"
#include "chrome/browser/ui/views/tabs/tab_group_views.h" #include "chrome/browser/ui/views/tabs/tab_group_views.h"
#include "chrome/browser/ui/views/tabs/tab_hover_card_bubble_view.h" #include "chrome/browser/ui/views/tabs/tab_hover_card_bubble_view.h"
#include "chrome/browser/ui/views/tabs/tab_search_button.h"
#include "chrome/browser/ui/views/tabs/tab_slot_view.h" #include "chrome/browser/ui/views/tabs/tab_slot_view.h"
#include "chrome/browser/ui/views/tabs/tab_strip_controller.h" #include "chrome/browser/ui/views/tabs/tab_strip_controller.h"
#include "chrome/browser/ui/views/tabs/tab_strip_layout_helper.h" #include "chrome/browser/ui/views/tabs/tab_strip_layout_helper.h"
...@@ -86,14 +84,12 @@ ...@@ -86,14 +84,12 @@
#include "ui/gfx/skia_util.h" #include "ui/gfx/skia_util.h"
#include "ui/views/accessibility/view_accessibility.h" #include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/controls/image_view.h" #include "ui/views/controls/image_view.h"
#include "ui/views/layout/flex_layout.h"
#include "ui/views/masked_targeter_delegate.h" #include "ui/views/masked_targeter_delegate.h"
#include "ui/views/mouse_watcher_view_host.h" #include "ui/views/mouse_watcher_view_host.h"
#include "ui/views/rect_based_targeting_utils.h" #include "ui/views/rect_based_targeting_utils.h"
#include "ui/views/view_model_utils.h" #include "ui/views/view_model_utils.h"
#include "ui/views/view_observer.h" #include "ui/views/view_observer.h"
#include "ui/views/view_targeter.h" #include "ui/views/view_targeter.h"
#include "ui/views/view_targeter_delegate.h"
#include "ui/views/view_utils.h" #include "ui/views/view_utils.h"
#include "ui/views/widget/root_view.h" #include "ui/views/widget/root_view.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
...@@ -308,33 +304,6 @@ int GetStackableTabWidth() { ...@@ -308,33 +304,6 @@ int GetStackableTabWidth() {
(ui::TouchUiController::Get()->touch_ui() ? 136 : 102); (ui::TouchUiController::Get()->touch_ui() ? 136 : 102);
} }
// |TabControlsContainer| is as a container class for control views that live
// in the tab strip.
class TabControlsContainer : public views::View,
public views::ViewTargeterDelegate {
public:
TabControlsContainer() {
SetEventTargeter(std::make_unique<views::ViewTargeter>(this));
SetLayoutManager(std::make_unique<views::FlexLayout>());
}
~TabControlsContainer() override = default;
// views::ViewTargeterDelegate:
bool DoesIntersectRect(const View* target,
const gfx::Rect& rect) const override {
DCHECK_EQ(this, target);
const auto& children = target->children();
const auto hits_child = [target, rect](const views::View* child) {
gfx::RectF child_rect(rect);
views::View::ConvertRectToTarget(target, child, &child_rect);
return child->GetVisible() &&
child->HitTestRect(gfx::ToEnclosingRect(child_rect));
};
return std::any_of(children.cbegin(), children.cend(), hits_child);
}
};
} // namespace } // namespace
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
...@@ -557,7 +526,7 @@ class TabStrip::TabDragContextImpl : public TabDragContext { ...@@ -557,7 +526,7 @@ class TabStrip::TabDragContextImpl : public TabDragContext {
} }
void DestroyDragController() override { void DestroyDragController() override {
SetTabControlsVisible(true); SetNewTabButtonVisible(true);
drag_controller_.reset(); drag_controller_.reset();
} }
...@@ -748,7 +717,7 @@ class TabStrip::TabDragContextImpl : public TabDragContext { ...@@ -748,7 +717,7 @@ class TabStrip::TabDragContextImpl : public TabDragContext {
// Hide the new tab button immediately if we didn't originate the drag. // Hide the new tab button immediately if we didn't originate the drag.
if (!drag_controller_) if (!drag_controller_)
SetTabControlsVisible(false); SetNewTabButtonVisible(false);
// Reset dragging state of existing tabs. // Reset dragging state of existing tabs.
for (int i = 0; i < GetTabCount(); ++i) for (int i = 0; i < GetTabCount(); ++i)
...@@ -782,7 +751,7 @@ class TabStrip::TabDragContextImpl : public TabDragContext { ...@@ -782,7 +751,7 @@ class TabStrip::TabDragContextImpl : public TabDragContext {
// Let the controller know that the user is not dragging this tabstrip's // Let the controller know that the user is not dragging this tabstrip's
// tabs anymore. // tabs anymore.
tab_strip_->controller_->OnStoppedDragging(); tab_strip_->controller_->OnStoppedDragging();
SetTabControlsVisible(true); SetNewTabButtonVisible(true);
} }
void StoppedDragging(const std::vector<TabSlotView*>& views, void StoppedDragging(const std::vector<TabSlotView*>& views,
...@@ -792,7 +761,7 @@ class TabStrip::TabDragContextImpl : public TabDragContext { ...@@ -792,7 +761,7 @@ class TabStrip::TabDragContextImpl : public TabDragContext {
// Let the controller know that the user stopped dragging tabs. // Let the controller know that the user stopped dragging tabs.
tab_strip_->controller_->OnStoppedDragging(); tab_strip_->controller_->OnStoppedDragging();
SetTabControlsVisible(true); SetNewTabButtonVisible(true);
if (move_only && tab_strip_->touch_layout_) { if (move_only && tab_strip_->touch_layout_) {
if (completed) if (completed)
tab_strip_->touch_layout_->SizeToFit(); tab_strip_->touch_layout_->SizeToFit();
...@@ -811,7 +780,7 @@ class TabStrip::TabDragContextImpl : public TabDragContext { ...@@ -811,7 +780,7 @@ class TabStrip::TabDragContextImpl : public TabDragContext {
// Immediately hide the new tab button if the last tab is being dragged. // Immediately hide the new tab button if the last tab is being dragged.
const Tab* last_visible_tab = tab_strip_->GetLastVisibleTab(); const Tab* last_visible_tab = tab_strip_->GetLastVisibleTab();
if (last_visible_tab && last_visible_tab->dragging()) if (last_visible_tab && last_visible_tab->dragging())
SetTabControlsVisible(false); SetNewTabButtonVisible(true);
std::vector<gfx::Rect> bounds = CalculateBoundsForDraggedViews(views); std::vector<gfx::Rect> bounds = CalculateBoundsForDraggedViews(views);
DCHECK_EQ(views.size(), bounds.size()); DCHECK_EQ(views.size(), bounds.size());
...@@ -854,8 +823,8 @@ class TabStrip::TabDragContextImpl : public TabDragContext { ...@@ -854,8 +823,8 @@ class TabStrip::TabDragContextImpl : public TabDragContext {
return tab_strip_->ideal_bounds(group); return tab_strip_->ideal_bounds(group);
} }
void SetTabControlsVisible(bool visible) { void SetNewTabButtonVisible(bool visible) {
tab_strip_->tab_controls_container_->SetVisible(visible); tab_strip_->new_tab_button_->SetVisible(visible);
} }
// Used by GetInsertionIndexForDraggedBounds() when the tabstrip is stacked. // Used by GetInsertionIndexForDraggedBounds() when the tabstrip is stacked.
...@@ -1082,8 +1051,6 @@ TabStrip::~TabStrip() { ...@@ -1082,8 +1051,6 @@ TabStrip::~TabStrip() {
RemoveMessageLoopObserver(); RemoveMessageLoopObserver();
new_tab_button_->RemoveObserver(this); new_tab_button_->RemoveObserver(this);
if (tab_search_button_)
tab_search_button_->RemoveObserver(this);
hover_card_observer_.RemoveAll(); hover_card_observer_.RemoveAll();
...@@ -1125,8 +1092,6 @@ void TabStrip::FrameColorsChanged() { ...@@ -1125,8 +1092,6 @@ void TabStrip::FrameColorsChanged() {
for (int i = 0; i < tab_count(); ++i) for (int i = 0; i < tab_count(); ++i)
tab_at(i)->FrameColorsChanged(); tab_at(i)->FrameColorsChanged();
new_tab_button_->FrameColorsChanged(); new_tab_button_->FrameColorsChanged();
if (tab_search_button_)
tab_search_button_->FrameColorsChanged();
UpdateContrastRatioValues(); UpdateContrastRatioValues();
SchedulePaint(); SchedulePaint();
} }
...@@ -1165,26 +1130,22 @@ bool TabStrip::IsRectInWindowCaption(const gfx::Rect& rect) { ...@@ -1165,26 +1130,22 @@ bool TabStrip::IsRectInWindowCaption(const gfx::Rect& rect) {
tab_drag_handle.Intersects(rect); tab_drag_handle.Intersects(rect);
} }
// Similarly, a hit in the tab controls container is considered to be in the // Similarly, a hit in the new tab button is considered to be in the caption
// caption if it's in this thin strip. // if it's in this thin strip.
gfx::Rect tab_controls_drag_handle = gfx::Rect new_tab_button_drag_handle = new_tab_button_->GetMirroredBounds();
tab_controls_container_->GetMirroredBounds(); new_tab_button_drag_handle.set_height(drag_handle_extension);
tab_controls_drag_handle.set_height(drag_handle_extension); if (extend_drag_handle && new_tab_button_drag_handle.Intersects(rect))
if (extend_drag_handle && tab_controls_drag_handle.Intersects(rect))
return true; return true;
// Check to see if the rect intersects the non-button parts of the tab // Check to see if the rect intersects the non-button parts of the new tab
// controls container. The enclosed buttons have a non-rectangular shape, so // button. The button has a non-rectangular shape, so if it's not in the
// if it's not in the visual portions of the buttons we treat it as a click to // visual portions of the button we treat it as a click to the caption.
// the caption. gfx::RectF rect_in_new_tab_coords_f(rect);
gfx::RectF rect_in_tab_controls_coords_f(rect); View::ConvertRectToTarget(this, new_tab_button_, &rect_in_new_tab_coords_f);
View::ConvertRectToTarget(this, tab_controls_container_, gfx::Rect rect_in_new_tab_coords =
&rect_in_tab_controls_coords_f); gfx::ToEnclosingRect(rect_in_new_tab_coords_f);
gfx::Rect rect_in_tab_controls_coords = return new_tab_button_->GetLocalBounds().Intersects(rect_in_new_tab_coords) &&
gfx::ToEnclosingRect(rect_in_tab_controls_coords_f); !new_tab_button_->HitTestRect(rect_in_new_tab_coords);
return tab_controls_container_->GetLocalBounds().Intersects(
rect_in_tab_controls_coords) &&
!tab_controls_container_->HitTestRect(rect_in_tab_controls_coords);
} }
bool TabStrip::IsPositionInWindowCaption(const gfx::Point& point) { bool TabStrip::IsPositionInWindowCaption(const gfx::Point& point) {
...@@ -1332,7 +1293,7 @@ void TabStrip::MoveTab(int from_model_index, ...@@ -1332,7 +1293,7 @@ void TabStrip::MoveTab(int from_model_index,
StartMoveTabAnimation(); StartMoveTabAnimation();
if (TabDragController::IsAttachedTo(GetDragContext()) && if (TabDragController::IsAttachedTo(GetDragContext()) &&
(last_tab != GetLastVisibleTab() || last_tab->dragging())) { (last_tab != GetLastVisibleTab() || last_tab->dragging())) {
tab_controls_container_->SetVisible(false); new_tab_button_->SetVisible(false);
} }
SwapLayoutIfNecessary(); SwapLayoutIfNecessary();
...@@ -1512,11 +1473,6 @@ void TabStrip::ShiftGroupRight(const tab_groups::TabGroupId& group) { ...@@ -1512,11 +1473,6 @@ void TabStrip::ShiftGroupRight(const tab_groups::TabGroupId& group) {
ShiftGroupRelative(group, 1); ShiftGroupRelative(group, 1);
} }
void TabStrip::OnTabSearchBubbleClosed() {
UpdateIdealBounds();
AnimateToIdealBounds();
}
bool TabStrip::ShouldTabBeVisible(const Tab* tab) const { bool TabStrip::ShouldTabBeVisible(const Tab* tab) const {
// Detached tabs should always be invisible (as they close). // Detached tabs should always be invisible (as they close).
if (tab->detached()) if (tab->detached())
...@@ -1949,11 +1905,8 @@ bool TabStrip::IsTabFirst(const Tab* tab) const { ...@@ -1949,11 +1905,8 @@ bool TabStrip::IsTabFirst(const Tab* tab) const {
} }
bool TabStrip::IsFocusInTabs() const { bool TabStrip::IsFocusInTabs() const {
// Focus is in tabs if the currently focused view is contained in the TabStrip
// and not in the |tab_controls_container_|.
return GetFocusManager() && Contains(GetFocusManager()->GetFocusedView()) && return GetFocusManager() && Contains(GetFocusManager()->GetFocusedView()) &&
!tab_controls_container_->Contains( GetFocusManager()->GetFocusedView() != new_tab_button_;
GetFocusManager()->GetFocusedView());
} }
void TabStrip::MaybeStartDrag( void TabStrip::MaybeStartDrag(
...@@ -2248,14 +2201,6 @@ void TabStrip::Layout() { ...@@ -2248,14 +2201,6 @@ void TabStrip::Layout() {
SetTabSlotVisibility(); SetTabSlotVisibility();
} }
if (tab_search_button_ &&
!tab_controls_container_->Contains(tab_search_button_)) {
auto preferred_size = tab_search_button_->GetPreferredSize();
tab_search_button_->SetBoundsRect(
gfx::Rect(width() - preferred_size.width(), 0, preferred_size.width(),
preferred_size.height()));
}
// Only do a layout if our size or the available width changed. // Only do a layout if our size or the available width changed.
const int available_width = GetAvailableWidthForTabStrip(); const int available_width = GetAvailableWidthForTabStrip();
if (last_layout_size_ == size() && last_available_width_ == available_width) if (last_layout_size_ == size() && last_available_width_ == available_width)
...@@ -2363,8 +2308,7 @@ void TabStrip::PaintChildren(const views::PaintInfo& paint_info) { ...@@ -2363,8 +2308,7 @@ void TabStrip::PaintChildren(const views::PaintInfo& paint_info) {
if (active_tab && !is_dragging) if (active_tab && !is_dragging)
active_tab->Paint(paint_info); active_tab->Paint(paint_info);
// Paint the tab controls. new_tab_button_->Paint(paint_info);
tab_controls_container_->Paint(paint_info);
// If dragging a group, paint the group highlight and header above all // If dragging a group, paint the group highlight and header above all
// non-dragging tabs and groups. // non-dragging tabs and groups.
...@@ -2433,9 +2377,9 @@ views::View* TabStrip::GetTooltipHandlerForPoint(const gfx::Point& point) { ...@@ -2433,9 +2377,9 @@ views::View* TabStrip::GetTooltipHandlerForPoint(const gfx::Point& point) {
if (tab) if (tab)
return tab; return tab;
} else { } else {
if (tab_controls_container_->GetVisible()) { if (new_tab_button_->GetVisible()) {
views::View* view = ConvertPointToViewAndGetTooltipHandler( views::View* view =
this, tab_controls_container_, point); ConvertPointToViewAndGetTooltipHandler(this, new_tab_button_, point);
if (view) if (view)
return view; return view;
} }
...@@ -2495,43 +2439,20 @@ void TabStrip::Init() { ...@@ -2495,43 +2439,20 @@ void TabStrip::Init() {
// So we get enter/exit on children to switch stacked layout on and off. // So we get enter/exit on children to switch stacked layout on and off.
SetNotifyEnterExitOnChild(true); SetNotifyEnterExitOnChild(true);
tab_controls_container_ = new_tab_button_ = AddChildView(std::make_unique<NewTabButton>(
AddChildView(std::make_unique<TabControlsContainer>());
auto new_tab_button = std::make_unique<NewTabButton>(
this, base::BindRepeating(&TabStrip::NewTabButtonPressed, this, base::BindRepeating(&TabStrip::NewTabButtonPressed,
base::Unretained(this))); base::Unretained(this))));
new_tab_button->SetTooltipText( new_tab_button_->SetTooltipText(
l10n_util::GetStringUTF16(IDS_TOOLTIP_NEW_TAB)); l10n_util::GetStringUTF16(IDS_TOOLTIP_NEW_TAB));
new_tab_button->SetAccessibleName( new_tab_button_->SetAccessibleName(
l10n_util::GetStringUTF16(IDS_ACCNAME_NEWTAB)); l10n_util::GetStringUTF16(IDS_ACCNAME_NEWTAB));
new_tab_button->SetImageVerticalAlignment(views::ImageButton::ALIGN_BOTTOM); new_tab_button_->SetImageVerticalAlignment(views::ImageButton::ALIGN_BOTTOM);
new_tab_button->SetEventTargeter( new_tab_button_->SetEventTargeter(
std::make_unique<views::ViewTargeter>(new_tab_button.get())); std::make_unique<views::ViewTargeter>(new_tab_button_));
new_tab_button->AddObserver(this); new_tab_button_->AddObserver(this);
new_tab_button_ =
tab_controls_container_->AddChildView(std::move(new_tab_button));
if (base::FeatureList::IsEnabled(features::kTabSearch) &&
!base::FeatureList::IsEnabled(features::kTabSearchFixedEntrypoint) &&
!controller_->GetProfile()->IsIncognitoProfile()) {
auto tab_search_button = std::make_unique<TabSearchButton>(this);
tab_search_button->SetTooltipText(
l10n_util::GetStringUTF16(IDS_TOOLTIP_TAB_SEARCH));
tab_search_button->SetAccessibleName(
l10n_util::GetStringUTF16(IDS_ACCNAME_TAB_SEARCH));
tab_search_button->SetEventTargeter(
std::make_unique<views::ViewTargeter>(tab_search_button.get()));
tab_search_button->AddObserver(this);
tab_search_button_ =
tab_controls_container_->AddChildView(std::move(tab_search_button));
}
UpdateNewTabButtonBorder(); UpdateNewTabButtonBorder();
tab_controls_container_ideal_bounds_.set_size( new_tab_button_ideal_bounds_.set_size(new_tab_button_->GetPreferredSize());
tab_controls_container_->GetPreferredSize());
if (g_drop_indicator_width == 0) { if (g_drop_indicator_width == 0) {
// Direction doesn't matter, both images are the same size. // Direction doesn't matter, both images are the same size.
...@@ -2700,12 +2621,11 @@ void TabStrip::StartRemoveTabAnimation(int model_index, bool was_active) { ...@@ -2700,12 +2621,11 @@ void TabStrip::StartRemoveTabAnimation(int model_index, bool was_active) {
// sense to me. Why is each condition justified? // sense to me. Why is each condition justified?
if ((touch_layout_ || !in_tab_close_ || model_index == GetModelCount()) && if ((touch_layout_ || !in_tab_close_ || model_index == GetModelCount()) &&
TabDragController::IsAttachedTo(GetDragContext())) { TabDragController::IsAttachedTo(GetDragContext())) {
// Don't animate the tab controls container when dragging tabs. Otherwise it // Don't animate the new tab button when dragging tabs. Otherwise it looks
// looks like the controls magically appear from beyond the end of the tab // like the new tab button magically appears from beyond the end of the tab
// strip. // strip.
bounds_animator_.StopAnimatingView(tab_controls_container_); bounds_animator_.StopAnimatingView(new_tab_button_);
tab_controls_container_->SetBoundsRect( new_tab_button_->SetBoundsRect(new_tab_button_ideal_bounds_);
tab_controls_container_ideal_bounds_);
} }
} }
...@@ -2761,10 +2681,10 @@ void TabStrip::AnimateToIdealBounds() { ...@@ -2761,10 +2681,10 @@ void TabStrip::AnimateToIdealBounds() {
base::Unretained(this)))); base::Unretained(this))));
} }
if (bounds_animator_.GetTargetBounds(tab_controls_container_) != if (bounds_animator_.GetTargetBounds(new_tab_button_) !=
tab_controls_container_ideal_bounds_) { new_tab_button_ideal_bounds_) {
bounds_animator_.AnimateViewTo(tab_controls_container_, bounds_animator_.AnimateViewTo(new_tab_button_,
tab_controls_container_ideal_bounds_); new_tab_button_ideal_bounds_);
} }
} }
...@@ -2778,7 +2698,7 @@ void TabStrip::SnapToIdealBounds() { ...@@ -2778,7 +2698,7 @@ void TabStrip::SnapToIdealBounds() {
header_pair.second->UpdateBounds(); header_pair.second->UpdateBounds();
} }
tab_controls_container_->SetBoundsRect(tab_controls_container_ideal_bounds_); new_tab_button_->SetBoundsRect(new_tab_button_ideal_bounds_);
PreferredSizeChanged(); PreferredSizeChanged();
} }
...@@ -2803,7 +2723,7 @@ int TabStrip::FrameGrabWidth() const { ...@@ -2803,7 +2723,7 @@ int TabStrip::FrameGrabWidth() const {
// The grab area is adjacent to the new tab button. Treat the padding in the // The grab area is adjacent to the new tab button. Treat the padding in the
// new tab button as part of the grab area. // new tab button as part of the grab area.
constexpr int kApparentWidth = 50; constexpr int kApparentWidth = 50;
return kApparentWidth - tab_controls_container_->GetInsets().right(); return kApparentWidth - new_tab_button_->GetInsets().right();
} }
bool TabStrip::TitlebarBackgroundIsTransparent() const { bool TabStrip::TitlebarBackgroundIsTransparent() const {
...@@ -2876,8 +2796,8 @@ int TabStrip::GetTabAreaWidth() const { ...@@ -2876,8 +2796,8 @@ int TabStrip::GetTabAreaWidth() const {
} }
int TabStrip::GetRightSideReservedWidth() const { int TabStrip::GetRightSideReservedWidth() const {
return tab_controls_container_ideal_bounds_.width() + return new_tab_button_ideal_bounds_.width() + TabToNewTabButtonSpacing() +
TabToNewTabButtonSpacing() + FrameGrabWidth(); FrameGrabWidth();
} }
const Tab* TabStrip::GetLastVisibleTab() const { const Tab* TabStrip::GetLastVisibleTab() const {
...@@ -3461,7 +3381,7 @@ void TabStrip::UpdateIdealBounds() { ...@@ -3461,7 +3381,7 @@ void TabStrip::UpdateIdealBounds() {
if (touch_layout_) { if (touch_layout_) {
const int trailing_x = tabs_.ideal_bounds(tab_count() - 1).right(); const int trailing_x = tabs_.ideal_bounds(tab_count() - 1).right();
tab_controls_container_ideal_bounds_.set_origin( new_tab_button_ideal_bounds_.set_origin(
gfx::Point(trailing_x + TabToNewTabButtonSpacing(), 0)); gfx::Point(trailing_x + TabToNewTabButtonSpacing(), 0));
} else { } else {
const int available_width_for_tabs = CalculateAvailableWidthForTabs(); const int available_width_for_tabs = CalculateAvailableWidthForTabs();
...@@ -3472,13 +3392,9 @@ void TabStrip::UpdateIdealBounds() { ...@@ -3472,13 +3392,9 @@ void TabStrip::UpdateIdealBounds() {
base::FeatureList::IsEnabled(features::kScrollableTabStrip) base::FeatureList::IsEnabled(features::kScrollableTabStrip)
? trailing_x ? trailing_x
: std::min(available_width_for_tabs, trailing_x); : std::min(available_width_for_tabs, trailing_x);
// We want to lock the |tab_controls_container_| in place if the Tab Search
// bubble is open to prevent the UI sliding across the screen as the tab new_tab_button_ideal_bounds_.set_origin(
// strip changes. gfx::Point(ntb_x_offset + TabToNewTabButtonSpacing(), 0));
if (!tab_search_button_ || !tab_search_button_->IsBubbleVisible()) {
tab_controls_container_ideal_bounds_.set_origin(
gfx::Point(ntb_x_offset + TabToNewTabButtonSpacing(), 0));
}
} }
} }
...@@ -3670,24 +3586,17 @@ void TabStrip::SetResetToShrinkOnExit(bool value) { ...@@ -3670,24 +3586,17 @@ void TabStrip::SetResetToShrinkOnExit(bool value) {
} }
void TabStrip::UpdateNewTabButtonBorder() { void TabStrip::UpdateNewTabButtonBorder() {
// The controls container is placed vertically exactly in the center of the
// tabstrip.
const int extra_vertical_space = GetLayoutConstant(TAB_HEIGHT) - const int extra_vertical_space = GetLayoutConstant(TAB_HEIGHT) -
GetLayoutConstant(TABSTRIP_TOOLBAR_OVERLAP) - GetLayoutConstant(TABSTRIP_TOOLBAR_OVERLAP) -
NewTabButton::kButtonSize.height(); NewTabButton::kButtonSize.height();
// Extend the border of the tab controls such that it extends to the top of
// the tabstrip bounds. This is essential to ensure they targetable on the
// edge of the screen when in fullscreen mode and ensures the buttons abide by
// the correct Fitt's Law behavior (https://crbug.com/1136557).
const gfx::Insets button_insets(extra_vertical_space / 2, 0, 0, 0);
new_tab_button_->SetBorder(views::CreateEmptyBorder(button_insets));
if (tab_search_button_)
tab_search_button_->SetBorder(views::CreateEmptyBorder(button_insets));
constexpr int kHorizontalInset = 8; constexpr int kHorizontalInset = 8;
tab_controls_container_->SetBorder(views::CreateEmptyBorder( // The new tab button is placed vertically exactly in the center of the
gfx::Insets(0, kHorizontalInset, 0, kHorizontalInset))); // tabstrip. Extend the border of the button such that it extends to the top
// of the tabstrip bounds. This is essential to ensure it is targetable on the
// edge of the screen when in fullscreen mode and ensures the button abides
// by the correct Fitt's Law behavior (https://crbug.com/1136557).
new_tab_button_->SetBorder(views::CreateEmptyBorder(gfx::Insets(
extra_vertical_space / 2, kHorizontalInset, 0, kHorizontalInset)));
} }
void TabStrip::OnTabSlotAnimationProgressed(TabSlotView* view) { void TabStrip::OnTabSlotAnimationProgressed(TabSlotView* view) {
...@@ -3822,9 +3731,9 @@ views::View* TabStrip::TargetForRect(views::View* root, const gfx::Rect& rect) { ...@@ -3822,9 +3731,9 @@ views::View* TabStrip::TargetForRect(views::View* root, const gfx::Rect& rect) {
if (tab) if (tab)
return tab; return tab;
} else { } else {
if (tab_controls_container_->GetVisible()) { if (new_tab_button_->GetVisible()) {
views::View* view = ConvertPointToViewAndGetEventHandler( views::View* view =
this, tab_controls_container_, point); ConvertPointToViewAndGetEventHandler(this, new_tab_button_, point);
if (view) if (view)
return view; return view;
} }
...@@ -3857,9 +3766,8 @@ void TabStrip::OnViewBlurred(views::View* observed_view) { ...@@ -3857,9 +3766,8 @@ void TabStrip::OnViewBlurred(views::View* observed_view) {
void TabStrip::OnTouchUiChanged() { void TabStrip::OnTouchUiChanged() {
UpdateNewTabButtonBorder(); UpdateNewTabButtonBorder();
tab_controls_container_ideal_bounds_.set_size( new_tab_button_ideal_bounds_.set_size(new_tab_button_->GetPreferredSize());
tab_controls_container_->GetPreferredSize()); new_tab_button_->SetBoundsRect(new_tab_button_ideal_bounds_);
tab_controls_container_->SetBoundsRect(tab_controls_container_ideal_bounds_);
StopAnimating(true); StopAnimating(true);
PreferredSizeChanged(); PreferredSizeChanged();
} }
...@@ -44,7 +44,6 @@ class NewTabButton; ...@@ -44,7 +44,6 @@ class NewTabButton;
class StackedTabStripLayout; class StackedTabStripLayout;
class Tab; class Tab;
class TabHoverCardBubbleView; class TabHoverCardBubbleView;
class TabSearchButton;
class TabStripController; class TabStripController;
class TabStripObserver; class TabStripObserver;
class TabStripLayoutHelper; class TabStripLayoutHelper;
...@@ -146,9 +145,9 @@ class TabStrip : public views::View, ...@@ -146,9 +145,9 @@ class TabStrip : public views::View,
// Sets |stacked_layout_| and animates if necessary. // Sets |stacked_layout_| and animates if necessary.
void SetStackedLayout(bool stacked_layout); void SetStackedLayout(bool stacked_layout);
// Returns the ideal bounds of the tab controls container. // Returns the ideal bounds of the new tab button.
gfx::Rect tab_controls_container_ideal_bounds() const { const gfx::Rect& new_tab_button_ideal_bounds() const {
return tab_controls_container_ideal_bounds_; return new_tab_button_ideal_bounds_;
} }
// Adds a tab at the specified index. // Adds a tab at the specified index.
...@@ -205,12 +204,6 @@ class TabStrip : public views::View, ...@@ -205,12 +204,6 @@ class TabStrip : public views::View,
// Attempts to move the specified group to the right. // Attempts to move the specified group to the right.
void ShiftGroupRight(const tab_groups::TabGroupId& group); void ShiftGroupRight(const tab_groups::TabGroupId& group);
// While the Tab Search bubble is open, the |tab_controls_container_| is kept
// in a fixed position in the tab strip. This is called when the bubble is
// closed to allow the |tab_controls_container_| to animate to the correct
// position.
void OnTabSearchBubbleClosed();
// Returns true if the tab is not partly or fully clipped (due to overflow), // Returns true if the tab is not partly or fully clipped (due to overflow),
// and the tab couldn't become partly clipped due to changing the selected tab // and the tab couldn't become partly clipped due to changing the selected tab
// (for example, if currently the strip has the last tab selected, and // (for example, if currently the strip has the last tab selected, and
...@@ -247,9 +240,6 @@ class TabStrip : public views::View, ...@@ -247,9 +240,6 @@ class TabStrip : public views::View,
// Returns the NewTabButton. // Returns the NewTabButton.
NewTabButton* new_tab_button() { return new_tab_button_; } NewTabButton* new_tab_button() { return new_tab_button_; }
// Returns the TabSearchButton.
TabSearchButton* tab_search_button() { return tab_search_button_; }
// Returns the index of the specified view in the model coordinate system, or // Returns the index of the specified view in the model coordinate system, or
// -1 if view is closing or not a tab. // -1 if view is closing or not a tab.
int GetModelIndexOf(const TabSlotView* view) const; int GetModelIndexOf(const TabSlotView* view) const;
...@@ -709,15 +699,11 @@ class TabStrip : public views::View, ...@@ -709,15 +699,11 @@ class TabStrip : public views::View,
// Responsible for animating tabs in response to model changes. // Responsible for animating tabs in response to model changes.
views::BoundsAnimator bounds_animator_{this}; views::BoundsAnimator bounds_animator_{this};
// Container that holds the |new_tab_button_| and the |tab_search_button_|. // The "New Tab" button.
views::View* tab_controls_container_ = nullptr;
NewTabButton* new_tab_button_ = nullptr; NewTabButton* new_tab_button_ = nullptr;
// |tab_search_button_| will be null if features::kTabSearch is disabled or if
// the current profile is an incognito profile.
TabSearchButton* tab_search_button_ = nullptr;
// Ideal bounds of container holding the tab controls. // Ideal bounds of the new tab button.
gfx::Rect tab_controls_container_ideal_bounds_; gfx::Rect new_tab_button_ideal_bounds_;
// If this value is defined, it is used as the width to lay out tabs // If this value is defined, it is used as the width to lay out tabs
// (instead of GetTabAreaWidth()). It is defined when closing tabs with the // (instead of GetTabAreaWidth()). It is defined when closing tabs with the
......
...@@ -138,10 +138,6 @@ class TabStripTest : public ChromeViewsTestBase, ...@@ -138,10 +138,6 @@ class TabStripTest : public ChromeViewsTestBase,
return tab->icon_->ShowingAttentionIndicator(); return tab->icon_->ShowingAttentionIndicator();
} }
views::View* tab_controls_container() {
return tab_strip_->tab_controls_container_;
}
// Checks whether |tab| contains |point_in_tabstrip_coords|, where the point // Checks whether |tab| contains |point_in_tabstrip_coords|, where the point
// is in |tab_strip_| coordinates. // is in |tab_strip_| coordinates.
bool IsPointInTab(Tab* tab, const gfx::Point& point_in_tabstrip_coords) { bool IsPointInTab(Tab* tab, const gfx::Point& point_in_tabstrip_coords) {
...@@ -863,8 +859,7 @@ TEST_P(TabStripTest, NewTabButtonStaysVisible) { ...@@ -863,8 +859,7 @@ TEST_P(TabStripTest, NewTabButtonStaysVisible) {
CompleteAnimationAndLayout(); CompleteAnimationAndLayout();
EXPECT_LE(tab_strip_->tab_controls_container_ideal_bounds().right(), EXPECT_LE(tab_strip_->new_tab_button_ideal_bounds().right(), kTabStripWidth);
kTabStripWidth);
} }
TEST_P(TabStripTest, NewTabButtonRightOfTabs) { TEST_P(TabStripTest, NewTabButtonRightOfTabs) {
...@@ -875,7 +870,7 @@ TEST_P(TabStripTest, NewTabButtonRightOfTabs) { ...@@ -875,7 +870,7 @@ TEST_P(TabStripTest, NewTabButtonRightOfTabs) {
AnimateToIdealBounds(); AnimateToIdealBounds();
EXPECT_EQ(tab_strip_->tab_controls_container_ideal_bounds().x(), EXPECT_EQ(tab_strip_->new_tab_button_ideal_bounds().x(),
tab_strip_->ideal_bounds(0).right() + TabToNewTabButtonSpacing()); tab_strip_->ideal_bounds(0).right() + TabToNewTabButtonSpacing());
} }
...@@ -1351,20 +1346,10 @@ TEST_P(TabStripTest, NewTabButtonFlushWithTopOfTabStrip) { ...@@ -1351,20 +1346,10 @@ TEST_P(TabStripTest, NewTabButtonFlushWithTopOfTabStrip) {
AnimateToIdealBounds(); AnimateToIdealBounds();
// |tab_controls_container_| should sit flush with the top of the tab strip.
EXPECT_EQ(0, tab_strip_->tab_controls_container_ideal_bounds().y());
// The new tab button should sit flush with the top of the // The new tab button should sit flush with the top of the
// |tab_controls_container_|. // |tab_strip_|.
EXPECT_EQ(tab_strip_, tab_strip_->new_tab_button()->parent());
EXPECT_EQ(0, tab_strip_->new_tab_button()->bounds().y()); EXPECT_EQ(0, tab_strip_->new_tab_button()->bounds().y());
// The new tab button should be positioned flush with the top of the tab
// strip.
gfx::RectF ntb_in_child_coords_f(tab_strip_->new_tab_button()->bounds());
views::View::ConvertRectToTarget(tab_controls_container(), tab_strip_,
&ntb_in_child_coords_f);
gfx::Rect ntb_in_child_coords = gfx::ToEnclosingRect(ntb_in_child_coords_f);
EXPECT_EQ(0, ntb_in_child_coords.y());
} }
INSTANTIATE_TEST_SUITE_P(All, TabStripTest, ::testing::Values(false, true)); INSTANTIATE_TEST_SUITE_P(All, TabStripTest, ::testing::Values(false, true));
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