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 24 matching lines...) Expand all Loading... | |
35 #include "ui/gfx/transform.h" | 35 #include "ui/gfx/transform.h" |
36 #include "ui/native_theme/native_theme.h" | 36 #include "ui/native_theme/native_theme.h" |
37 #include "ui/views/accessibility/native_view_accessibility.h" | 37 #include "ui/views/accessibility/native_view_accessibility.h" |
38 #include "ui/views/background.h" | 38 #include "ui/views/background.h" |
39 #include "ui/views/border.h" | 39 #include "ui/views/border.h" |
40 #include "ui/views/context_menu_controller.h" | 40 #include "ui/views/context_menu_controller.h" |
41 #include "ui/views/drag_controller.h" | 41 #include "ui/views/drag_controller.h" |
42 #include "ui/views/layout/layout_manager.h" | 42 #include "ui/views/layout/layout_manager.h" |
43 #include "ui/views/rect_based_targeting_utils.h" | 43 #include "ui/views/rect_based_targeting_utils.h" |
44 #include "ui/views/views_delegate.h" | 44 #include "ui/views/views_delegate.h" |
45 #include "ui/views/views_switches.h" | |
45 #include "ui/views/widget/native_widget_private.h" | 46 #include "ui/views/widget/native_widget_private.h" |
46 #include "ui/views/widget/root_view.h" | 47 #include "ui/views/widget/root_view.h" |
47 #include "ui/views/widget/tooltip_manager.h" | 48 #include "ui/views/widget/tooltip_manager.h" |
48 #include "ui/views/widget/widget.h" | 49 #include "ui/views/widget/widget.h" |
49 | 50 |
50 #if defined(USE_AURA) | 51 #if defined(USE_AURA) |
51 #include "ui/base/cursor/cursor.h" | 52 #include "ui/base/cursor/cursor.h" |
52 #endif | 53 #endif |
53 | 54 |
54 #if defined(OS_WIN) | 55 #if defined(OS_WIN) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 | 91 |
91 namespace internal { | 92 namespace internal { |
92 | 93 |
93 // This event handler receives events in the post-target phase and takes care of | 94 // This event handler receives events in the post-target phase and takes care of |
94 // the following: | 95 // the following: |
95 // - Generates context menu, or initiates drag-and-drop, from gesture events. | 96 // - Generates context menu, or initiates drag-and-drop, from gesture events. |
96 class PostEventDispatchHandler : public ui::EventHandler { | 97 class PostEventDispatchHandler : public ui::EventHandler { |
97 public: | 98 public: |
98 explicit PostEventDispatchHandler(View* owner) | 99 explicit PostEventDispatchHandler(View* owner) |
99 : owner_(owner), | 100 : owner_(owner), |
100 touch_dnd_enabled_(switches::IsTouchDragDropEnabled()) { | 101 touch_dnd_enabled_(::switches::IsTouchDragDropEnabled()) { |
101 } | 102 } |
102 virtual ~PostEventDispatchHandler() {} | 103 virtual ~PostEventDispatchHandler() {} |
103 | 104 |
104 private: | 105 private: |
105 // Overridden from ui::EventHandler: | 106 // Overridden from ui::EventHandler: |
106 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { | 107 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { |
107 DCHECK_EQ(ui::EP_POSTTARGET, event->phase()); | 108 DCHECK_EQ(ui::EP_POSTTARGET, event->phase()); |
108 if (event->handled()) | 109 if (event->handled()) |
109 return; | 110 return; |
110 | 111 |
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
942 return gfx::kNullCursor; | 943 return gfx::kNullCursor; |
943 #endif | 944 #endif |
944 } | 945 } |
945 | 946 |
946 bool View::HitTestPoint(const gfx::Point& point) const { | 947 bool View::HitTestPoint(const gfx::Point& point) const { |
947 return HitTestRect(gfx::Rect(point, gfx::Size(1, 1))); | 948 return HitTestRect(gfx::Rect(point, gfx::Size(1, 1))); |
948 } | 949 } |
949 | 950 |
950 bool View::HitTestRect(const gfx::Rect& rect) const { | 951 bool View::HitTestRect(const gfx::Rect& rect) const { |
951 if (GetLocalBounds().Intersects(rect)) { | 952 if (GetLocalBounds().Intersects(rect)) { |
952 if (HasHitTestMask()) { | 953 if (views::switches::IsRectBasedTargetingEnabled() && HasHitTestMask()) { |
sadrul
2014/01/23 00:40:42
Does this break hit-testing along the slanted edge
msw
2014/01/23 00:54:32
Hmm, yeah. Adjacent tabs obscure the right half of
| |
953 gfx::Path mask; | 954 gfx::Path mask; |
954 HitTestSource source = HIT_TEST_SOURCE_MOUSE; | 955 HitTestSource source = HIT_TEST_SOURCE_MOUSE; |
955 if (!views::UsePointBasedTargeting(rect)) | 956 if (!views::UsePointBasedTargeting(rect)) |
956 source = HIT_TEST_SOURCE_TOUCH; | 957 source = HIT_TEST_SOURCE_TOUCH; |
957 GetHitTestMask(source, &mask); | 958 GetHitTestMask(source, &mask); |
958 #if defined(USE_AURA) | 959 #if defined(USE_AURA) |
959 // TODO: should we use this every where? | 960 // TODO: should we use this every where? |
960 SkRegion clip_region; | 961 SkRegion clip_region; |
961 clip_region.setRect(0, 0, width(), height()); | 962 clip_region.setRect(0, 0, width(), height()); |
962 SkRegion mask_region; | 963 SkRegion mask_region; |
(...skipping 1424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2387 // Message the RootView to do the drag and drop. That way if we're removed | 2388 // Message the RootView to do the drag and drop. That way if we're removed |
2388 // the RootView can detect it and avoid calling us back. | 2389 // the RootView can detect it and avoid calling us back. |
2389 gfx::Point widget_location(event.location()); | 2390 gfx::Point widget_location(event.location()); |
2390 ConvertPointToWidget(this, &widget_location); | 2391 ConvertPointToWidget(this, &widget_location); |
2391 widget->RunShellDrag(this, data, widget_location, drag_operations, source); | 2392 widget->RunShellDrag(this, data, widget_location, drag_operations, source); |
2392 // WARNING: we may have been deleted. | 2393 // WARNING: we may have been deleted. |
2393 return true; | 2394 return true; |
2394 } | 2395 } |
2395 | 2396 |
2396 } // namespace views | 2397 } // namespace views |
OLD | NEW |