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 #ifndef HitRegion_h | 5 #ifndef HitRegion_h |
6 #define HitRegion_h | 6 #define HitRegion_h |
7 | 7 |
8 #include "bindings/v8/Dictionary.h" | 8 #include "bindings/v8/Dictionary.h" |
9 #include "core/dom/Element.h" | 9 #include "core/dom/Element.h" |
10 #include "platform/graphics/Path.h" | 10 #include "platform/graphics/Path.h" |
11 #include "platform/heap/Handle.h" | 11 #include "platform/heap/Handle.h" |
12 #include "wtf/Noncopyable.h" | 12 #include "wtf/Noncopyable.h" |
13 #include "wtf/OwnPtr.h" | 13 #include "wtf/OwnPtr.h" |
14 #include "wtf/PassOwnPtr.h" | 14 #include "wtf/PassOwnPtr.h" |
15 #include "wtf/PassRefPtr.h" | 15 #include "wtf/PassRefPtr.h" |
16 #include "wtf/RefPtr.h" | 16 #include "wtf/RefPtr.h" |
17 | 17 |
18 namespace WebCore { | 18 namespace WebCore { |
19 | 19 |
20 struct HitRegionOptions { | 20 struct HitRegionOptions { |
21 STACK_ALLOCATED(); | 21 STACK_ALLOCATED(); |
22 | 22 |
23 public: | 23 public: |
24 String id; | 24 String id; |
25 RefPtrWillBeMember<Element> control; | 25 RefPtrWillBeMember<Element> control; |
26 Path path; | 26 Path path; |
27 }; | 27 }; |
28 | 28 |
29 class HitRegion FINAL : public RefCountedWillBeGarbageCollected<HitRegion> { | 29 class HitRegion FINAL : public RefCountedWillBeGarbageCollectedFinalized<HitRegi
on> { |
30 public: | 30 public: |
31 static PassRefPtrWillBeRawPtr<HitRegion> create(const HitRegionOptions& opti
ons) | 31 static PassRefPtrWillBeRawPtr<HitRegion> create(const HitRegionOptions& opti
ons) |
32 { | 32 { |
33 return adoptRefWillBeNoop(new HitRegion(options)); | 33 return adoptRefWillBeNoop(new HitRegion(options)); |
34 } | 34 } |
35 | 35 |
36 virtual ~HitRegion() { } | 36 virtual ~HitRegion() { } |
37 | 37 |
38 void removePixels(const Path&); | 38 void removePixels(const Path&); |
39 void updateAccessibility(Element* canvas); | 39 void updateAccessibility(Element* canvas); |
40 | 40 |
41 bool contains(const LayoutPoint&) const; | 41 bool contains(const LayoutPoint&) const; |
42 | 42 |
43 const String& id() const { return m_id; } | 43 const String& id() const { return m_id; } |
44 const Path& path() const { return m_path; } | 44 const Path& path() const { return m_path; } |
45 Element* control() const { return m_control.get(); } | 45 Element* control() const { return m_control.get(); } |
46 | 46 |
47 void trace(Visitor*); | 47 void trace(Visitor*); |
48 | 48 |
49 private: | 49 private: |
50 explicit HitRegion(const HitRegionOptions&); | 50 explicit HitRegion(const HitRegionOptions&); |
51 | 51 |
52 String m_id; | 52 String m_id; |
53 RefPtrWillBeMember<Element> m_control; | 53 RefPtrWillBeMember<Element> m_control; |
54 Path m_path; | 54 Path m_path; |
55 }; | 55 }; |
56 | 56 |
57 class HitRegionManager FINAL : public NoBaseWillBeGarbageCollected<HitRegionMana
ger> { | 57 class HitRegionManager FINAL : public NoBaseWillBeGarbageCollected<HitRegionMana
ger> { |
58 WTF_MAKE_NONCOPYABLE(HitRegionManager); | 58 WTF_MAKE_NONCOPYABLE(HitRegionManager); |
59 | 59 DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(HitRegionManager) |
60 public: | 60 public: |
61 static PassOwnPtrWillBeRawPtr<HitRegionManager> create() { return adoptPtrWi
llBeNoop(new HitRegionManager()); } | 61 static PassOwnPtrWillBeRawPtr<HitRegionManager> create() { return adoptPtrWi
llBeNoop(new HitRegionManager()); } |
62 virtual ~HitRegionManager() { } | |
63 | 62 |
64 void addHitRegion(PassRefPtrWillBeRawPtr<HitRegion>); | 63 void addHitRegion(PassRefPtrWillBeRawPtr<HitRegion>); |
65 | 64 |
66 void removeHitRegion(HitRegion*); | 65 void removeHitRegion(HitRegion*); |
67 void removeHitRegionById(const String& id); | 66 void removeHitRegionById(const String& id); |
68 void removeHitRegionByControl(Element*); | 67 void removeHitRegionByControl(Element*); |
69 void removeHitRegionsInRect(const FloatRect&, const AffineTransform&); | 68 void removeHitRegionsInRect(const FloatRect&, const AffineTransform&); |
70 void removeAllHitRegions(); | 69 void removeAllHitRegions(); |
71 | 70 |
72 HitRegion* getHitRegionById(const String& id) const; | 71 HitRegion* getHitRegionById(const String& id) const; |
(...skipping 13 matching lines...) Expand all Loading... |
86 typedef WillBeHeapHashMap<RefPtrWillBeMember<Element>, RefPtrWillBeMember<Hi
tRegion> > HitRegionControlMap; | 85 typedef WillBeHeapHashMap<RefPtrWillBeMember<Element>, RefPtrWillBeMember<Hi
tRegion> > HitRegionControlMap; |
87 | 86 |
88 HitRegionList m_hitRegionList; | 87 HitRegionList m_hitRegionList; |
89 HitRegionIdMap m_hitRegionIdMap; | 88 HitRegionIdMap m_hitRegionIdMap; |
90 HitRegionControlMap m_hitRegionControlMap; | 89 HitRegionControlMap m_hitRegionControlMap; |
91 }; | 90 }; |
92 | 91 |
93 } // namespace WebCore | 92 } // namespace WebCore |
94 | 93 |
95 #endif | 94 #endif |
OLD | NEW |