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

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

Issue 300223009: Implement basic parts of hit regions on canvas2d. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add clip tests 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 HitRegion_h
6 #define HitRegion_h
7
8 #include "bindings/v8/Dictionary.h"
9 #include "core/dom/Element.h"
10 #include "platform/graphics/Path.h"
11 #include "platform/heap/Handle.h"
12 #include "wtf/Noncopyable.h"
13 #include "wtf/OwnPtr.h"
14 #include "wtf/PassOwnPtr.h"
15 #include "wtf/PassRefPtr.h"
16 #include "wtf/RefPtr.h"
17
18 namespace WebCore {
19
20 struct HitRegionOptions {
21 STACK_ALLOCATED();
22
23 public:
24 String id;
25 RefPtrWillBeMember<Element> control;
26 Path path;
27 };
28
29 class HitRegion FINAL : public RefCountedWillBeGarbageCollected<HitRegion> {
30 public:
31 static PassRefPtrWillBeRawPtr<HitRegion> create(const HitRegionOptions& opti ons)
32 {
33 return adoptRefWillBeNoop(new HitRegion(options));
34 }
35
36 virtual ~HitRegion() { }
37
38 void removePixels(const Path&);
39 void updateAccessibility(Element* canvas);
40
41 bool contains(const LayoutPoint&) const;
42
43 const String& id() const { return m_id; }
44 const Path& path() const { return m_path; }
45 Element* control() const { return m_control.get(); }
46
47 virtual void trace(Visitor*) OVERRIDE;
48
49 private:
50 explicit HitRegion(const HitRegionOptions&);
51
52 String m_id;
53 RefPtrWillBeMember<Element> m_control;
54 Path m_path;
55 };
56
57 class HitRegionManager FINAL : public NoBaseWillBeGarbageCollected<HitRegionMana ger> {
58 WTF_MAKE_NONCOPYABLE(HitRegionManager);
59
60 public:
61 static PassOwnPtrWillBeRawPtr<HitRegionManager> create() { return adoptPtrWi llBeNoop(new HitRegionManager()); }
62 virtual ~HitRegionManager() { }
63
64 void addHitRegion(PassRefPtrWillBeRawPtr<HitRegion>);
65
66 void removeHitRegion(HitRegion*);
67 void removeHitRegionById(const String& id);
68 void removeHitRegionByControl(Element*);
69 void removeHitRegionsInRect(const FloatRect&, const AffineTransform&);
70 void removeAllHitRegions();
71
72 HitRegion* getHitRegionById(const String& id) const;
73 HitRegion* getHitRegionByControl(Element*) const;
74 HitRegion* getHitRegionAtPoint(const LayoutPoint&) const;
75
76 unsigned getHitRegionsCount() const;
77
78 virtual void trace(Visitor*) OVERRIDE;
79
80 private:
81 explicit HitRegionManager() { }
82
83 typedef WillBeHeapListHashSet< RefPtrWillBeMember<HitRegion> > HitRegionList ;
84 typedef HitRegionList::const_reverse_iterator HitRegionIterator;
85 typedef WillBeHeapHashMap< String, RefPtrWillBeMember<HitRegion> > HitRegion IdMap;
86 typedef WillBeHeapHashMap< RefPtrWillBeMember<Element>, RefPtrWillBeMember<H itRegion> > HitRegionControlMap;
87
88 HitRegionList m_hitRegionList;
89 HitRegionIdMap m_hitRegionIdMap;
90 HitRegionControlMap m_hitRegionControlMap;
91 };
92
93 } // namespace WebCore
94
95 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698