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
3 // found in the LICENSE file.
6 #include "core/paint/TableRowPainter.h"
8 #include "core/layout/LayoutTableCell.h"
9 #include "core/layout/LayoutTableRow.h"
10 #include "core/paint/LayoutObjectDrawingRecorder.h"
11 #include "core/paint/ObjectPainter.h"
12 #include "core/paint/PaintInfo.h"
13 #include "core/paint/TableCellPainter.h"
17 void TableRowPainter::paint(const PaintInfo
& paintInfo
, const LayoutPoint
& paintOffset
)
19 ASSERT(m_layoutTableRow
.hasSelfPaintingLayer());
21 paintOutlineForRowIfNeeded(paintInfo
, paintOffset
);
22 for (LayoutTableCell
* cell
= m_layoutTableRow
.firstCell(); cell
; cell
= cell
->nextCell()) {
23 // Paint the row background behind the cell.
24 if (paintInfo
.phase
== PaintPhaseBlockBackground
|| paintInfo
.phase
== PaintPhaseChildBlockBackground
) {
25 if (m_layoutTableRow
.hasBackground()) {
26 TableCellPainter
tableCellPainter(*cell
);
27 if (!LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo
.context
, *cell
, DisplayItem::TableCellBackgroundFromSelfPaintingRow
, paintOffset
)) {
28 LayoutObjectDrawingRecorder
recorder(*paintInfo
.context
, *cell
, DisplayItem::TableCellBackgroundFromSelfPaintingRow
, tableCellPainter
.paintBounds(paintOffset
, TableCellPainter::AddOffsetFromParent
), paintOffset
);
29 tableCellPainter
.paintBackgroundsBehindCell(paintInfo
, paintOffset
, &m_layoutTableRow
);
34 if (!cell
->hasSelfPaintingLayer())
35 cell
->paint(paintInfo
, paintOffset
);
39 void TableRowPainter::paintOutlineForRowIfNeeded(const PaintInfo
& paintInfo
, const LayoutPoint
& paintOffset
)
41 PaintPhase paintPhase
= paintInfo
.phase
;
42 if ((paintPhase
== PaintPhaseOutline
|| paintPhase
== PaintPhaseSelfOutline
) && m_layoutTableRow
.style()->visibility() == VISIBLE
) {
43 LayoutPoint adjustedPaintOffset
= paintOffset
+ m_layoutTableRow
.location();
44 ObjectPainter(m_layoutTableRow
).paintOutline(paintInfo
, adjustedPaintOffset
);