OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1997 Martin Jones (mjones@kde.org) | 2 * Copyright (C) 1997 Martin Jones (mjones@kde.org) |
3 * (C) 1997 Torben Weis (weis@kde.org) | 3 * (C) 1997 Torben Weis (weis@kde.org) |
4 * (C) 1998 Waldo Bastian (bastian@kde.org) | 4 * (C) 1998 Waldo Bastian (bastian@kde.org) |
5 * (C) 1999 Lars Knoll (knoll@kde.org) | 5 * (C) 1999 Lars Knoll (knoll@kde.org) |
6 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 6 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. | 7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. |
8 * All rights reserved. | 8 * All rights reserved. |
9 * | 9 * |
10 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 previousCell()->setPreferredLogicalWidthsDirty(); | 115 previousCell()->setPreferredLogicalWidthsDirty(); |
116 } | 116 } |
117 if (nextCell()) { | 117 if (nextCell()) { |
118 // TODO(dgrogan): Same as above re: setChildNeedsLayout vs setNeedsLayout. | 118 // TODO(dgrogan): Same as above re: setChildNeedsLayout vs setNeedsLayout. |
119 nextCell()->setNeedsLayout(LayoutInvalidationReason::TableChanged); | 119 nextCell()->setNeedsLayout(LayoutInvalidationReason::TableChanged); |
120 nextCell()->setPreferredLogicalWidthsDirty(); | 120 nextCell()->setPreferredLogicalWidthsDirty(); |
121 } | 121 } |
122 } | 122 } |
123 | 123 |
124 unsigned LayoutTableCell::parseColSpanFromDOM() const { | 124 unsigned LayoutTableCell::parseColSpanFromDOM() const { |
125 ASSERT(node()); | 125 DCHECK(node()); |
126 // TODO(dgrogan): HTMLTableCellElement::colSpan() already clamps to something | 126 // TODO(dgrogan): HTMLTableCellElement::colSpan() already clamps to something |
127 // smaller than maxColumnIndex; can we just DCHECK here? | 127 // smaller than maxColumnIndex; can we just DCHECK here? |
128 if (isHTMLTableCellElement(*node())) | 128 if (isHTMLTableCellElement(*node())) |
129 return std::min<unsigned>(toHTMLTableCellElement(*node()).colSpan(), | 129 return std::min<unsigned>(toHTMLTableCellElement(*node()).colSpan(), |
130 maxColumnIndex); | 130 maxColumnIndex); |
131 return 1; | 131 return 1; |
132 } | 132 } |
133 | 133 |
134 unsigned LayoutTableCell::parseRowSpanFromDOM() const { | 134 unsigned LayoutTableCell::parseRowSpanFromDOM() const { |
135 ASSERT(node()); | 135 DCHECK(node()); |
136 if (isHTMLTableCellElement(*node())) | 136 if (isHTMLTableCellElement(*node())) |
137 return std::min<unsigned>(toHTMLTableCellElement(*node()).rowSpan(), | 137 return std::min<unsigned>(toHTMLTableCellElement(*node()).rowSpan(), |
138 maxRowIndex); | 138 maxRowIndex); |
139 return 1; | 139 return 1; |
140 } | 140 } |
141 | 141 |
142 void LayoutTableCell::updateColAndRowSpanFlags() { | 142 void LayoutTableCell::updateColAndRowSpanFlags() { |
143 // The vast majority of table cells do not have a colspan or rowspan, | 143 // The vast majority of table cells do not have a colspan or rowspan, |
144 // so we keep a bool to know if we need to bother reading from the DOM. | 144 // so we keep a bool to know if we need to bother reading from the DOM. |
145 m_hasColSpan = node() && parseColSpanFromDOM() != 1; | 145 m_hasColSpan = node() && parseColSpanFromDOM() != 1; |
146 m_hasRowSpan = node() && parseRowSpanFromDOM() != 1; | 146 m_hasRowSpan = node() && parseRowSpanFromDOM() != 1; |
147 } | 147 } |
148 | 148 |
149 void LayoutTableCell::colSpanOrRowSpanChanged() { | 149 void LayoutTableCell::colSpanOrRowSpanChanged() { |
150 ASSERT(node()); | 150 DCHECK(node()); |
151 ASSERT(isHTMLTableCellElement(*node())); | 151 DCHECK(isHTMLTableCellElement(*node())); |
152 | 152 |
153 updateColAndRowSpanFlags(); | 153 updateColAndRowSpanFlags(); |
154 | 154 |
155 setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation( | 155 setNeedsLayoutAndPrefWidthsRecalcAndFullPaintInvalidation( |
156 LayoutInvalidationReason::AttributeChanged); | 156 LayoutInvalidationReason::AttributeChanged); |
157 if (parent() && section()) | 157 if (parent() && section()) |
158 section()->setNeedsCellRecalc(); | 158 section()->setNeedsCellRecalc(); |
159 } | 159 } |
160 | 160 |
161 Length LayoutTableCell::logicalWidthFromColumns( | 161 Length LayoutTableCell::logicalWidthFromColumns( |
162 LayoutTableCol* firstColForThisCell, | 162 LayoutTableCol* firstColForThisCell, |
163 Length widthFromStyle) const { | 163 Length widthFromStyle) const { |
164 ASSERT(firstColForThisCell && | 164 DCHECK(firstColForThisCell); |
165 firstColForThisCell == | 165 DCHECK_EQ(firstColForThisCell, |
166 table() | 166 table() |
167 ->colElementAtAbsoluteColumn(absoluteColumnIndex()) | 167 ->colElementAtAbsoluteColumn(absoluteColumnIndex()) |
168 .innermostColOrColGroup()); | 168 .innermostColOrColGroup()); |
169 LayoutTableCol* tableCol = firstColForThisCell; | 169 LayoutTableCol* tableCol = firstColForThisCell; |
170 | 170 |
171 unsigned colSpanCount = colSpan(); | 171 unsigned colSpanCount = colSpan(); |
172 int colWidthSum = 0; | 172 int colWidthSum = 0; |
173 for (unsigned i = 1; i <= colSpanCount; i++) { | 173 for (unsigned i = 1; i <= colSpanCount; i++) { |
174 Length colWidth = tableCol->style()->logicalWidth(); | 174 Length colWidth = tableCol->style()->logicalWidth(); |
175 | 175 |
176 // Percentage value should be returned only for colSpan == 1. | 176 // Percentage value should be returned only for colSpan == 1. |
177 // Otherwise we return original width for the cell. | 177 // Otherwise we return original width for the cell. |
178 if (!colWidth.isFixed()) { | 178 if (!colWidth.isFixed()) { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 if (tableLayoutLogicalWidth == logicalWidth()) | 293 if (tableLayoutLogicalWidth == logicalWidth()) |
294 return; | 294 return; |
295 | 295 |
296 layouter.setNeedsLayout(this, LayoutInvalidationReason::SizeChanged); | 296 layouter.setNeedsLayout(this, LayoutInvalidationReason::SizeChanged); |
297 | 297 |
298 setLogicalWidth(LayoutUnit(tableLayoutLogicalWidth)); | 298 setLogicalWidth(LayoutUnit(tableLayoutLogicalWidth)); |
299 setCellWidthChanged(true); | 299 setCellWidthChanged(true); |
300 } | 300 } |
301 | 301 |
302 void LayoutTableCell::layout() { | 302 void LayoutTableCell::layout() { |
303 ASSERT(needsLayout()); | 303 DCHECK(needsLayout()); |
304 LayoutAnalyzer::Scope analyzer(*this); | 304 LayoutAnalyzer::Scope analyzer(*this); |
305 | 305 |
306 int oldCellBaseline = cellBaselinePosition(); | 306 int oldCellBaseline = cellBaselinePosition(); |
307 layoutBlock(cellWidthChanged()); | 307 layoutBlock(cellWidthChanged()); |
308 | 308 |
309 // If we have replaced content, the intrinsic height of our content may have | 309 // If we have replaced content, the intrinsic height of our content may have |
310 // changed since the last time we laid out. If that's the case the intrinsic | 310 // changed since the last time we laid out. If that's the case the intrinsic |
311 // padding we used for layout (the padding required to push the contents of | 311 // padding we used for layout (the padding required to push the contents of |
312 // the cell down to the row's baseline) is included in our new height and | 312 // the cell down to the row's baseline) is included in our new height and |
313 // baseline and makes both of them wrong. So if our content's intrinsic height | 313 // baseline and makes both of them wrong. So if our content's intrinsic height |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 | 389 |
390 void LayoutTableCell::setOverrideLogicalContentHeightFromRowHeight( | 390 void LayoutTableCell::setOverrideLogicalContentHeightFromRowHeight( |
391 LayoutUnit rowHeight) { | 391 LayoutUnit rowHeight) { |
392 clearIntrinsicPadding(); | 392 clearIntrinsicPadding(); |
393 setOverrideLogicalContentHeight( | 393 setOverrideLogicalContentHeight( |
394 (rowHeight - collapsedBorderAndCSSPaddingLogicalHeight()) | 394 (rowHeight - collapsedBorderAndCSSPaddingLogicalHeight()) |
395 .clampNegativeToZero()); | 395 .clampNegativeToZero()); |
396 } | 396 } |
397 | 397 |
398 LayoutSize LayoutTableCell::offsetFromContainer(const LayoutObject* o) const { | 398 LayoutSize LayoutTableCell::offsetFromContainer(const LayoutObject* o) const { |
399 ASSERT(o == container()); | 399 DCHECK_EQ(o, container()); |
400 | 400 |
401 LayoutSize offset = LayoutBlockFlow::offsetFromContainer(o); | 401 LayoutSize offset = LayoutBlockFlow::offsetFromContainer(o); |
402 if (parent()) | 402 if (parent()) |
403 offset -= parentBox()->locationOffset(); | 403 offset -= parentBox()->locationOffset(); |
404 | 404 |
405 return offset; | 405 return offset; |
406 } | 406 } |
407 | 407 |
408 LayoutRect LayoutTableCell::localVisualRect() const { | 408 LayoutRect LayoutTableCell::localVisualRect() const { |
409 // If the table grid is dirty, we cannot get reliable information about | 409 // If the table grid is dirty, we cannot get reliable information about |
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1498 } | 1498 } |
1499 | 1499 |
1500 bool LayoutTableCell::hasLineIfEmpty() const { | 1500 bool LayoutTableCell::hasLineIfEmpty() const { |
1501 if (node() && hasEditableStyle(*node())) | 1501 if (node() && hasEditableStyle(*node())) |
1502 return true; | 1502 return true; |
1503 | 1503 |
1504 return LayoutBlock::hasLineIfEmpty(); | 1504 return LayoutBlock::hasLineIfEmpty(); |
1505 } | 1505 } |
1506 | 1506 |
1507 } // namespace blink | 1507 } // namespace blink |
OLD | NEW |