From 66b4b70e4dd4323fc44ce31cccaeb4e8cc26fe8c Mon Sep 17 00:00:00 2001 From: Robert Longson Date: Wed, 13 Sep 2023 14:27:36 +0000 Subject: [PATCH] Bug 1852867 - Replace call to isalpha in SVGDataParser::IsAlpha with a call to mozilla::IsAsciiAlpha r=mstange Differential Revision: https://phabricator.services.mozilla.com/D188071 --- dom/svg/SVGDataParser.h | 6 ------ dom/svg/SVGPathDataParser.cpp | 18 +++++++++--------- dom/svg/SVGTransformListParser.cpp | 2 +- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/dom/svg/SVGDataParser.h b/dom/svg/SVGDataParser.h index 9e0996361a4e..fddd2696aad0 100644 --- a/dom/svg/SVGDataParser.h +++ b/dom/svg/SVGDataParser.h @@ -7,7 +7,6 @@ #ifndef DOM_SVG_SVGDATAPARSER_H_ #define DOM_SVG_SVGDATAPARSER_H_ -#include #include "mozilla/RangedPtr.h" #include "nsStringFwd.h" @@ -22,11 +21,6 @@ class SVGDataParser { explicit SVGDataParser(const nsAString& aValue); protected: - static bool IsAlpha(char16_t aCh) { - // Exclude non-ascii characters before calling isalpha - return (aCh & 0x7f) == aCh && isalpha(aCh); - } - // Returns true if there are more characters to read, false otherwise. bool SkipCommaWsp(); diff --git a/dom/svg/SVGPathDataParser.cpp b/dom/svg/SVGPathDataParser.cpp index b08b98c98fd7..3574a0d9b5cf 100644 --- a/dom/svg/SVGPathDataParser.cpp +++ b/dom/svg/SVGPathDataParser.cpp @@ -130,7 +130,7 @@ bool SVGPathDataParser::ParseMoveto() { return false; } - if (!SkipWsp() || IsAlpha(*mIter)) { + if (!SkipWsp() || IsAsciiAlpha(*mIter)) { // End of data, or start of a new command return true; } @@ -163,7 +163,7 @@ bool SVGPathDataParser::ParseLineto(bool aAbsCoords) { return false; } - if (!SkipWsp() || IsAlpha(*mIter)) { + if (!SkipWsp() || IsAsciiAlpha(*mIter)) { // End of data, or start of a new command return true; } @@ -187,7 +187,7 @@ bool SVGPathDataParser::ParseHorizontalLineto(bool aAbsCoords) { return false; } - if (!SkipWsp() || IsAlpha(*mIter)) { + if (!SkipWsp() || IsAsciiAlpha(*mIter)) { // End of data, or start of a new command return true; } @@ -211,7 +211,7 @@ bool SVGPathDataParser::ParseVerticalLineto(bool aAbsCoords) { return false; } - if (!SkipWsp() || IsAlpha(*mIter)) { + if (!SkipWsp() || IsAsciiAlpha(*mIter)) { // End of data, or start of a new command return true; } @@ -236,7 +236,7 @@ bool SVGPathDataParser::ParseCurveto(bool aAbsCoords) { return false; } - if (!SkipWsp() || IsAlpha(*mIter)) { + if (!SkipWsp() || IsAsciiAlpha(*mIter)) { // End of data, or start of a new command return true; } @@ -260,7 +260,7 @@ bool SVGPathDataParser::ParseSmoothCurveto(bool aAbsCoords) { return false; } - if (!SkipWsp() || IsAlpha(*mIter)) { + if (!SkipWsp() || IsAsciiAlpha(*mIter)) { // End of data, or start of a new command return true; } @@ -284,7 +284,7 @@ bool SVGPathDataParser::ParseQuadBezierCurveto(bool aAbsCoords) { return false; } - if (!SkipWsp() || IsAlpha(*mIter)) { + if (!SkipWsp() || IsAsciiAlpha(*mIter)) { // Start of a new command return true; } @@ -308,7 +308,7 @@ bool SVGPathDataParser::ParseSmoothQuadBezierCurveto(bool aAbsCoords) { return false; } - if (!SkipWsp() || IsAlpha(*mIter)) { + if (!SkipWsp() || IsAsciiAlpha(*mIter)) { // End of data, or start of a new command return true; } @@ -339,7 +339,7 @@ bool SVGPathDataParser::ParseEllipticalArc(bool aAbsCoords) { return false; } - if (!SkipWsp() || IsAlpha(*mIter)) { + if (!SkipWsp() || IsAsciiAlpha(*mIter)) { // End of data, or start of a new command return true; } diff --git a/dom/svg/SVGTransformListParser.cpp b/dom/svg/SVGTransformListParser.cpp index 692577bea70b..227139fe0197 100644 --- a/dom/svg/SVGTransformListParser.cpp +++ b/dom/svg/SVGTransformListParser.cpp @@ -49,7 +49,7 @@ bool SVGTransformListParser::ParseTransforms() { bool SVGTransformListParser::ParseTransform() { RangedPtr start(mIter); - while (IsAlpha(*mIter)) { + while (IsAsciiAlpha(*mIter)) { ++mIter; if (mIter == mEnd) { return false;