| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 116 |
| 117 // The rare data cleanup may have caused other SVG nodes to be deleted, | 117 // The rare data cleanup may have caused other SVG nodes to be deleted, |
| 118 // modifying the rare data map. Do not rely on the existing iterator. | 118 // modifying the rare data map. Do not rely on the existing iterator. |
| 119 ASSERT(rareDataMap.contains(this)); | 119 ASSERT(rareDataMap.contains(this)); |
| 120 rareDataMap.remove(this); | 120 rareDataMap.remove(this); |
| 121 // Clear HasSVGRareData flag now so that we are in a consistent state wh
en | 121 // Clear HasSVGRareData flag now so that we are in a consistent state wh
en |
| 122 // calling rebuildAllElementReferencesForTarget() and | 122 // calling rebuildAllElementReferencesForTarget() and |
| 123 // removeAllElementReferencesForTarget() below. | 123 // removeAllElementReferencesForTarget() below. |
| 124 clearHasSVGRareData(); | 124 clearHasSVGRareData(); |
| 125 } | 125 } |
| 126 document().accessSVGExtensions()->rebuildAllElementReferencesForTarget(this)
; | 126 document().accessSVGExtensions().rebuildAllElementReferencesForTarget(this); |
| 127 document().accessSVGExtensions()->removeAllElementReferencesForTarget(this); | 127 document().accessSVGExtensions().removeAllElementReferencesForTarget(this); |
| 128 SVGAnimatedProperty::detachAnimatedPropertiesForElement(this); | 128 SVGAnimatedProperty::detachAnimatedPropertiesForElement(this); |
| 129 } | 129 } |
| 130 | 130 |
| 131 void SVGElement::willRecalcStyle(StyleRecalcChange change) | 131 void SVGElement::willRecalcStyle(StyleRecalcChange change) |
| 132 { | 132 { |
| 133 // FIXME: This assumes that when shouldNotifyRendererWithIdenticalStyles() i
s true | 133 // FIXME: This assumes that when shouldNotifyRendererWithIdenticalStyles() i
s true |
| 134 // the change came from a SMIL animation, but what if there were non-SMIL ch
anges | 134 // the change came from a SMIL animation, but what if there were non-SMIL ch
anges |
| 135 // since then? I think we should remove the shouldNotifyRendererWithIdentica
lStyles | 135 // since then? I think we should remove the shouldNotifyRendererWithIdentica
lStyles |
| 136 // check. | 136 // check. |
| 137 if (!hasSVGRareData() || shouldNotifyRendererWithIdenticalStyles()) | 137 if (!hasSVGRareData() || shouldNotifyRendererWithIdenticalStyles()) |
| 138 return; | 138 return; |
| 139 // If the style changes because of a regular property change (not induced by
SMIL animations themselves) | 139 // If the style changes because of a regular property change (not induced by
SMIL animations themselves) |
| 140 // reset the "computed style without SMIL style properties", so the base val
ue change gets reflected. | 140 // reset the "computed style without SMIL style properties", so the base val
ue change gets reflected. |
| 141 if (change > NoChange || needsStyleRecalc()) | 141 if (change > NoChange || needsStyleRecalc()) |
| 142 svgRareData()->setNeedsOverrideComputedStyleUpdate(); | 142 svgRareData()->setNeedsOverrideComputedStyleUpdate(); |
| 143 } | 143 } |
| 144 | 144 |
| 145 void SVGElement::buildPendingResourcesIfNeeded() | 145 void SVGElement::buildPendingResourcesIfNeeded() |
| 146 { | 146 { |
| 147 Document& document = this->document(); | 147 Document& document = this->document(); |
| 148 if (!needsPendingResourceHandling() || !inDocument() || isInShadowTree()) | 148 if (!needsPendingResourceHandling() || !inDocument() || isInShadowTree()) |
| 149 return; | 149 return; |
| 150 | 150 |
| 151 SVGDocumentExtensions* extensions = document.accessSVGExtensions(); | 151 SVGDocumentExtensions& extensions = document.accessSVGExtensions(); |
| 152 AtomicString resourceId = getIdAttribute(); | 152 AtomicString resourceId = getIdAttribute(); |
| 153 if (!extensions->hasPendingResource(resourceId)) | 153 if (!extensions.hasPendingResource(resourceId)) |
| 154 return; | 154 return; |
| 155 | 155 |
| 156 // Mark pending resources as pending for removal. | 156 // Mark pending resources as pending for removal. |
| 157 extensions->markPendingResourcesForRemoval(resourceId); | 157 extensions.markPendingResourcesForRemoval(resourceId); |
| 158 | 158 |
| 159 // Rebuild pending resources for each client of a pending resource that is b
eing removed. | 159 // Rebuild pending resources for each client of a pending resource that is b
eing removed. |
| 160 while (Element* clientElement = extensions->removeElementFromPendingResource
sForRemoval(resourceId)) { | 160 while (Element* clientElement = extensions.removeElementFromPendingResources
ForRemoval(resourceId)) { |
| 161 ASSERT(clientElement->hasPendingResources()); | 161 ASSERT(clientElement->hasPendingResources()); |
| 162 if (clientElement->hasPendingResources()) { | 162 if (clientElement->hasPendingResources()) { |
| 163 clientElement->buildPendingResource(); | 163 clientElement->buildPendingResource(); |
| 164 extensions->clearHasPendingResourcesIfPossible(clientElement); | 164 extensions.clearHasPendingResourcesIfPossible(clientElement); |
| 165 } | 165 } |
| 166 } | 166 } |
| 167 } | 167 } |
| 168 | 168 |
| 169 bool SVGElement::rendererIsNeeded(const RenderStyle& style) | 169 bool SVGElement::rendererIsNeeded(const RenderStyle& style) |
| 170 { | 170 { |
| 171 // http://www.w3.org/TR/SVG/extend.html#PrivateData | 171 // http://www.w3.org/TR/SVG/extend.html#PrivateData |
| 172 // Prevent anything other than SVG renderers from appearing in our render tr
ee | 172 // Prevent anything other than SVG renderers from appearing in our render tr
ee |
| 173 // Spec: SVG allows inclusion of elements from foreign namespaces anywhere | 173 // Spec: SVG allows inclusion of elements from foreign namespaces anywhere |
| 174 // with the SVG content. In general, the SVG user agent will include the unk
nown | 174 // with the SVG content. In general, the SVG user agent will include the unk
nown |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 // This is true whenever this is the outermost SVG, even if there are HTML e
lements outside it | 219 // This is true whenever this is the outermost SVG, even if there are HTML e
lements outside it |
| 220 return !parentNode()->isSVGElement(); | 220 return !parentNode()->isSVGElement(); |
| 221 } | 221 } |
| 222 | 222 |
| 223 void SVGElement::reportAttributeParsingError(SVGParsingError error, const Qualif
iedName& name, const AtomicString& value) | 223 void SVGElement::reportAttributeParsingError(SVGParsingError error, const Qualif
iedName& name, const AtomicString& value) |
| 224 { | 224 { |
| 225 if (error == NoError) | 225 if (error == NoError) |
| 226 return; | 226 return; |
| 227 | 227 |
| 228 String errorString = "<" + tagName() + "> attribute " + name.toString() + "=
\"" + value + "\""; | 228 String errorString = "<" + tagName() + "> attribute " + name.toString() + "=
\"" + value + "\""; |
| 229 SVGDocumentExtensions* extensions = document().accessSVGExtensions(); | 229 SVGDocumentExtensions& extensions = document().accessSVGExtensions(); |
| 230 | 230 |
| 231 if (error == NegativeValueForbiddenError) { | 231 if (error == NegativeValueForbiddenError) { |
| 232 extensions->reportError("Invalid negative value for " + errorString); | 232 extensions.reportError("Invalid negative value for " + errorString); |
| 233 return; | 233 return; |
| 234 } | 234 } |
| 235 | 235 |
| 236 if (error == ParsingAttributeFailedError) { | 236 if (error == ParsingAttributeFailedError) { |
| 237 extensions->reportError("Invalid value for " + errorString); | 237 extensions.reportError("Invalid value for " + errorString); |
| 238 return; | 238 return; |
| 239 } | 239 } |
| 240 | 240 |
| 241 ASSERT_NOT_REACHED(); | 241 ASSERT_NOT_REACHED(); |
| 242 } | 242 } |
| 243 | 243 |
| 244 String SVGElement::title() const | 244 String SVGElement::title() const |
| 245 { | 245 { |
| 246 // According to spec, we should not return titles when hovering over root <s
vg> elements (those | 246 // According to spec, we should not return titles when hovering over root <s
vg> elements (those |
| 247 // <title> elements are the title of the document, not a tooltip) so we inst
antly return. | 247 // <title> elements are the title of the document, not a tooltip) so we inst
antly return. |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 } | 368 } |
| 369 | 369 |
| 370 m_elementsWithRelativeLengths.clear(); | 370 m_elementsWithRelativeLengths.clear(); |
| 371 } | 371 } |
| 372 | 372 |
| 373 ASSERT_WITH_SECURITY_IMPLICATION(!rootParent->isSVGElement() || !toSVGElemen
t(rootParent)->m_elementsWithRelativeLengths.contains(this)); | 373 ASSERT_WITH_SECURITY_IMPLICATION(!rootParent->isSVGElement() || !toSVGElemen
t(rootParent)->m_elementsWithRelativeLengths.contains(this)); |
| 374 | 374 |
| 375 Element::removedFrom(rootParent); | 375 Element::removedFrom(rootParent); |
| 376 | 376 |
| 377 if (wasInDocument) { | 377 if (wasInDocument) { |
| 378 document().accessSVGExtensions()->rebuildAllElementReferencesForTarget(t
his); | 378 document().accessSVGExtensions().rebuildAllElementReferencesForTarget(th
is); |
| 379 document().accessSVGExtensions()->removeAllElementReferencesForTarget(th
is); | 379 document().accessSVGExtensions().removeAllElementReferencesForTarget(thi
s); |
| 380 } | 380 } |
| 381 | 381 |
| 382 SVGElementInstance::invalidateAllInstancesOfElement(this); | 382 SVGElementInstance::invalidateAllInstancesOfElement(this); |
| 383 } | 383 } |
| 384 | 384 |
| 385 void SVGElement::childrenChanged(bool changedByParser, Node* beforeChange, Node*
afterChange, int childCountDelta) | 385 void SVGElement::childrenChanged(bool changedByParser, Node* beforeChange, Node*
afterChange, int childCountDelta) |
| 386 { | 386 { |
| 387 Element::childrenChanged(changedByParser, beforeChange, afterChange, childCo
untDelta); | 387 Element::childrenChanged(changedByParser, beforeChange, afterChange, childCo
untDelta); |
| 388 | 388 |
| 389 // Invalidate all SVGElementInstances associated with us. | 389 // Invalidate all SVGElementInstances associated with us. |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 // If the relative length state hasn't changed, we can stop propagating
the notification. | 492 // If the relative length state hasn't changed, we can stop propagating
the notification. |
| 493 if (hadRelativeLengths == currentElement->hasRelativeLengths()) | 493 if (hadRelativeLengths == currentElement->hasRelativeLengths()) |
| 494 return; | 494 return; |
| 495 | 495 |
| 496 clientElement = currentElement; | 496 clientElement = currentElement; |
| 497 clientHasRelativeLengths = clientElement->hasRelativeLengths(); | 497 clientHasRelativeLengths = clientElement->hasRelativeLengths(); |
| 498 } | 498 } |
| 499 | 499 |
| 500 // Register root SVG elements for top level viewport change notifications. | 500 // Register root SVG elements for top level viewport change notifications. |
| 501 if (clientElement->isSVGSVGElement()) { | 501 if (clientElement->isSVGSVGElement()) { |
| 502 SVGDocumentExtensions* svgExtensions = accessDocumentSVGExtensions(); | 502 SVGDocumentExtensions& svgExtensions = accessDocumentSVGExtensions(); |
| 503 if (clientElement->hasRelativeLengths()) | 503 if (clientElement->hasRelativeLengths()) |
| 504 svgExtensions->addSVGRootWithRelativeLengthDescendents(toSVGSVGEleme
nt(clientElement)); | 504 svgExtensions.addSVGRootWithRelativeLengthDescendents(toSVGSVGElemen
t(clientElement)); |
| 505 else | 505 else |
| 506 svgExtensions->removeSVGRootWithRelativeLengthDescendents(toSVGSVGEl
ement(clientElement)); | 506 svgExtensions.removeSVGRootWithRelativeLengthDescendents(toSVGSVGEle
ment(clientElement)); |
| 507 } | 507 } |
| 508 } | 508 } |
| 509 | 509 |
| 510 void SVGElement::invalidateRelativeLengthClients(SubtreeLayoutScope* layoutScope
) | 510 void SVGElement::invalidateRelativeLengthClients(SubtreeLayoutScope* layoutScope
) |
| 511 { | 511 { |
| 512 if (!inDocument()) | 512 if (!inDocument()) |
| 513 return; | 513 return; |
| 514 | 514 |
| 515 ASSERT(!m_inRelativeLengthClientsInvalidation); | 515 ASSERT(!m_inRelativeLengthClientsInvalidation); |
| 516 #if !ASSERT_DISABLED | 516 #if !ASSERT_DISABLED |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 while (n) { | 553 while (n) { |
| 554 if (n->hasTagName(SVGNames::svgTag) || n->hasTagName(SVGNames::imageTag)
|| n->hasTagName(SVGNames::symbolTag)) | 554 if (n->hasTagName(SVGNames::svgTag) || n->hasTagName(SVGNames::imageTag)
|| n->hasTagName(SVGNames::symbolTag)) |
| 555 return toSVGElement(n); | 555 return toSVGElement(n); |
| 556 | 556 |
| 557 n = n->parentOrShadowHostNode(); | 557 n = n->parentOrShadowHostNode(); |
| 558 } | 558 } |
| 559 | 559 |
| 560 return 0; | 560 return 0; |
| 561 } | 561 } |
| 562 | 562 |
| 563 SVGDocumentExtensions* SVGElement::accessDocumentSVGExtensions() | 563 SVGDocumentExtensions& SVGElement::accessDocumentSVGExtensions() |
| 564 { | 564 { |
| 565 // This function is provided for use by SVGAnimatedProperty to avoid | 565 // This function is provided for use by SVGAnimatedProperty to avoid |
| 566 // global inclusion of core/dom/Document.h in SVG code. | 566 // global inclusion of core/dom/Document.h in SVG code. |
| 567 return document().accessSVGExtensions(); | 567 return document().accessSVGExtensions(); |
| 568 } | 568 } |
| 569 | 569 |
| 570 void SVGElement::mapInstanceToElement(SVGElementInstance* instance) | 570 void SVGElement::mapInstanceToElement(SVGElementInstance* instance) |
| 571 { | 571 { |
| 572 ASSERT(instance); | 572 ASSERT(instance); |
| 573 | 573 |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 950 // we send SVGLoad events here if we can, otherwise they'll be sent when any
required loads finish | 950 // we send SVGLoad events here if we can, otherwise they'll be sent when any
required loads finish |
| 951 if (isSVGSVGElement()) | 951 if (isSVGSVGElement()) |
| 952 sendSVGLoadEventIfPossible(); | 952 sendSVGLoadEventIfPossible(); |
| 953 } | 953 } |
| 954 | 954 |
| 955 void SVGElement::attributeChanged(const QualifiedName& name, const AtomicString&
newValue, AttributeModificationReason) | 955 void SVGElement::attributeChanged(const QualifiedName& name, const AtomicString&
newValue, AttributeModificationReason) |
| 956 { | 956 { |
| 957 Element::attributeChanged(name, newValue); | 957 Element::attributeChanged(name, newValue); |
| 958 | 958 |
| 959 if (isIdAttributeName(name)) | 959 if (isIdAttributeName(name)) |
| 960 document().accessSVGExtensions()->rebuildAllElementReferencesForTarget(t
his); | 960 document().accessSVGExtensions().rebuildAllElementReferencesForTarget(th
is); |
| 961 | 961 |
| 962 // Changes to the style attribute are processed lazily (see Element::getAttr
ibute() and related methods), | 962 // Changes to the style attribute are processed lazily (see Element::getAttr
ibute() and related methods), |
| 963 // so we don't want changes to the style attribute to result in extra work h
ere. | 963 // so we don't want changes to the style attribute to result in extra work h
ere. |
| 964 if (name != HTMLNames::styleAttr) | 964 if (name != HTMLNames::styleAttr) |
| 965 svgAttributeChanged(name); | 965 svgAttributeChanged(name); |
| 966 } | 966 } |
| 967 | 967 |
| 968 void SVGElement::svgAttributeChanged(const QualifiedName& attrName) | 968 void SVGElement::svgAttributeChanged(const QualifiedName& attrName) |
| 969 { | 969 { |
| 970 CSSPropertyID propId = SVGElement::cssPropertyIdForSVGAttributeName(attrName
); | 970 CSSPropertyID propId = SVGElement::cssPropertyIdForSVGAttributeName(attrName
); |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1191 animatableAttributes.add(SVGNames::zAttr); | 1191 animatableAttributes.add(SVGNames::zAttr); |
| 1192 } | 1192 } |
| 1193 | 1193 |
| 1194 if (name == classAttr) | 1194 if (name == classAttr) |
| 1195 return true; | 1195 return true; |
| 1196 | 1196 |
| 1197 return animatableAttributes.contains(name); | 1197 return animatableAttributes.contains(name); |
| 1198 } | 1198 } |
| 1199 #endif | 1199 #endif |
| 1200 } | 1200 } |
| OLD | NEW |