| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde
.org> | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde
.org> |
| 3 * Copyright (C) 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org> |
| 4 * Copyright (C) 2008 Apple Inc. All rights reserved. | 4 * Copyright (C) 2008 Apple Inc. All rights reserved. |
| 5 * Copyright (C) 2008 Alp Toker <alp@atoker.com> | 5 * Copyright (C) 2008 Alp Toker <alp@atoker.com> |
| 6 * Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> | 6 * Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 // The below teardown is all handled by weak pointer processing in oilpan. | 91 // The below teardown is all handled by weak pointer processing in oilpan. |
| 92 #if !ENABLE(OILPAN) | 92 #if !ENABLE(OILPAN) |
| 93 if (hasSVGRareData()) { | 93 if (hasSVGRareData()) { |
| 94 if (SVGCursorElement* cursorElement = svgRareData()->cursorElement()) | 94 if (SVGCursorElement* cursorElement = svgRareData()->cursorElement()) |
| 95 cursorElement->removeReferencedElement(this); | 95 cursorElement->removeReferencedElement(this); |
| 96 if (CSSCursorImageValue* cursorImageValue = svgRareData()->cursorImageVa
lue()) | 96 if (CSSCursorImageValue* cursorImageValue = svgRareData()->cursorImageVa
lue()) |
| 97 cursorImageValue->removeReferencedElement(this); | 97 cursorImageValue->removeReferencedElement(this); |
| 98 | 98 |
| 99 // With Oilpan, either removedFrom has been called or the document is de
ad | 99 // With Oilpan, either removedFrom has been called or the document is de
ad |
| 100 // as well and there is no reason to clear out the references. | 100 // as well and there is no reason to clear out the references. |
| 101 document().accessSVGExtensions().rebuildAllElementReferencesForTarget(th
is); | 101 rebuildAllIncomingReferences(); |
| 102 document().accessSVGExtensions().removeAllElementReferencesForTarget(thi
s); | 102 removeAllIncomingReferences(); |
| 103 } | 103 } |
| 104 #endif | 104 #endif |
| 105 } | 105 } |
| 106 | 106 |
| 107 void SVGElement::detach(const AttachContext& context) | 107 void SVGElement::detach(const AttachContext& context) |
| 108 { | 108 { |
| 109 Element::detach(context); | 109 Element::detach(context); |
| 110 if (SVGElement* element = correspondingElement()) | 110 if (SVGElement* element = correspondingElement()) |
| 111 element->removeInstanceMapping(this); | 111 element->removeInstanceMapping(this); |
| 112 } | 112 } |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 } | 310 } |
| 311 | 311 |
| 312 m_elementsWithRelativeLengths.clear(); | 312 m_elementsWithRelativeLengths.clear(); |
| 313 } | 313 } |
| 314 | 314 |
| 315 ASSERT_WITH_SECURITY_IMPLICATION(!rootParent->isSVGElement() || !toSVGElemen
t(rootParent)->m_elementsWithRelativeLengths.contains(this)); | 315 ASSERT_WITH_SECURITY_IMPLICATION(!rootParent->isSVGElement() || !toSVGElemen
t(rootParent)->m_elementsWithRelativeLengths.contains(this)); |
| 316 | 316 |
| 317 Element::removedFrom(rootParent); | 317 Element::removedFrom(rootParent); |
| 318 | 318 |
| 319 if (wasInDocument) { | 319 if (wasInDocument) { |
| 320 document().accessSVGExtensions().rebuildAllElementReferencesForTarget(th
is); | 320 rebuildAllIncomingReferences(); |
| 321 document().accessSVGExtensions().removeAllElementReferencesForTarget(thi
s); | 321 removeAllIncomingReferences(); |
| 322 } | 322 } |
| 323 | 323 |
| 324 invalidateInstances(); | 324 invalidateInstances(); |
| 325 } | 325 } |
| 326 | 326 |
| 327 void SVGElement::childrenChanged(bool changedByParser, Node* beforeChange, Node*
afterChange, int childCountDelta) | 327 void SVGElement::childrenChanged(bool changedByParser, Node* beforeChange, Node*
afterChange, int childCountDelta) |
| 328 { | 328 { |
| 329 Element::childrenChanged(changedByParser, beforeChange, afterChange, childCo
untDelta); | 329 Element::childrenChanged(changedByParser, beforeChange, afterChange, childCo
untDelta); |
| 330 | 330 |
| 331 // Invalidate all instances associated with us. | 331 // Invalidate all instances associated with us. |
| (...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 { | 890 { |
| 891 ASSERT_NOT_REACHED(); | 891 ASSERT_NOT_REACHED(); |
| 892 return 0; | 892 return 0; |
| 893 } | 893 } |
| 894 | 894 |
| 895 void SVGElement::attributeChanged(const QualifiedName& name, const AtomicString&
newValue, AttributeModificationReason) | 895 void SVGElement::attributeChanged(const QualifiedName& name, const AtomicString&
newValue, AttributeModificationReason) |
| 896 { | 896 { |
| 897 Element::attributeChanged(name, newValue); | 897 Element::attributeChanged(name, newValue); |
| 898 | 898 |
| 899 if (isIdAttributeName(name)) | 899 if (isIdAttributeName(name)) |
| 900 document().accessSVGExtensions().rebuildAllElementReferencesForTarget(th
is); | 900 rebuildAllIncomingReferences(); |
| 901 | 901 |
| 902 // Changes to the style attribute are processed lazily (see Element::getAttr
ibute() and related methods), | 902 // Changes to the style attribute are processed lazily (see Element::getAttr
ibute() and related methods), |
| 903 // so we don't want changes to the style attribute to result in extra work h
ere. | 903 // so we don't want changes to the style attribute to result in extra work h
ere. |
| 904 if (name != HTMLNames::styleAttr) | 904 if (name != HTMLNames::styleAttr) |
| 905 svgAttributeChanged(name); | 905 svgAttributeChanged(name); |
| 906 } | 906 } |
| 907 | 907 |
| 908 void SVGElement::svgAttributeChanged(const QualifiedName& attrName) | 908 void SVGElement::svgAttributeChanged(const QualifiedName& attrName) |
| 909 { | 909 { |
| 910 CSSPropertyID propId = SVGElement::cssPropertyIdForSVGAttributeName(attrName
); | 910 CSSPropertyID propId = SVGElement::cssPropertyIdForSVGAttributeName(attrName
); |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1145 animatableAttributes.add(SVGNames::zAttr); | 1145 animatableAttributes.add(SVGNames::zAttr); |
| 1146 } | 1146 } |
| 1147 | 1147 |
| 1148 if (name == classAttr) | 1148 if (name == classAttr) |
| 1149 return true; | 1149 return true; |
| 1150 | 1150 |
| 1151 return animatableAttributes.contains(name); | 1151 return animatableAttributes.contains(name); |
| 1152 } | 1152 } |
| 1153 #endif | 1153 #endif |
| 1154 | 1154 |
| 1155 SVGElementSet* SVGElement::setOfIncomingReferences() const |
| 1156 { |
| 1157 if (!hasSVGRareData()) |
| 1158 return 0; |
| 1159 return &svgRareData()->incomingReferences(); |
| 1160 } |
| 1161 |
| 1162 void SVGElement::addReferenceTo(SVGElement* targetElement) |
| 1163 { |
| 1164 ASSERT(targetElement); |
| 1165 |
| 1166 ensureSVGRareData()->outgoingReferences().add(targetElement); |
| 1167 targetElement->ensureSVGRareData()->incomingReferences().add(this); |
| 1168 } |
| 1169 |
| 1170 void SVGElement::rebuildAllIncomingReferences() |
| 1171 { |
| 1172 if (!hasSVGRareData()) |
| 1173 return; |
| 1174 |
| 1175 const SVGElementSet& incomingReferences = svgRareData()->incomingReferences(
); |
| 1176 |
| 1177 // Iterate on a snapshot as |incomingReferences| may be altered inside loop. |
| 1178 WillBeHeapVector<RawPtrWillBeMember<SVGElement> > incomingReferencesSnapshot
; |
| 1179 copyToVector(incomingReferences, incomingReferencesSnapshot); |
| 1180 |
| 1181 // Force rebuilding the |sourceElement| so it knows about this change. |
| 1182 for (WillBeHeapVector<RawPtrWillBeMember<SVGElement> >::iterator it = incomi
ngReferencesSnapshot.begin(), itEnd = incomingReferencesSnapshot.end(); it != it
End; ++it) { |
| 1183 SVGElement* sourceElement = *it; |
| 1184 |
| 1185 // Before rebuilding |sourceElement| ensure it was not removed from unde
r us. |
| 1186 if (incomingReferences.contains(sourceElement)) |
| 1187 sourceElement->svgAttributeChanged(XLinkNames::hrefAttr); |
| 1188 } |
| 1189 } |
| 1190 |
| 1191 void SVGElement::removeAllIncomingReferences() |
| 1192 { |
| 1193 if (!hasSVGRareData()) |
| 1194 return; |
| 1195 |
| 1196 SVGElementSet& incomingReferences = svgRareData()->incomingReferences(); |
| 1197 for (SVGElementSet::iterator it = incomingReferences.begin(), itEnd = incomi
ngReferences.end(); it != itEnd; ++it) { |
| 1198 SVGElement* sourceElement = *it; |
| 1199 ASSERT(sourceElement->hasSVGRareData()); |
| 1200 sourceElement->ensureSVGRareData()->outgoingReferences().remove(this); |
| 1201 } |
| 1202 incomingReferences.clear(); |
| 1203 } |
| 1204 |
| 1205 void SVGElement::removeAllOutgoingReferences() |
| 1206 { |
| 1207 if (!hasSVGRareData()) |
| 1208 return; |
| 1209 |
| 1210 SVGElementSet& outgoingReferences = svgRareData()->outgoingReferences(); |
| 1211 for (SVGElementSet::iterator it = outgoingReferences.begin(), itEnd = outgoi
ngReferences.end(); it != itEnd; ++it) { |
| 1212 SVGElement* targetElement = *it; |
| 1213 ASSERT(targetElement->hasSVGRareData()); |
| 1214 targetElement->ensureSVGRareData()->incomingReferences().remove(this); |
| 1215 } |
| 1216 outgoingReferences.clear(); |
| 1217 } |
| 1218 |
| 1155 void SVGElement::trace(Visitor* visitor) | 1219 void SVGElement::trace(Visitor* visitor) |
| 1156 { | 1220 { |
| 1157 visitor->trace(m_elementsWithRelativeLengths); | 1221 visitor->trace(m_elementsWithRelativeLengths); |
| 1158 visitor->trace(m_SVGRareData); | 1222 visitor->trace(m_SVGRareData); |
| 1159 Element::trace(visitor); | 1223 Element::trace(visitor); |
| 1160 } | 1224 } |
| 1161 | 1225 |
| 1162 const AtomicString& SVGElement::eventParameterName() | 1226 const AtomicString& SVGElement::eventParameterName() |
| 1163 { | 1227 { |
| 1164 DEFINE_STATIC_LOCAL(const AtomicString, evtString, ("evt", AtomicString::Con
structFromLiteral)); | 1228 DEFINE_STATIC_LOCAL(const AtomicString, evtString, ("evt", AtomicString::Con
structFromLiteral)); |
| 1165 return evtString; | 1229 return evtString; |
| 1166 } | 1230 } |
| 1167 | 1231 |
| 1168 } | 1232 } |
| OLD | NEW |