summaryrefslogtreecommitdiffstats
path: root/ash
diff options
context:
space:
mode:
authorbruthig@chromium.org <bruthig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-17 16:19:19 +0000
committerbruthig@chromium.org <bruthig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-17 16:19:19 +0000
commit43efc0f67e6a1750d4e7eb1e9782034c23af6d4f (patch)
treeaa4253e26c62b270bf7196cf3152d1832086d91f /ash
parent5f47741ca59cc428a28612316ddca2d831ebcc3f (diff)
downloadchromium_src-43efc0f67e6a1750d4e7eb1e9782034c23af6d4f.zip
chromium_src-43efc0f67e6a1750d4e7eb1e9782034c23af6d4f.tar.gz
chromium_src-43efc0f67e6a1750d4e7eb1e9782034c23af6d4f.tar.bz2
Fixed TrayBackgroundView::GetBubbleAnchorRect to handle left/right alignment when the tray isn't visible.
BUG=392473 Review URL: https://codereview.chromium.org/391213002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283790 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r--ash/system/tray/tray_background_view.cc53
1 files changed, 42 insertions, 11 deletions
diff --git a/ash/system/tray/tray_background_view.cc b/ash/system/tray/tray_background_view.cc
index bcf04a2..f4b75bc 100644
--- a/ash/system/tray/tray_background_view.cc
+++ b/ash/system/tray/tray_background_view.cc
@@ -548,9 +548,13 @@ gfx::Rect TrayBackgroundView::GetBubbleAnchorRect(
} else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_LEFT) {
rect.Inset(0, 0, kBubblePaddingVerticalSide + 4,
kBubblePaddingVerticalBottom);
- } else {
+ } else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT) {
rect.Inset(kBubblePaddingVerticalSide, 0, 0,
kBubblePaddingVerticalBottom);
+ } else {
+ // TODO(bruthig) May need to handle other ANCHOR_ALIGNMENT_ values.
+ // ie. ANCHOR_ALIGNMENT_TOP
+ DCHECK(false) << "Unhandled anchor alignment.";
}
} else if (anchor_type == TrayBubbleView::ANCHOR_TYPE_BUBBLE) {
// Invert the offsets to align with the bubble below.
@@ -562,21 +566,48 @@ gfx::Rect TrayBackgroundView::GetBubbleAnchorRect(
rect.Inset(vertical_alignment, 0, 0, horizontal_alignment);
else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT)
rect.Inset(0, 0, vertical_alignment, horizontal_alignment);
+ } else {
+ DCHECK(false) << "Unhandled anchor type.";
}
- }
-
- // TODO(jennyz): May need to add left/right alignment in the following code.
- if (rect.IsEmpty()) {
+ } else {
aura::Window* target_root = anchor_widget ?
anchor_widget->GetNativeView()->GetRootWindow() :
Shell::GetPrimaryRootWindow();
rect = target_root->bounds();
- rect = gfx::Rect(
- base::i18n::IsRTL() ? kPaddingFromRightEdgeOfScreenBottomAlignment :
- rect.width() - kPaddingFromRightEdgeOfScreenBottomAlignment,
- rect.height() - kPaddingFromBottomOfScreenBottomAlignment,
- 0, 0);
- rect = ScreenUtil::ConvertRectToScreen(target_root, rect);
+ if (anchor_type == TrayBubbleView::ANCHOR_TYPE_TRAY) {
+ if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_BOTTOM) {
+ rect = gfx::Rect(
+ base::i18n::IsRTL() ?
+ kPaddingFromRightEdgeOfScreenBottomAlignment :
+ rect.width() - kPaddingFromRightEdgeOfScreenBottomAlignment,
+ rect.height() - kPaddingFromBottomOfScreenBottomAlignment,
+ 0, 0);
+ rect = ScreenUtil::ConvertRectToScreen(target_root, rect);
+ } else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_LEFT) {
+ rect = gfx::Rect(
+ kPaddingFromRightEdgeOfScreenBottomAlignment,
+ rect.height() - kPaddingFromBottomOfScreenBottomAlignment,
+ 1, 1);
+ rect = ScreenUtil::ConvertRectToScreen(target_root, rect);
+ } else if (anchor_alignment == TrayBubbleView::ANCHOR_ALIGNMENT_RIGHT) {
+ rect = gfx::Rect(
+ rect.width() - kPaddingFromRightEdgeOfScreenBottomAlignment,
+ rect.height() - kPaddingFromBottomOfScreenBottomAlignment,
+ 1, 1);
+ rect = ScreenUtil::ConvertRectToScreen(target_root, rect);
+ } else {
+ // TODO(bruthig) May need to handle other ANCHOR_ALIGNMENT_ values.
+ // ie. ANCHOR_ALIGNMENT_TOP
+ DCHECK(false) << "Unhandled anchor alignment.";
+ }
+ } else {
+ rect = gfx::Rect(
+ base::i18n::IsRTL() ?
+ kPaddingFromRightEdgeOfScreenBottomAlignment :
+ rect.width() - kPaddingFromRightEdgeOfScreenBottomAlignment,
+ rect.height() - kPaddingFromBottomOfScreenBottomAlignment,
+ 0, 0);
+ }
}
return rect;
}