Title: [91437] trunk/Source/WebCore
Revision
91437
Author
[email protected]
Date
2011-07-20 19:05:10 -0700 (Wed, 20 Jul 2011)

Log Message

Patch by Tim Horton <[email protected]> on 2011-07-20
Reviewed by Darin Adler.

Errors encountered within SVG documents should be reported to the console
https://bugs.webkit.org/show_bug.cgi?id=62599
<rdar://problem/9727074>

Add SVGLength::construct, which can be used to construct an SVGLength
as normal, but returns an SVGParsingError via a reference argument.
The function also takes another argument, which is whether or not
the SVGLength value is allowed to be negative. If not, an error is
thrown. It defaults to allowing negatives if not specified.

* GNUmakefile.list.am:
* svg/SVGLength.cpp:
(WebCore::SVGLength::construct):
(WebCore::SVGLength::rawValue):
* svg/SVGLength.h:
* svg/SVGElement.h:
* svg/SVGParsingError.h: Added.
* WebCore.gypi:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (91436 => 91437)


--- trunk/Source/WebCore/ChangeLog	2011-07-21 01:42:51 UTC (rev 91436)
+++ trunk/Source/WebCore/ChangeLog	2011-07-21 02:05:10 UTC (rev 91437)
@@ -1,3 +1,29 @@
+2011-07-20  Tim Horton  <[email protected]>
+
+        Reviewed by Darin Adler.
+
+        Errors encountered within SVG documents should be reported to the console
+        https://bugs.webkit.org/show_bug.cgi?id=62599
+        <rdar://problem/9727074>
+
+        Add SVGLength::construct, which can be used to construct an SVGLength
+        as normal, but returns an SVGParsingError via a reference argument.
+        The function also takes another argument, which is whether or not
+        the SVGLength value is allowed to be negative. If not, an error is
+        thrown. It defaults to allowing negatives if not specified.
+
+        * GNUmakefile.list.am:
+        * svg/SVGLength.cpp:
+        (WebCore::SVGLength::construct):
+        (WebCore::SVGLength::rawValue):
+        * svg/SVGLength.h:
+        * svg/SVGElement.h:
+        * svg/SVGParsingError.h: Added.
+        * WebCore.gypi:
+        * WebCore.pro:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+
 2011-07-20  Levi Weintraub  <[email protected]>
 
         Switch getTransformFromContainer and its uses to new layout types

Modified: trunk/Source/WebCore/GNUmakefile.list.am (91436 => 91437)


--- trunk/Source/WebCore/GNUmakefile.list.am	2011-07-21 01:42:51 UTC (rev 91436)
+++ trunk/Source/WebCore/GNUmakefile.list.am	2011-07-21 02:05:10 UTC (rev 91437)
@@ -3631,6 +3631,7 @@
 	Source/WebCore/svg/SVGPaint.h \
 	Source/WebCore/svg/SVGParserUtilities.cpp \
 	Source/WebCore/svg/SVGParserUtilities.h \
+	Source/WebCore/svg/SVGParsingError.h \
 	Source/WebCore/svg/SVGPathBlender.cpp \
 	Source/WebCore/svg/SVGPathBlender.h \
 	Source/WebCore/svg/SVGPathBuilder.cpp \

Modified: trunk/Source/WebCore/WebCore.gypi (91436 => 91437)


--- trunk/Source/WebCore/WebCore.gypi	2011-07-21 01:42:51 UTC (rev 91436)
+++ trunk/Source/WebCore/WebCore.gypi	2011-07-21 02:05:10 UTC (rev 91437)
@@ -5862,6 +5862,7 @@
             'svg/SVGPaint.cpp',
             'svg/SVGParserUtilities.cpp',
             'svg/SVGParserUtilities.h',
+            'svg/SVGParsingError.h',
             'svg/SVGPathBlender.cpp',
             'svg/SVGPathBlender.h',
             'svg/SVGPathBuilder.cpp',

Modified: trunk/Source/WebCore/WebCore.pro (91436 => 91437)


--- trunk/Source/WebCore/WebCore.pro	2011-07-21 01:42:51 UTC (rev 91436)
+++ trunk/Source/WebCore/WebCore.pro	2011-07-21 02:05:10 UTC (rev 91437)
@@ -2429,6 +2429,7 @@
     svg/SVGNumberList.h \
     svg/SVGPaint.h \
     svg/SVGParserUtilities.h \
