Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1324)

Unified Diff: chrome/browser/views/bubble_border.cc

Issue 194110: Convert the AutocompletePopupPositioner into a BubblePositioner in preparatio... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/views/bubble_border.cc
===================================================================
--- chrome/browser/views/bubble_border.cc (revision 26251)
+++ chrome/browser/views/bubble_border.cc (working copy)
@@ -21,10 +21,27 @@
SkBitmap* BubbleBorder::bottom_ = NULL;
SkBitmap* BubbleBorder::bottom_left_ = NULL;
+gfx::Rect BubbleBorder::GetBounds(const gfx::Rect& position_relative_to,
+ const gfx::Size& contents_size) const {
+ // The spacing (in pixels) between |position_relative_to| and the bubble
+ // content.
+ const int kBubbleSpacing = 2;
+
+ // Desired size is size of contents enlarged by the size of the border images.
+ gfx::Size border_size(contents_size);
+ gfx::Insets insets;
+ GetInsets(&insets);
+ border_size.Enlarge(insets.left() + insets.right(),
+ insets.top() + insets.bottom());
+
+ int x = position_relative_to.x() + (position_relative_to.width() / 2) -
+ (contents_size.width() / 2) - insets.left();
+ int y = position_relative_to.bottom() - (top_->height() - kBubbleSpacing);
+
+ return gfx::Rect(x, y, border_size.width(), border_size.height());
+}
+
void BubbleBorder::GetInsets(gfx::Insets* insets) const {
- // The left, right and bottom edge image sizes define our insets. The corner
- // images don't determine this because they can extend inside the border (onto
- // the contained contents).
insets->Set(top_->height(), left_->width(), bottom_->height(),
right_->width());
}
@@ -109,6 +126,7 @@
// Bottom edge
canvas->TileImageInt(*bottom_, bl_width, bottom, width - bl_width - br_width,
b_height);
+
// Bottom left corner
canvas->DrawBitmapInt(*bottom_left_, 0, bl_y);

Powered by Google App Engine
This is Rietveld 408576698