Changeset 52960 in webkit


Ignore:
Timestamp:
Jan 7, 2010 4:36:10 PM (14 years ago)
Author:
Nikolas Zimmermann
Message:

2010-01-07 Nikolas Zimmermann <nzimmermann@rim.com>

Reviewed by Dirk Schulze.

SVGTextElement & friends need to implement svgAttributeChanged
https://bugs.webkit.org/show_bug.cgi?id=33284

Implement svgAttributeChanged() for SVGTextElement & SVGTRefElement. As <text> element contain children,
childrenChanged() has to be implemented as well for SVGTextElement.

Simplify SVGTransformable::parseTransformAttribute() code, clearing lists in the beginning
and on error case, after parsing - previously the calling site had to take care of that.

Tests: svg/dynamic-updates/SVGTRefElement-dom-href-attr.html

svg/dynamic-updates/SVGTextElement-dom-transform-attr.html
svg/dynamic-updates/SVGTextElement-svgdom-transform-prop.html

  • svg/SVGGradientElement.cpp: (WebCore::SVGGradientElement::parseMappedAttribute):
  • svg/SVGPatternElement.cpp: (WebCore::SVGPatternElement::parseMappedAttribute):
  • svg/SVGStyledTransformableElement.cpp: (WebCore::SVGStyledTransformableElement::parseMappedAttribute):
  • svg/SVGTRefElement.cpp: (WebCore::SVGTRefElement::svgAttributeChanged):
  • svg/SVGTRefElement.h:
  • svg/SVGTextElement.cpp: (WebCore::SVGTextElement::parseMappedAttribute): (WebCore::SVGTextElement::svgAttributeChanged): (WebCore::SVGTextElement::childrenChanged):
  • svg/SVGTextElement.h:
  • svg/SVGTextPositioningElement.cpp: (WebCore::SVGTextPositioningElement::svgAttributeChanged):
  • svg/SVGTextPositioningElement.h:
  • svg/SVGTransformable.cpp: (WebCore::SVGTransformable::parseTransformAttribute):
  • svg/SVGTransformable.h:
