RESOLVED FIXED 16305
Width of svg elements not applied to container elements
https://bugs.webkit.org/show_bug.cgi?id=16305
Summary Width of svg elements not applied to container elements
Yoah Bar-David
Reported 2007-12-05 02:37:22 PST
When adding svg element into the dom, the width of the element is not applied to the width of it's parent (the height is properly applied). Included is a simple example where an svg element is added into a table cell. Note that the row height is correctly set, but the cell width is not. <!DOCTYPE HTML> <html> <head> <title>WebKit SVG Bug</title> <script type="text/javascript"> function draw() { var NS = "http://www.w3.org/2000/svg"; var s = document.createElementNS(NS, "svg"); s.setAttribute("width", 400); s.setAttribute("height", 200); var rect = document.createElementNS(NS, "rect"); rect.setAttribute("x", "0"); rect.setAttribute("y", "0"); rect.setAttribute("width", "400"); rect.setAttribute("height", "200"); rect.setAttribute("fill", "yellow"); s.appendChild(rect); document.getElementById("d").appendChild(s); } </script> </head> <body onload="draw()"> <table border="1"> <tr> <td>X</td> <td id="d"></td> </tr> </table> </body> </html>
Attachments
Simple problem demo with an svg rectangle (778 bytes, text/html)
2007-12-05 02:39 PST, Yoah Bar-David
no flags
Add RenderSVGRoot::calcPrefWidth and test case (5.42 KB, patch)
2007-12-15 02:44 PST, Eric Seidel (no email)
oliver: review+
Yoah Bar-David
Comment 1 2007-12-05 02:39:13 PST
Created attachment 17716 [details] Simple problem demo with an svg rectangle
David Kilzer (:ddkilzer)
Comment 2 2007-12-05 08:26:27 PST
Confirmed with a local debug build of WebKit r28434 with Safari 3.0.4 (523.12) on Mac OS X 10.4.11 (8S165).
Eric Seidel (no email)
Comment 3 2007-12-15 01:37:52 PST
I doubt this has much to do with <svg>. This should basically function the same as <img>, I wonder if <img> works in this case. Cool bug though.
Eric Seidel (no email)
Comment 4 2007-12-15 02:20:18 PST
This also shows the bug: <html> <head> <script type="text/javascript"> function draw() { var NS = "http://www.w3.org/2000/svg"; var s = document.createElementNS(NS, "svg"); s.setAttribute("width", 400); s.setAttribute("height", 200); var rect = document.createElementNS(NS, "rect"); rect.setAttribute("width", "100%"); rect.setAttribute("height", "100%"); rect.setAttribute("fill", "yellow"); s.appendChild(rect); document.getElementById("d").appendChild(s); } </script> </head> <body onload="draw()"> <div style="border: 3px solid black; float: left;" id="d"></div> </body> </html> Interestingly, Firefox seems to have the same bug in the float case. Opera does not.
Eric Seidel (no email)
Comment 5 2007-12-15 02:44:29 PST
Created attachment 17909 [details] Add RenderSVGRoot::calcPrefWidth and test case LayoutTests/ChangeLog | 12 +++++++++ .../svg/css/css-box-min-width-expected.checksum | 1 + .../mac/svg/css/css-box-min-width-expected.png | Bin 0 -> 7834 bytes .../mac/svg/css/css-box-min-width-expected.txt | 11 ++++++++ LayoutTests/svg/css/css-box-min-width.html | 26 ++++++++++++++++++++ WebCore/ChangeLog | 15 +++++++++++ WebCore/rendering/RenderSVGRoot.cpp | 14 ++++++++++ WebCore/rendering/RenderSVGRoot.h | 1 + 8 files changed, 80 insertions(+), 0 deletions(-)
Eric Seidel (no email)
Comment 6 2007-12-15 12:03:52 PST
Landed as r28755
Note You need to log in before you can comment on or make changes to this bug.