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 "grit/ui_resources.h" | 9 #include "grit/ui_resources.h" |
10 #include "ui/base/hit_test.h" | 10 #include "ui/base/hit_test.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 // Give the contents a margin. | 177 // Give the contents a margin. |
178 client_size.Enlarge(content_margins_.width(), content_margins_.height()); | 178 client_size.Enlarge(content_margins_.width(), content_margins_.height()); |
179 | 179 |
180 const BubbleBorder::ArrowLocation arrow = bubble_border_->arrow_location(); | 180 const BubbleBorder::ArrowLocation arrow = bubble_border_->arrow_location(); |
181 if (adjust_if_offscreen && BubbleBorder::has_arrow(arrow)) { | 181 if (adjust_if_offscreen && BubbleBorder::has_arrow(arrow)) { |
182 if (!bubble_border_->is_arrow_at_center(arrow)) { | 182 if (!bubble_border_->is_arrow_at_center(arrow)) { |
183 // Try to mirror the anchoring if the bubble does not fit on the screen. | 183 // Try to mirror the anchoring if the bubble does not fit on the screen. |
184 MirrorArrowIfOffScreen(true, anchor_rect, client_size); | 184 MirrorArrowIfOffScreen(true, anchor_rect, client_size); |
185 MirrorArrowIfOffScreen(false, anchor_rect, client_size); | 185 MirrorArrowIfOffScreen(false, anchor_rect, client_size); |
186 } else { | 186 } else { |
| 187 // Mirror as needed vertically if the arrow is on a horizontal edge and |
| 188 // vice-versa. |
| 189 MirrorArrowIfOffScreen(BubbleBorder::is_arrow_on_horizontal(arrow), |
| 190 anchor_rect, |
| 191 client_size); |
187 OffsetArrowIfOffScreen(anchor_rect, client_size); | 192 OffsetArrowIfOffScreen(anchor_rect, client_size); |
188 } | 193 } |
189 } | 194 } |
190 | 195 |
191 // Calculate the bounds with the arrow in its updated location and offset. | 196 // Calculate the bounds with the arrow in its updated location and offset. |
192 return bubble_border_->GetBounds(anchor_rect, client_size); | 197 return bubble_border_->GetBounds(anchor_rect, client_size); |
193 } | 198 } |
194 | 199 |
195 gfx::Rect BubbleFrameView::GetMonitorBounds(const gfx::Rect& rect) { | 200 gfx::Rect BubbleFrameView::GetMonitorBounds(const gfx::Rect& rect) { |
196 // TODO(scottmg): Native is wrong. http://crbug.com/133312 | 201 // TODO(scottmg): Native is wrong. http://crbug.com/133312 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 // |offscreen_adjust|, e.g. positive |offscreen_adjust| means bubble | 259 // |offscreen_adjust|, e.g. positive |offscreen_adjust| means bubble |
255 // window needs to be moved to the right and that means we need to move arrow | 260 // window needs to be moved to the right and that means we need to move arrow |
256 // to the left, and that means negative offset. | 261 // to the left, and that means negative offset. |
257 bubble_border_->set_arrow_offset( | 262 bubble_border_->set_arrow_offset( |
258 bubble_border_->GetArrowOffset(window_bounds.size()) - offscreen_adjust); | 263 bubble_border_->GetArrowOffset(window_bounds.size()) - offscreen_adjust); |
259 if (offscreen_adjust) | 264 if (offscreen_adjust) |
260 SchedulePaint(); | 265 SchedulePaint(); |
261 } | 266 } |
262 | 267 |
263 } // namespace views | 268 } // namespace views |
OLD | NEW |