Commit 39cc523b authored by fs's avatar fs Committed by Commit bot

Remove platform/text/ParserUtilities.h

platform/ParsingUtilities.h caters to the same needs, so transition
users of skipString(...) to skipToken(...) and remove
platform/text/ParserUtilities.h.

Review-Url: https://codereview.chromium.org/2176623003
Cr-Commit-Position: refs/heads/master@{#407187}
parent 8502cd58
......@@ -23,8 +23,8 @@
#include "core/svg/SVGAnimationElement.h"
#include "core/svg/SVGParserUtilities.h"
#include "platform/ParsingUtilities.h"
#include "platform/geometry/FloatRect.h"
#include "platform/text/ParserUtilities.h"
#include "platform/transforms/AffineTransform.h"
#include "wtf/text/WTFString.h"
......@@ -65,7 +65,7 @@ SVGParsingError SVGPreserveAspectRatio::parseInternal(const CharType*& ptr, cons
return SVGParsingError(SVGParseStatus::ExpectedEnumeration, ptr - start);
if (*ptr == 'n') {
if (!skipString(ptr, end, "none"))
if (!skipToken(ptr, end, "none"))
return SVGParsingError(SVGParseStatus::ExpectedEnumeration, ptr - start);
align = SVG_PRESERVEASPECTRATIO_NONE;
skipOptionalSVGSpaces(ptr, end);
......@@ -128,11 +128,11 @@ SVGParsingError SVGPreserveAspectRatio::parseInternal(const CharType*& ptr, cons
if (ptr < end) {
if (*ptr == 'm') {
if (!skipString(ptr, end, "meet"))
if (!skipToken(ptr, end, "meet"))
return SVGParsingError(SVGParseStatus::ExpectedEnumeration, ptr - start);
skipOptionalSVGSpaces(ptr, end);
} else if (*ptr == 's') {
if (!skipString(ptr, end, "slice"))
if (!skipToken(ptr, end, "slice"))
return SVGParsingError(SVGParseStatus::ExpectedEnumeration, ptr - start);
skipOptionalSVGSpaces(ptr, end);
if (align != SVG_PRESERVEASPECTRATIO_NONE)
......
......@@ -26,7 +26,7 @@
#include "core/SVGNames.h"
#include "core/svg/SVGParserUtilities.h"
#include "core/svg/SVGTransformDistance.h"
#include "platform/text/ParserUtilities.h"
#include "platform/ParsingUtilities.h"
#include "wtf/text/StringBuilder.h"
#include "wtf/text/WTFString.h"
......@@ -64,13 +64,6 @@ bool SVGTransformList::concatenate(AffineTransform& result) const
namespace {
const LChar skewXDesc[] = {'s', 'k', 'e', 'w', 'X'};
const LChar skewYDesc[] = {'s', 'k', 'e', 'w', 'Y'};
const LChar scaleDesc[] = {'s', 'c', 'a', 'l', 'e'};
const LChar translateDesc[] = {'t', 'r', 'a', 'n', 's', 'l', 'a', 't', 'e'};
const LChar rotateDesc[] = {'r', 'o', 't', 'a', 't', 'e'};
const LChar matrixDesc[] = {'m', 'a', 't', 'r', 'i', 'x'};
template<typename CharType>
SVGTransformType parseAndSkipTransformType(const CharType*& ptr, const CharType* end)
{
......@@ -78,20 +71,20 @@ SVGTransformType parseAndSkipTransformType(const CharType*& ptr, const CharType*
return SVG_TRANSFORM_UNKNOWN;
if (*ptr == 's') {
if (skipString(ptr, end, skewXDesc, WTF_ARRAY_LENGTH(skewXDesc)))
if (skipToken(ptr, end, "skewX"))
return SVG_TRANSFORM_SKEWX;
if (skipString(ptr, end, skewYDesc, WTF_ARRAY_LENGTH(skewYDesc)))
if (skipToken(ptr, end, "skewY"))
return SVG_TRANSFORM_SKEWY;
if (skipString(ptr, end, scaleDesc, WTF_ARRAY_LENGTH(scaleDesc)))
if (skipToken(ptr, end, "scale"))
return SVG_TRANSFORM_SCALE;
return SVG_TRANSFORM_UNKNOWN;
}
if (skipString(ptr, end, translateDesc, WTF_ARRAY_LENGTH(translateDesc)))
if (skipToken(ptr, end, "translate"))
return SVG_TRANSFORM_TRANSLATE;
if (skipString(ptr, end, rotateDesc, WTF_ARRAY_LENGTH(rotateDesc)))
if (skipToken(ptr, end, "rotate"))
return SVG_TRANSFORM_ROTATE;
if (skipString(ptr, end, matrixDesc, WTF_ARRAY_LENGTH(matrixDesc)))
if (skipToken(ptr, end, "matrix"))
return SVG_TRANSFORM_MATRIX;
return SVG_TRANSFORM_UNKNOWN;
......
......@@ -25,7 +25,7 @@
#include "core/dom/ExceptionCode.h"
#include "core/svg/SVGAnimatedTransformList.h"
#include "core/svg/SVGParserUtilities.h"
#include "platform/text/ParserUtilities.h"
#include "platform/ParsingUtilities.h"
namespace blink {
......@@ -132,17 +132,10 @@ void SVGViewSpec::setZoomAndPan(unsigned short, ExceptionState& exceptionState)
exceptionState.throwDOMException(NoModificationAllowedError, ExceptionMessages::readOnly());
}
static const LChar svgViewSpec[] = {'s', 'v', 'g', 'V', 'i', 'e', 'w'};
static const LChar viewBoxSpec[] = {'v', 'i', 'e', 'w', 'B', 'o', 'x'};
static const LChar preserveAspectRatioSpec[] = {'p', 'r', 'e', 's', 'e', 'r', 'v', 'e', 'A', 's', 'p', 'e', 'c', 't', 'R', 'a', 't', 'i', 'o'};
static const LChar transformSpec[] = {'t', 'r', 'a', 'n', 's', 'f', 'o', 'r', 'm'};
static const LChar zoomAndPanSpec[] = {'z', 'o', 'o', 'm', 'A', 'n', 'd', 'P', 'a', 'n'};
static const LChar viewTargetSpec[] = {'v', 'i', 'e', 'w', 'T', 'a', 'r', 'g', 'e', 't'};
template<typename CharType>
bool SVGViewSpec::parseViewSpecInternal(const CharType* ptr, const CharType* end)
{
if (!skipString(ptr, end, svgViewSpec, WTF_ARRAY_LENGTH(svgViewSpec)))
if (!skipToken(ptr, end, "svgView"))
return false;
if (ptr >= end || *ptr != '(')
......@@ -151,7 +144,7 @@ bool SVGViewSpec::parseViewSpecInternal(const CharType* ptr, const CharType* end
while (ptr < end && *ptr != ')') {
if (*ptr == 'v') {
if (skipString(ptr, end, viewBoxSpec, WTF_ARRAY_LENGTH(viewBoxSpec))) {
if (skipToken(ptr, end, "viewBox")) {
if (ptr >= end || *ptr != '(')
return false;
ptr++;
......@@ -165,7 +158,7 @@ bool SVGViewSpec::parseViewSpecInternal(const CharType* ptr, const CharType* end
if (ptr >= end || *ptr != ')')
return false;
ptr++;
} else if (skipString(ptr, end, viewTargetSpec, WTF_ARRAY_LENGTH(viewTargetSpec))) {
} else if (skipToken(ptr, end, "viewTarget")) {
if (ptr >= end || *ptr != '(')
return false;
const CharType* viewTargetStart = ++ptr;
......@@ -178,7 +171,7 @@ bool SVGViewSpec::parseViewSpecInternal(const CharType* ptr, const CharType* end
} else
return false;
} else if (*ptr == 'z') {
if (!skipString(ptr, end, zoomAndPanSpec, WTF_ARRAY_LENGTH(zoomAndPanSpec)))
if (!skipToken(ptr, end, "zoomAndPan"))
return false;
if (ptr >= end || *ptr != '(')
return false;
......@@ -189,7 +182,7 @@ bool SVGViewSpec::parseViewSpecInternal(const CharType* ptr, const CharType* end
return false;
ptr++;
} else if (*ptr == 'p') {
if (!skipString(ptr, end, preserveAspectRatioSpec, WTF_ARRAY_LENGTH(preserveAspectRatioSpec)))
if (!skipToken(ptr, end, "preserveAspectRatio"))
return false;
if (ptr >= end || *ptr != '(')
return false;
......@@ -200,7 +193,7 @@ bool SVGViewSpec::parseViewSpecInternal(const CharType* ptr, const CharType* end
return false;
ptr++;
} else if (*ptr == 't') {
if (!skipString(ptr, end, transformSpec, WTF_ARRAY_LENGTH(transformSpec)))
if (!skipToken(ptr, end, "transform"))
return false;
if (ptr >= end || *ptr != '(')
return false;
......
......@@ -21,7 +21,7 @@
#include "core/svg/SVGZoomAndPan.h"
#include "platform/text/ParserUtilities.h"
#include "platform/ParsingUtilities.h"
namespace blink {
......@@ -40,17 +40,14 @@ bool SVGZoomAndPan::isKnownAttribute(const QualifiedName& attrName)
return attrName == SVGNames::zoomAndPanAttr;
}
static const LChar disable[] = {'d', 'i', 's', 'a', 'b', 'l', 'e'};
static const LChar magnify[] = {'m', 'a', 'g', 'n', 'i', 'f', 'y'};
template<typename CharType>
static bool parseZoomAndPanInternal(const CharType*& start, const CharType* end, SVGZoomAndPanType& zoomAndPan)
{
if (skipString(start, end, disable, WTF_ARRAY_LENGTH(disable))) {
if (skipToken(start, end, "disable")) {
zoomAndPan = SVGZoomAndPanDisable;
return true;
}
if (skipString(start, end, magnify, WTF_ARRAY_LENGTH(magnify))) {
if (skipToken(start, end, "magnify")) {
zoomAndPan = SVGZoomAndPanMagnify;
return true;
}
......
......@@ -1000,7 +1000,6 @@
'text/LocaleToScriptMapping.h',
'text/LocaleWin.cpp',
'text/LocaleWin.h',
'text/ParserUtilities.h',
'text/PlatformLocale.cpp',
'text/PlatformLocale.h',
'text/QuotedPrintable.cpp',
......
/*
* Copyright (C) 2008 Apple Inc. All Rights Reserved.
* Copyright (C) 2002, 2003 The Karbon Developers
* Copyright (C) 2006, 2007 Rob Buis <buis@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef ParserUtilities_h
#define ParserUtilities_h
#include "wtf/text/WTFString.h"
namespace blink {
template<typename CharType>
inline bool skipString(const CharType*& ptr, const CharType* end, const CharType* name, int length)
{
if (end - ptr < length)
return false;
if (memcmp(name, ptr, sizeof(CharType) * length))
return false;
ptr += length;
return true;
}
inline bool skipString(const UChar*& ptr, const UChar* end, const LChar* name, int length)
{
if (end - ptr < length)
return false;
for (int i = 0; i < length; ++i) {
if (ptr[i] != name[i])
return false;
}
ptr += length;
return true;
}
template<typename CharType>
inline bool skipString(const CharType*& ptr, const CharType* end, const char* str)
{
int length = strlen(str);
if (end - ptr < length)
return false;
for (int i = 0; i < length; ++i) {
if (ptr[i] != str[i])
return false;
}
ptr += length;
return true;
}
} // namespace blink
#endif // ParserUtilities_h
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment