| 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 SKY_ENGINE_CORE_HTML_CANVAS_HITREGION_H_ | |
| 6 #define SKY_ENGINE_CORE_HTML_CANVAS_HITREGION_H_ | |
| 7 | |
| 8 #include "sky/engine/core/dom/Element.h" | |
| 9 #include "sky/engine/platform/graphics/Path.h" | |
| 10 #include "sky/engine/platform/heap/Handle.h" | |
| 11 #include "sky/engine/wtf/Noncopyable.h" | |
| 12 #include "sky/engine/wtf/OwnPtr.h" | |
| 13 #include "sky/engine/wtf/PassOwnPtr.h" | |
| 14 #include "sky/engine/wtf/PassRefPtr.h" | |
| 15 #include "sky/engine/wtf/RefPtr.h" | |
| 16 | |
| 17 namespace blink { | |
| 18 | |
| 19 struct HitRegionOptions { | |
| 20 STACK_ALLOCATED(); | |
| 21 | |
| 22 public: | |
| 23 String id; | |
| 24 RefPtr<Element> control; | |
| 25 Path path; | |
| 26 WindRule fillRule; | |
| 27 }; | |
| 28 | |
| 29 class HitRegion final : public RefCounted<HitRegion> { | |
| 30 public: | |
| 31 static PassRefPtr<HitRegion> create(const HitRegionOptions& options) | |
| 32 { | |
| 33 return adoptRef(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 WindRule fillRule() const { return m_fillRule; } | |
| 47 | |
| 48 private: | |
| 49 explicit HitRegion(const HitRegionOptions&); | |
| 50 | |
| 51 String m_id; | |
| 52 RefPtr<Element> m_control; | |
| 53 Path m_path; | |
| 54 WindRule m_fillRule; | |
| 55 }; | |
| 56 | |
| 57 class HitRegionManager final { | |
| 58 WTF_MAKE_NONCOPYABLE(HitRegionManager); | |
| 59 DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(HitRegionManager) | |
| 60 public: | |
| 61 static PassOwnPtr<HitRegionManager> create() { return adoptPtr(new HitRegion
Manager()); } | |
| 62 | |
| 63 void addHitRegion(PassRefPtr<HitRegion>); | |
| 64 | |
| 65 void removeHitRegion(HitRegion*); | |
| 66 void removeHitRegionById(const String& id); | |
| 67 void removeHitRegionByControl(Element*); | |
| 68 void removeHitRegionsInRect(const FloatRect&, const AffineTransform&); | |
| 69 void removeAllHitRegions(); | |
| 70 | |
| 71 HitRegion* getHitRegionById(const String& id) const; | |
| 72 HitRegion* getHitRegionByControl(Element*) const; | |
| 73 HitRegion* getHitRegionAtPoint(const LayoutPoint&) const; | |
| 74 | |
| 75 unsigned getHitRegionsCount() const; | |
| 76 | |
| 77 private: | |
| 78 HitRegionManager() { } | |
| 79 | |
| 80 typedef ListHashSet<RefPtr<HitRegion> > HitRegionList; | |
| 81 typedef HitRegionList::const_reverse_iterator HitRegionIterator; | |
| 82 typedef HashMap<String, RefPtr<HitRegion> > HitRegionIdMap; | |
| 83 typedef HashMap<RefPtr<Element>, RefPtr<HitRegion> > HitRegionControlMap; | |
| 84 | |
| 85 HitRegionList m_hitRegionList; | |
| 86 HitRegionIdMap m_hitRegionIdMap; | |
| 87 HitRegionControlMap m_hitRegionControlMap; | |
| 88 }; | |
| 89 | |
| 90 } // namespace blink | |
| 91 | |
| 92 #endif // SKY_ENGINE_CORE_HTML_CANVAS_HITREGION_H_ | |
| OLD | NEW |