1/*
2 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB.  If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20#ifndef SVGElementRareData_h
21#define SVGElementRareData_h
22
23#include "core/svg/SVGElement.h"
24#include "wtf/HashSet.h"
25#include "wtf/Noncopyable.h"
26#include "wtf/StdLibExtras.h"
27
28namespace blink {
29
30class CSSCursorImageValue;
31class SVGCursorElement;
32
33class SVGElementRareData : public NoBaseWillBeGarbageCollectedFinalized<SVGElementRareData> {
34    WTF_MAKE_NONCOPYABLE(SVGElementRareData); WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
35public:
36    SVGElementRareData(SVGElement* owner)
37#if ENABLE(OILPAN)
38        : m_owner(owner)
39        , m_cursorElement(nullptr)
40#else
41        : m_cursorElement(nullptr)
42#endif
43        , m_cursorImageValue(nullptr)
44        , m_correspondingElement(nullptr)
45        , m_instancesUpdatesBlocked(false)
46        , m_useOverrideComputedStyle(false)
47        , m_needsOverrideComputedStyleUpdate(false)
48    {
49    }
50
51    SVGElementSet& outgoingReferences() { return m_outgoingReferences; }
52    const SVGElementSet& outgoingReferences() const { return m_outgoingReferences; }
53    SVGElementSet& incomingReferences() { return m_incomingReferences; }
54    const SVGElementSet& incomingReferences() const { return m_incomingReferences; }
55
56    WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement> >& elementInstances() { return m_elementInstances; }
57    const WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement> >& elementInstances() const { return m_elementInstances; }
58
59    bool instanceUpdatesBlocked() const { return m_instancesUpdatesBlocked; }
60    void setInstanceUpdatesBlocked(bool value) { m_instancesUpdatesBlocked = value; }
61
62    SVGCursorElement* cursorElement() const { return m_cursorElement; }
63    void setCursorElement(SVGCursorElement* cursorElement) { m_cursorElement = cursorElement; }
64
65    SVGElement* correspondingElement() { return m_correspondingElement.get(); }
66    void setCorrespondingElement(SVGElement* correspondingElement) { m_correspondingElement = correspondingElement; }
67
68    CSSCursorImageValue* cursorImageValue() const { return m_cursorImageValue; }
69    void setCursorImageValue(CSSCursorImageValue* cursorImageValue) { m_cursorImageValue = cursorImageValue; }
70
71    MutableStylePropertySet* animatedSMILStyleProperties() const { return m_animatedSMILStyleProperties.get(); }
72    MutableStylePropertySet* ensureAnimatedSMILStyleProperties();
73
74    RenderStyle* overrideComputedStyle(Element*, RenderStyle*);
75
76    bool useOverrideComputedStyle() const { return m_useOverrideComputedStyle; }
77    void setUseOverrideComputedStyle(bool value) { m_useOverrideComputedStyle = value; }
78    void setNeedsOverrideComputedStyleUpdate() { m_needsOverrideComputedStyleUpdate = true; }
79
80    void trace(Visitor*);
81    void processWeakMembers(Visitor*);
82
83private:
84#if ENABLE(OILPAN)
85    Member<SVGElement> m_owner;
86#endif
87    SVGElementSet m_outgoingReferences;
88    SVGElementSet m_incomingReferences;
89    WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement> > m_elementInstances;
90    RawPtrWillBeWeakMember<SVGCursorElement> m_cursorElement;
91    RawPtrWillBeWeakMember<CSSCursorImageValue> m_cursorImageValue;
92    RefPtrWillBeMember<SVGElement> m_correspondingElement;
93    bool m_instancesUpdatesBlocked : 1;
94    bool m_useOverrideComputedStyle : 1;
95    bool m_needsOverrideComputedStyleUpdate : 1;
96    RefPtrWillBeMember<MutableStylePropertySet> m_animatedSMILStyleProperties;
97    RefPtr<RenderStyle> m_overrideComputedStyle;
98};
99
100}
101
102#endif
103