2010-07-19 Dirk Schulze <krit@webkit.org>
authorkrit@webkit.org <krit@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Jul 2010 05:37:47 +0000 (05:37 +0000)
committerkrit@webkit.org <krit@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Jul 2010 05:37:47 +0000 (05:37 +0000)
commit90128184ba864d56343539a8409f01e2c94d0f16
treee775b79cf3840a1808eecf2d938926eace257943
parentbcb530290da8f4655204026586db5c940ce6843e
2010-07-19  Dirk Schulze  <krit@webkit.org>

        Reviewed by Nikolas Zimmermann.

        SVG CleanUp of SVGPathData parsing
        https://bugs.webkit.org/show_bug.cgi?id=41410

        Added piOverTwo to MathExtras.

        * wtf/MathExtras.h:
2010-07-19  Dirk Schulze  <krit@webkit.org>

        Reviewed by Nikolas Zimmermann.

        SVG CleanUp of SVGPathData parsing
        https://bugs.webkit.org/show_bug.cgi?id=41410

        Cleanup the parsing code for SVG Paths. Move classes out of the convoluted SVGParserUtilities.cpp
        in their own files. Make use of WebCore specific objects in parsing code like FloatPoint, AffineTransform,
        etc. instead of using home-brewn solutions.
        The SVGPathParser parses a path data string and delivers the parsed segments and values to the SVGPathConsumer.
        SVGPathConsumer is the base class for SVGPathBuilder and SVGPathSegListBuilder, that either build the platform
        Path object or a SVGPathSegList out of the segments.
        We're now directly parsing floats instead of truncating precision to float afterwards.

        SVG Path with an arc with radius of 0 does not render
        https://bugs.webkit.org/show_bug.cgi?id=40448

        If one of the radii on the elliptic arc are zero, we should draw a line from the starting point to
        the end point according to the spec. Fixed this bug with this patch, because an is zero check and
        an DRT check was neccessary with the current clean-up.
        Extended svg/dom/path-parser.xhml to check the correct behavior.

        * Android.mk:
        * GNUmakefile.am:
        * WebCore.gypi:
        * WebCore.pro:
        * WebCore.vcproj/WebCore.vcproj:
        * WebCore.xcodeproj/project.pbxproj:
        * platform/graphics/FloatPoint.h:
        (WebCore::FloatPoint::move): Follow WebKit style and use multiple lines for the function.
        (WebCore::FloatPoint::scale): Scale FloatPoint.
        (WebCore::operator+=):
        (WebCore::operator+): Add two FloatPoints and give back the sum as FloatPoint.
        * svg/SVGAllInOne.cpp: Added new created files.
        * svg/SVGAnimateElement.cpp:
        (WebCore::SVGAnimateElement::calculateFromAndToValues): Use new PathParser to create a PathSegList.
        * svg/SVGAnimateMotionElement.cpp:
        (WebCore::SVGAnimateMotionElement::parseMappedAttribute): Use new PathParser to create a Path.
        * svg/SVGGlyphElement.cpp:
        (WebCore::parsePathData): Use new PathParser to create a Path.
        * svg/SVGParserUtilities.cpp:
        (WebCore::parseArcFlag): Removed parseArcFlag(double&), we parse in float now.
        * svg/SVGParserUtilities.h: Removed path parsing code and a lot of unneccessary includes.
        * svg/SVGPathBuilder.cpp: Added.
        (WebCore::SVGPathBuilder::SVGPathBuilder):
        (WebCore::SVGPathBuilder::build): Builds a normalized Path.
        (WebCore::SVGPathBuilder::moveTo):
        (WebCore::SVGPathBuilder::lineTo):
        (WebCore::SVGPathBuilder::curveToCubic):
        (WebCore::SVGPathBuilder::closePath):
        * svg/SVGPathBuilder.h: Added. We just create normalized Paths, so this functions should never be reached.
        (WebCore::SVGPathBuilder::lineToHorizontal):
        (WebCore::SVGPathBuilder::lineToVertical):
        (WebCore::SVGPathBuilder::curveToCubicSmooth):
        (WebCore::SVGPathBuilder::curveToQuadratic):
        (WebCore::SVGPathBuilder::curveToQuadraticSmooth):
        (WebCore::SVGPathBuilder::arcTo):
        * svg/SVGPathConsumer.h: Added. Base class of SVGPathBuilder and SVGPathSegListBuilder.
        (WebCore::):
        (WebCore::SVGPathConsumer::SVGPathConsumer):
        (WebCore::SVGPathConsumer::~SVGPathConsumer):
        * svg/SVGPathElement.cpp:
        (WebCore::SVGPathElement::parseMappedAttribute): Use new PathParser to create a PathSegList.
        * svg/SVGPathParser.cpp: Added.
        (WebCore::SVGPathParser::SVGPathParser):
        (WebCore::SVGPathParser::~SVGPathParser):
        (WebCore::SVGPathParser::parseClosePathSegment):
        (WebCore::SVGPathParser::parseMoveToSegment):
        (WebCore::SVGPathParser::parseLineToSegment):
        (WebCore::SVGPathParser::parseLineToHorizontalSegment):
        (WebCore::SVGPathParser::parseLineToVerticalSegment):
        (WebCore::SVGPathParser::parseCurveToCubicSegment):
        (WebCore::SVGPathParser::parseCurveToCubicSmoothSegment):
        (WebCore::SVGPathParser::parseCurveToQuadraticSegment):
        (WebCore::SVGPathParser::parseCurveToQuadraticSmoothSegment):
        (WebCore::SVGPathParser::parseArcToSegment):
        (WebCore::SVGPathParser::parsePathDataString):
        (WebCore::SVGPathParser::decomposeArcToCubic): Normalizes an arc to multiple cubic curves.
        * svg/SVGPathParser.h: Added.
        * svg/SVGPathSegListBuilder.cpp: Added.
        (WebCore::SVGPathSegListBuilder::SVGPathSegListBuilder):
        (WebCore::SVGPathSegListBuilder::build):
        (WebCore::SVGPathSegListBuilder::moveTo):
        (WebCore::SVGPathSegListBuilder::lineTo):
        (WebCore::SVGPathSegListBuilder::lineToHorizontal):
        (WebCore::SVGPathSegListBuilder::lineToVertical):
        (WebCore::SVGPathSegListBuilder::curveToCubic):
        (WebCore::SVGPathSegListBuilder::curveToCubicSmooth):
        (WebCore::SVGPathSegListBuilder::curveToQuadratic):
        (WebCore::SVGPathSegListBuilder::curveToQuadraticSmooth):
        (WebCore::SVGPathSegListBuilder::arcTo):
        (WebCore::SVGPathSegListBuilder::closePath):
        * svg/SVGPathSegListBuilder.h: Added.
