| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 RenderBox* legend = findLegend(); | 67 RenderBox* legend = findLegend(); |
| 68 if (legend) { | 68 if (legend) { |
| 69 if (relayoutChildren) | 69 if (relayoutChildren) |
| 70 legend->setNeedsLayoutAndFullPaintInvalidation(); | 70 legend->setNeedsLayoutAndFullPaintInvalidation(); |
| 71 legend->layoutIfNeeded(); | 71 legend->layoutIfNeeded(); |
| 72 | 72 |
| 73 LayoutUnit logicalLeft; | 73 LayoutUnit logicalLeft; |
| 74 if (style()->isLeftToRightDirection()) { | 74 if (style()->isLeftToRightDirection()) { |
| 75 switch (legend->style()->textAlign()) { | 75 switch (legend->style()->textAlign()) { |
| 76 case CENTER: | 76 case CENTER: |
| 77 logicalLeft = (logicalWidth() - logicalWidthForChild(legend)) /
2; | 77 logicalLeft = (logicalWidth() - logicalWidthForChild(*legend)) /
2; |
| 78 break; | 78 break; |
| 79 case RIGHT: | 79 case RIGHT: |
| 80 logicalLeft = logicalWidth() - borderEnd() - paddingEnd() - logi
calWidthForChild(legend); | 80 logicalLeft = logicalWidth() - borderEnd() - paddingEnd() - logi
calWidthForChild(*legend); |
| 81 break; | 81 break; |
| 82 default: | 82 default: |
| 83 logicalLeft = borderStart() + paddingStart() + marginStartForChi
ld(legend); | 83 logicalLeft = borderStart() + paddingStart() + marginStartForChi
ld(*legend); |
| 84 break; | 84 break; |
| 85 } | 85 } |
| 86 } else { | 86 } else { |
| 87 switch (legend->style()->textAlign()) { | 87 switch (legend->style()->textAlign()) { |
| 88 case LEFT: | 88 case LEFT: |
| 89 logicalLeft = borderStart() + paddingStart(); | 89 logicalLeft = borderStart() + paddingStart(); |
| 90 break; | 90 break; |
| 91 case CENTER: { | 91 case CENTER: { |
| 92 // Make sure that the extra pixel goes to the end side in RTL (s
ince it went to the end side | 92 // Make sure that the extra pixel goes to the end side in RTL (s
ince it went to the end side |
| 93 // in LTR). | 93 // in LTR). |
| 94 LayoutUnit centeredWidth = logicalWidth() - logicalWidthForChild
(legend); | 94 LayoutUnit centeredWidth = logicalWidth() - logicalWidthForChild
(*legend); |
| 95 logicalLeft = centeredWidth - centeredWidth / 2; | 95 logicalLeft = centeredWidth - centeredWidth / 2; |
| 96 break; | 96 break; |
| 97 } | 97 } |
| 98 default: | 98 default: |
| 99 logicalLeft = logicalWidth() - borderStart() - paddingStart() -
marginStartForChild(legend) - logicalWidthForChild(legend); | 99 logicalLeft = logicalWidth() - borderStart() - paddingStart() -
marginStartForChild(*legend) - logicalWidthForChild(*legend); |
| 100 break; | 100 break; |
| 101 } | 101 } |
| 102 } | 102 } |
| 103 | 103 |
| 104 setLogicalLeftForChild(legend, logicalLeft); | 104 setLogicalLeftForChild(*legend, logicalLeft); |
| 105 | 105 |
| 106 LayoutUnit fieldsetBorderBefore = borderBefore(); | 106 LayoutUnit fieldsetBorderBefore = borderBefore(); |
| 107 LayoutUnit legendLogicalHeight = logicalHeightForChild(legend); | 107 LayoutUnit legendLogicalHeight = logicalHeightForChild(*legend); |
| 108 | 108 |
| 109 LayoutUnit legendLogicalTop; | 109 LayoutUnit legendLogicalTop; |
| 110 LayoutUnit collapsedLegendExtent; | 110 LayoutUnit collapsedLegendExtent; |
| 111 // FIXME: We need to account for the legend's margin before too. | 111 // FIXME: We need to account for the legend's margin before too. |
| 112 if (fieldsetBorderBefore > legendLogicalHeight) { | 112 if (fieldsetBorderBefore > legendLogicalHeight) { |
| 113 // The <legend> is smaller than the associated fieldset before borde
r | 113 // The <legend> is smaller than the associated fieldset before borde
r |
| 114 // so the latter determines positioning of the <legend>. The sizing
depends | 114 // so the latter determines positioning of the <legend>. The sizing
depends |
| 115 // on the legend's margins as we want to still follow the author's c
ues. | 115 // on the legend's margins as we want to still follow the author's c
ues. |
| 116 // Firefox completely ignores the margins in this case which seems w
rong. | 116 // Firefox completely ignores the margins in this case which seems w
rong. |
| 117 legendLogicalTop = (fieldsetBorderBefore - legendLogicalHeight) / 2; | 117 legendLogicalTop = (fieldsetBorderBefore - legendLogicalHeight) / 2; |
| 118 collapsedLegendExtent = max<LayoutUnit>(fieldsetBorderBefore, legend
LogicalTop + legendLogicalHeight + marginAfterForChild(legend)); | 118 collapsedLegendExtent = max<LayoutUnit>(fieldsetBorderBefore, legend
LogicalTop + legendLogicalHeight + marginAfterForChild(*legend)); |
| 119 } else | 119 } else { |
| 120 collapsedLegendExtent = legendLogicalHeight + marginAfterForChild(le
gend); | 120 collapsedLegendExtent = legendLogicalHeight + marginAfterForChild(*l
egend); |
| 121 } |
| 121 | 122 |
| 122 setLogicalTopForChild(legend, legendLogicalTop); | 123 setLogicalTopForChild(*legend, legendLogicalTop); |
| 123 setLogicalHeight(paddingBefore() + collapsedLegendExtent); | 124 setLogicalHeight(paddingBefore() + collapsedLegendExtent); |
| 124 } | 125 } |
| 125 return legend; | 126 return legend; |
| 126 } | 127 } |
| 127 | 128 |
| 128 RenderBox* RenderFieldset::findLegend(FindLegendOption option) const | 129 RenderBox* RenderFieldset::findLegend(FindLegendOption option) const |
| 129 { | 130 { |
| 130 for (RenderObject* legend = firstChild(); legend; legend = legend->nextSibli
ng()) { | 131 for (RenderObject* legend = firstChild(); legend; legend = legend->nextSibli
ng()) { |
| 131 if (option == IgnoreFloatingOrOutOfFlow && legend->isFloatingOrOutOfFlow
Positioned()) | 132 if (option == IgnoreFloatingOrOutOfFlow && legend->isFloatingOrOutOfFlow
Positioned()) |
| 132 continue; | 133 continue; |
| 133 | 134 |
| 134 if (isHTMLLegendElement(legend->node())) | 135 if (isHTMLLegendElement(legend->node())) |
| 135 return toRenderBox(legend); | 136 return toRenderBox(legend); |
| 136 } | 137 } |
| 137 return 0; | 138 return 0; |
| 138 } | 139 } |
| 139 | 140 |
| 140 void RenderFieldset::paintBoxDecorationBackground(const PaintInfo& paintInfo, co
nst LayoutPoint& paintOffset) | 141 void RenderFieldset::paintBoxDecorationBackground(const PaintInfo& paintInfo, co
nst LayoutPoint& paintOffset) |
| 141 { | 142 { |
| 142 FieldsetPainter(*this).paintBoxDecorationBackground(paintInfo, paintOffset); | 143 FieldsetPainter(*this).paintBoxDecorationBackground(paintInfo, paintOffset); |
| 143 } | 144 } |
| 144 | 145 |
| 145 void RenderFieldset::paintMask(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) | 146 void RenderFieldset::paintMask(const PaintInfo& paintInfo, const LayoutPoint& pa
intOffset) |
| 146 { | 147 { |
| 147 FieldsetPainter(*this).paintMask(paintInfo, paintOffset); | 148 FieldsetPainter(*this).paintMask(paintInfo, paintOffset); |
| 148 } | 149 } |
| 149 | 150 |
| 150 } // namespace blink | 151 } // namespace blink |
| OLD | NEW |