Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: third_party/WebKit/Source/core/paint/TableSectionPainter.cpp

Issue 2021703002: Display table header groups at the top of each page (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/paint/TableSectionPainter.h" 5 #include "core/paint/TableSectionPainter.h"
6 6
7 #include "core/layout/LayoutTableCell.h" 7 #include "core/layout/LayoutTableCell.h"
8 #include "core/layout/LayoutTableCol.h" 8 #include "core/layout/LayoutTableCol.h"
9 #include "core/layout/LayoutTableRow.h" 9 #include "core/layout/LayoutTableRow.h"
10 #include "core/layout/LayoutView.h"
10 #include "core/paint/BoxClipper.h" 11 #include "core/paint/BoxClipper.h"
11 #include "core/paint/ObjectPainter.h" 12 #include "core/paint/ObjectPainter.h"
12 #include "core/paint/PaintInfo.h" 13 #include "core/paint/PaintInfo.h"
14 #include "core/paint/PaintLayer.h"
13 #include "core/paint/TableCellPainter.h" 15 #include "core/paint/TableCellPainter.h"
14 #include "core/paint/TableRowPainter.h" 16 #include "core/paint/TableRowPainter.h"
15 #include <algorithm> 17 #include <algorithm>
16 18
17 namespace blink { 19 namespace blink {
18 20
19 inline const LayoutTableCell* TableSectionPainter::primaryCellToPaint(unsigned r ow, unsigned column, const CellSpan& dirtiedRows, const CellSpan& dirtiedColumns ) const 21 inline const LayoutTableCell* TableSectionPainter::primaryCellToPaint(unsigned r ow, unsigned column, const CellSpan& dirtiedRows, const CellSpan& dirtiedColumns ) const
20 { 22 {
21 DCHECK(row >= dirtiedRows.start() && row < dirtiedRows.end()); 23 DCHECK(row >= dirtiedRows.start() && row < dirtiedRows.end());
22 DCHECK(column >= dirtiedColumns.start() && column < dirtiedColumns.end()); 24 DCHECK(column >= dirtiedColumns.start() && column < dirtiedColumns.end());
23 25
24 const LayoutTableCell* cell = m_layoutTableSection.primaryCellAt(row, column ); 26 const LayoutTableCell* cell = m_layoutTableSection.primaryCellAt(row, column );
25 if (!cell) 27 if (!cell)
26 return nullptr; 28 return nullptr;
27 // We have painted (row, column) when painting (row - 1, column). 29 // We have painted (row, column) when painting (row - 1, column).
28 if (row > dirtiedRows.start() && m_layoutTableSection.primaryCellAt(row - 1, column) == cell) 30 if (row > dirtiedRows.start() && m_layoutTableSection.primaryCellAt(row - 1, column) == cell)
29 return nullptr; 31 return nullptr;
30 // We have painted (row, column) when painting (row, column -1). 32 // We have painted (row, column) when painting (row, column -1).
31 if (column > dirtiedColumns.start() && m_layoutTableSection.primaryCellAt(ro w, column - 1) == cell) 33 if (column > dirtiedColumns.start() && m_layoutTableSection.primaryCellAt(ro w, column - 1) == cell)
32 return nullptr; 34 return nullptr;
33 return cell; 35 return cell;
34 } 36 }
35 37
38 void TableSectionPainter::paintRepeatingHeaderGroup(const PaintInfo& paintInfo, const LayoutPoint& paintOffset, const CollapsedBorderValue& currentBorderValue, ItemToPaint itemToPaint)
39 {
40 if (m_layoutTableSection.getPaginationBreakability() == LayoutBox::AllowAnyB reaks)
41 return;
42 // TODO(rhogan): Should we paint a header repeatedly if it's self-painting?
43 if (m_layoutTableSection.hasSelfPaintingLayer())
44 return;
45 LayoutTable* table = m_layoutTableSection.table();
46 LayoutUnit pageHeight = table->pageLogicalHeightForOffset(LayoutUnit());
47 if (!pageHeight)
48 return;
49
50 LayoutPoint paginationOffset = paintOffset;
51 // Move paginationOffset to the top of the second page.
52 paginationOffset.move(0, pageHeight - table->pageLogicalOffset());
53 // Now move paginationOffset to the top of the page the cull rect starts on.
54 if (paintInfo.cullRect().m_rect.y() > paginationOffset.y())
55 paginationOffset.move(0, pageHeight * static_cast<int>((paintInfo.cullRe ct().m_rect.y() - paginationOffset.y()) / pageHeight));
56 LayoutUnit bottomBound = std::min(LayoutUnit(paintInfo.cullRect().m_rect.max Y()), paintOffset.y() + table->logicalHeight());
57 while (paginationOffset.y() < bottomBound) {
58 if (itemToPaint == PaintCollapsedBorders)
59 paintCollapsedSectionBorders(paintInfo.forDescendants(), paginationO ffset, currentBorderValue);
Xianzhu 2016/06/03 18:45:41 Remove .forDescendants() because the method is sti
60 else
61 paintSection(paintInfo.forDescendants(), paginationOffset);
Xianzhu 2016/06/03 18:45:41 Ditto.
62 paginationOffset.move(0, pageHeight);
63 }
64 }
65
36 void TableSectionPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& p aintOffset) 66 void TableSectionPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& p aintOffset)
37 { 67 {
68 paintSection(paintInfo, paintOffset);
69 LayoutTable* table = m_layoutTableSection.table();
70 if (table->header() == m_layoutTableSection)
71 paintRepeatingHeaderGroup(paintInfo, paintOffset, CollapsedBorderValue() , PaintChild);
72 }
73
74 void TableSectionPainter::paintSection(const PaintInfo& paintInfo, const LayoutP oint& paintOffset)
75 {
38 DCHECK(!m_layoutTableSection.needsLayout()); 76 DCHECK(!m_layoutTableSection.needsLayout());
39 // avoid crashing on bugs that cause us to paint with dirty layout 77 // avoid crashing on bugs that cause us to paint with dirty layout
40 if (m_layoutTableSection.needsLayout()) 78 if (m_layoutTableSection.needsLayout())
41 return; 79 return;
42 80
43 unsigned totalRows = m_layoutTableSection.numRows(); 81 unsigned totalRows = m_layoutTableSection.numRows();
44 unsigned totalCols = m_layoutTableSection.table()->numEffectiveColumns(); 82 unsigned totalCols = m_layoutTableSection.table()->numEffectiveColumns();
45 83
46 if (!totalRows || !totalCols) 84 if (!totalRows || !totalCols)
47 return; 85 return;
(...skipping 21 matching lines...) Expand all
69 static inline bool compareCellPositionsWithOverflowingCells(LayoutTableCell* ele m1, LayoutTableCell* elem2) 107 static inline bool compareCellPositionsWithOverflowingCells(LayoutTableCell* ele m1, LayoutTableCell* elem2)
70 { 108 {
71 if (elem1->rowIndex() != elem2->rowIndex()) 109 if (elem1->rowIndex() != elem2->rowIndex())
72 return elem1->rowIndex() < elem2->rowIndex(); 110 return elem1->rowIndex() < elem2->rowIndex();
73 111
74 return elem1->absoluteColumnIndex() < elem2->absoluteColumnIndex(); 112 return elem1->absoluteColumnIndex() < elem2->absoluteColumnIndex();
75 } 113 }
76 114
77 void TableSectionPainter::paintCollapsedBorders(const PaintInfo& paintInfo, cons t LayoutPoint& paintOffset, const CollapsedBorderValue& currentBorderValue) 115 void TableSectionPainter::paintCollapsedBorders(const PaintInfo& paintInfo, cons t LayoutPoint& paintOffset, const CollapsedBorderValue& currentBorderValue)
78 { 116 {
117 paintCollapsedSectionBorders(paintInfo, paintOffset, currentBorderValue);
118 LayoutTable* table = m_layoutTableSection.table();
119 if (table->header() == m_layoutTableSection)
120 paintRepeatingHeaderGroup(paintInfo, paintOffset, currentBorderValue, Pa intCollapsedBorders);
121 }
122
123 void TableSectionPainter::paintCollapsedSectionBorders(const PaintInfo& paintInf o, const LayoutPoint& paintOffset, const CollapsedBorderValue& currentBorderValu e)
124 {
79 if (!m_layoutTableSection.numRows() || !m_layoutTableSection.table()->effect iveColumns().size()) 125 if (!m_layoutTableSection.numRows() || !m_layoutTableSection.table()->effect iveColumns().size())
80 return; 126 return;
81 127
82 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutTableSection.locatio n(); 128 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutTableSection.locatio n();
83 BoxClipper boxClipper(m_layoutTableSection, paintInfo, adjustedPaintOffset, ForceContentsClip); 129 BoxClipper boxClipper(m_layoutTableSection, paintInfo, adjustedPaintOffset, ForceContentsClip);
84 130
85 LayoutRect localPaintInvalidationRect = LayoutRect(paintInfo.cullRect().m_re ct); 131 LayoutRect localPaintInvalidationRect = LayoutRect(paintInfo.cullRect().m_re ct);
86 localPaintInvalidationRect.moveBy(-adjustedPaintOffset); 132 localPaintInvalidationRect.moveBy(-adjustedPaintOffset);
87 133
88 LayoutRect tableAlignedRect = m_layoutTableSection.logicalRectForWritingMode AndDirection(localPaintInvalidationRect); 134 LayoutRect tableAlignedRect = m_layoutTableSection.logicalRectForWritingMode AndDirection(localPaintInvalidationRect);
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 277
232 void TableSectionPainter::paintCell(const LayoutTableCell& cell, const PaintInfo & paintInfoForCells, const LayoutPoint& paintOffset) 278 void TableSectionPainter::paintCell(const LayoutTableCell& cell, const PaintInfo & paintInfoForCells, const LayoutPoint& paintOffset)
233 { 279 {
234 if (!cell.hasSelfPaintingLayer() && !cell.row()->hasSelfPaintingLayer()) { 280 if (!cell.hasSelfPaintingLayer() && !cell.row()->hasSelfPaintingLayer()) {
235 LayoutPoint cellPoint = m_layoutTableSection.flipForWritingModeForChild( &cell, paintOffset); 281 LayoutPoint cellPoint = m_layoutTableSection.flipForWritingModeForChild( &cell, paintOffset);
236 cell.paint(paintInfoForCells, cellPoint); 282 cell.paint(paintInfoForCells, cellPoint);
237 } 283 }
238 } 284 }
239 285
240 } // namespace blink 286 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698