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, 2009, 2013 Apple Inc. All rights reserv
ed. | 7 * Copyright (C) 2003, 2004, 2005, 2006, 2009, 2013 Apple Inc. All rights |
| 8 * 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. |
18 * | 19 * |
19 * You should have received a copy of the GNU Library General Public License | 20 * You should have received a copy of the GNU Library General Public License |
20 * along with this library; see the file COPYING.LIB. If not, write to | 21 * along with this library; see the file COPYING.LIB. If not, write to |
21 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 22 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
22 * Boston, MA 02110-1301, USA. | 23 * Boston, MA 02110-1301, USA. |
23 */ | 24 */ |
24 | 25 |
25 #ifndef LayoutTableSection_h | 26 #ifndef LayoutTableSection_h |
26 #define LayoutTableSection_h | 27 #define LayoutTableSection_h |
27 | 28 |
28 #include "core/CoreExport.h" | 29 #include "core/CoreExport.h" |
29 #include "core/layout/LayoutTable.h" | 30 #include "core/layout/LayoutTable.h" |
30 #include "core/layout/LayoutTableBoxComponent.h" | 31 #include "core/layout/LayoutTableBoxComponent.h" |
31 #include "wtf/Vector.h" | 32 #include "wtf/Vector.h" |
32 | 33 |
33 namespace blink { | 34 namespace blink { |
34 | 35 |
35 // This variable is used to balance the memory consumption vs the paint invalida
tion time on big tables. | 36 // This variable is used to balance the memory consumption vs the paint |
| 37 // invalidation time on big tables. |
36 const float gMaxAllowedOverflowingCellRatioForFastPaintPath = 0.1f; | 38 const float gMaxAllowedOverflowingCellRatioForFastPaintPath = 0.1f; |
37 | 39 |
38 // Helper class for paintObject. | 40 // Helper class for paintObject. |
39 class CellSpan { | 41 class CellSpan { |
40 STACK_ALLOCATED(); | 42 STACK_ALLOCATED(); |
41 | 43 |
42 public: | 44 public: |
43 CellSpan(unsigned start, unsigned end) : m_start(start), m_end(end) {} | 45 CellSpan(unsigned start, unsigned end) : m_start(start), m_end(end) {} |
44 | 46 |
45 unsigned start() const { return m_start; } | 47 unsigned start() const { return m_start; } |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 LayoutTableCell* primaryCellAt(unsigned row, unsigned effectiveColumn) { | 220 LayoutTableCell* primaryCellAt(unsigned row, unsigned effectiveColumn) { |
219 CellStruct& c = m_grid[row].row[effectiveColumn]; | 221 CellStruct& c = m_grid[row].row[effectiveColumn]; |
220 return c.primaryCell(); | 222 return c.primaryCell(); |
221 } | 223 } |
222 const LayoutTableCell* primaryCellAt(unsigned row, | 224 const LayoutTableCell* primaryCellAt(unsigned row, |
223 unsigned effectiveColumn) const { | 225 unsigned effectiveColumn) const { |
224 return const_cast<LayoutTableSection*>(this)->primaryCellAt( | 226 return const_cast<LayoutTableSection*>(this)->primaryCellAt( |
225 row, effectiveColumn); | 227 row, effectiveColumn); |
226 } | 228 } |
227 | 229 |
228 // Returns null for cells with a rowspan that exceed the last row. Possibly ot
hers. | 230 // Returns null for cells with a rowspan that exceed the last row. Possibly |
| 231 // others. |
229 LayoutTableRow* rowLayoutObjectAt(unsigned row) { | 232 LayoutTableRow* rowLayoutObjectAt(unsigned row) { |
230 return m_grid[row].rowLayoutObject; | 233 return m_grid[row].rowLayoutObject; |
231 } | 234 } |
232 const LayoutTableRow* rowLayoutObjectAt(unsigned row) const { | 235 const LayoutTableRow* rowLayoutObjectAt(unsigned row) const { |
233 return m_grid[row].rowLayoutObject; | 236 return m_grid[row].rowLayoutObject; |
234 } | 237 } |
235 | 238 |
236 void appendEffectiveColumn(unsigned pos); | 239 void appendEffectiveColumn(unsigned pos); |
237 void splitEffectiveColumn(unsigned pos, unsigned first); | 240 void splitEffectiveColumn(unsigned pos, unsigned first); |
238 | 241 |
(...skipping 29 matching lines...) Expand all Loading... |
268 recalcCells(); | 271 recalcCells(); |
269 } | 272 } |
270 | 273 |
271 bool needsCellRecalc() const { return m_needsCellRecalc; } | 274 bool needsCellRecalc() const { return m_needsCellRecalc; } |
272 void setNeedsCellRecalc(); | 275 void setNeedsCellRecalc(); |
273 | 276 |
274 int rowBaseline(unsigned row) { return m_grid[row].baseline; } | 277 int rowBaseline(unsigned row) { return m_grid[row].baseline; } |
275 | 278 |
276 void rowLogicalHeightChanged(LayoutTableRow*); | 279 void rowLogicalHeightChanged(LayoutTableRow*); |
277 | 280 |
278 // distributeExtraLogicalHeightToRows methods return the *consumed* extra logi
cal height. | 281 // distributeExtraLogicalHeightToRows methods return the *consumed* extra |
279 // FIXME: We may want to introduce a structure holding the in-flux layout info
rmation. | 282 // logical height. |
| 283 // FIXME: We may want to introduce a structure holding the in-flux layout |
| 284 // information. |
280 int distributeExtraLogicalHeightToRows(int extraLogicalHeight); | 285 int distributeExtraLogicalHeightToRows(int extraLogicalHeight); |
281 | 286 |
282 static LayoutTableSection* createAnonymousWithParent(const LayoutObject*); | 287 static LayoutTableSection* createAnonymousWithParent(const LayoutObject*); |
283 LayoutBox* createAnonymousBoxWithSameTypeAs( | 288 LayoutBox* createAnonymousBoxWithSameTypeAs( |
284 const LayoutObject* parent) const override { | 289 const LayoutObject* parent) const override { |
285 return createAnonymousWithParent(parent); | 290 return createAnonymousWithParent(parent); |
286 } | 291 } |
287 | 292 |
288 void paint(const PaintInfo&, const LayoutPoint&) const override; | 293 void paint(const PaintInfo&, const LayoutPoint&) const override; |
289 | 294 |
290 // Flip the rect so it aligns with the coordinates used by the rowPos and colu
mnPos vectors. | 295 // Flip the rect so it aligns with the coordinates used by the rowPos and |
| 296 // columnPos vectors. |
291 LayoutRect logicalRectForWritingModeAndDirection(const LayoutRect&) const; | 297 LayoutRect logicalRectForWritingModeAndDirection(const LayoutRect&) const; |
292 | 298 |
293 CellSpan dirtiedRows(const LayoutRect& paintInvalidationRect) const; | 299 CellSpan dirtiedRows(const LayoutRect& paintInvalidationRect) const; |
294 CellSpan dirtiedEffectiveColumns( | 300 CellSpan dirtiedEffectiveColumns( |
295 const LayoutRect& paintInvalidationRect) const; | 301 const LayoutRect& paintInvalidationRect) const; |
296 const HashSet<LayoutTableCell*>& overflowingCells() const { | 302 const HashSet<LayoutTableCell*>& overflowingCells() const { |
297 return m_overflowingCells; | 303 return m_overflowingCells; |
298 } | 304 } |
299 bool hasMultipleCellLevels() const { return m_hasMultipleCellLevels; } | 305 bool hasMultipleCellLevels() const { return m_hasMultipleCellLevels; } |
300 | 306 |
301 const char* name() const override { return "LayoutTableSection"; } | 307 const char* name() const override { return "LayoutTableSection"; } |
302 | 308 |
303 // Whether a section has opaque background depends on many factors, e.g. borde
r spacing, | 309 // Whether a section has opaque background depends on many factors, e.g. |
304 // border collapsing, missing cells, etc. | 310 // border spacing, border collapsing, missing cells, etc. For simplicity, |
305 // For simplicity, just conservatively assume all table sections are not opaqu
e. | 311 // just conservatively assume all table sections are not opaque. |
306 bool foregroundIsKnownToBeOpaqueInRect(const LayoutRect&, | 312 bool foregroundIsKnownToBeOpaqueInRect(const LayoutRect&, |
307 unsigned) const override { | 313 unsigned) const override { |
308 return false; | 314 return false; |
309 } | 315 } |
310 bool backgroundIsKnownToBeOpaqueInRect(const LayoutRect&) const override { | 316 bool backgroundIsKnownToBeOpaqueInRect(const LayoutRect&) const override { |
311 return false; | 317 return false; |
312 } | 318 } |
313 | 319 |
314 int paginationStrutForRow(LayoutTableRow*, LayoutUnit logicalOffset) const; | 320 int paginationStrutForRow(LayoutTableRow*, LayoutUnit logicalOffset) const; |
315 | 321 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 return m_overflowingCells.size() || m_forceSlowPaintPathWithOverflowingCell; | 400 return m_overflowingCells.size() || m_forceSlowPaintPathWithOverflowingCell; |
395 } | 401 } |
396 | 402 |
397 void computeOverflowFromCells(unsigned totalRows, unsigned nEffCols); | 403 void computeOverflowFromCells(unsigned totalRows, unsigned nEffCols); |
398 | 404 |
399 CellSpan fullTableRowSpan() const { return CellSpan(0, m_grid.size()); } | 405 CellSpan fullTableRowSpan() const { return CellSpan(0, m_grid.size()); } |
400 CellSpan fullTableEffectiveColumnSpan() const { | 406 CellSpan fullTableEffectiveColumnSpan() const { |
401 return CellSpan(0, table()->numEffectiveColumns()); | 407 return CellSpan(0, table()->numEffectiveColumns()); |
402 } | 408 } |
403 | 409 |
404 // These two functions take a rectangle as input that has been flipped by logi
calRectForWritingModeAndDirection. | 410 // These two functions take a rectangle as input that has been flipped by |
405 // The returned span of rows or columns is end-exclusive, and empty if start==
end. | 411 // logicalRectForWritingModeAndDirection. |
| 412 // The returned span of rows or columns is end-exclusive, and empty if |
| 413 // start==end. |
406 CellSpan spannedRows(const LayoutRect& flippedRect) const; | 414 CellSpan spannedRows(const LayoutRect& flippedRect) const; |
407 CellSpan spannedEffectiveColumns(const LayoutRect& flippedRect) const; | 415 CellSpan spannedEffectiveColumns(const LayoutRect& flippedRect) const; |
408 | 416 |
409 void setLogicalPositionForCell(LayoutTableCell*, | 417 void setLogicalPositionForCell(LayoutTableCell*, |
410 unsigned effectiveColumn) const; | 418 unsigned effectiveColumn) const; |
411 | 419 |
412 void relayoutCellIfFlexed(LayoutTableCell&, int rowIndex, int rowHeight); | 420 void relayoutCellIfFlexed(LayoutTableCell&, int rowIndex, int rowHeight); |
413 | 421 |
414 // The representation of the rows and their cells (CellStruct). | 422 // The representation of the rows and their cells (CellStruct). |
415 Vector<RowStruct> m_grid; | 423 Vector<RowStruct> m_grid; |
(...skipping 22 matching lines...) Expand all Loading... |
438 unsigned m_cRow; | 446 unsigned m_cRow; |
439 | 447 |
440 int m_outerBorderStart; | 448 int m_outerBorderStart; |
441 int m_outerBorderEnd; | 449 int m_outerBorderEnd; |
442 int m_outerBorderBefore; | 450 int m_outerBorderBefore; |
443 int m_outerBorderAfter; | 451 int m_outerBorderAfter; |
444 | 452 |
445 bool m_needsCellRecalc; | 453 bool m_needsCellRecalc; |
446 | 454 |
447 // This HashSet holds the overflowing cells for faster painting. | 455 // This HashSet holds the overflowing cells for faster painting. |
448 // If we have more than gMaxAllowedOverflowingCellRatio * total cells, it will
be empty | 456 // If we have more than gMaxAllowedOverflowingCellRatio * total cells, it will |
449 // and m_forceSlowPaintPathWithOverflowingCell will be set to save memory. | 457 // be empty and m_forceSlowPaintPathWithOverflowingCell will be set to save |
| 458 // memory. |
450 HashSet<LayoutTableCell*> m_overflowingCells; | 459 HashSet<LayoutTableCell*> m_overflowingCells; |
451 bool m_forceSlowPaintPathWithOverflowingCell; | 460 bool m_forceSlowPaintPathWithOverflowingCell; |
452 | 461 |
453 // This boolean tracks if we have cells overlapping due to rowspan / colspan | 462 // This boolean tracks if we have cells overlapping due to rowspan / colspan |
454 // (see class comment above about when it could appear). | 463 // (see class comment above about when it could appear). |
455 // | 464 // |
456 // The use is to disable a painting optimization where we just paint the | 465 // The use is to disable a painting optimization where we just paint the |
457 // invalidated cells. | 466 // invalidated cells. |
458 bool m_hasMultipleCellLevels; | 467 bool m_hasMultipleCellLevels; |
459 | 468 |
460 LayoutUnit m_offsetForRepeatingHeader; | 469 LayoutUnit m_offsetForRepeatingHeader; |
461 }; | 470 }; |
462 | 471 |
463 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutTableSection, isTableSection()); | 472 DEFINE_LAYOUT_OBJECT_TYPE_CASTS(LayoutTableSection, isTableSection()); |
464 | 473 |
465 } // namespace blink | 474 } // namespace blink |
466 | 475 |
467 #endif // LayoutTableSection_h | 476 #endif // LayoutTableSection_h |
OLD | NEW |