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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
62 | 62 |
63 static EBorderStyle collapsedBorderStyle(EBorderStyle style) { | 63 static EBorderStyle collapsedBorderStyle(EBorderStyle style) { |
64 if (style == BorderStyleOutset) | 64 if (style == BorderStyleOutset) |
65 return BorderStyleGroove; | 65 return BorderStyleGroove; |
66 if (style == BorderStyleInset) | 66 if (style == BorderStyleInset) |
67 return BorderStyleRidge; | 67 return BorderStyleRidge; |
68 return style; | 68 return style; |
69 } | 69 } |
70 | 70 |
71 const DisplayItemClient& TableCellPainter::displayItemClientForBorders() const { | 71 const DisplayItemClient& TableCellPainter::displayItemClientForBorders() const { |
72 // TODO(wkorman): We may need to handle PaintInvalidationDelayedFull. | 72 return m_layoutTableCell.usesCompositedCellDisplayItemClients() |
73 // http://crbug.com/657186 | |
74 return m_layoutTableCell.usesTableAsAdditionalDisplayItemClient() | |
75 ? static_cast<const DisplayItemClient&>( | 73 ? static_cast<const DisplayItemClient&>( |
76 *m_layoutTableCell.collapsedBorderValues()) | 74 *m_layoutTableCell.collapsedBorderValues()) |
77 : m_layoutTableCell; | 75 : m_layoutTableCell; |
78 } | 76 } |
79 | 77 |
78 const DisplayItemClient& TableCellPainter::displayItemClientForBackground() | |
79 const { | |
80 return m_layoutTableCell.usesCompositedCellDisplayItemClients() | |
81 ? static_cast<const DisplayItemClient&>( | |
82 *m_layoutTableCell.rowBackgroundDisplayItemClient()) | |
83 : m_layoutTableCell; | |
84 } | |
85 | |
80 void TableCellPainter::paintCollapsedBorders( | 86 void TableCellPainter::paintCollapsedBorders( |
81 const PaintInfo& paintInfo, | 87 const PaintInfo& paintInfo, |
82 const LayoutPoint& paintOffset, | 88 const LayoutPoint& paintOffset, |
83 const CollapsedBorderValue& currentBorderValue) { | 89 const CollapsedBorderValue& currentBorderValue) { |
84 if (m_layoutTableCell.style()->visibility() != EVisibility::Visible) | 90 if (m_layoutTableCell.style()->visibility() != EVisibility::Visible) |
85 return; | 91 return; |
86 | 92 |
87 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutTableCell.location(); | 93 LayoutPoint adjustedPaintOffset = paintOffset + m_layoutTableCell.location(); |
88 if (!BlockPainter(m_layoutTableCell) | 94 if (!BlockPainter(m_layoutTableCell) |
89 .intersectsPaintRect(paintInfo, adjustedPaintOffset)) | 95 .intersectsPaintRect(paintInfo, adjustedPaintOffset)) |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
188 if (!BlockPainter(m_layoutTableCell) | 194 if (!BlockPainter(m_layoutTableCell) |
189 .intersectsPaintRect(paintInfo, adjustedPaintOffset)) | 195 .intersectsPaintRect(paintInfo, adjustedPaintOffset)) |
190 return; | 196 return; |
191 | 197 |
192 LayoutTable* table = m_layoutTableCell.table(); | 198 LayoutTable* table = m_layoutTableCell.table(); |
193 if (!table->collapseBorders() && | 199 if (!table->collapseBorders() && |
194 m_layoutTableCell.style()->emptyCells() == EEmptyCells::Hide && | 200 m_layoutTableCell.style()->emptyCells() == EEmptyCells::Hide && |
195 !m_layoutTableCell.firstChild()) | 201 !m_layoutTableCell.firstChild()) |
196 return; | 202 return; |
197 | 203 |
198 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible( | 204 const DisplayItemClient& client = displayItemClientForBackground(); |
199 paintInfo.context, m_layoutTableCell, type)) | 205 if (DrawingRecorder::useCachedDrawingIfPossible(paintInfo.context, client, |
206 type)) | |
Xianzhu
2016/11/03 03:06:49
This seems incorrect when we paint background of t
wkorman
2016/11/03 04:02:39
Hmm, ok. I missed that this was called from non-ro
| |
200 return; | 207 return; |
201 | 208 |
202 LayoutRect paintRect = | 209 LayoutRect paintRect = |
203 paintRectNotIncludingVisualOverflow(adjustedPaintOffset); | 210 paintRectNotIncludingVisualOverflow(adjustedPaintOffset); |
204 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutTableCell, | 211 DrawingRecorder recorder(paintInfo.context, client, type, |
205 type, paintRect); | 212 FloatRect(paintRect)); |
206 paintBackground(paintInfo, paintRect, backgroundObject); | 213 paintBackground(paintInfo, paintRect, backgroundObject); |
207 } | 214 } |
208 | 215 |
209 void TableCellPainter::paintBackground(const PaintInfo& paintInfo, | 216 void TableCellPainter::paintBackground(const PaintInfo& paintInfo, |
210 const LayoutRect& paintRect, | 217 const LayoutRect& paintRect, |
211 const LayoutObject& backgroundObject) { | 218 const LayoutObject& backgroundObject) { |
212 if (m_layoutTableCell.backgroundStolenForBeingBody()) | 219 if (m_layoutTableCell.backgroundStolenForBeingBody()) |
213 return; | 220 return; |
214 | 221 |
215 Color c = backgroundObject.resolveColor(CSSPropertyBackgroundColor); | 222 Color c = backgroundObject.resolveColor(CSSPropertyBackgroundColor); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
298 BoxPainter(m_layoutTableCell).paintMaskImages(paintInfo, paintRect); | 305 BoxPainter(m_layoutTableCell).paintMaskImages(paintInfo, paintRect); |
299 } | 306 } |
300 | 307 |
301 LayoutRect TableCellPainter::paintRectNotIncludingVisualOverflow( | 308 LayoutRect TableCellPainter::paintRectNotIncludingVisualOverflow( |
302 const LayoutPoint& paintOffset) { | 309 const LayoutPoint& paintOffset) { |
303 return LayoutRect(paintOffset, | 310 return LayoutRect(paintOffset, |
304 LayoutSize(m_layoutTableCell.pixelSnappedSize())); | 311 LayoutSize(m_layoutTableCell.pixelSnappedSize())); |
305 } | 312 } |
306 | 313 |
307 } // namespace blink | 314 } // namespace blink |
OLD | NEW |