Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / svg / SVGElementRareData.cpp
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 #include "config.h"
6 #include "core/svg/SVGElementRareData.h"
7
8 #include "core/css/CSSCursorImageValue.h"
9 #include "core/css/resolver/StyleResolver.h"
10 #include "core/dom/Document.h"
11 #include "core/svg/SVGCursorElement.h"
12 #include "platform/transforms/AffineTransform.h"
13
14 namespace blink {
15
16 MutableStylePropertySet* SVGElementRareData::ensureAnimatedSMILStyleProperties()
17 {
18     if (!m_animatedSMILStyleProperties)
19         m_animatedSMILStyleProperties = MutableStylePropertySet::create(SVGAttributeMode);
20     return m_animatedSMILStyleProperties.get();
21 }
22
23 RenderStyle* SVGElementRareData::overrideComputedStyle(Element* element, RenderStyle* parentStyle)
24 {
25     ASSERT(element);
26     if (!m_useOverrideComputedStyle)
27         return 0;
28     if (!m_overrideComputedStyle || m_needsOverrideComputedStyleUpdate) {
29         // The style computed here contains no CSS Animations/Transitions or SMIL induced rules - this is needed to compute the "base value" for the SMIL animation sandwhich model.
30         m_overrideComputedStyle = element->document().ensureStyleResolver().styleForElement(element, parentStyle, DisallowStyleSharing, MatchAllRulesExcludingSMIL);
31         m_needsOverrideComputedStyleUpdate = false;
32     }
33     ASSERT(m_overrideComputedStyle);
34     return m_overrideComputedStyle.get();
35 }
36
37 void SVGElementRareData::trace(Visitor* visitor)
38 {
39 #if ENABLE(OILPAN)
40     visitor->trace(m_outgoingReferences);
41     visitor->trace(m_incomingReferences);
42     visitor->trace(m_animatedSMILStyleProperties);
43     visitor->trace(m_elementInstances);
44     visitor->trace(m_correspondingElement);
45     visitor->trace(m_owner);
46     visitor->registerWeakMembers<SVGElementRareData, &SVGElementRareData::processWeakMembers>(this);
47 #endif
48 }
49
50 void SVGElementRareData::processWeakMembers(Visitor* visitor)
51 {
52 #if ENABLE(OILPAN)
53         ASSERT(m_owner);
54         if (!visitor->isAlive(m_cursorElement))
55             m_cursorElement = nullptr;
56
57         if (!visitor->isAlive(m_cursorImageValue)) {
58             // The owning SVGElement is still alive and if it is pointing to an SVGCursorElement
59             // we unregister it when the CSSCursorImageValue dies.
60             if (m_cursorElement) {
61                 m_cursorElement->removeReferencedElement(m_owner);
62                 m_cursorElement = nullptr;
63             }
64             m_cursorImageValue = nullptr;
65         }
66         ASSERT(!m_cursorElement || visitor->isAlive(m_cursorElement));
67         ASSERT(!m_cursorImageValue || visitor->isAlive(m_cursorImageValue));
68 #endif
69 }
70
71 AffineTransform* SVGElementRareData::animateMotionTransform()
72 {
73     if (!m_animateMotionTransform)
74         m_animateMotionTransform = adoptPtr(new AffineTransform);
75     return m_animateMotionTransform.get();
76 }
77
78 }