OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/views/bubble/bubble_frame_view.h" | 5 #include "ui/views/bubble/bubble_frame_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ui/gfx/screen.h" | 9 #include "ui/gfx/screen.h" |
10 #include "ui/views/bubble/bubble_border.h" | 10 #include "ui/views/bubble/bubble_border.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 | 95 |
96 void BubbleFrameView::SetBubbleBorder(BubbleBorder* border) { | 96 void BubbleFrameView::SetBubbleBorder(BubbleBorder* border) { |
97 bubble_border_ = border; | 97 bubble_border_ = border; |
98 set_border(bubble_border_); | 98 set_border(bubble_border_); |
99 | 99 |
100 // Update the background, which relies on the border. | 100 // Update the background, which relies on the border. |
101 set_background(new views::BubbleBackground(border)); | 101 set_background(new views::BubbleBackground(border)); |
102 } | 102 } |
103 | 103 |
104 gfx::Rect BubbleFrameView::GetMonitorBounds(const gfx::Rect& rect) { | 104 gfx::Rect BubbleFrameView::GetMonitorBounds(const gfx::Rect& rect) { |
105 return gfx::Screen::GetDisplayNearestPoint(rect.CenterPoint()).work_area(); | 105 // TODO(scottmg): Native is wrong. http://crbug.com/133312 |
| 106 return gfx::Screen::GetNativeScreen()->GetDisplayNearestPoint( |
| 107 rect.CenterPoint()).work_area(); |
106 } | 108 } |
107 | 109 |
108 void BubbleFrameView::MirrorArrowIfOffScreen( | 110 void BubbleFrameView::MirrorArrowIfOffScreen( |
109 bool vertical, | 111 bool vertical, |
110 const gfx::Rect& anchor_rect, | 112 const gfx::Rect& anchor_rect, |
111 const gfx::Size& client_size) { | 113 const gfx::Size& client_size) { |
112 // Check if the bounds don't fit on screen. | 114 // Check if the bounds don't fit on screen. |
113 gfx::Rect monitor_rect(GetMonitorBounds(anchor_rect)); | 115 gfx::Rect monitor_rect(GetMonitorBounds(anchor_rect)); |
114 gfx::Rect window_bounds(bubble_border_->GetBounds(anchor_rect, client_size)); | 116 gfx::Rect window_bounds(bubble_border_->GetBounds(anchor_rect, client_size)); |
115 if (GetOffScreenLength(monitor_rect, window_bounds, vertical) > 0) { | 117 if (GetOffScreenLength(monitor_rect, window_bounds, vertical) > 0) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 // |offscreen_adjust|, e.g. positive |offscreen_adjust| means bubble | 163 // |offscreen_adjust|, e.g. positive |offscreen_adjust| means bubble |
162 // window needs to be moved to the right and that means we need to move arrow | 164 // window needs to be moved to the right and that means we need to move arrow |
163 // to the left, and that means negative offset. | 165 // to the left, and that means negative offset. |
164 bubble_border_->set_arrow_offset( | 166 bubble_border_->set_arrow_offset( |
165 bubble_border_->GetArrowOffset(window_bounds.size()) - offscreen_adjust); | 167 bubble_border_->GetArrowOffset(window_bounds.size()) - offscreen_adjust); |
166 if (offscreen_adjust) | 168 if (offscreen_adjust) |
167 SchedulePaint(); | 169 SchedulePaint(); |
168 } | 170 } |
169 | 171 |
170 } // namespace views | 172 } // namespace views |
OLD | NEW |