+    svg/SVGParsingError.h \
     svg/SVGPathBuilder.h \
     svg/SVGPathConsumer.h \
     svg/SVGPathElement.h \

Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (91436 => 91437)


--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj	2011-07-21 01:42:51 UTC (rev 91436)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj	2011-07-21 02:05:10 UTC (rev 91437)
@@ -66350,6 +66350,10 @@
 				>
 			</File>
 			<File
+				RelativePath="..\svg\SVGParsingError.h"
+				>
+			</File>
+			<File
 				RelativePath="..\svg\SVGPathBlender.h"
 				>
 			</File>

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (91436 => 91437)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2011-07-21 01:42:51 UTC (rev 91436)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2011-07-21 02:05:10 UTC (rev 91437)
@@ -672,6 +672,7 @@
 		29A8124B0FBB9CA900510293 /* AXObjectCacheMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 29A812470FBB9CA900510293 /* AXObjectCacheMac.mm */; };
 		2BE8E2C712A589EC00FAD550 /* HTMLMetaCharsetParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 2BE8E2C612A589EC00FAD550 /* HTMLMetaCharsetParser.h */; };
 		2BE8E2C912A58A0100FAD550 /* HTMLMetaCharsetParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2BE8E2C812A58A0100FAD550 /* HTMLMetaCharsetParser.cpp */; };
+		2D3A0E3613A7D76100E85AF0 /* SVGParsingError.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D3A0E3513A7D76100E85AF0 /* SVGParsingError.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		2D9066060BE141D400956998 /* LayoutState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2D9066040BE141D400956998 /* LayoutState.cpp */; };
 		2D9066070BE141D400956998 /* LayoutState.h in Headers */ = {isa = PBXBuildFile; fileRef = 2D9066050BE141D400956998 /* LayoutState.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		2E0888D41148848A00AF4265 /* JSDOMFormData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2E0888D21148848A00AF4265 /* JSDOMFormData.cpp */; };
@@ -7156,6 +7157,7 @@
 		29A812470FBB9CA900510293 /* AXObjectCacheMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AXObjectCacheMac.mm; sourceTree = "<group>"; };
 		2BE8E2C612A589EC00FAD550 /* HTMLMetaCharsetParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HTMLMetaCharsetParser.h; path = parser/HTMLMetaCharsetParser.h; sourceTree = "<group>"; };
 		2BE8E2C812A58A0100FAD550 /* HTMLMetaCharsetParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = HTMLMetaCharsetParser.cpp; path = parser/HTMLMetaCharsetParser.cpp; sourceTree = "<group>"; };
+		2D3A0E3513A7D76100E85AF0 /* SVGParsingError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGParsingError.h; sourceTree = "<group>"; };
 		2D9066040BE141D400956998 /* LayoutState.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutState.cpp; sourceTree = "<group>"; };
 		2D9066050BE141D400956998 /* LayoutState.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = LayoutState.h; sourceTree = "<group>"; };
 		2D90660B0665D937006B6F1A /* ClipboardMac.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = ClipboardMac.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
@@ -17790,6 +17792,7 @@
 				B22278BF0D00BF200071B782 /* SVGPaint.idl */,
 				B22278C00D00BF200071B782 /* SVGParserUtilities.cpp */,
 				B22278C10D00BF200071B782 /* SVGParserUtilities.h */,
+				2D3A0E3513A7D76100E85AF0 /* SVGParsingError.h */,
 				84C6784A1214814700A92902 /* SVGPathBlender.cpp */,
 				84C6784B1214814700A92902 /* SVGPathBlender.h */,
 				8476C9E711DF6A2900555B02 /* SVGPathBuilder.cpp */,
@@ -22899,6 +22902,7 @@
 				B2227A510D00BF220071B782 /* SVGNumberList.h in Headers */,
 				B2227A540D00BF220071B782 /* SVGPaint.h in Headers */,
 				B2227A570D00BF220071B782 /* SVGParserUtilities.h in Headers */,
+				2D3A0E3613A7D76100E85AF0 /* SVGParsingError.h in Headers */,
 				84C6784D1214814700A92902 /* SVGPathBlender.h in Headers */,
 				8476C9EB11DF6A2900555B02 /* SVGPathBuilder.h in Headers */,
 				8419D2A7120D92D000141F8F /* SVGPathByteStream.h in Headers */,

