| 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/view.h" | 5 #include "ui/views/view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "third_party/skia/include/core/SkRect.h" | 15 #include "third_party/skia/include/core/SkRect.h" |
| 16 #include "ui/base/accessibility/accessibility_types.h" | 16 #include "ui/base/accessibility/accessibility_types.h" |
| 17 #include "ui/base/dragdrop/drag_drop_types.h" | 17 #include "ui/base/dragdrop/drag_drop_types.h" |
| 18 #include "ui/base/native_theme/native_theme.h" | 18 #include "ui/base/native_theme/native_theme.h" |
| 19 #include "ui/compositor/compositor.h" | 19 #include "ui/compositor/compositor.h" |
| 20 #include "ui/compositor/layer.h" | 20 #include "ui/compositor/layer.h" |
| 21 #include "ui/compositor/layer_animator.h" | 21 #include "ui/compositor/layer_animator.h" |
| 22 #include "ui/gfx/canvas.h" | 22 #include "ui/gfx/canvas.h" |
| 23 #include "ui/gfx/interpolated_transform.h" | 23 #include "ui/gfx/interpolated_transform.h" |
| 24 #include "ui/gfx/path.h" | 24 #include "ui/gfx/path.h" |
| 25 #include "ui/gfx/point_conversions.h" | 25 #include "ui/gfx/point_conversions.h" |
| 26 #include "ui/gfx/point3_f.h" | 26 #include "ui/gfx/point3_f.h" |
| 27 #include "ui/gfx/rect_conversions.h" |
| 27 #include "ui/gfx/skia_util.h" | 28 #include "ui/gfx/skia_util.h" |
| 28 #include "ui/gfx/transform.h" | 29 #include "ui/gfx/transform.h" |
| 29 #include "ui/views/background.h" | 30 #include "ui/views/background.h" |
| 30 #include "ui/views/context_menu_controller.h" | 31 #include "ui/views/context_menu_controller.h" |
| 31 #include "ui/views/drag_controller.h" | 32 #include "ui/views/drag_controller.h" |
| 32 #include "ui/views/layout/layout_manager.h" | 33 #include "ui/views/layout/layout_manager.h" |
| 33 #include "ui/views/views_delegate.h" | 34 #include "ui/views/views_delegate.h" |
| 34 #include "ui/views/widget/native_widget_private.h" | 35 #include "ui/views/widget/native_widget_private.h" |
| 35 #include "ui/views/widget/root_view.h" | 36 #include "ui/views/widget/root_view.h" |
| 36 #include "ui/views/widget/tooltip_manager.h" | 37 #include "ui/views/widget/tooltip_manager.h" |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 vis_bounds.Intersect(ancestor_bounds); | 348 vis_bounds.Intersect(ancestor_bounds); |
| 348 } else if (!view->GetWidget()) { | 349 } else if (!view->GetWidget()) { |
| 349 // If the view has no Widget, we're not visible. Return an empty rect. | 350 // If the view has no Widget, we're not visible. Return an empty rect. |
| 350 return gfx::Rect(); | 351 return gfx::Rect(); |
| 351 } | 352 } |
| 352 view = ancestor; | 353 view = ancestor; |
| 353 } | 354 } |
| 354 if (vis_bounds.IsEmpty()) | 355 if (vis_bounds.IsEmpty()) |
| 355 return vis_bounds; | 356 return vis_bounds; |
| 356 // Convert back to this views coordinate system. | 357 // Convert back to this views coordinate system. |
| 357 transform.TransformRectReverse(&vis_bounds); | 358 gfx::RectF views_vis_bounds(vis_bounds); |
| 358 return vis_bounds; | 359 transform.TransformRectReverse(&views_vis_bounds); |
| 360 // Partially visible pixels should be considered visible. |
| 361 return gfx::ToEnclosingRect(views_vis_bounds); |
| 359 } | 362 } |
| 360 | 363 |
| 361 gfx::Rect View::GetBoundsInScreen() const { | 364 gfx::Rect View::GetBoundsInScreen() const { |
| 362 gfx::Point origin; | 365 gfx::Point origin; |
| 363 View::ConvertPointToScreen(this, &origin); | 366 View::ConvertPointToScreen(this, &origin); |
| 364 return gfx::Rect(origin, size()); | 367 return gfx::Rect(origin, size()); |
| 365 } | 368 } |
| 366 | 369 |
| 367 gfx::Size View::GetPreferredSize() { | 370 gfx::Size View::GetPreferredSize() { |
| 368 if (layout_manager_.get()) | 371 if (layout_manager_.get()) |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 DCHECK(p); | 673 DCHECK(p); |
| 671 | 674 |
| 672 const views::Widget* widget = dst->GetWidget(); | 675 const views::Widget* widget = dst->GetWidget(); |
| 673 if (!widget) | 676 if (!widget) |
| 674 return; | 677 return; |
| 675 *p -= widget->GetClientAreaBoundsInScreen().OffsetFromOrigin(); | 678 *p -= widget->GetClientAreaBoundsInScreen().OffsetFromOrigin(); |
| 676 views::View::ConvertPointFromWidget(dst, p); | 679 views::View::ConvertPointFromWidget(dst, p); |
| 677 } | 680 } |
| 678 | 681 |
| 679 gfx::Rect View::ConvertRectToParent(const gfx::Rect& rect) const { | 682 gfx::Rect View::ConvertRectToParent(const gfx::Rect& rect) const { |
| 680 gfx::Rect x_rect = rect; | 683 gfx::RectF x_rect = rect; |
| 681 GetTransform().TransformRect(&x_rect); | 684 GetTransform().TransformRect(&x_rect); |
| 682 x_rect.Offset(GetMirroredPosition().OffsetFromOrigin()); | 685 x_rect.Offset(GetMirroredPosition().OffsetFromOrigin()); |
| 683 return x_rect; | 686 // Pixels we partially occupy in the parent should be included. |
| 687 return gfx::ToEnclosingRect(x_rect); |
| 684 } | 688 } |
| 685 | 689 |
| 686 gfx::Rect View::ConvertRectToWidget(const gfx::Rect& rect) const { | 690 gfx::Rect View::ConvertRectToWidget(const gfx::Rect& rect) const { |
| 687 gfx::Rect x_rect = rect; | 691 gfx::Rect x_rect = rect; |
| 688 for (const View* v = this; v; v = v->parent_) | 692 for (const View* v = this; v; v = v->parent_) |
| 689 x_rect = v->ConvertRectToParent(x_rect); | 693 x_rect = v->ConvertRectToParent(x_rect); |
| 690 return x_rect; | 694 return x_rect; |
| 691 } | 695 } |
| 692 | 696 |
| 693 // Painting -------------------------------------------------------------------- | 697 // Painting -------------------------------------------------------------------- |
| (...skipping 1464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2158 ConvertPointToWidget(this, &widget_location); | 2162 ConvertPointToWidget(this, &widget_location); |
| 2159 GetWidget()->RunShellDrag(this, data, widget_location, drag_operations, | 2163 GetWidget()->RunShellDrag(this, data, widget_location, drag_operations, |
| 2160 source); | 2164 source); |
| 2161 return true; | 2165 return true; |
| 2162 #else | 2166 #else |
| 2163 return false; | 2167 return false; |
| 2164 #endif // !defined(OS_MACOSX) | 2168 #endif // !defined(OS_MACOSX) |
| 2165 } | 2169 } |
| 2166 | 2170 |
| 2167 } // namespace views | 2171 } // namespace views |
| OLD | NEW |