2008-05-11 Sam Weinig <sam@webkit.org>
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 May 2008 00:34:19 +0000 (00:34 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 12 May 2008 00:34:19 +0000 (00:34 +0000)
        Reviewed by Mark Rowe.

        Move some generic parsing functions into a new ParserUtilities header so that
        they can be used for non-SVG builds too.

        * WebCore.vcproj/WebCore.vcproj:
        * WebCore.xcodeproj/project.pbxproj:
        * platform/text/ParserUtilities.h: Added.
        (WebCore::skipString):
        * svg/SVGParserUtilities.h:
        (WebCore::isWhitespace):
        (WebCore::skipOptionalSpaces):
        (WebCore::skipOptionalSpacesOrDelimiter):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@33034 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/WebCore.vcproj/WebCore.vcproj
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/platform/text/ParserUtilities.h [new file with mode: 0644]
WebCore/svg/SVGParserUtilities.h

index c6d84cd..f08fa3d 100644 (file)
@@ -1,5 +1,21 @@
 2008-05-11  Sam Weinig  <sam@webkit.org>
 
+        Reviewed by Mark Rowe.
+
+        Move some generic parsing functions into a new ParserUtilities header so that
+        they can be used for non-SVG builds too.
+
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/text/ParserUtilities.h: Added.
+        (WebCore::skipString):
+        * svg/SVGParserUtilities.h:
+        (WebCore::isWhitespace):
+        (WebCore::skipOptionalSpaces):
+        (WebCore::skipOptionalSpacesOrDelimiter):
+
+2008-05-11  Sam Weinig  <sam@webkit.org>
+
         Reviewed by Dan Bernstein.
 
         Add scaffolding for the implementation of Access Control for Cross-site Requests. 
index 8bf6f08..1078613 100644 (file)
                                        >\r
                                </File>\r
                                <File\r
+                                       RelativePath="..\platform\text\ParserUtilities.h"\r
+                                       >\r
+                               </File>\r
+                               <File\r
                                        RelativePath="..\platform\text\PlatformString.h"\r
                                        >\r
                                </File>\r
index 9ab3556..ec94eaa 100644 (file)
                BC6DC7A10C1A4BFA004E2017 /* JSHTMLAllCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = BC6DC7A00C1A4BFA004E2017 /* JSHTMLAllCollection.h */; };
                BC6E2B1A0C04B93600444EF8 /* DOMHTMLDocumentPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = BC6E2B190C04B93600444EF8 /* DOMHTMLDocumentPrivate.h */; };
                BC6E2B290C04B95400444EF8 /* DOMHTMLDocumentPrivate.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = BC6E2B190C04B93600444EF8 /* DOMHTMLDocumentPrivate.h */; };
+               BC76AC130DD7AD5C00415F34 /* ParserUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = BC76AC110DD7AD5C00415F34 /* ParserUtilities.h */; };
                BC772B3B0C4EA91E0083285F /* CSSHelper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC772B350C4EA91E0083285F /* CSSHelper.cpp */; };
                BC772B3C0C4EA91E0083285F /* CSSHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = BC772B360C4EA91E0083285F /* CSSHelper.h */; settings = {ATTRIBUTES = (Private, ); }; };
                BC772B3D0C4EA91E0083285F /* CSSParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC772B370C4EA91E0083285F /* CSSParser.cpp */; };
                BC6DADF90A19602B00E5CD14 /* WebFontCache.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = WebFontCache.mm; sourceTree = "<group>"; };
                BC6DC7A00C1A4BFA004E2017 /* JSHTMLAllCollection.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSHTMLAllCollection.h; sourceTree = "<group>"; };
                BC6E2B190C04B93600444EF8 /* DOMHTMLDocumentPrivate.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMHTMLDocumentPrivate.h; sourceTree = "<group>"; };
+               BC76AC110DD7AD5C00415F34 /* ParserUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParserUtilities.h; sourceTree = "<group>"; };
                BC772B350C4EA91E0083285F /* CSSHelper.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CSSHelper.cpp; sourceTree = "<group>"; };
                BC772B360C4EA91E0083285F /* CSSHelper.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = CSSHelper.h; sourceTree = "<group>"; };
                BC772B370C4EA91E0083285F /* CSSParser.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CSSParser.cpp; sourceTree = "<group>"; };
                                B2C3D9F50D006C1D00EF6F26 /* CharacterNames.h */,
                                B2C3D9F60D006C1D00EF6F26 /* CString.cpp */,
                                B2C3D9F70D006C1D00EF6F26 /* CString.h */,
