Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(555)

Unified Diff: third_party/WebKit/Source/core/layout/LayoutFieldset.cpp

Issue 2396813002: Support margin-top for legend in fieldset. (Closed)
Patch Set: Rebased to master. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/LayoutFieldset.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutFieldset.cpp b/third_party/WebKit/Source/core/layout/LayoutFieldset.cpp
index 5d94102c1f1c6aac885e4afadfcaca3eabc032c9..cf1f1885e97db68e82ed84c79909d34ac122a1b2 100644
--- a/third_party/WebKit/Source/core/layout/LayoutFieldset.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutFieldset.cpp
@@ -174,27 +174,29 @@ LayoutObject* LayoutFieldset::layoutSpecialExcludedChild(bool relayoutChildren,
LayoutUnit legendLogicalTop;
LayoutUnit collapsedLegendExtent;
LayoutUnit innerBlockPadding;
- // 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.
+
+ if (legendLogicalHeight < fieldsetBorderBefore) {
+ // Center legend in fieldset border
legendLogicalTop = (fieldsetBorderBefore - legendLogicalHeight) / 2;
- collapsedLegendExtent = max<LayoutUnit>(
- fieldsetBorderBefore, legendLogicalTop + legendLogicalHeight +
- marginAfterForChild(*legend));
- innerBlockPadding = marginAfterForChild(*legend)
- ? marginAfterForChild(*legend) - legendLogicalTop
- : LayoutUnit();
- } else {
- collapsedLegendExtent =
- legendLogicalHeight + marginAfterForChild(*legend);
- innerBlockPadding =
- legendLogicalHeight - borderAfter() + marginAfterForChild(*legend);
}
+ // Calculate how much legend + bottom margin sticks below the fieldset
+ // border
+ innerBlockPadding = (legendLogicalTop + legendLogicalHeight +
+ marginAfterForChild(*legend) - fieldsetBorderBefore)
+ .clampNegativeToZero();
+
+ if (legendLogicalTop < marginBeforeForChild(*legend)) {
+ // legend margin pushes everything down
+ innerBlockPadding += marginBeforeForChild(*legend) - legendLogicalTop;
+ legendLogicalTop = marginBeforeForChild(*legend);
+ }
+
+ collapsedLegendExtent =
+ std::max(fieldsetBorderBefore, marginBeforeForChild(*legend) +
+ legendLogicalHeight +
+ marginAfterForChild(*legend));
+
if (m_innerBlock)
setInnerBlockPadding(isHorizontalWritingMode(), m_innerBlock,
innerBlockPadding);

Powered by Google App Engine
This is Rietveld 408576698