| 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/wm/core/masked_window_targeter.h" | 5 #include "ui/wm/core/masked_window_targeter.h" |
| 6 | 6 |
| 7 #include "ui/aura/window.h" | 7 #include "ui/aura/window.h" |
| 8 #include "ui/gfx/path.h" | 8 #include "ui/gfx/path.h" |
| 9 | 9 |
| 10 namespace wm { | 10 namespace wm { |
| 11 | 11 |
| 12 MaskedWindowTargeter::MaskedWindowTargeter(aura::Window* masked_window) | 12 MaskedWindowTargeter::MaskedWindowTargeter(aura::Window* masked_window) |
| 13 : masked_window_(masked_window) { | 13 : masked_window_(masked_window) { |
| 14 } | 14 } |
| 15 | 15 |
| 16 MaskedWindowTargeter::~MaskedWindowTargeter() {} | 16 MaskedWindowTargeter::~MaskedWindowTargeter() {} |
| 17 | 17 |
| 18 bool MaskedWindowTargeter::EventLocationInsideBounds( | 18 bool MaskedWindowTargeter::EventLocationInsideBounds( |
| 19 aura::Window* window, | 19 aura::Window* window, |
| 20 const ui::LocatedEvent& event) const { | 20 const ui::LocatedEvent& event) const { |
| 21 if (window == masked_window_) { | 21 if (window == masked_window_) { |
| 22 gfx::Path mask; | 22 gfx::Path mask; |
| 23 if (!GetHitTestMask(window, &mask)) | 23 if (!GetHitTestMask(window, &mask)) |
| 24 return WindowTargeter::EventLocationInsideBounds(window, event); | 24 return WindowTargeter::EventLocationInsideBounds(window, event); |
| 25 | 25 |
| 26 gfx::Size size = window->bounds().size(); | 26 gfx::Size size = window->bounds().size(); |
| 27 SkRegion clip_region; | 27 SkRegion clip_region; |
| 28 clip_region.setRect(0, 0, size.width(), size.height()); | 28 clip_region.setRect(0, 0, size.width(), size.height()); |
| 29 | 29 |
| 30 gfx::Point point = event.location(); | 30 gfx::Point point = gfx::ToFlooredPoint(event.location()); |
| 31 if (window->parent()) | 31 if (window->parent()) |
| 32 aura::Window::ConvertPointToTarget(window->parent(), window, &point); | 32 aura::Window::ConvertPointToTarget(window->parent(), window, &point); |
| 33 | 33 |
| 34 SkRegion mask_region; | 34 SkRegion mask_region; |
| 35 return mask_region.setPath(mask, clip_region) && | 35 return mask_region.setPath(mask, clip_region) && |
| 36 mask_region.contains(point.x(), point.y()); | 36 mask_region.contains(point.x(), point.y()); |
| 37 } | 37 } |
| 38 | 38 |
| 39 return WindowTargeter::EventLocationInsideBounds(window, event); | 39 return WindowTargeter::EventLocationInsideBounds(window, event); |
| 40 } | 40 } |
| 41 | 41 |
| 42 } // namespace wm | 42 } // namespace wm |
| OLD | NEW |