+                               BC76AC110DD7AD5C00415F34 /* ParserUtilities.h */,
                                B2C3D9FB0D006C1D00EF6F26 /* PlatformString.h */,
                                B2C3D9FC0D006C1D00EF6F26 /* RegularExpression.cpp */,
                                B2C3D9FD0D006C1D00EF6F26 /* RegularExpression.h */,
                                BC34C33B0DD607DE00090123 /* AccessControlList.h in Headers */,
                                BC34C33D0DD607DE00090123 /* AccessItem.h in Headers */,
                                BC34C33F0DD607DE00090123 /* AccessItemRule.h in Headers */,
+                               BC76AC130DD7AD5C00415F34 /* ParserUtilities.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
diff --git a/WebCore/platform/text/ParserUtilities.h b/WebCore/platform/text/ParserUtilities.h
new file mode 100644 (file)
index 0000000..3105214
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * 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 "PlatformString.h"
+
+namespace WebCore {
+
+    inline bool skipString(const UChar*& ptr, const UChar* end, const UChar* name, int length)
+    {
+        if (end - ptr < length)
+            return false;
+        if (memcmp(name, ptr, sizeof(UChar) * length))
+            return false;
+        ptr += length;
+        return true;
+    }
+
+    inline bool skipString(const UChar*& ptr, const UChar* 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;
+    }
+
+} // namspace WebCore
+
+#endif // ParserUtilities_h
index 17c8b1b..8d3c9b2 100644 (file)
@@ -1,4 +1,4 @@
-/* This file is part of the KDE project
+/*
    Copyright (C) 2002, 2003 The Karbon Developers
                  2006, 2007 Rob Buis <buis@kde.org>
 
 #define SVGParserUtilities_h
 #if ENABLE(SVG)
 
-#include <PlatformString.h>
+#include "ParserUtilities.h"
+
+namespace WebCore {
 
-namespace WebCore
-{
     class Path;
     class SVGPointList;
     class SVGPathSegList;
@@ -35,18 +35,19 @@ namespace WebCore
 
     // SVG allows several different whitespace characters:
     // http://www.w3.org/TR/SVG/paths.html#PathDataBNF
-    static inline bool isWhitespace(const UChar& c) {
+    inline bool isWhitespace(const UChar& c)
+    {
         return (c == ' ' || c == '\t' || c == '\n' || c == '\r');
     }
 
-    static inline bool skipOptionalSpaces(const UChar*& ptr, const UChar* end)
+    inline bool skipOptionalSpaces(const UChar*& ptr, const UChar* end)
     {
         while (ptr < end && isWhitespace(*ptr))
             ptr++;
         return ptr < end;
     }
 
-    static inline bool skipOptionalSpacesOrDelimiter(const UChar*& ptr, const UChar *end, UChar delimiter = ',')
+    inline bool skipOptionalSpacesOrDelimiter(const UChar*& ptr, const UChar* end, UChar delimiter = ',')
     {
         if (ptr < end && !isWhitespace(*ptr) && *ptr != delimiter)
             return false;
@@ -59,28 +60,6 @@ namespace WebCore
         return ptr < end;
     }
 
-    static inline bool skipString(const UChar*& ptr, const UChar* end, const UChar* name, int length)
-    {
-        if (end - ptr < length)
-            return false;
-        if (memcmp(name, ptr, sizeof(UChar) * length))
-            return false;
-        ptr += length;
-        return true;
-    }
-
-    static inline bool skipString(const UChar*& ptr, const UChar* 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;
-    }
-
     bool pointsListFromSVGData(SVGPointList* pointsList, const String& points);
     bool pathFromSVGData(Path& path, const String& d);
     bool pathSegListFromSVGData(SVGPathSegList* pathSegList, const String& d, bool process = false);
@@ -89,4 +68,4 @@ namespace WebCore
 } // namespace WebCore
 
 #endif // ENABLE(SVG)
-#endif
+#endif // SVGParserUtilities_h