Chromium Code Reviews| Index: Source/core/html/canvas/HitRegion.h |
| diff --git a/Source/core/html/canvas/HitRegion.h b/Source/core/html/canvas/HitRegion.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7e81c47f90fb405688494a9ead3f3b6451b66308 |
| --- /dev/null |
| +++ b/Source/core/html/canvas/HitRegion.h |
| @@ -0,0 +1,86 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef HitRegion_h |
| +#define HitRegion_h |
| + |
| +#include "bindings/v8/Dictionary.h" |
| +#include "core/dom/Element.h" |
| +#include "platform/graphics/Path.h" |
| +#include "platform/heap/Handle.h" |
| +#include "wtf/Noncopyable.h" |
| +#include "wtf/OwnPtr.h" |
| +#include "wtf/PassOwnPtr.h" |
| +#include "wtf/PassRefPtr.h" |
| +#include "wtf/RefPtr.h" |
| + |
| +namespace WebCore { |
| + |
| +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.
|
| + String id; |
| + 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.
|
| + Path path; |
| +}; |
| + |
| +class HitRegion FINAL : public RefCountedWillBeGarbageCollectedFinalized<HitRegion> { |
|
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.
|
| +public: |
| + static PassRefPtrWillBeRawPtr<HitRegion> create(const HitRegionOptions& options) |
| + { |
| + return adoptRef(new HitRegion(options)); |
|
Justin Novosad
2014/06/02 22:56:13
adoptRef -> adoptRefWillBeNoop
zino
2014/06/06 06:35:17
Done.
|
| + } |
| + |
| + void removePixels(const Path&); |
| + void updateAccessibility(Element* canvas); |
| + |
| + bool contains(const LayoutPoint&) const; |
| + |
| + const String& id() const { return m_id; } |
| + const Path& path() const { return m_path; } |
| + const Element* control() const { return m_control.get(); } |
| + |
| +private: |
| + HitRegion(const HitRegionOptions&); |
|
haraken
2014/06/03 02:15:51
Add explicit.
zino
2014/06/06 06:35:17
Done.
|
| + |
| + String m_id; |
| + RefPtrWillBeMember<Element> m_control; |
|
Justin Novosad
2014/06/02 22:56:13
missing trace method
zino
2014/06/06 06:35:17
Done.
|
| + Path m_path; |
| +}; |
| + |
| +class HitRegionManager FINAL : public NoBaseWillBeGarbageCollectedFinalized<HitRegionManager> { |
|
Justin Novosad
2014/06/02 22:56:13
Does this class really need to be finalized?
zino
2014/06/06 06:35:16
Done.
|
| + WTF_MAKE_NONCOPYABLE(HitRegionManager); |
| + |
| +public: |
| + static PassOwnPtrWillBeRawPtr<HitRegionManager> create() { return adoptPtr(new HitRegionManager()); } |
| + 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
|
| + |
| + void addHitRegion(PassRefPtrWillBeRawPtr<HitRegion>); |
| + |
| + void removeHitRegion(HitRegion*); |
| + void removeHitRegionById(const String& id); |
| + void removeHitRegionByControl(const Element*); |
| + void removeHitRegionsInRect(const FloatRect&, const AffineTransform&); |
| + void removeAllHitRegions(); |
| + |
| + HitRegion* getHitRegionById(const String& id) const; |
| + HitRegion* getHitRegionByControl(const Element*) const; |
| + HitRegion* getHitRegionAtPoint(const LayoutPoint&) const; |
| + |
| + unsigned getHitRegionsCount() const; |
| + |
| +private: |
| + HitRegionManager() { } |
| + |
| + typedef WillBeHeapListHashSet< RefPtrWillBeMember<HitRegion> >::const_reverse_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 :)
|
| + typedef WillBeHeapListHashSet< RefPtrWillBeMember<HitRegion> > HitRegionList; |
| + typedef WillBeHeapHashMap< String, RefPtrWillBeMember<HitRegion> > HitRegionIdMap; |
| + typedef WillBeHeapHashMap< const Element*, RefPtrWillBeMember<HitRegion> > HitRegionControlMap; |
|
haraken
2014/06/03 02:15:51
How is it guaranteed that the Element raw pointer
zino
2014/06/06 06:35:16
Done.
|
| + |
| + 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.
|
| + HitRegionIdMap m_hitRegionIdMap; |
| + 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.
|
| +}; |
| + |
| +} // namespace WebCore |
| + |
| +#endif |