Chromium Code Reviews| 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, client_size); | |
|
msw
2013/03/14 20:59:44
nit: indent to match the open paren above.
varunjain
2013/03/14 21:15:08
Done.
| |
| 187 OffsetArrowIfOffScreen(anchor_rect, client_size); | 191 OffsetArrowIfOffScreen(anchor_rect, client_size); |
| 188 } | 192 } |
| 189 } | 193 } |
| 190 | 194 |
| 191 // Calculate the bounds with the arrow in its updated location and offset. | 195 // Calculate the bounds with the arrow in its updated location and offset. |
| 192 return bubble_border_->GetBounds(anchor_rect, client_size); | 196 return bubble_border_->GetBounds(anchor_rect, client_size); |
| 193 } | 197 } |
| 194 | 198 |
| 195 gfx::Rect BubbleFrameView::GetMonitorBounds(const gfx::Rect& rect) { | 199 gfx::Rect BubbleFrameView::GetMonitorBounds(const gfx::Rect& rect) { |
| 196 // TODO(scottmg): Native is wrong. http://crbug.com/133312 | 200 // 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 | 258 // |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 | 259 // 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. | 260 // to the left, and that means negative offset. |
| 257 bubble_border_->set_arrow_offset( | 261 bubble_border_->set_arrow_offset( |
| 258 bubble_border_->GetArrowOffset(window_bounds.size()) - offscreen_adjust); | 262 bubble_border_->GetArrowOffset(window_bounds.size()) - offscreen_adjust); |
| 259 if (offscreen_adjust) | 263 if (offscreen_adjust) |
| 260 SchedulePaint(); | 264 SchedulePaint(); |
| 261 } | 265 } |
| 262 | 266 |
| 263 } // namespace views | 267 } // namespace views |
| OLD | NEW |