2010-07-19  Dirk Schulze  <krit@webkit.org>

        Reviewed by Nikolas Zimmermann.

        SVG CleanUp of SVGPathData parsing
        https://bugs.webkit.org/show_bug.cgi?id=41410

        Parsing values as float instead of double causes some minimal changes on DRT results and
        pixel results. Even if the values get shrinked to float before the calculation of arc and
        others. But the calculation itself transforms the values back to double and shrinks it to
        floats again right before the drawing.

        SVG Path with an arc with radius of 0 does not render
        https://bugs.webkit.org/show_bug.cgi?id=40448

        Extended svg/dom/path-parser.xhml to check the correct behavior. We draw a line from the
        current point to the given end point.

        * platform/mac-leopard/svg/W3C-SVG-1.1/animate-elem-40-t-expected.checksum:
        * platform/mac-leopard/svg/W3C-SVG-1.1/animate-elem-40-t-expected.png:
        * platform/mac-leopard/svg/W3C-SVG-1.1/filters-morph-01-f-expected.checksum:
        * platform/mac-leopard/svg/W3C-SVG-1.1/filters-morph-01-f-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/animate-elem-03-t-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/animate-elem-03-t-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/extend-namespace-01-f-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/extend-namespace-01-f-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/filters-morph-01-f-expected.txt:
        * platform/mac/svg/W3C-SVG-1.1/metadata-example-01-b-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/metadata-example-01-b-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/metadata-example-01-b-expected.txt:
        * platform/mac/svg/W3C-SVG-1.1/paths-data-02-t-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/paths-data-02-t-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/paths-data-03-f-expected.checksum:
        * platform/mac/svg/W3C-SVG-1.1/paths-data-03-f-expected.png:
        * platform/mac/svg/W3C-SVG-1.1/paths-data-03-f-expected.txt:
        * platform/mac/svg/batik/text/textEffect3-expected.checksum:
        * platform/mac/svg/batik/text/textEffect3-expected.png:
        * platform/mac/svg/custom/relative-sized-inner-svg-expected.checksum:
        * platform/mac/svg/custom/relative-sized-inner-svg-expected.png:
        * platform/mac/svg/custom/relative-sized-inner-svg-expected.txt:
        * platform/mac/svg/custom/relative-sized-use-on-symbol-expected.txt:
        * platform/mac/svg/custom/relative-sized-use-without-attributes-on-symbol-expected.checksum:
        * platform/mac/svg/custom/relative-sized-use-without-attributes-on-symbol-expected.png:
        * platform/mac/svg/custom/relative-sized-use-without-attributes-on-symbol-expected.txt:
        * platform/mac/svg/custom/use-css-events-expected.txt:
        * platform/mac/svg/custom/use-on-symbol-inside-pattern-expected.txt:
        * platform/mac/svg/hixie/perf/007-expected.checksum:
        * platform/mac/svg/hixie/perf/007-expected.png:
        * platform/mac/svg/hixie/perf/007-expected.txt:
        * svg/custom/path-getTotalLength-expected.txt:
        * svg/dom/path-parser-expected.txt:
        * svg/dom/script-tests/path-parser.js:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@63721 268f45cc-cd09-0410-ab3c-d52691b4dbfc
