Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(367)

Side by Side Diff: ui/views/masked_view_targeter.cc

Issue 286933014: Introduce the MaskedViewTargeter class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: quick nit Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/views/masked_view_targeter.h ('k') | ui/views/view_targeter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/views/masked_view_targeter.h"
6
7 #include "ui/gfx/path.h"
8 #include "ui/gfx/skia_util.h"
9 #include "ui/views/view.h"
10
11 namespace views {
12
13 MaskedViewTargeter::MaskedViewTargeter(View* masked_view)
14 : masked_view_(masked_view) {
15 }
16
17 MaskedViewTargeter::~MaskedViewTargeter() {
18 }
19
20 bool MaskedViewTargeter::EventLocationInsideBounds(
21 ui::EventTarget* target,
22 const ui::LocatedEvent& event) const {
23 View* view = static_cast<View*>(target);
24 if (view == masked_view_) {
25 gfx::Path mask;
26 if (!GetHitTestMask(view, &mask))
27 return ViewTargeter::EventLocationInsideBounds(view, event);
28
29 gfx::Size size = view->bounds().size();
30 SkRegion clip_region;
31 clip_region.setRect(0, 0, size.width(), size.height());
32
33 gfx::RectF bounds_f = ViewTargeter::BoundsForEvent(event);
34 if (view->parent())
35 View::ConvertRectToTarget(view->parent(), view, &bounds_f);
36 gfx::Rect bounds = gfx::ToEnclosingRect(bounds_f);
37
38 SkRegion mask_region;
39 return mask_region.setPath(mask, clip_region) &&
40 mask_region.intersects(RectToSkIRect(bounds));
41 }
42
43 return ViewTargeter::EventLocationInsideBounds(view, event);
44 }
45
46 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/masked_view_targeter.h ('k') | ui/views/view_targeter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698