Chromium Code Reviews| OLD | NEW |
|---|---|
| (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() { } | |
|
haraken
2014/06/12 08:23:11
Drop explicit.
| |
| 82 | |
| 83 typedef WillBeHeapListHashSet< RefPtrWillBeMember<HitRegion> > HitRegionList ; | |
|
haraken
2014/06/12 08:23:11
Nit: No need to add a space after '<'.
| |
| 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 | |
| OLD | NEW |