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 "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/memory/ptr_util.h" |
8 #include "ui/events/event_targeter.h" | 9 #include "ui/events/event_targeter.h" |
9 #include "ui/events/event_utils.h" | 10 #include "ui/events/event_utils.h" |
10 #include "ui/gfx/path.h" | 11 #include "ui/gfx/path.h" |
11 #include "ui/views/masked_targeter_delegate.h" | 12 #include "ui/views/masked_targeter_delegate.h" |
12 #include "ui/views/test/views_test_base.h" | 13 #include "ui/views/test/views_test_base.h" |
13 #include "ui/views/view_targeter.h" | 14 #include "ui/views/view_targeter.h" |
14 #include "ui/views/view_targeter_delegate.h" | 15 #include "ui/views/view_targeter_delegate.h" |
15 #include "ui/views/views_switches.h" | 16 #include "ui/views/views_switches.h" |
16 #include "ui/views/widget/root_view.h" | 17 #include "ui/views/widget/root_view.h" |
17 | 18 |
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 v1->SetBoundsRect(v1_bounds); | 611 v1->SetBoundsRect(v1_bounds); |
611 root_view->AddChildView(v1); | 612 root_view->AddChildView(v1); |
612 | 613 |
613 // |v2| has a triangular hit test mask. Install a ViewTargeter on |v2| which | 614 // |v2| has a triangular hit test mask. Install a ViewTargeter on |v2| which |
614 // will be called into by View::HitTestRect(). | 615 // will be called into by View::HitTestRect(). |
615 gfx::Rect v2_bounds = gfx::Rect(105, 0, 100, 100); | 616 gfx::Rect v2_bounds = gfx::Rect(105, 0, 100, 100); |
616 TestMaskedView* v2 = new TestMaskedView(); | 617 TestMaskedView* v2 = new TestMaskedView(); |
617 v2->SetBoundsRect(v2_bounds); | 618 v2->SetBoundsRect(v2_bounds); |
618 root_view->AddChildView(v2); | 619 root_view->AddChildView(v2); |
619 ViewTargeter* view_targeter = new ViewTargeter(v2); | 620 ViewTargeter* view_targeter = new ViewTargeter(v2); |
620 v2->SetEventTargeter(make_scoped_ptr(view_targeter)); | 621 v2->SetEventTargeter(base::WrapUnique(view_targeter)); |
621 | 622 |
622 gfx::Point v1_centerpoint = v1_bounds.CenterPoint(); | 623 gfx::Point v1_centerpoint = v1_bounds.CenterPoint(); |
623 gfx::Point v2_centerpoint = v2_bounds.CenterPoint(); | 624 gfx::Point v2_centerpoint = v2_bounds.CenterPoint(); |
624 gfx::Point v1_origin = v1_bounds.origin(); | 625 gfx::Point v1_origin = v1_bounds.origin(); |
625 gfx::Point v2_origin = v2_bounds.origin(); | 626 gfx::Point v2_origin = v2_bounds.origin(); |
626 gfx::Rect r1(10, 10, 110, 15); | 627 gfx::Rect r1(10, 10, 110, 15); |
627 gfx::Rect r2(106, 1, 98, 98); | 628 gfx::Rect r2(106, 1, 98, 98); |
628 gfx::Rect r3(0, 0, 300, 300); | 629 gfx::Rect r3(0, 0, 300, 300); |
629 gfx::Rect r4(115, 342, 200, 10); | 630 gfx::Rect r4(115, 342, 200, 10); |
630 | 631 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 EXPECT_EQ(v1, root_view->GetTooltipHandlerForPoint(v1_origin)); | 665 EXPECT_EQ(v1, root_view->GetTooltipHandlerForPoint(v1_origin)); |
665 EXPECT_EQ(root_view, root_view->GetTooltipHandlerForPoint(v2_origin)); | 666 EXPECT_EQ(root_view, root_view->GetTooltipHandlerForPoint(v2_origin)); |
666 | 667 |
667 EXPECT_FALSE(v1->GetTooltipHandlerForPoint(v2_origin)); | 668 EXPECT_FALSE(v1->GetTooltipHandlerForPoint(v2_origin)); |
668 | 669 |
669 widget->CloseNow(); | 670 widget->CloseNow(); |
670 } | 671 } |
671 | 672 |
672 } // namespace test | 673 } // namespace test |
673 } // namespace views | 674 } // namespace views |
OLD | NEW |