Diff
Modified: trunk/LayoutTests/ChangeLog (120016 => 120017)
--- trunk/LayoutTests/ChangeLog 2012-06-11 23:12:28 UTC (rev 120016)
+++ trunk/LayoutTests/ChangeLog 2012-06-11 23:14:38 UTC (rev 120017)
@@ -1,3 +1,19 @@
+2012-06-11 Julien Chaffraix <[email protected]>
+
+ Account for margin after when laying out <legend> element
+ https://bugs.webkit.org/show_bug.cgi?id=35981
+
+ Reviewed by Abhishek Arya.
+
+ * fast/forms/legend-after-margin-horizontal-writing-mode-expected.html: Added.
+ * fast/forms/legend-after-margin-horizontal-writing-mode.html: Added.
+ * fast/forms/legend-after-margin-vertical-writing-mode-expected.html: Added.
+ * fast/forms/legend-after-margin-vertical-writing-mode.html: Added.
+ * fast/forms/legend-after-margin-with-before-border-horizontal-mode-expected.html: Added.
+ * fast/forms/legend-after-margin-with-before-border-horizontal-mode.html: Added.
+ * fast/forms/legend-small-after-margin-before-border-horizontal-mode-expected.html: Added.
+ * fast/forms/legend-small-after-margin-before-border-horizontal-mode.html: Added.
+
2012-06-05 Eric Uhrhane <[email protected]>
Crash in fast/files/read tests during Garbage Collection
Added: trunk/LayoutTests/fast/forms/legend-after-margin-horizontal-writing-mode-expected.html (0 => 120017)
--- trunk/LayoutTests/fast/forms/legend-after-margin-horizontal-writing-mode-expected.html (rev 0)
+++ trunk/LayoutTests/fast/forms/legend-after-margin-horizontal-writing-mode-expected.html 2012-06-11 23:14:38 UTC (rev 120017)
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+ legend {
+ background: #fc0;
+ }
+ fieldset { background: #ddd; }
+ p { margin-top: 50px; }
+</style>
+<body>
+<div>bug <a href="" Can't apply a bottom-margin to the legend element</div>
+<form>
+ <fieldset>
+ <legend>Legend</legend>
+ <p>There should be a 50px gap above to account for the margin-bottom on the legend.</p>
+ </fieldset>
+</form>
+</body>
+</html>
Added: trunk/LayoutTests/fast/forms/legend-after-margin-horizontal-writing-mode.html (0 => 120017)
--- trunk/LayoutTests/fast/forms/legend-after-margin-horizontal-writing-mode.html (rev 0)
+++ trunk/LayoutTests/fast/forms/legend-after-margin-horizontal-writing-mode.html 2012-06-11 23:14:38 UTC (rev 120017)
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+ legend {
+ background: #fc0;
+ margin-bottom: 50px;
+ }
+ fieldset { background: #ddd; }
+ p { margin-top: 0px; }
+</style>
+<body>
+<div>bug <a href="" Can't apply a bottom-margin to the legend element</div>
+<form>
+ <fieldset>
+ <legend>Legend</legend>
+ <p>There should be a 50px gap above to account for the margin-bottom on the legend.</p>
+ </fieldset>
+</form>
+</body>
+</html>
Added: trunk/LayoutTests/fast/forms/legend-after-margin-vertical-writing-mode-expected.html (0 => 120017)
--- trunk/LayoutTests/fast/forms/legend-after-margin-vertical-writing-mode-expected.html (rev 0)
+++ trunk/LayoutTests/fast/forms/legend-after-margin-vertical-writing-mode-expected.html 2012-06-11 23:14:38 UTC (rev 120017)
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+ form {
+ -webkit-writing-mode: vertical-lr;
+ writing-mode: vertical-lr;
+ }
+ legend {
+ background: #fc0;
+ }
+ fieldset { background: #ddd; }
+ p { margin-left: 50px; }
+</style>
+<body>
+<div>bug <a href="" Can't apply a bottom-margin to the legend element</div>
+<form>
+ <fieldset>
+ <legend>Legend</legend>
+ <p>There should be a 50px gap on the right to account for the margin-bottom on the legend.</p>
+ </fieldset>
+</form>
+</body>
+</html>
Added: trunk/LayoutTests/fast/forms/legend-after-margin-vertical-writing-mode.html (0 => 120017)
--- trunk/LayoutTests/fast/forms/legend-after-margin-vertical-writing-mode.html (rev 0)
+++ trunk/LayoutTests/fast/forms/legend-after-margin-vertical-writing-mode.html 2012-06-11 23:14:38 UTC (rev 120017)
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+ form {
+ -webkit-writing-mode: vertical-lr;
+ writing-mode: vertical-lr;
+ }
+ legend {
+ background: #fc0;
+ margin-right: 50px;
+ }
+ fieldset { background: #ddd; }
+ p { margin-left: 0px; }
+</style>
+<body>
+<div>bug <a href="" Can't apply a bottom-margin to the legend element</div>
+<form>
+ <fieldset>
+ <legend>Legend</legend>
+ <p>There should be a 50px gap on the right to account for the margin-bottom on the legend.</p>
+ </fieldset>
+</form>
+</body>
+</html>
Added: trunk/LayoutTests/fast/forms/legend-after-margin-with-before-border-horizontal-mode-expected.html (0 => 120017)
--- trunk/LayoutTests/fast/forms/legend-after-margin-with-before-border-horizontal-mode-expected.html (rev 0)
+++ trunk/LayoutTests/fast/forms/legend-after-margin-with-before-border-horizontal-mode-expected.html 2012-06-11 23:14:38 UTC (rev 120017)
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+ legend {
+ background: #fc0;
+ font: 10px Ahem;
+ }
+ fieldset {
+ border-top: 70px solid #ddd;
+ background: #ddd;
+ }
+ p { margin-top: 20px; }
+</style>
+<body>
+<div>bug <a href="" Can't apply a bottom-margin to the legend element</div>
+<form>
+ <fieldset>
+ <legend>xxxx</legend>
+ <p>There should be a 20px gap above to account for the margin bottom collapsing into the fieldset before border.</p>
+ </fieldset>
+</form>
+</body>
+</html>
Added: trunk/LayoutTests/fast/forms/legend-after-margin-with-before-border-horizontal-mode.html (0 => 120017)
--- trunk/LayoutTests/fast/forms/legend-after-margin-with-before-border-horizontal-mode.html (rev 0)
+++ trunk/LayoutTests/fast/forms/legend-after-margin-with-before-border-horizontal-mode.html 2012-06-11 23:14:38 UTC (rev 120017)
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+ legend {
+ background: #fc0;
+ margin-bottom: 50px;
+ font: 10px Ahem;
+ }
+ fieldset {
+ border-top: 70px solid #ddd;
+ background: #ddd;
+ }
+ p { margin-top: 0px; }
+</style>
+<body>
+<div>bug <a href="" Can't apply a bottom-margin to the legend element</div>
+<form>
+ <fieldset>
+ <legend>xxxx</legend>
+ <p>There should be a 20px gap above to account for the margin bottom collapsing into the fieldset before border.</p>
+ </fieldset>
+</form>
+</body>
+</html>
Added: trunk/LayoutTests/fast/forms/legend-small-after-margin-before-border-horizontal-mode-expected.html (0 => 120017)
--- trunk/LayoutTests/fast/forms/legend-small-after-margin-before-border-horizontal-mode-expected.html (rev 0)
+++ trunk/LayoutTests/fast/forms/legend-small-after-margin-before-border-horizontal-mode-expected.html 2012-06-11 23:14:38 UTC (rev 120017)
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+ legend {
+ background: #fc0;
+ font: 10px Ahem;
+ }
+ fieldset {
+ border-top: 70px solid #ddd;
+ background: #ddd;
+ }
+ p { margin-top: 0px; }
+</style>
+<body>
+<p>bug <a href="" Can't apply a bottom-margin to the legend element</p>
+<form>
+ <fieldset>
+ <legend>xxxx</legend>
+ <p>There should be no gap above as the legend's margin bottom should be collapsed into the fieldset's border.</p>
+ </fieldset>
+</form>
+</body>
+</html>
Added: trunk/LayoutTests/fast/forms/legend-small-after-margin-before-border-horizontal-mode.html (0 => 120017)
--- trunk/LayoutTests/fast/forms/legend-small-after-margin-before-border-horizontal-mode.html (rev 0)
+++ trunk/LayoutTests/fast/forms/legend-small-after-margin-before-border-horizontal-mode.html 2012-06-11 23:14:38 UTC (rev 120017)
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+ legend {
+ background: #fc0;
+ margin-bottom: 30px;
+ font: 10px Ahem;
+ }
+ fieldset {
+ border-top: 70px solid #ddd;
+ background: #ddd;
+ }
+ p { margin-top: 0px; }
+</style>
+<body>
+<p>bug <a href="" Can't apply a bottom-margin to the legend element</p>
+<form>
+ <fieldset>
+ <legend>xxxx</legend>
+ <p>There should be no gap above as the legend's margin bottom should be collapsed into the fieldset's border.</p>
+ </fieldset>
+</form>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (120016 => 120017)
--- trunk/Source/WebCore/ChangeLog 2012-06-11 23:12:28 UTC (rev 120016)
+++ trunk/Source/WebCore/ChangeLog 2012-06-11 23:14:38 UTC (rev 120017)
@@ -1,3 +1,24 @@
+2012-06-11 Julien Chaffraix <[email protected]>
+
+ Account for margin after when laying out <legend> element
+ https://bugs.webkit.org/show_bug.cgi?id=35981
+
+ Reviewed by Abhishek Arya.
+
+ Tests: fast/forms/legend-after-margin-horizontal-writing-mode.html
+ fast/forms/legend-after-margin-vertical-writing-mode.html
+ fast/forms/legend-after-margin-with-before-border-horizontal-mode.html
+ fast/forms/legend-small-after-margin-before-border-horizontal-mode.html
+
+ The existing code would ignore margin after when layouting out the <legend>. This
+ change only adds the code to handle the margin after, the margin before is still
+ ignored as it's not obvious how it should be working.
+
+ * rendering/RenderFieldset.cpp:
+ (WebCore::RenderFieldset::layoutSpecialExcludedChild):
+ Split the code in 2 code paths to reflect how we position and size. Those are covered by the
+ tests above.
+
2012-06-11 James Robinson <[email protected]>
[chromium] Use WebGraphicsContext3D in rate limiting logic inside compositor
Modified: trunk/Source/WebCore/rendering/RenderFieldset.cpp (120016 => 120017)
--- trunk/Source/WebCore/rendering/RenderFieldset.cpp 2012-06-11 23:12:28 UTC (rev 120016)
+++ trunk/Source/WebCore/rendering/RenderFieldset.cpp 2012-06-11 23:14:38 UTC (rev 120017)
@@ -101,10 +101,24 @@
setLogicalLeftForChild(legend, logicalLeft);
- LayoutUnit b = borderBefore();
- LayoutUnit h = logicalHeightForChild(legend);
- setLogicalTopForChild(legend, max<LayoutUnit>((b - h) / 2, 0));
- setLogicalHeight(max(b, h) + paddingBefore());
+ LayoutUnit fieldsetBorderBefore = borderBefore();
+ LayoutUnit legendLogicalHeight = logicalHeightForChild(legend);
+
+ LayoutUnit legendLogicalTop;
+ LayoutUnit collapsedLegendExtent;
+ // FIXME: We need to account for the legend's margin before too.
+ if (fieldsetBorderBefore > legendLogicalHeight) {
+ // The <legend> is smaller than the associated fieldset before border
+ // so the latter determines positioning of the <legend>. The sizing depends
+ // on the legend's margins as we want to still follow the author's cues.
+ // Firefox completely ignores the margins in this case which seems wrong.
+ legendLogicalTop = (fieldsetBorderBefore - legendLogicalHeight) / 2;
+ collapsedLegendExtent = max<LayoutUnit>(fieldsetBorderBefore, legendLogicalTop + legendLogicalHeight + marginAfterForChild(legend));
+ } else
+ collapsedLegendExtent = legendLogicalHeight + marginAfterForChild(legend);
+
+ setLogicalTopForChild(legend, legendLogicalTop);
+ setLogicalHeight(paddingBefore() + collapsedLegendExtent);
}
return legend;
}