Commit 765bdeb0 authored by Taylor Bergquist's avatar Taylor Bergquist Committed by Commit Bot

Fix tab search button fixed entrypoint not being fixed.

Bug: 1138684
Change-Id: Ie4a64447dc71a9809d5e431e2842c45c1accc0fe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2476729Reviewed-by: default avatarThomas Lukaszewicz <tluk@chromium.org>
Commit-Queue: Taylor Bergquist <tbergquist@chromium.org>
Cr-Commit-Position: refs/heads/master@{#818104}
parent 2e09335e
...@@ -88,30 +88,27 @@ TabStripRegionView::TabStripRegionView(std::unique_ptr<TabStrip> tab_strip) { ...@@ -88,30 +88,27 @@ TabStripRegionView::TabStripRegionView(std::unique_ptr<TabStrip> tab_strip) {
tab_strip_container_flex_spec); tab_strip_container_flex_spec);
} }
reserved_grab_handle_space_ = AddChildView(std::make_unique<views::View>());
// TODO(tbergquist): Give |reserved_grab_handle_space_| a minimum size. For
// now, this space is reserved by the tabstrip itself, and we're just using
// this view to eat up flex space so that |tab_search_button| can be end-
// aligned.
reserved_grab_handle_space_->SetProperty(
views::kFlexBehaviorKey,
views::FlexSpecification(views::MinimumFlexSizeRule::kScaleToMinimum,
views::MaximumFlexSizeRule::kUnbounded));
if (base::FeatureList::IsEnabled(features::kTabSearch) && if (base::FeatureList::IsEnabled(features::kTabSearch) &&
base::FeatureList::IsEnabled(features::kTabSearchFixedEntrypoint) && base::FeatureList::IsEnabled(features::kTabSearchFixedEntrypoint) &&
!tab_strip_->controller()->GetProfile()->IsIncognitoProfile()) { !tab_strip_->controller()->GetProfile()->IsIncognitoProfile()) {
// TODO(tluk): |tab_search_container| is only needed here so the tab search
// button can be vertically centered. This can be removed if FlexLayout is
// updated to support per-child cross-axis alignment.
auto* tab_search_container = AddChildView(std::make_unique<views::View>());
tab_search_container->SetProperty(
views::kFlexBehaviorKey,
views::FlexSpecification(views::MinimumFlexSizeRule::kScaleToMinimum,
views::MaximumFlexSizeRule::kPreferred));
auto* container_layout_manager = tab_search_container->SetLayoutManager(
std::make_unique<views::FlexLayout>());
container_layout_manager
->SetOrientation(views::LayoutOrientation::kVertical)
.SetMainAxisAlignment(views::LayoutAlignment::kCenter);
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(
l10n_util::GetStringUTF16(IDS_TOOLTIP_TAB_SEARCH)); l10n_util::GetStringUTF16(IDS_TOOLTIP_TAB_SEARCH));
tab_search_button->SetAccessibleName( tab_search_button->SetAccessibleName(
l10n_util::GetStringUTF16(IDS_ACCNAME_TAB_SEARCH)); l10n_util::GetStringUTF16(IDS_ACCNAME_TAB_SEARCH));
tab_search_button_ = tab_search_button->SetProperty(views::kCrossAxisAlignmentKey,
tab_search_container->AddChildView(std::move(tab_search_button)); views::LayoutAlignment::kCenter);
tab_search_button_ = AddChildView(std::move(tab_search_button));
} }
} }
...@@ -137,7 +134,7 @@ bool TabStripRegionView::IsRectInWindowCaption(const gfx::Rect& rect) { ...@@ -137,7 +134,7 @@ bool TabStripRegionView::IsRectInWindowCaption(const gfx::Rect& rect) {
// The child could have a non-rectangular shape, so if the rect is not in the // The child could have a non-rectangular shape, so if the rect is not in the
// visual portions of the child view we treat it as a click to the caption. // visual portions of the child view we treat it as a click to the caption.
for (View* const child : children()) { for (View* const child : children()) {
if (child != tab_strip_container_ && if (child != tab_strip_container_ && child != reserved_grab_handle_space_ &&
child->GetLocalBounds().Intersects(get_target_rect(child))) { child->GetLocalBounds().Intersects(get_target_rect(child))) {
return !child->HitTestRect(get_target_rect(child)); return !child->HitTestRect(get_target_rect(child));
} }
...@@ -219,7 +216,7 @@ int TabStripRegionView::CalculateTabStripAvailableWidth() { ...@@ -219,7 +216,7 @@ int TabStripRegionView::CalculateTabStripAvailableWidth() {
int reserved_width = 0; int reserved_width = 0;
for (View* const child : children()) { for (View* const child : children()) {
if (child != tab_strip_container_) if (child != tab_strip_container_)
reserved_width += child->size().width(); reserved_width += child->GetMinimumSize().width();
} }
return size().width() - reserved_width; return size().width() - reserved_width;
......
...@@ -12,7 +12,6 @@ class TabSearchButton; ...@@ -12,7 +12,6 @@ class TabSearchButton;
class TabStrip; class TabStrip;
// Container for the tabstrip, new tab button, and reserved grab handle space. // Container for the tabstrip, new tab button, and reserved grab handle space.
// TODO (https://crbug.com/949660) Under construction.
class TabStripRegionView final : public views::AccessiblePaneView, class TabStripRegionView final : public views::AccessiblePaneView,
views::ViewObserver { views::ViewObserver {
public: public:
...@@ -59,6 +58,7 @@ class TabStripRegionView final : public views::AccessiblePaneView, ...@@ -59,6 +58,7 @@ class TabStripRegionView final : public views::AccessiblePaneView,
void ScrollTowardsTrailingTab(); void ScrollTowardsTrailingTab();
views::View* tab_strip_container_; views::View* tab_strip_container_;
views::View* reserved_grab_handle_space_;
TabStrip* tab_strip_; TabStrip* tab_strip_;
TabSearchButton* tab_search_button_ = nullptr; TabSearchButton* tab_search_button_ = nullptr;
views::ImageButton* leading_scroll_button_; views::ImageButton* leading_scroll_button_;
......
...@@ -176,6 +176,15 @@ IN_PROC_BROWSER_TEST_P(TabStripRegionViewBrowserTest, TestBeginEndFocus) { ...@@ -176,6 +176,15 @@ IN_PROC_BROWSER_TEST_P(TabStripRegionViewBrowserTest, TestBeginEndFocus) {
EXPECT_TRUE(tab_0->HasFocus()); EXPECT_TRUE(tab_0->HasFocus());
} }
IN_PROC_BROWSER_TEST_P(TabStripRegionViewBrowserTest,
TestSearchButtonIsEndAligned) {
if (base::FeatureList::IsEnabled(features::kTabSearch) &&
base::FeatureList::IsEnabled(features::kTabSearchFixedEntrypoint)) {
EXPECT_EQ(tab_strip_region_view()->GetLocalBounds().right(),
tab_search_button()->bounds().right());
}
}
INSTANTIATE_TEST_SUITE_P(All, INSTANTIATE_TEST_SUITE_P(All,
TabStripRegionViewBrowserTest, TabStripRegionViewBrowserTest,
::testing::Values(true, false)); ::testing::Values(true, false));
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