Changeset 18876 in webkit


Ignore:
Timestamp:
Jan 15, 2007 8:01:57 PM (17 years ago)
Author:
eseidel
Message:

2007-01-15 Eric Seidel <eric@webkit.org>

Reviewed by hyatt.

Fix SVGStyledElement::parseMappedAttribute to only map SVG-allowed CSS properties
(i.e. width is no longer mapped to CSS for SVG)
Add SVGStyledElement::mapToEntry to allow RenderStyle-sharing
http://bugs.webkit.org/show_bug.cgi?id=12060

  • dom/MappedAttributeEntry.h: (WebCore::):
  • ksvg2/svg/SVGStyledElement.cpp: (WebCore::cssPropertyIdForName): new helper (WebCore::mapAttributeToCSSProperty): new helper (WebCore::SVGStyledElement::cssPropertyIdForSVGAttributeName): new helper (WebCore::SVGStyledElement::mapToEntry): added. (WebCore::SVGStyledElement::parseMappedAttribute): use cssPropertyIdForSVGAttributeName
  • ksvg2/svg/SVGStyledElement.h:
Location:
trunk/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r18874 r18876  
     12007-01-15  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by hyatt.
     4
     5        Fix SVGStyledElement::parseMappedAttribute to only map SVG-allowed CSS properties
     6        (i.e. width is no longer mapped to CSS for SVG)
     7        Add SVGStyledElement::mapToEntry to allow RenderStyle-sharing
     8        http://bugs.webkit.org/show_bug.cgi?id=12060
     9
     10        * dom/MappedAttributeEntry.h:
     11        (WebCore::):
     12        * ksvg2/svg/SVGStyledElement.cpp:
     13        (WebCore::cssPropertyIdForName): new helper
     14        (WebCore::mapAttributeToCSSProperty): new helper
     15        (WebCore::SVGStyledElement::cssPropertyIdForSVGAttributeName): new helper
     16        (WebCore::SVGStyledElement::mapToEntry): added.
     17        (WebCore::SVGStyledElement::parseMappedAttribute): use cssPropertyIdForSVGAttributeName
     18        * ksvg2/svg/SVGStyledElement.h:
     19
    1202007-01-15  Eric Seidel  <eric@webkit.org>
    221
  • trunk/WebCore/dom/MappedAttributeEntry.h

    r13480 r18876  
    4444    , eBDO
    4545    , ePre
     46#ifdef SVG_SUPPORT
     47    , eSVG
     48#endif
    4649// When adding new entries, make sure to keep eLastEntry at the end of the list.
    4750    , eLastEntry
  • trunk/WebCore/ksvg2/svg/SVGStyledElement.cpp

    r18830 r18876  
    6565}
    6666
     67static inline int cssPropertyIdForName(const char* propertyName, int propertyLength)
     68{
     69    int propertyId = getPropertyID(propertyName, propertyLength);
     70    if (propertyId == 0)
     71        propertyId = SVG::getSVGCSSPropertyID(propertyName, propertyLength);
     72    return propertyId;
     73}
     74
     75static inline void mapAttributeToCSSProperty(HashMap<AtomicStringImpl*, int>* propertyNameToIdMap, const QualifiedName& attrName, const char* cssPropertyName = 0)
     76{
     77    int propertyId = 0;
     78    if (cssPropertyName)
     79        propertyId = cssPropertyIdForName(cssPropertyName, strlen(cssPropertyName));
     80    else {
     81        DeprecatedString propertyName = attrName.localName().deprecatedString();
     82        propertyId = cssPropertyIdForName(propertyName.ascii(), propertyName.length());
     83    }
     84    ASSERT(propertyId > 0);
     85    propertyNameToIdMap->set(attrName.localName().impl(), propertyId);
     86}
     87
     88int SVGStyledElement::cssPropertyIdForSVGAttributeName(const QualifiedName& attrName)
     89{
     90    static HashMap<AtomicStringImpl*, int>* propertyNameToIdMap = 0;
     91    if (!propertyNameToIdMap) {
     92        propertyNameToIdMap = new HashMap<AtomicStringImpl*, int>;
     93        // This is a list of all base CSS and SVG CSS properties which are exposed as SVG XML attributes
     94        mapAttributeToCSSProperty(propertyNameToIdMap, alignment_baselineAttr);
     95        mapAttributeToCSSProperty(propertyNameToIdMap, baseline_shiftAttr);
     96        mapAttributeToCSSProperty(propertyNameToIdMap, clipAttr);
     97        mapAttributeToCSSProperty(propertyNameToIdMap, clip_pathAttr);
     98        mapAttributeToCSSProperty(propertyNameToIdMap, clip_ruleAttr);
     99        mapAttributeToCSSProperty(propertyNameToIdMap, colorAttr);
     100        mapAttributeToCSSProperty(propertyNameToIdMap, color_interpolation_filtersAttr);
     101        mapAttributeToCSSProperty(propertyNameToIdMap, color_profileAttr);
     102        mapAttributeToCSSProperty(propertyNameToIdMap, cursorAttr);
     103        mapAttributeToCSSProperty(propertyNameToIdMap, directionAttr);
     104        mapAttributeToCSSProperty(propertyNameToIdMap, displayAttr);
     105        mapAttributeToCSSProperty(propertyNameToIdMap, dominant_baselineAttr);
     106        mapAttributeToCSSProperty(propertyNameToIdMap, enable_backgroundAttr);
     107        mapAttributeToCSSProperty(propertyNameToIdMap, fillAttr);
     108        mapAttributeToCSSProperty(propertyNameToIdMap, fill_opacityAttr);
     109        mapAttributeToCSSProperty(propertyNameToIdMap, fill_ruleAttr);
     110        mapAttributeToCSSProperty(propertyNameToIdMap, filterAttr);
     111        mapAttributeToCSSProperty(propertyNameToIdMap, flood_colorAttr);
     112        mapAttributeToCSSProperty(propertyNameToIdMap, flood_opacityAttr);
     113        mapAttributeToCSSProperty(propertyNameToIdMap, font_familyAttr);
     114        mapAttributeToCSSProperty(propertyNameToIdMap, font_sizeAttr);
     115        mapAttributeToCSSProperty(propertyNameToIdMap, font_stretchAttr);
     116        mapAttributeToCSSProperty(propertyNameToIdMap, font_styleAttr);
     117        mapAttributeToCSSProperty(propertyNameToIdMap, font_variantAttr);
     118        mapAttributeToCSSProperty(propertyNameToIdMap, font_weightAttr);
     119        mapAttributeToCSSProperty(propertyNameToIdMap, glyph_orientation_horizontalAttr);
     120        mapAttributeToCSSProperty(propertyNameToIdMap, glyph_orientation_verticalAttr);
     121        mapAttributeToCSSProperty(propertyNameToIdMap, image_renderingAttr);
     122        mapAttributeToCSSProperty(propertyNameToIdMap, kerningAttr);
     123        mapAttributeToCSSProperty(propertyNameToIdMap, letter_spacingAttr);
     124        mapAttributeToCSSProperty(propertyNameToIdMap, lighting_colorAttr);
     125        mapAttributeToCSSProperty(propertyNameToIdMap, marker_endAttr);
     126        mapAttributeToCSSProperty(propertyNameToIdMap, marker_midAttr);
     127        mapAttributeToCSSProperty(propertyNameToIdMap, marker_startAttr);
     128        mapAttributeToCSSProperty(propertyNameToIdMap, maskAttr);
     129        mapAttributeToCSSProperty(propertyNameToIdMap, opacityAttr);
     130        mapAttributeToCSSProperty(propertyNameToIdMap, overflowAttr);
     131        mapAttributeToCSSProperty(propertyNameToIdMap, pointer_eventsAttr);
     132        mapAttributeToCSSProperty(propertyNameToIdMap, shape_renderingAttr);
     133        mapAttributeToCSSProperty(propertyNameToIdMap, stop_colorAttr);
     134        mapAttributeToCSSProperty(propertyNameToIdMap, stop_opacityAttr);
     135        mapAttributeToCSSProperty(propertyNameToIdMap, strokeAttr);
     136        mapAttributeToCSSProperty(propertyNameToIdMap, stroke_dasharrayAttr);
     137        mapAttributeToCSSProperty(propertyNameToIdMap, stroke_dashoffsetAttr);
     138        mapAttributeToCSSProperty(propertyNameToIdMap, stroke_linecapAttr);
     139        mapAttributeToCSSProperty(propertyNameToIdMap, stroke_linejoinAttr);
     140        mapAttributeToCSSProperty(propertyNameToIdMap, stroke_miterlimitAttr);
     141        mapAttributeToCSSProperty(propertyNameToIdMap, stroke_opacityAttr);
     142        mapAttributeToCSSProperty(propertyNameToIdMap, stroke_widthAttr);
     143        mapAttributeToCSSProperty(propertyNameToIdMap, text_anchorAttr);
     144        mapAttributeToCSSProperty(propertyNameToIdMap, text_decorationAttr);
     145        mapAttributeToCSSProperty(propertyNameToIdMap, text_renderingAttr);
     146        mapAttributeToCSSProperty(propertyNameToIdMap, unicode_bidiAttr);
     147        mapAttributeToCSSProperty(propertyNameToIdMap, visibilityAttr);
     148        mapAttributeToCSSProperty(propertyNameToIdMap, word_spacingAttr);
     149    }
     150   
     151    return propertyNameToIdMap->get(attrName.localName().impl());
     152}
     153
     154bool SVGStyledElement::mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const
     155{
     156    if (SVGStyledElement::cssPropertyIdForSVGAttributeName(attrName) > 0) {
     157        result = eSVG;
     158        return false;
     159    }
     160    return SVGElement::mapToEntry(attrName, result);
     161}
     162
    67163void SVGStyledElement::parseMappedAttribute(MappedAttribute* attr)
    68164{
    69     const String& value = attr->value();
    70     // id and class are handled by StyledElement
    71     DeprecatedString qProp = attr->name().localName().deprecatedString();
    72     int propId = getPropertyID(qProp.ascii(), qProp.length());
    73     if (propId == 0)
    74         propId = SVG::getSVGCSSPropertyID(qProp.ascii(), qProp.length());
     165    // NOTE: Any subclass which overrides parseMappedAttribute for a property handled by
     166    // cssPropertyIdForSVGAttributeName will also have to override mapToEntry to disable the default eSVG mapping
     167    int propId = SVGStyledElement::cssPropertyIdForSVGAttributeName(attr->name());
    75168    if (propId > 0) {
    76         addCSSProperty(attr, propId, value);
     169        addCSSProperty(attr, propId, attr->value());
    77170        setChanged();
    78171        return;
    79172    }
    80173   
     174    // id and class are handled by StyledElement
    81175    SVGElement::parseMappedAttribute(attr);
    82176}
  • trunk/WebCore/ksvg2/svg/SVGStyledElement.h

    r18874 r18876  
    5353        virtual SVGResource* canvasResource() { return 0; }
    5454       
     55        virtual bool mapToEntry(const QualifiedName&, MappedAttributeEntry&) const;
    5556        virtual void parseMappedAttribute(MappedAttribute*);
    5657
     
    6566
    6667        virtual bool hasRelativeValues() const { return false; }
     68       
     69        static int cssPropertyIdForSVGAttributeName(const QualifiedName&);
    6770
    6871    private:
Note: See TracChangeset for help on using the changeset viewer.