Changeset 35248

Show
Ignore:
Timestamp:
07/19/08 08:46:48 (4 months ago)
Author:
zimmermann@webkit.org
Message:

Reviewed by Oliver & parts by Eric.

Fixes: https://bugs.webkit.org/show_bug.cgi?id=20051

Rewrite animated property concept without heavy macro usage, replace by a templatified solution.
Fewer virtual function calls, no more usage of the tear-off's within internal code (synchronization needed it before.)

Location:
trunk/WebCore
Files:
1 added
116 modified

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r35244 r35248  
     12008-07-19  Nikolas Zimmermann  <zimmermann@kde.org> 
     2 
     3        Reviewed by Oliver & parts by Eric. 
     4 
     5        Fixes: https://bugs.webkit.org/show_bug.cgi?id=20051 
     6 
     7        Rewrite animated property concept without heavy macro usage, replace by a templatified solution. 
     8        Fewer virtual function calls, no more usage of the tear-off's within internal code (synchronization needed it before.) 
     9 
     10        * dom/Element.cpp: 
     11        (WebCore::Element::attributes): 
     12        (WebCore::Element::getAttribute): 
     13        (WebCore::Element::hasAttributes): 
     14        * dom/Element.h: 
     15        (WebCore::Element::updateAnimatedSVGAttribute): Take const String&, not StringImpl*. 
     16        * svg/SVGAElement.cpp: 
     17        (WebCore::SVGAElement::SVGAElement): 
     18        * svg/SVGAElement.h: 
     19        * svg/SVGAltGlyphElement.h: 
     20        * svg/SVGAnimatedProperty.h: Added. 
     21        * svg/SVGAnimatedTemplate.h: 
     22        (WebCore::lookupOrCreateWrapper): 
     23        * svg/SVGAnimationElement.h: 
     24        * svg/SVGCircleElement.cpp: 
     25        (WebCore::SVGCircleElement::SVGCircleElement): 
     26        * svg/SVGCircleElement.h: 
     27        * svg/SVGClipPathElement.cpp: 
     28        (WebCore::SVGClipPathElement::SVGClipPathElement): 
     29        * svg/SVGClipPathElement.h: 
     30        * svg/SVGComponentTransferFunctionElement.cpp: 
     31        (WebCore::SVGComponentTransferFunctionElement::SVGComponentTransferFunctionElement): 
     32        * svg/SVGComponentTransferFunctionElement.h: 
     33        * svg/SVGCursorElement.cpp: 
     34        (WebCore::SVGCursorElement::SVGCursorElement): 
     35        * svg/SVGCursorElement.h: 
     36        * svg/SVGDefsElement.h: 
     37        (WebCore::SVGDefsElement::contextElement): 
     38        * svg/SVGElement.cpp: 
     39        (WebCore::SVGElement::updateAnimatedSVGAttribute): 
     40        * svg/SVGElement.h: 
     41        (WebCore::SVGElement::supplementalTransform): 
     42        (WebCore::SVGElement::invokeSVGPropertySynchronizer): 
     43        (WebCore::SVGElement::invokeAllSVGPropertySynchronizers): 
     44        (WebCore::SVGElement::addSVGPropertySynchronizer): 
     45        * svg/SVGEllipseElement.cpp: 
     46        (WebCore::SVGEllipseElement::SVGEllipseElement): 
     47        * svg/SVGEllipseElement.h: 
     48        * svg/SVGExternalResourcesRequired.cpp: 
     49        (WebCore::SVGExternalResourcesRequired::SVGExternalResourcesRequired): 
     50        * svg/SVGExternalResourcesRequired.h: 
     51        * svg/SVGFEBlendElement.cpp: 
     52        (WebCore::SVGFEBlendElement::SVGFEBlendElement): 
     53        * svg/SVGFEBlendElement.h: 
     54        * svg/SVGFEColorMatrixElement.cpp: 
     55        (WebCore::SVGFEColorMatrixElement::SVGFEColorMatrixElement): 
     56        * svg/SVGFEColorMatrixElement.h: 
     57        * svg/SVGFEComponentTransferElement.cpp: 
     58        (WebCore::SVGFEComponentTransferElement::SVGFEComponentTransferElement): 
     59        * svg/SVGFEComponentTransferElement.h: 
     60        * svg/SVGFECompositeElement.cpp: 
     61        (WebCore::SVGFECompositeElement::SVGFECompositeElement): 
     62        * svg/SVGFECompositeElement.h: 
     63        * svg/SVGFEDiffuseLightingElement.cpp: 
     64        (WebCore::SVGFEDiffuseLightingElement::SVGFEDiffuseLightingElement): 
     65        * svg/SVGFEDiffuseLightingElement.h: 
     66        * svg/SVGFEDisplacementMapElement.cpp: 
     67        (WebCore::SVGFEDisplacementMapElement::SVGFEDisplacementMapElement): 
     68        * svg/SVGFEDisplacementMapElement.h: 
     69        * svg/SVGFEFloodElement.h: 
     70        * svg/SVGFEGaussianBlurElement.cpp: 
     71        (WebCore::SVGFEGaussianBlurElement::SVGFEGaussianBlurElement): 
     72        * svg/SVGFEGaussianBlurElement.h: 
     73        * svg/SVGFEImageElement.cpp: 
     74        (WebCore::SVGFEImageElement::SVGFEImageElement): 
     75        * svg/SVGFEImageElement.h: 
     76        * svg/SVGFELightElement.cpp: 
     77        (WebCore::SVGFELightElement::SVGFELightElement): 
     78        * svg/SVGFELightElement.h: 
     79        (WebCore::SVGFELightElement::contextElement): 
     80        * svg/SVGFEMergeElement.h: 
     81        * svg/SVGFEMergeNodeElement.cpp: 
     82        (WebCore::SVGFEMergeNodeElement::SVGFEMergeNodeElement): 
     83        * svg/SVGFEMergeNodeElement.h: 
     84        * svg/SVGFEOffsetElement.cpp: 
     85        (WebCore::SVGFEOffsetElement::SVGFEOffsetElement): 
     86        * svg/SVGFEOffsetElement.h: 
     87        * svg/SVGFESpecularLightingElement.cpp: 
     88        (WebCore::SVGFESpecularLightingElement::SVGFESpecularLightingElement): 
     89        * svg/SVGFESpecularLightingElement.h: 
     90        * svg/SVGFETileElement.cpp: 
     91        (WebCore::SVGFETileElement::SVGFETileElement): 
     92        * svg/SVGFETileElement.h: 
     93        * svg/SVGFETurbulenceElement.cpp: 
     94        (WebCore::SVGFETurbulenceElement::SVGFETurbulenceElement): 
     95        * svg/SVGFETurbulenceElement.h: 
     96        * svg/SVGFilterElement.cpp: 
     97        (WebCore::SVGFilterElement::SVGFilterElement): 
     98        * svg/SVGFilterElement.h: 
     99        * svg/SVGFilterPrimitiveStandardAttributes.cpp: 
     100        (WebCore::SVGFilterPrimitiveStandardAttributes::SVGFilterPrimitiveStandardAttributes): 
     101        * svg/SVGFilterPrimitiveStandardAttributes.h: 
     102        * svg/SVGFitToViewBox.cpp: 
     103        (WebCore::SVGFitToViewBox::SVGFitToViewBox): 
     104        * svg/SVGFitToViewBox.h: 
     105        * svg/SVGFontElement.h: 
     106        (WebCore::SVGFontElement::rendererIsNeeded): 
     107        (WebCore::SVGFontElement::contextElement): 
     108        * svg/SVGForeignObjectElement.cpp: 
     109        (WebCore::SVGForeignObjectElement::SVGForeignObjectElement): 
     110        * svg/SVGForeignObjectElement.h: 
     111        * svg/SVGGElement.h: 
     112        * svg/SVGGradientElement.cpp: 
     113        (WebCore::SVGGradientElement::SVGGradientElement): 
     114        * svg/SVGGradientElement.h: 
     115        (WebCore::SVGGradientElement::contextElement): 
     116        * svg/SVGImageElement.cpp: 
     117        (WebCore::SVGImageElement::SVGImageElement): 
     118        * svg/SVGImageElement.h: 
     119        * svg/SVGLineElement.cpp: 
     120        (WebCore::SVGLineElement::SVGLineElement): 
     121        * svg/SVGLineElement.h: 
     122        * svg/SVGLinearGradientElement.cpp: 
     123        (WebCore::SVGLinearGradientElement::SVGLinearGradientElement): 
     124        * svg/SVGLinearGradientElement.h: 
     125        * svg/SVGMarkerElement.cpp: 
     126        (WebCore::SVGMarkerElement::SVGMarkerElement): 
     127        (WebCore::SVGMarkerElement::canvasResource): 
     128        * svg/SVGMarkerElement.h: 
     129        * svg/SVGMaskElement.cpp: 
     130        (WebCore::SVGMaskElement::SVGMaskElement): 
     131        * svg/SVGMaskElement.h: 
     132        * svg/SVGPathElement.cpp: 
     133        (WebCore::SVGPathElement::SVGPathElement): 
     134        (WebCore::SVGPathElement::parseMappedAttribute): 
     135        * svg/SVGPathElement.h: 
     136        * svg/SVGPatternElement.cpp: 
     137        (WebCore::SVGPatternElement::SVGPatternElement): 
     138        * svg/SVGPatternElement.h: 
     139        (WebCore::SVGPatternElement::contextElement): 
     140        * svg/SVGPolyElement.h: 
     141        * svg/SVGPreserveAspectRatio.cpp: 
     142        * svg/SVGRadialGradientElement.cpp: 
     143        (WebCore::SVGRadialGradientElement::SVGRadialGradientElement): 
     144        * svg/SVGRadialGradientElement.h: 
     145        * svg/SVGRectElement.cpp: 
     146        (WebCore::SVGRectElement::SVGRectElement): 
     147        * svg/SVGRectElement.h: 
     148        * svg/SVGSVGElement.cpp: 
     149        (WebCore::SVGSVGElement::SVGSVGElement): 
     150        * svg/SVGSVGElement.h: 
     151        * svg/SVGScriptElement.cpp: 
     152        * svg/SVGScriptElement.h: 
     153        * svg/SVGStopElement.cpp: 
     154        (WebCore::SVGStopElement::SVGStopElement): 
     155        * svg/SVGStopElement.h: 
     156        * svg/SVGStyledElement.cpp: 
     157        (WebCore::SVGStyledElement::SVGStyledElement): 
     158        * svg/SVGStyledElement.h: 
     159        * svg/SVGStyledTransformableElement.cpp: 
     160        (WebCore::SVGStyledTransformableElement::SVGStyledTransformableElement): 
     161        * svg/SVGStyledTransformableElement.h: 
     162        * svg/SVGSwitchElement.h: 
     163        * svg/SVGSymbolElement.h: 
     164        (WebCore::SVGSymbolElement::contextElement): 
     165        * svg/SVGTRefElement.h: 
     166        * svg/SVGTSpanElement.h: 
     167        * svg/SVGTextContentElement.cpp: 
     168        (WebCore::SVGTextContentElement::SVGTextContentElement): 
     169        * svg/SVGTextContentElement.h: 
     170        (WebCore::SVGTextContentElement::contextElement): 
     171        * svg/SVGTextElement.cpp: 
     172        (WebCore::SVGTextElement::SVGTextElement): 
     173        * svg/SVGTextElement.h: 
     174        * svg/SVGTextPathElement.cpp: 
     175        (WebCore::SVGTextPathElement::SVGTextPathElement): 
     176        * svg/SVGTextPathElement.h: 
     177        * svg/SVGTextPositioningElement.cpp: 
     178        (WebCore::SVGTextPositioningElement::SVGTextPositioningElement): 
     179        * svg/SVGTextPositioningElement.h: 
     180        * svg/SVGTransformable.h: 
     181        * svg/SVGURIReference.cpp: 
     182        (WebCore::SVGURIReference::SVGURIReference): 
     183        * svg/SVGURIReference.h: 
     184        * svg/SVGUseElement.cpp: 
     185        (WebCore::SVGUseElement::SVGUseElement): 
     186        * svg/SVGUseElement.h: 
     187        * svg/SVGViewElement.h: 
     188        * svg/SVGViewSpec.h: 
     189 
    11902008-07-18  Maxime Britto  <britto@apple.com> 
    2191 
  • trunk/WebCore/dom/Element.cpp

    r35035 r35248  
    201201#if ENABLE(SVG) 
    202202    if (!m_areSVGAttributesValid) 
    203         updateAnimatedSVGAttribute(0); 
     203        updateAnimatedSVGAttribute(String()); 
    204204#endif 
    205205 
     
    231231#if ENABLE(SVG) 
    232232    if (!m_areSVGAttributesValid) 
    233         updateAnimatedSVGAttribute(name.localName().impl()); 
     233        updateAnimatedSVGAttribute(name.localName()); 
    234234#endif 
    235235 
     
    486486#if ENABLE(SVG) 
    487487    if (!m_areSVGAttributesValid) 
    488         updateAnimatedSVGAttribute(name.impl()); 
     488        updateAnimatedSVGAttribute(name); 
    489489#endif 
    490490 
     
    601601#if ENABLE(SVG) 
    602602    if (!m_areSVGAttributesValid) 
    603         updateAnimatedSVGAttribute(0); 
     603        updateAnimatedSVGAttribute(String()); 
    604604#endif 
    605605 
  • trunk/WebCore/dom/Element.h

    r35035 r35248  
    208208 
    209209#if ENABLE(SVG) 
    210     virtual void updateAnimatedSVGAttribute(StringImpl* name) const {} 
     210    virtual void updateAnimatedSVGAttribute(const String&) const {} 
    211211#endif 
    212212 
  • trunk/WebCore/svg/SVGAElement.cpp

    r35035 r35248  
    5454    , SVGLangSpace() 
    5555    , SVGExternalResourcesRequired() 
     56    , m_target(this, SVGNames::targetAttr) 
    5657{ 
    5758} 
     
    6566    return getAttribute(XLinkNames::titleAttr); 
    6667} 
    67  
    68 ANIMATED_PROPERTY_DEFINITIONS(SVGAElement, String, Target, target, SVGNames::targetAttr) 
    6968 
    7069void SVGAElement::parseMappedAttribute(MappedAttribute* attr) 
  • trunk/WebCore/svg/SVGAElement.h

    r35035 r35248  
    6565 
    6666    private: 
    67         ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGURIReference, String, Href, href) 
    68         ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired) 
    69  
    70         ANIMATED_PROPERTY_DECLARATIONS(SVGAElement, String, Target, target) 
     67        ANIMATED_PROPERTY_DECLARATIONS(SVGAElement, SVGNames::aTagString, SVGNames::targetAttrString, String, Target, target) 
    7168    }; 
    7269 
  • trunk/WebCore/svg/SVGAltGlyphElement.h

    r34925 r35248  
    11/* 
    2     Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org> 
     2    Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 
    33                  2004, 2005, 2006 Rob Buis <buis@kde.org> 
    44    Copyright (C) 2008 Apple Computer, Inc. 
     
    2222#ifndef SVGAltGlyphElement_h 
    2323#define SVGAltGlyphElement_h 
     24 
    2425#if ENABLE(SVG_FONTS) 
    25  
    2626#include "AtomicString.h" 
    2727#include "SVGTextPositioningElement.h" 
    2828#include "SVGURIReference.h" 
    2929 
    30 namespace WebCore 
    31 { 
     30namespace WebCore { 
     31 
    3232    class SVGGlyphElement; 
    3333 
    34     class SVGAltGlyphElement : public SVGTextPositioningElement, public SVGURIReference 
    35     { 
     34    class SVGAltGlyphElement : public SVGTextPositioningElement, 
     35                               public SVGURIReference { 
    3636    public: 
    3737        SVGAltGlyphElement(const QualifiedName&, Document*); 
     
    5656#endif // ENABLE(SVG) 
    5757#endif 
    58  
    59 // vim:ts=4:noet 
  • trunk/WebCore/svg/SVGAnimatedTemplate.h

    r35035 r35248  
    146146    }; 
    147147 
    148     typedef void (*AnimatedPropertySynchronizer)(const SVGElement*); 
    149  
    150     template <class Type, class SVGElementSubClass> 
    151     PassRefPtr<Type> lookupOrCreateWrapper(const SVGElementSubClass* element, const QualifiedName& domAttrName, 
    152                                            const AtomicString& attrIdentifier, AnimatedPropertySynchronizer synchronizer) 
     148    template<typename OwnerTypeArg, typename AnimatedTypeArg, const char* TagName, const char* PropertyName> 
     149    class SVGAnimatedProperty; 
     150 
     151    template<typename OwnerType, typename AnimatedType, const char* TagName, const char* PropertyName, typename Type, typename OwnerElement>  
     152    PassRefPtr<Type> lookupOrCreateWrapper(const SVGAnimatedProperty<OwnerType, AnimatedType, TagName, PropertyName>& creator, 
     153                                           const OwnerElement* element, const QualifiedName& attrName, const AtomicString& attrIdentifier) 
    153154    { 
    154155        SVGAnimatedTypeWrapperKey key(element, attrIdentifier); 
     
    156157 
    157158        if (!wrapper) { 
    158             wrapper = Type::create(element, domAttrName); 
    159             element->addSVGPropertySynchronizer(domAttrName, synchronizer); 
     159            wrapper = Type::create(creator, element, attrName); 
     160            element->addSVGPropertySynchronizer(attrName, creator); 
    160161            Type::wrapperCache()->set(key, wrapper.get()); 
    161162        } 
     
    167168    template<typename Type> 
    168169    struct SVGAnimatedTypeValue : Noncopyable { 
     170        typedef RefPtr<Type> StorableType; 
     171        typedef Type* DecoratedType; 
     172 
    169173        static Type null() { return 0; } 
    170174        static AtomicString toString(Type type) { return type ? AtomicString(type->valueAsString()) : nullAtom; } 
     
    173177    template<> 
    174178    struct SVGAnimatedTypeValue<bool> : Noncopyable { 
     179        typedef bool StorableType; 
     180        typedef bool DecoratedType; 
     181 
    175182        static bool null() { return false; } 
    176183        static AtomicString toString(bool type) { return type ? "true" : "false"; } 
     
    179186    template<> 
    180187    struct SVGAnimatedTypeValue<int> : Noncopyable { 
     188        typedef int StorableType; 
     189        typedef int DecoratedType; 
     190 
    181191        static int null() { return 0; } 
    182192        static AtomicString toString(int type) { return String::number(type); } 
     
    185195    template<> 
    186196    struct SVGAnimatedTypeValue<long> : Noncopyable { 
     197        typedef long StorableType; 
     198        typedef long DecoratedType; 
     199 
    187200        static long null() { return 0l; } 
    188201        static AtomicString toString(long type) { return String::number(type); } 
     
    191204    template<> 
    192205    struct SVGAnimatedTypeValue<SVGLength> : Noncopyable { 
     206        typedef SVGLength StorableType; 
     207        typedef SVGLength DecoratedType; 
     208 
    193209        static SVGLength null() { return SVGLength(); } 
    194210        static AtomicString toString(const SVGLength& type) { return type.valueAsString(); } 
     
    197213    template<> 
    198214    struct SVGAnimatedTypeValue<float> : Noncopyable { 
     215        typedef float StorableType; 
     216        typedef float DecoratedType; 
     217 
    199218        static float null() { return 0.0f; } 
    200219        static AtomicString toString(float type) { return String::number(type); } 
     
    203222    template<> 
    204223    struct SVGAnimatedTypeValue<FloatRect> : Noncopyable { 
     224        typedef FloatRect StorableType; 
     225        typedef FloatRect DecoratedType; 
     226 
    205227        static FloatRect null() { return FloatRect(); } 
    206228        static AtomicString toString(const FloatRect& type) { return String::format("%f %f %f %f", type.x(), type.y(), type.width(), type.height()); } 
     
    209231    template<> 
    210232    struct SVGAnimatedTypeValue<String> : Noncopyable { 
     233        typedef String StorableType; 
     234        typedef String DecoratedType; 
     235 
    211236        static String null() { return String(); } 
    212237        static AtomicString toString(const String& type) { return type; } 
  • trunk/WebCore/svg/SVGAnimationElement.h

    r35204 r35248  
    9696        virtual void endedActiveInterval(); 
    9797         
    98         ANIMATED_PROPERTY_FORWARD_DECLARATIONS(SVGExternalResourcesRequired, bool, ExternalResourcesRequired, externalResourcesRequired) 
    9998    private: 
    10099        virtual bool calculateFromAndToValues(const String& fromString, const String& toString) = 0; 
  • trunk/WebCore/svg/SVGCircleElement.cpp

    r35204 r35248  
    3838    , SVGLangSpace() 
    3939    , SVGExternalResourcesRequired() 
    40     , m_cx(LengthModeWidth) 
    41     , m_cy(LengthModeHeight) 
    42     , m_r(LengthModeOther) 
     40    , m_cx(this, SVGNames::cxAttr, LengthModeWidth) 
     41    , m_cy(this, SVGNames::cyAttr, LengthModeHeight) 
     42    , m_r(this, SVGNames::rAttr, LengthModeOther) 
    4343{ 
    4444} 
     
    4747{ 
    4848} 
    49