summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-03 21:10:35 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-03 21:10:35 +0000
commit3386fbe6b3b67c3783ad220c45ce0019c85b52b9 (patch)
treeffe65f48f2ee9148954315518cdfa6bac3026a7f
parent175a7a296b06339ee76d59fd8a98507b59aa2187 (diff)
downloadchromium_src-3386fbe6b3b67c3783ad220c45ce0019c85b52b9.zip
chromium_src-3386fbe6b3b67c3783ad220c45ce0019c85b52b9.tar.gz
chromium_src-3386fbe6b3b67c3783ad220c45ce0019c85b52b9.tar.bz2
Fix two bugs in the omnibox2 popup:
- popup frequently flashes white after being updated. This was because rows weren't being laid out after being added so they had zero size after async changes to the model. - text ran off the right side because DrawStringFragment wasn't clamping the output width to the available width. Does this now, and so eliding works. Review URL: http://codereview.chromium.org/101023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15171 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc23
1 files changed, 12 insertions, 11 deletions
diff --git a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc
index 41385d9..04bf2cd 100644
--- a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc
+++ b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc
@@ -242,7 +242,7 @@ void AutocompleteResultView::Paint(ChromeCanvas* canvas) {
x = DrawString(canvas, separator, classifications, true, x,
text_bounds_.y());
- x = DrawString(canvas, match.description, match.description_class, true, x,
+ DrawString(canvas, match.description, match.description_class, true, x,
text_bounds_.y());
}
}
@@ -251,9 +251,11 @@ void AutocompleteResultView::Layout() {
icon_bounds_.SetRect(kRowLeftPadding, (height() - icon_size_) / 2,
icon_size_, icon_size_);
int text_x = icon_bounds_.right() + kIconTextSpacing;
- text_bounds_.SetRect(text_x, (height() - font_.height()) / 2,
- bounds().right() - text_x - kRowRightPadding,
- font_.height());
+ text_bounds_.SetRect(
+ text_x,
+ std::max(0, (height() - font_.height()) / 2),
+ std::max(0, bounds().right() - text_x - kRowRightPadding),
+ font_.height());
}
gfx::Size AutocompleteResultView::GetPreferredSize() {
@@ -431,7 +433,10 @@ int AutocompleteResultView::DrawStringFragment(
int x,
int y) {
ChromeFont display_font = GetFragmentFont(style);
- int string_width = display_font.GetStringWidth(text);
+ // Clamp text width to the available width within the popup so we elide if
+ // necessary.
+ int string_width = std::min(display_font.GetStringWidth(text),
+ width() - kRowRightPadding - x);
canvas->DrawStringInt(text, GetFragmentFont(style),
GetFragmentTextColor(style), x, y, string_width,
display_font.height());
@@ -596,11 +601,7 @@ void AutocompletePopupContentsView::UpdateResultViewsFromResult(
RemoveAllChildViews(true);
for (size_t i = 0; i < result.size(); ++i)
AddChildView(new AutocompleteResultView(this, i, edit_font_));
-
- // Need to schedule a paint here because if we don't and our result count
- // hasn't changed since last time we were shown, we may not repaint to
- // show selection changes.
- SchedulePaint();
+ Layout();
}
gfx::Rect AutocompletePopupContentsView::GetPopupBounds() const {
@@ -767,7 +768,7 @@ void AutocompletePopupContentsView::MakeContentsPath(
void AutocompletePopupContentsView::UpdateBlurRegion() {
// We only support background blurring on Vista with Aero-Glass enabled.
- if (!win_util::ShouldUseVistaFrame())
+ if (!win_util::ShouldUseVistaFrame() || !GetWidget())
return;
// Provide a blurred background effect within the contents region of the