Modified: trunk/Source/WebCore/svg/SVGElement.h (91436 => 91437)


--- trunk/Source/WebCore/svg/SVGElement.h	2011-07-21 01:42:51 UTC (rev 91436)
+++ trunk/Source/WebCore/svg/SVGElement.h	2011-07-21 02:05:10 UTC (rev 91437)
@@ -24,18 +24,13 @@
 
 #if ENABLE(SVG)
 #include "SVGLocatable.h"
+#include "SVGParsingError.h"
 #include "SVGPropertyInfo.h"
 #include "StyledElement.h"
 #include <wtf/HashMap.h>
 
 namespace WebCore {
 
-enum SVGParsingError {
-    NoError,
-    ParsingAttributeFailedError,
-    NegativeValueForbiddenError
-};
-
 class AffineTransform;
 class CSSCursorImageValue;
 class Document;

Modified: trunk/Source/WebCore/svg/SVGLength.cpp (91436 => 91437)


--- trunk/Source/WebCore/svg/SVGLength.cpp	2011-07-21 01:42:51 UTC (rev 91436)
+++ trunk/Source/WebCore/svg/SVGLength.cpp	2011-07-21 02:05:10 UTC (rev 91437)
@@ -31,6 +31,7 @@
 #include "RenderObject.h"
 #include "RenderPart.h"
 #include "RenderView.h"
+#include "SVGException.h"
 #include "SVGNames.h"
 #include "SVGParserUtilities.h"
 #include "SVGSVGElement.h"
@@ -165,6 +166,21 @@
     return !operator==(other);
 }
 
+SVGLength SVGLength::construct(SVGLengthMode mode, const String& valueAsString, SVGParsingError& parseError, SVGLengthNegativeValuesMode negativeValuesMode)
+{
+    ExceptionCode ec = 0;
+    SVGLength length(mode);
+
+    length.setValueAsString(valueAsString, ec);
+
+    if (ec)
+        parseError = ParsingAttributeFailedError;
+    else if (negativeValuesMode == ForbidNegativeLengths && length.valueInSpecifiedUnits() < 0)
+        parseError = NegativeValueForbiddenError;
+
+    return length;
+}
+
 SVGLengthType SVGLength::unitType() const
 {
     return extractType(m_unit);

Modified: trunk/Source/WebCore/svg/SVGLength.h (91436 => 91437)


--- trunk/Source/WebCore/svg/SVGLength.h	2011-07-21 01:42:51 UTC (rev 91436)
+++ trunk/Source/WebCore/svg/SVGLength.h	2011-07-21 02:05:10 UTC (rev 91437)
@@ -23,6 +23,7 @@
 
 #if ENABLE(SVG)
 #include "ExceptionCode.h"
+#include "SVGParsingError.h"
 #include "SVGPropertyTraits.h"
 
 namespace WebCore {
@@ -49,6 +50,11 @@
     LengthModeOther
 };
 
+enum SVGLengthNegativeValuesMode {
+    AllowNegativeLengths,
+    ForbidNegativeLengths
+};
+
 class QualifiedName;
 class SVGElement;
 
@@ -78,6 +84,8 @@
     bool operator==(const SVGLength&) const;
     bool operator!=(const SVGLength&) const;
 
+    static SVGLength construct(SVGLengthMode, const String&, SVGParsingError&, SVGLengthNegativeValuesMode = AllowNegativeLengths);
+
     float value(const SVGElement* context) const;
     float value(const SVGElement* context, ExceptionCode&) const;
     void setValue(float, const SVGElement* context, ExceptionCode&);

Added: trunk/Source/WebCore/svg/SVGParsingError.h (0 => 91437)


--- trunk/Source/WebCore/svg/SVGParsingError.h	                        (rev 0)
+++ trunk/Source/WebCore/svg/SVGParsingError.h	2011-07-21 02:05:10 UTC (rev 91437)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) Research In Motion Limited 2011. All rights reserved.
+ * Copyright (C) 2011 Apple, Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef SVGParsingError_h
+#define SVGParsingError_h
+
+#if ENABLE(SVG)
+
+namespace WebCore {
+
+enum SVGParsingError {
+    NoError,
+    ParsingAttributeFailedError,
+    NegativeValueForbiddenError
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SVG)
+#endif // SVGParsingError_h
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to