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

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

Issue 1391753005: (WIP) Invalidation during painting (for synchronized painting) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 LayoutPoint adjustedPaintOffset = paintRect.location(); 108 LayoutPoint adjustedPaintOffset = paintRect.location();
109 IntRect borderRect = pixelSnappedIntRect(paintRect.x() - leftWidth / 2, 109 IntRect borderRect = pixelSnappedIntRect(paintRect.x() - leftWidth / 2,
110 paintRect.y() - topWidth / 2, 110 paintRect.y() - topWidth / 2,
111 paintRect.width() + leftWidth / 2 + (rightWidth + 1) / 2, 111 paintRect.width() + leftWidth / 2 + (rightWidth + 1) / 2,
112 paintRect.height() + topWidth / 2 + (bottomWidth + 1) / 2); 112 paintRect.height() + topWidth / 2 + (bottomWidth + 1) / 2);
113 113
114 if (!paintInfo.cullRect().intersectsCullRect(borderRect)) 114 if (!paintInfo.cullRect().intersectsCullRect(borderRect))
115 return; 115 return;
116 116
117 GraphicsContext& graphicsContext = paintInfo.context; 117 GraphicsContext& graphicsContext = paintInfo.context;
118 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(graphicsContext, m_layoutTableCell, static_cast<DisplayItem::Type>(displayItemType), adjustedPai ntOffset)) 118 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(graphicsContext, m_layoutTableCell, static_cast<DisplayItem::Type>(displayItemType)))
119 return; 119 return;
120 120
121 LayoutObjectDrawingRecorder recorder(graphicsContext, m_layoutTableCell, sta tic_cast<DisplayItem::Type>(displayItemType), borderRect, adjustedPaintOffset); 121 LayoutObjectDrawingRecorder recorder(graphicsContext, m_layoutTableCell, sta tic_cast<DisplayItem::Type>(displayItemType), borderRect);
122 Color cellColor = m_layoutTableCell.resolveColor(CSSPropertyColor); 122 Color cellColor = m_layoutTableCell.resolveColor(CSSPropertyColor);
123 123
124 // We never paint diagonals at the joins. We simply let the border with the highest 124 // 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. 125 // precedence paint on top of borders with lower precedence.
126 if (displayItemType & DisplayItem::TableCollapsedBorderTop) { 126 if (displayItemType & DisplayItem::TableCollapsedBorderTop) {
127 ObjectPainter::drawLineForBoxSide(graphicsContext, borderRect.x(), borde rRect.y(), borderRect.maxX(), borderRect.y() + topWidth, BSTop, 127 ObjectPainter::drawLineForBoxSide(graphicsContext, borderRect.x(), borde rRect.y(), borderRect.maxX(), borderRect.y() + topWidth, BSTop,
128 topBorderValue->color().resolve(cellColor), collapsedBorderStyle(top BorderValue->style()), 0, 0, true); 128 topBorderValue->color().resolve(cellColor), collapsedBorderStyle(top BorderValue->style()), 0, 0, true);
129 } 129 }
130 if (displayItemType & DisplayItem::TableCollapsedBorderBottom) { 130 if (displayItemType & DisplayItem::TableCollapsedBorderBottom) {
131 ObjectPainter::drawLineForBoxSide(graphicsContext, borderRect.x(), borde rRect.maxY() - bottomWidth, borderRect.maxX(), borderRect.maxY(), BSBottom, 131 ObjectPainter::drawLineForBoxSide(graphicsContext, borderRect.x(), borde rRect.maxY() - bottomWidth, borderRect.maxX(), borderRect.maxY(), BSBottom,
(...skipping 20 matching lines...) Expand all
152 LayoutTable* tableElt = m_layoutTableCell.table(); 152 LayoutTable* tableElt = m_layoutTableCell.table();
153 if (!tableElt->collapseBorders() && m_layoutTableCell.style()->emptyCells() == HIDE && !m_layoutTableCell.firstChild()) 153 if (!tableElt->collapseBorders() && m_layoutTableCell.style()->emptyCells() == HIDE && !m_layoutTableCell.firstChild())
154 return; 154 return;
155 155
156 LayoutRect paintRect = paintBounds(paintOffset, backgroundObject != &m_layou tTableCell ? AddOffsetFromParent : DoNotAddOffsetFromParent); 156 LayoutRect paintRect = paintBounds(paintOffset, backgroundObject != &m_layou tTableCell ? AddOffsetFromParent : DoNotAddOffsetFromParent);
157 157
158 // Record drawing only if the cell is painting background from containers. 158 // Record drawing only if the cell is painting background from containers.
159 Optional<LayoutObjectDrawingRecorder> recorder; 159 Optional<LayoutObjectDrawingRecorder> recorder;
160 if (backgroundObject != &m_layoutTableCell) { 160 if (backgroundObject != &m_layoutTableCell) {
161 LayoutPoint adjustedPaintOffset = paintRect.location(); 161 LayoutPoint adjustedPaintOffset = paintRect.location();
162 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.co ntext, m_layoutTableCell, type, adjustedPaintOffset)) 162 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.co ntext, m_layoutTableCell, type))
163 return; 163 return;
164 recorder.emplace(paintInfo.context, m_layoutTableCell, type, paintRect, adjustedPaintOffset); 164 recorder.emplace(paintInfo.context, m_layoutTableCell, type, paintRect, adjustedPaintOffset);
165 } else { 165 } else {
166 ASSERT(paintRect.location() == paintOffset); 166 ASSERT(paintRect.location() == paintOffset);
167 } 167 }
168 168
169 Color c = backgroundObject->resolveColor(CSSPropertyBackgroundColor); 169 Color c = backgroundObject->resolveColor(CSSPropertyBackgroundColor);
170 const FillLayer& bgLayer = backgroundObject->style()->backgroundLayers(); 170 const FillLayer& bgLayer = backgroundObject->style()->backgroundLayers();
171 if (bgLayer.hasImage() || c.alpha()) { 171 if (bgLayer.hasImage() || c.alpha()) {
172 // We have to clip here because the background would paint 172 // We have to clip here because the background would paint
(...skipping 12 matching lines...) Expand all
185 void TableCellPainter::paintBoxDecorationBackground(const PaintInfo& paintInfo, const LayoutPoint& paintOffset) 185 void TableCellPainter::paintBoxDecorationBackground(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
186 { 186 {
187 LayoutTable* table = m_layoutTableCell.table(); 187 LayoutTable* table = m_layoutTableCell.table();
188 if (!table->collapseBorders() && m_layoutTableCell.style()->emptyCells() == HIDE && !m_layoutTableCell.firstChild()) 188 if (!table->collapseBorders() && m_layoutTableCell.style()->emptyCells() == HIDE && !m_layoutTableCell.firstChild())
189 return; 189 return;
190 190
191 bool needsToPaintBorder = m_layoutTableCell.styleRef().hasBorderDecoration() && !table->collapseBorders(); 191 bool needsToPaintBorder = m_layoutTableCell.styleRef().hasBorderDecoration() && !table->collapseBorders();
192 if (!m_layoutTableCell.hasBackground() && !m_layoutTableCell.styleRef().boxS hadow() && !needsToPaintBorder) 192 if (!m_layoutTableCell.hasBackground() && !m_layoutTableCell.styleRef().boxS hadow() && !needsToPaintBorder)
193 return; 193 return;
194 194
195 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex t, m_layoutTableCell, DisplayItem::BoxDecorationBackground, paintOffset)) 195 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex t, m_layoutTableCell, DisplayItem::BoxDecorationBackground))
196 return; 196 return;
197 197
198 LayoutRect visualOverflowRect = m_layoutTableCell.visualOverflowRect(); 198 LayoutRect visualOverflowRect = m_layoutTableCell.visualOverflowRect();
199 visualOverflowRect.moveBy(paintOffset); 199 visualOverflowRect.moveBy(paintOffset);
200 // TODO(chrishtr): the pixel-snapping here is likely incorrect. 200 // TODO(chrishtr): the pixel-snapping here is likely incorrect.
201 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutTableCell, D isplayItem::BoxDecorationBackground, pixelSnappedIntRect(visualOverflowRect), pa intOffset); 201 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutTableCell, D isplayItem::BoxDecorationBackground, pixelSnappedIntRect(visualOverflowRect));
202 202
203 LayoutRect paintRect = paintBounds(paintOffset, DoNotAddOffsetFromParent); 203 LayoutRect paintRect = paintBounds(paintOffset, DoNotAddOffsetFromParent);
204 204
205 BoxPainter::paintBoxShadow(paintInfo, paintRect, m_layoutTableCell.styleRef( ), Normal); 205 BoxPainter::paintBoxShadow(paintInfo, paintRect, m_layoutTableCell.styleRef( ), Normal);
206 206
207 // Paint our cell background. 207 // Paint our cell background.
208 paintBackgroundsBehindCell(paintInfo, paintOffset, &m_layoutTableCell, Displ ayItem::BoxDecorationBackground); 208 paintBackgroundsBehindCell(paintInfo, paintOffset, &m_layoutTableCell, Displ ayItem::BoxDecorationBackground);
209 209
210 BoxPainter::paintBoxShadow(paintInfo, paintRect, m_layoutTableCell.styleRef( ), Inset); 210 BoxPainter::paintBoxShadow(paintInfo, paintRect, m_layoutTableCell.styleRef( ), Inset);
211 211
212 if (!needsToPaintBorder) 212 if (!needsToPaintBorder)
213 return; 213 return;
214 214
215 BoxPainter::paintBorder(m_layoutTableCell, paintInfo, paintRect, m_layoutTab leCell.styleRef()); 215 BoxPainter::paintBorder(m_layoutTableCell, paintInfo, paintRect, m_layoutTab leCell.styleRef());
216 } 216 }
217 217
218 void TableCellPainter::paintMask(const PaintInfo& paintInfo, const LayoutPoint& paintOffset) 218 void TableCellPainter::paintMask(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
219 { 219 {
220 if (m_layoutTableCell.style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask) 220 if (m_layoutTableCell.style()->visibility() != VISIBLE || paintInfo.phase != PaintPhaseMask)
221 return; 221 return;
222 222
223 LayoutTable* tableElt = m_layoutTableCell.table(); 223 LayoutTable* tableElt = m_layoutTableCell.table();
224 if (!tableElt->collapseBorders() && m_layoutTableCell.style()->emptyCells() == HIDE && !m_layoutTableCell.firstChild()) 224 if (!tableElt->collapseBorders() && m_layoutTableCell.style()->emptyCells() == HIDE && !m_layoutTableCell.firstChild())
225 return; 225 return;
226 226
227 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex t, m_layoutTableCell, paintInfo.phase, paintOffset)) 227 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex t, m_layoutTableCell, paintInfo.phase))
228 return; 228 return;
229 229
230 LayoutRect paintRect = paintBounds(paintOffset, DoNotAddOffsetFromParent); 230 LayoutRect paintRect = paintBounds(paintOffset, DoNotAddOffsetFromParent);
231 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutTableCell, p aintInfo.phase, paintRect, paintOffset); 231 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutTableCell, p aintInfo.phase, paintRect);
232 BoxPainter(m_layoutTableCell).paintMaskImages(paintInfo, paintRect); 232 BoxPainter(m_layoutTableCell).paintMaskImages(paintInfo, paintRect);
233 } 233 }
234 234
235 LayoutRect TableCellPainter::paintBounds(const LayoutPoint& paintOffset, PaintBo undOffsetBehavior paintBoundOffsetBehavior) 235 LayoutRect TableCellPainter::paintBounds(const LayoutPoint& paintOffset, PaintBo undOffsetBehavior paintBoundOffsetBehavior)
236 { 236 {
237 LayoutPoint adjustedPaintOffset = paintOffset; 237 LayoutPoint adjustedPaintOffset = paintOffset;
238 if (paintBoundOffsetBehavior == AddOffsetFromParent) 238 if (paintBoundOffsetBehavior == AddOffsetFromParent)
239 adjustedPaintOffset.moveBy(m_layoutTableCell.location()); 239 adjustedPaintOffset.moveBy(m_layoutTableCell.location());
240 return LayoutRect(adjustedPaintOffset, LayoutSize(m_layoutTableCell.pixelSna ppedSize())); 240 return LayoutRect(adjustedPaintOffset, LayoutSize(m_layoutTableCell.pixelSna ppedSize()));
241 } 241 }
242 242
243 } // namespace blink 243 } // namespace blink
244 244
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/ScrollableAreaPainter.cpp ('k') | third_party/WebKit/Source/core/paint/TablePainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698