summaryrefslogtreecommitdiff
path: root/Source/WebCore/svg/SVGParserUtilities.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/svg/SVGParserUtilities.cpp')
-rw-r--r--Source/WebCore/svg/SVGParserUtilities.cpp45
1 files changed, 24 insertions, 21 deletions
diff --git a/Source/WebCore/svg/SVGParserUtilities.cpp b/Source/WebCore/svg/SVGParserUtilities.cpp
index b7ae15051..7e2d313a3 100644
--- a/Source/WebCore/svg/SVGParserUtilities.cpp
+++ b/Source/WebCore/svg/SVGParserUtilities.cpp
@@ -21,16 +21,14 @@
*/
#include "config.h"
-
-#if ENABLE(SVG)
#include "SVGParserUtilities.h"
#include "Document.h"
#include "FloatRect.h"
-#include "SVGPointList.h"
-
+#include "SVGPointListValues.h"
#include <limits>
#include <wtf/ASCIICType.h>
+#include <wtf/text/StringView.h>
namespace WebCore {
@@ -64,13 +62,12 @@ template <typename CharacterType, typename FloatType> static bool genericParseNu
sign = -1;
}
- if (ptr == end || ((*ptr < '0' || *ptr > '9') && *ptr != '.'))
- // The first character of a number must be one of [0-9+-.]
+ if (ptr == end || (!isASCIIDigit(*ptr) && *ptr != '.'))
return false;
// read the integer part, build right-to-left
const CharacterType* ptrStartIntPart = ptr;
- while (ptr < end && *ptr >= '0' && *ptr <= '9')
+ while (ptr < end && isASCIIDigit(*ptr))
++ptr; // Advance to first non-digit.
if (ptr != ptrStartIntPart) {
@@ -89,10 +86,10 @@ template <typename CharacterType, typename FloatType> static bool genericParseNu
ptr++;
// There must be a least one digit following the .
- if (ptr >= end || *ptr < '0' || *ptr > '9')
+ if (ptr >= end || !isASCIIDigit(*ptr))
return false;
- while (ptr < end && *ptr >= '0' && *ptr <= '9')
+ while (ptr < end && isASCIIDigit(*ptr))
decimal += (*(ptr++) - '0') * (frac *= static_cast<FloatType>(0.1));
}
@@ -110,10 +107,10 @@ template <typename CharacterType, typename FloatType> static bool genericParseNu
}
// There must be an exponent
- if (ptr >= end || *ptr < '0' || *ptr > '9')
+ if (ptr >= end || !isASCIIDigit(*ptr))
return false;
- while (ptr < end && *ptr >= '0' && *ptr <= '9') {
+ while (ptr < end && isASCIIDigit(*ptr)) {
exponent *= static_cast<FloatType>(10);
exponent += *ptr - '0';
ptr++;
@@ -166,7 +163,8 @@ bool parseNumber(const UChar*& ptr, const UChar* end, float& number, bool skip)
bool parseNumberFromString(const String& string, float& number, bool skip)
{
- const UChar* ptr = string.deprecatedCharacters();
+ auto upconvertedCharacters = StringView(string).upconvertedCharacters();
+ const UChar* ptr = upconvertedCharacters;
const UChar* end = ptr + string.length();
return genericParseNumber(ptr, end, number, skip) && ptr == end;
}
@@ -205,7 +203,9 @@ bool parseNumberOptionalNumber(const String& s, float& x, float& y)
{
if (s.isEmpty())
return false;
- const UChar* cur = s.deprecatedCharacters();
+
+ auto upconvertedCharacters = StringView(s).upconvertedCharacters();
+ const UChar* cur = upconvertedCharacters;
const UChar* end = cur + s.length();
if (!parseNumber(cur, end, x))
@@ -221,7 +221,8 @@ bool parseNumberOptionalNumber(const String& s, float& x, float& y)
bool parseRect(const String& string, FloatRect& rect)
{
- const UChar* ptr = string.deprecatedCharacters();
+ auto upconvertedCharacters = StringView(string).upconvertedCharacters();
+ const UChar* ptr = upconvertedCharacters;
const UChar* end = ptr + string.length();
skipOptionalSVGSpaces(ptr, end);
@@ -234,11 +235,12 @@ bool parseRect(const String& string, FloatRect& rect)
return valid;
}
-bool pointsListFromSVGData(SVGPointList& pointsList, const String& points)
+bool pointsListFromSVGData(SVGPointListValues& pointsList, const String& points)
{
if (points.isEmpty())
return true;
- const UChar* cur = points.deprecatedCharacters();
+ auto upconvertedCharacters = StringView(points).upconvertedCharacters();
+ const UChar* cur = upconvertedCharacters;
const UChar* end = cur + points.length();
skipOptionalSVGSpaces(cur, end);
@@ -272,7 +274,8 @@ bool parseGlyphName(const String& input, HashSet<String>& values)
// FIXME: Parsing error detection is missing.
values.clear();
- const UChar* ptr = input.deprecatedCharacters();
+ auto upconvertedCharacters = StringView(input).upconvertedCharacters();
+ const UChar* ptr = upconvertedCharacters;
const UChar* end = ptr + input.length();
skipOptionalSVGSpaces(ptr, end);
@@ -369,7 +372,8 @@ static bool parseUnicodeRange(const UChar* characters, unsigned length, UnicodeR
bool parseKerningUnicodeString(const String& input, UnicodeRanges& rangeList, HashSet<String>& stringList)
{
// FIXME: Parsing error detection is missing.
- const UChar* ptr = input.deprecatedCharacters();
+ auto upconvertedCharacters = StringView(input).upconvertedCharacters();
+ const UChar* ptr = upconvertedCharacters;
const UChar* end = ptr + input.length();
while (ptr < end) {
@@ -396,7 +400,8 @@ Vector<String> parseDelimitedString(const String& input, const char seperator)
{
Vector<String> values;
- const UChar* ptr = input.deprecatedCharacters();
+ auto upconvertedCharacters = StringView(input).upconvertedCharacters();
+ const UChar* ptr = upconvertedCharacters;
const UChar* end = ptr + input.length();
skipOptionalSVGSpaces(ptr, end);
@@ -482,5 +487,3 @@ template bool parseFloatPoint3(const LChar*& current, const LChar* end, FloatPoi
template bool parseFloatPoint3(const UChar*& current, const UChar* end, FloatPoint& point1, FloatPoint& point2, FloatPoint& point3);
}
-
-#endif // ENABLE(SVG)