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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 const CollapsedBorderValue* tableCurrentBorderValue = m_layoutTableCell.tabl
e()->currentBorderValue(); | 76 const CollapsedBorderValue* tableCurrentBorderValue = m_layoutTableCell.tabl
e()->currentBorderValue(); |
77 if (!tableCurrentBorderValue) | 77 if (!tableCurrentBorderValue) |
78 return; | 78 return; |
79 | 79 |
80 const ComputedStyle& styleForCellFlow = m_layoutTableCell.styleForCellFlow()
; | 80 const ComputedStyle& styleForCellFlow = m_layoutTableCell.styleForCellFlow()
; |
81 const CollapsedBorderValue& leftBorderValue = cachedCollapsedLeftBorder(styl
eForCellFlow); | 81 const CollapsedBorderValue& leftBorderValue = cachedCollapsedLeftBorder(styl
eForCellFlow); |
82 const CollapsedBorderValue& rightBorderValue = cachedCollapsedRightBorder(st
yleForCellFlow); | 82 const CollapsedBorderValue& rightBorderValue = cachedCollapsedRightBorder(st
yleForCellFlow); |
83 const CollapsedBorderValue& topBorderValue = cachedCollapsedTopBorder(styleF
orCellFlow); | 83 const CollapsedBorderValue& topBorderValue = cachedCollapsedTopBorder(styleF
orCellFlow); |
84 const CollapsedBorderValue& bottomBorderValue = cachedCollapsedBottomBorder(
styleForCellFlow); | 84 const CollapsedBorderValue& bottomBorderValue = cachedCollapsedBottomBorder(
styleForCellFlow); |
85 | 85 |
86 bool shouldPaintTop = topBorderValue.shouldPaint(*tableCurrentBorderValue); | 86 int displayItemType = DisplayItem::TableCollapsedBorderBase; |
87 bool shouldPaintBottom = bottomBorderValue.shouldPaint(*tableCurrentBorderVa
lue); | 87 if (topBorderValue.shouldPaint(*tableCurrentBorderValue)) |
88 bool shouldPaintLeft = leftBorderValue.shouldPaint(*tableCurrentBorderValue)
; | 88 displayItemType |= DisplayItem::TableCollapsedBorderTop; |
89 bool shouldPaintRight = rightBorderValue.shouldPaint(*tableCurrentBorderValu
e); | 89 if (bottomBorderValue.shouldPaint(*tableCurrentBorderValue)) |
| 90 displayItemType |= DisplayItem::TableCollapsedBorderBottom; |
| 91 if (leftBorderValue.shouldPaint(*tableCurrentBorderValue)) |
| 92 displayItemType |= DisplayItem::TableCollapsedBorderLeft; |
| 93 if (rightBorderValue.shouldPaint(*tableCurrentBorderValue)) |
| 94 displayItemType |= DisplayItem::TableCollapsedBorderRight; |
90 | 95 |
91 if (!shouldPaintTop && !shouldPaintBottom && !shouldPaintLeft && !shouldPain
tRight) | 96 if (displayItemType == DisplayItem::TableCollapsedBorderBase) |
92 return; | 97 return; |
93 | 98 |
94 // Adjust our x/y/width/height so that we paint the collapsed borders at the
correct location. | 99 // Adjust our x/y/width/height so that we paint the collapsed borders at the
correct location. |
95 int topWidth = topBorderValue.width(); | 100 int topWidth = topBorderValue.width(); |
96 int bottomWidth = bottomBorderValue.width(); | 101 int bottomWidth = bottomBorderValue.width(); |
97 int leftWidth = leftBorderValue.width(); | 102 int leftWidth = leftBorderValue.width(); |
98 int rightWidth = rightBorderValue.width(); | 103 int rightWidth = rightBorderValue.width(); |
99 | 104 |
100 LayoutRect paintRect = paintBounds(paintOffset, AddOffsetFromParent); | 105 LayoutRect paintRect = paintBounds(paintOffset, AddOffsetFromParent); |
101 IntRect borderRect = pixelSnappedIntRect(paintRect.x() - leftWidth / 2, | 106 IntRect borderRect = pixelSnappedIntRect(paintRect.x() - leftWidth / 2, |
102 paintRect.y() - topWidth / 2, | 107 paintRect.y() - topWidth / 2, |
103 paintRect.width() + leftWidth / 2 + (rightWidth + 1) / 2, | 108 paintRect.width() + leftWidth / 2 + (rightWidth + 1) / 2, |
104 paintRect.height() + topWidth / 2 + (bottomWidth + 1) / 2); | 109 paintRect.height() + topWidth / 2 + (bottomWidth + 1) / 2); |
105 | 110 |
106 if (!borderRect.intersects(paintInfo.rect)) | 111 if (!borderRect.intersects(paintInfo.rect)) |
107 return; | 112 return; |
108 | 113 |
109 GraphicsContext* graphicsContext = paintInfo.context; | 114 GraphicsContext* graphicsContext = paintInfo.context; |
110 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*graphicsContext
, m_layoutTableCell, paintInfo.phase)) | 115 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(*graphicsContext
, m_layoutTableCell, static_cast<DisplayItem::Type>(displayItemType))) |
111 return; | 116 return; |
112 | 117 |
113 LayoutObjectDrawingRecorder recorder(*graphicsContext, m_layoutTableCell, pa
intInfo.phase, borderRect); | 118 LayoutObjectDrawingRecorder recorder(*graphicsContext, m_layoutTableCell, st
atic_cast<DisplayItem::Type>(displayItemType), borderRect); |
114 Color cellColor = m_layoutTableCell.resolveColor(CSSPropertyColor); | 119 Color cellColor = m_layoutTableCell.resolveColor(CSSPropertyColor); |
115 bool antialias = BoxPainter::shouldAntialiasLines(graphicsContext); | 120 bool antialias = BoxPainter::shouldAntialiasLines(graphicsContext); |
116 | 121 |
117 // 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 |
118 // precedence paint on top of borders with lower precedence. | 123 // precedence paint on top of borders with lower precedence. |
119 if (shouldPaintTop) { | 124 if (displayItemType & DisplayItem::TableCollapsedBorderTop) { |
120 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, |
121 topBorderValue.color().resolve(cellColor), collapsedBorderStyle(topB
orderValue.style()), 0, 0, antialias); | 126 topBorderValue.color().resolve(cellColor), collapsedBorderStyle(topB
orderValue.style()), 0, 0, antialias); |
122 } | 127 } |
123 if (shouldPaintBottom) { | 128 if (displayItemType & DisplayItem::TableCollapsedBorderBottom) { |
124 ObjectPainter::drawLineForBoxSide(graphicsContext, borderRect.x(), borde
rRect.maxY() - bottomWidth, borderRect.maxX(), borderRect.maxY(), BSBottom, | 129 ObjectPainter::drawLineForBoxSide(graphicsContext, borderRect.x(), borde
rRect.maxY() - bottomWidth, borderRect.maxX(), borderRect.maxY(), BSBottom, |
125 bottomBorderValue.color().resolve(cellColor), collapsedBorderStyle(b
ottomBorderValue.style()), 0, 0, antialias); | 130 bottomBorderValue.color().resolve(cellColor), collapsedBorderStyle(b
ottomBorderValue.style()), 0, 0, antialias); |
126 } | 131 } |
127 if (shouldPaintLeft) { | 132 if (displayItemType & DisplayItem::TableCollapsedBorderLeft) { |
128 ObjectPainter::drawLineForBoxSide(graphicsContext, borderRect.x(), borde
rRect.y(), borderRect.x() + leftWidth, borderRect.maxY(), BSLeft, | 133 ObjectPainter::drawLineForBoxSide(graphicsContext, borderRect.x(), borde
rRect.y(), borderRect.x() + leftWidth, borderRect.maxY(), BSLeft, |
129 leftBorderValue.color().resolve(cellColor), collapsedBorderStyle(lef
tBorderValue.style()), 0, 0, antialias); | 134 leftBorderValue.color().resolve(cellColor), collapsedBorderStyle(lef
tBorderValue.style()), 0, 0, antialias); |
130 } | 135 } |
131 if (shouldPaintRight) { | 136 if (displayItemType & DisplayItem::TableCollapsedBorderRight) { |
132 ObjectPainter::drawLineForBoxSide(graphicsContext, borderRect.maxX() - r
ightWidth, borderRect.y(), borderRect.maxX(), borderRect.maxY(), BSRight, | 137 ObjectPainter::drawLineForBoxSide(graphicsContext, borderRect.maxX() - r
ightWidth, borderRect.y(), borderRect.maxX(), borderRect.maxY(), BSRight, |
133 rightBorderValue.color().resolve(cellColor), collapsedBorderStyle(ri
ghtBorderValue.style()), 0, 0, antialias); | 138 rightBorderValue.color().resolve(cellColor), collapsedBorderStyle(ri
ghtBorderValue.style()), 0, 0, antialias); |
134 } | 139 } |
135 } | 140 } |
136 | 141 |
137 void TableCellPainter::paintBackgroundsBehindCell(const PaintInfo& paintInfo, co
nst LayoutPoint& paintOffset, LayoutObject* backgroundObject) | 142 void TableCellPainter::paintBackgroundsBehindCell(const PaintInfo& paintInfo, co
nst LayoutPoint& paintOffset, LayoutObject* backgroundObject) |
138 { | 143 { |
139 if (!paintInfo.shouldPaintWithinRoot(&m_layoutTableCell)) | 144 if (!paintInfo.shouldPaintWithinRoot(&m_layoutTableCell)) |
140 return; | 145 return; |
141 | 146 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 LayoutRect TableCellPainter::paintBounds(const LayoutPoint& paintOffset, PaintBo
undOffsetBehavior paintBoundOffsetBehavior) | 228 LayoutRect TableCellPainter::paintBounds(const LayoutPoint& paintOffset, PaintBo
undOffsetBehavior paintBoundOffsetBehavior) |
224 { | 229 { |
225 LayoutPoint adjustedPaintOffset = paintOffset; | 230 LayoutPoint adjustedPaintOffset = paintOffset; |
226 if (paintBoundOffsetBehavior == AddOffsetFromParent) | 231 if (paintBoundOffsetBehavior == AddOffsetFromParent) |
227 adjustedPaintOffset.moveBy(m_layoutTableCell.location()); | 232 adjustedPaintOffset.moveBy(m_layoutTableCell.location()); |
228 return LayoutRect(adjustedPaintOffset, LayoutSize(m_layoutTableCell.pixelSna
ppedSize())); | 233 return LayoutRect(adjustedPaintOffset, LayoutSize(m_layoutTableCell.pixelSna
ppedSize())); |
229 } | 234 } |
230 | 235 |
231 } // namespace blink | 236 } // namespace blink |
232 | 237 |
OLD | NEW |