summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorsaintlou@chromium.org <saintlou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-23 20:44:57 +0000
committersaintlou@chromium.org <saintlou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-23 20:44:57 +0000
commitd1e4a3dc13d6dd1d54b264b1afdd61aa329a787d (patch)
tree8c8175fc4583af340098d0ba36ade986ca1dca03 /chrome
parent821960ab4a099ee5f674211a64b620893cf7a2c8 (diff)
downloadchromium_src-d1e4a3dc13d6dd1d54b264b1afdd61aa329a787d.zip
chromium_src-d1e4a3dc13d6dd1d54b264b1afdd61aa329a787d.tar.gz
chromium_src-d1e4a3dc13d6dd1d54b264b1afdd61aa329a787d.tar.bz2
Revert "This is a redo of http://codereview.chromium.org/7629009/"
This reverts commit 59e1c15b1ee0e29742a2479527de09715a2e5525. TBR=saintlou@chromium.org BUG=none TEST=none Review URL: http://codereview.chromium.org/7720010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97914 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/chromeos/frame/bubble_frame_view.cc6
-rw-r--r--chrome/browser/chromeos/login/message_bubble.cc19
-rw-r--r--chrome/browser/chromeos/login/message_bubble.h19
-rw-r--r--chrome/browser/chromeos/login/screen_locker.cc12
-rw-r--r--chrome/browser/chromeos/login/screen_locker.h2
-rw-r--r--chrome/browser/chromeos/login/views_login_display.cc6
-rw-r--r--chrome/browser/chromeos/login/views_network_screen_actor.cc2
-rw-r--r--chrome/browser/chromeos/setting_level_bubble.cc2
-rw-r--r--chrome/browser/chromeos/status/network_menu_button.cc2
-rw-r--r--chrome/browser/external_tab_container_win.cc3
-rw-r--r--chrome/browser/speech/speech_input_bubble_views.cc2
-rw-r--r--chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc7
-rw-r--r--chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.h7
-rw-r--r--chrome/browser/ui/views/avatar_menu_button.cc3
-rw-r--r--chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc2
-rw-r--r--chrome/browser/ui/views/browser_actions_container.cc4
-rw-r--r--chrome/browser/ui/views/browser_bubble.cc6
-rw-r--r--chrome/browser/ui/views/browser_bubble.h6
-rw-r--r--chrome/browser/ui/views/bubble/border_contents.cc25
-rw-r--r--chrome/browser/ui/views/bubble/border_contents.h19
-rw-r--r--chrome/browser/ui/views/bubble/border_contents_unittest.cc96
-rw-r--r--chrome/browser/ui/views/bubble/border_widget_win.cc2
-rw-r--r--chrome/browser/ui/views/bubble/border_widget_win.h9
-rw-r--r--chrome/browser/ui/views/bubble/bubble.cc10
-rw-r--r--chrome/browser/ui/views/bubble/bubble.h21
-rw-r--r--chrome/browser/ui/views/bubble/bubble_border.cc444
-rw-r--r--chrome/browser/ui/views/bubble/bubble_border.h172
-rw-r--r--chrome/browser/ui/views/extensions/extension_installed_bubble.cc5
-rw-r--r--chrome/browser/ui/views/extensions/extension_popup.cc15
-rw-r--r--chrome/browser/ui/views/extensions/extension_popup.h6
-rw-r--r--chrome/browser/ui/views/first_run_bubble.cc11
-rw-r--r--chrome/browser/ui/views/first_run_bubble.h9
-rw-r--r--chrome/browser/ui/views/location_bar/content_setting_image_view.cc4
-rw-r--r--chrome/browser/ui/views/location_bar/location_bar_view.cc7
-rw-r--r--chrome/browser/ui/views/location_bar/page_action_image_view.cc4
-rw-r--r--chrome/browser/ui/views/notifications/balloon_view.cc9
-rw-r--r--chrome/browser/ui/views/page_info_bubble_view.cc2
-rw-r--r--chrome/browser/ui/views/pinned_contents_info_bubble.cc6
-rw-r--r--chrome/browser/ui/views/pinned_contents_info_bubble.h4
-rw-r--r--chrome/chrome_browser.gypi4
40 files changed, 796 insertions, 198 deletions
diff --git a/chrome/browser/chromeos/frame/bubble_frame_view.cc b/chrome/browser/chromeos/frame/bubble_frame_view.cc
index 4d7cba8a..c0981b4 100644
--- a/chrome/browser/chromeos/frame/bubble_frame_view.cc
+++ b/chrome/browser/chromeos/frame/bubble_frame_view.cc
@@ -6,7 +6,7 @@
#include "chrome/browser/chromeos/frame/bubble_window.h"
#include "chrome/browser/chromeos/login/helper.h"
-#include "views/bubble/bubble_border.h"
+#include "chrome/browser/ui/views/bubble/bubble_border.h"
#include "grit/theme_resources_standard.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas_skia.h"
@@ -47,7 +47,7 @@ BubbleFrameView::BubbleFrameView(views::Widget* frame,
title_(NULL),
close_button_(NULL),
throbber_(NULL) {
- set_border(new views::BubbleBorder(views::BubbleBorder::NONE));
+ set_border(new BubbleBorder(BubbleBorder::NONE));
if (widget_delegate->ShouldShowWindowTitle()) {
title_ = new views::Label(widget_delegate->GetWindowTitle());
@@ -218,7 +218,7 @@ void BubbleFrameView::OnPaint(gfx::Canvas* canvas) {
SkRect rect;
rect.set(SkIntToScalar(bounds.x()), SkIntToScalar(bounds.y()),
SkIntToScalar(bounds.right()), SkIntToScalar(bounds.bottom()));
- SkScalar radius = SkIntToScalar(views::BubbleBorder::GetCornerRadius());
+ SkScalar radius = SkIntToScalar(BubbleBorder::GetCornerRadius());
path.addRoundRect(rect, radius, radius);
canvas->AsCanvasSkia()->drawPath(path, paint);
diff --git a/chrome/browser/chromeos/login/message_bubble.cc b/chrome/browser/chromeos/login/message_bubble.cc
index e0c8605..76b2812 100644
--- a/chrome/browser/chromeos/login/message_bubble.cc
+++ b/chrome/browser/chromeos/login/message_bubble.cc
@@ -113,14 +113,13 @@ void MessageBubble::LinkClicked(views::Link* source, int event_flags) {
}
// static
-MessageBubble* MessageBubble::Show(
- views::Widget* parent,
- const gfx::Rect& position_relative_to,
- views::BubbleBorder::ArrowLocation arrow_location,
- SkBitmap* image,
- const std::wstring& text,
- const std::wstring& help,
- MessageBubbleDelegate* delegate) {
+MessageBubble* MessageBubble::Show(views::Widget* parent,
+ const gfx::Rect& position_relative_to,
+ BubbleBorder::ArrowLocation arrow_location,
+ SkBitmap* image,
+ const std::wstring& text,
+ const std::wstring& help,
+ MessageBubbleDelegate* delegate) {
std::vector<std::wstring> links;
if (!help.empty())
links.push_back(help);
@@ -137,7 +136,7 @@ MessageBubble* MessageBubble::Show(
MessageBubble* MessageBubble::ShowWithLinks(
views::Widget* parent,
const gfx::Rect& position_relative_to,
- views::BubbleBorder::ArrowLocation arrow_location,
+ BubbleBorder::ArrowLocation arrow_location,
SkBitmap* image,
const std::wstring& text,
const std::vector<std::wstring>& links,
@@ -155,7 +154,7 @@ MessageBubble* MessageBubble::ShowWithLinks(
MessageBubble* MessageBubble::ShowNoGrab(
views::Widget* parent,
const gfx::Rect& position_relative_to,
- views::BubbleBorder::ArrowLocation arrow_location,
+ BubbleBorder::ArrowLocation arrow_location,
SkBitmap* image,
const std::wstring& text,
const std::wstring& help,
diff --git a/chrome/browser/chromeos/login/message_bubble.h b/chrome/browser/chromeos/login/message_bubble.h
index 4852b06..d0a47c7 100644
--- a/chrome/browser/chromeos/login/message_bubble.h
+++ b/chrome/browser/chromeos/login/message_bubble.h
@@ -42,7 +42,7 @@ class MessageBubble : public Bubble,
// |links| is an optional vector of links texts.
static MessageBubble* Show(views::Widget* parent,
const gfx::Rect& position_relative_to,
- views::BubbleBorder::ArrowLocation arrow_location,
+ BubbleBorder::ArrowLocation arrow_location,
SkBitmap* image,
const std::wstring& text,
const std::wstring& help,
@@ -53,7 +53,7 @@ class MessageBubble : public Bubble,
static MessageBubble* ShowWithLinks(
views::Widget* parent,
const gfx::Rect& position_relative_to,
- views::BubbleBorder::ArrowLocation arrow_location,
+ BubbleBorder::ArrowLocation arrow_location,
SkBitmap* image,
const std::wstring& text,
const std::vector<std::wstring>& links,
@@ -62,14 +62,13 @@ class MessageBubble : public Bubble,
// Create and show bubble which does not grab pointer. This creates
// a TYPE_CHILD NativeWidgetGtk and |position_relative_to| must be in parent's
// coordinates.
- static MessageBubble* ShowNoGrab(
- views::Widget* parent,
- const gfx::Rect& position_relative_to,
- views::BubbleBorder::ArrowLocation arrow_location,
- SkBitmap* image,
- const std::wstring& text,
- const std::wstring& help,
- MessageBubbleDelegate* delegate);
+ static MessageBubble* ShowNoGrab(views::Widget* parent,
+ const gfx::Rect& position_relative_to,
+ BubbleBorder::ArrowLocation arrow_location,
+ SkBitmap* image,
+ const std::wstring& text,
+ const std::wstring& help,
+ MessageBubbleDelegate* delegate);
// Overridden from NativeWidgetGtk.
virtual void Close() OVERRIDE;
diff --git a/chrome/browser/chromeos/login/screen_locker.cc b/chrome/browser/chromeos/login/screen_locker.cc
index fe1616b..9dc6cbd 100644
--- a/chrome/browser/chromeos/login/screen_locker.cc
+++ b/chrome/browser/chromeos/login/screen_locker.cc
@@ -849,7 +849,7 @@ void ScreenLocker::OnLoginFailure(const LoginFailure& error) {
msg += ASCIIToUTF16("\n") +
l10n_util::GetStringUTF16(IDS_LOGIN_ERROR_KEYBOARD_SWITCH_HINT);
- ShowErrorBubble(UTF16ToWide(msg), views::BubbleBorder::BOTTOM_LEFT);
+ ShowErrorBubble(UTF16ToWide(msg), BubbleBorder::BOTTOM_LEFT);
if (login_status_consumer_)
login_status_consumer_->OnLoginFailure(error);
@@ -1012,9 +1012,8 @@ void ScreenLocker::ShowErrorMessage(const std::wstring& message,
}
screen_lock_view_->SetSignoutEnabled(sign_out_only);
// Make sure that active Sign Out button is not hidden behind the bubble.
- ShowErrorBubble(
- message, sign_out_only ?
- views::BubbleBorder::BOTTOM_RIGHT : views::BubbleBorder::BOTTOM_LEFT);
+ ShowErrorBubble(message, sign_out_only ?
+ BubbleBorder::BOTTOM_RIGHT : BubbleBorder::BOTTOM_LEFT);
}
void ScreenLocker::OnGrabInputs() {
@@ -1171,9 +1170,8 @@ void ScreenLocker::OnWindowManagerReady() {
ScreenLockReady();
}
-void ScreenLocker::ShowErrorBubble(
- const std::wstring& message,
- views::BubbleBorder::ArrowLocation arrow_location) {
+void ScreenLocker::ShowErrorBubble(const std::wstring& message,
+ BubbleBorder::ArrowLocation arrow_location) {
if (error_info_)
error_info_->Close();
diff --git a/chrome/browser/chromeos/login/screen_locker.h b/chrome/browser/chromeos/login/screen_locker.h
index e7f16cd..514db65 100644
--- a/chrome/browser/chromeos/login/screen_locker.h
+++ b/chrome/browser/chromeos/login/screen_locker.h
@@ -157,7 +157,7 @@ class ScreenLocker : public LoginStatusConsumer,
// Shows error_info_ bubble with the |message| and |arrow_location| specified.
// Assumes that UI controls were locked before that.
void ShowErrorBubble(const std::wstring& message,
- views::BubbleBorder::ArrowLocation arrow_location);
+ BubbleBorder::ArrowLocation arrow_location);
// Stops screen saver.
void StopScreenSaver();
diff --git a/chrome/browser/chromeos/login/views_login_display.cc b/chrome/browser/chromeos/login/views_login_display.cc
index eae6fe7..1e7627a 100644
--- a/chrome/browser/chromeos/login/views_login_display.cc
+++ b/chrome/browser/chromeos/login/views_login_display.cc
@@ -209,13 +209,13 @@ void ViewsLoginDisplay::ShowError(int error_msg_id,
gfx::Rect bounds =
controllers_[selected_view_index_]->GetMainInputScreenBounds();
- views::BubbleBorder::ArrowLocation arrow;
+ BubbleBorder::ArrowLocation arrow;
if (controllers_[selected_view_index_]->is_new_user()) {
- arrow = views::BubbleBorder::LEFT_TOP;
+ arrow = BubbleBorder::LEFT_TOP;
} else {
// Point info bubble arrow to cursor position (approximately).
bounds.set_width(kCursorOffset * 2);
- arrow = views::BubbleBorder::BOTTOM_LEFT;
+ arrow = BubbleBorder::BOTTOM_LEFT;
}
string16 help_link;
diff --git a/chrome/browser/chromeos/login/views_network_screen_actor.cc b/chrome/browser/chromeos/login/views_network_screen_actor.cc
index 0f11440..d806a6d 100644
--- a/chrome/browser/chromeos/login/views_network_screen_actor.cc
+++ b/chrome/browser/chromeos/login/views_network_screen_actor.cc
@@ -97,7 +97,7 @@ void ViewsNetworkScreenActor::ShowError(const string16& message) {
bubble_ = MessageBubble::Show(
network_control->GetWidget(),
network_control->GetScreenBounds(),
- views::BubbleBorder::LEFT_TOP,
+ BubbleBorder::LEFT_TOP,
ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_WARNING),
UTF16ToWide(message),
UTF16ToWide(l10n_util::GetStringUTF16(IDS_LEARN_MORE)),
diff --git a/chrome/browser/chromeos/setting_level_bubble.cc b/chrome/browser/chromeos/setting_level_bubble.cc
index eed33ea..4320ea1 100644
--- a/chrome/browser/chromeos/setting_level_bubble.cc
+++ b/chrome/browser/chromeos/setting_level_bubble.cc
@@ -131,7 +131,7 @@ void SettingLevelBubble::ShowBubble(double percent, bool enabled) {
bubble_ = Bubble::ShowFocusless(parent_widget,
position_relative_to,
- views::BubbleBorder::FLOAT,
+ BubbleBorder::FLOAT,
view_, // contents
this, // delegate
true); // show while screen is locked
diff --git a/chrome/browser/chromeos/status/network_menu_button.cc b/chrome/browser/chromeos/status/network_menu_button.cc
index 5d34934..e8d8f3a 100644
--- a/chrome/browser/chromeos/status/network_menu_button.cc
+++ b/chrome/browser/chromeos/status/network_menu_button.cc
@@ -417,7 +417,7 @@ void NetworkMenuButton::ShowOptionalMobileDataPromoNotification(
mobile_data_bubble_ = MessageBubble::ShowWithLinks(
GetWidget(),
button_bounds,
- views::BubbleBorder::TOP_RIGHT ,
+ BubbleBorder::TOP_RIGHT ,
ResourceBundle::GetSharedInstance().GetBitmapNamed(IDR_NOTIFICATION_3G),
notification_text,
links,
diff --git a/chrome/browser/external_tab_container_win.cc b/chrome/browser/external_tab_container_win.cc
index af6e945..aa66e70 100644
--- a/chrome/browser/external_tab_container_win.cc
+++ b/chrome/browser/external_tab_container_win.cc
@@ -594,8 +594,7 @@ void ExternalTabContainer::ShowPageInfo(Profile* profile,
PageInfoBubbleView* page_info_bubble =
new ExternalTabPageInfoBubbleView(this, NULL, profile, url,
ssl, show_history);
- Bubble* bubble = Bubble::Show(GetWidget(), bounds,
- views::BubbleBorder::TOP_LEFT,
+ Bubble* bubble = Bubble::Show(GetWidget(), bounds, BubbleBorder::TOP_LEFT,
page_info_bubble, page_info_bubble);
page_info_bubble->set_bubble(bubble);
}
diff --git a/chrome/browser/speech/speech_input_bubble_views.cc b/chrome/browser/speech/speech_input_bubble_views.cc
index 1032803..0daa7df 100644
--- a/chrome/browser/speech/speech_input_bubble_views.cc
+++ b/chrome/browser/speech/speech_input_bubble_views.cc
@@ -367,7 +367,7 @@ void SpeechInputBubbleImpl::Show() {
}
bubble_ = Bubble::Show(toplevel_widget,
target_rect,
- views::BubbleBorder::TOP_LEFT, bubble_content_,
+ BubbleBorder::TOP_LEFT, bubble_content_,
this);
// We don't want fade outs when closing because it makes speech recognition
// appear slower than it is. Also setting it to false allows |Close| to
diff --git a/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc b/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc
index 10cf688..4f60c52 100644
--- a/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc
+++ b/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/omnibox/omnibox_view.h"
#include "chrome/browser/ui/views/autocomplete/autocomplete_result_view.h"
+#include "chrome/browser/ui/views/bubble/bubble_border.h"
#include "chrome/browser/ui/views/location_bar/location_bar_view.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
@@ -24,7 +25,6 @@
#include "ui/gfx/insets.h"
#include "ui/gfx/path.h"
#include "unicode/ubidi.h"
-#include "views/bubble/bubble_border.h"
#include "views/controls/button/text_button.h"
#include "views/controls/label.h"
#include "views/layout/grid_layout.h"
@@ -241,8 +241,7 @@ AutocompletePopupContentsView::AutocompletePopupContentsView(
ALLOW_THIS_IN_INITIALIZER_LIST(size_animation_(this)) {
// The following little dance is required because set_border() requires a
// pointer to a non-const object.
- views::BubbleBorder* bubble_border =
- new views::BubbleBorder(views::BubbleBorder::NONE);
+ BubbleBorder* bubble_border = new BubbleBorder(BubbleBorder::NONE);
bubble_border_ = bubble_border;
set_border(bubble_border);
// The contents is owned by the LocationBarView.
@@ -598,7 +597,7 @@ void AutocompletePopupContentsView::MakeContentsPath(
SkIntToScalar(bounding_rect.right()),
SkIntToScalar(bounding_rect.bottom()));
- SkScalar radius = SkIntToScalar(views::BubbleBorder::GetCornerRadius());
+ SkScalar radius = SkIntToScalar(BubbleBorder::GetCornerRadius());
path->addRoundRect(rect, radius, radius);
}
diff --git a/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.h b/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.h
index c49fa6f..ba07542 100644
--- a/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.h
+++ b/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.h
@@ -19,6 +19,7 @@
class AutocompleteEditModel;
struct AutocompleteMatch;
class AutocompleteResultView;
+class BubbleBorder;
class Profile;
namespace gfx {
@@ -26,10 +27,6 @@ class CanvasSkia;
class Insets;
}
-namespace views {
-class BubbleBorder;
-}
-
// A view representing the contents of the autocomplete popup.
class AutocompletePopupContentsView : public views::View,
public AutocompleteResultViewModel,
@@ -151,7 +148,7 @@ class AutocompletePopupContentsView : public views::View,
views::View* location_bar_;
// Our border, which can compute our desired bounds.
- const views::BubbleBorder* bubble_border_;
+ const BubbleBorder* bubble_border_;
// The font that we should use for result rows. This is based on the font used
// by the edit that created us.
diff --git a/chrome/browser/ui/views/avatar_menu_button.cc b/chrome/browser/ui/views/avatar_menu_button.cc
index f754f7d..7b99ee0 100644
--- a/chrome/browser/ui/views/avatar_menu_button.cc
+++ b/chrome/browser/ui/views/avatar_menu_button.cc
@@ -73,7 +73,6 @@ void AvatarMenuButton::RunMenu(views::View* source, const gfx::Point& pt) {
AvatarMenuBubbleView* bubble_view = new AvatarMenuBubbleView(browser_);
// Bubble::Show() takes ownership of the view.
- Bubble::Show(browser_view->GetWidget(), bounds,
- views::BubbleBorder::TOP_LEFT,
+ Bubble::Show(browser_view->GetWidget(), bounds, BubbleBorder::TOP_LEFT,
bubble_view, bubble_view);
}
diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc
index e79ef8f..53393e66 100644
--- a/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc
+++ b/chrome/browser/ui/views/bookmarks/bookmark_bubble_view.cc
@@ -91,7 +91,7 @@ void BookmarkBubbleView::Show(views::Widget* parent,
bookmark_bubble_ = new BookmarkBubbleView(delegate, profile, url,
newly_bookmarked);
Bubble* bubble = Bubble::Show(
- parent, bounds, views::BubbleBorder::TOP_RIGHT, bookmark_bubble_,
+ parent, bounds, BubbleBorder::TOP_RIGHT, bookmark_bubble_,
bookmark_bubble_);
// |bubble_| can be set to NULL in BubbleClosing when we close the bubble
// asynchronously. However, that can happen during the Show call above if the
diff --git a/chrome/browser/ui/views/browser_actions_container.cc b/chrome/browser/ui/views/browser_actions_container.cc
index 1980660..a8a369e 100644
--- a/chrome/browser/ui/views/browser_actions_container.cc
+++ b/chrome/browser/ui/views/browser_actions_container.cc
@@ -510,8 +510,8 @@ void BrowserActionsContainer::OnBrowserActionExecuted(
gfx::Rect rect = reference_view->bounds();
rect.set_origin(origin);
- views::BubbleBorder::ArrowLocation arrow_location = base::i18n::IsRTL() ?
- views::BubbleBorder::TOP_LEFT : views::BubbleBorder::TOP_RIGHT;
+ BubbleBorder::ArrowLocation arrow_location = base::i18n::IsRTL() ?
+ BubbleBorder::TOP_LEFT : BubbleBorder::TOP_RIGHT;
popup_ = ExtensionPopup::Show(button->GetPopupUrl(), browser_, rect,
arrow_location, inspect_with_devtools,
diff --git a/chrome/browser/ui/views/browser_bubble.cc b/chrome/browser/ui/views/browser_bubble.cc
index f826469..6dcd658 100644
--- a/chrome/browser/ui/views/browser_bubble.cc
+++ b/chrome/browser/ui/views/browser_bubble.cc
@@ -32,7 +32,7 @@ BrowserBubbleHost* GetBubbleHostFromFrame(views::Widget* frame) {
BrowserBubble::BrowserBubble(views::View* view,
views::Widget* frame,
const gfx::Rect& relative_to,
- views::BubbleBorder::ArrowLocation arrow_location)
+ BubbleBorder::ArrowLocation arrow_location)
: frame_(frame),
view_(view),
relative_to_(relative_to),
@@ -48,7 +48,7 @@ BrowserBubble::BrowserBubble(views::View* view,
// Use half the corner radius as contents margins so that contents fit better
// in the bubble. See http://crbug.com/80416.
- int corner_inset = views::BubbleBorder::GetCornerRadius() / 2;
+ int corner_inset = BubbleBorder::GetCornerRadius() / 2;
gfx::Insets content_margins(corner_inset, corner_inset,
corner_inset, corner_inset);
InitPopup(content_margins);
@@ -146,3 +146,5 @@ void BrowserBubble::SetAbsoluteBounds(const gfx::Rect& window_bounds) {
void BrowserBubble::MovePopup(int x, int y, int w, int h) {
popup_->SetBounds(gfx::Rect(x, y, w, h));
}
+
+
diff --git a/chrome/browser/ui/views/browser_bubble.h b/chrome/browser/ui/views/browser_bubble.h
index 58bbc54..c74d40b 100644
--- a/chrome/browser/ui/views/browser_bubble.h
+++ b/chrome/browser/ui/views/browser_bubble.h
@@ -6,7 +6,7 @@
#define CHROME_BROWSER_UI_VIEWS_BROWSER_BUBBLE_H_
#pragma once
-#include "views/bubble/bubble_border.h"
+#include "chrome/browser/ui/views/bubble/bubble_border.h"
#include "views/view.h"
#include "views/widget/widget.h"
@@ -48,7 +48,7 @@ class BrowserBubble {
BrowserBubble(views::View* view,
views::Widget* frame,
const gfx::Rect& relative_to,
- views::BubbleBorder::ArrowLocation arrow_location);
+ BubbleBorder::ArrowLocation arrow_location);
virtual ~BrowserBubble();
// Call manually if you need to detach the bubble from tracking the browser's
@@ -121,7 +121,7 @@ class BrowserBubble {
gfx::Rect relative_to_;
// Arrow location of this bubble.
- views::BubbleBorder::ArrowLocation arrow_location_;
+ BubbleBorder::ArrowLocation arrow_location_;
// The bounds relative to the frame.
gfx::Rect bounds_;
diff --git a/chrome/browser/ui/views/bubble/border_contents.cc b/chrome/browser/ui/views/bubble/border_contents.cc
index 3503b19..ceb2a6d 100644
--- a/chrome/browser/ui/views/bubble/border_contents.cc
+++ b/chrome/browser/ui/views/bubble/border_contents.cc
@@ -15,7 +15,6 @@ static const int kTopMargin = 6;
static const int kRightMargin = 6;
static const int kBottomMargin = 9;
-
BorderContents::BorderContents()
: bubble_border_(NULL),
content_margins_(kTopMargin, kLeftMargin, kBottomMargin, kRightMargin) {
@@ -23,15 +22,14 @@ BorderContents::BorderContents()
void BorderContents::Init() {
// Default arrow location.
- views::BubbleBorder::ArrowLocation arrow_location =
- views::BubbleBorder::TOP_LEFT;
+ BubbleBorder::ArrowLocation arrow_location = BubbleBorder::TOP_LEFT;
if (base::i18n::IsRTL())
- arrow_location = views::BubbleBorder::horizontal_mirror(arrow_location);
+ arrow_location = BubbleBorder::horizontal_mirror(arrow_location);
DCHECK(!bubble_border_);
- bubble_border_ = new views::BubbleBorder(arrow_location);
+ bubble_border_ = new BubbleBorder(arrow_location);
set_border(bubble_border_);
- set_background(new views::BubbleBackground(bubble_border_));
+ set_background(new BubbleBackground(bubble_border_));
}
void BorderContents::SetBackgroundColor(SkColor color) {
@@ -40,13 +38,13 @@ void BorderContents::SetBackgroundColor(SkColor color) {
void BorderContents::SizeAndGetBounds(
const gfx::Rect& position_relative_to,
- views::BubbleBorder::ArrowLocation arrow_location,
+ BubbleBorder::ArrowLocation arrow_location,
bool allow_bubble_offscreen,
const gfx::Size& contents_size,
gfx::Rect* contents_bounds,
gfx::Rect* window_bounds) {
if (base::i18n::IsRTL())
- arrow_location = views::BubbleBorder::horizontal_mirror(arrow_location);
+ arrow_location = BubbleBorder::horizontal_mirror(arrow_location);
bubble_border_->set_arrow_location(arrow_location);
// Set the border.
set_border(bubble_border_);
@@ -95,7 +93,7 @@ void BorderContents::MirrorArrowIfOffScreen(
const gfx::Rect& position_relative_to,
const gfx::Rect& monitor_bounds,
const gfx::Size& local_contents_size,
- views::BubbleBorder::ArrowLocation* arrow_location,
+ BubbleBorder::ArrowLocation* arrow_location,
gfx::Rect* window_bounds) {
// If the bounds don't fit, move the arrow to its mirrored position to see if
// it improves things.
@@ -103,11 +101,10 @@ void BorderContents::MirrorArrowIfOffScreen(
if (ComputeOffScreenInsets(monitor_bounds, *window_bounds,
&offscreen_insets) &&
GetInsetsLength(offscreen_insets, vertical) > 0) {
- views::BubbleBorder::ArrowLocation original_arrow_location =
- *arrow_location;
- *arrow_location =
- vertical ? views::BubbleBorder::vertical_mirror(*arrow_location) :
- views::BubbleBorder::horizontal_mirror(*arrow_location);
+ BubbleBorder::ArrowLocation original_arrow_location = *arrow_location;
+ *arrow_location =
+ vertical ? BubbleBorder::vertical_mirror(*arrow_location) :
+ BubbleBorder::horizontal_mirror(*arrow_location);
// Change the arrow and get the new bounds.
bubble_border_->set_arrow_location(*arrow_location);
diff --git a/chrome/browser/ui/views/bubble/border_contents.h b/chrome/browser/ui/views/bubble/border_contents.h
index d61b847..235d8c4 100644
--- a/chrome/browser/ui/views/bubble/border_contents.h
+++ b/chrome/browser/ui/views/bubble/border_contents.h
@@ -6,7 +6,7 @@
#define CHROME_BROWSER_UI_VIEWS_BUBBLE_BORDER_CONTENTS_H_
#pragma once
-#include "views/bubble/bubble_border.h"
+#include "chrome/browser/ui/views/bubble/bubble_border.h"
#include "third_party/skia/include/core/SkColor.h"
#include "views/view.h"
@@ -30,7 +30,7 @@ class BorderContents : public views::View {
// bubble shows entirely.
virtual void SizeAndGetBounds(
const gfx::Rect& position_relative_to, // In screen coordinates
- views::BubbleBorder::ArrowLocation arrow_location,
+ BubbleBorder::ArrowLocation arrow_location,
bool allow_bubble_offscreen,
const gfx::Size& contents_size,
gfx::Rect* contents_bounds, // Returned in window coordinates
@@ -53,19 +53,18 @@ class BorderContents : public views::View {
return content_margins_;
}
- views::BubbleBorder* bubble_border_;
+ BubbleBorder* bubble_border_;
private:
// Changes |arrow_location| to its mirrored version, vertically if |vertical|
// is true, horizontally otherwise, if |window_bounds| don't fit in
// |monitor_bounds|.
- void MirrorArrowIfOffScreen(
- bool vertical,
- const gfx::Rect& position_relative_to,
- const gfx::Rect& monitor_bounds,
- const gfx::Size& local_contents_size,
- views::BubbleBorder::ArrowLocation* arrow_location,
- gfx::Rect* window_bounds);
+ void MirrorArrowIfOffScreen(bool vertical,
+ const gfx::Rect& position_relative_to,
+ const gfx::Rect& monitor_bounds,
+ const gfx::Size& local_contents_size,
+ BubbleBorder::ArrowLocation* arrow_location,
+ gfx::Rect* window_bounds);
// Computes how much |window_bounds| is off-screen of the monitor bounds
// |monitor_bounds| and puts the values in |offscreen_insets|.
diff --git a/chrome/browser/ui/views/bubble/border_contents_unittest.cc b/chrome/browser/ui/views/bubble/border_contents_unittest.cc
index 1a0db0a..630064e 100644
--- a/chrome/browser/ui/views/bubble/border_contents_unittest.cc
+++ b/chrome/browser/ui/views/bubble/border_contents_unittest.cc
@@ -15,7 +15,7 @@ class TestBorderContents : public BorderContents {
monitor_bounds_ = bounds;
}
- views::BubbleBorder* bubble_border() const { return bubble_border_; }
+ BubbleBorder* bubble_border() const { return bubble_border_; }
protected:
virtual gfx::Rect GetMonitorBounds(const gfx::Rect& rect) {
@@ -44,16 +44,16 @@ TEST_F(BorderContentsTest, BorderContentsSizeAndGetBounds) {
border_contents.set_monitor_bounds(gfx::Rect(0, 0, 1000, 1000));
border_contents.SizeAndGetBounds(
gfx::Rect(100, 100, 50, 50), // |position_relative_to|
- views::BubbleBorder::TOP_LEFT,
+ BubbleBorder::TOP_LEFT,
false, // |allow_bubble_offscreen|
gfx::Size(500, 500), // |contents_size|
&contents_bounds, &window_bounds);
// The arrow shouldn't have changed from TOP_LEFT.
- views::BubbleBorder::ArrowLocation arrow_location =
+ BubbleBorder::ArrowLocation arrow_location =
border_contents.bubble_border()->arrow_location();
- EXPECT_TRUE(views::BubbleBorder::has_arrow(arrow_location));
- EXPECT_TRUE(views::BubbleBorder::is_arrow_on_top(arrow_location));
- EXPECT_TRUE(views::BubbleBorder::is_arrow_on_left(arrow_location));
+ EXPECT_TRUE(BubbleBorder::has_arrow(arrow_location));
+ EXPECT_TRUE(BubbleBorder::is_arrow_on_top(arrow_location));
+ EXPECT_TRUE(BubbleBorder::is_arrow_on_left(arrow_location));
EXPECT_GT(window_bounds.x(), xposition);
EXPECT_GT(window_bounds.y(), 100 + 50 - 10); // -10 to roughly compensate for
// arrow overlap.
@@ -61,15 +61,15 @@ TEST_F(BorderContentsTest, BorderContentsSizeAndGetBounds) {
// Test bubble not fitting on left.
border_contents.SizeAndGetBounds(
gfx::Rect(100, 100, 50, 50), // |position_relative_to|
- views::BubbleBorder::TOP_RIGHT,
+ BubbleBorder::TOP_RIGHT,
false, // |allow_bubble_offscreen|
gfx::Size(500, 500), // |contents_size|
&contents_bounds, &window_bounds);
arrow_location = border_contents.bubble_border()->arrow_location();
// The arrow should have changed to TOP_LEFT.
- EXPECT_TRUE(views::BubbleBorder::has_arrow(arrow_location));
- EXPECT_TRUE(views::BubbleBorder::is_arrow_on_top(arrow_location));
- EXPECT_TRUE(views::BubbleBorder::is_arrow_on_left(arrow_location));
+ EXPECT_TRUE(BubbleBorder::has_arrow(arrow_location));
+ EXPECT_TRUE(BubbleBorder::is_arrow_on_top(arrow_location));
+ EXPECT_TRUE(BubbleBorder::is_arrow_on_left(arrow_location));
EXPECT_GT(window_bounds.x(), xposition);
EXPECT_GT(window_bounds.y(), 100 + 50 - 10); // -10 to roughly compensate for
// arrow overlap.
@@ -77,15 +77,15 @@ TEST_F(BorderContentsTest, BorderContentsSizeAndGetBounds) {
// Test bubble not fitting on left or top.
border_contents.SizeAndGetBounds(
gfx::Rect(100, 100, 50, 50), // |position_relative_to|
- views::BubbleBorder::BOTTOM_RIGHT,
+ BubbleBorder::BOTTOM_RIGHT,
false, // |allow_bubble_offscreen|
gfx::Size(500, 500), // |contents_size|
&contents_bounds, &window_bounds);
arrow_location = border_contents.bubble_border()->arrow_location();
// The arrow should have changed to TOP_LEFT.
- EXPECT_TRUE(views::BubbleBorder::has_arrow(arrow_location));
- EXPECT_TRUE(views::BubbleBorder::is_arrow_on_top(arrow_location));
- EXPECT_TRUE(views::BubbleBorder::is_arrow_on_left(arrow_location));
+ EXPECT_TRUE(BubbleBorder::has_arrow(arrow_location));
+ EXPECT_TRUE(BubbleBorder::is_arrow_on_top(arrow_location));
+ EXPECT_TRUE(BubbleBorder::is_arrow_on_left(arrow_location));
EXPECT_GT(window_bounds.x(), xposition);
EXPECT_GT(window_bounds.y(), 100 + 50 - 10); // -10 to roughly compensate for
// arrow overlap.
@@ -93,15 +93,15 @@ TEST_F(BorderContentsTest, BorderContentsSizeAndGetBounds) {
// Test bubble not fitting on top.
border_contents.SizeAndGetBounds(
gfx::Rect(100, 100, 50, 50), // |position_relative_to|
- views::BubbleBorder::BOTTOM_LEFT,
+ BubbleBorder::BOTTOM_LEFT,
false, // |allow_bubble_offscreen|
gfx::Size(500, 500), // |contents_size|
&contents_bounds, &window_bounds);
arrow_location = border_contents.bubble_border()->arrow_location();
// The arrow should have changed to TOP_LEFT.
- EXPECT_TRUE(views::BubbleBorder::has_arrow(arrow_location));
- EXPECT_TRUE(views::BubbleBorder::is_arrow_on_top(arrow_location));
- EXPECT_TRUE(views::BubbleBorder::is_arrow_on_left(arrow_location));
+ EXPECT_TRUE(BubbleBorder::has_arrow(arrow_location));
+ EXPECT_TRUE(BubbleBorder::is_arrow_on_top(arrow_location));
+ EXPECT_TRUE(BubbleBorder::is_arrow_on_left(arrow_location));
EXPECT_GT(window_bounds.x(), xposition);
EXPECT_GT(window_bounds.y(), 100 + 50 - 10); // -10 to roughly compensate for
// arrow overlap.
@@ -109,15 +109,15 @@ TEST_F(BorderContentsTest, BorderContentsSizeAndGetBounds) {
// Test bubble not fitting on top and right.
border_contents.SizeAndGetBounds(
gfx::Rect(900, 100, 50, 50), // |position_relative_to|
- views::BubbleBorder::BOTTOM_LEFT,
+ BubbleBorder::BOTTOM_LEFT,
false, // |allow_bubble_offscreen|
gfx::Size(500, 500), // |contents_size|
&contents_bounds, &window_bounds);
arrow_location = border_contents.bubble_border()->arrow_location();
// The arrow should have changed to TOP_RIGHT.
- EXPECT_TRUE(views::BubbleBorder::has_arrow(arrow_location));
- EXPECT_TRUE(views::BubbleBorder::is_arrow_on_top(arrow_location));
- EXPECT_FALSE(views::BubbleBorder::is_arrow_on_left(arrow_location));
+ EXPECT_TRUE(BubbleBorder::has_arrow(arrow_location));
+ EXPECT_TRUE(BubbleBorder::is_arrow_on_top(arrow_location));
+ EXPECT_FALSE(BubbleBorder::is_arrow_on_left(arrow_location));
EXPECT_LT(window_bounds.x(), 900 + 50 - 500);
EXPECT_GT(window_bounds.y(), 100 + 50 - 10); // -10 to roughly compensate for
// arrow overlap.
@@ -125,15 +125,15 @@ TEST_F(BorderContentsTest, BorderContentsSizeAndGetBounds) {
// Test bubble not fitting on right.
border_contents.SizeAndGetBounds(
gfx::Rect(900, 100, 50, 50), // |position_relative_to|
- views::BubbleBorder::TOP_LEFT,
+ BubbleBorder::TOP_LEFT,
false, // |allow_bubble_offscreen|
gfx::Size(500, 500), // |contents_size|
&contents_bounds, &window_bounds);
arrow_location = border_contents.bubble_border()->arrow_location();
// The arrow should have changed to TOP_RIGHT.
- EXPECT_TRUE(views::BubbleBorder::has_arrow(arrow_location));
- EXPECT_TRUE(views::BubbleBorder::is_arrow_on_top(arrow_location));
- EXPECT_FALSE(views::BubbleBorder::is_arrow_on_left(arrow_location));
+ EXPECT_TRUE(BubbleBorder::has_arrow(arrow_location));
+ EXPECT_TRUE(BubbleBorder::is_arrow_on_top(arrow_location));
+ EXPECT_FALSE(BubbleBorder::is_arrow_on_left(arrow_location));
EXPECT_LT(window_bounds.x(), 900 + 50 - 500);
EXPECT_GT(window_bounds.y(), 100 + 50 - 10); // -10 to roughly compensate for
// arrow overlap.
@@ -141,15 +141,15 @@ TEST_F(BorderContentsTest, BorderContentsSizeAndGetBounds) {
// Test bubble not fitting on bottom and right.
border_contents.SizeAndGetBounds(
gfx::Rect(900, 900, 50, 50), // |position_relative_to|
- views::BubbleBorder::TOP_LEFT,
+ BubbleBorder::TOP_LEFT,
false, // |allow_bubble_offscreen|
gfx::Size(500, 500), // |contents_size|
&contents_bounds, &window_bounds);
arrow_location = border_contents.bubble_border()->arrow_location();
// The arrow should have changed to BOTTOM_RIGHT.
- EXPECT_TRUE(views::BubbleBorder::has_arrow(arrow_location));
- EXPECT_FALSE(views::BubbleBorder::is_arrow_on_top(arrow_location));
- EXPECT_FALSE(views::BubbleBorder::is_arrow_on_left(arrow_location));
+ EXPECT_TRUE(BubbleBorder::has_arrow(arrow_location));
+ EXPECT_FALSE(BubbleBorder::is_arrow_on_top(arrow_location));
+ EXPECT_FALSE(BubbleBorder::is_arrow_on_left(arrow_location));
EXPECT_LT(window_bounds.x(), 900 + 50 - 500);
EXPECT_LT(window_bounds.y(), 900 - 500 - 15); // -15 to roughly compensate
// for arrow height.
@@ -157,15 +157,15 @@ TEST_F(BorderContentsTest, BorderContentsSizeAndGetBounds) {
// Test bubble not fitting at the bottom.
border_contents.SizeAndGetBounds(
gfx::Rect(100, 900, 50, 50), // |position_relative_to|
- views::BubbleBorder::TOP_LEFT,
+ BubbleBorder::TOP_LEFT,
false, // |allow_bubble_offscreen|
gfx::Size(500, 500), // |contents_size|
&contents_bounds, &window_bounds);
arrow_location = border_contents.bubble_border()->arrow_location();
// The arrow should have changed to BOTTOM_LEFT.
- EXPECT_TRUE(views::BubbleBorder::has_arrow(arrow_location));
- EXPECT_FALSE(views::BubbleBorder::is_arrow_on_top(arrow_location));
- EXPECT_TRUE(views::BubbleBorder::is_arrow_on_left(arrow_location));
+ EXPECT_TRUE(BubbleBorder::has_arrow(arrow_location));
+ EXPECT_FALSE(BubbleBorder::is_arrow_on_top(arrow_location));
+ EXPECT_TRUE(BubbleBorder::is_arrow_on_left(arrow_location));
// The window should be right aligned with the position_relative_to.
EXPECT_LT(window_bounds.x(), 900 + 50 - 500);
EXPECT_LT(window_bounds.y(), 900 - 500 - 15); // -15 to roughly compensate
@@ -174,15 +174,15 @@ TEST_F(BorderContentsTest, BorderContentsSizeAndGetBounds) {
// Test bubble not fitting at the bottom and left.
border_contents.SizeAndGetBounds(
gfx::Rect(100, 900, 50, 50), // |position_relative_to|
- views::BubbleBorder::TOP_RIGHT,
+ BubbleBorder::TOP_RIGHT,
false, // |allow_bubble_offscreen|
gfx::Size(500, 500), // |contents_size|
&contents_bounds, &window_bounds);
arrow_location = border_contents.bubble_border()->arrow_location();
// The arrow should have changed to BOTTOM_LEFT.
- EXPECT_TRUE(views::BubbleBorder::has_arrow(arrow_location));
- EXPECT_FALSE(views::BubbleBorder::is_arrow_on_top(arrow_location));
- EXPECT_TRUE(views::BubbleBorder::is_arrow_on_left(arrow_location));
+ EXPECT_TRUE(BubbleBorder::has_arrow(arrow_location));
+ EXPECT_FALSE(BubbleBorder::is_arrow_on_top(arrow_location));
+ EXPECT_TRUE(BubbleBorder::is_arrow_on_left(arrow_location));
// The window should be right aligned with the position_relative_to.
EXPECT_LT(window_bounds.x(), 900 + 50 - 500);
EXPECT_LT(window_bounds.y(), 900 - 500 - 15); // -15 to roughly compensate
@@ -199,18 +199,18 @@ TEST_F(BorderContentsTest, BorderContentsSizeAndGetBoundsDontMoveArrow) {
border_contents.set_monitor_bounds(gfx::Rect(0, 0, 1000, 1000));
border_contents.SizeAndGetBounds(
gfx::Rect(400, 100, 50, 50), // |position_relative_to|
- views::BubbleBorder::TOP_LEFT,
+ BubbleBorder::TOP_LEFT,
false, // |allow_bubble_offscreen|
gfx::Size(500, 700), // |contents_size|
&contents_bounds, &window_bounds);
// The arrow should not have changed, as it would make it the bubble even more
// offscreen.
- views::BubbleBorder::ArrowLocation arrow_location =
+ BubbleBorder::ArrowLocation arrow_location =
border_contents.bubble_border()->arrow_location();
- EXPECT_TRUE(views::BubbleBorder::has_arrow(arrow_location));
- EXPECT_TRUE(views::BubbleBorder::is_arrow_on_top(arrow_location));
- EXPECT_TRUE(views::BubbleBorder::is_arrow_on_left(arrow_location));
+ EXPECT_TRUE(BubbleBorder::has_arrow(arrow_location));
+ EXPECT_TRUE(BubbleBorder::is_arrow_on_top(arrow_location));
+ EXPECT_TRUE(BubbleBorder::is_arrow_on_left(arrow_location));
}
// Test that the 'allow offscreen' prevents the bubble from moving.
@@ -222,17 +222,17 @@ TEST_F(BorderContentsTest, BorderContentsSizeAndGetBoundsAllowOffscreen) {
border_contents.set_monitor_bounds(gfx::Rect(0, 0, 1000, 1000));
border_contents.SizeAndGetBounds(
gfx::Rect(100, 900, 50, 50), // |position_relative_to|
- views::BubbleBorder::TOP_RIGHT,
+ BubbleBorder::TOP_RIGHT,
true, // |allow_bubble_offscreen|
gfx::Size(500, 500), // |contents_size|
&contents_bounds, &window_bounds);
// The arrow should not have changed (eventhough the bubble does not fit).
- views::BubbleBorder::ArrowLocation arrow_location =
+ BubbleBorder::ArrowLocation arrow_location =
border_contents.bubble_border()->arrow_location();
- EXPECT_TRUE(views::BubbleBorder::has_arrow(arrow_location));
- EXPECT_TRUE(views::BubbleBorder::is_arrow_on_top(arrow_location));
- EXPECT_FALSE(views::BubbleBorder::is_arrow_on_left(arrow_location));
+ EXPECT_TRUE(BubbleBorder::has_arrow(arrow_location));
+ EXPECT_TRUE(BubbleBorder::is_arrow_on_top(arrow_location));
+ EXPECT_FALSE(BubbleBorder::is_arrow_on_left(arrow_location));
// The coordinates should be pointing to 'positive relative to' from
// TOP_RIGHT.
EXPECT_LT(window_bounds.x(), 100 + 50 - 500);
diff --git a/chrome/browser/ui/views/bubble/border_widget_win.cc b/chrome/browser/ui/views/bubble/border_widget_win.cc
index 528de19..df5c959 100644
--- a/chrome/browser/ui/views/bubble/border_widget_win.cc
+++ b/chrome/browser/ui/views/bubble/border_widget_win.cc
@@ -32,7 +32,7 @@ void BorderWidgetWin::InitBorderWidgetWin(BorderContents* border_contents,
gfx::Rect BorderWidgetWin::SizeAndGetBounds(
const gfx::Rect& position_relative_to,
- views::BubbleBorder::ArrowLocation arrow_location,
+ BubbleBorder::ArrowLocation arrow_location,
const gfx::Size& contents_size) {
// Ask the border view to calculate our bounds (and our contents').
gfx::Rect contents_bounds;
diff --git a/chrome/browser/ui/views/bubble/border_widget_win.h b/chrome/browser/ui/views/bubble/border_widget_win.h
index 6faff35..cbdddcc 100644
--- a/chrome/browser/ui/views/bubble/border_widget_win.h
+++ b/chrome/browser/ui/views/bubble/border_widget_win.h
@@ -6,7 +6,7 @@
#define CHROME_BROWSER_UI_VIEWS_BUBBLE_BORDER_WIDGET_WIN_H_
#pragma once
-#include "views/bubble/bubble_border.h"
+#include "chrome/browser/ui/views/bubble/bubble_border.h"
#include "views/widget/native_widget_win.h"
class BorderContents;
@@ -30,10 +30,9 @@ class BorderWidgetWin : public views::NativeWidgetWin {
// contents should use. |arrow_location| is prefered arrow location,
// the function tries to preserve the location and direction, in case of RTL
// arrow location is mirrored.
- virtual gfx::Rect SizeAndGetBounds(
- const gfx::Rect& position_relative_to,
- views::BubbleBorder::ArrowLocation arrow_location,
- const gfx::Size& contents_size);
+ virtual gfx::Rect SizeAndGetBounds(const gfx::Rect& position_relative_to,
+ BubbleBorder::ArrowLocation arrow_location,
+ const gfx::Size& contents_size);
// Simple accessors.
BorderContents* border_contents() { return border_contents_; }
diff --git a/chrome/browser/ui/views/bubble/bubble.cc b/chrome/browser/ui/views/bubble/bubble.cc
index 82ed36f..d828f8a 100644
--- a/chrome/browser/ui/views/bubble/bubble.cc
+++ b/chrome/browser/ui/views/bubble/bubble.cc
@@ -50,7 +50,7 @@ std::wstring BubbleDelegate::accessible_name() {
// static
Bubble* Bubble::Show(views::Widget* parent,
const gfx::Rect& position_relative_to,
- views::BubbleBorder::ArrowLocation arrow_location,
+ BubbleBorder::ArrowLocation arrow_location,
views::View* contents,
BubbleDelegate* delegate) {
Bubble* bubble = new Bubble;
@@ -68,7 +68,7 @@ Bubble* Bubble::Show(views::Widget* parent,
Bubble* Bubble::ShowFocusless(
views::Widget* parent,
const gfx::Rect& position_relative_to,
- views::BubbleBorder::ArrowLocation arrow_location,
+ BubbleBorder::ArrowLocation arrow_location,
views::View* contents,
BubbleDelegate* delegate,
bool show_while_screen_is_locked) {
@@ -144,7 +144,7 @@ Bubble::Bubble()
#if defined(OS_CHROMEOS)
show_while_screen_is_locked_(false),
#endif
- arrow_location_(views::BubbleBorder::NONE),
+ arrow_location_(BubbleBorder::NONE),
contents_(NULL),
accelerator_registered_(false) {
}
@@ -159,7 +159,7 @@ Bubble::Bubble(views::Widget::InitParams::Type type,
fade_away_on_close_(false),
type_(type),
show_while_screen_is_locked_(show_while_screen_is_locked),
- arrow_location_(views::BubbleBorder::NONE),
+ arrow_location_(BubbleBorder::NONE),
contents_(NULL) {
}
#endif
@@ -169,7 +169,7 @@ Bubble::~Bubble() {
void Bubble::InitBubble(views::Widget* parent,
const gfx::Rect& position_relative_to,
- views::BubbleBorder::ArrowLocation arrow_location,
+ BubbleBorder::ArrowLocation arrow_location,
views::View* contents,
BubbleDelegate* delegate) {
delegate_ = delegate;
diff --git a/chrome/browser/ui/views/bubble/bubble.h b/chrome/browser/ui/views/bubble/bubble.h
index f4f4fec..5bb6b28 100644
--- a/chrome/browser/ui/views/bubble/bubble.h
+++ b/chrome/browser/ui/views/bubble/bubble.h
@@ -6,7 +6,7 @@
#define CHROME_BROWSER_UI_VIEWS_BUBBLE_BUBBLE_H_
#pragma once
-#include "views/bubble/bubble_border.h"
+#include "chrome/browser/ui/views/bubble/bubble_border.h"
#include "ui/base/animation/animation_delegate.h"
#include "views/accelerator.h"
#include "views/view.h"
@@ -93,7 +93,7 @@ class Bubble
// pressed (the default behavior).
static Bubble* Show(views::Widget* parent,
const gfx::Rect& position_relative_to,
- views::BubbleBorder::ArrowLocation arrow_location,
+ BubbleBorder::ArrowLocation arrow_location,
views::View* contents,
BubbleDelegate* delegate);
@@ -104,13 +104,12 @@ class Bubble
// to achieve the focusless effect. If |show_while_screen_is_locked| is true,
// a property is set telling the window manager to continue showing the bubble
// even while the screen is locked.
- static Bubble* ShowFocusless(
- views::Widget* parent,
- const gfx::Rect& position_relative_to,
- views::BubbleBorder::ArrowLocation arrow_location,
- views::View* contents,
- BubbleDelegate* delegate,
- bool show_while_screen_is_locked);
+ static Bubble* ShowFocusless(views::Widget* parent,
+ const gfx::Rect& position_relative_to,
+ BubbleBorder::ArrowLocation arrow_location,
+ views::View* contents,
+ BubbleDelegate* delegate,
+ bool show_while_screen_is_locked);
#endif
// Resizes and potentially moves the Bubble to best accommodate the
@@ -149,7 +148,7 @@ class Bubble
// Creates the Bubble.
virtual void InitBubble(views::Widget* parent,
const gfx::Rect& position_relative_to,
- views::BubbleBorder::ArrowLocation arrow_location,
+ BubbleBorder::ArrowLocation arrow_location,
views::View* contents,
BubbleDelegate* delegate);
@@ -221,7 +220,7 @@ class Bubble
#endif
gfx::Rect position_relative_to_;
- views::BubbleBorder::ArrowLocation arrow_location_;
+ BubbleBorder::ArrowLocation arrow_location_;
views::View* contents_;
diff --git a/chrome/browser/ui/views/bubble/bubble_border.cc b/chrome/browser/ui/views/bubble/bubble_border.cc
new file mode 100644
index 0000000..9cd36d5
--- /dev/null
+++ b/chrome/browser/ui/views/bubble/bubble_border.cc
@@ -0,0 +1,444 @@
+// Copyright (c) 2011 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/ui/views/bubble/bubble_border.h"
+
+#include "base/logging.h"
+#include "grit/ui_resources.h"
+#include "grit/ui_resources_standard.h"
+#include "third_party/skia/include/core/SkBitmap.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "ui/gfx/canvas_skia.h"
+#include "ui/gfx/path.h"
+
+// static
+SkBitmap* BubbleBorder::left_ = NULL;
+SkBitmap* BubbleBorder::top_left_ = NULL;
+SkBitmap* BubbleBorder::top_ = NULL;
+SkBitmap* BubbleBorder::top_right_ = NULL;
+SkBitmap* BubbleBorder::right_ = NULL;
+SkBitmap* BubbleBorder::bottom_right_ = NULL;
+SkBitmap* BubbleBorder::bottom_ = NULL;
+SkBitmap* BubbleBorder::bottom_left_ = NULL;
+SkBitmap* BubbleBorder::top_arrow_ = NULL;
+SkBitmap* BubbleBorder::bottom_arrow_ = NULL;
+SkBitmap* BubbleBorder::left_arrow_ = NULL;
+SkBitmap* BubbleBorder::right_arrow_ = NULL;
+
+// static
+int BubbleBorder::arrow_offset_;
+
+// The height inside the arrow image, in pixels.
+static const int kArrowInteriorHeight = 7;
+
+gfx::Rect BubbleBorder::GetBounds(const gfx::Rect& position_relative_to,
+ const gfx::Size& contents_size) const {
+ // 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());
+
+ // Screen position depends on the arrow location.
+ // The arrow should overlap the target by some amount since there is space
+ // for shadow between arrow tip and bitmap bounds.
+ const int kArrowOverlap = 3;
+ int x = position_relative_to.x();
+ int y = position_relative_to.y();
+ int w = position_relative_to.width();
+ int h = position_relative_to.height();
+ int arrow_offset = override_arrow_offset_ ? override_arrow_offset_ :
+ arrow_offset_;
+
+ // Calculate bubble x coordinate.
+ switch (arrow_location_) {
+ case TOP_LEFT:
+ case BOTTOM_LEFT:
+ x += w / 2 - arrow_offset;
+ break;
+
+ case TOP_RIGHT:
+ case BOTTOM_RIGHT:
+ x += w / 2 + arrow_offset - border_size.width() + 1;
+ break;
+
+ case LEFT_TOP:
+ case LEFT_BOTTOM:
+ x += w - kArrowOverlap;
+ break;
+
+ case RIGHT_TOP:
+ case RIGHT_BOTTOM:
+ x += kArrowOverlap - border_size.width();
+ break;
+
+ case NONE:
+ case FLOAT:
+ x += w / 2 - border_size.width() / 2;
+ break;
+ }
+
+ // Calculate bubble y coordinate.
+ switch (arrow_location_) {
+ case TOP_LEFT:
+ case TOP_RIGHT:
+ y += h - kArrowOverlap;
+ break;
+
+ case BOTTOM_LEFT:
+ case BOTTOM_RIGHT:
+ y += kArrowOverlap - border_size.height();
+ break;
+
+ case LEFT_TOP:
+ case RIGHT_TOP:
+ y += h / 2 - arrow_offset;
+ break;
+
+ case LEFT_BOTTOM:
+ case RIGHT_BOTTOM:
+ y += h / 2 + arrow_offset - border_size.height() + 1;
+ break;
+
+ case NONE:
+ y += h;
+ break;
+
+ case FLOAT:
+ y += h / 2 - border_size.height() / 2;
+ break;
+ }
+
+ 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();
+ int left = left_->width();
+ int right = right_->width();
+ switch (arrow_location_) {
+ case TOP_LEFT:
+ case TOP_RIGHT:
+ top = std::max(top, top_arrow_->height());
+ break;
+
+ case BOTTOM_LEFT:
+ case BOTTOM_RIGHT:
+ bottom = std::max(bottom, bottom_arrow_->height());
+ break;
+
+ case LEFT_TOP:
+ case LEFT_BOTTOM:
+ left = std::max(left, left_arrow_->width());
+ break;
+
+ case RIGHT_TOP:
+ case RIGHT_BOTTOM:
+ right = std::max(right, right_arrow_->width());
+ break;
+
+ case NONE:
+ case FLOAT:
+ // Nothing to do.
+ break;
+ }
+ insets->Set(top, left, bottom, right);
+}
+
+int BubbleBorder::SetArrowOffset(int offset, const gfx::Size& contents_size) {
+ gfx::Size border_size(contents_size);
+ gfx::Insets insets;
+ GetInsets(&insets);
+ border_size.Enlarge(insets.left() + insets.right(),
+ insets.top() + insets.bottom());
+ offset = std::max(arrow_offset_,
+ std::min(offset, (is_arrow_on_horizontal(arrow_location_) ?
+ border_size.width() : border_size.height()) - arrow_offset_));
+ override_arrow_offset_ = offset;
+ return override_arrow_offset_;
+}
+
+// static
+void BubbleBorder::InitClass() {
+ static bool initialized = false;
+ if (!initialized) {
+ // Load images.
+ ResourceBundle& rb = ResourceBundle::GetSharedInstance();
+ left_ = rb.GetBitmapNamed(IDR_BUBBLE_L);
+ top_left_ = rb.GetBitmapNamed(IDR_BUBBLE_TL);
+ top_ = rb.GetBitmapNamed(IDR_BUBBLE_T);
+ top_right_ = rb.GetBitmapNamed(IDR_BUBBLE_TR);
+ right_ = rb.GetBitmapNamed(IDR_BUBBLE_R);
+ bottom_right_ = rb.GetBitmapNamed(IDR_BUBBLE_BR);
+ bottom_ = rb.GetBitmapNamed(IDR_BUBBLE_B);
+ bottom_left_ = rb.GetBitmapNamed(IDR_BUBBLE_BL);
+ left_arrow_ = rb.GetBitmapNamed(IDR_BUBBLE_L_ARROW);
+ top_arrow_ = rb.GetBitmapNamed(IDR_BUBBLE_T_ARROW);
+ right_arrow_ = rb.GetBitmapNamed(IDR_BUBBLE_R_ARROW);
+ bottom_arrow_ = rb.GetBitmapNamed(IDR_BUBBLE_B_ARROW);
+
+ // Calculate horizontal and vertical insets for arrow by ensuring that
+ // the widest arrow and corner images will have enough room to avoid overlap
+ int offset_x =
+ (std::max(top_arrow_->width(), bottom_arrow_->width()) / 2) +
+ std::max(std::max(top_left_->width(), top_right_->width()),
+ std::max(bottom_left_->width(), bottom_right_->width()));
+ int offset_y =
+ (std::max(left_arrow_->height(), right_arrow_->height()) / 2) +
+ std::max(std::max(top_left_->height(), top_right_->height()),
+ std::max(bottom_left_->height(), bottom_right_->height()));
+ arrow_offset_ = std::max(offset_x, offset_y);
+
+ initialized = true;
+ }
+}
+
+void BubbleBorder::Paint(const views::View& view, gfx::Canvas* canvas) const {
+ // Convenience shorthand variables.
+ const int tl_width = top_left_->width();
+ const int tl_height = top_left_->height();
+ const int t_height = top_->height();
+ const int tr_width = top_right_->width();
+ const int tr_height = top_right_->height();
+ const int l_width = left_->width();
+ const int r_width = right_->width();
+ const int br_width = bottom_right_->width();
+ const int br_height = bottom_right_->height();
+ const int b_height = bottom_->height();
+ const int bl_width = bottom_left_->width();
+ const int bl_height = bottom_left_->height();
+
+ gfx::Insets insets;
+ GetInsets(&insets);
+ const int top = insets.top() - t_height;
+ const int bottom = view.height() - insets.bottom() + b_height;
+ const int left = insets.left() - l_width;
+ const int right = view.width() - insets.right() + r_width;
+ const int height = bottom - top;
+ const int width = right - left;
+
+ // |arrow_offset| is offset of arrow from the begining of the edge.
+ int arrow_offset = arrow_offset_;
+ if (override_arrow_offset_)
+ arrow_offset = override_arrow_offset_;
+ else if (is_arrow_on_horizontal(arrow_location_) &&
+ !is_arrow_on_left(arrow_location_)) {
+ arrow_offset = view.width() - arrow_offset - 1;
+ } else if (!is_arrow_on_horizontal(arrow_location_) &&
+ !is_arrow_on_top(arrow_location_)) {
+ arrow_offset = view.height() - arrow_offset - 1;
+ }
+
+ // Left edge.
+ if (arrow_location_ == LEFT_TOP || arrow_location_ == LEFT_BOTTOM) {
+ int start_y = top + tl_height;
+ int before_arrow = arrow_offset - start_y - left_arrow_->height() / 2;
+ int after_arrow =
+ height - tl_height - bl_height - left_arrow_->height() - before_arrow;
+ DrawArrowInterior(canvas,
+ false,
+ left_arrow_->width() - kArrowInteriorHeight,
+ start_y + before_arrow + left_arrow_->height() / 2,
+ kArrowInteriorHeight,
+ left_arrow_->height() / 2 - 1);
+ DrawEdgeWithArrow(canvas,
+ false,
+ left_,
+ left_arrow_,
+ left,
+ start_y,
+ before_arrow,
+ after_arrow,
+ left_->width() - left_arrow_->width());
+ } else {
+ canvas->TileImageInt(*left_, left, top + tl_height, l_width,
+ height - tl_height - bl_height);
+ }
+
+ // Top left corner.
+ canvas->DrawBitmapInt(*top_left_, left, top);
+
+ // Top edge.
+ if (arrow_location_ == TOP_LEFT || arrow_location_ == TOP_RIGHT) {
+ int start_x = left + tl_width;
+ int before_arrow = arrow_offset - start_x - top_arrow_->width() / 2;
+ int after_arrow =
+ width - tl_width - tr_width - top_arrow_->width() - before_arrow;
+ DrawArrowInterior(canvas,
+ true,
+ start_x + before_arrow + top_arrow_->width() / 2,
+ top_arrow_->height() - kArrowInteriorHeight,
+ 1 - top_arrow_->width() / 2,
+ kArrowInteriorHeight);
+ DrawEdgeWithArrow(canvas,
+ true,
+ top_,
+ top_arrow_,
+ start_x,
+ top,
+ before_arrow,
+ after_arrow,
+ top_->height() - top_arrow_->height());
+ } else {
+ canvas->TileImageInt(*top_, left + tl_width, top,
+ width - tl_width - tr_width, t_height);
+ }
+
+ // Top right corner.
+ canvas->DrawBitmapInt(*top_right_, right - tr_width, top);
+
+ // Right edge.
+ if (arrow_location_ == RIGHT_TOP || arrow_location_ == RIGHT_BOTTOM) {
+ int start_y = top + tr_height;
+ int before_arrow = arrow_offset - start_y - right_arrow_->height() / 2;
+ int after_arrow = height - tl_height - bl_height -
+ right_arrow_->height() - before_arrow;
+ DrawArrowInterior(canvas,
+ false,
+ right - r_width + kArrowInteriorHeight,
+ start_y + before_arrow + right_arrow_->height() / 2,
+ -kArrowInteriorHeight,
+ right_arrow_->height() / 2 - 1);
+ DrawEdgeWithArrow(canvas,
+ false,
+ right_,
+ right_arrow_,
+ right - r_width,
+ start_y,
+ before_arrow,
+ after_arrow,
+ 0);
+ } else {
+ canvas->TileImageInt(*right_, right - r_width, top + tr_height, r_width,
+ height - tr_height - br_height);
+ }
+
+ // Bottom right corner.
+ canvas->DrawBitmapInt(*bottom_right_, right - br_width, bottom - br_height);
+
+ // Bottom edge.
+ if (arrow_location_ == BOTTOM_LEFT || arrow_location_ == BOTTOM_RIGHT) {
+ int start_x = left + bl_width;
+ int before_arrow = arrow_offset - start_x - bottom_arrow_->width() / 2;
+ int after_arrow =
+ width - bl_width - br_width - bottom_arrow_->width() - before_arrow;
+ DrawArrowInterior(canvas,
+ true,
+ start_x + before_arrow + bottom_arrow_->width() / 2,
+ bottom - b_height + kArrowInteriorHeight,
+ 1 - bottom_arrow_->width() / 2,
+ -kArrowInteriorHeight);
+ DrawEdgeWithArrow(canvas,
+ true,
+ bottom_,
+ bottom_arrow_,
+ start_x,
+ bottom - b_height,
+ before_arrow,
+ after_arrow,
+ 0);
+ } else {
+ canvas->TileImageInt(*bottom_, left + bl_width, bottom - b_height,
+ width - bl_width - br_width, b_height);
+ }
+
+ // Bottom left corner.
+ canvas->DrawBitmapInt(*bottom_left_, left, bottom - bl_height);
+}
+
+void BubbleBorder::DrawEdgeWithArrow(gfx::Canvas* canvas,
+ bool is_horizontal,
+ SkBitmap* edge,
+ SkBitmap* arrow,
+ int start_x,
+ int start_y,
+ int before_arrow,
+ int after_arrow,
+ int offset) const {
+ /* Here's what the parameters mean:
+ * start_x
+ * .
+ * . ┌───┐ ┬ offset
+ * start_y..........┌────┬────────┤ ▲ ├────────┬────┐
+ * │ / │--------│∙ ∙│--------│ \ │
+ * │ / ├────────┴───┴────────┤ \ │
+ * ├───┬┘ └┬───┤
+ * └───┬────┘ └───┬────┘
+ * before_arrow ─┘ └─ after_arrow
+ */
+ if (before_arrow) {
+ canvas->TileImageInt(*edge, start_x, start_y,
+ is_horizontal ? before_arrow : edge->width(),
+ is_horizontal ? edge->height() : before_arrow);
+ }
+
+ canvas->DrawBitmapInt(*arrow,
+ start_x + (is_horizontal ? before_arrow : offset),
+ start_y + (is_horizontal ? offset : before_arrow));
+
+ if (after_arrow) {
+ start_x += (is_horizontal ? before_arrow + arrow->width() : 0);
+ start_y += (is_horizontal ? 0 : before_arrow + arrow->height());
+ canvas->TileImageInt(*edge, start_x, start_y,
+ is_horizontal ? after_arrow : edge->width(),
+ is_horizontal ? edge->height() : after_arrow);
+ }
+}
+
+void BubbleBorder::DrawArrowInterior(gfx::Canvas* canvas,
+ bool is_horizontal,
+ int tip_x,
+ int tip_y,
+ int shift_x,
+ int shift_y) const {
+ /* This function fills the interior of the arrow with background color.
+ * It draws isosceles triangle under semitransparent arrow tip.
+ *
+ * Here's what the parameters mean:
+ *
+ * ┌──────── |tip_x|
+ * ┌─────┐
+ * │ ▲ │ ──── |tip y|
+ * │∙∙∙∙∙│ ┐
+ * └─────┘ └─── |shift_x| (offset from tip to vertexes of isosceles triangle)
+ * └────────── |shift_y|
+ */
+ SkPaint paint;
+ paint.setStyle(SkPaint::kFill_Style);
+ paint.setColor(background_color_);
+ gfx::Path path;
+ path.incReserve(4);
+ path.moveTo(SkIntToScalar(tip_x), SkIntToScalar(tip_y));
+ path.lineTo(SkIntToScalar(tip_x + shift_x),
+ SkIntToScalar(tip_y + shift_y));
+ if (is_horizontal)
+ path.lineTo(SkIntToScalar(tip_x - shift_x), SkIntToScalar(tip_y + shift_y));
+ else
+ path.lineTo(SkIntToScalar(tip_x + shift_x), SkIntToScalar(tip_y - shift_y));
+ path.close();
+ canvas->AsCanvasSkia()->drawPath(path, paint);
+}
+
+/////////////////////////
+
+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);
+ paint.setColor(border_->background_color());
+ gfx::Path path;
+ gfx::Rect bounds(view->GetContentsBounds());
+ SkRect rect;
+ rect.set(SkIntToScalar(bounds.x()), SkIntToScalar(bounds.y()),
+ SkIntToScalar(bounds.right()), SkIntToScalar(bounds.bottom()));
+ SkScalar radius = SkIntToScalar(BubbleBorder::GetCornerRadius());
+ path.addRoundRect(rect, radius, radius);
+ canvas->AsCanvasSkia()->drawPath(path, paint);
+}
diff --git a/chrome/browser/ui/views/bubble/bubble_border.h b/chrome/browser/ui/views/bubble/bubble_border.h
new file mode 100644
index 0000000..4082d28
--- /dev/null
+++ b/chrome/browser/ui/views/bubble/bubble_border.h
@@ -0,0 +1,172 @@
+// 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_UI_VIEWS_BUBBLE_BORDER_H_
+#define CHROME_BROWSER_UI_VIEWS_BUBBLE_BORDER_H_
+#pragma once
+
+#include "third_party/skia/include/core/SkColor.h"
+#include "views/background.h"
+#include "views/border.h"
+
+class SkBitmap;
+
+// Renders a border, with optional arrow, and a custom dropshadow.
+// This can be used to produce floating "bubble" objects with rounded corners.
+class BubbleBorder : public views::Border {
+ public:
+ // Possible locations for the (optional) arrow.
+ // 0 bit specifies left or right.
+ // 1 bit specifies top or bottom.
+ // 2 bit specifies horizontal or vertical.
+ enum ArrowLocation {
+ TOP_LEFT = 0,
+ TOP_RIGHT = 1,
+ BOTTOM_LEFT = 2,
+ BOTTOM_RIGHT = 3,
+ LEFT_TOP = 4,
+ RIGHT_TOP = 5,
+ LEFT_BOTTOM = 6,
+ RIGHT_BOTTOM = 7,
+ NONE = 8, // No arrow. Positioned under the supplied rect.
+ FLOAT = 9 // No arrow. Centered over the supplied rect.
+ };
+
+ explicit BubbleBorder(ArrowLocation arrow_location)
+ : override_arrow_offset_(0),
+ arrow_location_(arrow_location),
+ background_color_(SK_ColorWHITE) {
+ InitClass();
+ }
+
+ // Returns the radius of the corner of the border.
+ static int GetCornerRadius() {
+ // We can't safely calculate a border radius by comparing the sizes of the
+ // side and corner images, because either may have been extended in various
+ // directions in order to do more subtle dropshadow fading or other effects.
+ // So we hardcode the most accurate value.
+ return 4;
+ }
+
+ // Sets the location for the arrow.
+ void set_arrow_location(ArrowLocation arrow_location) {
+ arrow_location_ = arrow_location;
+ }
+ ArrowLocation arrow_location() const { return arrow_location_; }
+
+ static ArrowLocation horizontal_mirror(ArrowLocation loc) {
+ return loc >= NONE ? loc : static_cast<ArrowLocation>(loc ^ 1);
+ }
+
+ static ArrowLocation vertical_mirror(ArrowLocation loc) {
+ return loc >= NONE ? loc : static_cast<ArrowLocation>(loc ^ 2);
+ }
+
+ static bool has_arrow(ArrowLocation loc) {
+ return loc >= NONE ? false : true;
+ }
+
+ static bool is_arrow_on_left(ArrowLocation loc) {
+ return loc >= NONE ? false : !(loc & 1);
+ }
+
+ static bool is_arrow_on_top(ArrowLocation loc) {
+ return loc >= NONE ? false : !(loc & 2);
+ }
+
+ static bool is_arrow_on_horizontal(ArrowLocation loc) {
+ return loc >= NONE ? false : !(loc & 4);
+ }
+
+ // Sets the background color for the arrow body. This is irrelevant if you do
+ // not also set the arrow location to something other than NONE.
+ void set_background_color(SkColor background_color) {
+ background_color_ = background_color;
+ }
+ SkColor background_color() const { return background_color_; }
+
+ // For borders with an arrow, gives the desired bounds (in screen coordinates)
+ // given the rect to point to and the size of the contained contents. This
+ // depends on the arrow location, so if you change that, you should call this
+ // again to find out the new coordinates.
+ gfx::Rect GetBounds(const gfx::Rect& position_relative_to,
+ const gfx::Size& contents_size) const;
+
+ // Sets a fixed offset for the arrow from the beginning of corresponding edge.
+ // The arrow will still point to the same location but the bubble will shift
+ // location to make that happen. Returns actuall arrow offset, in case of
+ // overflow it differ from desired.
+ int SetArrowOffset(int offset, const gfx::Size& contents_size);
+
+ // Overridden from views::Border:
+ virtual void GetInsets(gfx::Insets* insets) const;
+
+ private:
+ // Loads images if necessary.
+ static void InitClass();
+
+ virtual ~BubbleBorder() { }
+
+ // Overridden from views::Border:
+ virtual void Paint(const views::View& view, gfx::Canvas* canvas) const;
+
+ void DrawEdgeWithArrow(gfx::Canvas* canvas,
+ bool is_horizontal,
+ SkBitmap* edge,
+ SkBitmap* arrow,
+ int start_x,
+ int start_y,
+ int before_arrow,
+ int after_arrow,
+ int offset) const;
+
+ void DrawArrowInterior(gfx::Canvas* canvas,
+ bool is_horizontal,
+ int tip_x,
+ int tip_y,
+ int shift_x,
+ int shift_y) const;
+
+ // Border graphics.
+ static SkBitmap* left_;
+ static SkBitmap* top_left_;
+ static SkBitmap* top_;
+ static SkBitmap* top_right_;
+ static SkBitmap* right_;
+ static SkBitmap* bottom_right_;
+ static SkBitmap* bottom_;
+ static SkBitmap* bottom_left_;
+ static SkBitmap* left_arrow_;
+ static SkBitmap* top_arrow_;
+ static SkBitmap* right_arrow_;
+ static SkBitmap* bottom_arrow_;
+
+ // Minimal offset of the arrow from the closet edge of bounding rect.
+ static int arrow_offset_;
+
+ // If specified, overrides the pre-calculated |arrow_offset_| of the arrow.
+ int override_arrow_offset_;
+
+ ArrowLocation arrow_location_;
+ SkColor background_color_;
+
+ DISALLOW_COPY_AND_ASSIGN(BubbleBorder);
+};
+
+// A Background that clips itself to the specified BubbleBorder and uses
+// the background color of the BubbleBorder.
+class BubbleBackground : public views::Background {
+ public:
+ explicit BubbleBackground(BubbleBorder* border) : border_(border) {}
+
+ // Background overrides.
+ virtual void Paint(gfx::Canvas* canvas, views::View* view) const;
+
+ private:
+ BubbleBorder* border_;
+
+ DISALLOW_COPY_AND_ASSIGN(BubbleBackground);
+};
+
+#endif // CHROME_BROWSER_UI_VIEWS_BUBBLE_BORDER_H_
diff --git a/chrome/browser/ui/views/extensions/extension_installed_bubble.cc b/chrome/browser/ui/views/extensions/extension_installed_bubble.cc
index 11258bc..5e0ff1e 100644
--- a/chrome/browser/ui/views/extensions/extension_installed_bubble.cc
+++ b/chrome/browser/ui/views/extensions/extension_installed_bubble.cc
@@ -390,8 +390,7 @@ void ExtensionInstalledBubble::ShowInternal() {
views::View::ConvertPointToScreen(reference_view, &origin);
gfx::Rect bounds = reference_view->bounds();
bounds.set_origin(origin);
- views::BubbleBorder::ArrowLocation arrow_location =
- views::BubbleBorder::TOP_RIGHT;
+ BubbleBorder::ArrowLocation arrow_location = BubbleBorder::TOP_RIGHT;
// For omnibox keyword bubbles, move the arrow to point to the left edge
// of the omnibox, just to the right of the icon.
@@ -399,7 +398,7 @@ void ExtensionInstalledBubble::ShowInternal() {
bounds.set_origin(
browser_view->GetLocationBarView()->GetLocationEntryOrigin());
bounds.set_width(0);
- arrow_location = views::BubbleBorder::TOP_LEFT;
+ arrow_location = BubbleBorder::TOP_LEFT;
}
bubble_content_ = new InstalledBubbleContent(
diff --git a/chrome/browser/ui/views/extensions/extension_popup.cc b/chrome/browser/ui/views/extensions/extension_popup.cc
index 28ceec6..c33cd8b 100644
--- a/chrome/browser/ui/views/extensions/extension_popup.cc
+++ b/chrome/browser/ui/views/extensions/extension_popup.cc
@@ -38,13 +38,12 @@ const int ExtensionPopup::kMinHeight = 25;
const int ExtensionPopup::kMaxWidth = 800;
const int ExtensionPopup::kMaxHeight = 600;
-ExtensionPopup::ExtensionPopup(
- ExtensionHost* host,
- views::Widget* frame,
- const gfx::Rect& relative_to,
- views::BubbleBorder::ArrowLocation arrow_location,
- bool inspect_with_devtools,
- Observer* observer)
+ExtensionPopup::ExtensionPopup(ExtensionHost* host,
+ views::Widget* frame,
+ const gfx::Rect& relative_to,
+ BubbleBorder::ArrowLocation arrow_location,
+ bool inspect_with_devtools,
+ Observer* observer)
: BrowserBubble(host->view(),
frame,
relative_to,
@@ -177,7 +176,7 @@ ExtensionPopup* ExtensionPopup::Show(
const GURL& url,
Browser* browser,
const gfx::Rect& relative_to,
- views::BubbleBorder::ArrowLocation arrow_location,
+ BubbleBorder::ArrowLocation arrow_location,
bool inspect_with_devtools,
Observer* observer) {
ExtensionProcessManager* manager =
diff --git a/chrome/browser/ui/views/extensions/extension_popup.h b/chrome/browser/ui/views/extensions/extension_popup.h
index c374d7f..7f0abc3 100644
--- a/chrome/browser/ui/views/extensions/extension_popup.h
+++ b/chrome/browser/ui/views/extensions/extension_popup.h
@@ -9,10 +9,10 @@
#include "base/memory/ref_counted.h"
#include "chrome/browser/extensions/extension_host.h"
#include "chrome/browser/ui/views/browser_bubble.h"
+#include "chrome/browser/ui/views/bubble/bubble_border.h"
#include "chrome/browser/ui/views/extensions/extension_view.h"
#include "content/common/notification_observer.h"
#include "googleurl/src/gurl.h"
-#include "views/bubble/bubble_border.h"
class Browser;
@@ -55,7 +55,7 @@ class ExtensionPopup : public BrowserBubble,
// finish loading in order to minimize UI flashing and resizing.
static ExtensionPopup* Show(const GURL& url, Browser* browser,
const gfx::Rect& relative_to,
- views::BubbleBorder::ArrowLocation arrow_location,
+ BubbleBorder::ArrowLocation arrow_location,
bool inspect_with_devtools,
Observer* observer);
@@ -101,7 +101,7 @@ class ExtensionPopup : public BrowserBubble,
ExtensionPopup(ExtensionHost* host,
views::Widget* frame,
const gfx::Rect& relative_to,
- views::BubbleBorder::ArrowLocation arrow_location,
+ BubbleBorder::ArrowLocation arrow_location,
bool inspect_with_devtools,
Observer* observer);
diff --git a/chrome/browser/ui/views/first_run_bubble.cc b/chrome/browser/ui/views/first_run_bubble.cc
index 14428d5..637d967 100644
--- a/chrome/browser/ui/views/first_run_bubble.cc
+++ b/chrome/browser/ui/views/first_run_bubble.cc
@@ -479,12 +479,11 @@ void FirstRunMinimalBubbleView::FocusWillChange(View* focused_before,
// FirstRunBubble -------------------------------------------------------------
// static
-FirstRunBubble* FirstRunBubble::Show(
- Profile* profile,
- views::Widget* parent,
- const gfx::Rect& position_relative_to,
- views::BubbleBorder::ArrowLocation arrow_location,
- FirstRun::BubbleType bubble_type) {
+FirstRunBubble* FirstRunBubble::Show(Profile* profile,
+ views::Widget* parent,
+ const gfx::Rect& position_relative_to,
+ BubbleBorder::ArrowLocation arrow_location,
+ FirstRun::BubbleType bubble_type) {
FirstRunBubble* bubble = new FirstRunBubble();
FirstRunBubbleViewBase* view = NULL;
diff --git a/chrome/browser/ui/views/first_run_bubble.h b/chrome/browser/ui/views/first_run_bubble.h
index 37b2598..15ca056 100644
--- a/chrome/browser/ui/views/first_run_bubble.h
+++ b/chrome/browser/ui/views/first_run_bubble.h
@@ -17,11 +17,10 @@ class Profile;
class FirstRunBubble : public Bubble,
public BubbleDelegate {
public:
- static FirstRunBubble* Show(
- Profile* profile, views::Widget* parent,
- const gfx::Rect& position_relative_to,
- views::BubbleBorder::ArrowLocation arrow_location,
- FirstRun::BubbleType bubble_type);
+ static FirstRunBubble* Show(Profile* profile, views::Widget* parent,
+ const gfx::Rect& position_relative_to,
+ BubbleBorder::ArrowLocation arrow_location,
+ FirstRun::BubbleType bubble_type);
private:
FirstRunBubble();
diff --git a/chrome/browser/ui/views/location_bar/content_setting_image_view.cc b/chrome/browser/ui/views/location_bar/content_setting_image_view.cc
index 990323f..3123709 100644
--- a/chrome/browser/ui/views/location_bar/content_setting_image_view.cc
+++ b/chrome/browser/ui/views/location_bar/content_setting_image_view.cc
@@ -142,8 +142,7 @@ void ContentSettingImageView::OnMouseReleased(const views::MouseEvent& event) {
parent_->browser(), tab_contents, profile,
content_setting_image_model_->get_content_settings_type()),
profile, tab_contents->tab_contents());
- bubble_ = Bubble::Show(GetWidget(), screen_bounds,
- views::BubbleBorder::TOP_RIGHT,
+ bubble_ = Bubble::Show(GetWidget(), screen_bounds, BubbleBorder::TOP_RIGHT,
bubble_contents, this);
bubble_contents->set_bubble(bubble_);
}
@@ -243,3 +242,4 @@ void ContentSettingImageView::AnimateToState(double state) {
parent_->Layout();
parent_->SchedulePaint();
}
+
diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc
index 25fa2ca..f15d5c9 100644
--- a/chrome/browser/ui/views/location_bar/location_bar_view.cc
+++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc
@@ -52,7 +52,6 @@
#include "ui/gfx/canvas_skia.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/skia_util.h"
-#include "views/bubble/bubble_border.h"
#include "views/controls/label.h"
#include "views/controls/textfield/native_textfield_views.h"
#include "views/drag_utils.h"
@@ -719,8 +718,7 @@ void LocationBarView::OnPaint(gfx::Canvas* canvas) {
paint.setAntiAlias(true);
// The round corners of the omnibox match the round corners of the dropdown
// below, and all our other bubbles.
- const SkScalar radius(SkIntToScalar(
- views::BubbleBorder::GetCornerRadius()));
+ const SkScalar radius(SkIntToScalar(BubbleBorder::GetCornerRadius()));
bounds.Inset(kNormalHorizontalEdgeThickness, 0);
canvas->AsCanvasSkia()->drawRoundRect(gfx::RectToSkRect(bounds), radius,
radius, paint);
@@ -1009,8 +1007,7 @@ void LocationBarView::ShowFirstRunBubbleInternal(
origin.set_x(width() - origin.x());
views::View::ConvertPointToScreen(this, &origin);
FirstRunBubble::Show(browser_->profile(), GetWidget(),
- gfx::Rect(origin, gfx::Size()),
- views::BubbleBorder::TOP_LEFT, bubble_type);
+ gfx::Rect(origin, gfx::Size()), BubbleBorder::TOP_LEFT, bubble_type);
#endif
}
diff --git a/chrome/browser/ui/views/location_bar/page_action_image_view.cc b/chrome/browser/ui/views/location_bar/page_action_image_view.cc
index 694428f..36e1761 100644
--- a/chrome/browser/ui/views/location_bar/page_action_image_view.cc
+++ b/chrome/browser/ui/views/location_bar/page_action_image_view.cc
@@ -75,8 +75,8 @@ void PageActionImageView::ExecuteAction(int button,
View::ConvertPointToScreen(this, &origin);
screen_bounds.set_origin(origin);
- views::BubbleBorder::ArrowLocation arrow_location = base::i18n::IsRTL() ?
- views::BubbleBorder::TOP_LEFT : views::BubbleBorder::TOP_RIGHT;
+ BubbleBorder::ArrowLocation arrow_location = base::i18n::IsRTL() ?
+ BubbleBorder::TOP_LEFT : BubbleBorder::TOP_RIGHT;
popup_ = ExtensionPopup::Show(
page_action_->GetPopupUrl(current_tab_id_),
diff --git a/chrome/browser/ui/views/notifications/balloon_view.cc b/chrome/browser/ui/views/notifications/balloon_view.cc
index 6067b42..1b8dcf5 100644
--- a/chrome/browser/ui/views/notifications/balloon_view.cc
+++ b/chrome/browser/ui/views/notifications/balloon_view.cc
@@ -13,6 +13,7 @@
#include "chrome/browser/notifications/desktop_notification_service.h"
#include "chrome/browser/notifications/notification.h"
#include "chrome/browser/notifications/notification_options_menu_model.h"
+#include "chrome/browser/ui/views/bubble/bubble_border.h"
#include "chrome/browser/ui/views/notifications/balloon_view_host.h"
#include "chrome/common/chrome_notification_types.h"
#include "content/browser/renderer_host/render_view_host.h"
@@ -29,7 +30,6 @@
#include "ui/gfx/canvas_skia.h"
#include "ui/gfx/insets.h"
#include "ui/gfx/native_widget_types.h"
-#include "views/bubble/bubble_border.h"
#include "views/controls/button/button.h"
#include "views/controls/button/image_button.h"
#include "views/controls/button/text_button.h"
@@ -104,8 +104,7 @@ BalloonViewImpl::BalloonViewImpl(BalloonCollection* collection)
// as it is owned by the balloon.
set_parent_owned(false);
- views::BubbleBorder* bubble_border =
- new views::BubbleBorder(views::BubbleBorder::FLOAT);
+ BubbleBorder* bubble_border = new BubbleBorder(BubbleBorder::FLOAT);
set_border(bubble_border);
}
@@ -381,7 +380,7 @@ void BalloonViewImpl::GetContentsMask(const gfx::Rect& rect,
gfx::Path* path) const {
// This rounds the corners, and we also cut out a circle for the close
// button, since we can't guarantee the ordering of two top-most windows.
- SkScalar radius = SkIntToScalar(views::BubbleBorder::GetCornerRadius());
+ SkScalar radius = SkIntToScalar(BubbleBorder::GetCornerRadius());
SkScalar spline_radius = radius -
SkScalarMul(radius, (SK_ScalarSqrt2 - SK_Scalar1) * 4 / 3);
SkScalar left = SkIntToScalar(0);
@@ -405,7 +404,7 @@ void BalloonViewImpl::GetContentsMask(const gfx::Rect& rect,
void BalloonViewImpl::GetFrameMask(const gfx::Rect& rect,
gfx::Path* path) const {
- SkScalar radius = SkIntToScalar(views::BubbleBorder::GetCornerRadius());
+ SkScalar radius = SkIntToScalar(BubbleBorder::GetCornerRadius());
SkScalar spline_radius = radius -
SkScalarMul(radius, (SK_ScalarSqrt2 - SK_Scalar1) * 4 / 3);
SkScalar left = SkIntToScalar(rect.x());
diff --git a/chrome/browser/ui/views/page_info_bubble_view.cc b/chrome/browser/ui/views/page_info_bubble_view.cc
index d8fbad7..067794c 100644
--- a/chrome/browser/ui/views/page_info_bubble_view.cc
+++ b/chrome/browser/ui/views/page_info_bubble_view.cc
@@ -499,7 +499,7 @@ void ShowPageInfoBubble(gfx::NativeWindow parent,
new PageInfoBubbleView(parent, profile, url, ssl, show_history);
Bubble* bubble =
Bubble::Show(browser_view->GetWidget(), bounds,
- views::BubbleBorder::TOP_LEFT,
+ BubbleBorder::TOP_LEFT,
page_info_bubble, page_info_bubble);
page_info_bubble->set_bubble(bubble);
}
diff --git a/chrome/browser/ui/views/pinned_contents_info_bubble.cc b/chrome/browser/ui/views/pinned_contents_info_bubble.cc
index f1b712b..bd79c63 100644
--- a/chrome/browser/ui/views/pinned_contents_info_bubble.cc
+++ b/chrome/browser/ui/views/pinned_contents_info_bubble.cc
@@ -4,11 +4,11 @@
#include "chrome/browser/ui/views/pinned_contents_info_bubble.h"
-#include "views/bubble/bubble_border.h"
+#include "chrome/browser/ui/views/bubble/bubble_border.h"
void PinnedContentsBorderContents::SizeAndGetBounds(
const gfx::Rect& position_relative_to,
- views::BubbleBorder::ArrowLocation arrow_location,
+ BubbleBorder::ArrowLocation arrow_location,
bool allow_bubble_offscreen,
const gfx::Size& contents_size,
gfx::Rect* contents_bounds,
@@ -37,7 +37,7 @@ void PinnedContentsBorderContents::SizeAndGetBounds(
PinnedContentsInfoBubble* PinnedContentsInfoBubble::Show(
views::Widget* parent,
const gfx::Rect& position_relative_to,
- views::BubbleBorder::ArrowLocation arrow_location,
+ BubbleBorder::ArrowLocation arrow_location,
const gfx::Point& bubble_anchor,
views::View* contents,
BubbleDelegate* delegate) {
diff --git a/chrome/browser/ui/views/pinned_contents_info_bubble.h b/chrome/browser/ui/views/pinned_contents_info_bubble.h
index 381af56..2de87ab 100644
--- a/chrome/browser/ui/views/pinned_contents_info_bubble.h
+++ b/chrome/browser/ui/views/pinned_contents_info_bubble.h
@@ -20,7 +20,7 @@ class PinnedContentsBorderContents : public BorderContents {
// BorderContents overrides:
virtual void SizeAndGetBounds(
const gfx::Rect& position_relative_to, // In screen coordinates
- views::BubbleBorder::ArrowLocation arrow_location,
+ BubbleBorder::ArrowLocation arrow_location,
bool allow_bubble_offscreen,
const gfx::Size& contents_size,
gfx::Rect* contents_bounds, // Returned in window coordinates
@@ -47,7 +47,7 @@ class PinnedContentsInfoBubble : public Bubble {
static PinnedContentsInfoBubble* Show(
views::Widget* parent,
const gfx::Rect& position_relative_to,
- views::BubbleBorder::ArrowLocation arrow_location,
+ BubbleBorder::ArrowLocation arrow_location,
const gfx::Point& bubble_anchor_,
views::View* contents,
BubbleDelegate* delegate);
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index fba143d..fc6b188 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -3090,6 +3090,8 @@
'browser/ui/views/bubble/border_widget_win.h',
'browser/ui/views/bubble/bubble.cc',
'browser/ui/views/bubble/bubble.h',
+ 'browser/ui/views/bubble/bubble_border.cc',
+ 'browser/ui/views/bubble/bubble_border.h',
'browser/ui/views/certificate_viewer_win.cc',
'browser/ui/views/chrome_views_delegate.cc',
'browser/ui/views/chrome_views_delegate.h',
@@ -4361,6 +4363,8 @@
['include', '^browser/ui/views/bubble/border_contents.h'],
['include', '^browser/ui/views/bubble/bubble.cc'],
['include', '^browser/ui/views/bubble/bubble.h'],
+ ['include', '^browser/ui/views/bubble/bubble_border.cc'],
+ ['include', '^browser/ui/views/bubble/bubble_border.h'],
['include', '^browser/ui/views/chrome_views_delegate.cc'],
['include', '^browser/ui/views/compact_nav/compact_location_bar_view.cc'],
['include', '^browser/ui/views/compact_nav/compact_location_bar_view.h'],