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

Side by Side Diff: Source/core/html/canvas/MouseEventHitRegion.h

Issue 300223009: Implement basic parts of hit regions on canvas2d. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: addressed comments 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
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 MouseEventHitRegion_h
6 #define MouseEventHitRegion_h
7
8 #include "core/events/MouseEvent.h"
9 #include "core/html/HTMLCanvasElement.h"
10 #include "core/html/canvas/CanvasRenderingContext.h"
11 #include "core/html/canvas/CanvasRenderingContext2D.h"
12
13 namespace WebCore {
14
15 class MouseEventHitRegion {
16 public:
17 static String region(MouseEvent& event, bool& isNull)
18 {
19 if (!isHTMLCanvasElement(event.target()->toNode())) {
20 isNull = true;
21 return String();
22 }
23
24 HTMLCanvasElement* canvas = toHTMLCanvasElement(event.target()->toNode() );
25 CanvasRenderingContext* context = canvas->renderingContext();
26 if (!context || !context->is2d()) {
27 isNull = true;
28 return String();
29 }
30
31 HitRegion* hitRegion = toCanvasRenderingContext2D(context)->
32 hitRegionAtPoint(LayoutPoint(event.offsetX(), event.offsetY()));
33
34 String id;
35 if (hitRegion)
36 id = hitRegion->id();
37
38 isNull = id.isEmpty();
39
40 return id;
41 }
42 };
43
44 } // namespace WebCore
45
46 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698