summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-09 16:08:49 +0000
committerthakis@chromium.org <thakis@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-09 16:08:49 +0000
commit269ab28cc179018f1e050b3d3332c2007c30422f (patch)
treefb08a02d42e41c9a3ad0eea81e73f971177a122a /chrome/browser
parentfd1b644e55267bb83696fb970acb01856f65006c (diff)
downloadchromium_src-269ab28cc179018f1e050b3d3332c2007c30422f.zip
chromium_src-269ab28cc179018f1e050b3d3332c2007c30422f.tar.gz
chromium_src-269ab28cc179018f1e050b3d3332c2007c30422f.tar.bz2
Mac: Let status bubble dodge to the right if necessary.
Windows seems to do this either if a shelf is visible or if the status bubble would slide off screen, so chrome/mac now does that too :-/ Note that the right-aligned bubble overlaps a vertical scrollbar if present. That matches windows. BUG=22198 TEST=See bug. Also test that if both popup block bubble and status bubble are at the right, the status bubble should be on top of the popup block bubble. Review URL: http://codereview.chromium.org/372051 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31428 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/cocoa/status_bubble_mac.mm45
-rw-r--r--chrome/browser/views/status_bubble_views.cc2
2 files changed, 32 insertions, 15 deletions
diff --git a/chrome/browser/cocoa/status_bubble_mac.mm b/chrome/browser/cocoa/status_bubble_mac.mm
index fb954cc..5072cbc 100644
--- a/chrome/browser/cocoa/status_bubble_mac.mm
+++ b/chrome/browser/cocoa/status_bubble_mac.mm
@@ -225,6 +225,8 @@ void StatusBubbleMac::MouseMoved() {
cursor_location.x -= NSMaxX(window_frame);
cursor_location.y -= NSMaxY(window_frame);
+ bool isShelfVisible = [delegate_ verticalOffsetForStatusBubble] > 0;
+
// If the mouse is in a position where we think it would move the
// status bubble, figure out where and how the bubble should be moved.
if (cursor_location.y < kMousePadding &&
@@ -240,22 +242,37 @@ void StatusBubbleMac::MouseMoved() {
offset = offset * ((kMousePadding - cursor_location.x) / kMousePadding);
}
- // Cap the offset and change the visual presentation of the bubble
- // depending on where it ends up (so that rounded corners square off
- // and mate to the edges of the tab content).
- if (offset >= NSHeight(window_frame)) {
- offset = NSHeight(window_frame);
- [[window_ contentView] setCornerFlags:
- kRoundedBottomLeftCorner | kRoundedBottomRightCorner];
- } else if (offset > 0) {
- [[window_ contentView] setCornerFlags:
- kRoundedTopRightCorner | kRoundedBottomLeftCorner |
- kRoundedBottomRightCorner];
- } else {
- [[window_ contentView] setCornerFlags:kRoundedTopRightCorner];
+ bool isOnScreen = true;
+ NSScreen* screen = [window_ screen];
+ if (screen &&
+ NSMinY([screen visibleFrame]) > NSMinY(window_frame) - offset) {
+ isOnScreen = false;
}
- window_frame.origin.y -= offset;
+ if (isOnScreen && !isShelfVisible) {
+ // Cap the offset and change the visual presentation of the bubble
+ // depending on where it ends up (so that rounded corners square off
+ // and mate to the edges of the tab content).
+ if (offset >= NSHeight(window_frame)) {
+ offset = NSHeight(window_frame);
+ [[window_ contentView] setCornerFlags:
+ kRoundedBottomLeftCorner | kRoundedBottomRightCorner];
+ } else if (offset > 0) {
+ [[window_ contentView] setCornerFlags:
+ kRoundedTopRightCorner | kRoundedBottomLeftCorner |
+ kRoundedBottomRightCorner];
+ } else {
+ [[window_ contentView] setCornerFlags:kRoundedTopRightCorner];
+ }
+ window_frame.origin.y -= offset;
+ } else {
+ // The bubble will obscure the download shelf. Move the bubble to the
+ // right and reset Y offset_ to zero.
+ [[window_ contentView] setCornerFlags:kRoundedTopLeftCorner];
+
+ // Subtract border width + bubble width.
+ window_frame.origin.x += NSWidth([parent_ frame]) - NSWidth(window_frame);
+ }
} else {
[[window_ contentView] setCornerFlags:kRoundedTopRightCorner];
}
diff --git a/chrome/browser/views/status_bubble_views.cc b/chrome/browser/views/status_bubble_views.cc
index 935b894..9642294 100644
--- a/chrome/browser/views/status_bubble_views.cc
+++ b/chrome/browser/views/status_bubble_views.cc
@@ -655,7 +655,7 @@ void StatusBubbleViews::AvoidMouse() {
view_->SetStyle(StatusView::STYLE_STANDARD_RIGHT);
offset_ = 0;
- // Substract border width + bubble width.
+ // Subtract border width + bubble width.
int right_position_x = window_width - (position_.x() + size_.width());
popup_->SetBounds(gfx::Rect(top_left.x() + right_position_x,
top_left.y() + position_.y(),