Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(398)

Side by Side Diff: third_party/WebKit/Source/core/paint/TableRowPainter.cpp

Issue 1983853003: Refactor background painting behind table cells (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
9 #include "core/paint/LayoutObjectDrawingRecorder.h" 10 #include "core/paint/LayoutObjectDrawingRecorder.h"
10 #include "core/paint/ObjectPainter.h" 11 #include "core/paint/ObjectPainter.h"
11 #include "core/paint/PaintInfo.h" 12 #include "core/paint/PaintInfo.h"
12 #include "core/paint/TableCellPainter.h" 13 #include "core/paint/TableCellPainter.h"
13 14
14 namespace blink { 15 namespace blink {
15 16
16 void TableRowPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paint Offset) 17 void TableRowPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paint Offset)
17 { 18 {
18 ASSERT(m_layoutTableRow.hasSelfPaintingLayer()); 19 DCHECK(m_layoutTableRow.hasSelfPaintingLayer());
19 20
20 // TODO(wangxianzhu): This painting order is inconsistent with other outline s. crbug.com/577282. 21 // TODO(crbug.com/577282): This painting order is inconsistent with other ou tlines.
21 paintOutlineForRowIfNeeded(paintInfo, paintOffset); 22 if (shouldPaintSelfOutline(paintInfo.phase))
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 bool shouldPaintRowBackground = shouldPaintSelfBlockBackground(paintInfo.pha se) && m_layoutTableRow.hasBackground(); 28 if (shouldPaintSelfBlockBackground(paintInfo.phase) && m_layoutTableRow.hasB ackground()) {
27 bool shouldPaintCells = paintInfo.phase != PaintPhaseSelfBlockBackgroundOnly ; 29 // Paint row background of behind the cells.
30 for (LayoutTableCell* cell = m_layoutTableRow.firstCell(); cell; cell = cell->nextCell())
31 TableCellPainter(*cell).paintContainerBackgroundBehindCell(paintInfo ForCells, paintOffset, m_layoutTableRow, DisplayItem::TableCellBackgroundFromRow );
32 }
33
34 if (paintInfo.phase == PaintPhaseSelfBlockBackgroundOnly)
35 return;
36
28 for (LayoutTableCell* cell = m_layoutTableRow.firstCell(); cell; cell = cell ->nextCell()) { 37 for (LayoutTableCell* cell = m_layoutTableRow.firstCell(); cell; cell = cell ->nextCell()) {
29 if (shouldPaintRowBackground) 38 if (!cell->hasSelfPaintingLayer())
30 TableCellPainter(*cell).paintBackgroundsBehindCell(paintInfoForCells , paintOffset, &m_layoutTableRow, DisplayItem::TableCellBackgroundFromRow);
31 if (shouldPaintCells && !cell->hasSelfPaintingLayer())
32 cell->paint(paintInfoForCells, paintOffset); 39 cell->paint(paintInfoForCells, paintOffset);
33 } 40 }
34 } 41 }
35 42
36 void TableRowPainter::paintOutlineForRowIfNeeded(const PaintInfo& paintInfo, con st LayoutPoint& paintOffset) 43 void TableRowPainter::paintOutline(const PaintInfo& paintInfo, const LayoutPoint & paintOffset)
37 { 44 {
38 PaintPhase paintPhase = paintInfo.phase; 45 DCHECK(shouldPaintSelfOutline(paintInfo.phase));
39 if (shouldPaintSelfOutline(paintPhase)) { 46 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutTableRow.location();
40 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutTableRow.locatio n(); 47 ObjectPainter(m_layoutTableRow).paintOutline(paintInfo, adjustedPaintOffset) ;
41 ObjectPainter(m_layoutTableRow).paintOutline(paintInfo, adjustedPaintOff set); 48 }
42 } 49
50 void TableRowPainter::paintBackgroundBehindCell(const LayoutTableCell& cell, con st PaintInfo& paintInfo, const LayoutPoint& paintOffset)
51 {
52 DCHECK(m_layoutTableRow.hasBackground() && !m_layoutTableRow.hasSelfPainting Layer());
53 LayoutPoint cellPoint = m_layoutTableRow.section()->flipForWritingModeForChi ld(&cell, paintOffset);
54 TableCellPainter(cell).paintContainerBackgroundBehindCell(paintInfo, cellPoi nt, m_layoutTableRow, DisplayItem::TableCellBackgroundFromRow);
43 } 55 }
44 56
45 } // namespace blink 57 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698