OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/svg/SVGElementRareData.h" | 5 #include "core/svg/SVGElementRareData.h" |
6 | 6 |
7 #include "core/css/CSSCursorImageValue.h" | 7 #include "core/css/CSSCursorImageValue.h" |
8 #include "core/css/resolver/StyleResolver.h" | 8 #include "core/css/resolver/StyleResolver.h" |
9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
10 #include "core/svg/SVGCursorElement.h" | 10 #include "core/svg/SVGCursorElement.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 MutableStylePropertySet* | 14 MutableStylePropertySet* |
15 SVGElementRareData::ensureAnimatedSMILStyleProperties() { | 15 SVGElementRareData::ensureAnimatedSMILStyleProperties() { |
16 if (!m_animatedSMILStyleProperties) | 16 if (!m_animatedSMILStyleProperties) |
17 m_animatedSMILStyleProperties = | 17 m_animatedSMILStyleProperties = |
18 MutableStylePropertySet::create(SVGAttributeMode); | 18 MutableStylePropertySet::create(SVGAttributeMode); |
19 return m_animatedSMILStyleProperties.get(); | 19 return m_animatedSMILStyleProperties.get(); |
20 } | 20 } |
21 | 21 |
22 ComputedStyle* SVGElementRareData::overrideComputedStyle( | 22 ComputedStyle* SVGElementRareData::overrideComputedStyle( |
23 Element* element, | 23 Element* element, |
24 const ComputedStyle* parentStyle) { | 24 const ComputedStyle* parentStyle) { |
25 ASSERT(element); | 25 ASSERT(element); |
26 if (!m_useOverrideComputedStyle) | 26 if (!m_useOverrideComputedStyle) |
27 return nullptr; | 27 return nullptr; |
28 if (!m_overrideComputedStyle || m_needsOverrideComputedStyleUpdate) { | 28 if (!m_overrideComputedStyle || m_needsOverrideComputedStyleUpdate) { |
29 // The style computed here contains no CSS Animations/Transitions or SMIL in
duced rules - this is needed to compute the "base value" for the SMIL animation
sandwhich model. | 29 // The style computed here contains no CSS Animations/Transitions or SMIL |
| 30 // induced rules - this is needed to compute the "base value" for the SMIL |
| 31 // animation sandwhich model. |
30 m_overrideComputedStyle = | 32 m_overrideComputedStyle = |
31 element->document().ensureStyleResolver().styleForElement( | 33 element->document().ensureStyleResolver().styleForElement( |
32 element, parentStyle, DisallowStyleSharing, | 34 element, parentStyle, DisallowStyleSharing, |
33 MatchAllRulesExcludingSMIL); | 35 MatchAllRulesExcludingSMIL); |
34 m_needsOverrideComputedStyleUpdate = false; | 36 m_needsOverrideComputedStyleUpdate = false; |
35 } | 37 } |
36 ASSERT(m_overrideComputedStyle); | 38 ASSERT(m_overrideComputedStyle); |
37 return m_overrideComputedStyle.get(); | 39 return m_overrideComputedStyle.get(); |
38 } | 40 } |
39 | 41 |
40 DEFINE_TRACE(SVGElementRareData) { | 42 DEFINE_TRACE(SVGElementRareData) { |
41 visitor->trace(m_outgoingReferences); | 43 visitor->trace(m_outgoingReferences); |
42 visitor->trace(m_incomingReferences); | 44 visitor->trace(m_incomingReferences); |
43 visitor->trace(m_animatedSMILStyleProperties); | 45 visitor->trace(m_animatedSMILStyleProperties); |
44 visitor->trace(m_elementInstances); | 46 visitor->trace(m_elementInstances); |
45 visitor->trace(m_correspondingElement); | 47 visitor->trace(m_correspondingElement); |
46 visitor->trace(m_owner); | 48 visitor->trace(m_owner); |
47 visitor->template registerWeakMembers< | 49 visitor->template registerWeakMembers< |
48 SVGElementRareData, &SVGElementRareData::processWeakMembers>(this); | 50 SVGElementRareData, &SVGElementRareData::processWeakMembers>(this); |
49 } | 51 } |
50 | 52 |
51 void SVGElementRareData::processWeakMembers(Visitor* visitor) { | 53 void SVGElementRareData::processWeakMembers(Visitor* visitor) { |
52 ASSERT(m_owner); | 54 ASSERT(m_owner); |
53 if (!ThreadHeap::isHeapObjectAlive(m_cursorElement)) | 55 if (!ThreadHeap::isHeapObjectAlive(m_cursorElement)) |
54 m_cursorElement = nullptr; | 56 m_cursorElement = nullptr; |
55 | 57 |
56 if (!ThreadHeap::isHeapObjectAlive(m_cursorImageValue)) { | 58 if (!ThreadHeap::isHeapObjectAlive(m_cursorImageValue)) { |
57 // The owning SVGElement is still alive and if it is pointing to an SVGCurso
rElement | 59 // The owning SVGElement is still alive and if it is pointing to an |
58 // we unregister it when the CSSCursorImageValue dies. | 60 // SVGCursorElement we unregister it when the CSSCursorImageValue dies. |
59 if (m_cursorElement) { | 61 if (m_cursorElement) { |
60 m_cursorElement->removeReferencedElement(m_owner); | 62 m_cursorElement->removeReferencedElement(m_owner); |
61 m_cursorElement = nullptr; | 63 m_cursorElement = nullptr; |
62 } | 64 } |
63 m_cursorImageValue = nullptr; | 65 m_cursorImageValue = nullptr; |
64 } | 66 } |
65 ASSERT(!m_cursorElement || ThreadHeap::isHeapObjectAlive(m_cursorElement)); | 67 ASSERT(!m_cursorElement || ThreadHeap::isHeapObjectAlive(m_cursorElement)); |
66 ASSERT(!m_cursorImageValue || | 68 ASSERT(!m_cursorImageValue || |
67 ThreadHeap::isHeapObjectAlive(m_cursorImageValue)); | 69 ThreadHeap::isHeapObjectAlive(m_cursorImageValue)); |
68 } | 70 } |
69 | 71 |
70 AffineTransform* SVGElementRareData::animateMotionTransform() { | 72 AffineTransform* SVGElementRareData::animateMotionTransform() { |
71 return &m_animateMotionTransform; | 73 return &m_animateMotionTransform; |
72 } | 74 } |
73 | 75 |
74 } // namespace blink | 76 } // namespace blink |
OLD | NEW |