| 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/core/v8/Dictionary.h" | 8 #include "bindings/core/v8/Dictionary.h" |
| 9 #include "core/dom/Element.h" | 9 #include "core/dom/Element.h" |
| 10 #include "core/html/canvas/HitRegionOptions.h" |
| 10 #include "platform/graphics/Path.h" | 11 #include "platform/graphics/Path.h" |
| 11 #include "platform/heap/Handle.h" | 12 #include "platform/heap/Handle.h" |
| 12 #include "wtf/Noncopyable.h" | 13 #include "wtf/Noncopyable.h" |
| 13 #include "wtf/OwnPtr.h" | 14 #include "wtf/OwnPtr.h" |
| 14 #include "wtf/PassOwnPtr.h" | 15 #include "wtf/PassOwnPtr.h" |
| 15 #include "wtf/PassRefPtr.h" | 16 #include "wtf/PassRefPtr.h" |
| 16 #include "wtf/RefPtr.h" | 17 #include "wtf/RefPtr.h" |
| 17 | 18 |
| 18 namespace blink { | 19 namespace blink { |
| 19 | 20 |
| 20 // FIXME: We already have IDL dictionary support; this should be removed. | |
| 21 // http://crbug.com/403150 | |
| 22 struct HitRegionOptionsInternal { | |
| 23 STACK_ALLOCATED(); | |
| 24 | |
| 25 public: | |
| 26 String id; | |
| 27 RefPtrWillBeMember<Element> control; | |
| 28 Path path; | |
| 29 WindRule fillRule; | |
| 30 }; | |
| 31 | |
| 32 class HitRegion FINAL : public RefCountedWillBeGarbageCollectedFinalized<HitRegi
on> { | 21 class HitRegion FINAL : public RefCountedWillBeGarbageCollectedFinalized<HitRegi
on> { |
| 33 public: | 22 public: |
| 34 static PassRefPtrWillBeRawPtr<HitRegion> create(const HitRegionOptionsIntern
al& options) | 23 static PassRefPtrWillBeRawPtr<HitRegion> create(const Path& path, const HitR
egionOptions& options) |
| 35 { | 24 { |
| 36 return adoptRefWillBeNoop(new HitRegion(options)); | 25 return adoptRefWillBeNoop(new HitRegion(path, options)); |
| 37 } | 26 } |
| 38 | 27 |
| 39 virtual ~HitRegion() { } | 28 virtual ~HitRegion() { } |
| 40 | 29 |
| 41 void removePixels(const Path&); | 30 void removePixels(const Path&); |
| 42 void updateAccessibility(Element* canvas); | 31 void updateAccessibility(Element* canvas); |
| 43 | 32 |
| 44 bool contains(const LayoutPoint&) const; | 33 bool contains(const LayoutPoint&) const; |
| 45 | 34 |
| 46 const String& id() const { return m_id; } | 35 const String& id() const { return m_id; } |
| 47 const Path& path() const { return m_path; } | 36 const Path& path() const { return m_path; } |
| 48 Element* control() const { return m_control.get(); } | 37 Element* control() const { return m_control.get(); } |
| 49 WindRule fillRule() const { return m_fillRule; } | 38 WindRule fillRule() const { return m_fillRule; } |
| 50 | 39 |
| 51 void trace(Visitor*); | 40 void trace(Visitor*); |
| 52 | 41 |
| 53 private: | 42 private: |
| 54 explicit HitRegion(const HitRegionOptionsInternal&); | 43 HitRegion(const Path&, const HitRegionOptions&); |
| 55 | 44 |
| 56 String m_id; | 45 String m_id; |
| 57 RefPtrWillBeMember<Element> m_control; | 46 RefPtrWillBeMember<Element> m_control; |
| 58 Path m_path; | 47 Path m_path; |
| 59 WindRule m_fillRule; | 48 WindRule m_fillRule; |
| 60 }; | 49 }; |
| 61 | 50 |
| 62 class HitRegionManager FINAL : public NoBaseWillBeGarbageCollected<HitRegionMana
ger> { | 51 class HitRegionManager FINAL : public NoBaseWillBeGarbageCollected<HitRegionMana
ger> { |
| 63 WTF_MAKE_NONCOPYABLE(HitRegionManager); | 52 WTF_MAKE_NONCOPYABLE(HitRegionManager); |
| 64 DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(HitRegionManager) | 53 DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(HitRegionManager) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 90 typedef WillBeHeapHashMap<RefPtrWillBeMember<Element>, RefPtrWillBeMember<Hi
tRegion> > HitRegionControlMap; | 79 typedef WillBeHeapHashMap<RefPtrWillBeMember<Element>, RefPtrWillBeMember<Hi
tRegion> > HitRegionControlMap; |
| 91 | 80 |
| 92 HitRegionList m_hitRegionList; | 81 HitRegionList m_hitRegionList; |
| 93 HitRegionIdMap m_hitRegionIdMap; | 82 HitRegionIdMap m_hitRegionIdMap; |
| 94 HitRegionControlMap m_hitRegionControlMap; | 83 HitRegionControlMap m_hitRegionControlMap; |
| 95 }; | 84 }; |
| 96 | 85 |
| 97 } // namespace blink | 86 } // namespace blink |
| 98 | 87 |
| 99 #endif | 88 #endif |
| OLD | NEW |