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"
15 MutableStylePropertySet* SVGElementRareData::ensureAnimatedSMILStyleProperties()
17 if (!m_animatedSMILStyleProperties)
18 m_animatedSMILStyleProperties = MutableStylePropertySet::create(SVGAttributeMode);
19 return m_animatedSMILStyleProperties.get();
22 RenderStyle* SVGElementRareData::overrideComputedStyle(Element* element, RenderStyle* parentStyle)
25 if (!m_useOverrideComputedStyle)
27 if (!m_overrideComputedStyle || m_needsOverrideComputedStyleUpdate) {
28 // 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.
29 m_overrideComputedStyle = element->document().ensureStyleResolver().styleForElement(element, parentStyle, DisallowStyleSharing, MatchAllRulesExcludingSMIL);
30 m_needsOverrideComputedStyleUpdate = false;
32 ASSERT(m_overrideComputedStyle);
33 return m_overrideComputedStyle.get();
36 void SVGElementRareData::trace(Visitor* visitor)
39 visitor->trace(m_outgoingReferences);
40 visitor->trace(m_incomingReferences);
41 visitor->trace(m_animatedSMILStyleProperties);
42 visitor->trace(m_elementInstances);
43 visitor->trace(m_correspondingElement);
44 visitor->trace(m_owner);
45 visitor->registerWeakMembers<SVGElementRareData, &SVGElementRareData::processWeakMembers>(this);
49 void SVGElementRareData::processWeakMembers(Visitor* visitor)
53 if (!visitor->isAlive(m_cursorElement))
54 m_cursorElement = nullptr;
56 if (!visitor->isAlive(m_cursorImageValue)) {
57 // The owning SVGElement is still alive and if it is pointing to an SVGCursorElement
58 // we unregister it when the CSSCursorImageValue dies.
59 if (m_cursorElement) {
60 m_cursorElement->removeReferencedElement(m_owner);
61 m_cursorElement = nullptr;
63 m_cursorImageValue = nullptr;
65 ASSERT(!m_cursorElement || visitor->isAlive(m_cursorElement));
66 ASSERT(!m_cursorImageValue || visitor->isAlive(m_cursorImageValue));