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