diff options
Diffstat (limited to 'chrome/browser/views')
-rw-r--r-- | chrome/browser/views/app_launcher.cc | 42 | ||||
-rw-r--r-- | chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc | 65 | ||||
-rw-r--r-- | chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h | 6 | ||||
-rw-r--r-- | chrome/browser/views/bubble_border.cc | 95 | ||||
-rw-r--r-- | chrome/browser/views/bubble_border.h | 20 | ||||
-rw-r--r-- | chrome/browser/views/info_bubble.cc | 2 | ||||
-rw-r--r-- | chrome/browser/views/location_bar_view.cc | 77 | ||||
-rw-r--r-- | chrome/browser/views/location_bar_view.h | 14 | ||||
-rw-r--r-- | chrome/browser/views/toolbar_view.cc | 27 | ||||
-rw-r--r-- | chrome/browser/views/toolbar_view.h | 7 |
10 files changed, 162 insertions, 193 deletions
diff --git a/chrome/browser/views/app_launcher.cc b/chrome/browser/views/app_launcher.cc index fd55086..35c8b07 100644 --- a/chrome/browser/views/app_launcher.cc +++ b/chrome/browser/views/app_launcher.cc @@ -16,7 +16,6 @@ #include "chrome/browser/autocomplete/autocomplete_edit_view.h" #include "chrome/browser/browser.h" #include "chrome/browser/browser_window.h" -#include "chrome/browser/bubble_positioner.h" #include "chrome/browser/in_process_webkit/webkit_context.h" #include "chrome/browser/profile.h" #include "chrome/browser/renderer_host/render_view_host.h" @@ -54,8 +53,9 @@ const int kNavigationEntryYMargin = 1; // Padding between the navigation bar and the render view contents. const int kNavigationBarBottomPadding = 3; -// NavigationBar size. +// NavigationBar constants. const int kNavigationBarHeight = 25; +const int kNavigationBarBorderThickness = 1; // The delta applied to the default font size for the omnibox. const int kAutocompleteEditFontDelta = 3; @@ -147,8 +147,7 @@ void TabContentsDelegateImpl::OpenURLFromTab(TabContents* source, // mode. class NavigationBar : public views::View, - public AutocompleteEditController, - public BubblePositioner { + public AutocompleteEditController { public: explicit NavigationBar(AppLauncher* app_launcher) : app_launcher_(app_launcher), @@ -156,7 +155,12 @@ class NavigationBar : public views::View, SetFocusable(true); location_entry_view_ = new views::NativeViewHost; AddChildView(location_entry_view_); - set_border(views::Border::CreateSolidBorder(1, SK_ColorGRAY)); + set_border(views::Border::CreateSolidBorder(kNavigationBarBorderThickness, + SK_ColorGRAY)); + + AddChildView(&popup_positioning_view_); + popup_positioning_view_.SetVisible(false); + popup_positioning_view_.set_parent_owned(false); } virtual ~NavigationBar() { @@ -186,7 +190,8 @@ class NavigationBar : public views::View, new AutocompleteEditViewWin(font, this, browser->toolbar_model(), this, GetWidget()->GetNativeView(), browser->profile(), - browser->command_updater(), false, this); + browser->command_updater(), false, + &popup_positioning_view_); location_entry_.reset(autocomplete_view); autocomplete_view->Update(NULL); // The Update call above sets the autocomplete text to the current one in @@ -196,7 +201,8 @@ class NavigationBar : public views::View, AutocompleteEditViewGtk* autocomplete_view = new AutocompleteEditViewGtk(this, browser->toolbar_model(), browser->profile(), - browser->command_updater(), false, this); + browser->command_updater(), false, + &popup_positioning_view_); autocomplete_view->Init(); gtk_widget_show_all(autocomplete_view->GetNativeView()); gtk_widget_hide(autocomplete_view->GetNativeView()); @@ -216,21 +222,10 @@ class NavigationBar : public views::View, bounds.width() - 2 * (kNavigationEntryPadding + kNavigationEntryXMargin), bounds.height() - kNavigationEntryYMargin * 2); - } - // BubblePositioner implementation. - virtual gfx::Rect GetLocationStackBounds() const { - gfx::Rect bounds = location_entry_view_->GetBounds( - views::View::APPLY_MIRRORING_TRANSFORMATION); - gfx::Point origin(bounds.x(), bounds.bottom() + kNavigationEntryPadding); - views::View::ConvertPointToScreen(this, &origin); - gfx::Rect rect = gfx::Rect(origin, gfx::Size(500, 0)); - if (UILayoutIsRightToLeft()) { - // Align the window to the right side of the entry view when - // UI is RTL mode. - rect.set_x(rect.x() - (rect.width() - location_entry_view_->width())); - } - return rect; + gfx::Rect popup_positioning_bounds(bounds); + popup_positioning_bounds.Inset(0, -(kNavigationBarBorderThickness + 1)); + popup_positioning_view_.SetBounds(popup_positioning_bounds); } // AutocompleteController implementation. @@ -270,6 +265,11 @@ class NavigationBar : public views::View, NOTIMPLEMENTED(); #endif + // This invisible view is provided to the popup in place of |this|, so the + // popup can size itself against it using the same offsets it does with the + // LocationBarView. + views::View popup_positioning_view_; + DISALLOW_COPY_AND_ASSIGN(NavigationBar); }; diff --git a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc index ae4ad87..7f974a8 100644 --- a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc +++ b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc @@ -12,7 +12,6 @@ #include "base/i18n/rtl.h" #include "chrome/browser/autocomplete/autocomplete_edit_view.h" #include "chrome/browser/autocomplete/autocomplete_popup_model.h" -#include "chrome/browser/bubble_positioner.h" #include "chrome/browser/views/bubble_border.h" #include "gfx/canvas.h" #include "gfx/color_utils.h" @@ -91,13 +90,11 @@ const int kIconVerticalPadding = 2; // bottom of the row. See comment about the use of "minimum" for // kIconVerticalPadding. const int kTextVerticalPadding = 3; -// The padding at the left edge of the row, left of the icon. -const int kRowLeftPadding = 6; -// The padding on the right edge of the row, right of the text. -const int kRowRightPadding = 3; +// The padding at the edges of the row. +const int kRowPadding = 3; // The horizontal distance between the right edge of the icon and the left edge // of the text. -const int kIconTextSpacing = 9; +const int kIconTextSpacing = 4; // The size delta between the font used for the edit and the result rows. Passed // to gfx::Font::DeriveFont. #if !defined(OS_CHROMEOS) @@ -344,14 +341,12 @@ void AutocompleteResultView::Paint(gfx::Canvas* canvas) { } void AutocompleteResultView::Layout() { - icon_bounds_.SetRect(kRowLeftPadding, (height() - icon_size_) / 2, - icon_size_, icon_size_); + icon_bounds_.SetRect(kRowPadding, (height() - icon_size_) / 2, icon_size_, + icon_size_); int text_x = icon_bounds_.right() + kIconTextSpacing; - text_bounds_.SetRect( - text_x, - std::max(0, (height() - font_.height()) / 2), - std::max(0, 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 - kRowPadding), + font_.height()); } gfx::Size AutocompleteResultView::GetPreferredSize() { @@ -476,8 +471,8 @@ int AutocompleteResultView::DrawStringFragment( gfx::Font display_font = GetFragmentFont(style); // 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); + int string_width = + std::min(display_font.GetStringWidth(text), width() - kRowPadding - x); int string_left = mirroring_context_->GetLeft(x, x + string_width); const int flags = force_rtl_directionality ? gfx::Canvas::FORCE_RTL_DIRECTIONALITY : 0; @@ -508,10 +503,10 @@ AutocompletePopupContentsView::AutocompletePopupContentsView( AutocompleteEditView* edit_view, AutocompleteEditModel* edit_model, Profile* profile, - const BubblePositioner* bubble_positioner) + const views::View* location_bar) : model_(new AutocompletePopupModel(this, edit_model, profile)), edit_view_(edit_view), - bubble_positioner_(bubble_positioner), + location_bar_(location_bar), result_font_(font.DeriveFont(kEditFontAdjust)), ignore_mouse_drag_(false), ALLOW_THIS_IN_INITIALIZER_LIST(size_animation_(this)) { @@ -577,10 +572,13 @@ void AutocompletePopupContentsView::UpdatePopupAppearance() { } // Calculate desired bounds. - gfx::Rect location_stack_bounds = - bubble_positioner_->GetLocationStackBounds(); - gfx::Rect new_target_bounds(bubble_border_->GetBounds(location_stack_bounds, - gfx::Size(location_stack_bounds.width(), total_child_height))); + gfx::Rect location_bar_bounds(location_bar_->bounds()); + gfx::Point location; + views::View::ConvertPointToScreen(location_bar_, &location); + location_bar_bounds.set_origin(location); + location_bar_bounds.set_height(location_bar_bounds.height() - 1); + gfx::Rect new_target_bounds(bubble_border_->GetBounds(location_bar_bounds, + gfx::Size(location_bar_bounds.width(), total_child_height))); // If we're animating and our target height changes, reset the animation. // NOTE: If we just reset blindly on _every_ update, then when the user types @@ -787,7 +785,19 @@ void AutocompletePopupContentsView::MakeContentsPath( SkIntToScalar(bounding_rect.bottom())); SkScalar radius = SkIntToScalar(BubbleBorder::GetCornerRadius()); - path->addRoundRect(rect, radius, radius); + SkScalar scaled_radius = + SkScalarMul(radius, (SK_ScalarSqrt2 - SK_Scalar1) * 4 / 3); + path->moveTo(rect.fRight, rect.fTop); + path->lineTo(rect.fRight, rect.fBottom - radius); + path->cubicTo(rect.fRight, rect.fBottom - radius + scaled_radius, + rect.fRight - radius + scaled_radius, rect.fBottom, + rect.fRight - radius, rect.fBottom); + path->lineTo(rect.fLeft + radius, rect.fBottom); + path->cubicTo(rect.fLeft + radius - scaled_radius, rect.fBottom, + rect.fLeft, rect.fBottom - radius + scaled_radius, + rect.fLeft, rect.fBottom - radius); + path->lineTo(rect.fLeft, rect.fTop); + path->close(); } void AutocompletePopupContentsView::UpdateBlurRegion() { @@ -860,14 +870,3 @@ size_t AutocompletePopupContentsView::GetIndexForPoint( } return AutocompletePopupModel::kNoMatch; } - -// static -AutocompletePopupView* AutocompletePopupView::CreatePopupView( - const gfx::Font& font, - AutocompleteEditView* edit_view, - AutocompleteEditModel* edit_model, - Profile* profile, - const BubblePositioner* bubble_positioner) { - return new AutocompletePopupContentsView(font, edit_view, edit_model, - profile, bubble_positioner); -} diff --git a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h index 58d3c3a..31237c4 100644 --- a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h +++ b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h @@ -45,7 +45,7 @@ class AutocompletePopupContentsView : public views::View, AutocompleteEditView* edit_view, AutocompleteEditModel* edit_model, Profile* profile, - const BubblePositioner* bubble_positioner); + const views::View* location_bar); virtual ~AutocompletePopupContentsView() {} // Returns the bounds the popup should be shown at. This is the display bounds @@ -122,8 +122,8 @@ class AutocompletePopupContentsView : public views::View, // The edit view that invokes us. AutocompleteEditView* edit_view_; - // An object that tells the popup how to position itself. - const BubblePositioner* bubble_positioner_; + // An object that the popup positions itself against. + const views::View* location_bar_; // Our border, which can compute our desired bounds. const BubbleBorder* bubble_border_; diff --git a/chrome/browser/views/bubble_border.cc b/chrome/browser/views/bubble_border.cc index 230a0f4..d7bd07f 100644 --- a/chrome/browser/views/bubble_border.cc +++ b/chrome/browser/views/bubble_border.cc @@ -1,6 +1,6 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this -// source code is governed by a BSD-style license that can be found in the -// LICENSE file. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. #include "chrome/browser/views/bubble_border.h" @@ -31,10 +31,6 @@ static const int kArrowInteriorHeight = 7; 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; @@ -43,6 +39,10 @@ gfx::Rect BubbleBorder::GetBounds(const gfx::Rect& position_relative_to, insets.top() + insets.bottom()); // Screen position depends on the arrow location. + // The arrow should overlap the target by some amount since the bottom arrow + // has lots of shadow below it and the top arrow is given an equivalent amount + // of padding. + const int kArrowOverlap = 3; int x = position_relative_to.x() + (position_relative_to.width() / 2); if (arrow_is_left()) x -= arrow_x_offset_; @@ -51,25 +51,26 @@ gfx::Rect BubbleBorder::GetBounds(const gfx::Rect& position_relative_to, else x += (arrow_x_offset_ - border_size.width() + 1); int y = position_relative_to.y(); - if (arrow_is_top()) { - y += (position_relative_to.height() - - (top_arrow_->height() - kBubbleSpacing)); - } else if (arrow_location_ == NONE) { - y += (position_relative_to.height() - (top_->height() - kBubbleSpacing)); - } else { - y += ((bottom_arrow_->height() - kBubbleSpacing) - border_size.height()); - } + if (arrow_is_bottom()) + y += (kArrowOverlap - border_size.height()); + else if (arrow_location_ == NONE) + y += position_relative_to.height(); + else + y += (position_relative_to.height() - kArrowOverlap); return gfx::Rect(x, y, border_size.width(), border_size.height()); } void BubbleBorder::GetInsets(gfx::Insets* insets) const { - int top = top_->height(); - int bottom = bottom_->height(); - if (arrow_is_top()) - top = std::max(top, top_arrow_->height()); - else if (arrow_location_ != NONE) - bottom = std::max(bottom, bottom_arrow_->height()); + int top, bottom; + if (arrow_is_bottom()) { + top = top_->height(); + bottom = std::max(bottom_->height(), bottom_arrow_->height()); + } else { + top = (arrow_location_ == NONE) ? + 0 : std::max(top_->height(), top_arrow_->height()); + bottom = bottom_->height(); + } insets->Set(top, left_->width(), bottom, right_->width()); } @@ -132,25 +133,33 @@ void BubbleBorder::Paint(const views::View& view, gfx::Canvas* canvas) const { * border_bottom∙∙∙∙└────┴─┤ ▼ ├──────┤ ▼ ├─┴────┘ * view.height()∙∙∙∙∙∙∙∙∙∙∙└───┘ └───┘ * - * (At most one of the arrows will be drawn) + * If |arrow_location_| == NONE, the entire top edge is ommitted, and + * |tl_bottom| == |tr_bottom| == 0. Otherwise, one of the four arrows will be + * drawn. */ gfx::Insets insets; GetInsets(&insets); int top = insets.top(); - int border_top = top - t_height; - int tl_bottom = border_top + tl_height; - int tr_bottom = border_top + tr_height; int bottom = view.height() - insets.bottom(); int border_bottom = bottom + b_height; int bl_y = border_bottom - bl_height; int br_y = border_bottom - br_height; - // Top left corner - canvas->DrawBitmapInt(*top_left_, 0, border_top); + int border_top, tl_bottom, tr_bottom; + if (arrow_location_ == NONE) { + border_top = tl_bottom = tr_bottom = 0; + } else { + border_top = top - t_height; + tl_bottom = border_top + tl_height; + tr_bottom = border_top + tr_height; + + // Top left corner + canvas->DrawBitmapInt(*top_left_, 0, border_top); - // Top right corner - canvas->DrawBitmapInt(*top_right_, width - tr_width, border_top); + // Top right corner + canvas->DrawBitmapInt(*top_right_, width - tr_width, border_top); + } // Right edge canvas->TileImageInt(*right_, width - r_width, tr_bottom, r_width, @@ -167,7 +176,7 @@ void BubbleBorder::Paint(const views::View& view, gfx::Canvas* canvas) const { canvas->TileImageInt(*left_, 0, tl_bottom, left_->width(), bl_y - tl_bottom); // Arrow edge, if necessary - bool should_draw_top_edge = true; + bool should_draw_top_edge = false; bool should_draw_bottom_edge = true; if (arrow_location_ != NONE) { /* Here's what the variables below mean (without loss of generality): @@ -194,17 +203,8 @@ void BubbleBorder::Paint(const views::View& view, gfx::Canvas* canvas) const { SkBitmap* arrow; int left_of_edge, right_of_edge, edge_y, arrow_y; SkScalar border_y, tip_y; - if (arrow_is_top()) { - should_draw_top_edge = false; - edge = top_; - arrow = top_arrow_; - left_of_edge = tl_width; - right_of_edge = tr_width; - edge_y = border_top; - arrow_y = top - top_arrow_->height(); - border_y = SkIntToScalar(top); - tip_y = SkIntToScalar(top - kArrowInteriorHeight); - } else { + if (arrow_is_bottom()) { + should_draw_top_edge = true; should_draw_bottom_edge = false; edge = bottom_; arrow = bottom_arrow_; @@ -213,8 +213,17 @@ void BubbleBorder::Paint(const views::View& view, gfx::Canvas* canvas) const { edge_y = arrow_y = bottom; border_y = SkIntToScalar(bottom); tip_y = SkIntToScalar(bottom + kArrowInteriorHeight); + } else { + edge = top_; + arrow = top_arrow_; + left_of_edge = tl_width; + right_of_edge = tr_width; + edge_y = border_top; + arrow_y = top - top_arrow_->height(); + border_y = SkIntToScalar(top); + tip_y = SkIntToScalar(top - kArrowInteriorHeight); } - int arrow_width = (arrow_is_top() ? top_arrow_ : bottom_arrow_)->width(); + int arrow_width = arrow->width(); int arrow_center = arrow_is_left() ? arrow_x_offset_ : width - arrow_x_offset_ - 1; int arrow_x = arrow_center - (arrow_width / 2); @@ -271,6 +280,8 @@ void BubbleBorder::Paint(const views::View& view, gfx::Canvas* canvas) const { void BubbleBackground::Paint(gfx::Canvas* canvas, views::View* view) const { // The border of this view creates an anti-aliased round-rect region for the // contents, which we need to fill with the background color. + // NOTE: This doesn't handle an arrow location of "NONE", which has square top + // corners. SkPaint paint; paint.setAntiAlias(true); paint.setStyle(SkPaint::kFill_Style); diff --git a/chrome/browser/views/bubble_border.h b/chrome/browser/views/bubble_border.h index 3b48048..e2d5de3 100644 --- a/chrome/browser/views/bubble_border.h +++ b/chrome/browser/views/bubble_border.h @@ -1,6 +1,6 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this -// source code is governed by a BSD-style license that can be found in the -// LICENSE file. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. #ifndef CHROME_BROWSER_VIEWS_BUBBLE_BORDER_H_ #define CHROME_BROWSER_VIEWS_BUBBLE_BORDER_H_ @@ -11,8 +11,11 @@ class SkBitmap; -// Renders a round-rect border, with optional arrow (off by default), and a -// custom dropshadow. This can be used to produce floating "bubble" objects. +// Renders a border, with optional arrow (off by default), and a custom +// dropshadow. This can be used to produce floating "bubble" objects. +// +// If the arrow is on, the bubble has four round corner. If not, it has round +// corners on the bottom and square corners on the top, and lacks a top border. class BubbleBorder : public views::Border { public: // Possible locations for the (optional) arrow. @@ -68,9 +71,10 @@ class BubbleBorder : public views::Border { virtual ~BubbleBorder() { } - // Returns true if there is an arrow and it is positioned on the top edge. - bool arrow_is_top() const { - return (arrow_location_ == TOP_LEFT) || (arrow_location_ == TOP_RIGHT); + // Returns true if there is an arrow and it is positioned on the bottom edge. + bool arrow_is_bottom() const { + return (arrow_location_ == BOTTOM_LEFT) || + (arrow_location_ == BOTTOM_RIGHT); } // Returns true if there is an arrow and it is positioned on the left side. diff --git a/chrome/browser/views/info_bubble.cc b/chrome/browser/views/info_bubble.cc index e5c4858..218decd 100644 --- a/chrome/browser/views/info_bubble.cc +++ b/chrome/browser/views/info_bubble.cc @@ -128,6 +128,8 @@ void BorderContents::InitAndGetBounds( void BorderContents::Paint(gfx::Canvas* canvas) { // The border of this view creates an anti-aliased round-rect region for the // contents, which we need to fill with the background color. + // NOTE: This doesn't handle an arrow location of "NONE", which has square top + // corners. SkPaint paint; paint.setAntiAlias(true); paint.setStyle(SkPaint::kFill_Style); diff --git a/chrome/browser/views/location_bar_view.cc b/chrome/browser/views/location_bar_view.cc index 324731f..4ea36e2 100644 --- a/chrome/browser/views/location_bar_view.cc +++ b/chrome/browser/views/location_bar_view.cc @@ -17,7 +17,6 @@ #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/alternate_nav_url_fetcher.h" #include "chrome/browser/browser_list.h" -#include "chrome/browser/bubble_positioner.h" #include "chrome/browser/command_updater.h" #include "chrome/browser/content_setting_bubble_model.h" #include "chrome/browser/content_setting_image_model.h" @@ -126,8 +125,7 @@ LocationBarView::LocationBarView(Profile* profile, CommandUpdater* command_updater, ToolbarModel* model, Delegate* delegate, - bool popup_window_mode, - const BubblePositioner* bubble_positioner) + bool popup_window_mode) : profile_(profile), command_updater_(command_updater), model_(model), @@ -140,8 +138,7 @@ LocationBarView::LocationBarView(Profile* profile, type_to_search_view_(l10n_util::GetString(IDS_OMNIBOX_EMPTY_TEXT)), star_view_(command_updater), popup_window_mode_(popup_window_mode), - first_run_bubble_(this), - bubble_positioner_(bubble_positioner) { + first_run_bubble_(this) { DCHECK(profile_); SetID(VIEW_ID_LOCATION_BAR); SetFocusable(true); @@ -175,10 +172,10 @@ void LocationBarView::Init() { #if defined(OS_WIN) location_entry_.reset(new AutocompleteEditViewWin(font_, this, model_, this, GetWidget()->GetNativeView(), profile_, command_updater_, - popup_window_mode_, bubble_positioner_)); + popup_window_mode_, this)); #else location_entry_.reset(new AutocompleteEditViewGtk(this, model_, profile_, - command_updater_, popup_window_mode_, bubble_positioner_)); + command_updater_, popup_window_mode_, this)); location_entry_->Init(); // Make all the children of the widget visible. NOTE: this won't display // anything, it just toggles the visible flag. @@ -217,9 +214,8 @@ void LocationBarView::Init() { security_info_label_.set_parent_owned(false); for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { - ContentSettingImageView* content_blocked_view = - new ContentSettingImageView(static_cast<ContentSettingsType>(i), this, - profile_, bubble_positioner_); + ContentSettingImageView* content_blocked_view = new ContentSettingImageView( + static_cast<ContentSettingsType>(i), this, profile_); content_setting_views_.push_back(content_blocked_view); AddChildView(content_blocked_view); content_blocked_view->SetVisible(false); @@ -402,13 +398,14 @@ void LocationBarView::SetStarToggled(bool on) { } void LocationBarView::ShowStarBubble(const GURL& url, bool newly_bookmarked) { - gfx::Rect bounds(bubble_positioner_->GetLocationStackBounds()); - gfx::Point location; - views::View::ConvertPointToScreen(&star_view_, &location); - bounds.set_x(location.x()); - bounds.set_width(star_view_.width()); - browser::ShowBookmarkBubbleView(GetWindow(), bounds, &star_view_, profile_, - url, newly_bookmarked); + gfx::Rect screen_bounds(star_view_.GetImageBounds()); + // Compensate for some built-in padding in the Star image. + screen_bounds.Inset(1, 1, 1, 2); + gfx::Point origin(screen_bounds.origin()); + views::View::ConvertPointToScreen(&star_view_, &origin); + screen_bounds.set_origin(origin); + browser::ShowBookmarkBubbleView(GetWindow(), screen_bounds, &star_view_, + profile_, url, newly_bookmarked); } gfx::Size LocationBarView::GetPreferredSize() { @@ -1188,15 +1185,13 @@ void LocationBarView::KeywordHintView::Layout() { LocationBarView::ContentSettingImageView::ContentSettingImageView( ContentSettingsType content_type, const LocationBarView* parent, - Profile* profile, - const BubblePositioner* bubble_positioner) + Profile* profile) : content_setting_image_model_( ContentSettingImageModel::CreateContentSettingImageModel( content_type)), parent_(parent), profile_(profile), - info_bubble_(NULL), - bubble_positioner_(bubble_positioner) { + info_bubble_(NULL) { } LocationBarView::ContentSettingImageView::~ContentSettingImageView() { @@ -1237,11 +1232,10 @@ void LocationBarView::ContentSettingImageView::OnMouseReleased( if (!tab_contents) return; - gfx::Rect bounds(bubble_positioner_->GetLocationStackBounds()); - gfx::Point location; - views::View::ConvertPointToScreen(this, &location); - bounds.set_x(location.x()); - bounds.set_width(width()); + gfx::Rect screen_bounds(GetImageBounds()); + gfx::Point origin(screen_bounds.origin()); + views::View::ConvertPointToScreen(this, &origin); + screen_bounds.set_origin(origin); ContentSettingBubbleContents* bubble_contents = new ContentSettingBubbleContents( ContentSettingBubbleModel::CreateContentSettingBubbleModel( @@ -1249,7 +1243,8 @@ void LocationBarView::ContentSettingImageView::OnMouseReleased( content_setting_image_model_->get_content_settings_type()), profile_, tab_contents); DCHECK(!info_bubble_); - info_bubble_ = InfoBubble::Show(GetWindow(), bounds, bubble_contents, this); + info_bubble_ = + InfoBubble::Show(GetWindow(), screen_bounds, bubble_contents, this); bubble_contents->set_info_bubble(info_bubble_); } @@ -1333,19 +1328,17 @@ void LocationBarView::PageActionImageView::ExecuteAction(int button, if (popup_showing) return; - View* parent = GetParent(); - gfx::Point origin; - View::ConvertPointToScreen(parent, &origin); - gfx::Rect rect = parent->bounds(); - rect.set_x(origin.x()); - rect.set_y(origin.y()); + gfx::Rect screen_bounds(GetImageBounds()); + gfx::Point origin(screen_bounds.origin()); + View::ConvertPointToScreen(this, &origin); + screen_bounds.set_origin(origin); popup_ = ExtensionPopup::Show( page_action_->GetPopupUrl(current_tab_id_), browser, browser->profile(), browser->window()->GetNativeHandle(), - rect, + screen_bounds, BubbleBorder::TOP_RIGHT, true, // Activate the popup window. inspect_with_devtools, @@ -1378,20 +1371,20 @@ void LocationBarView::PageActionImageView::OnMouseReleased( button = 2; } else if (event.IsRightMouseButton()) { // Get the top left point of this button in screen coordinates. - gfx::Point point = gfx::Point(0, 0); - ConvertPointToScreen(this, &point); + gfx::Point menu_origin; + ConvertPointToScreen(this, &menu_origin); // Make the menu appear below the button. - point.Offset(0, height()); + menu_origin.Offset(0, height()); Extension* extension = profile_->GetExtensionsService()->GetExtensionById( page_action()->extension_id(), false); Browser* browser = BrowserView::GetBrowserViewForNativeWindow( platform_util::GetTopLevel(GetWidget()->GetNativeView()))->browser(); - context_menu_contents_ = new ExtensionContextMenuModel( - extension, browser, this); + context_menu_contents_ = + new ExtensionContextMenuModel(extension, browser, this)); context_menu_menu_.reset(new views::Menu2(context_menu_contents_.get())); - context_menu_menu_->RunContextMenuAt(point); + context_menu_menu_->RunContextMenuAt(menu_origin); return; } @@ -1426,8 +1419,8 @@ void LocationBarView::PageActionImageView::UpdateVisibility( current_tab_id_ = ExtensionTabUtil::GetTabId(contents); current_url_ = url; - bool visible = preview_enabled_ || - page_action_->GetIsVisible(current_tab_id_); + bool visible = + preview_enabled_ || page_action_->GetIsVisible(current_tab_id_); if (visible) { // Set the tooltip. tooltip_ = page_action_->GetTitle(current_tab_id_); diff --git a/chrome/browser/views/location_bar_view.h b/chrome/browser/views/location_bar_view.h index dee0ee2..2be8812 100644 --- a/chrome/browser/views/location_bar_view.h +++ b/chrome/browser/views/location_bar_view.h @@ -37,7 +37,6 @@ #endif class Browser; -class BubblePositioner; class CommandUpdater; class ContentSettingImageModel; class ExtensionAction; @@ -82,8 +81,7 @@ class LocationBarView : public LocationBar, CommandUpdater* command_updater, ToolbarModel* model, Delegate* delegate, - bool popup_window_mode, - const BubblePositioner* bubble_positioner); + bool popup_window_mode); virtual ~LocationBarView(); void Init(); @@ -318,8 +316,7 @@ class LocationBarView : public LocationBar, public: ContentSettingImageView(ContentSettingsType content_type, const LocationBarView* parent, - Profile* profile, - const BubblePositioner* bubble_positioner); + Profile* profile); virtual ~ContentSettingImageView(); void set_profile(Profile* profile) { profile_ = profile; } @@ -347,10 +344,6 @@ class LocationBarView : public LocationBar, // The currently shown info bubble if any. InfoBubble* info_bubble_; - // A positioner used to give the info bubble the correct target bounds. The - // caller maintains ownership of this and must ensure it's kept alive. - const BubblePositioner* bubble_positioner_; - DISALLOW_IMPLICIT_CONSTRUCTORS(ContentSettingImageView); }; typedef std::vector<ContentSettingImageView*> ContentSettingViews; @@ -591,9 +584,6 @@ class LocationBarView : public LocationBar, // Used schedule a task for the first run info bubble. ScopedRunnableMethodFactory<LocationBarView> first_run_bubble_; - // The positioner that places the omnibox and info bubbles. - const BubblePositioner* bubble_positioner_; - // Storage of string needed for accessibility. std::wstring accessible_name_; diff --git a/chrome/browser/views/toolbar_view.cc b/chrome/browser/views/toolbar_view.cc index 97224d1..e69ff0f 100644 --- a/chrome/browser/views/toolbar_view.cc +++ b/chrome/browser/views/toolbar_view.cc @@ -305,30 +305,6 @@ void ToolbarView::ButtonPressed(views::Button* sender, } //////////////////////////////////////////////////////////////////////////////// -// ToolbarView, BubblePositioner implementation: - -gfx::Rect ToolbarView::GetLocationStackBounds() const { - // The number of pixels from the left or right edges of the location stack to - // "just inside the visible borders". When the omnibox bubble contents are - // aligned with this, the visible borders tacked on to the outsides will line - // up with the visible borders on the location stack. - const int kLocationStackEdgeWidth = 2; - - gfx::Point origin; - views::View::ConvertPointToScreen(reload_, &origin); - gfx::Rect stack_bounds(origin.x(), origin.y(), - reload_->width() + location_bar_->width() + go_->width(), - location_bar_->height()); - if (UILayoutIsRightToLeft()) { - stack_bounds.set_x( - stack_bounds.x() - location_bar_->width() - go_->width()); - } - // Inset the bounds to just inside the visible edges (see comment above). - stack_bounds.Inset(kLocationStackEdgeWidth, 0); - return stack_bounds; -} - -//////////////////////////////////////////////////////////////////////////////// // ToolbarView, NotificationObserver implementation: void ToolbarView::Observe(NotificationType type, @@ -620,8 +596,7 @@ void ToolbarView::CreateCenterStack(Profile *profile) { location_bar_ = new LocationBarView(profile, browser_->command_updater(), model_, this, - display_mode_ == DISPLAYMODE_LOCATION, - this); + display_mode_ == DISPLAYMODE_LOCATION); // The Go button. go_ = new GoButton(location_bar_, browser_); diff --git a/chrome/browser/views/toolbar_view.h b/chrome/browser/views/toolbar_view.h index 86e3249..6e45799 100644 --- a/chrome/browser/views/toolbar_view.h +++ b/chrome/browser/views/toolbar_view.h @@ -11,7 +11,6 @@ #include "base/scoped_ptr.h" #include "chrome/browser/app_menu_model.h" #include "chrome/browser/back_forward_menu_model.h" -#include "chrome/browser/bubble_positioner.h" #include "chrome/browser/command_updater.h" #include "chrome/browser/page_menu_model.h" #include "chrome/browser/pref_member.h" @@ -40,8 +39,7 @@ class ToolbarView : public AccessibleToolbarView, public LocationBarView::Delegate, public NotificationObserver, public CommandUpdater::CommandObserver, - public views::ButtonListener, - public BubblePositioner { + public views::ButtonListener { public: explicit ToolbarView(Browser* browser); virtual ~ToolbarView(); @@ -112,9 +110,6 @@ class ToolbarView : public AccessibleToolbarView, // Overridden from views::BaseButton::ButtonListener: virtual void ButtonPressed(views::Button* sender, const views::Event& event); - // BubblePositioner: - virtual gfx::Rect GetLocationStackBounds() const; - // Overridden from NotificationObserver: virtual void Observe(NotificationType type, const NotificationSource& source, |