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.
6 #include "core/svg/SVGElementRareData.h"
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"
16 MutableStylePropertySet* SVGElementRareData::ensureAnimatedSMILStyleProperties()
18 if (!m_animatedSMILStyleProperties)
19 m_animatedSMILStyleProperties = MutableStylePropertySet::create(SVGAttributeMode);
20 return m_animatedSMILStyleProperties.get();
23 RenderStyle* SVGElementRareData::overrideComputedStyle(Element* element, RenderStyle* parentStyle)
26 if (!m_useOverrideComputedStyle)
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;
33 ASSERT(m_overrideComputedStyle);
34 return m_overrideComputedStyle.get();
37 void SVGElementRareData::trace(Visitor* visitor)
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);
50 void SVGElementRareData::processWeakMembers(Visitor* visitor)
54 if (!visitor->isAlive(m_cursorElement))
55 m_cursorElement = nullptr;
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;
64 m_cursorImageValue = nullptr;
66 ASSERT(!m_cursorElement || visitor->isAlive(m_cursorElement));
67 ASSERT(!m_cursorImageValue || visitor->isAlive(m_cursorImageValue));
71 AffineTransform* SVGElementRareData::animateMotionTransform()
73 if (!m_animateMotionTransform)
74 m_animateMotionTransform = adoptPtr(new AffineTransform);
75 return m_animateMotionTransform.get();