| 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 "config.h" | 5 #include "config.h" |
| 6 #include "core/paint/TableCellPainter.h" | 6 #include "core/paint/TableCellPainter.h" |
| 7 | 7 |
| 8 #include "core/layout/LayoutTableCell.h" | 8 #include "core/layout/LayoutTableCell.h" |
| 9 #include "core/paint/BlockPainter.h" | 9 #include "core/paint/BlockPainter.h" |
| 10 #include "core/paint/BoxPainter.h" | 10 #include "core/paint/BoxPainter.h" |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 LayoutRect paintRect = paintBounds(paintOffset, AddOffsetFromParent); | 105 LayoutRect paintRect = paintBounds(paintOffset, AddOffsetFromParent); |
| 106 IntRect borderRect = pixelSnappedIntRect(paintRect.x() - leftWidth / 2, | 106 IntRect borderRect = pixelSnappedIntRect(paintRect.x() - leftWidth / 2, |
| 107 paintRect.y() - topWidth / 2, | 107 paintRect.y() - topWidth / 2, |
| 108 paintRect.width() + leftWidth / 2 + (rightWidth + 1) / 2, | 108 paintRect.width() + leftWidth / 2 + (rightWidth + 1) / 2, |
| 109 paintRect.height() + topWidth / 2 + (bottomWidth + 1) / 2); | 109 paintRect.height() + topWidth / 2 + (bottomWidth + 1) / 2); |
| 110 | 110 |
| 111 if (!borderRect.intersects(paintInfo.rect)) | 111 if (!borderRect.intersects(paintInfo.rect)) |
| 112 return; | 112 return; |
| 113 | 113 |
| 114 GraphicsContext* graphicsContext = paintInfo.context; | 114 GraphicsContext* graphicsContext = paintInfo.context; |
| 115 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*graphicsContext
, m_layoutTableCell, static_cast<DisplayItem::Type>(displayItemType))) | 115 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*graphicsContext
, m_layoutTableCell, static_cast<DisplayItem::Type>(displayItemType), paintOffse
t)) |
| 116 return; | 116 return; |
| 117 | 117 |
| 118 LayoutObjectDrawingRecorder recorder(*graphicsContext, m_layoutTableCell, st
atic_cast<DisplayItem::Type>(displayItemType), borderRect); | 118 LayoutObjectDrawingRecorder recorder(*graphicsContext, m_layoutTableCell, st
atic_cast<DisplayItem::Type>(displayItemType), borderRect, paintOffset); |
| 119 Color cellColor = m_layoutTableCell.resolveColor(CSSPropertyColor); | 119 Color cellColor = m_layoutTableCell.resolveColor(CSSPropertyColor); |
| 120 bool antialias = BoxPainter::shouldAntialiasLines(graphicsContext); | 120 bool antialias = BoxPainter::shouldAntialiasLines(graphicsContext); |
| 121 | 121 |
| 122 // We never paint diagonals at the joins. We simply let the border with the
highest | 122 // We never paint diagonals at the joins. We simply let the border with the
highest |
| 123 // precedence paint on top of borders with lower precedence. | 123 // precedence paint on top of borders with lower precedence. |
| 124 if (displayItemType & DisplayItem::TableCollapsedBorderTop) { | 124 if (displayItemType & DisplayItem::TableCollapsedBorderTop) { |
| 125 ObjectPainter::drawLineForBoxSide(graphicsContext, borderRect.x(), borde
rRect.y(), borderRect.maxX(), borderRect.y() + topWidth, BSTop, | 125 ObjectPainter::drawLineForBoxSide(graphicsContext, borderRect.x(), borde
rRect.y(), borderRect.maxX(), borderRect.y() + topWidth, BSTop, |
| 126 topBorderValue.color().resolve(cellColor), collapsedBorderStyle(topB
orderValue.style()), 0, 0, antialias); | 126 topBorderValue.color().resolve(cellColor), collapsedBorderStyle(topB
orderValue.style()), 0, 0, antialias); |
| 127 } | 127 } |
| 128 if (displayItemType & DisplayItem::TableCollapsedBorderBottom) { | 128 if (displayItemType & DisplayItem::TableCollapsedBorderBottom) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 return; | 179 return; |
| 180 | 180 |
| 181 LayoutTable* table = m_layoutTableCell.table(); | 181 LayoutTable* table = m_layoutTableCell.table(); |
| 182 if (!table->collapseBorders() && m_layoutTableCell.style()->emptyCells() ==
HIDE && !m_layoutTableCell.firstChild()) | 182 if (!table->collapseBorders() && m_layoutTableCell.style()->emptyCells() ==
HIDE && !m_layoutTableCell.firstChild()) |
| 183 return; | 183 return; |
| 184 | 184 |
| 185 bool needsToPaintBorder = m_layoutTableCell.styleRef().hasBorderDecoration()
&& !table->collapseBorders(); | 185 bool needsToPaintBorder = m_layoutTableCell.styleRef().hasBorderDecoration()
&& !table->collapseBorders(); |
| 186 if (!m_layoutTableCell.hasBackground() && !m_layoutTableCell.styleRef().boxS
hadow() && !needsToPaintBorder) | 186 if (!m_layoutTableCell.hasBackground() && !m_layoutTableCell.styleRef().boxS
hadow() && !needsToPaintBorder) |
| 187 return; | 187 return; |
| 188 | 188 |
| 189 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte
xt, m_layoutTableCell, DisplayItem::BoxDecorationBackground)) | 189 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte
xt, m_layoutTableCell, DisplayItem::BoxDecorationBackground, paintOffset)) |
| 190 return; | 190 return; |
| 191 | 191 |
| 192 LayoutRect visualOverflowRect = m_layoutTableCell.visualOverflowRect(); | 192 LayoutRect visualOverflowRect = m_layoutTableCell.visualOverflowRect(); |
| 193 visualOverflowRect.moveBy(paintOffset); | 193 visualOverflowRect.moveBy(paintOffset); |
| 194 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutTableCell,
DisplayItem::BoxDecorationBackground, pixelSnappedIntRect(visualOverflowRect)); | 194 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutTableCell,
DisplayItem::BoxDecorationBackground, pixelSnappedIntRect(visualOverflowRect), p
aintOffset); |
| 195 | 195 |
| 196 LayoutRect paintRect = paintBounds(paintOffset, DoNotAddOffsetFromParent); | 196 LayoutRect paintRect = paintBounds(paintOffset, DoNotAddOffsetFromParent); |
| 197 | 197 |
| 198 BoxPainter::paintBoxShadow(paintInfo, paintRect, m_layoutTableCell.styleRef(
), Normal); | 198 BoxPainter::paintBoxShadow(paintInfo, paintRect, m_layoutTableCell.styleRef(
), Normal); |
| 199 | 199 |
| 200 // Paint our cell background. | 200 // Paint our cell background. |
| 201 paintBackgroundsBehindCell(paintInfo, paintOffset, &m_layoutTableCell); | 201 paintBackgroundsBehindCell(paintInfo, paintOffset, &m_layoutTableCell); |
| 202 | 202 |
| 203 BoxPainter::paintBoxShadow(paintInfo, paintRect, m_layoutTableCell.styleRef(
), Inset); | 203 BoxPainter::paintBoxShadow(paintInfo, paintRect, m_layoutTableCell.styleRef(
), Inset); |
| 204 | 204 |
| 205 if (!needsToPaintBorder) | 205 if (!needsToPaintBorder) |
| 206 return; | 206 return; |
| 207 | 207 |
| 208 BoxPainter::paintBorder(m_layoutTableCell, paintInfo, paintRect, m_layoutTab
leCell.styleRef()); | 208 BoxPainter::paintBorder(m_layoutTableCell, paintInfo, paintRect, m_layoutTab
leCell.styleRef()); |
| 209 } | 209 } |
| 210 | 210 |
| 211 void TableCellPainter::paintMask(const PaintInfo& paintInfo, const LayoutPoint&
paintOffset) | 211 void TableCellPainter::paintMask(const PaintInfo& paintInfo, const LayoutPoint&
paintOffset) |
| 212 { | 212 { |
| 213 if (m_layoutTableCell.style()->visibility() != VISIBLE || paintInfo.phase !=
PaintPhaseMask) | 213 if (m_layoutTableCell.style()->visibility() != VISIBLE || paintInfo.phase !=
PaintPhaseMask) |
| 214 return; | 214 return; |
| 215 | 215 |
| 216 LayoutTable* tableElt = m_layoutTableCell.table(); | 216 LayoutTable* tableElt = m_layoutTableCell.table(); |
| 217 if (!tableElt->collapseBorders() && m_layoutTableCell.style()->emptyCells()
== HIDE && !m_layoutTableCell.firstChild()) | 217 if (!tableElt->collapseBorders() && m_layoutTableCell.style()->emptyCells()
== HIDE && !m_layoutTableCell.firstChild()) |
| 218 return; | 218 return; |
| 219 | 219 |
| 220 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte
xt, m_layoutTableCell, paintInfo.phase)) | 220 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*paintInfo.conte
xt, m_layoutTableCell, paintInfo.phase, paintOffset)) |
| 221 return; | 221 return; |
| 222 | 222 |
| 223 LayoutRect paintRect = paintBounds(paintOffset, DoNotAddOffsetFromParent); | 223 LayoutRect paintRect = paintBounds(paintOffset, DoNotAddOffsetFromParent); |
| 224 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutTableCell,
paintInfo.phase, paintRect); | 224 LayoutObjectDrawingRecorder recorder(*paintInfo.context, m_layoutTableCell,
paintInfo.phase, paintRect, paintOffset); |
| 225 BoxPainter(m_layoutTableCell).paintMaskImages(paintInfo, paintRect); | 225 BoxPainter(m_layoutTableCell).paintMaskImages(paintInfo, paintRect); |
| 226 } | 226 } |
| 227 | 227 |
| 228 LayoutRect TableCellPainter::paintBounds(const LayoutPoint& paintOffset, PaintBo
undOffsetBehavior paintBoundOffsetBehavior) | 228 LayoutRect TableCellPainter::paintBounds(const LayoutPoint& paintOffset, PaintBo
undOffsetBehavior paintBoundOffsetBehavior) |
| 229 { | 229 { |
| 230 LayoutPoint adjustedPaintOffset = paintOffset; | 230 LayoutPoint adjustedPaintOffset = paintOffset; |
| 231 if (paintBoundOffsetBehavior == AddOffsetFromParent) | 231 if (paintBoundOffsetBehavior == AddOffsetFromParent) |
| 232 adjustedPaintOffset.moveBy(m_layoutTableCell.location()); | 232 adjustedPaintOffset.moveBy(m_layoutTableCell.location()); |
| 233 return LayoutRect(adjustedPaintOffset, LayoutSize(m_layoutTableCell.pixelSna
ppedSize())); | 233 return LayoutRect(adjustedPaintOffset, LayoutSize(m_layoutTableCell.pixelSna
ppedSize())); |
| 234 } | 234 } |
| 235 | 235 |
| 236 } // namespace blink | 236 } // namespace blink |
| 237 | 237 |
| OLD | NEW |