| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 DCHECK_GE(minPreferredLogicalWidth, LayoutUnit()); | 84 DCHECK_GE(minPreferredLogicalWidth, LayoutUnit()); |
| 85 DCHECK_GE(maxPreferredLogicalWidth, LayoutUnit()); | 85 DCHECK_GE(maxPreferredLogicalWidth, LayoutUnit()); |
| 86 minPreferredLogicalWidth += margin; | 86 minPreferredLogicalWidth += margin; |
| 87 maxPreferredLogicalWidth += margin; | 87 maxPreferredLogicalWidth += margin; |
| 88 minLogicalWidth = std::max(minPreferredLogicalWidth, minLogicalWidth); | 88 minLogicalWidth = std::max(minPreferredLogicalWidth, minLogicalWidth); |
| 89 maxLogicalWidth = std::max(maxPreferredLogicalWidth, maxLogicalWidth); | 89 maxLogicalWidth = std::max(maxPreferredLogicalWidth, maxLogicalWidth); |
| 90 } | 90 } |
| 91 | 91 |
| 92 maxLogicalWidth = std::max(minLogicalWidth, maxLogicalWidth); | 92 maxLogicalWidth = std::max(minLogicalWidth, maxLogicalWidth); |
| 93 | 93 |
| 94 // Due to negative margins, it is possible that we calculated a negative intri
nsic width. Make sure that we | 94 // Due to negative margins, it is possible that we calculated a negative |
| 95 // never return a negative width. | 95 // intrinsic width. Make sure that we never return a negative width. |
| 96 minLogicalWidth = std::max(LayoutUnit(), minLogicalWidth); | 96 minLogicalWidth = std::max(LayoutUnit(), minLogicalWidth); |
| 97 maxLogicalWidth = std::max(LayoutUnit(), maxLogicalWidth); | 97 maxLogicalWidth = std::max(LayoutUnit(), maxLogicalWidth); |
| 98 | 98 |
| 99 LayoutUnit scrollbarWidth(scrollbarLogicalWidth()); | 99 LayoutUnit scrollbarWidth(scrollbarLogicalWidth()); |
| 100 maxLogicalWidth += scrollbarWidth; | 100 maxLogicalWidth += scrollbarWidth; |
| 101 minLogicalWidth += scrollbarWidth; | 101 minLogicalWidth += scrollbarWidth; |
| 102 } | 102 } |
| 103 | 103 |
| 104 void LayoutFieldset::setLogicalLeftForChild(LayoutBox& child, | 104 void LayoutFieldset::setLogicalLeftForChild(LayoutBox& child, |
| 105 LayoutUnit logicalLeft) { | 105 LayoutUnit logicalLeft) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 logicalLeft = | 144 logicalLeft = |
| 145 borderStart() + paddingStart() + marginStartForChild(*legend); | 145 borderStart() + paddingStart() + marginStartForChild(*legend); |
| 146 break; | 146 break; |
| 147 } | 147 } |
| 148 } else { | 148 } else { |
| 149 switch (legend->style()->textAlign()) { | 149 switch (legend->style()->textAlign()) { |
| 150 case LEFT: | 150 case LEFT: |
| 151 logicalLeft = borderStart() + paddingStart(); | 151 logicalLeft = borderStart() + paddingStart(); |
| 152 break; | 152 break; |
| 153 case CENTER: { | 153 case CENTER: { |
| 154 // Make sure that the extra pixel goes to the end side in RTL (since i
t went to the end side | 154 // Make sure that the extra pixel goes to the end side in RTL (since |
| 155 // in LTR). | 155 // it went to the end side in LTR). |
| 156 LayoutUnit centeredWidth = | 156 LayoutUnit centeredWidth = |
| 157 logicalWidth() - logicalWidthForChild(*legend); | 157 logicalWidth() - logicalWidthForChild(*legend); |
| 158 logicalLeft = centeredWidth - centeredWidth / 2; | 158 logicalLeft = centeredWidth - centeredWidth / 2; |
| 159 break; | 159 break; |
| 160 } | 160 } |
| 161 default: | 161 default: |
| 162 logicalLeft = logicalWidth() - borderStart() - paddingStart() - | 162 logicalLeft = logicalWidth() - borderStart() - paddingStart() - |
| 163 marginStartForChild(*legend) - | 163 marginStartForChild(*legend) - |
| 164 logicalWidthForChild(*legend); | 164 logicalWidthForChild(*legend); |
| 165 break; | 165 break; |
| 166 } | 166 } |
| 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 // FIXME: We need to account for the legend's margin before too. |
| 178 if (fieldsetBorderBefore > legendLogicalHeight) { | 178 if (fieldsetBorderBefore > legendLogicalHeight) { |
| 179 // The <legend> is smaller than the associated fieldset before border | 179 // The <legend> is smaller than the associated fieldset before border |
| 180 // so the latter determines positioning of the <legend>. The sizing depend
s | 180 // so the latter determines positioning of the <legend>. The sizing |
| 181 // on the legend's margins as we want to still follow the author's cues. | 181 // depends on the legend's margins as we want to still follow the |
| 182 // author's cues. |
| 182 // Firefox completely ignores the margins in this case which seems wrong. | 183 // Firefox completely ignores the margins in this case which seems wrong. |
| 183 legendLogicalTop = (fieldsetBorderBefore - legendLogicalHeight) / 2; | 184 legendLogicalTop = (fieldsetBorderBefore - legendLogicalHeight) / 2; |
| 184 collapsedLegendExtent = max<LayoutUnit>( | 185 collapsedLegendExtent = max<LayoutUnit>( |
| 185 fieldsetBorderBefore, legendLogicalTop + legendLogicalHeight + | 186 fieldsetBorderBefore, legendLogicalTop + legendLogicalHeight + |
| 186 marginAfterForChild(*legend)); | 187 marginAfterForChild(*legend)); |
| 187 innerBlockPadding = marginAfterForChild(*legend) | 188 innerBlockPadding = marginAfterForChild(*legend) |
| 188 ? marginAfterForChild(*legend) - legendLogicalTop | 189 ? marginAfterForChild(*legend) - legendLogicalTop |
| 189 : LayoutUnit(); | 190 : LayoutUnit(); |
| 190 } else { | 191 } else { |
| 191 collapsedLegendExtent = | 192 collapsedLegendExtent = |
| 192 legendLogicalHeight + marginAfterForChild(*legend); | 193 legendLogicalHeight + marginAfterForChild(*legend); |
| 193 innerBlockPadding = | 194 innerBlockPadding = |
| 194 legendLogicalHeight - borderAfter() + marginAfterForChild(*legend); | 195 legendLogicalHeight - borderAfter() + marginAfterForChild(*legend); |
| 195 } | 196 } |
| 196 | 197 |
| 197 if (m_innerBlock) | 198 if (m_innerBlock) |
| 198 setInnerBlockPadding(isHorizontalWritingMode(), m_innerBlock, | 199 setInnerBlockPadding(isHorizontalWritingMode(), m_innerBlock, |
| 199 innerBlockPadding); | 200 innerBlockPadding); |
| 200 setLogicalTopForChild(*legend, legendLogicalTop); | 201 setLogicalTopForChild(*legend, legendLogicalTop); |
| 201 setLogicalHeight(paddingBefore() + collapsedLegendExtent); | 202 setLogicalHeight(paddingBefore() + collapsedLegendExtent); |
| 202 | 203 |
| 203 if (legend->frameRect() != oldLegendFrameRect) { | 204 if (legend->frameRect() != oldLegendFrameRect) { |
| 204 // We need to invalidate the fieldset border if the legend's frame changed
. | 205 // We need to invalidate the fieldset border if the legend's frame |
| 206 // changed. |
| 205 setShouldDoFullPaintInvalidation(); | 207 setShouldDoFullPaintInvalidation(); |
| 206 if (m_innerBlock) | 208 if (m_innerBlock) |
| 207 m_innerBlock->setNeedsLayout(LayoutInvalidationReason::FieldsetChanged, | 209 m_innerBlock->setNeedsLayout(LayoutInvalidationReason::FieldsetChanged, |
| 208 MarkOnlyThis); | 210 MarkOnlyThis); |
| 209 } | 211 } |
| 210 } | 212 } |
| 211 return legend; | 213 return legend; |
| 212 } | 214 } |
| 213 | 215 |
| 214 LayoutBox* LayoutFieldset::findInFlowLegend() const { | 216 LayoutBox* LayoutFieldset::findInFlowLegend() const { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 LayoutFlexibleBox::removeChild(oldChild); | 296 LayoutFlexibleBox::removeChild(oldChild); |
| 295 m_innerBlock = nullptr; | 297 m_innerBlock = nullptr; |
| 296 } else if (oldChild->parent() == this) { | 298 } else if (oldChild->parent() == this) { |
| 297 LayoutFlexibleBox::removeChild(oldChild); | 299 LayoutFlexibleBox::removeChild(oldChild); |
| 298 } else if (m_innerBlock) { | 300 } else if (m_innerBlock) { |
| 299 m_innerBlock->removeChild(oldChild); | 301 m_innerBlock->removeChild(oldChild); |
| 300 } | 302 } |
| 301 } | 303 } |
| 302 | 304 |
| 303 } // namespace blink | 305 } // namespace blink |
| OLD | NEW |