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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. 5 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 } 167 }
168 168
169 setLogicalLeftForChild(*legend, logicalLeft); 169 setLogicalLeftForChild(*legend, logicalLeft);
170 170
171 LayoutUnit fieldsetBorderBefore = LayoutUnit(borderBefore()); 171 LayoutUnit fieldsetBorderBefore = LayoutUnit(borderBefore());
172 LayoutUnit legendLogicalHeight = logicalHeightForChild(*legend); 172 LayoutUnit legendLogicalHeight = logicalHeightForChild(*legend);
173 173
174 LayoutUnit legendLogicalTop; 174 LayoutUnit legendLogicalTop;
175 LayoutUnit collapsedLegendExtent; 175 LayoutUnit collapsedLegendExtent;
176 LayoutUnit innerBlockPadding; 176 LayoutUnit innerBlockPadding;
177 // FIXME: We need to account for the legend's margin before too. 177
178 if (fieldsetBorderBefore > legendLogicalHeight) { 178 if (legendLogicalHeight < fieldsetBorderBefore) {
179 // The <legend> is smaller than the associated fieldset before border 179 // Center legend in fieldset border
180 // so the latter determines positioning of the <legend>. The sizing
181 // depends on the legend's margins as we want to still follow the
182 // author's cues.
183 // Firefox completely ignores the margins in this case which seems wrong.
184 legendLogicalTop = (fieldsetBorderBefore - legendLogicalHeight) / 2; 180 legendLogicalTop = (fieldsetBorderBefore - legendLogicalHeight) / 2;
185 collapsedLegendExtent = max<LayoutUnit>(
186 fieldsetBorderBefore, legendLogicalTop + legendLogicalHeight +
187 marginAfterForChild(*legend));
188 innerBlockPadding = marginAfterForChild(*legend)
189 ? marginAfterForChild(*legend) - legendLogicalTop
190 : LayoutUnit();
191 } else {
192 collapsedLegendExtent =
193 legendLogicalHeight + marginAfterForChild(*legend);
194 innerBlockPadding =
195 legendLogicalHeight - borderAfter() + marginAfterForChild(*legend);
196 } 181 }
197 182
183 // Calculate how much legend + bottom margin sticks below the fieldset
184 // border
185 innerBlockPadding = (legendLogicalTop + legendLogicalHeight +
186 marginAfterForChild(*legend) - fieldsetBorderBefore)
187 .clampNegativeToZero();
188
189 if (legendLogicalTop < marginBeforeForChild(*legend)) {
190 // legend margin pushes everything down
191 innerBlockPadding += marginBeforeForChild(*legend) - legendLogicalTop;
192 legendLogicalTop = marginBeforeForChild(*legend);
193 }
194
195 collapsedLegendExtent =
196 std::max(fieldsetBorderBefore, marginBeforeForChild(*legend) +
197 legendLogicalHeight +
198 marginAfterForChild(*legend));
199
198 if (m_innerBlock) 200 if (m_innerBlock)
199 setInnerBlockPadding(isHorizontalWritingMode(), m_innerBlock, 201 setInnerBlockPadding(isHorizontalWritingMode(), m_innerBlock,
200 innerBlockPadding); 202 innerBlockPadding);
201 setLogicalTopForChild(*legend, legendLogicalTop); 203 setLogicalTopForChild(*legend, legendLogicalTop);
202 setLogicalHeight(paddingBefore() + collapsedLegendExtent); 204 setLogicalHeight(paddingBefore() + collapsedLegendExtent);
203 205
204 if (legend->frameRect() != oldLegendFrameRect) { 206 if (legend->frameRect() != oldLegendFrameRect) {
205 // We need to invalidate the fieldset border if the legend's frame 207 // We need to invalidate the fieldset border if the legend's frame
206 // changed. 208 // changed.
207 setShouldDoFullPaintInvalidation(); 209 setShouldDoFullPaintInvalidation();
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 LayoutFlexibleBox::removeChild(oldChild); 298 LayoutFlexibleBox::removeChild(oldChild);
297 m_innerBlock = nullptr; 299 m_innerBlock = nullptr;
298 } else if (oldChild->parent() == this) { 300 } else if (oldChild->parent() == this) {
299 LayoutFlexibleBox::removeChild(oldChild); 301 LayoutFlexibleBox::removeChild(oldChild);
300 } else if (m_innerBlock) { 302 } else if (m_innerBlock) {
301 m_innerBlock->removeChild(oldChild); 303 m_innerBlock->removeChild(oldChild);
302 } 304 }
303 } 305 }
304 306
305 } // namespace blink 307 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698