OLD | NEW |
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 Loading... |
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 | 177 // FIXME: We need to account for the legend's margin before too. |
178 if (legendLogicalHeight < fieldsetBorderBefore) { | 178 if (fieldsetBorderBefore > legendLogicalHeight) { |
179 // Center legend in fieldset border | 179 // The <legend> is smaller than the associated fieldset before 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. |
180 legendLogicalTop = (fieldsetBorderBefore - legendLogicalHeight) / 2; | 184 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); |
181 } | 196 } |
182 | 197 |
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 | |
200 if (m_innerBlock) | 198 if (m_innerBlock) |
201 setInnerBlockPadding(isHorizontalWritingMode(), m_innerBlock, | 199 setInnerBlockPadding(isHorizontalWritingMode(), m_innerBlock, |
202 innerBlockPadding); | 200 innerBlockPadding); |
203 setLogicalTopForChild(*legend, legendLogicalTop); | 201 setLogicalTopForChild(*legend, legendLogicalTop); |
204 setLogicalHeight(paddingBefore() + collapsedLegendExtent); | 202 setLogicalHeight(paddingBefore() + collapsedLegendExtent); |
205 | 203 |
206 if (legend->frameRect() != oldLegendFrameRect) { | 204 if (legend->frameRect() != oldLegendFrameRect) { |
207 // We need to invalidate the fieldset border if the legend's frame | 205 // We need to invalidate the fieldset border if the legend's frame |
208 // changed. | 206 // changed. |
209 setShouldDoFullPaintInvalidation(); | 207 setShouldDoFullPaintInvalidation(); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 LayoutFlexibleBox::removeChild(oldChild); | 294 LayoutFlexibleBox::removeChild(oldChild); |
297 m_innerBlock = nullptr; | 295 m_innerBlock = nullptr; |
298 } else if (oldChild->parent() == this) { | 296 } else if (oldChild->parent() == this) { |
299 LayoutFlexibleBox::removeChild(oldChild); | 297 LayoutFlexibleBox::removeChild(oldChild); |
300 } else if (m_innerBlock) { | 298 } else if (m_innerBlock) { |
301 m_innerBlock->removeChild(oldChild); | 299 m_innerBlock->removeChild(oldChild); |
302 } | 300 } |
303 } | 301 } |
304 | 302 |
305 } // namespace blink | 303 } // namespace blink |
OLD | NEW |