Bug 10362 - SVG needs to support SVGError events and some form of "error state"
Summary: SVG needs to support SVGError events and some form of "error state"
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P4 Normal
Assignee: Nobody
URL:
Keywords:
Depends on: 10361
Blocks:
  Show dependency treegraph
 
Reported: 2006-08-12 01:32 PDT by Eric Seidel (no email)
Modified: 2007-01-07 09:24 PST (History)
0 users

See Also:


Attachments
First attempt (13.86 KB, patch)
2007-01-01 11:59 PST, Rob Buis
eric: review-
Details | Formatted Diff | Diff
Improved patch (26.85 KB, patch)
2007-01-03 11:15 PST, Rob Buis
eric: review-
Details | Formatted Diff | Diff
Improved patch (28.87 KB, patch)
2007-01-05 12:45 PST, Rob Buis
sam: review-
Details | Formatted Diff | Diff
Improved patch (25.26 KB, patch)
2007-01-07 08:32 PST, Rob Buis
sam: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Seidel (no email) 2006-08-12 01:32:34 PDT
SVG needs to support SVGError events and some form of "error state"

The spec calls for implementing an "error state":
http://www.w3.org/TR/SVG11/implnote.html#ErrorProcessing

"A highly perceivable indication of error shall occur. For visual rendering situations, an example of an indication of error would be to render a translucent colored pattern such as a checkerboard on top of the area where the SVG content is rendered."

Most desktop browser authors would consider such error behavior complete lunacy, given the current expectation of web content authors for browsers to silently render any erroneous HTML page.

Regardless, we should have some way to display errors to the content author, even if we silently render erroneous content nicely for the end user.  One possible solution would be to leverage an error console, such as is described by bug 10361.
Comment 1 Rob Buis 2007-01-01 11:59:09 PST
Created attachment 12145 [details]
First attempt

Note that this is just a start. I am not adding svg error reporting everywhere yet (so nothing is in place for reporting path syntax errors) since I'd like to know whether this is the right approach :)
Cheers,

Rob.
Comment 2 Eric Seidel (no email) 2007-01-01 13:38:31 PST
Comment on attachment 12145 [details]
First attempt

I don't like the idea of stopping parsing.  Also fprintfs are a bad idea for the layout tests, we should just remove those.

I think reporting errors is great.  I don't think we should stop parsing however.  Long term we could consider offering some sort of "debug mode" in Safari which would stop parsing, etc.  But I still think that's probably a bad idea.
Comment 3 Rob Buis 2007-01-03 11:15:49 PST
Created attachment 12193 [details]
Improved patch

This patch should be much better. It reports a lot of errors that occur during parsing and DOM changes.
Cheers,

Rob.
Comment 4 Eric Seidel (no email) 2007-01-05 00:56:11 PST
Comment on attachment 12193 [details]
Improved patch

we discussed a bunch of improvements over irc, including making lineNumber(), etc pure virtual, using contextElement() instead of passing document() and cleaning up the long ifs which repeatedly called the same error message.
Comment 5 Rob Buis 2007-01-05 12:45:54 PST
Created attachment 12244 [details]
Improved patch

This should fix most of MacDome's issues. It doesnt seem worth it to make lineNumber() pure virtual, since three Tokenizer-derived classes in loader/ would need the same base implementation.
It is hard to get the js line numbers. Maybe that needs to be done later.
I also split out Tokenizer itself. That is not really required for this patch to work, but I thought it may make sense.
Cheers,

Rob.
Comment 6 Sam Weinig 2007-01-05 15:11:54 PST
Comment on attachment 12244 [details]
Improved patch

r- for a couple style issues

In Tokenizer.h (I do realize that this is just a copy and paste but we might as well get it right):

There should not be a trailing underscore.

+#ifndef Tokenizer_h_
+#define Tokenizer_h_

Put the brace on the same line as the class name.

+class Tokenizer
+{

Indent the initialization list and put the braces on two lines.

+    Tokenizer(bool viewSourceMode = false) 
+    : m_parserStopped(false)
+    , m_inViewSourceMode(viewSourceMode)
+    {}

You should also indent the whole class declaration.

Add comments to closing brace and #endif.

+}
+
+#endif


In SVGDocumentExtensions.cpp:

The lines (seen in both reportWarning() and reportError())

+        int lineNumber = 1;
+        if (m_doc->tokenizer())
+            lineNumber =  m_doc->tokenizer()->lineNumber();

could be clearer if written in one line, like:

    int lineNumber = m_doc->tokenizer() ? m_doc->tokenizer()->lineNumber() : 1;

(note that I got rid of the double space :) )


The changes in SVGFitToViewBox.h don't seem to have anything todo with the patch.


In SVGParserUtilities.h:

As long as you are changing the return value, please fix the &.

+        bool parsePoints(const String &points) const;
Comment 7 Rob Buis 2007-01-07 08:32:33 PST
Created attachment 12278 [details]
Improved patch

Deciding to not touch Tokenizer too much since it is unrelated to the patch. This patch should address
Sam's issues.
Cheers,

Rob.
Comment 8 Rob Buis 2007-01-07 09:24:51 PST
Landed in r18652.