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

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

Issue 1781463002: Fix table background painting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sample code for improved collapsed border painting Created 3 years, 11 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/TableSectionPainter.h" 5 #include "core/paint/TableSectionPainter.h"
6 6
7 #include "core/layout/LayoutTable.h" 7 #include "core/layout/LayoutTable.h"
8 #include "core/layout/LayoutTableCell.h" 8 #include "core/layout/LayoutTableCell.h"
9 #include "core/layout/LayoutTableCol.h" 9 #include "core/layout/LayoutTableCol.h"
10 #include "core/layout/LayoutTableRow.h" 10 #include "core/layout/LayoutTableRow.h"
11 #include "core/paint/BlockPainter.h" 11 #include "core/paint/BlockPainter.h"
12 #include "core/paint/BoxClipper.h" 12 #include "core/paint/BoxClipper.h"
13 #include "core/paint/LayoutObjectDrawingRecorder.h" 13 #include "core/paint/LayoutObjectDrawingRecorder.h"
14 #include "core/paint/ObjectPainter.h" 14 #include "core/paint/ObjectPainter.h"
15 #include "core/paint/PaintInfo.h" 15 #include "core/paint/PaintInfo.h"
16 #include "core/paint/TableCellPainter.h" 16 #include "core/paint/TableCellPainter.h"
17 #include "core/paint/TableCollapsedBorderPainter.h"
17 #include "core/paint/TableRowPainter.h" 18 #include "core/paint/TableRowPainter.h"
18 #include <algorithm> 19 #include <algorithm>
19 20
20 namespace blink { 21 namespace blink {
21 22
22 void TableSectionPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& p aintOffset) 23 void TableSectionPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& p aintOffset)
23 { 24 {
24 ASSERT(!m_layoutTableSection.needsLayout()); 25 ASSERT(!m_layoutTableSection.needsLayout());
25 // avoid crashing on bugs that cause us to paint with dirty layout 26 // avoid crashing on bugs that cause us to paint with dirty layout
26 if (m_layoutTableSection.needsLayout()) 27 if (m_layoutTableSection.needsLayout())
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 localPaintInvalidationRect.moveBy(-adjustedPaintOffset); 73 localPaintInvalidationRect.moveBy(-adjustedPaintOffset);
73 74
74 LayoutRect tableAlignedRect = m_layoutTableSection.logicalRectForWritingMode AndDirection(localPaintInvalidationRect); 75 LayoutRect tableAlignedRect = m_layoutTableSection.logicalRectForWritingMode AndDirection(localPaintInvalidationRect);
75 76
76 CellSpan dirtiedRows = m_layoutTableSection.dirtiedRows(tableAlignedRect); 77 CellSpan dirtiedRows = m_layoutTableSection.dirtiedRows(tableAlignedRect);
77 CellSpan dirtiedColumns = m_layoutTableSection.dirtiedEffectiveColumns(table AlignedRect); 78 CellSpan dirtiedColumns = m_layoutTableSection.dirtiedEffectiveColumns(table AlignedRect);
78 79
79 if (dirtiedColumns.start() >= dirtiedColumns.end()) 80 if (dirtiedColumns.start() >= dirtiedColumns.end())
80 return; 81 return;
81 82
83
82 // Collapsed borders are painted from the bottom right to the top left so th at precedence 84 // Collapsed borders are painted from the bottom right to the top left so th at precedence
83 // due to cell position is respected. 85 // due to cell position is respected.
84 for (unsigned r = dirtiedRows.end(); r > dirtiedRows.start(); r--) { 86 for (unsigned r = dirtiedRows.end(); r > dirtiedRows.start(); r--) {
85 unsigned row = r - 1; 87 unsigned row = r - 1;
86 for (unsigned c = dirtiedColumns.end(); c > dirtiedColumns.start(); c--) { 88 for (unsigned c = dirtiedColumns.end(); c > dirtiedColumns.start(); c--) {
87 unsigned col = c - 1; 89 unsigned col = c - 1;
88 const LayoutTableSection::CellStruct& current = m_layoutTableSection .cellAt(row, col); 90 const LayoutTableSection::CellStruct& current = m_layoutTableSection .cellAt(row, col);
89 const LayoutTableCell* cell = current.primaryCell(); 91 const LayoutTableCell* cell = current.primaryCell();
90 if (!cell || (row > dirtiedRows.start() && m_layoutTableSection.prim aryCellAt(row - 1, col) == cell) || (col > dirtiedColumns.start() && m_layoutTab leSection.primaryCellAt(row, col - 1) == cell)) 92 if (!cell || (row > dirtiedRows.start() && m_layoutTableSection.prim aryCellAt(row - 1, col) == cell) || (col > dirtiedColumns.start() && m_layoutTab leSection.primaryCellAt(row, col - 1) == cell))
91 continue; 93 continue;
92 LayoutPoint cellPoint = m_layoutTableSection.flipForWritingModeForCh ild(cell, adjustedPaintOffset); 94 LayoutPoint cellPoint = m_layoutTableSection.flipForWritingModeForCh ild(cell, adjustedPaintOffset);
93 TableCellPainter(*cell).paintCollapsedBorders(paintInfo, cellPoint, currentBorderValue); 95 TableCellPainter(*cell).paintCollapsedBorders(paintInfo, cellPoint, currentBorderValue);
94 } 96 }
95 } 97 }
96 } 98 }
97 99
100 void TableSectionPainter::paintCollapsedBorders2(const PaintInfo& paintInfo, con st LayoutPoint& paintOffset, TableCollapsedBorderPainter& previousPainter)
101 {
102 if (!m_layoutTableSection.numRows() || !m_layoutTableSection.table()->effect iveColumns().size())
103 return;
104
105 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutTableSection.locatio n();
106 BoxClipper boxClipper(m_layoutTableSection, paintInfo, adjustedPaintOffset, ForceContentsClip);
107
108 LayoutRect localPaintInvalidationRect = LayoutRect(paintInfo.cullRect().m_re ct);
109 localPaintInvalidationRect.moveBy(-adjustedPaintOffset);
110
111 LayoutRect tableAlignedRect = m_layoutTableSection.logicalRectForWritingMode AndDirection(localPaintInvalidationRect);
112
113 CellSpan dirtiedRows = m_layoutTableSection.dirtiedRows(tableAlignedRect);
114 CellSpan dirtiedEffColumns = m_layoutTableSection.dirtiedEffectiveColumns(ta bleAlignedRect);
115
116 TableCollapsedBorderPainter painter(&m_layoutTableSection);
117 painter.paintBorders(paintInfo, paintOffset, dirtiedRows, dirtiedEffColumns, previousPainter);
118 previousPainter = painter;
119 return;
120 }
121
98 void TableSectionPainter::paintObject(const PaintInfo& paintInfo, const LayoutPo int& paintOffset) 122 void TableSectionPainter::paintObject(const PaintInfo& paintInfo, const LayoutPo int& paintOffset)
99 { 123 {
100 LayoutRect localPaintInvalidationRect = LayoutRect(paintInfo.cullRect().m_re ct); 124 LayoutRect localPaintInvalidationRect = LayoutRect(paintInfo.cullRect().m_re ct);
101 localPaintInvalidationRect.moveBy(-paintOffset); 125 localPaintInvalidationRect.moveBy(-paintOffset);
102 126
103 LayoutRect tableAlignedRect = m_layoutTableSection.logicalRectForWritingMode AndDirection(localPaintInvalidationRect); 127 LayoutRect tableAlignedRect = m_layoutTableSection.logicalRectForWritingMode AndDirection(localPaintInvalidationRect);
104 128
105 CellSpan dirtiedRows = m_layoutTableSection.dirtiedRows(tableAlignedRect); 129 CellSpan dirtiedRows = m_layoutTableSection.dirtiedRows(tableAlignedRect);
106 CellSpan dirtiedColumns = m_layoutTableSection.dirtiedEffectiveColumns(table AlignedRect); 130 CellSpan dirtiedColumns = m_layoutTableSection.dirtiedEffectiveColumns(table AlignedRect);
107 131
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 // painting the row background for the cell. 234 // painting the row background for the cell.
211 if (row->hasBackground() && !row->hasSelfPaintingLayer()) 235 if (row->hasBackground() && !row->hasSelfPaintingLayer())
212 TableCellPainter(cell).paintBackgroundsBehindCell(paintInfoForCells, cellPoint, row, DisplayItem::TableCellBackgroundFromRow); 236 TableCellPainter(cell).paintBackgroundsBehindCell(paintInfoForCells, cellPoint, row, DisplayItem::TableCellBackgroundFromRow);
213 } 237 }
214 238
215 if (originalPaintPhase != PaintPhaseSelfBlockBackgroundOnly && !cell.hasSelf PaintingLayer() && !row->hasSelfPaintingLayer()) 239 if (originalPaintPhase != PaintPhaseSelfBlockBackgroundOnly && !cell.hasSelf PaintingLayer() && !row->hasSelfPaintingLayer())
216 cell.paint(paintInfoForCells, cellPoint); 240 cell.paint(paintInfoForCells, cellPoint);
217 } 241 }
218 242
219 } // namespace blink 243 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698