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

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

Issue 2430313004: Paint collapsed borders of a table as one display item (Closed)
Patch Set: - Created 4 years, 1 month 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/LayoutTableCell.h" 7 #include "core/layout/LayoutTableCell.h"
8 #include "core/layout/LayoutTableCol.h" 8 #include "core/layout/LayoutTableCol.h"
9 #include "core/layout/LayoutTableRow.h" 9 #include "core/layout/LayoutTableRow.h"
10 #include "core/paint/BoxClipper.h" 10 #include "core/paint/BoxClipper.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 // properly issue paint invalidations. 134 // properly issue paint invalidations.
135 static inline bool compareCellPositionsWithOverflowingCells( 135 static inline bool compareCellPositionsWithOverflowingCells(
136 LayoutTableCell* elem1, 136 LayoutTableCell* elem1,
137 LayoutTableCell* elem2) { 137 LayoutTableCell* elem2) {
138 if (elem1->rowIndex() != elem2->rowIndex()) 138 if (elem1->rowIndex() != elem2->rowIndex())
139 return elem1->rowIndex() < elem2->rowIndex(); 139 return elem1->rowIndex() < elem2->rowIndex();
140 140
141 return elem1->absoluteColumnIndex() < elem2->absoluteColumnIndex(); 141 return elem1->absoluteColumnIndex() < elem2->absoluteColumnIndex();
142 } 142 }
143 143
144 void TableSectionPainter::paintCollapsedBorders( 144 PaintResult TableSectionPainter::paintCollapsedBorders(
145 const PaintInfo& paintInfo, 145 const PaintInfo& paintInfo,
146 const LayoutPoint& paintOffset, 146 const LayoutPoint& paintOffset,
147 const CollapsedBorderValue& currentBorderValue) { 147 const CollapsedBorderValue& currentBorderValue) {
148 paintCollapsedSectionBorders(paintInfo, paintOffset, currentBorderValue); 148 PaintResult result =
149 paintCollapsedSectionBorders(paintInfo, paintOffset, currentBorderValue);
149 LayoutTable* table = m_layoutTableSection.table(); 150 LayoutTable* table = m_layoutTableSection.table();
150 if (table->header() == m_layoutTableSection) 151 if (table->header() == m_layoutTableSection) {
151 paintRepeatingHeaderGroup(paintInfo, paintOffset, currentBorderValue, 152 paintRepeatingHeaderGroup(paintInfo, paintOffset, currentBorderValue,
152 PaintCollapsedBorders); 153 PaintCollapsedBorders);
154 }
155 return result;
153 } 156 }
154 157
155 void TableSectionPainter::paintCollapsedSectionBorders( 158 PaintResult TableSectionPainter::paintCollapsedSectionBorders(
156 const PaintInfo& paintInfo, 159 const PaintInfo& paintInfo,
157 const LayoutPoint& paintOffset, 160 const LayoutPoint& paintOffset,
158 const CollapsedBorderValue& currentBorderValue) { 161 const CollapsedBorderValue& currentBorderValue) {
159 if (!m_layoutTableSection.numRows() || 162 if (!m_layoutTableSection.numRows() ||
160 !m_layoutTableSection.table()->effectiveColumns().size()) 163 !m_layoutTableSection.table()->effectiveColumns().size())
161 return; 164 return FullyPainted;
162 165
163 LayoutPoint adjustedPaintOffset = 166 LayoutPoint adjustedPaintOffset =
164 paintOffset + m_layoutTableSection.location(); 167 paintOffset + m_layoutTableSection.location();
165 BoxClipper boxClipper(m_layoutTableSection, paintInfo, adjustedPaintOffset, 168 BoxClipper boxClipper(m_layoutTableSection, paintInfo, adjustedPaintOffset,
166 ForceContentsClip); 169 ForceContentsClip);
167 170
168 LayoutRect localVisualRect = LayoutRect(paintInfo.cullRect().m_rect); 171 LayoutRect localVisualRect = LayoutRect(paintInfo.cullRect().m_rect);
169 localVisualRect.moveBy(-adjustedPaintOffset); 172 localVisualRect.moveBy(-adjustedPaintOffset);
170 173
171 LayoutRect tableAlignedRect = 174 LayoutRect tableAlignedRect =
172 m_layoutTableSection.logicalRectForWritingModeAndDirection( 175 m_layoutTableSection.logicalRectForWritingModeAndDirection(
173 localVisualRect); 176 localVisualRect);
174 177
175 CellSpan dirtiedRows = m_layoutTableSection.dirtiedRows(tableAlignedRect); 178 CellSpan dirtiedRows = m_layoutTableSection.dirtiedRows(tableAlignedRect);
176 CellSpan dirtiedColumns = 179 CellSpan dirtiedColumns =
177 m_layoutTableSection.dirtiedEffectiveColumns(tableAlignedRect); 180 m_layoutTableSection.dirtiedEffectiveColumns(tableAlignedRect);
178 181
179 if (dirtiedColumns.start() >= dirtiedColumns.end()) 182 if (dirtiedColumns.start() >= dirtiedColumns.end())
180 return; 183 return MayBeClippedByPaintDirtyRect;
181 184
182 // Collapsed borders are painted from the bottom right to the top left so that 185 // Collapsed borders are painted from the bottom right to the top left so that
183 // precedence due to cell position is respected. 186 // precedence due to cell position is respected.
184 for (unsigned r = dirtiedRows.end(); r > dirtiedRows.start(); r--) { 187 for (unsigned r = dirtiedRows.end(); r > dirtiedRows.start(); r--) {
185 unsigned row = r - 1; 188 unsigned row = r - 1;
186 for (unsigned c = dirtiedColumns.end(); c > dirtiedColumns.start(); c--) { 189 for (unsigned c = dirtiedColumns.end(); c > dirtiedColumns.start(); c--) {
187 unsigned col = c - 1; 190 unsigned col = c - 1;
188 const LayoutTableSection::CellStruct& current = 191 const LayoutTableSection::CellStruct& current =
189 m_layoutTableSection.cellAt(row, col); 192 m_layoutTableSection.cellAt(row, col);
190 const LayoutTableCell* cell = current.primaryCell(); 193 const LayoutTableCell* cell = current.primaryCell();
191 if (!cell || (row > dirtiedRows.start() && 194 if (!cell || (row > dirtiedRows.start() &&
192 m_layoutTableSection.primaryCellAt(row - 1, col) == cell) || 195 m_layoutTableSection.primaryCellAt(row - 1, col) == cell) ||
193 (col > dirtiedColumns.start() && 196 (col > dirtiedColumns.start() &&
194 m_layoutTableSection.primaryCellAt(row, col - 1) == cell)) 197 m_layoutTableSection.primaryCellAt(row, col - 1) == cell))
195 continue; 198 continue;
196 LayoutPoint cellPoint = m_layoutTableSection.flipForWritingModeForChild( 199 LayoutPoint cellPoint = m_layoutTableSection.flipForWritingModeForChild(
197 cell, adjustedPaintOffset); 200 cell, adjustedPaintOffset);
198 TableCellPainter(*cell).paintCollapsedBorders(paintInfo, cellPoint, 201 TableCellPainter(*cell).paintCollapsedBorders(paintInfo, cellPoint,
199 currentBorderValue); 202 currentBorderValue);
200 } 203 }
201 } 204 }
205
206 if (dirtiedRows == m_layoutTableSection.fullTableRowSpan() &&
207 dirtiedColumns == m_layoutTableSection.fullTableEffectiveColumnSpan())
208 return FullyPainted;
209 return MayBeClippedByPaintDirtyRect;
202 } 210 }
203 211
204 void TableSectionPainter::paintObject(const PaintInfo& paintInfo, 212 void TableSectionPainter::paintObject(const PaintInfo& paintInfo,
205 const LayoutPoint& paintOffset) { 213 const LayoutPoint& paintOffset) {
206 LayoutRect localVisualRect = LayoutRect(paintInfo.cullRect().m_rect); 214 LayoutRect localVisualRect = LayoutRect(paintInfo.cullRect().m_rect);
207 localVisualRect.moveBy(-paintOffset); 215 localVisualRect.moveBy(-paintOffset);
208 216
209 LayoutRect tableAlignedRect = 217 LayoutRect tableAlignedRect =
210 m_layoutTableSection.logicalRectForWritingModeAndDirection( 218 m_layoutTableSection.logicalRectForWritingModeAndDirection(
211 localVisualRect); 219 localVisualRect);
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 LayoutRect bounds = BoxPainter(m_layoutTableSection) 399 LayoutRect bounds = BoxPainter(m_layoutTableSection)
392 .boundsForDrawingRecorder(paintInfo, paintOffset); 400 .boundsForDrawingRecorder(paintInfo, paintOffset);
393 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutTableSection, 401 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutTableSection,
394 type, bounds); 402 type, bounds);
395 BoxPainter::paintBoxShadow( 403 BoxPainter::paintBoxShadow(
396 paintInfo, LayoutRect(paintOffset, m_layoutTableSection.size()), 404 paintInfo, LayoutRect(paintOffset, m_layoutTableSection.size()),
397 m_layoutTableSection.styleRef(), shadowStyle); 405 m_layoutTableSection.styleRef(), shadowStyle);
398 } 406 }
399 407
400 } // namespace blink 408 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698