<html>
<head>
<base href="https://bugs.webkit.org/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - The heights of SVG elements using relative sizes are miscalculated within border-box parents"
href="https://bugs.webkit.org/show_bug.cgi?id=154049">154049</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>The heights of SVG elements using relative sizes are miscalculated within border-box parents
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr>
<tr>
<th>Product</th>
<td>WebKit
</td>
</tr>
<tr>
<th>Version</th>
<td>WebKit Nightly Build
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Unspecified
</td>
</tr>
<tr>
<th>OS</th>
<td>Unspecified
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>Normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P2
</td>
</tr>
<tr>
<th>Component</th>
<td>SVG
</td>
</tr>
<tr>
<th>Assignee</th>
<td>webkit-unassigned@lists.webkit.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>anthony.lalande@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>zimmermann@kde.org
</td>
</tr></table>
<p>
<div>
<pre>Overview:
When including an SVG element within a parent element that uses `box-sizing: border-box`, the relative height of the SVG element seems to be miscalculated.
Steps to reproduce:
- Create an enclosing block element with the `box-sizing: border-box` directive.
- Add a padding value > 0 for this enclosing element.
- Create an inner SVG element with the `height: 100%` directive.
- Observe that the SVG element has a height that is too short by a factor of 2x the parent's padding.
Expected results:
I would expect an SVG element to be sized identically to a `<div>` element that uses `box-sizing: border-box`, as here:
<a href="https://jsfiddle.net/p9ke6bo9/">https://jsfiddle.net/p9ke6bo9/</a>
Note that the underlying black box forms a 10px "border" all around the white box.
Actual results:
When you change the `<div>` element to `<svg>` in the example above, the black outline grows to 30px at the bottom:
<a href="https://jsfiddle.net/p9ke6bo9/1/">https://jsfiddle.net/p9ke6bo9/1/</a>
This seems to be because the `<svg>` element is subtracting 4 * 10px (instead of 2 * 10px) from the parent element's height.
Additional example:
When you remove the `box-sizing: border-box` directive from the outer element, the inner `<svg>` element draws correctly:
<a href="https://jsfiddle.net/p9ke6bo9/3/">https://jsfiddle.net/p9ke6bo9/3/</a></pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>