X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fthird_party%2FWebKit%2FSource%2Fcore%2Fsvg%2FSVGElementRareData.h;h=648d9ce8a700fae10234b17e1acac31d19768caf;hb=004985e17e624662a4c85c76a7654039dc83f028;hp=776af3c32da1306c0232c9e0a99c130539201b43;hpb=2f108dbacb161091e42a3479f4e171339b7e7623;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/third_party/WebKit/Source/core/svg/SVGElementRareData.h b/src/third_party/WebKit/Source/core/svg/SVGElementRareData.h index 776af3c..648d9ce 100644 --- a/src/third_party/WebKit/Source/core/svg/SVGElementRareData.h +++ b/src/third_party/WebKit/Source/core/svg/SVGElementRareData.h @@ -31,14 +31,14 @@ namespace WebCore { class CSSCursorImageValue; class SVGCursorElement; class SVGElement; -class SVGElementInstance; -class SVGElementRareData { - WTF_MAKE_NONCOPYABLE(SVGElementRareData); WTF_MAKE_FAST_ALLOCATED; +class SVGElementRareData : public NoBaseWillBeGarbageCollectedFinalized { + WTF_MAKE_NONCOPYABLE(SVGElementRareData); WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; public: - SVGElementRareData() - : m_cursorElement(0) - , m_cursorImageValue(0) + SVGElementRareData(SVGElement* owner) + : m_owner(owner) + , m_cursorElement(nullptr) + , m_cursorImageValue(nullptr) , m_correspondingElement(0) , m_instancesUpdatesBlocked(false) , m_useOverrideComputedStyle(false) @@ -46,12 +46,17 @@ public: { } - typedef HashMap SVGElementRareDataMap; + typedef WillBeHeapHashMap, RawPtrWillBeMember > SVGElementRareDataMap; static SVGElementRareDataMap& rareDataMap() { +#if ENABLE(OILPAN) + DEFINE_STATIC_LOCAL(Persistent, rareDataMap, (new SVGElementRareDataMap)); + return *rareDataMap; +#else DEFINE_STATIC_LOCAL(SVGElementRareDataMap, rareDataMap, ()); return rareDataMap; +#endif } static SVGElementRareData* rareDataFromMap(const SVGElement* element) @@ -59,8 +64,8 @@ public: return rareDataMap().get(element); } - HashSet& elementInstances() { return m_elementInstances; } - const HashSet& elementInstances() const { return m_elementInstances; } + WillBeHeapHashSet >& elementInstances() { return m_elementInstances; } + const WillBeHeapHashSet >& elementInstances() const { return m_elementInstances; } bool instanceUpdatesBlocked() const { return m_instancesUpdatesBlocked; } void setInstanceUpdatesBlocked(bool value) { m_instancesUpdatesBlocked = value; } @@ -82,11 +87,6 @@ public: return m_animatedSMILStyleProperties.get(); } - void destroyAnimatedSMILStyleProperties() - { - m_animatedSMILStyleProperties.clear(); - } - RenderStyle* overrideComputedStyle(Element* element, RenderStyle* parentStyle) { ASSERT(element); @@ -105,15 +105,55 @@ public: void setUseOverrideComputedStyle(bool value) { m_useOverrideComputedStyle = value; } void setNeedsOverrideComputedStyleUpdate() { m_needsOverrideComputedStyleUpdate = true; } + void trace(Visitor* visitor) + { + visitor->trace(m_animatedSMILStyleProperties); + visitor->trace(m_elementInstances); + visitor->registerWeakMembers(this); + } + + void processWeakMembers(Visitor* visitor) + { +#if ENABLE(OILPAN) + if (!visitor->isAlive(m_owner)) { + // If the owning SVGElement is dead this raraData element will be collected ASAP. + // The owning SVGElement will also be automatically removed from the SVGCursorElement's + // HashSet so no need to call out and clear anything. + // It should not be necessary, but just in case we clear the internal members to + // ensure we don't have a stale pointer. + m_owner = nullptr; + m_cursorElement = nullptr; + m_cursorImageValue = nullptr; + return; + } + ASSERT(m_owner); + if (!visitor->isAlive(m_cursorElement)) + m_cursorElement = nullptr; + + if (!visitor->isAlive(m_cursorImageValue)) { + // If the owning SVGElement is still alive and it is pointing to an SVGCursorElement + // we unregister it when the CSSCursorImageValue dies. + if (m_cursorElement) { + m_cursorElement->removeReferencedElement(m_owner); + m_cursorElement = nullptr; + } + m_cursorImageValue = nullptr; + } + ASSERT(!m_cursorElement || visitor->isAlive(m_cursorElement)); + ASSERT(!m_cursorImageValue || visitor->isAlive(m_cursorImageValue)); +#endif + } + private: - HashSet m_elementInstances; - SVGCursorElement* m_cursorElement; - CSSCursorImageValue* m_cursorImageValue; + RawPtrWillBeWeakMember m_owner; + WillBeHeapHashSet > m_elementInstances; + RawPtrWillBeWeakMember m_cursorElement; + RawPtrWillBeWeakMember m_cursorImageValue; SVGElement* m_correspondingElement; bool m_instancesUpdatesBlocked : 1; bool m_useOverrideComputedStyle : 1; bool m_needsOverrideComputedStyleUpdate : 1; - RefPtrWillBePersistent m_animatedSMILStyleProperties; + RefPtrWillBeMember m_animatedSMILStyleProperties; RefPtr m_overrideComputedStyle; };