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/aura/window.h" | 5 #include "ui/aura/window.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "ui/aura/event_filter.h" | 22 #include "ui/aura/event_filter.h" |
23 #include "ui/aura/focus_manager.h" | 23 #include "ui/aura/focus_manager.h" |
24 #include "ui/aura/layout_manager.h" | 24 #include "ui/aura/layout_manager.h" |
25 #include "ui/aura/root_window.h" | 25 #include "ui/aura/root_window.h" |
26 #include "ui/aura/window_delegate.h" | 26 #include "ui/aura/window_delegate.h" |
27 #include "ui/aura/window_observer.h" | 27 #include "ui/aura/window_observer.h" |
28 #include "ui/base/animation/multi_animation.h" | 28 #include "ui/base/animation/multi_animation.h" |
29 #include "ui/compositor/compositor.h" | 29 #include "ui/compositor/compositor.h" |
30 #include "ui/compositor/layer.h" | 30 #include "ui/compositor/layer.h" |
31 #include "ui/gfx/canvas.h" | 31 #include "ui/gfx/canvas.h" |
| 32 #include "ui/gfx/path.h" |
32 #include "ui/gfx/screen.h" | 33 #include "ui/gfx/screen.h" |
33 | 34 |
34 namespace aura { | 35 namespace aura { |
35 | 36 |
36 namespace { | 37 namespace { |
37 | 38 |
38 Window* GetParentForWindow(Window* window, Window* suggested_parent) { | 39 Window* GetParentForWindow(Window* window, Window* suggested_parent) { |
39 if (suggested_parent) | 40 if (suggested_parent) |
40 return suggested_parent; | 41 return suggested_parent; |
41 if (client::GetStackingClient()) | 42 if (client::GetStackingClient()) |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 bool Window::ContainsPoint(const gfx::Point& local_point) { | 436 bool Window::ContainsPoint(const gfx::Point& local_point) { |
436 gfx::Rect local_bounds(gfx::Point(), bounds().size()); | 437 gfx::Rect local_bounds(gfx::Point(), bounds().size()); |
437 return local_bounds.Contains(local_point); | 438 return local_bounds.Contains(local_point); |
438 } | 439 } |
439 | 440 |
440 bool Window::HitTest(const gfx::Point& local_point) { | 441 bool Window::HitTest(const gfx::Point& local_point) { |
441 // Expand my bounds for hit testing (override is usually zero but it's | 442 // Expand my bounds for hit testing (override is usually zero but it's |
442 // probably cheaper to do the math every time than to branch). | 443 // probably cheaper to do the math every time than to branch). |
443 gfx::Rect local_bounds(gfx::Point(), bounds().size()); | 444 gfx::Rect local_bounds(gfx::Point(), bounds().size()); |
444 local_bounds.Inset(hit_test_bounds_override_outer_); | 445 local_bounds.Inset(hit_test_bounds_override_outer_); |
445 // TODO(beng): hittest masks. | 446 |
446 return local_bounds.Contains(local_point); | 447 if (!delegate_ || !delegate_->HasHitTestMask()) |
| 448 return local_bounds.Contains(local_point); |
| 449 |
| 450 gfx::Path mask; |
| 451 delegate_->GetHitTestMask(&mask); |
| 452 |
| 453 SkRegion clip_region; |
| 454 clip_region.setRect(local_bounds.x(), local_bounds.y(), |
| 455 local_bounds.width(), local_bounds.height()); |
| 456 SkRegion mask_region; |
| 457 return mask_region.setPath(mask, clip_region) && |
| 458 mask_region.contains(local_point.x(), local_point.y()); |
447 } | 459 } |
448 | 460 |
449 Window* Window::GetEventHandlerForPoint(const gfx::Point& local_point) { | 461 Window* Window::GetEventHandlerForPoint(const gfx::Point& local_point) { |
450 return GetWindowForPoint(local_point, true, true); | 462 return GetWindowForPoint(local_point, true, true); |
451 } | 463 } |
452 | 464 |
453 Window* Window::GetTopWindowContainingPoint(const gfx::Point& local_point) { | 465 Window* Window::GetTopWindowContainingPoint(const gfx::Point& local_point) { |
454 return GetWindowForPoint(local_point, false, false); | 466 return GetWindowForPoint(local_point, false, false); |
455 } | 467 } |
456 | 468 |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 for (Windows::const_reverse_iterator it = children_.rbegin(), | 882 for (Windows::const_reverse_iterator it = children_.rbegin(), |
871 rend = children_.rend(); | 883 rend = children_.rend(); |
872 it != rend; ++it) { | 884 it != rend; ++it) { |
873 Window* child = *it; | 885 Window* child = *it; |
874 child->PrintWindowHierarchy(depth + 1); | 886 child->PrintWindowHierarchy(depth + 1); |
875 } | 887 } |
876 } | 888 } |
877 #endif | 889 #endif |
878 | 890 |
879 } // namespace aura | 891 } // namespace aura |
OLD | NEW |