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/layout/LayoutTable.h" | 8 #include "core/layout/LayoutTable.h" |
9 #include "core/layout/LayoutTableCell.h" | 9 #include "core/layout/LayoutTableCell.h" |
10 #include "core/layout/LayoutTableCol.h" | 10 #include "core/layout/LayoutTableCol.h" |
11 #include "core/layout/LayoutTableRow.h" | 11 #include "core/layout/LayoutTableRow.h" |
| 12 #include "core/paint/BlockPainter.h" |
12 #include "core/paint/BoxClipper.h" | 13 #include "core/paint/BoxClipper.h" |
13 #include "core/paint/LayoutObjectDrawingRecorder.h" | 14 #include "core/paint/LayoutObjectDrawingRecorder.h" |
14 #include "core/paint/ObjectPainter.h" | 15 #include "core/paint/ObjectPainter.h" |
15 #include "core/paint/PaintInfo.h" | 16 #include "core/paint/PaintInfo.h" |
16 #include "core/paint/TableCellPainter.h" | 17 #include "core/paint/TableCellPainter.h" |
17 #include "core/paint/TableRowPainter.h" | 18 #include "core/paint/TableRowPainter.h" |
18 | 19 |
19 namespace blink { | 20 namespace blink { |
20 | 21 |
21 void TableSectionPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& p
aintOffset) | 22 void TableSectionPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& p
aintOffset) |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 } | 154 } |
154 } | 155 } |
155 } | 156 } |
156 | 157 |
157 void TableSectionPainter::paintCell(LayoutTableCell* cell, const PaintInfo& pain
tInfo, const LayoutPoint& paintOffset) | 158 void TableSectionPainter::paintCell(LayoutTableCell* cell, const PaintInfo& pain
tInfo, const LayoutPoint& paintOffset) |
158 { | 159 { |
159 LayoutPoint cellPoint = m_layoutTableSection.flipForWritingModeForChild(cell
, paintOffset); | 160 LayoutPoint cellPoint = m_layoutTableSection.flipForWritingModeForChild(cell
, paintOffset); |
160 PaintPhase paintPhase = paintInfo.phase; | 161 PaintPhase paintPhase = paintInfo.phase; |
161 LayoutTableRow* row = toLayoutTableRow(cell->parent()); | 162 LayoutTableRow* row = toLayoutTableRow(cell->parent()); |
162 | 163 |
163 if (paintPhase == PaintPhaseBlockBackground || paintPhase == PaintPhaseChild
BlockBackground) { | 164 if ((paintPhase == PaintPhaseBlockBackground || paintPhase == PaintPhaseChil
dBlockBackground) |
| 165 && BlockPainter(*cell).isVisibleInPaintRect(paintInfo, paintOffset)) { |
164 // We need to handle painting a stack of backgrounds. This stack (from b
ottom to top) consists of | 166 // We need to handle painting a stack of backgrounds. This stack (from b
ottom to top) consists of |
165 // the column group, column, row group, row, and then the cell. | 167 // the column group, column, row group, row, and then the cell. |
166 LayoutTableCol* column = m_layoutTableSection.table()->colElement(cell->
col()); | 168 LayoutTableCol* column = m_layoutTableSection.table()->colElement(cell->
col()); |
167 LayoutTableCol* columnGroup = column ? column->enclosingColumnGroup() :
0; | 169 LayoutTableCol* columnGroup = column ? column->enclosingColumnGroup() :
0; |
168 | 170 |
169 bool columnHasBackground = column && column->hasBackground(); | 171 bool columnHasBackground = column && column->hasBackground(); |
170 bool columnGroupHasBackground = columnGroup && columnGroup->hasBackgroun
d(); | 172 bool columnGroupHasBackground = columnGroup && columnGroup->hasBackgroun
d(); |
171 bool sectionHasBackground = m_layoutTableSection.hasBackground(); | 173 bool sectionHasBackground = m_layoutTableSection.hasBackground(); |
172 bool rowHasBackground = row->hasBackground(); | 174 bool rowHasBackground = row->hasBackground(); |
173 | 175 |
174 if (columnHasBackground || columnGroupHasBackground || sectionHasBackgro
und || rowHasBackground) { | 176 if (columnHasBackground || columnGroupHasBackground || sectionHasBackgro
und || rowHasBackground) { |
175 TableCellPainter tableCellPainter(*cell); | 177 TableCellPainter tableCellPainter(*cell); |
176 if (!LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintI
nfo.context, *cell, paintPhase, paintOffset)) { | 178 if (!LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintI
nfo.context, *cell, DisplayItem::TableCellBackgroundFromContainers, paintOffset)
) { |
177 LayoutObjectDrawingRecorder recorder(*paintInfo.context, *cell,
paintPhase, tableCellPainter.paintBounds(cellPoint, TableCellPainter::AddOffsetF
romParent), paintOffset); | 179 LayoutObjectDrawingRecorder recorder(*paintInfo.context, *cell,
DisplayItem::TableCellBackgroundFromContainers, tableCellPainter.paintBounds(cel
lPoint, TableCellPainter::AddOffsetFromParent), paintOffset); |
178 // Column groups and columns first. | 180 // Column groups and columns first. |
179 // FIXME: Columns and column groups do not currently support opa
city, and they are being painted "too late" in | 181 // FIXME: Columns and column groups do not currently support opa
city, and they are being painted "too late" in |
180 // the stack, since we have already opened a transparency layer
(potentially) for the table row group. | 182 // the stack, since we have already opened a transparency layer
(potentially) for the table row group. |
181 // Note that we deliberately ignore whether or not the cell has
a layer, since these backgrounds paint "behind" the | 183 // Note that we deliberately ignore whether or not the cell has
a layer, since these backgrounds paint "behind" the |
182 // cell. | 184 // cell. |
183 if (columnGroupHasBackground) | 185 if (columnGroupHasBackground) |
184 tableCellPainter.paintBackgroundsBehindCell(paintInfo, cellP
oint, columnGroup); | 186 tableCellPainter.paintBackgroundsBehindCell(paintInfo, cellP
oint, columnGroup); |
185 if (columnHasBackground) | 187 if (columnHasBackground) |
186 tableCellPainter.paintBackgroundsBehindCell(paintInfo, cellP
oint, column); | 188 tableCellPainter.paintBackgroundsBehindCell(paintInfo, cellP
oint, column); |
187 | 189 |
188 // Paint the row group next. | 190 // Paint the row group next. |
189 if (sectionHasBackground) | 191 if (sectionHasBackground) |
190 tableCellPainter.paintBackgroundsBehindCell(paintInfo, cellP
oint, &m_layoutTableSection); | 192 tableCellPainter.paintBackgroundsBehindCell(paintInfo, cellP
oint, &m_layoutTableSection); |
191 | 193 |
192 // Paint the row next, but only if it doesn't have a layer. If a
row has a layer, it will be responsible for | 194 // Paint the row next, but only if it doesn't have a layer. If a
row has a layer, it will be responsible for |
193 // painting the row background for the cell. | 195 // painting the row background for the cell. |
194 if (rowHasBackground && !row->hasSelfPaintingLayer()) | 196 if (rowHasBackground && !row->hasSelfPaintingLayer()) |
195 tableCellPainter.paintBackgroundsBehindCell(paintInfo, cellP
oint, row); | 197 tableCellPainter.paintBackgroundsBehindCell(paintInfo, cellP
oint, row); |
196 } | 198 } |
197 } | 199 } |
198 } | 200 } |
199 if ((!cell->hasSelfPaintingLayer() && !row->hasSelfPaintingLayer())) | 201 if ((!cell->hasSelfPaintingLayer() && !row->hasSelfPaintingLayer())) |
200 cell->paint(paintInfo, cellPoint); | 202 cell->paint(paintInfo, cellPoint); |
201 } | 203 } |
202 | 204 |
203 } // namespace blink | 205 } // namespace blink |
OLD | NEW |