| 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 "core/paint/TableRowPainter.h" | 5 #include "core/paint/TableRowPainter.h" |
| 6 | 6 |
| 7 #include "core/layout/LayoutTableCell.h" | 7 #include "core/layout/LayoutTableCell.h" |
| 8 #include "core/layout/LayoutTableRow.h" | 8 #include "core/layout/LayoutTableRow.h" |
| 9 #include "core/paint/LayoutObjectDrawingRecorder.h" | 9 #include "core/paint/LayoutObjectDrawingRecorder.h" |
| 10 #include "core/paint/ObjectPainter.h" | 10 #include "core/paint/ObjectPainter.h" |
| 11 #include "core/paint/PaintInfo.h" | 11 #include "core/paint/PaintInfo.h" |
| 12 #include "core/paint/TableCellPainter.h" | 12 #include "core/paint/TableCellPainter.h" |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 void TableRowPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paint
Offset) | 16 void TableRowPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paint
Offset) |
| 17 { | 17 { |
| 18 ASSERT(m_layoutTableRow.hasSelfPaintingLayer()); | 18 ASSERT(m_layoutTableRow.hasSelfPaintingLayer()); |
| 19 | 19 |
| 20 // Table rows don't paint self background. The cells paint table section's b
ackground | |
| 21 // behind them when needed during PaintPhaseBlockBackground or PaintPhaseDes
cendantBlockBackgroundOnly. | |
| 22 if (paintInfo.phase == PaintPhaseSelfBlockBackgroundOnly) | |
| 23 return; | |
| 24 | |
| 25 // TODO(wangxianzhu): This painting order is inconsistent with other outline
s. crbug.com/577282. | 20 // TODO(wangxianzhu): This painting order is inconsistent with other outline
s. crbug.com/577282. |
| 26 paintOutlineForRowIfNeeded(paintInfo, paintOffset); | 21 paintOutlineForRowIfNeeded(paintInfo, paintOffset); |
| 27 if (paintInfo.phase == PaintPhaseSelfOutlineOnly) | 22 if (paintInfo.phase == PaintPhaseSelfOutlineOnly) |
| 28 return; | 23 return; |
| 29 | 24 |
| 30 PaintInfo paintInfoForCells = paintInfo.forDescendants(); | 25 PaintInfo paintInfoForCells = paintInfo.forDescendants(); |
| 26 bool shouldPaintRowBackground = shouldPaintSelfBlockBackground(paintInfo.pha
se) && m_layoutTableRow.hasBackground(); |
| 27 bool shouldPaintCells = paintInfo.phase != PaintPhaseSelfBlockBackgroundOnly
; |
| 31 for (LayoutTableCell* cell = m_layoutTableRow.firstCell(); cell; cell = cell
->nextCell()) { | 28 for (LayoutTableCell* cell = m_layoutTableRow.firstCell(); cell; cell = cell
->nextCell()) { |
| 32 // Paint the row background behind the cell. | 29 if (shouldPaintRowBackground) |
| 33 if (shouldPaintSelfBlockBackground(paintInfoForCells.phase)) { | 30 TableCellPainter(*cell).paintBackgroundsBehindCell(paintInfoForCells
, paintOffset, &m_layoutTableRow, DisplayItem::TableCellBackgroundFromRow); |
| 34 if (m_layoutTableRow.hasBackground()) | 31 if (shouldPaintCells && !cell->hasSelfPaintingLayer()) |
| 35 TableCellPainter(*cell).paintBackgroundsBehindCell(paintInfoForC
ells, paintOffset, &m_layoutTableRow, DisplayItem::TableCellBackgroundFromRow); | |
| 36 } | |
| 37 | |
| 38 if (!cell->hasSelfPaintingLayer()) | |
| 39 cell->paint(paintInfoForCells, paintOffset); | 32 cell->paint(paintInfoForCells, paintOffset); |
| 40 } | 33 } |
| 41 } | 34 } |
| 42 | 35 |
| 43 void TableRowPainter::paintOutlineForRowIfNeeded(const PaintInfo& paintInfo, con
st LayoutPoint& paintOffset) | 36 void TableRowPainter::paintOutlineForRowIfNeeded(const PaintInfo& paintInfo, con
st LayoutPoint& paintOffset) |
| 44 { | 37 { |
| 45 PaintPhase paintPhase = paintInfo.phase; | 38 PaintPhase paintPhase = paintInfo.phase; |
| 46 if (shouldPaintSelfOutline(paintPhase)) { | 39 if (shouldPaintSelfOutline(paintPhase)) { |
| 47 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutTableRow.locatio
n(); | 40 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutTableRow.locatio
n(); |
| 48 ObjectPainter(m_layoutTableRow).paintOutline(paintInfo, adjustedPaintOff
set); | 41 ObjectPainter(m_layoutTableRow).paintOutline(paintInfo, adjustedPaintOff
set); |
| 49 } | 42 } |
| 50 } | 43 } |
| 51 | 44 |
| 52 } // namespace blink | 45 } // namespace blink |
| OLD | NEW |