Changeset 18652 in webkit
- Timestamp:
- Jan 7, 2007 8:47:24 AM (17 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r18651 r18652 1 2007-01-07 Rob Buis <buis@kde.org> 2 3 Reviewed by weinig. 4 5 http://bugs.webkit.org/show_bug.cgi?id=10362 6 SVG needs to support SVGError events and some form of "error state" 7 8 Report SVG warnings and errors on (JS) console. 9 Expose line and column number getters in Tokenizer in 10 order to display them with the error message. 11 12 * dom/XMLTokenizer.cpp: 13 * dom/XMLTokenizer.h: 14 (WebCore::Tokenizer::lineNumber): 15 (WebCore::Tokenizer::columnNumber): 16 * html/HTMLTokenizer.h: 17 (WebCore::HTMLTokenizer::lineNumber): 18 (WebCore::HTMLTokenizer::columnNumber): 19 * ksvg2/misc/SVGDocumentExtensions.cpp: 20 (WebCore::SVGDocumentExtensions::reportWarning): 21 (WebCore::SVGDocumentExtensions::reportError): 22 * ksvg2/misc/SVGDocumentExtensions.h: 23 * ksvg2/svg/SVGCircleElement.cpp: 24 (WebCore::SVGCircleElement::parseMappedAttribute): 25 * ksvg2/svg/SVGElement.h: 26 * ksvg2/svg/SVGEllipseElement.cpp: 27 (WebCore::SVGEllipseElement::parseMappedAttribute): 28 * ksvg2/svg/SVGFitToViewBox.cpp: 29 (WebCore::SVGFitToViewBox::parseViewBox): 30 * ksvg2/svg/SVGFitToViewBox.h: 31 * ksvg2/svg/SVGImageElement.cpp: 32 (WebCore::SVGImageElement::parseMappedAttribute): 33 * ksvg2/svg/SVGParserUtilities.cpp: 34 (WebCore::SVGPolyParser::parsePoints): 35 * ksvg2/svg/SVGParserUtilities.h: 36 * ksvg2/svg/SVGPathElement.cpp: 37 (WebCore::SVGPathElement::parseMappedAttribute): 38 * ksvg2/svg/SVGPatternElement.cpp: 39 (WebCore::SVGPatternElement::parseMappedAttribute): 40 * ksvg2/svg/SVGPolyElement.cpp: 41 (WebCore::SVGPolyElement::parseMappedAttribute): 42 * ksvg2/svg/SVGRadialGradientElement.cpp: 43 (WebCore::SVGRadialGradientElement::parseMappedAttribute): 44 * ksvg2/svg/SVGRectElement.cpp: 45 (WebCore::SVGRectElement::parseMappedAttribute): 46 * ksvg2/svg/SVGSVGElement.cpp: 47 (WebCore::SVGSVGElement::parseMappedAttribute): 48 * ksvg2/svg/SVGTextContentElement.cpp: 49 (WebCore::SVGTextContentElement::parseMappedAttribute): 50 * ksvg2/svg/SVGUseElement.cpp: 51 (WebCore::SVGUseElement::parseMappedAttribute): 52 1 53 2007-01-07 Nikolas Zimmermann <zimmermann@kde.org> 2 54 -
trunk/WebCore/dom/XMLTokenizer.cpp
r18218 r18652 114 114 virtual bool wellFormed() const { return !m_sawError; } 115 115 116 int lineNumber() const; 117 int columnNumber() const; 118 116 119 private: 117 120 void initializeParserContext(); 118 121 void setCurrentNode(Node*); 119 120 int lineNumber() const;121 int columnNumber() const;122 122 123 123 void insertErrorMessageBlock(); -
trunk/WebCore/dom/XMLTokenizer.h
r17860 r18652 66 66 virtual bool wellFormed() const { return true; } 67 67 68 virtual int lineNumber() const { return -1; } 69 virtual int columnNumber() const { return -1; } 70 68 71 protected: 69 72 // The tokenizer has buffers, so parsing may continue even after -
trunk/WebCore/html/HTMLTokenizer.h
r16245 r18652 94 94 virtual bool processingData() const; 95 95 virtual int executingScript() const { return m_executingScript; } 96 97 virtual int lineNumber() const { return lineno; } 98 virtual int columnNumber() const { return 1; } 96 99 97 100 private: -
trunk/WebCore/ksvg2/misc/SVGDocumentExtensions.cpp
r18521 r18652 2 2 Copyright (C) 2006 Apple Computer, Inc. 3 3 2006 Nikolas Zimmermann <zimmermann@kde.org> 4 2007 Rob Buis <buis@kde.org> 4 5 5 6 This file is part of the WebKit project … … 26 27 #include "SVGDocumentExtensions.h" 27 28 29 #include "AtomicString.h" 30 #include "Chrome.h" 28 31 #include "Document.h" 29 32 #include "EventListener.h" 30 33 #include "Frame.h" 34 #include "FrameLoader.h" 35 #include "Page.h" 36 #include "SVGSVGElement.h" 31 37 #include "TimeScheduler.h" 32 #include " AtomicString.h"38 #include "XMLTokenizer.h" 33 39 #include "kjs_proxy.h" 34 #include "SVGSVGElement.h"35 40 36 41 namespace WebCore { … … 88 93 } 89 94 95 void SVGDocumentExtensions::reportWarning(const String& message) 96 { 97 if (Page* page = m_doc->frame()->page()) { 98 page->chrome()->addMessageToConsole("Warning: " + message, m_doc->tokenizer() ? m_doc->tokenizer()->lineNumber() : 1, String()); 99 } 100 } 101 102 void SVGDocumentExtensions::reportError(const String& message) 103 { 104 if (Page* page = m_doc->frame()->page()) { 105 page->chrome()->addMessageToConsole("Error: " + message, m_doc->tokenizer() ? m_doc->tokenizer()->lineNumber() : 1, String()); 106 } 107 } 108 90 109 void SVGDocumentExtensions::addPendingResource(const AtomicString& id, SVGStyledElement* obj) 91 110 { -
trunk/WebCore/ksvg2/misc/SVGDocumentExtensions.h
r18521 r18652 61 61 void unpauseAnimations(); 62 62 63 void reportWarning(const String&); 64 void reportError(const String&); 65 63 66 private: 64 67 Document* m_doc; // weak reference -
trunk/WebCore/ksvg2/svg/SVGCircleElement.cpp
r18268 r18652 57 57 else if (attr->name() == SVGNames::cyAttr) 58 58 setCyBaseValue(SVGLength(this, LengthModeHeight, value)); 59 else if (attr->name() == SVGNames::rAttr) 59 else if (attr->name() == SVGNames::rAttr) { 60 60 setRBaseValue(SVGLength(this, LengthModeOther, value)); 61 else { 61 if (r().value() < 0.0) 62 document()->accessSVGExtensions()->reportError("A negative value for circle <r> is not allowed"); 63 } else { 62 64 if (SVGTests::parseMappedAttribute(attr)) 63 65 return; -
trunk/WebCore/ksvg2/svg/SVGElement.h
r18217 r18652 174 174 175 175 namespace WebCore { 176 class DocumentPtr;177 176 class Ecma; 178 177 class SVGPreserveAspectRatio; -
trunk/WebCore/ksvg2/svg/SVGEllipseElement.cpp
r18268 r18652 60 60 else if (attr->name() == SVGNames::cyAttr) 61 61 setCyBaseValue(SVGLength(this, LengthModeHeight, value)); 62 else if (attr->name() == SVGNames::rxAttr) 62 else if (attr->name() == SVGNames::rxAttr) { 63 63 setRxBaseValue(SVGLength(this, LengthModeWidth, value)); 64 else if (attr->name() == SVGNames::ryAttr) 64 if (rx().value() < 0.0) 65 document()->accessSVGExtensions()->reportError("A negative value for ellipse <rx> is not allowed"); 66 } else if (attr->name() == SVGNames::ryAttr) { 65 67 setRyBaseValue(SVGLength(this, LengthModeHeight, value)); 66 else { 68 if (ry().value() < 0.0) 69 document()->accessSVGExtensions()->reportError("A negative value for ellipse <ry> is not allowed"); 70 } else { 67 71 if (SVGTests::parseMappedAttribute(attr)) 68 72 return; -
trunk/WebCore/ksvg2/svg/SVGFitToViewBox.cpp
r18478 r18652 1 1 /* 2 2 Copyright (C) 2004, 2005 Nikolas Zimmermann <wildfox@kde.org> 3 2004, 2005, 2006 Rob Buis <buis@kde.org>3 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> 4 4 5 5 This file is part of the KDE project … … 25 25 #include "SVGFitToViewBox.h" 26 26 27 #include "AffineTransform.h" 27 28 #include "FloatRect.h" 29 #include "SVGDocumentExtensions.h" 28 30 #include "SVGNames.h" 29 31 #include "SVGParserUtilities.h" 30 32 #include "SVGPreserveAspectRatio.h" 31 #include "SVGSVGElement.h"32 33 #include "StringImpl.h" 33 34 … … 52 53 const UChar* c = str.characters(); 53 54 const UChar* end = c + str.length(); 55 Document* doc = contextElement()->document(); 54 56 55 57 skipOptionalSpaces(c, end); 56 58 57 if (!parseNumber(c, end, x)) 58 goto bail_out; 59 if (!(parseNumber(c, end, x) && parseNumber(c, end, y) && 60 parseNumber(c, end, w) && parseNumber(c, end, h, false))) { 61 doc->accessSVGExtensions()->reportWarning("Problem parsing viewBox=\"" + str + "\""); 62 return; 63 } 59 64 60 if (!parseNumber(c, end, y)) 61 goto bail_out; 62 63 if (!parseNumber(c, end, w) || w < 0.0) // check that width is positive 64 goto bail_out; 65 66 if (!parseNumber(c, end, h, false) || h < 0.0) // check that height is positive 67 goto bail_out; 68 69 skipOptionalSpaces(c, end); 70 71 if (c < end) // nothing should come after the last, fourth number 72 goto bail_out; 73 74 setViewBoxBaseValue(FloatRect(x, y, w, h)); 75 return; 76 77 bail_out:; 78 // FIXME: Per the spec we are supposed to set the document into an "error state" here. 65 if (w < 0.0) // check that width is positive 66 doc->accessSVGExtensions()->reportError("A negative value for ViewBox width is not allowed"); 67 else if (h < 0.0) // check that height is positive 68 doc->accessSVGExtensions()->reportError("A negative value for ViewBox height is not allowed"); 69 else { 70 skipOptionalSpaces(c, end); 71 if (c < end) // nothing should come after the last, fourth number 72 doc->accessSVGExtensions()->reportWarning("Problem parsing viewBox=\"" + str + "\""); 73 else 74 setViewBoxBaseValue(FloatRect(x, y, w, h)); 75 } 79 76 } 80 77 -
trunk/WebCore/ksvg2/svg/SVGFitToViewBox.h
r18177 r18652 21 21 */ 22 22 23 #ifndef KSVG_SVGFitToViewBoxImpl_H24 #define KSVG_SVGFitToViewBoxImpl_H23 #ifndef SVGFitToViewBox_H 24 #define SVGFitToViewBox_H 25 25 #ifdef SVG_SUPPORT 26 26 … … 28 28 29 29 namespace WebCore { 30 class Attribute;31 30 class AffineTransform; 32 31 class SVGPreserveAspectRatio; 33 class StringImpl;34 32 35 33 class SVGFitToViewBox { … … 55 53 56 54 #endif // SVG_SUPPORT 57 #endif // KSVG_SVGFitToViewBoxImpl_H55 #endif // SVGFitToViewBox_H 58 56 59 57 // vim:ts=4:noet -
trunk/WebCore/ksvg2/svg/SVGImageElement.cpp
r18428 r18652 76 76 setWidthBaseValue(SVGLength(this, LengthModeWidth, value)); 77 77 addCSSProperty(attr, CSS_PROP_WIDTH, value); 78 if (width().value() < 0.0) 79 document()->accessSVGExtensions()->reportError("A negative value for image attribute <width> is not allowed"); 78 80 } else if (attr->name() == SVGNames::heightAttr) { 79 81 setHeightBaseValue(SVGLength(this, LengthModeHeight, value)); 80 82 addCSSProperty(attr, CSS_PROP_HEIGHT, value); 83 if (height().value() < 0.0) 84 document()->accessSVGExtensions()->reportError("A negative value for image attribute <height> is not allowed"); 81 85 } else { 82 86 if (SVGTests::parseMappedAttribute(attr)) -
trunk/WebCore/ksvg2/svg/SVGParserUtilities.cpp
r18489 r18652 110 110 } 111 111 112 voidSVGPolyParser::parsePoints(const String& s) const112 bool SVGPolyParser::parsePoints(const String& s) const 113 113 { 114 114 if (s.isEmpty()) 115 return ;115 return true; 116 116 const UChar* cur = s.characters(); 117 117 const UChar* end = cur + s.length(); … … 123 123 double xPos = 0; 124 124 if (!parseNumber(cur, end, xPos)) 125 break;125 return false; 126 126 127 127 double yPos = 0; 128 128 if (!parseNumber(cur, end, yPos)) 129 break;129 return false; 130 130 131 131 svgPolyTo(xPos, yPos, segmentNum++); -
trunk/WebCore/ksvg2/svg/SVGParserUtilities.h
r18489 r18652 70 70 public: 71 71 virtual ~SVGPolyParser() { } 72 void parsePoints(const String &points) const;72 bool parsePoints(const String& points) const; 73 73 74 74 protected: … … 91 91 public: 92 92 virtual ~SVGPathParser() { } 93 bool parseSVG(const String &d, bool process = false);93 bool parseSVG(const String& d, bool process = false); 94 94 95 95 protected: … … 105 105 virtual void svgClosePath() = 0; 106 106 private: 107 void calculateArc(bool relative, double &curx, double &cury, double angle, double x, double y, double r1, double r2, bool largeArcFlag, bool sweepFlag);107 void calculateArc(bool relative, double& curx, double& cury, double angle, double x, double y, double r1, double r2, bool largeArcFlag, bool sweepFlag); 108 108 }; 109 109 -
trunk/WebCore/ksvg2/svg/SVGPathElement.cpp
r18518 r18652 269 269 void SVGPathElement::parseMappedAttribute(MappedAttribute* attr) 270 270 { 271 const AtomicString& value = attr->value(); 271 272 if (attr->name() == SVGNames::dAttr) { 272 273 ExceptionCode ec; 273 274 pathSegList()->clear(ec); 274 if (!parseSVG(attr->value(), true)) 275 pathSegList()->clear(ec); 275 if (!parseSVG(value, true)) 276 document()->accessSVGExtensions()->reportError("Problem parsing d=\"" + value + "\""); 277 } else if (attr->name() == SVGNames::pathLengthAttr) { 278 m_pathLength = value.toDouble(); 279 if (m_pathLength < 0.0) 280 document()->accessSVGExtensions()->reportError("A negative value for path attribute <pathLength> is not allowed"); 276 281 } else { 277 282 if (SVGTests::parseMappedAttribute(attr)) -
trunk/WebCore/ksvg2/svg/SVGPatternElement.cpp
r18641 r18652 100 100 else if (attr->name() == SVGNames::yAttr) 101 101 setYBaseValue(SVGLength(this, LengthModeHeight, value)); 102 else if (attr->name() == SVGNames::widthAttr) 102 else if (attr->name() == SVGNames::widthAttr) { 103 103 setWidthBaseValue(SVGLength(this, LengthModeWidth, value)); 104 else if (attr->name() == SVGNames::heightAttr) 104 if (width().value() < 0.0) 105 document()->accessSVGExtensions()->reportError("A negative value for pattern attribute <width> is not allowed"); 106 } else if (attr->name() == SVGNames::heightAttr) { 105 107 setHeightBaseValue(SVGLength(this, LengthModeHeight, value)); 106 else { 108 if (width().value() < 0.0) 109 document()->accessSVGExtensions()->reportError("A negative value for pattern attribute <height> is not allowed"); 110 } else { 107 111 if (SVGURIReference::parseMappedAttribute(attr)) 108 112 return; -
trunk/WebCore/ksvg2/svg/SVGPolyElement.cpp
r18489 r18652 1 1 /* 2 2 Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 3 2004, 2005, 2006 Rob Buis <buis@kde.org>3 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> 4 4 5 5 This file is part of the KDE project … … 63 63 void SVGPolyElement::parseMappedAttribute(MappedAttribute* attr) 64 64 { 65 const AtomicString& value = attr->value(); 65 66 if (attr->name() == SVGNames::pointsAttr) { 66 67 ExceptionCode ec = 0; 67 68 points()->clear(ec); 68 parsePoints(attr->value()); 69 if (!parsePoints(value) && !m_ignoreAttributeChanges) 70 document()->accessSVGExtensions()->reportError("Problem parsing points=\"" + value + "\""); 69 71 } else { 70 72 if (SVGTests::parseMappedAttribute(attr)) -
trunk/WebCore/ksvg2/svg/SVGRadialGradientElement.cpp
r18521 r18652 68 68 else if (attr->name() == SVGNames::cyAttr) 69 69 setCyBaseValue(SVGLength(this, LengthModeHeight, value)); 70 else if (attr->name() == SVGNames::rAttr) 70 else if (attr->name() == SVGNames::rAttr) { 71 71 setRBaseValue(SVGLength(this, LengthModeOther, value)); 72 else if (attr->name() == SVGNames::fxAttr) 72 if (r().value() < 0.0) 73 document()->accessSVGExtensions()->reportError("A negative value for radial gradient radius <r> is not allowed"); 74 } else if (attr->name() == SVGNames::fxAttr) 73 75 setFxBaseValue(SVGLength(this, LengthModeWidth, value)); 74 76 else if (attr->name() == SVGNames::fyAttr) -
trunk/WebCore/ksvg2/svg/SVGRectElement.cpp
r18268 r18652 62 62 else if (attr->name() == SVGNames::yAttr) 63 63 setYBaseValue(SVGLength(this, LengthModeHeight, value)); 64 else if (attr->name() == SVGNames::rxAttr) 65 setRxBaseValue(SVGLength(this, LengthModeWidth, value)); 66 else if (attr->name() == SVGNames::ryAttr) 67 setRyBaseValue(SVGLength(this, LengthModeHeight, value)); 68 else if (attr->name() == SVGNames::widthAttr) 64 else if (attr->name() == SVGNames::rxAttr) { 65 setRxBaseValue(SVGLength(this, LengthModeWidth, value)); 66 document()->accessSVGExtensions()->reportError("A negative value for rect <rx> is not allowed"); 67 } else if (attr->name() == SVGNames::ryAttr) { 68 setRyBaseValue(SVGLength(this, LengthModeHeight, value)); 69 if (ry().value() < 0.0) 70 document()->accessSVGExtensions()->reportError("A negative value for rect <ry> is not allowed"); 71 } else if (attr->name() == SVGNames::widthAttr) { 69 72 setWidthBaseValue(SVGLength(this, LengthModeWidth, value)); 70 else if (attr->name() == SVGNames::heightAttr) 73 if (width().value() < 0.0) 74 document()->accessSVGExtensions()->reportError("A negative value for rect <width> is not allowed"); 75 } else if (attr->name() == SVGNames::heightAttr) { 71 76 setHeightBaseValue(SVGLength(this, LengthModeHeight, value)); 72 else { 77 if (height().value() < 0.0) 78 document()->accessSVGExtensions()->reportError("A negative value for rect <height> is not allowed"); 79 } else { 73 80 if (SVGTests::parseMappedAttribute(attr)) 74 81 return; -
trunk/WebCore/ksvg2/svg/SVGSVGElement.cpp
r18524 r18652 197 197 setWidthBaseValue(SVGLength(this, LengthModeWidth, value)); 198 198 addCSSProperty(attr, CSS_PROP_WIDTH, value); 199 if (width().value() < 0.0) 200 document()->accessSVGExtensions()->reportError("A negative value for svg attribute <width> is not allowed"); 199 201 } else if (attr->name() == SVGNames::heightAttr) { 200 202 setHeightBaseValue(SVGLength(this, LengthModeHeight, value)); 201 203 addCSSProperty(attr, CSS_PROP_HEIGHT, value); 204 if (height().value() < 0.0) 205 document()->accessSVGExtensions()->reportError("A negative value for svg attribute <height> is not allowed"); 202 206 } else { 203 207 if (SVGTests::parseMappedAttribute(attr)) -
trunk/WebCore/ksvg2/svg/SVGTextContentElement.cpp
r18268 r18652 95 95 void SVGTextContentElement::parseMappedAttribute(MappedAttribute* attr) 96 96 { 97 const AtomicString& value = attr->value(); 97 98 //if (attr->name() == SVGNames::lengthAdjustAttr) 98 99 // setXBaseValue(SVGLength(this, LengthModeWidth, value)); 99 100 //else 100 { 101 if (attr->name() == SVGNames::textLengthAttr) { 102 setTextLengthBaseValue(SVGLength(this, LengthModeOther, value)); 103 if (textLength().value() < 0.0) 104 document()->accessSVGExtensions()->reportError("A negative value for text attribute <textLength> is not allowed"); 105 } else { 101 106 if (SVGTests::parseMappedAttribute(attr)) 102 107 return; -
trunk/WebCore/ksvg2/svg/SVGUseElement.cpp
r18643 r18652 67 67 else if (attr->name() == SVGNames::yAttr) 68 68 setYBaseValue(SVGLength(this, LengthModeHeight, value)); 69 else if (attr->name() == SVGNames::widthAttr) 69 else if (attr->name() == SVGNames::widthAttr) { 70 70 setWidthBaseValue(SVGLength(this, LengthModeWidth, value)); 71 else if (attr->name() == SVGNames::heightAttr) 71 if (width().value() < 0.0) 72 document()->accessSVGExtensions()->reportError("A negative value for use attribute <width> is not allowed"); 73 } else if (attr->name() == SVGNames::heightAttr) { 72 74 setHeightBaseValue(SVGLength(this, LengthModeHeight, value)); 73 else { 75 if (height().value() < 0.0) 76 document()->accessSVGExtensions()->reportError("A negative value for use attribute <height> is not allowed"); 77 } else { 74 78 if (SVGTests::parseMappedAttribute(attr)) 75 79 return;
Note: See TracChangeset
for help on using the changeset viewer.