Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(544)

Side by Side Diff: third_party/WebKit/Source/core/paint/TableCellPainter.cpp

Issue 2469903002: Use appropriate background object visual rect for composited table cell backgrounds. (Closed)
Patch Set: Rename test. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 } 61 }
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&
72 TableCellPainter::displayItemClientRespectingCompositing() const {
72 // TODO(wkorman): We may need to handle PaintInvalidationDelayedFull. 73 // TODO(wkorman): We may need to handle PaintInvalidationDelayedFull.
73 // http://crbug.com/657186 74 // http://crbug.com/657186
74 return m_layoutTableCell.usesTableAsAdditionalDisplayItemClient() 75 return m_layoutTableCell.usesTableAsAdditionalDisplayItemClient()
75 ? static_cast<const DisplayItemClient&>( 76 ? static_cast<const DisplayItemClient&>(
76 *m_layoutTableCell.collapsedBorderValues()) 77 *m_layoutTableCell.compositedTableCell())
77 : m_layoutTableCell; 78 : m_layoutTableCell;
78 } 79 }
79 80
80 void TableCellPainter::paintCollapsedBorders( 81 void TableCellPainter::paintCollapsedBorders(
81 const PaintInfo& paintInfo, 82 const PaintInfo& paintInfo,
82 const LayoutPoint& paintOffset, 83 const LayoutPoint& paintOffset,
83 const CollapsedBorderValue& currentBorderValue) { 84 const CollapsedBorderValue& currentBorderValue) {
84 if (m_layoutTableCell.style()->visibility() != EVisibility::Visible) 85 if (m_layoutTableCell.style()->visibility() != EVisibility::Visible)
85 return; 86 return;
86 87
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 // Adjust our x/y/width/height so that we paint the collapsed borders at the 125 // Adjust our x/y/width/height so that we paint the collapsed borders at the
125 // correct location. 126 // correct location.
126 LayoutRect paintRect = 127 LayoutRect paintRect =
127 paintRectNotIncludingVisualOverflow(adjustedPaintOffset); 128 paintRectNotIncludingVisualOverflow(adjustedPaintOffset);
128 IntRect borderRect = pixelSnappedIntRect( 129 IntRect borderRect = pixelSnappedIntRect(
129 paintRect.x() - leftWidth / 2, paintRect.y() - topWidth / 2, 130 paintRect.x() - leftWidth / 2, paintRect.y() - topWidth / 2,
130 paintRect.width() + leftWidth / 2 + (rightWidth + 1) / 2, 131 paintRect.width() + leftWidth / 2 + (rightWidth + 1) / 2,
131 paintRect.height() + topWidth / 2 + (bottomWidth + 1) / 2); 132 paintRect.height() + topWidth / 2 + (bottomWidth + 1) / 2);
132 133
133 GraphicsContext& graphicsContext = paintInfo.context; 134 GraphicsContext& graphicsContext = paintInfo.context;
134 const DisplayItemClient& client = displayItemClientForBorders(); 135 const DisplayItemClient& client = displayItemClientRespectingCompositing();
135 if (DrawingRecorder::useCachedDrawingIfPossible( 136 if (DrawingRecorder::useCachedDrawingIfPossible(
136 graphicsContext, client, 137 graphicsContext, client,
137 static_cast<DisplayItem::Type>(displayItemType))) 138 static_cast<DisplayItem::Type>(displayItemType)))
138 return; 139 return;
139 140
140 DrawingRecorder recorder(graphicsContext, client, 141 DrawingRecorder recorder(graphicsContext, client,
141 static_cast<DisplayItem::Type>(displayItemType), 142 static_cast<DisplayItem::Type>(displayItemType),
142 borderRect); 143 borderRect);
143 Color cellColor = m_layoutTableCell.resolveColor(CSSPropertyColor); 144 Color cellColor = m_layoutTableCell.resolveColor(CSSPropertyColor);
144 145
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 if (!BlockPainter(m_layoutTableCell) 189 if (!BlockPainter(m_layoutTableCell)
189 .intersectsPaintRect(paintInfo, adjustedPaintOffset)) 190 .intersectsPaintRect(paintInfo, adjustedPaintOffset))
190 return; 191 return;
191 192
192 LayoutTable* table = m_layoutTableCell.table(); 193 LayoutTable* table = m_layoutTableCell.table();
193 if (!table->collapseBorders() && 194 if (!table->collapseBorders() &&
194 m_layoutTableCell.style()->emptyCells() == EEmptyCells::Hide && 195 m_layoutTableCell.style()->emptyCells() == EEmptyCells::Hide &&
195 !m_layoutTableCell.firstChild()) 196 !m_layoutTableCell.firstChild())
196 return; 197 return;
197 198
198 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible( 199 const DisplayItemClient& client = displayItemClientRespectingCompositing();
199 paintInfo.context, m_layoutTableCell, type)) 200 if (DrawingRecorder::useCachedDrawingIfPossible(paintInfo.context, client,
201 type))
200 return; 202 return;
201 203
202 LayoutRect paintRect = 204 LayoutRect paintRect =
203 paintRectNotIncludingVisualOverflow(adjustedPaintOffset); 205 paintRectNotIncludingVisualOverflow(adjustedPaintOffset);
204 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutTableCell, 206 DrawingRecorder recorder(paintInfo.context, client, type,
205 type, paintRect); 207 FloatRect(paintRect));
206 paintBackground(paintInfo, paintRect, backgroundObject); 208 paintBackground(paintInfo, paintRect, backgroundObject);
207 } 209 }
208 210
209 void TableCellPainter::paintBackground(const PaintInfo& paintInfo, 211 void TableCellPainter::paintBackground(const PaintInfo& paintInfo,
210 const LayoutRect& paintRect, 212 const LayoutRect& paintRect,
211 const LayoutObject& backgroundObject) { 213 const LayoutObject& backgroundObject) {
212 if (m_layoutTableCell.backgroundStolenForBeingBody()) 214 if (m_layoutTableCell.backgroundStolenForBeingBody())
213 return; 215 return;
214 216
215 Color c = backgroundObject.resolveColor(CSSPropertyBackgroundColor); 217 Color c = backgroundObject.resolveColor(CSSPropertyBackgroundColor);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 BoxPainter(m_layoutTableCell).paintMaskImages(paintInfo, paintRect); 300 BoxPainter(m_layoutTableCell).paintMaskImages(paintInfo, paintRect);
299 } 301 }
300 302
301 LayoutRect TableCellPainter::paintRectNotIncludingVisualOverflow( 303 LayoutRect TableCellPainter::paintRectNotIncludingVisualOverflow(
302 const LayoutPoint& paintOffset) { 304 const LayoutPoint& paintOffset) {
303 return LayoutRect(paintOffset, 305 return LayoutRect(paintOffset,
304 LayoutSize(m_layoutTableCell.pixelSnappedSize())); 306 LayoutSize(m_layoutTableCell.pixelSnappedSize()));
305 } 307 }
306 308
307 } // namespace blink 309 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698