| Index: Source/core/svg/SVGPathByteStreamSource.cpp
|
| diff --git a/Source/core/svg/SVGPathByteStreamSource.cpp b/Source/core/svg/SVGPathByteStreamSource.cpp
|
| index 98b99b8a01103a365466d1b1ac5261c1bc6a4221..5511d57e0d9bf0664946530c924ff82286f02b69 100644
|
| --- a/Source/core/svg/SVGPathByteStreamSource.cpp
|
| +++ b/Source/core/svg/SVGPathByteStreamSource.cpp
|
| @@ -27,78 +27,66 @@ bool SVGPathByteStreamSource::hasMoreData() const
|
| return m_streamCurrent < m_streamEnd;
|
| }
|
|
|
| -bool SVGPathByteStreamSource::parseSVGSegmentType(SVGPathSegType& pathSegType)
|
| +SVGPathSegType SVGPathByteStreamSource::peekSegmentType()
|
| {
|
| - pathSegType = static_cast<SVGPathSegType>(readSVGSegmentType());
|
| - return true;
|
| + ASSERT(hasMoreData());
|
| + ASSERT(m_streamCurrent + sizeof(unsigned short) <= m_streamEnd);
|
| + unsigned short commandBytes;
|
| + memcpy(&commandBytes, m_streamCurrent, sizeof(commandBytes));
|
| + return static_cast<SVGPathSegType>(commandBytes);
|
| }
|
|
|
| -SVGPathSegType SVGPathByteStreamSource::nextCommand(SVGPathSegType)
|
| +PathSegmentData SVGPathByteStreamSource::parseSegment()
|
| {
|
| - return static_cast<SVGPathSegType>(readSVGSegmentType());
|
| -}
|
| -
|
| -bool SVGPathByteStreamSource::parseMoveToSegment(FloatPoint& targetPoint)
|
| -{
|
| - targetPoint = readFloatPoint();
|
| - return true;
|
| -}
|
| -
|
| -bool SVGPathByteStreamSource::parseLineToSegment(FloatPoint& targetPoint)
|
| -{
|
| - targetPoint = readFloatPoint();
|
| - return true;
|
| -}
|
| -
|
| -bool SVGPathByteStreamSource::parseLineToHorizontalSegment(float& x)
|
| -{
|
| - x = readFloat();
|
| - return true;
|
| -}
|
| -
|
| -bool SVGPathByteStreamSource::parseLineToVerticalSegment(float& y)
|
| -{
|
| - y = readFloat();
|
| - return true;
|
| -}
|
| + ASSERT(hasMoreData());
|
| + PathSegmentData segment;
|
| + segment.command = static_cast<SVGPathSegType>(readSVGSegmentType());
|
|
|
| -bool SVGPathByteStreamSource::parseCurveToCubicSegment(FloatPoint& point1, FloatPoint& point2, FloatPoint& targetPoint)
|
| -{
|
| - point1 = readFloatPoint();
|
| - point2 = readFloatPoint();
|
| - targetPoint = readFloatPoint();
|
| - return true;
|
| -}
|
| -
|
| -bool SVGPathByteStreamSource::parseCurveToCubicSmoothSegment(FloatPoint& point2, FloatPoint& targetPoint)
|
| -{
|
| - point2 = readFloatPoint();
|
| - targetPoint = readFloatPoint();
|
| - return true;
|
| -}
|
| -
|
| -bool SVGPathByteStreamSource::parseCurveToQuadraticSegment(FloatPoint& point1, FloatPoint& targetPoint)
|
| -{
|
| - point1 = readFloatPoint();
|
| - targetPoint = readFloatPoint();
|
| - return true;
|
| -}
|
| -
|
| -bool SVGPathByteStreamSource::parseCurveToQuadraticSmoothSegment(FloatPoint& targetPoint)
|
| -{
|
| - targetPoint = readFloatPoint();
|
| - return true;
|
| -}
|
| -
|
| -bool SVGPathByteStreamSource::parseArcToSegment(float& rx, float& ry, float& angle, bool& largeArc, bool& sweep, FloatPoint& targetPoint)
|
| -{
|
| - rx = readFloat();
|
| - ry = readFloat();
|
| - angle = readFloat();
|
| - largeArc = readFlag();
|
| - sweep = readFlag();
|
| - targetPoint = readFloatPoint();
|
| - return true;
|
| + switch (segment.command) {
|
| + case PathSegCurveToCubicRel:
|
| + case PathSegCurveToCubicAbs:
|
| + segment.point1 = readFloatPoint();
|
| + /* fall through */
|
| + case PathSegCurveToCubicSmoothRel:
|
| + case PathSegCurveToCubicSmoothAbs:
|
| + segment.point2 = readFloatPoint();
|
| + /* fall through */
|
| + case PathSegMoveToRel:
|
| + case PathSegMoveToAbs:
|
| + case PathSegLineToRel:
|
| + case PathSegLineToAbs:
|
| + case PathSegCurveToQuadraticSmoothRel:
|
| + case PathSegCurveToQuadraticSmoothAbs:
|
| + segment.targetPoint = readFloatPoint();
|
| + break;
|
| + case PathSegLineToHorizontalRel:
|
| + case PathSegLineToHorizontalAbs:
|
| + segment.targetPoint.setX(readFloat());
|
| + break;
|
| + case PathSegLineToVerticalRel:
|
| + case PathSegLineToVerticalAbs:
|
| + segment.targetPoint.setY(readFloat());
|
| + break;
|
| + case PathSegClosePath:
|
| + break;
|
| + case PathSegCurveToQuadraticRel:
|
| + case PathSegCurveToQuadraticAbs:
|
| + segment.point1 = readFloatPoint();
|
| + segment.targetPoint = readFloatPoint();
|
| + break;
|
| + case PathSegArcRel:
|
| + case PathSegArcAbs: {
|
| + segment.point1 = readFloatPoint(); // rx and ry
|
| + segment.point2.setX(readFloat()); // angle
|
| + segment.arcLarge = readFlag();
|
| + segment.arcSweep = readFlag();
|
| + segment.targetPoint = readFloatPoint();
|
| + break;
|
| + }
|
| + default:
|
| + ASSERT_NOT_REACHED();
|
| + }
|
| + return segment;
|
| }
|
|
|
| }
|
|
|