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/BoxPainter.h" |
| 10 #include "core/paint/LayoutObjectDrawingRecorder.h" |
9 #include "core/paint/ObjectPainter.h" | 11 #include "core/paint/ObjectPainter.h" |
10 #include "core/paint/PaintInfo.h" | 12 #include "core/paint/PaintInfo.h" |
11 #include "core/paint/TableCellPainter.h" | 13 #include "core/paint/TableCellPainter.h" |
12 | 14 |
13 namespace blink { | 15 namespace blink { |
14 | 16 |
15 void TableRowPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paint
Offset) | 17 void TableRowPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paint
Offset) |
16 { | 18 { |
17 DCHECK(m_layoutTableRow.hasSelfPaintingLayer()); | 19 DCHECK(m_layoutTableRow.hasSelfPaintingLayer()); |
18 | 20 |
19 // TODO(crbug.com/577282): This painting order is inconsistent with other ou
tlines. | 21 // TODO(crbug.com/577282): This painting order is inconsistent with other ou
tlines. |
20 if (shouldPaintSelfOutline(paintInfo.phase)) | 22 if (shouldPaintSelfOutline(paintInfo.phase)) |
21 paintOutline(paintInfo, paintOffset); | 23 paintOutline(paintInfo, paintOffset); |
22 if (paintInfo.phase == PaintPhaseSelfOutlineOnly) | 24 if (paintInfo.phase == PaintPhaseSelfOutlineOnly) |
23 return; | 25 return; |
24 | 26 |
25 PaintInfo paintInfoForCells = paintInfo.forDescendants(); | 27 PaintInfo paintInfoForCells = paintInfo.forDescendants(); |
26 if (shouldPaintSelfBlockBackground(paintInfo.phase) && m_layoutTableRow.hasB
ackground()) { | 28 if (shouldPaintSelfBlockBackground(paintInfo.phase)) { |
27 // Paint row background of behind the cells. | 29 paintBoxShadow(paintInfo, paintOffset, Normal); |
28 for (LayoutTableCell* cell = m_layoutTableRow.firstCell(); cell; cell =
cell->nextCell()) | 30 if (m_layoutTableRow.hasBackground()) { |
29 TableCellPainter(*cell).paintContainerBackgroundBehindCell(paintInfo
ForCells, paintOffset, m_layoutTableRow, DisplayItem::TableCellBackgroundFromRow
); | 31 // Paint row background of behind the cells. |
| 32 for (LayoutTableCell* cell = m_layoutTableRow.firstCell(); cell; cel
l = cell->nextCell()) |
| 33 TableCellPainter(*cell).paintContainerBackgroundBehindCell(paint
InfoForCells, paintOffset, m_layoutTableRow, DisplayItem::TableCellBackgroundFro
mRow); |
| 34 } |
| 35 paintBoxShadow(paintInfo, paintOffset, Inset); |
30 } | 36 } |
31 | 37 |
32 if (paintInfo.phase == PaintPhaseSelfBlockBackgroundOnly) | 38 if (paintInfo.phase == PaintPhaseSelfBlockBackgroundOnly) |
33 return; | 39 return; |
34 | 40 |
35 for (LayoutTableCell* cell = m_layoutTableRow.firstCell(); cell; cell = cell
->nextCell()) { | 41 for (LayoutTableCell* cell = m_layoutTableRow.firstCell(); cell; cell = cell
->nextCell()) { |
36 if (!cell->hasSelfPaintingLayer()) | 42 if (!cell->hasSelfPaintingLayer()) |
37 cell->paint(paintInfoForCells, paintOffset); | 43 cell->paint(paintInfoForCells, paintOffset); |
38 } | 44 } |
39 } | 45 } |
40 | 46 |
41 void TableRowPainter::paintOutline(const PaintInfo& paintInfo, const LayoutPoint
& paintOffset) | 47 void TableRowPainter::paintOutline(const PaintInfo& paintInfo, const LayoutPoint
& paintOffset) |
42 { | 48 { |
43 DCHECK(shouldPaintSelfOutline(paintInfo.phase)); | 49 DCHECK(shouldPaintSelfOutline(paintInfo.phase)); |
44 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutTableRow.location(); | 50 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutTableRow.location(); |
45 ObjectPainter(m_layoutTableRow).paintOutline(paintInfo, adjustedPaintOffset)
; | 51 ObjectPainter(m_layoutTableRow).paintOutline(paintInfo, adjustedPaintOffset)
; |
46 } | 52 } |
47 | 53 |
| 54 void TableRowPainter::paintBoxShadow(const PaintInfo& paintInfo, const LayoutPoi
nt& paintOffset, ShadowStyle shadowStyle) |
| 55 { |
| 56 DCHECK(shouldPaintSelfBlockBackground(paintInfo.phase)); |
| 57 if (!m_layoutTableRow.styleRef().boxShadow()) |
| 58 return; |
| 59 |
| 60 DisplayItem::Type type = shadowStyle == Normal ? DisplayItem::TableRowBoxSha
dowNormal : DisplayItem::TableRowBoxShadowInset; |
| 61 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex
t, m_layoutTableRow, type)) |
| 62 return; |
| 63 |
| 64 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutTableRow.location(); |
| 65 LayoutRect bounds = BoxPainter(m_layoutTableRow).boundsForDrawingRecorder(ad
justedPaintOffset); |
| 66 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutTableRow, ty
pe, bounds); |
| 67 BoxPainter::paintBoxShadow(paintInfo, LayoutRect(adjustedPaintOffset, m_layo
utTableRow.size()), m_layoutTableRow.styleRef(), shadowStyle); |
| 68 } |
| 69 |
48 void TableRowPainter::paintBackgroundBehindCell(const LayoutTableCell& cell, con
st PaintInfo& paintInfo, const LayoutPoint& paintOffset) | 70 void TableRowPainter::paintBackgroundBehindCell(const LayoutTableCell& cell, con
st PaintInfo& paintInfo, const LayoutPoint& paintOffset) |
49 { | 71 { |
50 DCHECK(m_layoutTableRow.hasBackground() && !m_layoutTableRow.hasSelfPainting
Layer()); | 72 DCHECK(m_layoutTableRow.hasBackground() && !m_layoutTableRow.hasSelfPainting
Layer()); |
51 LayoutPoint cellPoint = m_layoutTableRow.section()->flipForWritingModeForChi
ld(&cell, paintOffset); | 73 LayoutPoint cellPoint = m_layoutTableRow.section()->flipForWritingModeForChi
ld(&cell, paintOffset); |
52 TableCellPainter(cell).paintContainerBackgroundBehindCell(paintInfo, cellPoi
nt, m_layoutTableRow, DisplayItem::TableCellBackgroundFromRow); | 74 TableCellPainter(cell).paintContainerBackgroundBehindCell(paintInfo, cellPoi
nt, m_layoutTableRow, DisplayItem::TableCellBackgroundFromRow); |
53 } | 75 } |
54 | 76 |
55 } // namespace blink | 77 } // namespace blink |
OLD | NEW |