[Webkit-unassigned] [Bug 12609] Any SVG element will create renderers even when children of HTML elements

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Feb 22 13:34:01 PST 2007


------- Comment #7 from macdome at opendarwin.org  2007-02-22 13:34 PDT -------
I'm not sure what you mean "by design". :)  But yes, SVG renderers (and
elements) generally assume that their parents are also SVG renderers (or
elements).  This is part of the SVG spec, as SVG renderers require a "viewport"
in order to measure distances from, etc.  (The concept of "containing block" in
CSS is similar but not identical.)

WebKit currently would probably try to render something like this:

<html xmlns='http://www.w3.org/1999/xhtml'>
         <circle xmlns='http://www.w3.org/2000/svg' />

Even though it shouldn't, and it's likely that certain combinations of
javascript calls (or other things which cause the renderer to reach for its
containing viewport) could crash.

There are several ways to fix this:
1.  Make it disallowed for svg elements to be inserted under a parent other
than an SVG element (mjs previously expressed over IRC that this would be "bad"
since we currently only throw exceptions based on trying to insert bad node
types, not bad node names).
2.  Change Element:: childShouldCreateRenderer() to disallow creation of SVG
element renderers unless it's an SVGSVGElement, this would be overridden by
SVGElement:: childShouldCreateRenderer() of course.  This is the easiest fix,
but is perhaps a little hackish.
3.  Add some sort of "Element::shouldCreateRendererWithParent(Element*)" call
and override it for SVGElement to produce this behavior.  (also clean, possibly
hot code we're talking about here though.)
4.  Change every since SVGElement subclass createRenderer() to not create a
renderer if the parent is not an SVGElement subclass.  (This is decent wrt OO
design, but sucks in terms of the amount of duplicate code, and is prone to

I recommend either 2. or 3.

Configure bugmail: http://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

More information about the webkit-unassigned mailing list