From 49b6f6ae630f972b44fe34b9ddda600619aac6f0 Mon Sep 17 00:00:00 2001 From: "simon.fraser@apple.com" Date: Sun, 29 Nov 2015 18:47:08 +0000 Subject: [PATCH] Use SVGTransform::SVGTransformType instead of an unsigned short https://bugs.webkit.org/show_bug.cgi?id=151637 Reviewed by Brady Eidson. Make 'type' more strongly typed. * svg/SVGTransformable.cpp: (WebCore::SVGTransformable::parseTransformValue): (WebCore::parseAndSkipType): (WebCore::SVGTransformable::parseTransformType): (WebCore::SVGTransformable::parseTransformAttribute): * svg/SVGTransformable.h: git-svn-id: https://svn.webkit.org/repository/webkit/trunk@192787 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebCore/ChangeLog | 16 ++++++++++++++++ Source/WebCore/svg/SVGTransformable.cpp | 11 +++++++---- Source/WebCore/svg/SVGTransformable.h | 2 +- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 53dc7b3..274a328 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,19 @@ +2015-11-29 Simon Fraser + + Use SVGTransform::SVGTransformType instead of an unsigned short + https://bugs.webkit.org/show_bug.cgi?id=151637 + + Reviewed by Brady Eidson. + + Make 'type' more strongly typed. + + * svg/SVGTransformable.cpp: + (WebCore::SVGTransformable::parseTransformValue): + (WebCore::parseAndSkipType): + (WebCore::SVGTransformable::parseTransformType): + (WebCore::SVGTransformable::parseTransformAttribute): + * svg/SVGTransformable.h: + 2015-11-27 Brady Eidson Modern IDB: Class-ify IDBGetResult making it impossible to get the data members wrong. diff --git a/Source/WebCore/svg/SVGTransformable.cpp b/Source/WebCore/svg/SVGTransformable.cpp index 4e156c62..7a50caa 100644 --- a/Source/WebCore/svg/SVGTransformable.cpp +++ b/Source/WebCore/svg/SVGTransformable.cpp @@ -93,7 +93,7 @@ SVGTransformable::~SVGTransformable() { } -bool SVGTransformable::parseTransformValue(unsigned type, const UChar*& ptr, const UChar* end, SVGTransform& transform) +bool SVGTransformable::parseTransformValue(SVGTransform::SVGTransformType type, const UChar*& ptr, const UChar* end, SVGTransform& transform) { if (type == SVGTransform::SVG_TRANSFORM_UNKNOWN) return false; @@ -104,6 +104,9 @@ bool SVGTransformable::parseTransformValue(unsigned type, const UChar*& ptr, con return false; switch (type) { + case SVGTransform::SVG_TRANSFORM_UNKNOWN: + ASSERT_NOT_REACHED(); + break; case SVGTransform::SVG_TRANSFORM_SKEWX: transform.setSkewX(values[0]); break; @@ -143,7 +146,7 @@ static const UChar translateDesc[] = {'t', 'r', 'a', 'n', 's', 'l', 'a', 't', ' static const UChar rotateDesc[] = {'r', 'o', 't', 'a', 't', 'e'}; static const UChar matrixDesc[] = {'m', 'a', 't', 'r', 'i', 'x'}; -static inline bool parseAndSkipType(const UChar*& currTransform, const UChar* end, unsigned short& type) +static inline bool parseAndSkipType(const UChar*& currTransform, const UChar* end, SVGTransform::SVGTransformType& type) { if (currTransform >= end) return false; @@ -171,7 +174,7 @@ static inline bool parseAndSkipType(const UChar*& currTransform, const UChar* en SVGTransform::SVGTransformType SVGTransformable::parseTransformType(const String& typeString) { - unsigned short type = SVGTransform::SVG_TRANSFORM_UNKNOWN; + SVGTransform::SVGTransformType type = SVGTransform::SVG_TRANSFORM_UNKNOWN; auto upconvertedCharacters = StringView(typeString).upconvertedCharacters(); const UChar* characters = upconvertedCharacters; parseAndSkipType(characters, characters + typeString.length(), type); @@ -186,7 +189,7 @@ bool SVGTransformable::parseTransformAttribute(SVGTransformList& list, const UCh bool delimParsed = false; while (currTransform < end) { delimParsed = false; - unsigned short type = SVGTransform::SVG_TRANSFORM_UNKNOWN; + SVGTransform::SVGTransformType type = SVGTransform::SVG_TRANSFORM_UNKNOWN; skipOptionalSVGSpaces(currTransform, end); if (!parseAndSkipType(currTransform, end, type)) diff --git a/Source/WebCore/svg/SVGTransformable.h b/Source/WebCore/svg/SVGTransformable.h index 98521b6..cc3545b 100644 --- a/Source/WebCore/svg/SVGTransformable.h +++ b/Source/WebCore/svg/SVGTransformable.h @@ -40,7 +40,7 @@ public: virtual ~SVGTransformable(); static bool parseTransformAttribute(SVGTransformList&, const UChar*& ptr, const UChar* end, TransformParsingMode mode = ClearList); - static bool parseTransformValue(unsigned type, const UChar*& ptr, const UChar* end, SVGTransform&); + static bool parseTransformValue(SVGTransform::SVGTransformType, const UChar*& ptr, const UChar* end, SVGTransform&); static SVGTransform::SVGTransformType parseTransformType(const String&); virtual AffineTransform localCoordinateSpaceTransform(SVGLocatable::CTMScope) const override { return animatedLocalTransform(); } -- 1.8.3.1