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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #include "core/svg/SVGElementRareData.h" | 44 #include "core/svg/SVGElementRareData.h" |
45 #include "core/svg/SVGGraphicsElement.h" | 45 #include "core/svg/SVGGraphicsElement.h" |
46 #include "core/svg/SVGSVGElement.h" | 46 #include "core/svg/SVGSVGElement.h" |
47 #include "core/svg/SVGUseElement.h" | 47 #include "core/svg/SVGUseElement.h" |
48 | 48 |
49 #include "wtf/TemporaryChange.h" | 49 #include "wtf/TemporaryChange.h" |
50 | 50 |
51 namespace WebCore { | 51 namespace WebCore { |
52 | 52 |
53 // Animated property definitions | 53 // Animated property definitions |
54 DEFINE_ANIMATED_STRING(SVGElement, HTMLNames::classAttr, ClassName, className) | |
55 | 54 |
56 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGElement) | 55 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGElement) |
57 REGISTER_LOCAL_ANIMATED_PROPERTY(className) | |
58 END_REGISTER_ANIMATED_PROPERTIES | 56 END_REGISTER_ANIMATED_PROPERTIES |
59 | 57 |
60 using namespace HTMLNames; | 58 using namespace HTMLNames; |
61 using namespace SVGNames; | 59 using namespace SVGNames; |
62 | 60 |
63 void mapAttributeToCSSProperty(HashMap<StringImpl*, CSSPropertyID>* propertyName
ToIdMap, const QualifiedName& attrName) | 61 void mapAttributeToCSSProperty(HashMap<StringImpl*, CSSPropertyID>* propertyName
ToIdMap, const QualifiedName& attrName) |
64 { | 62 { |
65 // FIXME: when CSS supports "transform-origin" the special case for transfor
m_originAttr can be removed. | 63 // FIXME: when CSS supports "transform-origin" the special case for transfor
m_originAttr can be removed. |
66 CSSPropertyID propertyId = cssPropertyID(attrName.localName()); | 64 CSSPropertyID propertyId = cssPropertyID(attrName.localName()); |
67 if (!propertyId && attrName == transform_originAttr) | 65 if (!propertyId && attrName == transform_originAttr) |
68 propertyId = CSSPropertyWebkitTransformOrigin; // cssPropertyID("-webkit
-transform-origin") | 66 propertyId = CSSPropertyWebkitTransformOrigin; // cssPropertyID("-webkit
-transform-origin") |
69 ASSERT(propertyId > 0); | 67 ASSERT(propertyId > 0); |
70 propertyNameToIdMap->set(attrName.localName().impl(), propertyId); | 68 propertyNameToIdMap->set(attrName.localName().impl(), propertyId); |
71 } | 69 } |
72 | 70 |
73 SVGElement::SVGElement(const QualifiedName& tagName, Document& document, Constru
ctionType constructionType) | 71 SVGElement::SVGElement(const QualifiedName& tagName, Document& document, Constru
ctionType constructionType) |
74 : Element(tagName, &document, constructionType) | 72 : Element(tagName, &document, constructionType) |
| 73 , m_className(SVGAnimatedString::create(this, HTMLNames::classAttr, SVGStrin
g::create())) |
75 #if !ASSERT_DISABLED | 74 #if !ASSERT_DISABLED |
76 , m_inRelativeLengthClientsInvalidation(false) | 75 , m_inRelativeLengthClientsInvalidation(false) |
77 #endif | 76 #endif |
78 , m_animatedPropertiesDestructed(false) | 77 , m_animatedPropertiesDestructed(false) |
79 , m_isContextElement(false) | 78 , m_isContextElement(false) |
80 , m_hasSVGRareData(false) | 79 , m_hasSVGRareData(false) |
81 { | 80 { |
82 ScriptWrappable::init(this); | 81 ScriptWrappable::init(this); |
| 82 addToPropertyMap(m_className); |
83 registerAnimatedPropertiesForSVGElement(); | 83 registerAnimatedPropertiesForSVGElement(); |
84 setHasCustomStyleCallbacks(); | 84 setHasCustomStyleCallbacks(); |
85 } | 85 } |
86 | 86 |
87 SVGElement::~SVGElement() | 87 SVGElement::~SVGElement() |
88 { | 88 { |
89 ASSERT(inDocument() || !hasRelativeLengths()); | 89 ASSERT(inDocument() || !hasRelativeLengths()); |
90 } | 90 } |
91 | 91 |
92 void | 92 void |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 setAttributeEventListener(EventTypeNames::focusin, createAttributeEventL
istener(this, name, value)); | 674 setAttributeEventListener(EventTypeNames::focusin, createAttributeEventL
istener(this, name, value)); |
675 else if (name == SVGNames::onfocusoutAttr) | 675 else if (name == SVGNames::onfocusoutAttr) |
676 setAttributeEventListener(EventTypeNames::focusout, createAttributeEvent
Listener(this, name, value)); | 676 setAttributeEventListener(EventTypeNames::focusout, createAttributeEvent
Listener(this, name, value)); |
677 else if (name == SVGNames::onactivateAttr) | 677 else if (name == SVGNames::onactivateAttr) |
678 setAttributeEventListener(EventTypeNames::DOMActivate, createAttributeEv
entListener(this, name, value)); | 678 setAttributeEventListener(EventTypeNames::DOMActivate, createAttributeEv
entListener(this, name, value)); |
679 else if (name == HTMLNames::classAttr) { | 679 else if (name == HTMLNames::classAttr) { |
680 // SVG animation has currently requires special storage of values so we
set | 680 // SVG animation has currently requires special storage of values so we
set |
681 // the className here. svgAttributeChanged actually causes the resulting | 681 // the className here. svgAttributeChanged actually causes the resulting |
682 // style updates (instead of Element::parseAttribute). We don't | 682 // style updates (instead of Element::parseAttribute). We don't |
683 // tell Element about the change to avoid parsing the class list twice | 683 // tell Element about the change to avoid parsing the class list twice |
684 setClassNameBaseValue(value); | 684 SVGParsingError parseError = NoError; |
| 685 m_className->setBaseValueAsString(value, parseError); |
| 686 reportAttributeParsingError(parseError, name, value); |
685 } else if (name == ontouchstartAttr) { | 687 } else if (name == ontouchstartAttr) { |
686 setAttributeEventListener(EventTypeNames::touchstart, createAttributeEve
ntListener(this, name, value)); | 688 setAttributeEventListener(EventTypeNames::touchstart, createAttributeEve
ntListener(this, name, value)); |
687 } else if (name == ontouchmoveAttr) { | 689 } else if (name == ontouchmoveAttr) { |
688 setAttributeEventListener(EventTypeNames::touchmove, createAttributeEven
tListener(this, name, value)); | 690 setAttributeEventListener(EventTypeNames::touchmove, createAttributeEven
tListener(this, name, value)); |
689 } else if (name == ontouchendAttr) { | 691 } else if (name == ontouchendAttr) { |
690 setAttributeEventListener(EventTypeNames::touchend, createAttributeEvent
Listener(this, name, value)); | 692 setAttributeEventListener(EventTypeNames::touchend, createAttributeEvent
Listener(this, name, value)); |
691 } else if (name == ontouchcancelAttr) { | 693 } else if (name == ontouchcancelAttr) { |
692 setAttributeEventListener(EventTypeNames::touchcancel, createAttributeEv
entListener(this, name, value)); | 694 setAttributeEventListener(EventTypeNames::touchcancel, createAttributeEv
entListener(this, name, value)); |
693 } else if (name.matches(XMLNames::langAttr) || name.matches(XMLNames::spaceA
ttr)) { | 695 } else if (name.matches(XMLNames::langAttr) || name.matches(XMLNames::spaceA
ttr)) { |
694 } else { | 696 } else { |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
989 | 991 |
990 void SVGElement::svgAttributeChanged(const QualifiedName& attrName) | 992 void SVGElement::svgAttributeChanged(const QualifiedName& attrName) |
991 { | 993 { |
992 CSSPropertyID propId = SVGElement::cssPropertyIdForSVGAttributeName(attrName
); | 994 CSSPropertyID propId = SVGElement::cssPropertyIdForSVGAttributeName(attrName
); |
993 if (propId > 0) { | 995 if (propId > 0) { |
994 SVGElementInstance::invalidateAllInstancesOfElement(this); | 996 SVGElementInstance::invalidateAllInstancesOfElement(this); |
995 return; | 997 return; |
996 } | 998 } |
997 | 999 |
998 if (attrName == HTMLNames::classAttr) { | 1000 if (attrName == HTMLNames::classAttr) { |
999 classAttributeChanged(AtomicString(classNameCurrentValue())); | 1001 classAttributeChanged(AtomicString(m_className->currentValue()->value())
); |
1000 SVGElementInstance::invalidateAllInstancesOfElement(this); | 1002 SVGElementInstance::invalidateAllInstancesOfElement(this); |
1001 return; | 1003 return; |
1002 } | 1004 } |
1003 | 1005 |
1004 if (isIdAttributeName(attrName)) { | 1006 if (isIdAttributeName(attrName)) { |
1005 RenderObject* object = renderer(); | 1007 RenderObject* object = renderer(); |
1006 // Notify resources about id changes, this is important as we cache reso
urces by id in SVGDocumentExtensions | 1008 // Notify resources about id changes, this is important as we cache reso
urces by id in SVGDocumentExtensions |
1007 if (object && object->isSVGResourceContainer()) | 1009 if (object && object->isSVGResourceContainer()) |
1008 toRenderSVGResourceContainer(object)->idChanged(); | 1010 toRenderSVGResourceContainer(object)->idChanged(); |
1009 if (inDocument()) | 1011 if (inDocument()) |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1213 animatableAttributes.add(SVGNames::zAttr); | 1215 animatableAttributes.add(SVGNames::zAttr); |
1214 } | 1216 } |
1215 | 1217 |
1216 if (name == classAttr) | 1218 if (name == classAttr) |
1217 return true; | 1219 return true; |
1218 | 1220 |
1219 return animatableAttributes.contains(name); | 1221 return animatableAttributes.contains(name); |
1220 } | 1222 } |
1221 #endif | 1223 #endif |
1222 } | 1224 } |
OLD | NEW |