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/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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 // properly issue paint invalidations. | 141 // properly issue paint invalidations. |
142 static inline bool compareCellPositionsWithOverflowingCells( | 142 static inline bool compareCellPositionsWithOverflowingCells( |
143 LayoutTableCell* elem1, | 143 LayoutTableCell* elem1, |
144 LayoutTableCell* elem2) { | 144 LayoutTableCell* elem2) { |
145 if (elem1->rowIndex() != elem2->rowIndex()) | 145 if (elem1->rowIndex() != elem2->rowIndex()) |
146 return elem1->rowIndex() < elem2->rowIndex(); | 146 return elem1->rowIndex() < elem2->rowIndex(); |
147 | 147 |
148 return elem1->absoluteColumnIndex() < elem2->absoluteColumnIndex(); | 148 return elem1->absoluteColumnIndex() < elem2->absoluteColumnIndex(); |
149 } | 149 } |
150 | 150 |
151 void TableSectionPainter::paintCollapsedBorders( | 151 PaintResult TableSectionPainter::paintCollapsedBorders( |
152 const PaintInfo& paintInfo, | 152 const PaintInfo& paintInfo, |
153 const LayoutPoint& paintOffset, | 153 const LayoutPoint& paintOffset, |
154 const CollapsedBorderValue& currentBorderValue) { | 154 const CollapsedBorderValue& currentBorderValue) { |
155 paintCollapsedSectionBorders(paintInfo, paintOffset, currentBorderValue); | 155 PaintResult result = |
| 156 paintCollapsedSectionBorders(paintInfo, paintOffset, currentBorderValue); |
156 LayoutTable* table = m_layoutTableSection.table(); | 157 LayoutTable* table = m_layoutTableSection.table(); |
157 if (table->header() == m_layoutTableSection) | 158 if (table->header() == m_layoutTableSection) { |
158 paintRepeatingHeaderGroup(paintInfo, paintOffset, currentBorderValue, | 159 paintRepeatingHeaderGroup(paintInfo, paintOffset, currentBorderValue, |
159 PaintCollapsedBorders); | 160 PaintCollapsedBorders); |
| 161 } |
| 162 return result; |
160 } | 163 } |
161 | 164 |
162 void TableSectionPainter::paintCollapsedSectionBorders( | 165 PaintResult TableSectionPainter::paintCollapsedSectionBorders( |
163 const PaintInfo& paintInfo, | 166 const PaintInfo& paintInfo, |
164 const LayoutPoint& paintOffset, | 167 const LayoutPoint& paintOffset, |
165 const CollapsedBorderValue& currentBorderValue) { | 168 const CollapsedBorderValue& currentBorderValue) { |
166 if (!m_layoutTableSection.numRows() || | 169 if (!m_layoutTableSection.numRows() || |
167 !m_layoutTableSection.table()->effectiveColumns().size()) | 170 !m_layoutTableSection.table()->effectiveColumns().size()) |
168 return; | 171 return FullyPainted; |
169 | 172 |
170 LayoutPoint adjustedPaintOffset = | 173 LayoutPoint adjustedPaintOffset = |
171 paintOffset + m_layoutTableSection.location(); | 174 paintOffset + m_layoutTableSection.location(); |
172 BoxClipper boxClipper(m_layoutTableSection, paintInfo, adjustedPaintOffset, | 175 BoxClipper boxClipper(m_layoutTableSection, paintInfo, adjustedPaintOffset, |
173 ForceContentsClip); | 176 ForceContentsClip); |
174 | 177 |
175 LayoutRect localVisualRect = LayoutRect(paintInfo.cullRect().m_rect); | 178 LayoutRect localVisualRect = LayoutRect(paintInfo.cullRect().m_rect); |
176 localVisualRect.moveBy(-adjustedPaintOffset); | 179 localVisualRect.moveBy(-adjustedPaintOffset); |
177 | 180 |
178 LayoutRect tableAlignedRect = | 181 LayoutRect tableAlignedRect = |
179 m_layoutTableSection.logicalRectForWritingModeAndDirection( | 182 m_layoutTableSection.logicalRectForWritingModeAndDirection( |
180 localVisualRect); | 183 localVisualRect); |
181 | 184 |
182 CellSpan dirtiedRows = m_layoutTableSection.dirtiedRows(tableAlignedRect); | 185 CellSpan dirtiedRows = m_layoutTableSection.dirtiedRows(tableAlignedRect); |
183 CellSpan dirtiedColumns = | 186 CellSpan dirtiedColumns = |
184 m_layoutTableSection.dirtiedEffectiveColumns(tableAlignedRect); | 187 m_layoutTableSection.dirtiedEffectiveColumns(tableAlignedRect); |
185 | 188 |
186 if (dirtiedColumns.start() >= dirtiedColumns.end()) | 189 if (dirtiedColumns.start() >= dirtiedColumns.end()) |
187 return; | 190 return MayBeClippedByPaintDirtyRect; |
188 | 191 |
189 // Collapsed borders are painted from the bottom right to the top left so that | 192 // Collapsed borders are painted from the bottom right to the top left so that |
190 // precedence due to cell position is respected. | 193 // precedence due to cell position is respected. |
191 for (unsigned r = dirtiedRows.end(); r > dirtiedRows.start(); r--) { | 194 for (unsigned r = dirtiedRows.end(); r > dirtiedRows.start(); r--) { |
192 unsigned row = r - 1; | 195 unsigned row = r - 1; |
193 for (unsigned c = dirtiedColumns.end(); c > dirtiedColumns.start(); c--) { | 196 for (unsigned c = dirtiedColumns.end(); c > dirtiedColumns.start(); c--) { |
194 unsigned col = c - 1; | 197 unsigned col = c - 1; |
195 const LayoutTableSection::CellStruct& current = | 198 const LayoutTableSection::CellStruct& current = |
196 m_layoutTableSection.cellAt(row, col); | 199 m_layoutTableSection.cellAt(row, col); |
197 const LayoutTableCell* cell = current.primaryCell(); | 200 const LayoutTableCell* cell = current.primaryCell(); |
198 if (!cell || (row > dirtiedRows.start() && | 201 if (!cell || (row > dirtiedRows.start() && |
199 m_layoutTableSection.primaryCellAt(row - 1, col) == cell) || | 202 m_layoutTableSection.primaryCellAt(row - 1, col) == cell) || |
200 (col > dirtiedColumns.start() && | 203 (col > dirtiedColumns.start() && |
201 m_layoutTableSection.primaryCellAt(row, col - 1) == cell)) | 204 m_layoutTableSection.primaryCellAt(row, col - 1) == cell)) |
202 continue; | 205 continue; |
203 LayoutPoint cellPoint = m_layoutTableSection.flipForWritingModeForChild( | 206 LayoutPoint cellPoint = m_layoutTableSection.flipForWritingModeForChild( |
204 cell, adjustedPaintOffset); | 207 cell, adjustedPaintOffset); |
205 TableCellPainter(*cell).paintCollapsedBorders(paintInfo, cellPoint, | 208 TableCellPainter(*cell).paintCollapsedBorders(paintInfo, cellPoint, |
206 currentBorderValue); | 209 currentBorderValue); |
207 } | 210 } |
208 } | 211 } |
| 212 |
| 213 if (dirtiedRows == m_layoutTableSection.fullTableRowSpan() && |
| 214 dirtiedColumns == m_layoutTableSection.fullTableEffectiveColumnSpan()) |
| 215 return FullyPainted; |
| 216 return MayBeClippedByPaintDirtyRect; |
209 } | 217 } |
210 | 218 |
211 void TableSectionPainter::paintObject(const PaintInfo& paintInfo, | 219 void TableSectionPainter::paintObject(const PaintInfo& paintInfo, |
212 const LayoutPoint& paintOffset) { | 220 const LayoutPoint& paintOffset) { |
213 LayoutRect localVisualRect = LayoutRect(paintInfo.cullRect().m_rect); | 221 LayoutRect localVisualRect = LayoutRect(paintInfo.cullRect().m_rect); |
214 localVisualRect.moveBy(-paintOffset); | 222 localVisualRect.moveBy(-paintOffset); |
215 | 223 |
216 LayoutRect tableAlignedRect = | 224 LayoutRect tableAlignedRect = |
217 m_layoutTableSection.logicalRectForWritingModeAndDirection( | 225 m_layoutTableSection.logicalRectForWritingModeAndDirection( |
218 localVisualRect); | 226 localVisualRect); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 LayoutRect bounds = BoxPainter(m_layoutTableSection) | 406 LayoutRect bounds = BoxPainter(m_layoutTableSection) |
399 .boundsForDrawingRecorder(paintInfo, paintOffset); | 407 .boundsForDrawingRecorder(paintInfo, paintOffset); |
400 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutTableSection, | 408 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutTableSection, |
401 type, bounds); | 409 type, bounds); |
402 BoxPainter::paintBoxShadow( | 410 BoxPainter::paintBoxShadow( |
403 paintInfo, LayoutRect(paintOffset, m_layoutTableSection.size()), | 411 paintInfo, LayoutRect(paintOffset, m_layoutTableSection.size()), |
404 m_layoutTableSection.styleRef(), shadowStyle); | 412 m_layoutTableSection.styleRef(), shadowStyle); |
405 } | 413 } |
406 | 414 |
407 } // namespace blink | 415 } // namespace blink |
OLD | NEW |