59 files changed:
JavaScriptCore/ChangeLog
JavaScriptCore/wtf/MathExtras.h
LayoutTests/ChangeLog
LayoutTests/platform/mac-leopard/svg/W3C-SVG-1.1/animate-elem-40-t-expected.checksum
LayoutTests/platform/mac-leopard/svg/W3C-SVG-1.1/animate-elem-40-t-expected.png
LayoutTests/platform/mac-leopard/svg/W3C-SVG-1.1/filters-morph-01-f-expected.checksum
LayoutTests/platform/mac-leopard/svg/W3C-SVG-1.1/filters-morph-01-f-expected.png
LayoutTests/platform/mac/svg/W3C-SVG-1.1/animate-elem-03-t-expected.checksum
LayoutTests/platform/mac/svg/W3C-SVG-1.1/animate-elem-03-t-expected.png
LayoutTests/platform/mac/svg/W3C-SVG-1.1/extend-namespace-01-f-expected.checksum
LayoutTests/platform/mac/svg/W3C-SVG-1.1/extend-namespace-01-f-expected.png
LayoutTests/platform/mac/svg/W3C-SVG-1.1/filters-morph-01-f-expected.txt
LayoutTests/platform/mac/svg/W3C-SVG-1.1/metadata-example-01-b-expected.checksum
LayoutTests/platform/mac/svg/W3C-SVG-1.1/metadata-example-01-b-expected.png
LayoutTests/platform/mac/svg/W3C-SVG-1.1/metadata-example-01-b-expected.txt
LayoutTests/platform/mac/svg/W3C-SVG-1.1/paths-data-02-t-expected.checksum
LayoutTests/platform/mac/svg/W3C-SVG-1.1/paths-data-02-t-expected.png
LayoutTests/platform/mac/svg/W3C-SVG-1.1/paths-data-03-f-expected.checksum
LayoutTests/platform/mac/svg/W3C-SVG-1.1/paths-data-03-f-expected.png
LayoutTests/platform/mac/svg/W3C-SVG-1.1/paths-data-03-f-expected.txt
LayoutTests/platform/mac/svg/batik/text/textEffect3-expected.checksum
LayoutTests/platform/mac/svg/batik/text/textEffect3-expected.png
LayoutTests/platform/mac/svg/custom/relative-sized-inner-svg-expected.checksum
LayoutTests/platform/mac/svg/custom/relative-sized-inner-svg-expected.png
LayoutTests/platform/mac/svg/custom/relative-sized-inner-svg-expected.txt
LayoutTests/platform/mac/svg/custom/relative-sized-use-on-symbol-expected.txt
LayoutTests/platform/mac/svg/custom/relative-sized-use-without-attributes-on-symbol-expected.checksum
LayoutTests/platform/mac/svg/custom/relative-sized-use-without-attributes-on-symbol-expected.png
LayoutTests/platform/mac/svg/custom/relative-sized-use-without-attributes-on-symbol-expected.txt
LayoutTests/platform/mac/svg/custom/use-css-events-expected.txt
LayoutTests/platform/mac/svg/custom/use-on-symbol-inside-pattern-expected.txt
LayoutTests/platform/mac/svg/hixie/perf/007-expected.checksum
LayoutTests/platform/mac/svg/hixie/perf/007-expected.png
LayoutTests/platform/mac/svg/hixie/perf/007-expected.txt
LayoutTests/svg/custom/path-getTotalLength-expected.txt
LayoutTests/svg/dom/path-parser-expected.txt
LayoutTests/svg/dom/script-tests/path-parser.js
WebCore/Android.mk
WebCore/ChangeLog
WebCore/GNUmakefile.am
WebCore/WebCore.gypi
WebCore/WebCore.pro
WebCore/WebCore.vcproj/WebCore.vcproj
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/platform/graphics/FloatPoint.h
WebCore/svg/SVGAllInOne.cpp
WebCore/svg/SVGAnimateElement.cpp
WebCore/svg/SVGAnimateMotionElement.cpp
WebCore/svg/SVGGlyphElement.cpp
WebCore/svg/SVGParserUtilities.cpp
WebCore/svg/SVGParserUtilities.h
WebCore/svg/SVGPathBuilder.cpp [new file with mode: 0644]
WebCore/svg/SVGPathBuilder.h [new file with mode: 0644]
WebCore/svg/SVGPathConsumer.h [new file with mode: 0644]
WebCore/svg/SVGPathElement.cpp
WebCore/svg/SVGPathParser.cpp [new file with mode: 0644]
WebCore/svg/SVGPathParser.h [new file with mode: 0644]
WebCore/svg/SVGPathSegListBuilder.cpp [new file with mode: 0644]
WebCore/svg/SVGPathSegListBuilder.h [new file with mode: 0644]