Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1825)

Unified Diff: ash/system/tray/tray_background_view.cc

Issue 391213002: Fixed TrayBackgroundView::GetBubbleAnchorRect to handle left/right alignment when the tray isn't vi… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added handling for failing test use case. Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/tray/tray_background_view.cc
diff --git a/ash/system/tray/tray_background_view.cc b/ash/system/tray/tray_background_view.cc
index bcf04a21497db735bfda5c6238d1731b0a9382be..f4b75bc4e46fd0a6aa3e039196f203d96dc0a8e4 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;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698