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

Side by Side Diff: sky/engine/core/html/canvas/MouseEventHitRegion.h

Issue 870073003: Remove mouse events from Sky (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 11 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
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 #ifndef SKY_ENGINE_CORE_HTML_CANVAS_MOUSEEVENTHITREGION_H_
6 #define SKY_ENGINE_CORE_HTML_CANVAS_MOUSEEVENTHITREGION_H_
7
8 #include "sky/engine/core/events/MouseEvent.h"
9 #include "sky/engine/core/html/HTMLCanvasElement.h"
10 #include "sky/engine/core/html/canvas/CanvasRenderingContext.h"
11 #include "sky/engine/core/html/canvas/CanvasRenderingContext2D.h"
12
13 namespace blink {
14
15 class MouseEventHitRegion {
16 public:
17 static String region(MouseEvent& event)
18 {
19 if (!event.target() || !isHTMLCanvasElement(event.target()->toNode()))
20 return String();
21
22 HTMLCanvasElement* canvas = toHTMLCanvasElement(event.target()->toNode() );
23 CanvasRenderingContext* context = canvas->renderingContext();
24 if (!context || !context->is2d())
25 return String();
26
27 HitRegion* hitRegion = toCanvasRenderingContext2D(context)->
28 hitRegionAtPoint(LayoutPoint(event.offsetX(), event.offsetY()));
29
30 if (!hitRegion)
31 return String();
32
33 String id = hitRegion->id();
34 if (id.isEmpty())
35 return String();
36
37 return id;
38 }
39 };
40
41 } // namespace blink
42
43 #endif // SKY_ENGINE_CORE_HTML_CANVAS_MOUSEEVENTHITREGION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698