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, 2009, 2013 Apple Inc. All rights
reserved. | 7 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009, 2013 Apple Inc. |
| 8 * All rights reserved. |
8 * | 9 * |
9 * This library is free software; you can redistribute it and/or | 10 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 11 * modify it under the terms of the GNU Library General Public |
11 * License as published by the Free Software Foundation; either | 12 * License as published by the Free Software Foundation; either |
12 * version 2 of the License, or (at your option) any later version. | 13 * version 2 of the License, or (at your option) any later version. |
13 * | 14 * |
14 * This library is distributed in the hope that it will be useful, | 15 * This library is distributed in the hope that it will be useful, |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
17 * Library General Public License for more details. | 18 * Library General Public License for more details. |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 return logicalWidthFromColumns(firstColumn, styleWidth); | 146 return logicalWidthFromColumns(firstColumn, styleWidth); |
146 return styleWidth; | 147 return styleWidth; |
147 } | 148 } |
148 | 149 |
149 int logicalHeightFromStyle() const { | 150 int logicalHeightFromStyle() const { |
150 Length height = style()->logicalHeight(); | 151 Length height = style()->logicalHeight(); |
151 int styleLogicalHeight = height.isIntrinsicOrAuto() | 152 int styleLogicalHeight = height.isIntrinsicOrAuto() |
152 ? 0 | 153 ? 0 |
153 : valueForLength(height, LayoutUnit()).toInt(); | 154 : valueForLength(height, LayoutUnit()).toInt(); |
154 | 155 |
155 // In strict mode, box-sizing: content-box do the right thing and actually a
dd in the border and padding. | 156 // In strict mode, box-sizing: content-box do the right thing and actually |
| 157 // add in the border and padding. |
156 // Call computedCSSPadding* directly to avoid including implicitPadding. | 158 // Call computedCSSPadding* directly to avoid including implicitPadding. |
157 if (!document().inQuirksMode() && | 159 if (!document().inQuirksMode() && |
158 style()->boxSizing() != BoxSizingBorderBox) | 160 style()->boxSizing() != BoxSizingBorderBox) |
159 styleLogicalHeight += | 161 styleLogicalHeight += |
160 (computedCSSPaddingBefore() + computedCSSPaddingAfter()).floor() + | 162 (computedCSSPaddingBefore() + computedCSSPaddingAfter()).floor() + |
161 borderBefore() + borderAfter(); | 163 borderBefore() + borderAfter(); |
162 return styleLogicalHeight; | 164 return styleLogicalHeight; |
163 } | 165 } |
164 | 166 |
165 int logicalHeightForRowSizing() const { | 167 int logicalHeightForRowSizing() const { |
166 // FIXME: This function does too much work, and is very hot during table lay
out! | 168 // FIXME: This function does too much work, and is very hot during table |
| 169 // layout! |
167 int adjustedLogicalHeight = | 170 int adjustedLogicalHeight = |
168 pixelSnappedLogicalHeight() - | 171 pixelSnappedLogicalHeight() - |
169 (intrinsicPaddingBefore() + intrinsicPaddingAfter()); | 172 (intrinsicPaddingBefore() + intrinsicPaddingAfter()); |
170 int styleLogicalHeight = logicalHeightFromStyle(); | 173 int styleLogicalHeight = logicalHeightFromStyle(); |
171 return max(styleLogicalHeight, adjustedLogicalHeight); | 174 return max(styleLogicalHeight, adjustedLogicalHeight); |
172 } | 175 } |
173 | 176 |
174 void setCellLogicalWidth(int constrainedLogicalWidth, SubtreeLayoutScope&); | 177 void setCellLogicalWidth(int constrainedLogicalWidth, SubtreeLayoutScope&); |
175 | 178 |
176 int borderLeft() const override; | 179 int borderLeft() const override; |
(...skipping 24 matching lines...) Expand all Loading... |
201 void clearIntrinsicPadding() { setIntrinsicPadding(0, 0); } | 204 void clearIntrinsicPadding() { setIntrinsicPadding(0, 0); } |
202 | 205 |
203 int intrinsicPaddingBefore() const { return m_intrinsicPaddingBefore; } | 206 int intrinsicPaddingBefore() const { return m_intrinsicPaddingBefore; } |
204 int intrinsicPaddingAfter() const { return m_intrinsicPaddingAfter; } | 207 int intrinsicPaddingAfter() const { return m_intrinsicPaddingAfter; } |
205 | 208 |
206 LayoutUnit paddingTop() const override; | 209 LayoutUnit paddingTop() const override; |
207 LayoutUnit paddingBottom() const override; | 210 LayoutUnit paddingBottom() const override; |
208 LayoutUnit paddingLeft() const override; | 211 LayoutUnit paddingLeft() const override; |
209 LayoutUnit paddingRight() const override; | 212 LayoutUnit paddingRight() const override; |
210 | 213 |
211 // FIXME: For now we just assume the cell has the same block flow direction as
the table. It's likely we'll | 214 // FIXME: For now we just assume the cell has the same block flow direction as |
212 // create an extra anonymous LayoutBlock to handle mixing directionality anywa
y, in which case we can lock | 215 // the table. It's likely we'll create an extra anonymous LayoutBlock to |
213 // the block flow directionality of the cells to the table's directionality. | 216 // handle mixing directionality anyway, in which case we can lock the block |
| 217 // flow directionality of the cells to the table's directionality. |
214 LayoutUnit paddingBefore() const override; | 218 LayoutUnit paddingBefore() const override; |
215 LayoutUnit paddingAfter() const override; | 219 LayoutUnit paddingAfter() const override; |
216 | 220 |
217 void setOverrideLogicalContentHeightFromRowHeight(LayoutUnit); | 221 void setOverrideLogicalContentHeightFromRowHeight(LayoutUnit); |
218 | 222 |
219 void scrollbarsChanged(bool horizontalScrollbarChanged, | 223 void scrollbarsChanged(bool horizontalScrollbarChanged, |
220 bool verticalScrollbarChanged) override; | 224 bool verticalScrollbarChanged) override; |
221 | 225 |
222 bool cellWidthChanged() const { return m_cellWidthChanged; } | 226 bool cellWidthChanged() const { return m_cellWidthChanged; } |
223 void setCellWidthChanged(bool b = true) { m_cellWidthChanged = b; } | 227 void setCellWidthChanged(bool b = true) { m_cellWidthChanged = b; } |
224 | 228 |
225 static LayoutTableCell* createAnonymous(Document*); | 229 static LayoutTableCell* createAnonymous(Document*); |
226 static LayoutTableCell* createAnonymousWithParent(const LayoutObject*); | 230 static LayoutTableCell* createAnonymousWithParent(const LayoutObject*); |
227 LayoutBox* createAnonymousBoxWithSameTypeAs( | 231 LayoutBox* createAnonymousBoxWithSameTypeAs( |
228 const LayoutObject* parent) const override { | 232 const LayoutObject* parent) const override { |
229 return createAnonymousWithParent(parent); | 233 return createAnonymousWithParent(parent); |
230 } | 234 } |
231 | 235 |
232 // This function is used to unify which table part's style we use for computin
g direction and | 236 // This function is used to unify which table part's style we use for |
233 // writing mode. Writing modes are not allowed on row group and row but direct
ion is. | 237 // computing direction and writing mode. Writing modes are not allowed on row |
234 // This means we can safely use the same style in all cases to simplify our co
de. | 238 // group and row but direction is. This means we can safely use the same style |
235 // FIXME: Eventually this function should replaced by style() once we support
direction | 239 // in all cases to simplify our code. |
236 // on all table parts and writing-mode on cells. | 240 // FIXME: Eventually this function should replaced by style() once we support |
| 241 // direction on all table parts and writing-mode on cells. |
237 const ComputedStyle& styleForCellFlow() const { return row()->styleRef(); } | 242 const ComputedStyle& styleForCellFlow() const { return row()->styleRef(); } |
238 | 243 |
239 const BorderValue& borderAdjoiningTableStart() const { | 244 const BorderValue& borderAdjoiningTableStart() const { |
240 ASSERT(isFirstOrLastCellInRow()); | 245 ASSERT(isFirstOrLastCellInRow()); |
241 if (section()->hasSameDirectionAs(table())) | 246 if (section()->hasSameDirectionAs(table())) |
242 return style()->borderStart(); | 247 return style()->borderStart(); |
243 | 248 |
244 return style()->borderEnd(); | 249 return style()->borderEnd(); |
245 } | 250 } |
246 | 251 |
247 const BorderValue& borderAdjoiningTableEnd() const { | 252 const BorderValue& borderAdjoiningTableEnd() const { |
248 ASSERT(isFirstOrLastCellInRow()); | 253 ASSERT(isFirstOrLastCellInRow()); |
249 if (section()->hasSameDirectionAs(table())) | 254 if (section()->hasSameDirectionAs(table())) |
250 return style()->borderEnd(); | 255 return style()->borderEnd(); |
251 | 256 |
252 return style()->borderStart(); | 257 return style()->borderStart(); |
253 } | 258 } |
254 | 259 |
255 const BorderValue& borderAdjoiningCellBefore(const LayoutTableCell* cell) { | 260 const BorderValue& borderAdjoiningCellBefore(const LayoutTableCell* cell) { |
256 DCHECK_EQ(table()->cellAfter(cell), this); | 261 DCHECK_EQ(table()->cellAfter(cell), this); |
257 // FIXME: https://webkit.org/b/79272 - Add support for mixed directionality
at the cell level. | 262 // FIXME: https://webkit.org/b/79272 - Add support for mixed directionality |
| 263 // at the cell level. |
258 return style()->borderStart(); | 264 return style()->borderStart(); |
259 } | 265 } |
260 | 266 |
261 const BorderValue& borderAdjoiningCellAfter(const LayoutTableCell* cell) { | 267 const BorderValue& borderAdjoiningCellAfter(const LayoutTableCell* cell) { |
262 DCHECK_EQ(table()->cellBefore(cell), this); | 268 DCHECK_EQ(table()->cellBefore(cell), this); |
263 // FIXME: https://webkit.org/b/79272 - Add support for mixed directionality
at the cell level. | 269 // FIXME: https://webkit.org/b/79272 - Add support for mixed directionality |
| 270 // at the cell level. |
264 return style()->borderEnd(); | 271 return style()->borderEnd(); |
265 } | 272 } |
266 | 273 |
267 #if ENABLE(ASSERT) | 274 #if ENABLE(ASSERT) |
268 bool isFirstOrLastCellInRow() const { | 275 bool isFirstOrLastCellInRow() const { |
269 return !table()->cellAfter(this) || !table()->cellBefore(this); | 276 return !table()->cellAfter(this) || !table()->cellBefore(this); |
270 } | 277 } |
271 #endif | 278 #endif |
272 | 279 |
273 const char* name() const override { return "LayoutTableCell"; } | 280 const char* name() const override { return "LayoutTableCell"; } |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 Length widthFromStyle) const; | 378 Length widthFromStyle) const; |
372 | 379 |
373 void updateColAndRowSpanFlags(); | 380 void updateColAndRowSpanFlags(); |
374 | 381 |
375 unsigned parseRowSpanFromDOM() const; | 382 unsigned parseRowSpanFromDOM() const; |
376 unsigned parseColSpanFromDOM() const; | 383 unsigned parseColSpanFromDOM() const; |
377 | 384 |
378 void nextSibling() const = delete; | 385 void nextSibling() const = delete; |
379 void previousSibling() const = delete; | 386 void previousSibling() const = delete; |
380 | 387 |
381 // Note MSVC will only pack members if they have identical types, hence we use
unsigned instead of bool here. | 388 // Note MSVC will only pack members if they have identical types, hence we use |
| 389 // unsigned instead of bool here. |
382 unsigned m_absoluteColumnIndex : 29; | 390 unsigned m_absoluteColumnIndex : 29; |
383 unsigned m_cellWidthChanged : 1; | 391 unsigned m_cellWidthChanged : 1; |
384 unsigned m_hasColSpan : 1; | 392 unsigned m_hasColSpan : 1; |
385 unsigned m_hasRowSpan : 1; | 393 unsigned m_hasRowSpan : 1; |
386 | 394 |
387 // The intrinsic padding. | 395 // The intrinsic padding. |
388 // See class comment for what they are. | 396 // See class comment for what they are. |
389 // | 397 // |
390 // Note: Those fields are using non-subpixel units (int) | 398 // Note: Those fields are using non-subpixel units (int) |
391 // because we don't do fractional arithmetic on tables. | 399 // because we don't do fractional arithmetic on tables. |
(...skipping 17 matching lines...) Expand all Loading... |
409 return toLayoutTableCell(firstChild()); | 417 return toLayoutTableCell(firstChild()); |
410 } | 418 } |
411 | 419 |
412 inline LayoutTableCell* LayoutTableRow::lastCell() const { | 420 inline LayoutTableCell* LayoutTableRow::lastCell() const { |
413 return toLayoutTableCell(lastChild()); | 421 return toLayoutTableCell(lastChild()); |
414 } | 422 } |
415 | 423 |
416 } // namespace blink | 424 } // namespace blink |
417 | 425 |
418 #endif // LayoutTableCell_h | 426 #endif // LayoutTableCell_h |
OLD | NEW |