| 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 29 matching lines...) Expand all Loading... |
| 40 #include "core/rendering/RenderObject.h" | 40 #include "core/rendering/RenderObject.h" |
| 41 #include "core/rendering/svg/RenderSVGResourceContainer.h" | 41 #include "core/rendering/svg/RenderSVGResourceContainer.h" |
| 42 #include "core/svg/SVGCursorElement.h" | 42 #include "core/svg/SVGCursorElement.h" |
| 43 #include "core/svg/SVGDocumentExtensions.h" | 43 #include "core/svg/SVGDocumentExtensions.h" |
| 44 #include "core/svg/SVGElementInstance.h" | 44 #include "core/svg/SVGElementInstance.h" |
| 45 #include "core/svg/SVGElementRareData.h" | 45 #include "core/svg/SVGElementRareData.h" |
| 46 #include "core/svg/SVGGraphicsElement.h" | 46 #include "core/svg/SVGGraphicsElement.h" |
| 47 #include "core/svg/SVGSVGElement.h" | 47 #include "core/svg/SVGSVGElement.h" |
| 48 #include "core/svg/SVGUseElement.h" | 48 #include "core/svg/SVGUseElement.h" |
| 49 | 49 |
| 50 #include "wtf/TemporaryChange.h" |
| 51 |
| 50 namespace WebCore { | 52 namespace WebCore { |
| 51 | 53 |
| 52 // Animated property definitions | 54 // Animated property definitions |
| 53 DEFINE_ANIMATED_STRING(SVGElement, HTMLNames::classAttr, ClassName, className) | 55 DEFINE_ANIMATED_STRING(SVGElement, HTMLNames::classAttr, ClassName, className) |
| 54 | 56 |
| 55 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGElement) | 57 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGElement) |
| 56 REGISTER_LOCAL_ANIMATED_PROPERTY(className) | 58 REGISTER_LOCAL_ANIMATED_PROPERTY(className) |
| 57 END_REGISTER_ANIMATED_PROPERTIES | 59 END_REGISTER_ANIMATED_PROPERTIES |
| 58 | 60 |
| 59 using namespace HTMLNames; | 61 using namespace HTMLNames; |
| 60 using namespace SVGNames; | 62 using namespace SVGNames; |
| 61 | 63 |
| 62 void mapAttributeToCSSProperty(HashMap<StringImpl*, CSSPropertyID>* propertyName
ToIdMap, const QualifiedName& attrName) | 64 void mapAttributeToCSSProperty(HashMap<StringImpl*, CSSPropertyID>* propertyName
ToIdMap, const QualifiedName& attrName) |
| 63 { | 65 { |
| 64 // FIXME: when CSS supports "transform-origin" the special case for transfor
m_originAttr can be removed. | 66 // FIXME: when CSS supports "transform-origin" the special case for transfor
m_originAttr can be removed. |
| 65 CSSPropertyID propertyId = cssPropertyID(attrName.localName()); | 67 CSSPropertyID propertyId = cssPropertyID(attrName.localName()); |
| 66 if (!propertyId && attrName == transform_originAttr) | 68 if (!propertyId && attrName == transform_originAttr) |
| 67 propertyId = CSSPropertyWebkitTransformOrigin; // cssPropertyID("-webkit
-transform-origin") | 69 propertyId = CSSPropertyWebkitTransformOrigin; // cssPropertyID("-webkit
-transform-origin") |
| 68 ASSERT(propertyId > 0); | 70 ASSERT(propertyId > 0); |
| 69 propertyNameToIdMap->set(attrName.localName().impl(), propertyId); | 71 propertyNameToIdMap->set(attrName.localName().impl(), propertyId); |
| 70 } | 72 } |
| 71 | 73 |
| 72 SVGElement::SVGElement(const QualifiedName& tagName, Document& document, Constru
ctionType constructionType) | 74 SVGElement::SVGElement(const QualifiedName& tagName, Document& document, Constru
ctionType constructionType) |
| 73 : Element(tagName, &document, constructionType) | 75 : Element(tagName, &document, constructionType) |
| 76 #if !ASSERT_DISABLED |
| 77 , m_inRelativeLengthClientsInvalidation(false) |
| 78 #endif |
| 74 { | 79 { |
| 75 ScriptWrappable::init(this); | 80 ScriptWrappable::init(this); |
| 76 registerAnimatedPropertiesForSVGElement(); | 81 registerAnimatedPropertiesForSVGElement(); |
| 77 setHasCustomStyleCallbacks(); | 82 setHasCustomStyleCallbacks(); |
| 78 } | 83 } |
| 79 | 84 |
| 80 SVGElement::~SVGElement() | 85 SVGElement::~SVGElement() |
| 81 { | 86 { |
| 82 if (!hasSVGRareData()) | 87 if (!hasSVGRareData()) |
| 83 ASSERT(!SVGElementRareData::rareDataMap().contains(this)); | 88 ASSERT(!SVGElementRareData::rareDataMap().contains(this)); |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 { | 449 { |
| 445 // If we're not yet in a document, this function will be called again from i
nsertedInto(). Do nothing now. | 450 // If we're not yet in a document, this function will be called again from i
nsertedInto(). Do nothing now. |
| 446 if (!inDocument()) | 451 if (!inDocument()) |
| 447 return; | 452 return; |
| 448 | 453 |
| 449 // An element wants to notify us that its own relative lengths state changed
. | 454 // An element wants to notify us that its own relative lengths state changed
. |
| 450 // Register it in the relative length map, and register us in the parent rel
ative length map. | 455 // Register it in the relative length map, and register us in the parent rel
ative length map. |
| 451 // Register the parent in the grandparents map, etc. Repeat procedure until
the root of the SVG tree. | 456 // Register the parent in the grandparents map, etc. Repeat procedure until
the root of the SVG tree. |
| 452 for (ContainerNode* currentNode = this; currentNode && currentNode->isSVGEle
ment(); currentNode = currentNode->parentNode()) { | 457 for (ContainerNode* currentNode = this; currentNode && currentNode->isSVGEle
ment(); currentNode = currentNode->parentNode()) { |
| 453 SVGElement* currentElement = toSVGElement(currentNode); | 458 SVGElement* currentElement = toSVGElement(currentNode); |
| 459 ASSERT(!currentElement->m_inRelativeLengthClientsInvalidation); |
| 454 | 460 |
| 455 bool hadRelativeLengths = currentElement->hasRelativeLengths(); | 461 bool hadRelativeLengths = currentElement->hasRelativeLengths(); |
| 456 if (clientHasRelativeLengths) | 462 if (clientHasRelativeLengths) |
| 457 currentElement->m_elementsWithRelativeLengths.add(clientElement); | 463 currentElement->m_elementsWithRelativeLengths.add(clientElement); |
| 458 else | 464 else |
| 459 currentElement->m_elementsWithRelativeLengths.remove(clientElement); | 465 currentElement->m_elementsWithRelativeLengths.remove(clientElement); |
| 460 | 466 |
| 461 // If the relative length state hasn't changed, we can stop propagating
the notfication. | 467 // If the relative length state hasn't changed, we can stop propagating
the notfication. |
| 462 if (hadRelativeLengths == currentElement->hasRelativeLengths()) | 468 if (hadRelativeLengths == currentElement->hasRelativeLengths()) |
| 463 break; | 469 break; |
| 464 | 470 |
| 465 clientElement = currentElement; | 471 clientElement = currentElement; |
| 466 clientHasRelativeLengths = clientElement->hasRelativeLengths(); | 472 clientHasRelativeLengths = clientElement->hasRelativeLengths(); |
| 467 } | 473 } |
| 468 } | 474 } |
| 469 | 475 |
| 476 void SVGElement::invalidateRelativeLengthClients(SubtreeLayoutScope* layoutScope
) |
| 477 { |
| 478 if (!inDocument()) |
| 479 return; |
| 480 |
| 481 ASSERT(!m_inRelativeLengthClientsInvalidation); |
| 482 #if !ASSERT_DISABLED |
| 483 TemporaryChange<bool> inRelativeLengthClientsInvalidationChange(m_inRelative
LengthClientsInvalidation, true); |
| 484 #endif |
| 485 |
| 486 HashSet<SVGElement*>::iterator end = m_elementsWithRelativeLengths.end(); |
| 487 for (HashSet<SVGElement*>::iterator it = m_elementsWithRelativeLengths.begin
(); it != end; ++it) { |
| 488 if (*it == this) |
| 489 continue; |
| 490 |
| 491 if ((*it)->renderer() && (*it)->selfHasRelativeLengths()) |
| 492 (*it)->renderer()->setNeedsLayout(MarkContainingBlockChain, layoutSc
ope); |
| 493 |
| 494 (*it)->invalidateRelativeLengthClients(layoutScope); |
| 495 } |
| 496 } |
| 497 |
| 470 SVGSVGElement* SVGElement::ownerSVGElement() const | 498 SVGSVGElement* SVGElement::ownerSVGElement() const |
| 471 { | 499 { |
| 472 ContainerNode* n = parentOrShadowHostNode(); | 500 ContainerNode* n = parentOrShadowHostNode(); |
| 473 while (n) { | 501 while (n) { |
| 474 if (n->hasTagName(SVGNames::svgTag)) | 502 if (n->hasTagName(SVGNames::svgTag)) |
| 475 return toSVGSVGElement(n); | 503 return toSVGSVGElement(n); |
| 476 | 504 |
| 477 n = n->parentOrShadowHostNode(); | 505 n = n->parentOrShadowHostNode(); |
| 478 } | 506 } |
| 479 | 507 |
| (...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1139 } | 1167 } |
| 1140 | 1168 |
| 1141 if (name == classAttr) | 1169 if (name == classAttr) |
| 1142 return true; | 1170 return true; |
| 1143 | 1171 |
| 1144 return animatableAttributes.contains(name); | 1172 return animatableAttributes.contains(name); |
| 1145 } | 1173 } |
| 1146 #endif | 1174 #endif |
| 1147 | 1175 |
| 1148 } | 1176 } |
| OLD | NEW |