Commit c9a56a17 authored by Dana Fried's avatar Dana Fried Committed by Commit Bot

Fix browser actions container snapping during drag.

Logic for max size is now consistent with animation/dragging.
Animation correctly plays if drag does not end at exact size.

This is not a complete fix for extensions dragging.

Bug: 916209
Change-Id: Iccb0d11bbe540a16edec0720105d272e091cf43d
Reviewed-on: https://chromium-review.googlesource.com/c/1492049
Commit-Queue: Dana Fried <dfried@chromium.org>
Reviewed-by: default avatarDana Fried <dfried@chromium.org>
Reviewed-by: default avatarBret Sepulveda <bsep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#636653}
parent ffd89042
......@@ -355,13 +355,28 @@ views::FlexRule BrowserActionsContainer::GetFlexRule() {
[](const views::View* view, const views::SizeBounds& maximum_size) {
const BrowserActionsContainer* browser_actions =
static_cast<const BrowserActionsContainer*>(view);
gfx::Size size = browser_actions->GetPreferredSize();
gfx::Size preferred_size = browser_actions->GetPreferredSize();
if (maximum_size.width()) {
size.set_width(
browser_actions->GetWidthForMaxWidth(*maximum_size.width()));
int width;
if (browser_actions->resizing() || browser_actions->animating()) {
// When there are actions present, the floor on the size of the
// browser actions bar should be the resize handle.
const int min_width = browser_actions->num_toolbar_actions() == 0
? 0
: browser_actions->GetResizeAreaWidth();
// The ceiling on the value is the lesser of the preferred and
// available size.
width = std::max(min_width, std::min(preferred_size.width(),
*maximum_size.width()));
} else {
// When not animating or resizing, the desired width should always
// be based on the number of icons that can be displayed.
width = browser_actions->GetWidthForMaxWidth(*maximum_size.width());
}
preferred_size =
gfx::Size(width, browser_actions->GetHeightForWidth(width));
}
size.set_height(browser_actions->GetHeightForWidth(size.width()));
return size;
return preferred_size;
});
}
......
......@@ -164,6 +164,9 @@ class BrowserActionsContainer : public views::View,
return resize_animation_ && resize_animation_->is_animating();
}
// Is the view being resized?
bool resizing() const { return resize_starting_width_.has_value(); }
// Returns the ID of the action represented by the view at |index|.
std::string GetIdAt(size_t index) const;
......
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