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 13namespace blink { 14 15MutableStylePropertySet* SVGElementRareData::ensureAnimatedSMILStyleProperties() 16{ 17 if (!m_animatedSMILStyleProperties) 18 m_animatedSMILStyleProperties = MutableStylePropertySet::create(SVGAttributeMode); 19 return m_animatedSMILStyleProperties.get(); 20} 21 22RenderStyle* SVGElementRareData::overrideComputedStyle(Element* element, RenderStyle* parentStyle) 23{ 24 ASSERT(element); 25 if (!m_useOverrideComputedStyle) 26 return 0; 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; 31 } 32 ASSERT(m_overrideComputedStyle); 33 return m_overrideComputedStyle.get(); 34} 35 36void SVGElementRareData::trace(Visitor* visitor) 37{ 38#if ENABLE(OILPAN) 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); 46#endif 47} 48 49void SVGElementRareData::processWeakMembers(Visitor* visitor) 50{ 51#if ENABLE(OILPAN) 52 ASSERT(m_owner); 53 if (!visitor->isAlive(m_cursorElement)) 54 m_cursorElement = nullptr; 55 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; 62 } 63 m_cursorImageValue = nullptr; 64 } 65 ASSERT(!m_cursorElement || visitor->isAlive(m_cursorElement)); 66 ASSERT(!m_cursorImageValue || visitor->isAlive(m_cursorImageValue)); 67#endif 68} 69 70 71} 72