WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
First attempt
10362.diff (text/plain), 13.86 KB, created by
Rob Buis
on 2007-01-01 11:59:09 PST
(
hide
)
Description:
First attempt
Filename:
MIME Type:
Creator:
Rob Buis
Created:
2007-01-01 11:59:09 PST
Size:
13.86 KB
patch
obsolete
>Index: WebCore/ChangeLog >=================================================================== >--- WebCore/ChangeLog (revision 18507) >+++ WebCore/ChangeLog (working copy) >@@ -1,3 +1,37 @@ >+2007-01-01 Rob Buis <buis@kde.org> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ http://bugs.webkit.org/show_bug.cgi?id=10362 >+ SVG needs to support SVGError events and some form of "error state" >+ >+ Report SVG warnings on console and CLI. Halt parsing/rendering >+ when encountering a (fatal) SVG error. >+ >+ * ksvg2/misc/SVGDocumentExtensions.cpp: >+ (WebCore::SVGDocumentExtensions::reportWarning): >+ (WebCore::SVGDocumentExtensions::reportError): >+ * ksvg2/misc/SVGDocumentExtensions.h: >+ * ksvg2/svg/SVGCircleElement.cpp: >+ (WebCore::SVGCircleElement::parseMappedAttribute): >+ * ksvg2/svg/SVGElement.h: >+ * ksvg2/svg/SVGEllipseElement.cpp: >+ (WebCore::SVGEllipseElement::parseMappedAttribute): >+ * ksvg2/svg/SVGFitToViewBox.cpp: >+ (WebCore::SVGFitToViewBox::parseViewBox): >+ (WebCore::SVGFitToViewBox::parseMappedAttribute): >+ * ksvg2/svg/SVGFitToViewBox.h: >+ * ksvg2/svg/SVGMarkerElement.cpp: >+ (WebCore::SVGMarkerElement::parseMappedAttribute): >+ * ksvg2/svg/SVGPatternElement.cpp: >+ (WebCore::SVGPatternElement::parseMappedAttribute): >+ * ksvg2/svg/SVGSVGElement.cpp: >+ (WebCore::SVGSVGElement::parseMappedAttribute): >+ * ksvg2/svg/SVGSymbolElement.cpp: >+ (WebCore::SVGSymbolElement::parseMappedAttribute): >+ * ksvg2/svg/SVGViewElement.cpp: >+ (WebCore::SVGViewElement::parseMappedAttribute): >+ > 2007-01-01 Eric Seidel <eric@webkit.org> > > Reviewed by andersca. >Index: WebCore/ksvg2/misc/SVGDocumentExtensions.cpp >=================================================================== >--- WebCore/ksvg2/misc/SVGDocumentExtensions.cpp (revision 18507) >+++ WebCore/ksvg2/misc/SVGDocumentExtensions.cpp (working copy) >@@ -23,13 +23,17 @@ > #ifdef SVG_SUPPORT > #include "SVGDocumentExtensions.h" > >+#include "AtomicString.h" >+#include "Chrome.h" > #include "Document.h" > #include "EventListener.h" > #include "Frame.h" >+#include "FrameLoader.h" >+#include "Page.h" >+#include "SVGSVGElement.h" > #include "TimeScheduler.h" >-#include "AtomicString.h" >+#include "XMLTokenizer.h" > #include "kjs_proxy.h" >-#include "SVGSVGElement.h" > > namespace WebCore { > >@@ -85,6 +89,19 @@ void SVGDocumentExtensions::unpauseAnima > (*itr)->unpauseAnimations(); > } > >+void SVGDocumentExtensions::reportWarning(const String& message) >+{ >+ fprintf(stderr, "SVG Warning: %s\n", message.deprecatedString().ascii()); >+ if (Page* page = m_doc->frame()->page()) >+ page->chrome()->addMessageToConsole(message, 1, String()); //fixme: provide a real line number and sourceurl >+} >+ >+void SVGDocumentExtensions::reportError(const String& message) >+{ >+ fprintf(stderr, "SVG Error: %s\n", message.deprecatedString().ascii()); >+ m_doc->tokenizer()->stopParsing(); >+} >+ > } > > #endif >Index: WebCore/ksvg2/misc/SVGDocumentExtensions.h >=================================================================== >--- WebCore/ksvg2/misc/SVGDocumentExtensions.h (revision 18507) >+++ WebCore/ksvg2/misc/SVGDocumentExtensions.h (working copy) >@@ -59,6 +59,9 @@ public: > void pauseAnimations(); > void unpauseAnimations(); > >+ void reportWarning(const String&); >+ void reportError(const String&); >+ > private: > Document* m_doc; // weak reference > HashSet<SVGSVGElement*> m_timeContainers; // For SVG 1.2 support this will need to be made more general. >Index: WebCore/ksvg2/svg/SVGCircleElement.cpp >=================================================================== >--- WebCore/ksvg2/svg/SVGCircleElement.cpp (revision 18507) >+++ WebCore/ksvg2/svg/SVGCircleElement.cpp (working copy) >@@ -56,9 +56,11 @@ void SVGCircleElement::parseMappedAttrib > setCxBaseValue(SVGLength(this, LengthModeWidth, value)); > else if (attr->name() == SVGNames::cyAttr) > setCyBaseValue(SVGLength(this, LengthModeHeight, value)); >- else if (attr->name() == SVGNames::rAttr) >+ else if (attr->name() == SVGNames::rAttr) { > setRBaseValue(SVGLength(this, LengthModeOther, value)); >- else { >+ if (r().value() < 0.0) >+ document()->accessSVGExtensions()->reportError("A negative value for circle <r> is an error"); >+ } else { > if (SVGTests::parseMappedAttribute(attr)) > return; > if (SVGLangSpace::parseMappedAttribute(attr)) >Index: WebCore/ksvg2/svg/SVGElement.h >=================================================================== >--- WebCore/ksvg2/svg/SVGElement.h (revision 18507) >+++ WebCore/ksvg2/svg/SVGElement.h (working copy) >@@ -173,7 +173,6 @@ PassRefPtr<ClassName::SVGAnimatedTemplat > } > > namespace WebCore { >- class DocumentPtr; > class Ecma; > class SVGPreserveAspectRatio; > class SVGMatrix; >Index: WebCore/ksvg2/svg/SVGEllipseElement.cpp >=================================================================== >--- WebCore/ksvg2/svg/SVGEllipseElement.cpp (revision 18507) >+++ WebCore/ksvg2/svg/SVGEllipseElement.cpp (working copy) >@@ -59,11 +59,15 @@ void SVGEllipseElement::parseMappedAttri > setCxBaseValue(SVGLength(this, LengthModeWidth, value)); > else if (attr->name() == SVGNames::cyAttr) > setCyBaseValue(SVGLength(this, LengthModeHeight, value)); >- else if (attr->name() == SVGNames::rxAttr) >+ else if (attr->name() == SVGNames::rxAttr) { > setRxBaseValue(SVGLength(this, LengthModeWidth, value)); >- else if (attr->name() == SVGNames::ryAttr) >+ if (rx().value() < 0.0) >+ document()->accessSVGExtensions()->reportError("A negative value for ellipse <rx> is an error"); >+ } else if (attr->name() == SVGNames::ryAttr) { > setRyBaseValue(SVGLength(this, LengthModeHeight, value)); >- else { >+ if (ry().value() < 0.0) >+ document()->accessSVGExtensions()->reportError("A negative value for ellipse <ry> is an error"); >+ } else { > if (SVGTests::parseMappedAttribute(attr)) > return; > if (SVGLangSpace::parseMappedAttribute(attr)) >Index: WebCore/ksvg2/svg/SVGFitToViewBox.cpp >=================================================================== >--- WebCore/ksvg2/svg/SVGFitToViewBox.cpp (revision 18507) >+++ WebCore/ksvg2/svg/SVGFitToViewBox.cpp (working copy) >@@ -24,11 +24,12 @@ > #ifdef SVG_SUPPORT > #include "SVGFitToViewBox.h" > >+#include "AffineTransform.h" > #include "FloatRect.h" >+#include "SVGDocumentExtensions.h" > #include "SVGNames.h" > #include "SVGParserUtilities.h" > #include "SVGPreserveAspectRatio.h" >-#include "SVGSVGElement.h" > #include "StringImpl.h" > > namespace WebCore { >@@ -46,7 +47,7 @@ SVGFitToViewBox::~SVGFitToViewBox() > ANIMATED_PROPERTY_DEFINITIONS_WITH_CONTEXT(SVGFitToViewBox, FloatRect, Rect, rect, ViewBox, viewBox, SVGNames::viewBoxAttr.localName(), m_viewBox) > ANIMATED_PROPERTY_DEFINITIONS_WITH_CONTEXT(SVGFitToViewBox, SVGPreserveAspectRatio*, PreserveAspectRatio, preserveAspectRatio, PreserveAspectRatio, preserveAspectRatio, SVGNames::preserveAspectRatioAttr.localName(), m_preserveAspectRatio.get()) > >-void SVGFitToViewBox::parseViewBox(const String& str) >+void SVGFitToViewBox::parseViewBox(const String& str, Document* doc) > { > double x = 0, y = 0, w = 0, h = 0; > const UChar* c = str.characters(); >@@ -55,27 +56,24 @@ void SVGFitToViewBox::parseViewBox(const > skipOptionalSpaces(c, end); > > if (!parseNumber(c, end, x)) >- goto bail_out; >- >- if (!parseNumber(c, end, y)) >- goto bail_out; >- >- if (!parseNumber(c, end, w) || w < 0.0) // check that width is positive >- goto bail_out; >- >- if (!parseNumber(c, end, h, false) || h < 0.0) // check that height is positive >- goto bail_out; >- >- skipOptionalSpaces(c, end); >- >- if (c < end) // nothing should come after the last, fourth number >- goto bail_out; >- >- setViewBoxBaseValue(FloatRect(x, y, w, h)); >- return; >- >-bail_out:; >- // FIXME: Per the spec we are supposed to set the document into an "error state" here. >+ doc->accessSVGExtensions()->reportWarning("Problem parsing viewBox=\"" + str + "\""); >+ else if (!parseNumber(c, end, y)) >+ doc->accessSVGExtensions()->reportWarning("Problem parsing viewBox=\"" + str + "\""); >+ else if (!parseNumber(c, end, w)) >+ doc->accessSVGExtensions()->reportWarning("Problem parsing viewBox=\"" + str + "\""); >+ else if (w < 0.0) // check that width is positive >+ doc->accessSVGExtensions()->reportError("A negative value for ViewBox width is an error"); >+ else if (!parseNumber(c, end, h, false)) >+ doc->accessSVGExtensions()->reportWarning("Problem parsing viewBox=\"" + str + "\""); >+ else if (h < 0.0) // check that height is positive >+ doc->accessSVGExtensions()->reportError("A negative value for ViewBox height is an error"); >+ else { >+ skipOptionalSpaces(c, end); >+ if (c < end) // nothing should come after the last, fourth number >+ doc->accessSVGExtensions()->reportWarning("Problem parsing viewBox=\"" + str + "\""); >+ else >+ setViewBoxBaseValue(FloatRect(x, y, w, h)); >+ } > } > > AffineTransform SVGFitToViewBox::viewBoxToViewTransform(float viewWidth, float viewHeight) const >@@ -89,10 +87,10 @@ AffineTransform SVGFitToViewBox::viewBox > 0, 0, viewWidth, viewHeight); > } > >-bool SVGFitToViewBox::parseMappedAttribute(MappedAttribute* attr) >+bool SVGFitToViewBox::parseMappedAttribute(MappedAttribute* attr, Document* doc) > { > if (attr->name() == SVGNames::viewBoxAttr) { >- parseViewBox(attr->value()); >+ parseViewBox(attr->value(), doc); > return true; > } else if (attr->name() == SVGNames::preserveAspectRatioAttr) { > preserveAspectRatioBaseValue()->parsePreserveAspectRatio(attr->value()); >Index: WebCore/ksvg2/svg/SVGFitToViewBox.h >=================================================================== >--- WebCore/ksvg2/svg/SVGFitToViewBox.h (revision 18507) >+++ WebCore/ksvg2/svg/SVGFitToViewBox.h (working copy) >@@ -20,8 +20,8 @@ > Boston, MA 02111-1307, USA. > */ > >-#ifndef KSVG_SVGFitToViewBoxImpl_H >-#define KSVG_SVGFitToViewBoxImpl_H >+#ifndef SVGFitToViewBox_H >+#define SVGFitToViewBox_H > #ifdef SVG_SUPPORT > > #include "SVGElement.h" >@@ -29,6 +29,7 @@ > namespace WebCore { > class Attribute; > class AffineTransform; >+ class Document; > class SVGPreserveAspectRatio; > class StringImpl; > >@@ -38,10 +39,10 @@ namespace WebCore { > virtual ~SVGFitToViewBox(); > > // 'SVGFitToViewBox' functions >- void parseViewBox(const String&); >+ void parseViewBox(const String&, Document*); > AffineTransform viewBoxToViewTransform(float viewWidth, float viewHeight) const; > >- bool parseMappedAttribute(MappedAttribute*); >+ bool parseMappedAttribute(MappedAttribute*, Document*); > > protected: > virtual const SVGElement* contextElement() const = 0; >Index: WebCore/ksvg2/svg/SVGMarkerElement.cpp >=================================================================== >--- WebCore/ksvg2/svg/SVGMarkerElement.cpp (revision 18507) >+++ WebCore/ksvg2/svg/SVGMarkerElement.cpp (working copy) >@@ -90,7 +90,7 @@ void SVGMarkerElement::parseMappedAttrib > return; > if (SVGExternalResourcesRequired::parseMappedAttribute(attr)) > return; >- if (SVGFitToViewBox::parseMappedAttribute(attr)) >+ if (SVGFitToViewBox::parseMappedAttribute(attr, document())) > return; > > SVGStyledElement::parseMappedAttribute(attr); >Index: WebCore/ksvg2/svg/SVGPatternElement.cpp >=================================================================== >--- WebCore/ksvg2/svg/SVGPatternElement.cpp (revision 18507) >+++ WebCore/ksvg2/svg/SVGPatternElement.cpp (working copy) >@@ -109,7 +109,7 @@ void SVGPatternElement::parseMappedAttri > return; > if (SVGExternalResourcesRequired::parseMappedAttribute(attr)) > return; >- if (SVGFitToViewBox::parseMappedAttribute(attr)) >+ if (SVGFitToViewBox::parseMappedAttribute(attr, document())) > return; > > SVGStyledElement::parseMappedAttribute(attr); >Index: WebCore/ksvg2/svg/SVGSVGElement.cpp >=================================================================== >--- WebCore/ksvg2/svg/SVGSVGElement.cpp (revision 18507) >+++ WebCore/ksvg2/svg/SVGSVGElement.cpp (working copy) >@@ -204,7 +204,7 @@ void SVGSVGElement::parseMappedAttribute > return; > if (SVGExternalResourcesRequired::parseMappedAttribute(attr)) > return; >- if (SVGFitToViewBox::parseMappedAttribute(attr) && renderer()) >+ if (SVGFitToViewBox::parseMappedAttribute(attr, document()) && renderer()) > static_cast<RenderSVGContainer*>(renderer())->setViewBox(viewBox()); > if (SVGZoomAndPan::parseMappedAttribute(attr)) > return; >Index: WebCore/ksvg2/svg/SVGSymbolElement.cpp >=================================================================== >--- WebCore/ksvg2/svg/SVGSymbolElement.cpp (revision 18507) >+++ WebCore/ksvg2/svg/SVGSymbolElement.cpp (working copy) >@@ -47,7 +47,7 @@ void SVGSymbolElement::parseMappedAttrib > return; > if (SVGExternalResourcesRequired::parseMappedAttribute(attr)) > return; >- if (SVGFitToViewBox::parseMappedAttribute(attr)) >+ if (SVGFitToViewBox::parseMappedAttribute(attr, document())) > return; > > SVGStyledElement::parseMappedAttribute(attr); >Index: WebCore/ksvg2/svg/SVGViewElement.cpp >=================================================================== >--- WebCore/ksvg2/svg/SVGViewElement.cpp (revision 18507) >+++ WebCore/ksvg2/svg/SVGViewElement.cpp (working copy) >@@ -60,7 +60,7 @@ void SVGViewElement::parseMappedAttribut > viewTarget()->reset(value); > else { > if(SVGExternalResourcesRequired::parseMappedAttribute(attr) >- || SVGFitToViewBox::parseMappedAttribute(attr) >+ || SVGFitToViewBox::parseMappedAttribute(attr, document()) > || SVGZoomAndPan::parseMappedAttribute(attr)) > return; >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
eric
:
review-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 10362
:
12145
|
12193
|
12244
|
12278