| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_targeter.h" | 5 #include "ui/views/view_targeter.h" |
| 6 | 6 |
| 7 #include "ui/events/event_targeter.h" | 7 #include "ui/events/event_targeter.h" |
| 8 #include "ui/events/event_utils.h" | 8 #include "ui/events/event_utils.h" |
| 9 #include "ui/gfx/path.h" | 9 #include "ui/gfx/path.h" |
| 10 #include "ui/views/masked_targeter_delegate.h" | 10 #include "ui/views/masked_targeter_delegate.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 void set_can_process_events_within_subtree(bool can_process) { | 27 void set_can_process_events_within_subtree(bool can_process) { |
| 28 can_process_events_within_subtree_ = can_process; | 28 can_process_events_within_subtree_ = can_process; |
| 29 } | 29 } |
| 30 | 30 |
| 31 // A call-through function to ViewTargeterDelegate::DoesIntersectRect(). | 31 // A call-through function to ViewTargeterDelegate::DoesIntersectRect(). |
| 32 bool TestDoesIntersectRect(const View* target, const gfx::Rect& rect) const { | 32 bool TestDoesIntersectRect(const View* target, const gfx::Rect& rect) const { |
| 33 return DoesIntersectRect(target, rect); | 33 return DoesIntersectRect(target, rect); |
| 34 } | 34 } |
| 35 | 35 |
| 36 // View: | 36 // View: |
| 37 virtual bool CanProcessEventsWithinSubtree() const OVERRIDE { | 37 virtual bool CanProcessEventsWithinSubtree() const override { |
| 38 return can_process_events_within_subtree_; | 38 return can_process_events_within_subtree_; |
| 39 } | 39 } |
| 40 | 40 |
| 41 private: | 41 private: |
| 42 // Value to return from CanProcessEventsWithinSubtree(). | 42 // Value to return from CanProcessEventsWithinSubtree(). |
| 43 bool can_process_events_within_subtree_; | 43 bool can_process_events_within_subtree_; |
| 44 | 44 |
| 45 DISALLOW_COPY_AND_ASSIGN(TestingView); | 45 DISALLOW_COPY_AND_ASSIGN(TestingView); |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 // A derived class of View having a triangular-shaped hit test mask. | 48 // A derived class of View having a triangular-shaped hit test mask. |
| 49 class TestMaskedView : public View, public MaskedTargeterDelegate { | 49 class TestMaskedView : public View, public MaskedTargeterDelegate { |
| 50 public: | 50 public: |
| 51 TestMaskedView() {} | 51 TestMaskedView() {} |
| 52 virtual ~TestMaskedView() {} | 52 virtual ~TestMaskedView() {} |
| 53 | 53 |
| 54 // A call-through function to MaskedTargeterDelegate::DoesIntersectRect(). | 54 // A call-through function to MaskedTargeterDelegate::DoesIntersectRect(). |
| 55 bool TestDoesIntersectRect(const View* target, const gfx::Rect& rect) const { | 55 bool TestDoesIntersectRect(const View* target, const gfx::Rect& rect) const { |
| 56 return DoesIntersectRect(target, rect); | 56 return DoesIntersectRect(target, rect); |
| 57 } | 57 } |
| 58 | 58 |
| 59 private: | 59 private: |
| 60 // MaskedTargeterDelegate: | 60 // MaskedTargeterDelegate: |
| 61 virtual bool GetHitTestMask(gfx::Path* mask) const OVERRIDE { | 61 virtual bool GetHitTestMask(gfx::Path* mask) const override { |
| 62 DCHECK(mask); | 62 DCHECK(mask); |
| 63 SkScalar w = SkIntToScalar(width()); | 63 SkScalar w = SkIntToScalar(width()); |
| 64 SkScalar h = SkIntToScalar(height()); | 64 SkScalar h = SkIntToScalar(height()); |
| 65 | 65 |
| 66 // Create a triangular mask within the bounds of this View. | 66 // Create a triangular mask within the bounds of this View. |
| 67 mask->moveTo(w / 2, 0); | 67 mask->moveTo(w / 2, 0); |
| 68 mask->lineTo(w, h); | 68 mask->lineTo(w, h); |
| 69 mask->lineTo(0, h); | 69 mask->lineTo(0, h); |
| 70 mask->close(); | 70 mask->close(); |
| 71 return true; | 71 return true; |
| (...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 EXPECT_EQ(v1, root_view->GetTooltipHandlerForPoint(v1_origin)); | 664 EXPECT_EQ(v1, root_view->GetTooltipHandlerForPoint(v1_origin)); |
| 665 EXPECT_EQ(root_view, root_view->GetTooltipHandlerForPoint(v2_origin)); | 665 EXPECT_EQ(root_view, root_view->GetTooltipHandlerForPoint(v2_origin)); |
| 666 | 666 |
| 667 EXPECT_FALSE(v1->GetTooltipHandlerForPoint(v2_origin)); | 667 EXPECT_FALSE(v1->GetTooltipHandlerForPoint(v2_origin)); |
| 668 | 668 |
| 669 widget->CloseNow(); | 669 widget->CloseNow(); |
| 670 } | 670 } |
| 671 | 671 |
| 672 } // namespace test | 672 } // namespace test |
| 673 } // namespace views | 673 } // namespace views |
| OLD | NEW |