Location:
trunk
Files:
9 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r52956 r52960  
     12010-01-07  Nikolas Zimmermann  <nzimmermann@rim.com>
     2
     3        Reviewed by Dirk Schulze.
     4
     5        SVGTextElement & friends need to implement svgAttributeChanged
     6        https://bugs.webkit.org/show_bug.cgi?id=33284
     7
     8        * svg/dynamic-updates/SVGTRefElement-dom-href-attr-expected.txt: Added.
     9        * svg/dynamic-updates/SVGTRefElement-dom-href-attr.html: Added.
     10        * svg/dynamic-updates/SVGTextElement-dom-transform-attr-expected.txt: Added.
     11        * svg/dynamic-updates/SVGTextElement-dom-transform-attr.html: Added.
     12        * svg/dynamic-updates/SVGTextElement-svgdom-transform-prop-expected.txt: Added.
     13        * svg/dynamic-updates/SVGTextElement-svgdom-transform-prop.html: Added.
     14        * svg/dynamic-updates/script-tests/SVGTRefElement-dom-href-attr.js: Added.
     15        (executeTest):
     16        * svg/dynamic-updates/script-tests/SVGTextElement-dom-transform-attr.js: Added.
     17        (executeTest):
     18        * svg/dynamic-updates/script-tests/SVGTextElement-svgdom-transform-prop.js: Added.
     19        (executeTest):
     20
    1212010-01-07  Alexey Proskuryakov  <ap@apple.com>
    222
  • trunk/WebCore/ChangeLog

    r52958 r52960  
     12010-01-07  Nikolas Zimmermann  <nzimmermann@rim.com>
     2
     3        Reviewed by Dirk Schulze.
     4
     5        SVGTextElement & friends need to implement svgAttributeChanged
     6        https://bugs.webkit.org/show_bug.cgi?id=33284
     7
     8        Implement svgAttributeChanged() for SVGTextElement & SVGTRefElement. As <text> element contain children,
     9        childrenChanged() has to be implemented as well for SVGTextElement.
     10
     11        Simplify SVGTransformable::parseTransformAttribute() code, clearing lists in the beginning
     12        and on error case, after parsing - previously the calling site had to take care of that.
     13
     14        Tests: svg/dynamic-updates/SVGTRefElement-dom-href-attr.html
     15               svg/dynamic-updates/SVGTextElement-dom-transform-attr.html
     16               svg/dynamic-updates/SVGTextElement-svgdom-transform-prop.html
     17
     18        * svg/SVGGradientElement.cpp:
     19        (WebCore::SVGGradientElement::parseMappedAttribute):
     20        * svg/SVGPatternElement.cpp:
     21        (WebCore::SVGPatternElement::parseMappedAttribute):
     22        * svg/SVGStyledTransformableElement.cpp:
     23        (WebCore::SVGStyledTransformableElement::parseMappedAttribute):
     24        * svg/SVGTRefElement.cpp:
     25        (WebCore::SVGTRefElement::svgAttributeChanged):
     26        * svg/SVGTRefElement.h:
     27        * svg/SVGTextElement.cpp:
     28        (WebCore::SVGTextElement::parseMappedAttribute):
     29        (WebCore::SVGTextElement::svgAttributeChanged):
     30        (WebCore::SVGTextElement::childrenChanged):
     31        * svg/SVGTextElement.h:
     32        * svg/SVGTextPositioningElement.cpp:
     33        (WebCore::SVGTextPositioningElement::svgAttributeChanged):
     34        * svg/SVGTextPositioningElement.h:
     35        * svg/SVGTransformable.cpp:
     36        (WebCore::SVGTransformable::parseTransformAttribute):
     37        * svg/SVGTransformable.h:
     38
    1392010-01-07  Brian Weinstein  <bweinstein@apple.com>
    240
  • trunk/WebCore/svg/SVGStyledTransformableElement.cpp

    r50583 r52960  
    7171void SVGStyledTransformableElement::parseMappedAttribute(MappedAttribute* attr)
    7272{
    73     if (attr->name() == SVGNames::transformAttr) {
     73    if (SVGTransformable::isKnownAttribute(attr->name())) {
    7474        SVGTransformList* localTransforms = transformBaseValue();
    75 
    76         ExceptionCode ec = 0;
    77         localTransforms->clear(ec);
    78  
    79         if (!SVGTransformable::parseTransformAttribute(localTransforms, attr->value()))
     75        if (!SVGTransformable::parseTransformAttribute(localTransforms, attr->value())) {
     76            ExceptionCode ec = 0;
    8077            localTransforms->clear(ec);
    81         else
    82             setTransformBaseValue(localTransforms);
    83     } else
     78        }
     79    } else
    8480        SVGStyledLocatableElement::parseMappedAttribute(attr);
    8581}
  • trunk/WebCore/svg/SVGTRefElement.cpp

    r50583 r52960  
    6262}
    6363
     64void SVGTRefElement::svgAttributeChanged(const QualifiedName& attrName)
     65{
     66    SVGTextPositioningElement::svgAttributeChanged(attrName);
     67
     68    if (!renderer())
     69        return;
     70
     71    if (SVGURIReference::isKnownAttribute(attrName))
     72        renderer()->setNeedsLayout(true);
     73}
     74
    6475bool SVGTRefElement::childShouldCreateRenderer(Node* child) const
    6576{
  • trunk/WebCore/svg/SVGTRefElement.h

    r49602 r52960  
    3535
    3636        virtual void parseMappedAttribute(MappedAttribute*);
     37        virtual void svgAttributeChanged(const QualifiedName&);
    3738
    3839        virtual RenderObject* createRenderer(RenderArena*, RenderStyle*);
  • trunk/WebCore/svg/SVGTextElement.cpp

    r50583 r52960  
    4848void SVGTextElement::parseMappedAttribute(MappedAttribute* attr)
    4949{
    50     if (attr->name() == SVGNames::transformAttr) {
     50    if (SVGTransformable::isKnownAttribute(attr->name())) {
    5151        SVGTransformList* localTransforms = transformBaseValue();
    52 
    53         ExceptionCode ec = 0;
    54         localTransforms->clear(ec);
    55 
    56         if (!SVGTransformable::parseTransformAttribute(localTransforms, attr->value()))
     52        if (!SVGTransformable::parseTransformAttribute(localTransforms, attr->value())) {
     53            ExceptionCode ec = 0;
    5754            localTransforms->clear(ec);
    58         else {
    59             setTransformBaseValue(localTransforms);
    60             if (renderer())
    61                 renderer()->setNeedsLayout(true); // should be in setTransformBaseValue
    6255        }
    6356    } else
     
    125118        return;
    126119
    127     if (SVGTextPositioningElement::isKnownAttribute(attrName))
     120    if (SVGTransformable::isKnownAttribute(attrName))
    128121        renderer()->setNeedsLayout(true);
     122}
     123
     124void SVGTextElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
     125{
     126    SVGTextPositioningElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
     127
     128    if (!renderer())
     129        return;
     130
     131    renderer()->setNeedsLayout(true);
    129132}
    130133
  • trunk/WebCore/svg/SVGTextElement.h

    r50583 r52960  
    4949               
    5050        virtual void svgAttributeChanged(const QualifiedName&);
     51        virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0);
    5152
    5253    private:
  • trunk/WebCore/svg/SVGTextPositioningElement.cpp

    r50583 r52960  
    2525
    2626#include "MappedAttribute.h"
     27#include "RenderObject.h"
    2728#include "SVGLengthList.h"
    2829#include "SVGNames.h"
     
    6364}
    6465
     66void SVGTextPositioningElement::svgAttributeChanged(const QualifiedName& attrName)
     67{
     68    SVGTextContentElement::svgAttributeChanged(attrName);
     69
     70    if (!renderer())
     71        return;
     72
     73    if (isKnownAttribute(attrName))
     74        renderer()->setNeedsLayout(true);
     75}
     76
    6577bool SVGTextPositioningElement::isKnownAttribute(const QualifiedName& attrName)
    6678{
  • trunk/WebCore/svg/SVGTextPositioningElement.h

    r50583 r52960  
    3737
    3838        virtual void parseMappedAttribute(MappedAttribute*);
     39        virtual void svgAttributeChanged(const QualifiedName&);
    3940
    4041        bool isKnownAttribute(const QualifiedName&);
  • trunk/WebCore/svg/SVGTransformable.cpp

    r45747 r52960  
    191191{
    192192    const UChar* start = transform.characters();
    193     const UChar* end = start + transform.length();
    194     return parseTransformAttribute(list, start, end);
    195 }
    196 
    197 bool SVGTransformable::parseTransformAttribute(SVGTransformList* list, const UChar*& currTransform, const UChar* end)
    198 {
     193    return parseTransformAttribute(list, start, start + transform.length());
     194}
     195
     196bool SVGTransformable::parseTransformAttribute(SVGTransformList* list, const UChar*& currTransform, const UChar* end, TransformParsingMode mode)
     197{
     198    ExceptionCode ec = 0;
     199    if (mode == ClearList) {
     200        list->clear(ec);
     201        ASSERT(!ec);
     202    }
     203
    199204    bool delimParsed = false;
    200205    while (currTransform < end) {
     
    202207        unsigned short type = SVGTransform::SVG_TRANSFORM_UNKNOWN;
    203208        skipOptionalSpaces(currTransform, end);
    204        
     209
    205210        if (!parseAndSkipType(currTransform, end, type))
    206211            return false;
     
    210215            return false;
    211216
    212         ExceptionCode ec = 0;
    213217        list->appendItem(t, ec);
    214218        skipOptionalSpaces(currTransform, end);
    215219        if (currTransform < end && *currTransform == ',') {
    216220            delimParsed = true;
    217             currTransform++;
     221            ++currTransform;
    218222        }
    219223        skipOptionalSpaces(currTransform, end);
  • trunk/WebCore/svg/SVGTransformable.h

    r50583 r52960  
    3939        virtual ~SVGTransformable();
    4040
     41        enum TransformParsingMode {
     42            ClearList,
     43            DoNotClearList
     44        };
     45
    4146        static bool parseTransformAttribute(SVGTransformList*, const AtomicString& transform);
    42         static bool parseTransformAttribute(SVGTransformList*, const UChar*& ptr, const UChar* end);
     47        static bool parseTransformAttribute(SVGTransformList*, const UChar*& ptr, const UChar* end, TransformParsingMode mode = ClearList);
    4348        static bool parseTransformValue(unsigned type, const UChar*& ptr, const UChar* end, SVGTransform&);
    4449       
  • trunk/WebCore/svg/SVGViewSpec.cpp

    r52373 r52960  
    153153                return false;
    154154            currViewSpec++;
    155             SVGTransformable::parseTransformAttribute(m_transform.get(), currViewSpec, end);
     155            SVGTransformable::parseTransformAttribute(m_transform.get(), currViewSpec, end, SVGTransformable::DoNotClearList);
    156156            if (currViewSpec >= end || *currViewSpec != ')')
    157157                return false;
Note: See TracChangeset for help on using the changeset viewer.