| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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" | 50 #include "wtf/TemporaryChange.h" |
| 51 | 51 |
| 52 namespace WebCore { | 52 namespace WebCore { |
| 53 | 53 |
| 54 // Animated property definitions | 54 // Animated property definitions |
| 55 DEFINE_ANIMATED_STRING(SVGElement, HTMLNames::classAttr, ClassName, className) | |
| 56 | 55 |
| 57 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGElement) | 56 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGElement) |
| 58 REGISTER_LOCAL_ANIMATED_PROPERTY(className) | |
| 59 END_REGISTER_ANIMATED_PROPERTIES | 57 END_REGISTER_ANIMATED_PROPERTIES |
| 60 | 58 |
| 61 using namespace HTMLNames; | 59 using namespace HTMLNames; |
| 62 using namespace SVGNames; | 60 using namespace SVGNames; |
| 63 | 61 |
| 64 void mapAttributeToCSSProperty(HashMap<StringImpl*, CSSPropertyID>* propertyName
ToIdMap, const QualifiedName& attrName) | 62 void mapAttributeToCSSProperty(HashMap<StringImpl*, CSSPropertyID>* propertyName
ToIdMap, const QualifiedName& attrName) |
| 65 { | 63 { |
| 66 // FIXME: when CSS supports "transform-origin" the special case for transfor
m_originAttr can be removed. | 64 // FIXME: when CSS supports "transform-origin" the special case for transfor
m_originAttr can be removed. |
| 67 CSSPropertyID propertyId = cssPropertyID(attrName.localName()); | 65 CSSPropertyID propertyId = cssPropertyID(attrName.localName()); |
| 68 if (!propertyId && attrName == transform_originAttr) | 66 if (!propertyId && attrName == transform_originAttr) |
| 69 propertyId = CSSPropertyWebkitTransformOrigin; // cssPropertyID("-webkit
-transform-origin") | 67 propertyId = CSSPropertyWebkitTransformOrigin; // cssPropertyID("-webkit
-transform-origin") |
| 70 ASSERT(propertyId > 0); | 68 ASSERT(propertyId > 0); |
| 71 propertyNameToIdMap->set(attrName.localName().impl(), propertyId); | 69 propertyNameToIdMap->set(attrName.localName().impl(), propertyId); |
| 72 } | 70 } |
| 73 | 71 |
| 74 SVGElement::SVGElement(const QualifiedName& tagName, Document& document, Constru
ctionType constructionType) | 72 SVGElement::SVGElement(const QualifiedName& tagName, Document& document, Constru
ctionType constructionType) |
| 75 : Element(tagName, &document, constructionType) | 73 : Element(tagName, &document, constructionType) |
| 74 , m_className(SVGAnimatedString::create(this, HTMLNames::classAttr, SVGStrin
g::create())) |
| 76 #if !ASSERT_DISABLED | 75 #if !ASSERT_DISABLED |
| 77 , m_inRelativeLengthClientsInvalidation(false) | 76 , m_inRelativeLengthClientsInvalidation(false) |
| 78 #endif | 77 #endif |
| 79 , m_animatedPropertiesDestructed(false) | 78 , m_animatedPropertiesDestructed(false) |
| 80 , m_isContextElement(false) | 79 , m_isContextElement(false) |
| 81 , m_hasSVGRareData(false) | 80 , m_hasSVGRareData(false) |
| 82 { | 81 { |
| 83 ScriptWrappable::init(this); | 82 ScriptWrappable::init(this); |
| 83 addToPropertyMap(m_className); |
| 84 registerAnimatedPropertiesForSVGElement(); | 84 registerAnimatedPropertiesForSVGElement(); |
| 85 setHasCustomStyleCallbacks(); | 85 setHasCustomStyleCallbacks(); |
| 86 } | 86 } |
| 87 | 87 |
| 88 SVGElement::~SVGElement() | 88 SVGElement::~SVGElement() |
| 89 { | 89 { |
| 90 ASSERT(inDocument() || !hasRelativeLengths()); | 90 ASSERT(inDocument() || !hasRelativeLengths()); |
| 91 } | 91 } |
| 92 | 92 |
| 93 void | 93 void |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 ensureSVGRareData()->setCorrespondingElement(correspondingElement); | 650 ensureSVGRareData()->setCorrespondingElement(correspondingElement); |
| 651 } | 651 } |
| 652 | 652 |
| 653 void SVGElement::parseAttribute(const QualifiedName& name, const AtomicString& v
alue) | 653 void SVGElement::parseAttribute(const QualifiedName& name, const AtomicString& v
alue) |
| 654 { | 654 { |
| 655 if (name == HTMLNames::classAttr) { | 655 if (name == HTMLNames::classAttr) { |
| 656 // SVG animation has currently requires special storage of values so we
set | 656 // SVG animation has currently requires special storage of values so we
set |
| 657 // the className here. svgAttributeChanged actually causes the resulting | 657 // the className here. svgAttributeChanged actually causes the resulting |
| 658 // style updates (instead of Element::parseAttribute). We don't | 658 // style updates (instead of Element::parseAttribute). We don't |
| 659 // tell Element about the change to avoid parsing the class list twice | 659 // tell Element about the change to avoid parsing the class list twice |
| 660 setClassNameBaseValue(value); | 660 SVGParsingError parseError = NoError; |
| 661 m_className->setBaseValueAsString(value, parseError); |
| 662 reportAttributeParsingError(parseError, name, value); |
| 661 } else if (name.matches(XMLNames::langAttr) || name.matches(XMLNames::spaceA
ttr)) { | 663 } else if (name.matches(XMLNames::langAttr) || name.matches(XMLNames::spaceA
ttr)) { |
| 662 } else { | 664 } else { |
| 663 // standard events | 665 // standard events |
| 664 const AtomicString& eventName = HTMLElement::eventNameForAttributeName(n
ame); | 666 const AtomicString& eventName = HTMLElement::eventNameForAttributeName(n
ame); |
| 665 if (!eventName.isNull()) | 667 if (!eventName.isNull()) |
| 666 setAttributeEventListener(eventName, createAttributeEventListener(th
is, name, value)); | 668 setAttributeEventListener(eventName, createAttributeEventListener(th
is, name, value)); |
| 667 else | 669 else |
| 668 Element::parseAttribute(name, value); | 670 Element::parseAttribute(name, value); |
| 669 } | 671 } |
| 670 } | 672 } |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 962 | 964 |
| 963 void SVGElement::svgAttributeChanged(const QualifiedName& attrName) | 965 void SVGElement::svgAttributeChanged(const QualifiedName& attrName) |
| 964 { | 966 { |
| 965 CSSPropertyID propId = SVGElement::cssPropertyIdForSVGAttributeName(attrName
); | 967 CSSPropertyID propId = SVGElement::cssPropertyIdForSVGAttributeName(attrName
); |
| 966 if (propId > 0) { | 968 if (propId > 0) { |
| 967 SVGElementInstance::invalidateAllInstancesOfElement(this); | 969 SVGElementInstance::invalidateAllInstancesOfElement(this); |
| 968 return; | 970 return; |
| 969 } | 971 } |
| 970 | 972 |
| 971 if (attrName == HTMLNames::classAttr) { | 973 if (attrName == HTMLNames::classAttr) { |
| 972 classAttributeChanged(AtomicString(classNameCurrentValue())); | 974 classAttributeChanged(AtomicString(m_className->currentValue()->value())
); |
| 973 SVGElementInstance::invalidateAllInstancesOfElement(this); | 975 SVGElementInstance::invalidateAllInstancesOfElement(this); |
| 974 return; | 976 return; |
| 975 } | 977 } |
| 976 | 978 |
| 977 if (isIdAttributeName(attrName)) { | 979 if (isIdAttributeName(attrName)) { |
| 978 RenderObject* object = renderer(); | 980 RenderObject* object = renderer(); |
| 979 // Notify resources about id changes, this is important as we cache reso
urces by id in SVGDocumentExtensions | 981 // Notify resources about id changes, this is important as we cache reso
urces by id in SVGDocumentExtensions |
| 980 if (object && object->isSVGResourceContainer()) | 982 if (object && object->isSVGResourceContainer()) |
| 981 toRenderSVGResourceContainer(object)->idChanged(); | 983 toRenderSVGResourceContainer(object)->idChanged(); |
| 982 if (inDocument()) | 984 if (inDocument()) |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1186 animatableAttributes.add(SVGNames::zAttr); | 1188 animatableAttributes.add(SVGNames::zAttr); |
| 1187 } | 1189 } |
| 1188 | 1190 |
| 1189 if (name == classAttr) | 1191 if (name == classAttr) |
| 1190 return true; | 1192 return true; |
| 1191 | 1193 |
| 1192 return animatableAttributes.contains(name); | 1194 return animatableAttributes.contains(name); |
| 1193 } | 1195 } |
| 1194 #endif | 1196 #endif |
| 1195 } | 1197 } |
| OLD | NEW |