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 { | |
|
Justin Novosad
2014/06/02 22:56:13
GarbageCollected?
haraken
2014/06/03 02:15:51
I think this is always stack-allocated. So you can
zino
2014/06/06 06:35:16
Done.
zino
2014/06/06 06:35:17
Done.
| |
| 21 String id; | |
| 22 RefPtrWillBeMember<Element> control; | |
|
Justin Novosad
2014/06/02 22:56:13
missing trace method
zino
2014/06/06 06:35:17
Please refer to @haraken's comment.
| |
| 23 Path path; | |
| 24 }; | |
| 25 | |
| 26 class HitRegion FINAL : public RefCountedWillBeGarbageCollectedFinalized<HitRegi on> { | |
|
Justin Novosad
2014/06/02 22:56:13
I don't think this class needs to be finalized. It
haraken
2014/06/03 02:15:51
Unfortunately this needs a destructor, since a Str
zino
2014/06/06 06:35:17
Done.
| |
| 27 public: | |
| 28 static PassRefPtrWillBeRawPtr<HitRegion> create(const HitRegionOptions& opti ons) | |
| 29 { | |
| 30 return adoptRef(new HitRegion(options)); | |
|
Justin Novosad
2014/06/02 22:56:13
adoptRef -> adoptRefWillBeNoop
zino
2014/06/06 06:35:17
Done.
| |
| 31 } | |
| 32 | |
| 33 void removePixels(const Path&); | |
| 34 void updateAccessibility(Element* canvas); | |
| 35 | |
| 36 bool contains(const LayoutPoint&) const; | |
| 37 | |
| 38 const String& id() const { return m_id; } | |
| 39 const Path& path() const { return m_path; } | |
| 40 const Element* control() const { return m_control.get(); } | |
| 41 | |
| 42 private: | |
| 43 HitRegion(const HitRegionOptions&); | |
|
haraken
2014/06/03 02:15:51
Add explicit.
zino
2014/06/06 06:35:17
Done.
| |
| 44 | |
| 45 String m_id; | |
| 46 RefPtrWillBeMember<Element> m_control; | |
|
Justin Novosad
2014/06/02 22:56:13
missing trace method
zino
2014/06/06 06:35:17
Done.
| |
| 47 Path m_path; | |
| 48 }; | |
| 49 | |
| 50 class HitRegionManager FINAL : public NoBaseWillBeGarbageCollectedFinalized<HitR egionManager> { | |
|
Justin Novosad
2014/06/02 22:56:13
Does this class really need to be finalized?
zino
2014/06/06 06:35:16
Done.
| |
| 51 WTF_MAKE_NONCOPYABLE(HitRegionManager); | |
| 52 | |
| 53 public: | |
| 54 static PassOwnPtrWillBeRawPtr<HitRegionManager> create() { return adoptPtr(n ew HitRegionManager()); } | |
| 55 virtual ~HitRegionManager() { } | |
|
Justin Novosad
2014/06/02 22:56:13
Is this necessary?
zino
2014/06/06 06:35:16
I'm not sure. if it wasn't exist, build error happ
| |
| 56 | |
| 57 void addHitRegion(PassRefPtrWillBeRawPtr<HitRegion>); | |
| 58 | |
| 59 void removeHitRegion(HitRegion*); | |
| 60 void removeHitRegionById(const String& id); | |
| 61 void removeHitRegionByControl(const Element*); | |
| 62 void removeHitRegionsInRect(const FloatRect&, const AffineTransform&); | |
| 63 void removeAllHitRegions(); | |
| 64 | |
| 65 HitRegion* getHitRegionById(const String& id) const; | |
| 66 HitRegion* getHitRegionByControl(const Element*) const; | |
| 67 HitRegion* getHitRegionAtPoint(const LayoutPoint&) const; | |
| 68 | |
| 69 unsigned getHitRegionsCount() const; | |
| 70 | |
| 71 private: | |
| 72 HitRegionManager() { } | |
| 73 | |
| 74 typedef WillBeHeapListHashSet< RefPtrWillBeMember<HitRegion> >::const_revers e_iterator HitRegionIterator; | |
|
fs
2014/06/03 11:47:01
If you move this after the HitRegionList typedef i
zino
2014/06/06 06:35:17
Done.
Good catch!
Thank you :)
| |
| 75 typedef WillBeHeapListHashSet< RefPtrWillBeMember<HitRegion> > HitRegionList ; | |
| 76 typedef WillBeHeapHashMap< String, RefPtrWillBeMember<HitRegion> > HitRegion IdMap; | |
| 77 typedef WillBeHeapHashMap< const Element*, RefPtrWillBeMember<HitRegion> > H itRegionControlMap; | |
|
haraken
2014/06/03 02:15:51
How is it guaranteed that the Element raw pointer
zino
2014/06/06 06:35:16
Done.
| |
| 78 | |
| 79 HitRegionList m_hitRegionList; | |
|
Justin Novosad
2014/06/02 22:56:13
This member and the one below need to be traced.
zino
2014/06/06 06:35:16
Done.
| |
| 80 HitRegionIdMap m_hitRegionIdMap; | |
| 81 HitRegionControlMap m_hitRegionControlMap; | |
|
fs
2014/06/03 11:47:01
I didn't see this being used for anything (just ac
zino
2014/06/06 06:35:16
It is actually used in addHitRegions().
Please re
fs
2014/06/09 11:06:27
Ok.
| |
| 82 }; | |
| 83 | |
| 84 } // namespace WebCore | |
| 85 | |
| 86 #endif | |
| OLD | NEW |