diff options
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit_view_win.cc | 6 | ||||
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit_view_win.h | 4 | ||||
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_popup_view.h | 4 | ||||
-rwxr-xr-x | chrome/browser/autocomplete/autocomplete_popup_view_win.cc | 9 | ||||
-rw-r--r-- | chrome/browser/external_tab_container.cc | 4 | ||||
-rw-r--r-- | chrome/browser/external_tab_container.h | 6 | ||||
-rw-r--r-- | chrome/browser/views/autocomplete/autocomplete_popup_win.cc | 229 | ||||
-rw-r--r-- | chrome/browser/views/autocomplete/autocomplete_popup_win.h | 27 | ||||
-rw-r--r-- | chrome/browser/views/location_bar_view.cc | 9 | ||||
-rw-r--r-- | chrome/browser/views/location_bar_view.h | 7 | ||||
-rw-r--r-- | chrome/browser/views/toolbar_view.cc | 27 | ||||
-rw-r--r-- | chrome/browser/views/toolbar_view.h | 7 |
12 files changed, 295 insertions, 44 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc index cfdf3bc..648a90f 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc +++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc @@ -398,11 +398,13 @@ AutocompleteEditViewWin::AutocompleteEditViewWin( HWND hwnd, Profile* profile, CommandUpdater* command_updater, - bool popup_window_mode) + bool popup_window_mode, + AutocompletePopupPositioner* popup_positioner) : model_(new AutocompleteEditModel(this, controller, profile)), popup_view_(AutocompletePopupView::CreatePopupView(font, this, model_.get(), - profile)), + profile, + popup_positioner)), controller_(controller), parent_view_(parent_view), toolbar_model_(toolbar_model), diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.h b/chrome/browser/autocomplete/autocomplete_edit_view_win.h index 85ea856..9bff0c2 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_win.h +++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.h @@ -16,6 +16,7 @@ #include "chrome/browser/autocomplete/autocomplete.h" #include "chrome/browser/autocomplete/autocomplete_edit_view.h" #include "chrome/browser/toolbar_model.h" +#include "chrome/browser/views/autocomplete/autocomplete_popup_win.h" #include "chrome/common/gfx/chrome_font.h" #include "chrome/common/page_transition_types.h" #include "chrome/views/controls/menu/menu.h" @@ -66,7 +67,8 @@ class AutocompleteEditViewWin HWND hwnd, Profile* profile, CommandUpdater* command_updater, - bool popup_window_mode); + bool popup_window_mode, + AutocompletePopupPositioner* popup_positioner); ~AutocompleteEditViewWin(); views::View* parent_view() const { return parent_view_; } diff --git a/chrome/browser/autocomplete/autocomplete_popup_view.h b/chrome/browser/autocomplete/autocomplete_popup_view.h index 9690ac0..05017e4 100644 --- a/chrome/browser/autocomplete/autocomplete_popup_view.h +++ b/chrome/browser/autocomplete/autocomplete_popup_view.h @@ -18,6 +18,7 @@ class ChromeFont; #if defined(OS_WIN) class AutocompleteEditViewWin; class AutocompleteEditModel; +class AutocompletePopupPositioner; class Profile; #endif @@ -51,7 +52,8 @@ class AutocompletePopupView { const ChromeFont& font, AutocompleteEditViewWin* edit_view, AutocompleteEditModel* edit_model, - Profile* profile); + Profile* profile, + AutocompletePopupPositioner* popup_positioner); #endif }; diff --git a/chrome/browser/autocomplete/autocomplete_popup_view_win.cc b/chrome/browser/autocomplete/autocomplete_popup_view_win.cc index 578edbb..4ae5dd1 100755 --- a/chrome/browser/autocomplete/autocomplete_popup_view_win.cc +++ b/chrome/browser/autocomplete/autocomplete_popup_view_win.cc @@ -683,8 +683,11 @@ AutocompletePopupView* AutocompletePopupView::CreatePopupView( const ChromeFont& font, AutocompleteEditViewWin* edit_view, AutocompleteEditModel* edit_model, - Profile* profile) { - if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableOmnibox2)) - return new AutocompletePopupWin(font, edit_view, edit_model, profile); + Profile* profile, + AutocompletePopupPositioner* popup_positioner) { + if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableOmnibox2)) { + return new AutocompletePopupWin(font, edit_view, edit_model, profile, + popup_positioner); + } return new AutocompletePopupViewWin(font, edit_view, edit_model, profile); } diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc index c424375..821bdd2 100644 --- a/chrome/browser/external_tab_container.cc +++ b/chrome/browser/external_tab_container.cc @@ -346,11 +346,11 @@ views::RootView* ExternalTabContainer::GetRootView() { return const_cast<views::RootView*>(&root_view_); } -bool ExternalTabContainer::IsVisible() { +bool ExternalTabContainer::IsVisible() const { return !!::IsWindowVisible(*this); } -bool ExternalTabContainer::IsActive() { +bool ExternalTabContainer::IsActive() const { return win_util::IsWindowActive(*this); } diff --git a/chrome/browser/external_tab_container.h b/chrome/browser/external_tab_container.h index afbbfc4..2c69beb 100644 --- a/chrome/browser/external_tab_container.h +++ b/chrome/browser/external_tab_container.h @@ -28,7 +28,7 @@ class TabContentsContainerView; // An external tab is a Chrome tab that is meant to displayed in an // external process. This class provides the FocusManger needed by the // TabContents as well as an implementation of TabContentsDelagate. -// It also implements Container +// TODO(beng): Should override WidgetWin instead of Widget. class ExternalTabContainer : public TabContentsDelegate, public NotificationObserver, public views::Widget, @@ -103,8 +103,8 @@ class ExternalTabContainer : public TabContentsDelegate, virtual gfx::NativeView GetNativeView() const; virtual void PaintNow(const gfx::Rect& update_rect); virtual views::RootView* GetRootView(); - virtual bool IsVisible(); - virtual bool IsActive(); + virtual bool IsVisible() const; + virtual bool IsActive() const; virtual bool GetAccelerator(int cmd_id, views::Accelerator* accelerator) { return false; diff --git a/chrome/browser/views/autocomplete/autocomplete_popup_win.cc b/chrome/browser/views/autocomplete/autocomplete_popup_win.cc index 96290e9..6b01ba7 100644 --- a/chrome/browser/views/autocomplete/autocomplete_popup_win.cc +++ b/chrome/browser/views/autocomplete/autocomplete_popup_win.cc @@ -4,22 +4,201 @@ #include "chrome/browser/views/autocomplete/autocomplete_popup_win.h" +#include <dwmapi.h> + #include "chrome/browser/autocomplete/autocomplete_edit_view_win.h" #include "chrome/browser/autocomplete/autocomplete_popup_model.h" +#include "chrome/common/gfx/chrome_canvas.h" +#include "chrome/common/gfx/insets.h" +#include "chrome/common/gfx/path.h" +#include "chrome/common/resource_bundle.h" #include "chrome/common/win_util.h" +#include "grit/theme_resources.h" + +// The stroke color around the popup border. +static const SkColor kEdgeColor = SkColorSetRGB(183, 195, 219); +static const int kPopupTransparency = 235; + +class PopupBorder : public views::Border { + public: + PopupBorder() { + InitClass(); + } + virtual ~PopupBorder() {} + + // Returns the border radius of the edge of the popup. + static int GetBorderRadius() { + InitClass(); + return dropshadow_topleft_->width() - dropshadow_left_->width(); + } + + // Overridden from views::Border: + virtual void Paint(const views::View& view, ChromeCanvas* canvas) const; + virtual void GetInsets(gfx::Insets* insets) const; + + private: + // Border graphics. + static SkBitmap* dropshadow_left_; + static SkBitmap* dropshadow_topleft_; + static SkBitmap* dropshadow_top_; + static SkBitmap* dropshadow_topright_; + static SkBitmap* dropshadow_right_; + static SkBitmap* dropshadow_bottomright_; + static SkBitmap* dropshadow_bottom_; + static SkBitmap* dropshadow_bottomleft_; + + static void InitClass(); + + DISALLOW_COPY_AND_ASSIGN(PopupBorder); +}; + +// static +SkBitmap* PopupBorder::dropshadow_left_ = NULL; +SkBitmap* PopupBorder::dropshadow_topleft_ = NULL; +SkBitmap* PopupBorder::dropshadow_top_ = NULL; +SkBitmap* PopupBorder::dropshadow_topright_ = NULL; +SkBitmap* PopupBorder::dropshadow_right_ = NULL; +SkBitmap* PopupBorder::dropshadow_bottomright_ = NULL; +SkBitmap* PopupBorder::dropshadow_bottom_ = NULL; +SkBitmap* PopupBorder::dropshadow_bottomleft_ = NULL; + +void PopupBorder::Paint(const views::View& view, ChromeCanvas* canvas) const { + int ds_tl_width = dropshadow_topleft_->width(); + int ds_tl_height = dropshadow_topleft_->height(); + int ds_tr_width = dropshadow_topright_->width(); + int ds_tr_height = dropshadow_topright_->height(); + int ds_br_width = dropshadow_bottomright_->width(); + int ds_br_height = dropshadow_bottomright_->height(); + int ds_bl_width = dropshadow_bottomleft_->width(); + int ds_bl_height = dropshadow_bottomleft_->height(); + + canvas->DrawBitmapInt(*dropshadow_topleft_, 0, 0); + canvas->TileImageInt(*dropshadow_top_, ds_tl_width, 0, + view.width() - ds_tr_width - ds_tl_width, + dropshadow_top_->height()); + canvas->DrawBitmapInt(*dropshadow_topright_, view.width() - ds_tr_width, 0); + canvas->TileImageInt(*dropshadow_right_, + view.width() - dropshadow_right_->width(), + ds_tr_height, dropshadow_right_->width(), + view.height() - ds_tr_height - ds_br_height); + canvas->DrawBitmapInt(*dropshadow_bottomright_, view.width() - ds_br_width, + view.height() - ds_br_height); + canvas->TileImageInt(*dropshadow_bottom_, ds_bl_width, + view.height() - dropshadow_bottom_->height(), + view.width() - ds_bl_width - ds_br_width, + dropshadow_bottom_->height()); + canvas->DrawBitmapInt(*dropshadow_bottomleft_, 0, + view.height() - dropshadow_bottomleft_->height()); + canvas->TileImageInt(*dropshadow_left_, 0, ds_tl_height, + dropshadow_left_->width(), + view.height() - ds_tl_height - ds_bl_height); +} + +void PopupBorder::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 in both directions. + insets->Set(dropshadow_top_->height(), dropshadow_left_->width(), + dropshadow_bottom_->height(), dropshadow_right_->width()); +} + +void PopupBorder::InitClass() { + static bool initialized = false; + if (!initialized) { + ResourceBundle& rb = ResourceBundle::GetSharedInstance(); + dropshadow_left_ = rb.GetBitmapNamed(IDR_OMNIBOX_POPUP_DS_L); + dropshadow_topleft_ = rb.GetBitmapNamed(IDR_OMNIBOX_POPUP_DS_TL); + dropshadow_top_ = rb.GetBitmapNamed(IDR_OMNIBOX_POPUP_DS_T); + dropshadow_topright_ = rb.GetBitmapNamed(IDR_OMNIBOX_POPUP_DS_TR); + dropshadow_right_ = rb.GetBitmapNamed(IDR_OMNIBOX_POPUP_DS_R); + dropshadow_bottomright_ = rb.GetBitmapNamed(IDR_OMNIBOX_POPUP_DS_BR); + dropshadow_bottom_ = rb.GetBitmapNamed(IDR_OMNIBOX_POPUP_DS_B); + dropshadow_bottomleft_ = rb.GetBitmapNamed(IDR_OMNIBOX_POPUP_DS_BL); + initialized = true; + } +} + +class AutocompletePopupViewContents : public views::View { + public: + AutocompletePopupViewContents() { + set_border(new PopupBorder); + } + virtual ~AutocompletePopupViewContents() {} + + // Overridden from views::View: + virtual void Paint(ChromeCanvas* canvas); + virtual void Layout(); + + private: + DISALLOW_COPY_AND_ASSIGN(AutocompletePopupViewContents); +}; + +void AutocompletePopupViewContents::Paint(ChromeCanvas* canvas) { + gfx::Rect contents_rect = GetLocalBounds(false); + + { + SkPaint paint; + SkRect rect; + rect.set(SkIntToScalar(contents_rect.x()), + SkIntToScalar(contents_rect.y()), + SkIntToScalar(contents_rect.right()), + SkIntToScalar(contents_rect.bottom())); + + SkScalar radius = SkIntToScalar(PopupBorder::GetBorderRadius()); + paint.setColor(SK_ColorWHITE); + paint.setAntiAlias(true); + paint.setStyle(SkPaint::kFill_Style); + canvas->drawRoundRect(rect, radius, radius, paint); + } + + // Allow the window blur effect to show through the popup background. + SkPaint paint; + paint.setColor(SkColorSetARGB(kPopupTransparency, 255, 255, 255)); + paint.setPorterDuffXfermode(SkPorterDuff::kDstIn_Mode); + paint.setStyle(SkPaint::kFill_Style); + canvas->FillRectInt(contents_rect.x(), contents_rect.y(), + contents_rect.width(), contents_rect.height(), paint); + + // Paint the dropshadow. + PaintBorder(canvas); +} + +void AutocompletePopupViewContents::Layout() { + // Provide a blurred background effect within the contents region of the + // popup. + DWM_BLURBEHIND bb = {0}; + bb.dwFlags = DWM_BB_ENABLE | DWM_BB_BLURREGION; + bb.fEnable = true; + + gfx::Rect contents_rect = GetLocalBounds(false); + gfx::Point origin(contents_rect.origin()); + views::View::ConvertPointToWidget(this, &origin); + contents_rect.set_origin(origin); + + ScopedGDIObject<HRGN> popup_region; + popup_region.Set(CreateRectRgn(contents_rect.x(), contents_rect.y(), + contents_rect.right(), + contents_rect.bottom())); + bb.hRgnBlur = popup_region.Get(); + DwmEnableBlurBehindWindow(GetWidget()->GetNativeView(), &bb); +} //////////////////////////////////////////////////////////////////////////////// // AutocompletePopupWin, public: -AutocompletePopupWin::AutocompletePopupWin(const ChromeFont& font, - AutocompleteEditViewWin* edit_view, - AutocompleteEditModel* edit_model, - Profile* profile) +AutocompletePopupWin::AutocompletePopupWin( + const ChromeFont& font, + AutocompleteEditViewWin* edit_view, + AutocompleteEditModel* edit_model, + Profile* profile, + AutocompletePopupPositioner* popup_positioner) : model_(new AutocompletePopupModel(this, edit_model, profile)), - edit_view_(edit_view) { + edit_view_(edit_view), + popup_positioner_(popup_positioner), + contents_(new AutocompletePopupViewContents) { set_delete_on_destroy(false); set_window_style(WS_POPUP | WS_CLIPCHILDREN); - set_window_ex_style(WS_EX_TOOLWINDOW); + set_window_ex_style(WS_EX_TOOLWINDOW | WS_EX_LAYERED); + contents_ = new AutocompletePopupViewContents; } AutocompletePopupWin::~AutocompletePopupWin() { @@ -29,7 +208,7 @@ AutocompletePopupWin::~AutocompletePopupWin() { // AutocompletePopupWin, AutocompletePopupView overrides: bool AutocompletePopupWin::IsOpen() const { - return false; + return IsWindow() && IsVisible(); } void AutocompletePopupWin::InvalidateLine(size_t line) { @@ -44,15 +223,24 @@ void AutocompletePopupWin::UpdatePopupAppearance() { return; } - gfx::Rect popup_bounds = GetPopupScreenBounds(); + gfx::Rect popup_bounds = GetPopupBounds(); if (!::IsWindow(GetNativeView())) { // Create the popup HWND parent_hwnd = edit_view_->parent_view()->GetWidget()->GetNativeView(); Init(parent_hwnd, popup_bounds, false); - Show(); + SetContentsView(contents_); + + // When an IME is attached to the rich-edit control, retrieve its window + // handle and show this popup window under the IME windows. + // Otherwise, show this popup window under top-most windows. + // TODO(hbono): http://b/1111369 if we exclude this popup window from the + // display area of IME windows, this workaround becomes unnecessary. + HWND ime_window = ImmGetDefaultIMEWnd(edit_view_->m_hWnd); + SetWindowPos(ime_window ? ime_window : HWND_NOTOPMOST, 0, 0, 0, 0, + SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_SHOWWINDOW); } else { // Move the popup - int flags = 0; + int flags = SWP_NOACTIVATE; if (!IsVisible()) flags |= SWP_SHOWWINDOW; win_util::SetChildBounds(GetNativeView(), NULL, NULL, popup_bounds, 0, @@ -73,16 +261,13 @@ AutocompletePopupModel* AutocompletePopupWin::GetModel() { //////////////////////////////////////////////////////////////////////////////// // AutocompletePopupWin, private: -gfx::Rect AutocompletePopupWin::GetPopupScreenBounds() const { - gfx::Point popup_origin; - views::View::ConvertPointToScreen(edit_view_->parent_view(), &popup_origin); - - gfx::Rect popup_bounds(popup_origin, - edit_view_->parent_view()->bounds().size()); - - // The popup starts at the bottom of the edit. - popup_bounds.set_y(popup_bounds.bottom()); - popup_bounds.set_height(100); - return popup_bounds; +gfx::Rect AutocompletePopupWin::GetPopupBounds() const { + gfx::Insets insets; + contents_->border()->GetInsets(&insets); + gfx::Rect contents_bounds = popup_positioner_->GetPopupBounds(); + contents_bounds.set_height(100); // TODO(beng): size to contents (once we have + // contents!) + contents_bounds.Inset(-insets.left(), -insets.top(), -insets.right(), + -insets.bottom()); + return contents_bounds; } - diff --git a/chrome/browser/views/autocomplete/autocomplete_popup_win.h b/chrome/browser/views/autocomplete/autocomplete_popup_win.h index 9c8be43..ed25678 100644 --- a/chrome/browser/views/autocomplete/autocomplete_popup_win.h +++ b/chrome/browser/views/autocomplete/autocomplete_popup_win.h @@ -10,15 +10,26 @@ class AutocompleteEditModel; class AutocompleteEditViewWin; +class AutocompletePopupViewContents; class Profile; +// Interface to retrieve the position of the popup. +class AutocompletePopupPositioner { + public: + // Returns the bounds at which the popup should be shown, in screen + // coordinates. The height is ignored, since the popup is sized to its + // contents automatically. + virtual gfx::Rect GetPopupBounds() const = 0; +}; + class AutocompletePopupWin : public views::WidgetWin, public AutocompletePopupView { public: AutocompletePopupWin(const ChromeFont& font, AutocompleteEditViewWin* edit_view, AutocompleteEditModel* edit_model, - Profile* profile); + Profile* profile, + AutocompletePopupPositioner* popup_positioner); virtual ~AutocompletePopupWin(); // Overridden from AutocompletePopupView: @@ -30,14 +41,22 @@ class AutocompletePopupWin : public views::WidgetWin, virtual AutocompletePopupModel* GetModel(); private: - // Returns the bounds the popup should be created or shown at, in screen - // coordinates. - gfx::Rect GetPopupScreenBounds() const; + // Returns the bounds of the popup window, in screen coordinates, adjusted for + // the amount of drop shadow the contents view may wish to add. + gfx::Rect GetPopupBounds() const; + // The provider of our result set. scoped_ptr<AutocompletePopupModel> model_; + // The edit view that invokes us. AutocompleteEditViewWin* edit_view_; + // An object that tells the popup how to position itself. + AutocompletePopupPositioner* popup_positioner_; + + // The view that holds the result views. + AutocompletePopupViewContents* contents_; + DISALLOW_COPY_AND_ASSIGN(AutocompletePopupWin); }; diff --git a/chrome/browser/views/location_bar_view.cc b/chrome/browser/views/location_bar_view.cc index 2ece304..c1b96b9 100644 --- a/chrome/browser/views/location_bar_view.cc +++ b/chrome/browser/views/location_bar_view.cc @@ -80,7 +80,8 @@ LocationBarView::LocationBarView(Profile* profile, CommandUpdater* command_updater, ToolbarModel* model, Delegate* delegate, - bool popup_window_mode) + bool popup_window_mode, + AutocompletePopupPositioner* popup_positioner) : profile_(profile), command_updater_(command_updater), model_(model), @@ -93,7 +94,8 @@ LocationBarView::LocationBarView(Profile* profile, security_image_view_(profile, model), rss_image_view_(model), popup_window_mode_(popup_window_mode), - first_run_bubble_(this) { + first_run_bubble_(this), + popup_positioner_(popup_positioner) { DCHECK(profile_); SetID(VIEW_ID_LOCATION_BAR); SetFocusable(true); @@ -123,7 +125,8 @@ void LocationBarView::Init() { location_entry_.reset(new AutocompleteEditViewWin(font_, this, model_, this, widget->GetNativeView(), profile_, command_updater_, - popup_window_mode_)); + popup_window_mode_, + popup_positioner_)); // View container for URL edit field. location_entry_view_ = new views::HWNDView; diff --git a/chrome/browser/views/location_bar_view.h b/chrome/browser/views/location_bar_view.h index d0bcdb2..93df32e 100644 --- a/chrome/browser/views/location_bar_view.h +++ b/chrome/browser/views/location_bar_view.h @@ -20,6 +20,7 @@ #include "chrome/views/controls/label.h" #include "chrome/views/painter.h" +class AutocompletePopupPositioner; class CommandUpdater; class GURL; class Profile; @@ -51,7 +52,8 @@ class LocationBarView : public LocationBar, CommandUpdater* command_updater, ToolbarModel* model_, Delegate* delegate, - bool popup_window_mode); + bool popup_window_mode, + AutocompletePopupPositioner* popup_positioner); virtual ~LocationBarView() { } void Init(); @@ -446,6 +448,9 @@ class LocationBarView : public LocationBar, // Used schedule a task for the first run info bubble. ScopedRunnableMethodFactory<LocationBarView> first_run_bubble_; + + // The positioner that places the autocomplete popup. + AutocompletePopupPositioner* popup_positioner_; }; #endif // CHROME_BROWSER_VIEWS_LOCATION_BAR_VIEW_H__ diff --git a/chrome/browser/views/toolbar_view.cc b/chrome/browser/views/toolbar_view.cc index b97fbf8..d5136b6 100644 --- a/chrome/browser/views/toolbar_view.cc +++ b/chrome/browser/views/toolbar_view.cc @@ -69,6 +69,14 @@ static const int kPopupTopSpacingNonGlass = 3; static const int kPopupBottomSpacingNonGlass = 2; static const int kPopupBottomSpacingGlass = 1; +// The vertical distance between the bottom of the omnibox and the top of the +// popup. +static const int kOmniboxPopupVerticalSpacing = 2; +// The number of pixels of margin on the buttons on either side of the omnibox. +// We use this value to inset the bounds returned for the omnibox popup, since +// we want the popup to be only as wide as the visible frame of the omnibox. +static const int kOmniboxButtonsHorizontalMargin = 2; + static SkBitmap* kPopupBackgroundEdge = NULL; BrowserToolbarView::BrowserToolbarView(Browser* browser) @@ -220,7 +228,8 @@ void BrowserToolbarView::CreateCenterStack(Profile *profile) { location_bar_ = new LocationBarView(profile, browser_->command_updater(), model_, this, - display_mode_ == DISPLAYMODE_LOCATION); + display_mode_ == DISPLAYMODE_LOCATION, + this); AddChildView(location_bar_); location_bar_->Init(); @@ -846,6 +855,22 @@ void BrowserToolbarView::ButtonPressed(views::Button* sender) { event_utils::DispositionFromEventFlags(sender->mouse_event_flags())); } +gfx::Rect BrowserToolbarView::GetPopupBounds() const { + gfx::Point origin; + views::View::ConvertPointToScreen(star_, &origin); + origin.set_y(origin.y() + star_->height() + kOmniboxPopupVerticalSpacing); + gfx::Rect popup_bounds(origin.x(), origin.y(), + star_->width() + location_bar_->width() + go_->width(), + 0); + popup_bounds.set_x(popup_bounds.x()); + popup_bounds.set_y(popup_bounds.y()); + popup_bounds.set_width(popup_bounds.width()); + // Inset the bounds a little, since the buttons on either edge of the omnibox + // have invisible padding that makes the popup appear too wide. + popup_bounds.Inset(kOmniboxButtonsHorizontalMargin, 0); + return popup_bounds; +} + // static int BrowserToolbarView::PopupTopSpacing() { return GetWidget()->AsWindow()->GetNonClientView()->UseNativeFrame() ? diff --git a/chrome/browser/views/toolbar_view.h b/chrome/browser/views/toolbar_view.h index 2b25bbc..a384de6 100644 --- a/chrome/browser/views/toolbar_view.h +++ b/chrome/browser/views/toolbar_view.h @@ -13,6 +13,7 @@ #include "chrome/browser/command_updater.h" #include "chrome/browser/encoding_menu_controller_delegate.h" #include "chrome/browser/user_data_manager.h" +#include "chrome/browser/views/autocomplete/autocomplete_popup_win.h" #include "chrome/browser/views/dom_view.h" #include "chrome/browser/views/go_button.h" #include "chrome/browser/views/location_bar_view.h" @@ -42,7 +43,8 @@ class BrowserToolbarView : public views::View, public NotificationObserver, public GetProfilesHelper::Delegate, public CommandUpdater::CommandObserver, - public views::ButtonListener { + public views::ButtonListener, + public AutocompletePopupPositioner { public: explicit BrowserToolbarView(Browser* browser); virtual ~BrowserToolbarView(); @@ -123,6 +125,9 @@ class BrowserToolbarView : public views::View, // Overridden from views::BaseButton::ButtonListener: virtual void ButtonPressed(views::Button* sender); + // Overridden from AutocompletePopupPositioner: + virtual gfx::Rect GetPopupBounds() const; + private: // Types of display mode this toolbar can have. enum DisplayMode { |