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

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

Issue 2558683002: Revert of Support margin-top for legend in fieldset. (Closed)
Patch Set: rebaseline Created 4 years 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 1527da1bdd632aaf0803296b2e45862baf241dfd..f21440a3e74f770c344fc45205a4277a3b8c0786 100644
--- a/third_party/WebKit/Source/core/layout/LayoutFieldset.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutFieldset.cpp
@@ -174,29 +174,27 @@ LayoutObject* LayoutFieldset::layoutSpecialExcludedChild(bool relayoutChildren,
LayoutUnit legendLogicalTop;
LayoutUnit collapsedLegendExtent;
LayoutUnit innerBlockPadding;
-
- if (legendLogicalHeight < fieldsetBorderBefore) {
- // Center legend in fieldset border
+ // 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));
+ 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