Chromium Code Reviews| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 return style; | 65 return style; |
| 66 } | 66 } |
| 67 | 67 |
| 68 void TableCellPainter::paintCollapsedBorders(const PaintInfo& paintInfo, const L ayoutPoint& paintOffset) | 68 void TableCellPainter::paintCollapsedBorders(const PaintInfo& paintInfo, const L ayoutPoint& paintOffset) |
| 69 { | 69 { |
| 70 ASSERT(paintInfo.phase == PaintPhaseCollapsedTableBorders); | 70 ASSERT(paintInfo.phase == PaintPhaseCollapsedTableBorders); |
| 71 | 71 |
| 72 if (!paintInfo.shouldPaintWithinRoot(&m_layoutTableCell) || m_layoutTableCel l.style()->visibility() != VISIBLE) | 72 if (!paintInfo.shouldPaintWithinRoot(&m_layoutTableCell) || m_layoutTableCel l.style()->visibility() != VISIBLE) |
| 73 return; | 73 return; |
| 74 | 74 |
| 75 LayoutRect paintRect = paintBounds(paintOffset, AddOffsetFromParent); | |
| 76 | |
| 77 LayoutRect drawingCullRect(paintRect); | |
| 78 drawingCullRect.expandEdges(m_layoutTableCell.table()->outerBorderTop(), m_l ayoutTableCell.table()->outerBorderRight(), | |
| 79 m_layoutTableCell.table()->outerBorderBottom(), m_layoutTableCell.table( )->outerBorderLeft()); | |
| 80 if (drawingCullRect.y() >= paintInfo.rect.maxY()) | |
|
chrishtr
2015/06/04 22:21:06
You're removing a non-SP culling optimization. Was
Xianzhu
2015/06/05 00:02:14
The cullrect was incorrect (which doesn't cover al
| |
| 81 return; | |
| 82 | |
| 83 if (drawingCullRect.maxY() <= paintInfo.rect.y()) | |
| 84 return; | |
| 85 | |
| 86 const CollapsedBorderValue* tableCurrentBorderValue = m_layoutTableCell.tabl e()->currentBorderValue(); | 75 const CollapsedBorderValue* tableCurrentBorderValue = m_layoutTableCell.tabl e()->currentBorderValue(); |
| 87 if (!tableCurrentBorderValue) | 76 if (!tableCurrentBorderValue) |
| 88 return; | 77 return; |
| 89 | 78 |
| 90 const ComputedStyle& styleForCellFlow = m_layoutTableCell.styleForCellFlow() ; | 79 const ComputedStyle& styleForCellFlow = m_layoutTableCell.styleForCellFlow() ; |
| 91 const CollapsedBorderValue& leftBorderValue = cachedCollapsedLeftBorder(styl eForCellFlow); | 80 const CollapsedBorderValue& leftBorderValue = cachedCollapsedLeftBorder(styl eForCellFlow); |
| 92 const CollapsedBorderValue& rightBorderValue = cachedCollapsedRightBorder(st yleForCellFlow); | 81 const CollapsedBorderValue& rightBorderValue = cachedCollapsedRightBorder(st yleForCellFlow); |
| 93 const CollapsedBorderValue& topBorderValue = cachedCollapsedTopBorder(styleF orCellFlow); | 82 const CollapsedBorderValue& topBorderValue = cachedCollapsedTopBorder(styleF orCellFlow); |
| 94 const CollapsedBorderValue& bottomBorderValue = cachedCollapsedBottomBorder( styleForCellFlow); | 83 const CollapsedBorderValue& bottomBorderValue = cachedCollapsedBottomBorder( styleForCellFlow); |
| 95 | 84 |
| 96 bool shouldPaintTop = topBorderValue.shouldPaint(*tableCurrentBorderValue); | 85 bool shouldPaintTop = topBorderValue.shouldPaint(*tableCurrentBorderValue); |
| 97 bool shouldPaintBottom = bottomBorderValue.shouldPaint(*tableCurrentBorderVa lue); | 86 bool shouldPaintBottom = bottomBorderValue.shouldPaint(*tableCurrentBorderVa lue); |
| 98 bool shouldPaintLeft = leftBorderValue.shouldPaint(*tableCurrentBorderValue) ; | 87 bool shouldPaintLeft = leftBorderValue.shouldPaint(*tableCurrentBorderValue) ; |
| 99 bool shouldPaintRight = rightBorderValue.shouldPaint(*tableCurrentBorderValu e); | 88 bool shouldPaintRight = rightBorderValue.shouldPaint(*tableCurrentBorderValu e); |
| 100 | 89 |
| 101 if (!shouldPaintTop && !shouldPaintBottom && !shouldPaintLeft && !shouldPain tRight) | 90 if (!shouldPaintTop && !shouldPaintBottom && !shouldPaintLeft && !shouldPain tRight) |
| 102 return; | 91 return; |
| 103 | 92 |
| 104 GraphicsContext* graphicsContext = paintInfo.context; | |
| 105 LayoutObjectDrawingRecorder recorder(*graphicsContext, m_layoutTableCell, pa intInfo.phase, drawingCullRect); | |
| 106 if (recorder.canUseCachedDrawing()) | |
| 107 return; | |
| 108 | |
| 109 bool antialias = BoxPainter::shouldAntialiasLines(graphicsContext); | |
| 110 | |
| 111 // Adjust our x/y/width/height so that we paint the collapsed borders at the correct location. | 93 // Adjust our x/y/width/height so that we paint the collapsed borders at the correct location. |
| 112 int topWidth = topBorderValue.width(); | 94 int topWidth = topBorderValue.width(); |
| 113 int bottomWidth = bottomBorderValue.width(); | 95 int bottomWidth = bottomBorderValue.width(); |
| 114 int leftWidth = leftBorderValue.width(); | 96 int leftWidth = leftBorderValue.width(); |
| 115 int rightWidth = rightBorderValue.width(); | 97 int rightWidth = rightBorderValue.width(); |
| 116 | 98 |
| 99 LayoutRect paintRect = paintBounds(paintOffset, AddOffsetFromParent); | |
|
chrishtr
2015/06/05 00:31:06
This is not used?
Why not fix paintBounds?
Xianzhu
2015/06/05 00:40:58
Here paintRect is used to calculate borderRect bel
chrishtr
2015/06/05 04:55:28
Oh right, sorry. My comment was too hasty.
| |
| 117 IntRect borderRect = pixelSnappedIntRect(paintRect.x() - leftWidth / 2, | 100 IntRect borderRect = pixelSnappedIntRect(paintRect.x() - leftWidth / 2, |
| 118 paintRect.y() - topWidth / 2, | 101 paintRect.y() - topWidth / 2, |
| 119 paintRect.width() + leftWidth / 2 + (rightWidth + 1) / 2, | 102 paintRect.width() + leftWidth / 2 + (rightWidth + 1) / 2, |
| 120 paintRect.height() + topWidth / 2 + (bottomWidth + 1) / 2); | 103 paintRect.height() + topWidth / 2 + (bottomWidth + 1) / 2); |
| 121 | 104 |
| 105 if (!borderRect.intersects(paintInfo.rect)) | |
| 106 return; | |
| 107 | |
| 108 GraphicsContext* graphicsContext = paintInfo.context; | |
| 109 LayoutObjectDrawingRecorder recorder(*graphicsContext, m_layoutTableCell, pa intInfo.phase, borderRect); | |
| 110 if (recorder.canUseCachedDrawing()) | |
| 111 return; | |
| 112 | |
| 122 Color cellColor = m_layoutTableCell.resolveColor(CSSPropertyColor); | 113 Color cellColor = m_layoutTableCell.resolveColor(CSSPropertyColor); |
| 114 bool antialias = BoxPainter::shouldAntialiasLines(graphicsContext); | |
| 123 | 115 |
| 124 // We never paint diagonals at the joins. We simply let the border with the highest | 116 // We never paint diagonals at the joins. We simply let the border with the highest |
| 125 // precedence paint on top of borders with lower precedence. | 117 // precedence paint on top of borders with lower precedence. |
| 126 if (shouldPaintTop) { | 118 if (shouldPaintTop) { |
| 127 ObjectPainter::drawLineForBoxSide(graphicsContext, borderRect.x(), borde rRect.y(), borderRect.maxX(), borderRect.y() + topWidth, BSTop, | 119 ObjectPainter::drawLineForBoxSide(graphicsContext, borderRect.x(), borde rRect.y(), borderRect.maxX(), borderRect.y() + topWidth, BSTop, |
| 128 topBorderValue.color().resolve(cellColor), collapsedBorderStyle(topB orderValue.style()), 0, 0, antialias); | 120 topBorderValue.color().resolve(cellColor), collapsedBorderStyle(topB orderValue.style()), 0, 0, antialias); |
| 129 } | 121 } |
| 130 if (shouldPaintBottom) { | 122 if (shouldPaintBottom) { |
| 131 ObjectPainter::drawLineForBoxSide(graphicsContext, borderRect.x(), borde rRect.maxY() - bottomWidth, borderRect.maxX(), borderRect.maxY(), BSBottom, | 123 ObjectPainter::drawLineForBoxSide(graphicsContext, borderRect.x(), borde rRect.maxY() - bottomWidth, borderRect.maxX(), borderRect.maxY(), BSBottom, |
| 132 bottomBorderValue.color().resolve(cellColor), collapsedBorderStyle(b ottomBorderValue.style()), 0, 0, antialias); | 124 bottomBorderValue.color().resolve(cellColor), collapsedBorderStyle(b ottomBorderValue.style()), 0, 0, antialias); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 221 LayoutRect TableCellPainter::paintBounds(const LayoutPoint& paintOffset, PaintBo undOffsetBehavior paintBoundOffsetBehavior) | 213 LayoutRect TableCellPainter::paintBounds(const LayoutPoint& paintOffset, PaintBo undOffsetBehavior paintBoundOffsetBehavior) |
| 222 { | 214 { |
| 223 LayoutPoint adjustedPaintOffset = paintOffset; | 215 LayoutPoint adjustedPaintOffset = paintOffset; |
| 224 if (paintBoundOffsetBehavior == AddOffsetFromParent) | 216 if (paintBoundOffsetBehavior == AddOffsetFromParent) |
| 225 adjustedPaintOffset.moveBy(m_layoutTableCell.location()); | 217 adjustedPaintOffset.moveBy(m_layoutTableCell.location()); |
| 226 return LayoutRect(adjustedPaintOffset, LayoutSize(m_layoutTableCell.pixelSna ppedSize())); | 218 return LayoutRect(adjustedPaintOffset, LayoutSize(m_layoutTableCell.pixelSna ppedSize())); |
| 227 } | 219 } |
| 228 | 220 |
| 229 } // namespace blink | 221 } // namespace blink |
| 230 | 222 |
| OLD | NEW |