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 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. | 5 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. |
6 | 6 |
7 #include "ui/views/view.h" | 7 #include "ui/views/view.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "ui/gfx/scoped_canvas.h" | 31 #include "ui/gfx/scoped_canvas.h" |
32 #include "ui/gfx/screen.h" | 32 #include "ui/gfx/screen.h" |
33 #include "ui/gfx/skia_util.h" | 33 #include "ui/gfx/skia_util.h" |
34 #include "ui/gfx/transform.h" | 34 #include "ui/gfx/transform.h" |
35 #include "ui/native_theme/native_theme.h" | 35 #include "ui/native_theme/native_theme.h" |
36 #include "ui/views/accessibility/native_view_accessibility.h" | 36 #include "ui/views/accessibility/native_view_accessibility.h" |
37 #include "ui/views/background.h" | 37 #include "ui/views/background.h" |
38 #include "ui/views/context_menu_controller.h" | 38 #include "ui/views/context_menu_controller.h" |
39 #include "ui/views/drag_controller.h" | 39 #include "ui/views/drag_controller.h" |
40 #include "ui/views/layout/layout_manager.h" | 40 #include "ui/views/layout/layout_manager.h" |
| 41 #include "ui/views/rect_based_targeting_utils.h" |
41 #include "ui/views/views_delegate.h" | 42 #include "ui/views/views_delegate.h" |
42 #include "ui/views/widget/native_widget_private.h" | 43 #include "ui/views/widget/native_widget_private.h" |
43 #include "ui/views/widget/root_view.h" | 44 #include "ui/views/widget/root_view.h" |
44 #include "ui/views/widget/tooltip_manager.h" | 45 #include "ui/views/widget/tooltip_manager.h" |
45 #include "ui/views/widget/widget.h" | 46 #include "ui/views/widget/widget.h" |
46 | 47 |
47 #if defined(USE_AURA) | 48 #if defined(USE_AURA) |
48 #include "ui/base/cursor/cursor.h" | 49 #include "ui/base/cursor/cursor.h" |
49 #endif | 50 #endif |
50 | 51 |
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
885 } | 886 } |
886 | 887 |
887 bool View::HitTestPoint(const gfx::Point& point) const { | 888 bool View::HitTestPoint(const gfx::Point& point) const { |
888 return HitTestRect(gfx::Rect(point, gfx::Size(1, 1))); | 889 return HitTestRect(gfx::Rect(point, gfx::Size(1, 1))); |
889 } | 890 } |
890 | 891 |
891 bool View::HitTestRect(const gfx::Rect& rect) const { | 892 bool View::HitTestRect(const gfx::Rect& rect) const { |
892 if (GetLocalBounds().Intersects(rect)) { | 893 if (GetLocalBounds().Intersects(rect)) { |
893 if (HasHitTestMask()) { | 894 if (HasHitTestMask()) { |
894 gfx::Path mask; | 895 gfx::Path mask; |
895 GetHitTestMask(&mask); | 896 HitTestSource source = HIT_TEST_SOURCE_MOUSE; |
| 897 if (!views::UsePointBasedTargeting(rect)) |
| 898 source = HIT_TEST_SOURCE_TOUCH; |
| 899 GetHitTestMask(source, &mask); |
896 #if defined(USE_AURA) | 900 #if defined(USE_AURA) |
897 // TODO: should we use this every where? | 901 // TODO: should we use this every where? |
898 SkRegion clip_region; | 902 SkRegion clip_region; |
899 clip_region.setRect(0, 0, width(), height()); | 903 clip_region.setRect(0, 0, width(), height()); |
900 SkRegion mask_region; | 904 SkRegion mask_region; |
901 return mask_region.setPath(mask, clip_region) && | 905 return mask_region.setPath(mask, clip_region) && |
902 mask_region.intersects(RectToSkIRect(rect)); | 906 mask_region.intersects(RectToSkIRect(rect)); |
903 #elif defined(OS_WIN) | 907 #elif defined(OS_WIN) |
904 base::win::ScopedRegion rgn(mask.CreateNativeRegion()); | 908 base::win::ScopedRegion rgn(mask.CreateNativeRegion()); |
905 const RECT r(rect.ToRECT()); | 909 const RECT r(rect.ToRECT()); |
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1494 } | 1498 } |
1495 } | 1499 } |
1496 } | 1500 } |
1497 | 1501 |
1498 // Input ----------------------------------------------------------------------- | 1502 // Input ----------------------------------------------------------------------- |
1499 | 1503 |
1500 bool View::HasHitTestMask() const { | 1504 bool View::HasHitTestMask() const { |
1501 return false; | 1505 return false; |
1502 } | 1506 } |
1503 | 1507 |
1504 void View::GetHitTestMask(gfx::Path* mask) const { | 1508 void View::GetHitTestMask(HitTestSource source, gfx::Path* mask) const { |
1505 DCHECK(mask); | 1509 DCHECK(mask); |
1506 } | 1510 } |
1507 | 1511 |
1508 View::DragInfo* View::GetDragInfo() { | 1512 View::DragInfo* View::GetDragInfo() { |
1509 return parent_ ? parent_->GetDragInfo() : NULL; | 1513 return parent_ ? parent_->GetDragInfo() : NULL; |
1510 } | 1514 } |
1511 | 1515 |
1512 // Focus ----------------------------------------------------------------------- | 1516 // Focus ----------------------------------------------------------------------- |
1513 | 1517 |
1514 void View::OnFocus() { | 1518 void View::OnFocus() { |
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2323 // Message the RootView to do the drag and drop. That way if we're removed | 2327 // Message the RootView to do the drag and drop. That way if we're removed |
2324 // the RootView can detect it and avoid calling us back. | 2328 // the RootView can detect it and avoid calling us back. |
2325 gfx::Point widget_location(event.location()); | 2329 gfx::Point widget_location(event.location()); |
2326 ConvertPointToWidget(this, &widget_location); | 2330 ConvertPointToWidget(this, &widget_location); |
2327 widget->RunShellDrag(this, data, widget_location, drag_operations, source); | 2331 widget->RunShellDrag(this, data, widget_location, drag_operations, source); |
2328 // WARNING: we may have been deleted. | 2332 // WARNING: we may have been deleted. |
2329 return true; | 2333 return true; |
2330 } | 2334 } |
2331 | 2335 |
2332 } // namespace views | 2336 } // namespace views |
OLD | NEW |