diff options
author | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-21 21:50:51 +0000 |
---|---|---|
committer | finnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-21 21:50:51 +0000 |
commit | f1e078ee676a83af09812986e1b376c580ac36de (patch) | |
tree | 6a38e4b9a7656a582a6ed58757d6270672de3072 /chrome | |
parent | d1b979e6bb8e590b78d06be4b56020dd5fdc5952 (diff) | |
download | chromium_src-f1e078ee676a83af09812986e1b376c580ac36de.zip chromium_src-f1e078ee676a83af09812986e1b376c580ac36de.tar.gz chromium_src-f1e078ee676a83af09812986e1b376c580ac36de.tar.bz2 |
Fix clipping issue on extension shelf (when detached).
BUG=22557
TEST=Open NTP, detach the extension shelf and resize the browser horizontally. Toolstrips should not draw outside the extension shelf border.
Review URL: http://codereview.chromium.org/211046
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26742 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/views/extensions/extension_shelf.cc | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/chrome/browser/views/extensions/extension_shelf.cc b/chrome/browser/views/extensions/extension_shelf.cc index ad26e77..5570acc 100644 --- a/chrome/browser/views/extensions/extension_shelf.cc +++ b/chrome/browser/views/extensions/extension_shelf.cc @@ -710,10 +710,16 @@ ExtensionShelf::~ExtensionShelf() { void ExtensionShelf::PaintChildren(gfx::Canvas* canvas) { InitBackground(canvas); + int max_x = width(); + if (IsDetached()) + max_x -= 2 * kNewtabHorizontalPadding; + // Draw vertical dividers between Toolstrip items in the Extension shelf. int count = GetChildViewCount(); for (int i = 0; i < count; ++i) { int right = GetChildViewAt(i)->bounds().right() + kToolstripPadding; + if (right >= max_x) + break; int vertical_padding = IsDetached() ? (height() - kShelfHeight) / 2 : 1; DetachableToolbarView::PaintVerticalDivider( @@ -1036,7 +1042,7 @@ gfx::Size ExtensionShelf::LayoutItems(bool compute_bounds_only) { y += static_cast<int>(static_cast<double> (kNewtabVerticalPadding + kNewtabExtraVerMargin) * current_state); max_x -= static_cast<int>(static_cast<double> - (kNewtabHorizontalPadding) * current_state); + (2 * kNewtabHorizontalPadding) * current_state); } int count = model_->count(); @@ -1047,10 +1053,15 @@ gfx::Size ExtensionShelf::LayoutItems(bool compute_bounds_only) { continue; View* view = toolstrip->GetShelfView(); gfx::Size pref = view->GetPreferredSize(); + + // |next_x| is the x value for where the next toolstrip in the list will be. int next_x = x + pref.width() + kToolstripPadding; // Right padding. if (!compute_bounds_only) { + bool clipped = next_x >= max_x; + if (clipped) + pref.set_width(std::max(0, max_x - x)); if (view == toolstrip->view()) - toolstrip->view()->set_is_clipped(next_x >= max_x); + toolstrip->view()->set_is_clipped(clipped); view->SetBounds(x, y, pref.width(), content_height); view->Layout(); if (toolstrip->window_visible()) |