OLD | NEW |
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 "config.h" | 5 #include "config.h" |
6 #include "core/paint/TableSectionPainter.h" | 6 #include "core/paint/TableSectionPainter.h" |
7 | 7 |
8 #include "core/paint/ObjectPainter.h" | 8 #include "core/paint/ObjectPainter.h" |
| 9 #include "core/paint/TableCellPainter.h" |
9 #include "core/paint/TableRowPainter.h" | 10 #include "core/paint/TableRowPainter.h" |
10 #include "core/rendering/GraphicsContextAnnotator.h" | 11 #include "core/rendering/GraphicsContextAnnotator.h" |
11 #include "core/rendering/PaintInfo.h" | 12 #include "core/rendering/PaintInfo.h" |
12 #include "core/rendering/RenderBoxClipper.h" | 13 #include "core/rendering/RenderBoxClipper.h" |
13 #include "core/rendering/RenderTable.h" | 14 #include "core/rendering/RenderTable.h" |
14 #include "core/rendering/RenderTableCell.h" | 15 #include "core/rendering/RenderTableCell.h" |
15 #include "core/rendering/RenderTableCol.h" | 16 #include "core/rendering/RenderTableCol.h" |
16 #include "core/rendering/RenderTableRow.h" | 17 #include "core/rendering/RenderTableRow.h" |
17 | 18 |
18 namespace blink { | 19 namespace blink { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 // due to cell position is respected. | 77 // due to cell position is respected. |
77 for (unsigned r = dirtiedRows.end(); r > dirtiedRows.start(); r-
-) { | 78 for (unsigned r = dirtiedRows.end(); r > dirtiedRows.start(); r-
-) { |
78 unsigned row = r - 1; | 79 unsigned row = r - 1; |
79 for (unsigned c = dirtiedColumns.end(); c > dirtiedColumns.s
tart(); c--) { | 80 for (unsigned c = dirtiedColumns.end(); c > dirtiedColumns.s
tart(); c--) { |
80 unsigned col = c - 1; | 81 unsigned col = c - 1; |
81 RenderTableSection::CellStruct& current = m_renderTableS
ection.cellAt(row, col); | 82 RenderTableSection::CellStruct& current = m_renderTableS
ection.cellAt(row, col); |
82 RenderTableCell* cell = current.primaryCell(); | 83 RenderTableCell* cell = current.primaryCell(); |
83 if (!cell || (row > dirtiedRows.start() && m_renderTable
Section.primaryCellAt(row - 1, col) == cell) || (col > dirtiedColumns.start() &&
m_renderTableSection.primaryCellAt(row, col - 1) == cell)) | 84 if (!cell || (row > dirtiedRows.start() && m_renderTable
Section.primaryCellAt(row - 1, col) == cell) || (col > dirtiedColumns.start() &&
m_renderTableSection.primaryCellAt(row, col - 1) == cell)) |
84 continue; | 85 continue; |
85 LayoutPoint cellPoint = m_renderTableSection.flipForWrit
ingModeForChild(cell, paintOffset); | 86 LayoutPoint cellPoint = m_renderTableSection.flipForWrit
ingModeForChild(cell, paintOffset); |
86 cell->paintCollapsedBorders(paintInfo, cellPoint); | 87 TableCellPainter(*cell).paintCollapsedBorders(paintInfo,
cellPoint); |
87 } | 88 } |
88 } | 89 } |
89 } else { | 90 } else { |
90 // Draw the dirty cells in the order that they appear. | 91 // Draw the dirty cells in the order that they appear. |
91 for (unsigned r = dirtiedRows.start(); r < dirtiedRows.end(); r+
+) { | 92 for (unsigned r = dirtiedRows.start(); r < dirtiedRows.end(); r+
+) { |
92 RenderTableRow* row = m_renderTableSection.rowRendererAt(r); | 93 RenderTableRow* row = m_renderTableSection.rowRendererAt(r); |
93 if (row && !row->hasSelfPaintingLayer()) | 94 if (row && !row->hasSelfPaintingLayer()) |
94 TableRowPainter(*row).paintOutlineForRowIfNeeded(paintIn
fo, paintOffset); | 95 TableRowPainter(*row).paintOutlineForRowIfNeeded(paintIn
fo, paintOffset); |
95 for (unsigned c = dirtiedColumns.start(); c < dirtiedColumns
.end(); c++) { | 96 for (unsigned c = dirtiedColumns.start(); c < dirtiedColumns
.end(); c++) { |
96 RenderTableSection::CellStruct& current = m_renderTableS
ection.cellAt(r, c); | 97 RenderTableSection::CellStruct& current = m_renderTableS
ection.cellAt(r, c); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 | 140 |
140 // Sort the dirty cells by paint order. | 141 // Sort the dirty cells by paint order. |
141 if (!overflowingCells.size()) | 142 if (!overflowingCells.size()) |
142 std::stable_sort(cells.begin(), cells.end(), compareCellPosition
s); | 143 std::stable_sort(cells.begin(), cells.end(), compareCellPosition
s); |
143 else | 144 else |
144 std::sort(cells.begin(), cells.end(), compareCellPositionsWithOv
erflowingCells); | 145 std::sort(cells.begin(), cells.end(), compareCellPositionsWithOv
erflowingCells); |
145 | 146 |
146 if (paintInfo.phase == PaintPhaseCollapsedTableBorders) { | 147 if (paintInfo.phase == PaintPhaseCollapsedTableBorders) { |
147 for (unsigned i = cells.size(); i > 0; --i) { | 148 for (unsigned i = cells.size(); i > 0; --i) { |
148 LayoutPoint cellPoint = m_renderTableSection.flipForWritingM
odeForChild(cells[i - 1], paintOffset); | 149 LayoutPoint cellPoint = m_renderTableSection.flipForWritingM
odeForChild(cells[i - 1], paintOffset); |
149 cells[i - 1]->paintCollapsedBorders(paintInfo, cellPoint); | 150 TableCellPainter(*cells[i - 1]).paintCollapsedBorders(paintI
nfo, cellPoint); |
150 } | 151 } |
151 } else { | 152 } else { |
152 for (unsigned i = 0; i < cells.size(); ++i) | 153 for (unsigned i = 0; i < cells.size(); ++i) |
153 paintCell(cells[i], paintInfo, paintOffset); | 154 paintCell(cells[i], paintInfo, paintOffset); |
154 } | 155 } |
155 } | 156 } |
156 } | 157 } |
157 } | 158 } |
158 | 159 |
159 void TableSectionPainter::paintCell(RenderTableCell* cell, PaintInfo& paintInfo,
const LayoutPoint& paintOffset) | 160 void TableSectionPainter::paintCell(RenderTableCell* cell, PaintInfo& paintInfo,
const LayoutPoint& paintOffset) |
160 { | 161 { |
161 LayoutPoint cellPoint = m_renderTableSection.flipForWritingModeForChild(cell
, paintOffset); | 162 LayoutPoint cellPoint = m_renderTableSection.flipForWritingModeForChild(cell
, paintOffset); |
162 PaintPhase paintPhase = paintInfo.phase; | 163 PaintPhase paintPhase = paintInfo.phase; |
163 RenderTableRow* row = toRenderTableRow(cell->parent()); | 164 RenderTableRow* row = toRenderTableRow(cell->parent()); |
164 | 165 |
165 if (paintPhase == PaintPhaseBlockBackground || paintPhase == PaintPhaseChild
BlockBackground) { | 166 if (paintPhase == PaintPhaseBlockBackground || paintPhase == PaintPhaseChild
BlockBackground) { |
166 // We need to handle painting a stack of backgrounds. This stack (from b
ottom to top) consists of | 167 // We need to handle painting a stack of backgrounds. This stack (from b
ottom to top) consists of |
167 // the column group, column, row group, row, and then the cell. | 168 // the column group, column, row group, row, and then the cell. |
168 RenderTableCol* column = m_renderTableSection.table()->colElement(cell->
col()); | 169 RenderTableCol* column = m_renderTableSection.table()->colElement(cell->
col()); |
169 RenderTableCol* columnGroup = column ? column->enclosingColumnGroup() :
0; | 170 RenderTableCol* columnGroup = column ? column->enclosingColumnGroup() :
0; |
170 | 171 |
171 // Column groups and columns first. | 172 // Column groups and columns first. |
172 // FIXME: Columns and column groups do not currently support opacity, an
d they are being painted "too late" in | 173 // FIXME: Columns and column groups do not currently support opacity, an
d they are being painted "too late" in |
173 // the stack, since we have already opened a transparency layer (potenti
ally) for the table row group. | 174 // the stack, since we have already opened a transparency layer (potenti
ally) for the table row group. |
174 // Note that we deliberately ignore whether or not the cell has a layer,
since these backgrounds paint "behind" the | 175 // Note that we deliberately ignore whether or not the cell has a layer,
since these backgrounds paint "behind" the |
175 // cell. | 176 // cell. |
176 cell->paintBackgroundsBehindCell(paintInfo, cellPoint, columnGroup); | 177 TableCellPainter(*cell).paintBackgroundsBehindCell(paintInfo, cellPoint,
columnGroup); |
177 cell->paintBackgroundsBehindCell(paintInfo, cellPoint, column); | 178 TableCellPainter(*cell).paintBackgroundsBehindCell(paintInfo, cellPoint,
column); |
178 | 179 |
179 // Paint the row group next. | 180 // Paint the row group next. |
180 cell->paintBackgroundsBehindCell(paintInfo, cellPoint, &m_renderTableSec
tion); | 181 TableCellPainter(*cell).paintBackgroundsBehindCell(paintInfo, cellPoint,
&m_renderTableSection); |
181 | 182 |
182 // Paint the row next, but only if it doesn't have a layer. If a row has
a layer, it will be responsible for | 183 // Paint the row next, but only if it doesn't have a layer. If a row has
a layer, it will be responsible for |
183 // painting the row background for the cell. | 184 // painting the row background for the cell. |
184 if (!row->hasSelfPaintingLayer()) | 185 if (!row->hasSelfPaintingLayer()) |
185 cell->paintBackgroundsBehindCell(paintInfo, cellPoint, row); | 186 TableCellPainter(*cell).paintBackgroundsBehindCell(paintInfo, cellPo
int, row); |
186 } | 187 } |
187 if ((!cell->hasSelfPaintingLayer() && !row->hasSelfPaintingLayer())) | 188 if ((!cell->hasSelfPaintingLayer() && !row->hasSelfPaintingLayer())) |
188 cell->paint(paintInfo, cellPoint); | 189 cell->paint(paintInfo, cellPoint); |
189 } | 190 } |
190 | 191 |
191 } // namespace blink | 192 } // namespace blink |
OLD | NEW |