Bug 57831

Summary: text-tspan-02-b.svg from SVG 1.1 2nd edition fails
Product: WebKit Reporter: Nikolas Zimmermann <zimmermann>
Component: SVGAssignee: Nikolas Zimmermann <zimmermann>
Status: RESOLVED FIXED    
Severity: Normal CC: aroben, krit, zimmermann
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: OS X 10.5   
URL: http://dev.w3.org/SVG/profiles/1.1F2/test/harness/htmlObject/text-tspan-02-b.html
Attachments:
Description Flags
Patch
aroben: review+
Patch v2 krit: review+

Description Nikolas Zimmermann 2011-04-05 05:23:26 PDT
text-tspan-02-b.svg from SVG 1.1 2nd edition fails.
We fail to correctly span the rotate attribute across text children.
Comment 1 Nikolas Zimmermann 2011-04-05 05:38:50 PDT
Created attachment 88208 [details]
Patch
Comment 2 Adam Roben (:aroben) 2011-04-05 07:44:55 PDT
Comment on attachment 88208 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=88208&action=review

> Source/WebCore/ChangeLog:26
> +        (WebCore::SVGTextLayoutAttributes::reserveCapacity): Also reserveCapacity for the text metrics list (minor optimiyation).

Typo: optimyation

> Source/WebCore/rendering/RenderBlockLineLayout.cpp:1997
> +                if (isSVGText && pos > 0 && !atStart) {

I don't think you mentioned the !atStart part of this change in your ChangeLog.

> Source/WebCore/rendering/svg/SVGTextLayoutAttributes.cpp:53
> +    // Doesn't touch m_textMetricsValues on purpose.

Instead of just "on purpose", maybe you can explain why we don't touch it. (Ditto for other similar functions in this patch.)

> Source/WebCore/rendering/svg/SVGTextLayoutAttributes.cpp:68
> +    if (position >= values.size())

When do we expect this to happen?

> Source/WebCore/rendering/svg/SVGTextLayoutAttributes.h:40
>      void reserveCapacity(unsigned length);
> +    void fillWithEmptyValue(unsigned length);
> +
> +    void appendEmptyValue();
> +    void appendSingleValueFromAttribute(const SVGTextLayoutAttributes&, unsigned position);

The length and position arguments should really be of type size_t.

> Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp:2
> - * Copyright (C) Research In Motion Limited 2010. All rights reserved.
> + * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.

I think we normally prefer comma-separated years.

> Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp:126
> +    if (start->isSVGText()) 
> +        ASSERT(m_textPositions.isEmpty());

You could turn this into just an assertion: ASSERT(!start->isSVGText() || m_textPositions.isEmpty());

> Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp:138
> +        unsigned atPosition = m_textPositions.size();

Should be size_t.

> Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp:148
> +        TextPosition& position = m_textPositions.at(atPosition);

Could use [] instead of .at().

> Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp:154
> +void SVGTextLayoutAttributesBuilder::buildLayoutAttributesForAllCharacters(RenderSVGText* textRoot, unsigned textLength)

Maybe you should assert that textLength is non-zero?

> Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp:177
> +    unsigned size = m_textPositions.size();
> +    for (unsigned i = 0; i < size; ++i)

Should be size_t

> Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp:178
> +        fillAttributesAtPosition(m_textPositions.at(i));

Could use [] instead of .at().

> Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp:257
> +    unsigned valuesSize = values.size();
> +    for (unsigned i = 0; i < valuesSize; ++i)

Should be size_t.

> Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.h:2
> - * Copyright (C) Research In Motion Limited 2010. All rights reserved.
> + * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.

I think we usually prefer comma-separated years.
Comment 3 Nikolas Zimmermann 2011-04-05 08:49:17 PDT
(In reply to comment #2)
> (From update of attachment 88208 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=88208&action=review
> 
> > Source/WebCore/ChangeLog:26
> > +        (WebCore::SVGTextLayoutAttributes::reserveCapacity): Also reserveCapacity for the text metrics list (minor optimiyation).
> 
> Typo: optimyation
Fixed.

> 
> > Source/WebCore/rendering/RenderBlockLineLayout.cpp:1997
> > +                if (isSVGText && pos > 0 && !atStart) {
> 
> I don't think you mentioned the !atStart part of this change in your ChangeLog.
> 
> > Source/WebCore/rendering/svg/SVGTextLayoutAttributes.cpp:53
> > +    // Doesn't touch m_textMetricsValues on purpose.
> 
> Instead of just "on purpose", maybe you can explain why we don't touch it. (Ditto for other similar functions in this patch.)
I refactored the code, to avoid the need at all for the comment. SVGTextLayoutAttributesBuilder only needs to store the global x/y/dx/dy/rotate lists, not the metrics lists.


> > Source/WebCore/rendering/svg/SVGTextLayoutAttributes.cpp:68
> > +    if (position >= values.size())
> 
> When do we expect this to happen?
Trailing whitespace, if xml:space is default. Covered by LayoutTests/svg/batik/text/xmlSpaces.svg
 
> > Source/WebCore/rendering/svg/SVGTextLayoutAttributes.h:40
> >      void reserveCapacity(unsigned length);
> > +    void fillWithEmptyValue(unsigned length);
> > +
> > +    void appendEmptyValue();
> > +    void appendSingleValueFromAttribute(const SVGTextLayoutAttributes&, unsigned position);
> 
> The length and position arguments should really be of type size_t.
Okay, as discussed on IRC that should be done seperated, as it affects much more than just this part of SVG.

> 
> > Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp:2
> > - * Copyright (C) Research In Motion Limited 2010. All rights reserved.
> > + * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
> 
> I think we normally prefer comma-separated years.
RIM has a different style.

> 
> > Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp:126
> > +    if (start->isSVGText()) 
> > +        ASSERT(m_textPositions.isEmpty());
> 
> You could turn this into just an assertion: ASSERT(!start->isSVGText() || m_textPositions.isEmpty());
Great.


> 
> > Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp:148
> > +        TextPosition& position = m_textPositions.at(atPosition);
> 
> Could use [] instead of .at().
Fixed.

> 
> > Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp:154
> > +void SVGTextLayoutAttributesBuilder::buildLayoutAttributesForAllCharacters(RenderSVGText* textRoot, unsigned textLength)
> 
> Maybe you should assert that textLength is non-zero?
Right, fixed.

> 
> > Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp:178
> > +        fillAttributesAtPosition(m_textPositions.at(i));
> 
> Could use [] instead of .at().
Fixed.

Posting new patch soon.
Comment 4 Nikolas Zimmermann 2011-04-05 09:14:07 PDT
Created attachment 88248 [details]
Patch v2

Fixed Adams comments.
Comment 5 Dirk Schulze 2011-04-05 09:36:45 PDT
Comment on attachment 88248 [details]
Patch v2

View in context: https://bugs.webkit.org/attachment.cgi?id=88248&action=review

LGTM. r=me

> Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.h:25
> +#include <wtf/HashMap.h>

You can remove this include.
Comment 6 Nikolas Zimmermann 2011-04-05 09:38:38 PDT
Landed in r82947.