summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authordbeam@chromium.org <dbeam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-16 19:51:12 +0000
committerdbeam@chromium.org <dbeam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-16 19:51:12 +0000
commit2d366a6bdccfa1d2a4dc6cb4a3845c30e578809e (patch)
tree1c809fae28d50f1449029fb9e6aaecbcf38f56f2 /ui
parent4047caec63b2d650d056c70b4ca683ca1ee507a1 (diff)
downloadchromium_src-2d366a6bdccfa1d2a4dc6cb4a3845c30e578809e.zip
chromium_src-2d366a6bdccfa1d2a4dc6cb4a3845c30e578809e.tar.gz
chromium_src-2d366a6bdccfa1d2a4dc6cb4a3845c30e578809e.tar.bz2
rAc: open info bubbles only within the dialog using existing logic.
Kills some duplicated logic and fixes vertical positioning. R=msw@chromium.org BUG=322816 NOTRY=true Review URL: https://codereview.chromium.org/115483004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@240984 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/views/bubble/bubble_delegate.cc6
-rw-r--r--ui/views/bubble/bubble_delegate.h3
-rw-r--r--ui/views/bubble/bubble_frame_view.cc60
-rw-r--r--ui/views/bubble/bubble_frame_view.h5
-rw-r--r--ui/views/bubble/bubble_frame_view_unittest.cc8
5 files changed, 38 insertions, 44 deletions
diff --git a/ui/views/bubble/bubble_delegate.cc b/ui/views/bubble/bubble_delegate.cc
index 515c400..dbd0cae8 100644
--- a/ui/views/bubble/bubble_delegate.cc
+++ b/ui/views/bubble/bubble_delegate.cc
@@ -134,7 +134,7 @@ NonClientFrameView* BubbleDelegateView::CreateNonClientFrameView(
Widget* widget) {
BubbleFrameView* frame = new BubbleFrameView(margins());
BubbleBorder::Arrow adjusted_arrow = arrow();
- if (ShouldFlipArrowForRtl() && base::i18n::IsRTL())
+ if (base::i18n::IsRTL())
adjusted_arrow = BubbleBorder::horizontal_mirror(adjusted_arrow);
frame->SetBubbleBorder(new BubbleBorder(adjusted_arrow, shadow(), color()));
return frame;
@@ -276,10 +276,6 @@ void BubbleDelegateView::AnimationProgressed(const gfx::Animation* animation) {
void BubbleDelegateView::Init() {}
-bool BubbleDelegateView::ShouldFlipArrowForRtl() const {
- return true;
-}
-
void BubbleDelegateView::SetAnchorView(View* anchor_view) {
// When the anchor view gets set the associated anchor widget might
// change as well.
diff --git a/ui/views/bubble/bubble_delegate.h b/ui/views/bubble/bubble_delegate.h
index 86bbc17..4bf8ff6 100644
--- a/ui/views/bubble/bubble_delegate.h
+++ b/ui/views/bubble/bubble_delegate.h
@@ -144,9 +144,6 @@ class VIEWS_EXPORT BubbleDelegateView : public WidgetDelegateView,
// Perform view initialization on the contents for bubble sizing.
virtual void Init();
- // Whether |arrow()| should automatically flip while in RTL.
- virtual bool ShouldFlipArrowForRtl() const;
-
// Sets the anchor view or rect and repositions the bubble. Note that if a
// valid view gets passed, the anchor rect will get ignored. If the view gets
// deleted, but no new view gets set, the last known anchor postion will get
diff --git a/ui/views/bubble/bubble_frame_view.cc b/ui/views/bubble/bubble_frame_view.cc
index ec60210..7e0fd5e 100644
--- a/ui/views/bubble/bubble_frame_view.cc
+++ b/ui/views/bubble/bubble_frame_view.cc
@@ -25,26 +25,27 @@ const int kTitleTopInset = 12;
const int kTitleLeftInset = 19;
const int kTitleBottomInset = 12;
-// Get the |vertical| or horizontal screen overflow of the |window_bounds|.
-int GetOffScreenLength(const gfx::Rect& monitor_bounds,
+// Get the |vertical| or horizontal amount that |available_bounds| overflows
+// |window_bounds|.
+int GetOffScreenLength(const gfx::Rect& available_bounds,
const gfx::Rect& window_bounds,
bool vertical) {
- if (monitor_bounds.IsEmpty() || monitor_bounds.Contains(window_bounds))
+ if (available_bounds.IsEmpty() || available_bounds.Contains(window_bounds))
return 0;
// window_bounds
- // +-------------------------------+
- // | top |
- // | +----------------+ |
- // | left | monitor_bounds | right |
- // | +----------------+ |
- // | bottom |
- // +-------------------------------+
+ // +---------------------------------+
+ // | top |
+ // | +------------------+ |
+ // | left | available_bounds | right |
+ // | +------------------+ |
+ // | bottom |
+ // +---------------------------------+
if (vertical)
- return std::max(0, monitor_bounds.y() - window_bounds.y()) +
- std::max(0, window_bounds.bottom() - monitor_bounds.bottom());
- return std::max(0, monitor_bounds.x() - window_bounds.x()) +
- std::max(0, window_bounds.right() - monitor_bounds.right());
+ return std::max(0, available_bounds.y() - window_bounds.y()) +
+ std::max(0, window_bounds.bottom() - available_bounds.bottom());
+ return std::max(0, available_bounds.x() - window_bounds.x()) +
+ std::max(0, window_bounds.right() - available_bounds.right());
}
} // namespace
@@ -265,7 +266,8 @@ gfx::Rect BubbleFrameView::GetUpdatedWindowBounds(const gfx::Rect& anchor_rect,
return bubble_border_->GetBounds(anchor_rect, client_size);
}
-gfx::Rect BubbleFrameView::GetMonitorBounds(const gfx::Rect& rect) {
+gfx::Rect BubbleFrameView::GetAvailableScreenBounds(const gfx::Rect& rect) {
+ // The bubble attempts to fit within the current screen bounds.
// TODO(scottmg): Native is wrong. http://crbug.com/133312
return gfx::Screen::GetNativeScreen()->GetDisplayNearestPoint(
rect.CenterPoint()).work_area();
@@ -276,9 +278,9 @@ void BubbleFrameView::MirrorArrowIfOffScreen(
const gfx::Rect& anchor_rect,
const gfx::Size& client_size) {
// Check if the bounds don't fit on screen.
- gfx::Rect monitor_rect(GetMonitorBounds(anchor_rect));
+ gfx::Rect available_bounds(GetAvailableScreenBounds(anchor_rect));
gfx::Rect window_bounds(bubble_border_->GetBounds(anchor_rect, client_size));
- if (GetOffScreenLength(monitor_rect, window_bounds, vertical) > 0) {
+ if (GetOffScreenLength(available_bounds, window_bounds, vertical) > 0) {
BubbleBorder::Arrow arrow = bubble_border()->arrow();
// Mirror the arrow and get the new bounds.
bubble_border_->set_arrow(
@@ -289,8 +291,8 @@ void BubbleFrameView::MirrorArrowIfOffScreen(
// Restore the original arrow if mirroring doesn't show more of the bubble.
// Otherwise it should invoke parent's Layout() to layout the content based
// on the new bubble border.
- if (GetOffScreenLength(monitor_rect, mirror_bounds, vertical) >=
- GetOffScreenLength(monitor_rect, window_bounds, vertical))
+ if (GetOffScreenLength(available_bounds, mirror_bounds, vertical) >=
+ GetOffScreenLength(available_bounds, window_bounds, vertical))
bubble_border_->set_arrow(arrow);
else if (parent())
parent()->Layout();
@@ -306,23 +308,23 @@ void BubbleFrameView::OffsetArrowIfOffScreen(const gfx::Rect& anchor_rect,
bubble_border_->set_arrow_offset(0);
gfx::Rect window_bounds(bubble_border_->GetBounds(anchor_rect, client_size));
- gfx::Rect monitor_rect(GetMonitorBounds(anchor_rect));
- if (monitor_rect.IsEmpty() || monitor_rect.Contains(window_bounds))
+ gfx::Rect available_bounds(GetAvailableScreenBounds(anchor_rect));
+ if (available_bounds.IsEmpty() || available_bounds.Contains(window_bounds))
return;
// Calculate off-screen adjustment.
const bool is_horizontal = BubbleBorder::is_arrow_on_horizontal(arrow);
int offscreen_adjust = 0;
if (is_horizontal) {
- if (window_bounds.x() < monitor_rect.x())
- offscreen_adjust = monitor_rect.x() - window_bounds.x();
- else if (window_bounds.right() > monitor_rect.right())
- offscreen_adjust = monitor_rect.right() - window_bounds.right();
+ if (window_bounds.x() < available_bounds.x())
+ offscreen_adjust = available_bounds.x() - window_bounds.x();
+ else if (window_bounds.right() > available_bounds.right())
+ offscreen_adjust = available_bounds.right() - window_bounds.right();
} else {
- if (window_bounds.y() < monitor_rect.y())
- offscreen_adjust = monitor_rect.y() - window_bounds.y();
- else if (window_bounds.bottom() > monitor_rect.bottom())
- offscreen_adjust = monitor_rect.bottom() - window_bounds.bottom();
+ if (window_bounds.y() < available_bounds.y())
+ offscreen_adjust = available_bounds.y() - window_bounds.y();
+ else if (window_bounds.bottom() > available_bounds.bottom())
+ offscreen_adjust = available_bounds.bottom() - window_bounds.bottom();
}
// For center arrows, arrows are moved in the opposite direction of
diff --git a/ui/views/bubble/bubble_frame_view.h b/ui/views/bubble/bubble_frame_view.h
index 6fe4c2a..d033c8d 100644
--- a/ui/views/bubble/bubble_frame_view.h
+++ b/ui/views/bubble/bubble_frame_view.h
@@ -71,9 +71,8 @@ class VIEWS_EXPORT BubbleFrameView : public NonClientFrameView,
bool adjust_if_offscreen);
protected:
- // Returns the bounds for the monitor showing the specified |rect|.
- // This function is virtual to support testing environments.
- virtual gfx::Rect GetMonitorBounds(const gfx::Rect& rect);
+ // Returns the available screen bounds if the frame were to show in |rect|.
+ virtual gfx::Rect GetAvailableScreenBounds(const gfx::Rect& rect);
private:
FRIEND_TEST_ALL_PREFIXES(BubbleFrameViewTest, GetBoundsForClientView);
diff --git a/ui/views/bubble/bubble_frame_view_unittest.cc b/ui/views/bubble/bubble_frame_view_unittest.cc
index c733507..ef5d58d 100644
--- a/ui/views/bubble/bubble_frame_view_unittest.cc
+++ b/ui/views/bubble/bubble_frame_view_unittest.cc
@@ -22,18 +22,18 @@ class TestBubbleFrameView : public BubbleFrameView {
public:
TestBubbleFrameView()
: BubbleFrameView(gfx::Insets(kMargin, kMargin, kMargin, kMargin)),
- monitor_bounds_(gfx::Rect(0, 0, 1000, 1000)) {
+ available_bounds_(gfx::Rect(0, 0, 1000, 1000)) {
SetBubbleBorder(new BubbleBorder(kArrow, BubbleBorder::NO_SHADOW, kColor));
}
virtual ~TestBubbleFrameView() {}
// BubbleFrameView overrides:
- virtual gfx::Rect GetMonitorBounds(const gfx::Rect& rect) OVERRIDE {
- return monitor_bounds_;
+ virtual gfx::Rect GetAvailableScreenBounds(const gfx::Rect& rect) OVERRIDE {
+ return available_bounds_;
}
private:
- gfx::Rect monitor_bounds_;
+ gfx::Rect available_bounds_;
DISALLOW_COPY_AND_ASSIGN(TestBubbleFrameView);
};