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/TableCellPainter.h" | 5 #include "core/paint/TableCellPainter.h" |
6 | 6 |
7 #include "core/layout/LayoutTableCell.h" | 7 #include "core/layout/LayoutTableCell.h" |
8 #include "core/paint/BlockPainter.h" | 8 #include "core/paint/BlockPainter.h" |
9 #include "core/paint/BoxPainter.h" | 9 #include "core/paint/BoxPainter.h" |
10 #include "core/paint/LayoutObjectDrawingRecorder.h" | 10 #include "core/paint/LayoutObjectDrawingRecorder.h" |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 if (rightBorderValue.shouldPaint(currentBorderValue)) | 102 if (rightBorderValue.shouldPaint(currentBorderValue)) |
103 displayItemType |= DisplayItem::TableCollapsedBorderRight; | 103 displayItemType |= DisplayItem::TableCollapsedBorderRight; |
104 if (displayItemType == DisplayItem::kTableCollapsedBorderBase) | 104 if (displayItemType == DisplayItem::kTableCollapsedBorderBase) |
105 return; | 105 return; |
106 | 106 |
107 int topWidth = topBorderValue.width(); | 107 int topWidth = topBorderValue.width(); |
108 int bottomWidth = bottomBorderValue.width(); | 108 int bottomWidth = bottomBorderValue.width(); |
109 int leftWidth = leftBorderValue.width(); | 109 int leftWidth = leftBorderValue.width(); |
110 int rightWidth = rightBorderValue.width(); | 110 int rightWidth = rightBorderValue.width(); |
111 | 111 |
112 // Adjust our x/y/width/height so that we paint the collapsed borders at the c
orrect location. | 112 // Adjust our x/y/width/height so that we paint the collapsed borders at the |
| 113 // correct location. |
113 LayoutRect paintRect = | 114 LayoutRect paintRect = |
114 paintRectNotIncludingVisualOverflow(adjustedPaintOffset); | 115 paintRectNotIncludingVisualOverflow(adjustedPaintOffset); |
115 IntRect borderRect = pixelSnappedIntRect( | 116 IntRect borderRect = pixelSnappedIntRect( |
116 paintRect.x() - leftWidth / 2, paintRect.y() - topWidth / 2, | 117 paintRect.x() - leftWidth / 2, paintRect.y() - topWidth / 2, |
117 paintRect.width() + leftWidth / 2 + (rightWidth + 1) / 2, | 118 paintRect.width() + leftWidth / 2 + (rightWidth + 1) / 2, |
118 paintRect.height() + topWidth / 2 + (bottomWidth + 1) / 2); | 119 paintRect.height() + topWidth / 2 + (bottomWidth + 1) / 2); |
119 | 120 |
120 GraphicsContext& graphicsContext = paintInfo.context; | 121 GraphicsContext& graphicsContext = paintInfo.context; |
121 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible( | 122 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible( |
122 graphicsContext, m_layoutTableCell, | 123 graphicsContext, m_layoutTableCell, |
123 static_cast<DisplayItem::Type>(displayItemType))) | 124 static_cast<DisplayItem::Type>(displayItemType))) |
124 return; | 125 return; |
125 | 126 |
126 LayoutObjectDrawingRecorder recorder( | 127 LayoutObjectDrawingRecorder recorder( |
127 graphicsContext, m_layoutTableCell, | 128 graphicsContext, m_layoutTableCell, |
128 static_cast<DisplayItem::Type>(displayItemType), borderRect); | 129 static_cast<DisplayItem::Type>(displayItemType), borderRect); |
129 Color cellColor = m_layoutTableCell.resolveColor(CSSPropertyColor); | 130 Color cellColor = m_layoutTableCell.resolveColor(CSSPropertyColor); |
130 | 131 |
131 // We never paint diagonals at the joins. We simply let the border with the h
ighest | 132 // We never paint diagonals at the joins. We simply let the border with the |
132 // precedence paint on top of borders with lower precedence. | 133 // highest precedence paint on top of borders with lower precedence. |
133 if (displayItemType & DisplayItem::TableCollapsedBorderTop) { | 134 if (displayItemType & DisplayItem::TableCollapsedBorderTop) { |
134 ObjectPainter::drawLineForBoxSide( | 135 ObjectPainter::drawLineForBoxSide( |
135 graphicsContext, borderRect.x(), borderRect.y(), borderRect.maxX(), | 136 graphicsContext, borderRect.x(), borderRect.y(), borderRect.maxX(), |
136 borderRect.y() + topWidth, BSTop, | 137 borderRect.y() + topWidth, BSTop, |
137 topBorderValue.color().resolve(cellColor), | 138 topBorderValue.color().resolve(cellColor), |
138 collapsedBorderStyle(topBorderValue.style()), 0, 0, true); | 139 collapsedBorderStyle(topBorderValue.style()), 0, 0, true); |
139 } | 140 } |
140 if (displayItemType & DisplayItem::TableCollapsedBorderBottom) { | 141 if (displayItemType & DisplayItem::TableCollapsedBorderBottom) { |
141 ObjectPainter::drawLineForBoxSide( | 142 ObjectPainter::drawLineForBoxSide( |
142 graphicsContext, borderRect.x(), borderRect.maxY() - bottomWidth, | 143 graphicsContext, borderRect.x(), borderRect.maxY() - bottomWidth, |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 BoxPainter(m_layoutTableCell).paintMaskImages(paintInfo, paintRect); | 285 BoxPainter(m_layoutTableCell).paintMaskImages(paintInfo, paintRect); |
285 } | 286 } |
286 | 287 |
287 LayoutRect TableCellPainter::paintRectNotIncludingVisualOverflow( | 288 LayoutRect TableCellPainter::paintRectNotIncludingVisualOverflow( |
288 const LayoutPoint& paintOffset) { | 289 const LayoutPoint& paintOffset) { |
289 return LayoutRect(paintOffset, | 290 return LayoutRect(paintOffset, |
290 LayoutSize(m_layoutTableCell.pixelSnappedSize())); | 291 LayoutSize(m_layoutTableCell.pixelSnappedSize())); |
291 } | 292 } |
292 | 293 |
293 } // namespace blink | 294 } // namespace blink |
OLD | NEW |