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