Commit 94cd64a2 authored by Anastasia Helfinstein's avatar Anastasia Helfinstein Committed by Commit Bot

Remove max_width from TrayBubbleView::InitParams

This change removes max_width, and renames min_width to preferred_width.

Currently, if max_width is left at its default value (0), any attempt
to set the bubble's width via SetWidth() is blocked, because the width
is clamped to min_width, max_width. Further, there is only one case in
which max_width is initialized to a different value than min_width, so
the decision was made to move the clamping logic from the base class
into that subclass.

Relnotes: N/A
Bug: 973719
Change-Id: I2a1512f5e955834529f4ed5fbb7d3926cfba5d0a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2140591Reviewed-by: default avatarTetsui Ohkubo <tetsui@chromium.org>
Commit-Queue: Anastasia Helfinstein <anastasi@google.com>
Cr-Commit-Position: refs/heads/master@{#757940}
parent 7081e308
......@@ -222,8 +222,7 @@ void AutoclickMenuBubbleController::ShowBubble(AutoclickEventType type,
init_params.insets = gfx::Insets(0, kCollisionWindowWorkAreaInsetsDp,
kCollisionWindowWorkAreaInsetsDp,
kCollisionWindowWorkAreaInsetsDp);
init_params.min_width = kAutoclickMenuWidth;
init_params.max_width = kAutoclickMenuWidth;
init_params.preferred_width = kAutoclickMenuWidth;
init_params.corner_radius = kUnifiedTrayCornerRadius;
init_params.has_shadow = false;
init_params.translucent = true;
......
......@@ -194,8 +194,7 @@ void AutoclickScrollBubbleController::ShowBubble(
// height of kUnifiedMenuPadding.
init_params.insets = gfx::Insets(0, kUnifiedMenuPadding, kUnifiedMenuPadding,
kUnifiedMenuPadding);
init_params.min_width = kAutoclickScrollMenuSizeDips;
init_params.max_width = kAutoclickScrollMenuSizeDips;
init_params.preferred_width = kAutoclickScrollMenuSizeDips;
init_params.max_height = kAutoclickScrollMenuSizeDips;
init_params.corner_radius = kUnifiedTrayCornerRadius;
init_params.has_shadow = false;
......
......@@ -41,11 +41,10 @@ void SwitchAccessBubbleController::ShowBackButton(const gfx::Rect& anchor) {
init_params.anchor_rect = anchor;
init_params.has_shadow = false;
// The back button is a circle, so the max/min width and height are the
// The back button is a circle, so the preferred width and height are the
// diameter, and the corner radius is the circle radius.
init_params.corner_radius = kBackButtonRadiusDip;
init_params.min_width = kBackButtonDiameterDip;
init_params.max_width = kBackButtonDiameterDip;
init_params.preferred_width = kBackButtonDiameterDip;
init_params.max_height = kBackButtonDiameterDip;
back_button_bubble_view_ = new TrayBubbleView(init_params);
......
......@@ -362,8 +362,7 @@ void ImeMenuTray::ShowImeMenuBubbleInternal(bool show_by_click) {
init_params.parent_window = GetBubbleWindowContainer();
init_params.anchor_view = GetBubbleAnchor();
init_params.shelf_alignment = shelf()->alignment();
init_params.min_width = kTrayMenuWidth;
init_params.max_width = kTrayMenuWidth;
init_params.preferred_width = kTrayMenuWidth;
init_params.close_on_deactivate = true;
init_params.show_by_click = show_by_click;
......
......@@ -74,8 +74,7 @@ UnifiedMessageCenterBubble::UnifiedMessageCenterBubble(UnifiedSystemTray* tray)
// Anchor within the overlay container.
init_params.parent_window = tray->GetBubbleWindowContainer();
init_params.anchor_mode = TrayBubbleView::AnchorMode::kRect;
init_params.min_width = kTrayMenuWidth;
init_params.max_width = kTrayMenuWidth;
init_params.preferred_width = kTrayMenuWidth;
init_params.has_shadow = false;
init_params.close_on_deactivate = false;
......
......@@ -471,8 +471,7 @@ void PaletteTray::ShowBubble(bool show_by_click) {
init_params.parent_window = GetBubbleWindowContainer();
init_params.anchor_view = GetBubbleAnchor();
init_params.shelf_alignment = shelf()->alignment();
init_params.min_width = kPaletteWidth;
init_params.max_width = kPaletteWidth;
init_params.preferred_width = kPaletteWidth;
init_params.close_on_deactivate = true;
init_params.show_by_click = show_by_click;
......
......@@ -42,8 +42,7 @@ void PrivacyScreenToastController::ShowToast() {
TrayBubbleView::InitParams init_params;
init_params.shelf_alignment = tray_->shelf()->alignment();
init_params.min_width = kPrivacyScreenToastMinWidth;
init_params.max_width = kPrivacyScreenToastMaxWidth;
init_params.preferred_width = kPrivacyScreenToastMinWidth;
init_params.delegate = this;
init_params.parent_window = tray_->GetBubbleWindowContainer();
init_params.anchor_view = nullptr;
......@@ -136,7 +135,10 @@ void PrivacyScreenToastController::UpdateToastView() {
toast_view_->SetPrivacyScreenEnabled(
/*enabled=*/privacy_screen_controller->GetEnabled(),
/*managed=*/privacy_screen_controller->IsManaged());
bubble_view_->SetWidth(toast_view_->GetPreferredSize().width());
int width = base::ClampToRange(toast_view_->GetPreferredSize().width(),
kPrivacyScreenToastMinWidth,
kPrivacyScreenToastMaxWidth);
bubble_view_->SetPreferredWidth(width);
}
}
......
......@@ -211,7 +211,7 @@ TrayBubbleView::TrayBubbleView(const InitParams& init_params)
params_(init_params),
layout_(nullptr),
delegate_(init_params.delegate),
preferred_width_(init_params.min_width),
preferred_width_(init_params.preferred_width),
bubble_border_(new BubbleBorder(
arrow(),
// Note: for legacy reasons, a shadow is rendered even if |has_shadow|
......@@ -317,8 +317,7 @@ void TrayBubbleView::SetBottomPadding(int padding) {
layout_->set_inside_border_insets(gfx::Insets(0, 0, padding, 0));
}
void TrayBubbleView::SetWidth(int width) {
width = base::ClampToRange(width, params_.min_width, params_.max_width);
void TrayBubbleView::SetPreferredWidth(int width) {
if (preferred_width_ == width)
return;
preferred_width_ = width;
......@@ -426,7 +425,6 @@ base::string16 TrayBubbleView::GetAccessibleWindowTitle() const {
}
gfx::Size TrayBubbleView::CalculatePreferredSize() const {
DCHECK_LE(preferred_width_, params_.max_width);
return gfx::Size(preferred_width_, GetHeightForWidth(preferred_width_));
}
......
......@@ -85,8 +85,7 @@ class ASH_EXPORT TrayBubbleView : public views::BubbleDialogDelegateView,
gfx::Rect anchor_rect;
bool is_anchored_to_status_area = true;
ShelfAlignment shelf_alignment = ShelfAlignment::kBottom;
int min_width = 0;
int max_width = 0;
int preferred_width = 0;
int max_height = 0;
bool close_on_deactivate = true;
// Indicates whether tray bubble view is shown by click on the tray view.
......@@ -120,7 +119,7 @@ class ASH_EXPORT TrayBubbleView : public views::BubbleDialogDelegateView,
void SetBottomPadding(int padding);
// Sets the bubble width.
void SetWidth(int width);
void SetPreferredWidth(int width);
// Returns the border insets. Called by TrayEventFilter.
gfx::Insets GetBorderInsets() const;
......
......@@ -159,8 +159,7 @@ void UnifiedSliderBubbleController::ShowBubble(SliderType slider_type) {
TrayBubbleView::InitParams init_params;
init_params.shelf_alignment = tray_->shelf()->alignment();
init_params.min_width = kTrayMenuWidth;
init_params.max_width = kTrayMenuWidth;
init_params.preferred_width = kTrayMenuWidth;
init_params.delegate = this;
init_params.parent_window = tray_->GetBubbleWindowContainer();
init_params.anchor_view = nullptr;
......
......@@ -79,8 +79,7 @@ UnifiedSystemTrayBubble::UnifiedSystemTrayBubble(UnifiedSystemTray* tray,
TrayBubbleView::InitParams init_params;
init_params.shelf_alignment = tray_->shelf()->alignment();
init_params.min_width = kTrayMenuWidth;
init_params.max_width = kTrayMenuWidth;
init_params.preferred_width = kTrayMenuWidth;
init_params.delegate = tray;
init_params.parent_window = tray->GetBubbleWindowContainer();
init_params.anchor_view = nullptr;
......
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