Bug 9752 - %-sizing of elements with a html parent is broken
Summary: %-sizing of elements with a html parent is broken
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P2 Normal
Assignee: Nobody
Keywords: HasReduction
Depends on: 12207
  Show dependency treegraph
Reported: 2006-07-06 04:49 PDT by Joost de Valk (AlthA)
Modified: 2007-06-16 23:31 PDT (History)
0 users

See Also:

testcase (268 bytes, application/xml)
2006-07-06 04:49 PDT, Joost de Valk (AlthA)
no flags Details
First attempt (23.50 KB, patch)
2007-06-14 10:35 PDT, Rob Buis
eric: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joost de Valk (AlthA) 2006-07-06 04:49:09 PDT
Following bug 9555, i encountered another bug: when an svg element has a size in percentages, and the parent is a html element, it doesn't draw at all. Adding simple testcase in a sec.
Comment 1 Joost de Valk (AlthA) 2006-07-06 04:49:37 PDT
Created attachment 9224 [details]
Comment 2 Eric Seidel (no email) 2006-09-12 23:19:55 PDT
Hum... shouldn't be hard to fix.

Looking at the RenderTree debug window, it seems the <svg> is correctly sized to 200x200, but the item inside it is not.  I expect this has to do with SVG doing all of its layout in the DOM tree instead of the render tree.
Comment 3 Eric Seidel (no email) 2007-01-31 05:03:57 PST
The function which would need to change is:
float SVGLength::PercentageOfViewport(float value, const SVGStyledElement* context, SVGLengthMode mode)

    } else if (viewportElement && viewportElement->isSVG()) {
        const SVGSVGElement* svg = static_cast<const SVGSVGElement*>(viewportElement);
        if (svg->hasAttribute(SVGNames::viewBoxAttr)) {
            width = svg->viewBox().width();
            height = svg->viewBox().height();
        } else {
            width = svg->width().value();
            height = svg->height().value();

Possibly that if should just check to see if the <svg> has a renderer() and if it does, use that width/height.  Seems a little hacky however.  Really SVG length resolution just needs to move entirely into the rendering tree.
Comment 4 Eric Seidel (no email) 2007-06-01 16:09:29 PDT
This is probably at least related to bug 5940
Comment 5 Rob Buis 2007-06-14 10:35:56 PDT
Created attachment 15025 [details]
First attempt

This should do it:)

Comment 6 Eric Seidel (no email) 2007-06-14 10:54:37 PDT
Comment on attachment 15025 [details]
First attempt

This looks fine.  Since the change is in SVGLength, I wonder if now things like <div><svg:circle></div> will draw...
Comment 7 Rob Buis 2007-06-16 23:31:06 PDT
Landed in r 23530.