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

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

Issue 1963313002: Implement box-shadow for table section and row (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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/TableSectionPainter.h" 5 #include "core/paint/TableSectionPainter.h"
6 6
7 #include "core/layout/LayoutTableCell.h" 7 #include "core/layout/LayoutTableCell.h"
8 #include "core/layout/LayoutTableCol.h" 8 #include "core/layout/LayoutTableCol.h"
9 #include "core/layout/LayoutTableRow.h" 9 #include "core/layout/LayoutTableRow.h"
10 #include "core/paint/BoxClipper.h" 10 #include "core/paint/BoxClipper.h"
11 #include "core/paint/BoxPainter.h"
12 #include "core/paint/LayoutObjectDrawingRecorder.h"
11 #include "core/paint/ObjectPainter.h" 13 #include "core/paint/ObjectPainter.h"
12 #include "core/paint/PaintInfo.h" 14 #include "core/paint/PaintInfo.h"
13 #include "core/paint/TableCellPainter.h" 15 #include "core/paint/TableCellPainter.h"
14 #include "core/paint/TableRowPainter.h" 16 #include "core/paint/TableRowPainter.h"
15 #include <algorithm> 17 #include <algorithm>
16 18
17 namespace blink { 19 namespace blink {
18 20
19 inline const LayoutTableCell* TableSectionPainter::primaryCellToPaint(unsigned r ow, unsigned column, const CellSpan& dirtiedRows, const CellSpan& dirtiedColumns ) const 21 inline const LayoutTableCell* TableSectionPainter::primaryCellToPaint(unsigned r ow, unsigned column, const CellSpan& dirtiedRows, const CellSpan& dirtiedColumns ) const
20 { 22 {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 120
119 CellSpan dirtiedRows = m_layoutTableSection.dirtiedRows(tableAlignedRect); 121 CellSpan dirtiedRows = m_layoutTableSection.dirtiedRows(tableAlignedRect);
120 CellSpan dirtiedColumns = m_layoutTableSection.dirtiedEffectiveColumns(table AlignedRect); 122 CellSpan dirtiedColumns = m_layoutTableSection.dirtiedEffectiveColumns(table AlignedRect);
121 123
122 if (dirtiedColumns.start() >= dirtiedColumns.end()) 124 if (dirtiedColumns.start() >= dirtiedColumns.end())
123 return; 125 return;
124 126
125 PaintInfo paintInfoForDescendants = paintInfo.forDescendants(); 127 PaintInfo paintInfoForDescendants = paintInfo.forDescendants();
126 128
127 if (shouldPaintSelfBlockBackground(paintInfo.phase)) { 129 if (shouldPaintSelfBlockBackground(paintInfo.phase)) {
130 paintBoxShadow(paintInfo, paintOffset, Normal);
128 for (unsigned r = dirtiedRows.start(); r < dirtiedRows.end(); r++) { 131 for (unsigned r = dirtiedRows.start(); r < dirtiedRows.end(); r++) {
129 for (unsigned c = dirtiedColumns.start(); c < dirtiedColumns.end(); c++) { 132 for (unsigned c = dirtiedColumns.start(); c < dirtiedColumns.end(); c++) {
130 if (const LayoutTableCell* cell = primaryCellToPaint(r, c, dirti edRows, dirtiedColumns)) 133 if (const LayoutTableCell* cell = primaryCellToPaint(r, c, dirti edRows, dirtiedColumns))
131 paintBackgroundsBehindCell(*cell, paintInfoForDescendants, p aintOffset); 134 paintBackgroundsBehindCell(*cell, paintInfoForDescendants, p aintOffset);
132 } 135 }
133 } 136 }
137 paintBoxShadow(paintInfo, paintOffset, Inset);
134 } 138 }
135 139
136 if (paintInfo.phase == PaintPhaseSelfBlockBackgroundOnly) 140 if (paintInfo.phase == PaintPhaseSelfBlockBackgroundOnly)
137 return; 141 return;
138 142
139 if (shouldPaintDescendantBlockBackgrounds(paintInfo.phase)) { 143 if (shouldPaintDescendantBlockBackgrounds(paintInfo.phase)) {
140 for (unsigned r = dirtiedRows.start(); r < dirtiedRows.end(); r++) { 144 for (unsigned r = dirtiedRows.start(); r < dirtiedRows.end(); r++) {
141 const LayoutTableRow* row = m_layoutTableSection.rowLayoutObjectAt(r ); 145 const LayoutTableRow* row = m_layoutTableSection.rowLayoutObjectAt(r );
142 // If a row has a layer, we'll paint row background in TableRowPaint er. 146 // If a row has a layer, we'll paint row background in TableRowPaint er.
143 if (!row || row->hasSelfPaintingLayer() || !row->hasBackground()) 147 if (!row || row->hasSelfPaintingLayer())
144 continue; 148 continue;
145 149
146 TableRowPainter rowPainter(*row); 150 TableRowPainter rowPainter(*row);
147 for (unsigned c = dirtiedColumns.start(); c < dirtiedColumns.end(); c++) { 151 rowPainter.paintBoxShadow(paintInfoForDescendants, paintOffset, Norm al);
148 if (const LayoutTableCell* cell = primaryCellToPaint(r, c, dirti edRows, dirtiedColumns)) 152 if (row->hasBackground()) {
149 rowPainter.paintBackgroundBehindCell(*cell, paintInfoForDesc endants, paintOffset); 153 for (unsigned c = dirtiedColumns.start(); c < dirtiedColumns.end (); c++) {
154 if (const LayoutTableCell* cell = primaryCellToPaint(r, c, d irtiedRows, dirtiedColumns))
155 rowPainter.paintBackgroundBehindCell(*cell, paintInfoFor Descendants, paintOffset);
156 }
150 } 157 }
158 rowPainter.paintBoxShadow(paintInfoForDescendants, paintOffset, Inse t);
151 } 159 }
152 } 160 }
153 161
154 const HashSet<LayoutTableCell*>& overflowingCells = m_layoutTableSection.ove rflowingCells(); 162 const HashSet<LayoutTableCell*>& overflowingCells = m_layoutTableSection.ove rflowingCells();
155 if (!m_layoutTableSection.hasMultipleCellLevels() && overflowingCells.isEmpt y()) { 163 if (!m_layoutTableSection.hasMultipleCellLevels() && overflowingCells.isEmpt y()) {
156 for (unsigned r = dirtiedRows.start(); r < dirtiedRows.end(); r++) { 164 for (unsigned r = dirtiedRows.start(); r < dirtiedRows.end(); r++) {
157 const LayoutTableRow* row = m_layoutTableSection.rowLayoutObjectAt(r ); 165 const LayoutTableRow* row = m_layoutTableSection.rowLayoutObjectAt(r );
158 // TODO(crbug.com/577282): This painting order is inconsistent with other outlines. 166 // TODO(crbug.com/577282): This painting order is inconsistent with other outlines.
159 if (row && !row->hasSelfPaintingLayer() && shouldPaintSelfOutline(pa intInfoForDescendants.phase)) 167 if (row && !row->hasSelfPaintingLayer() && shouldPaintSelfOutline(pa intInfoForDescendants.phase))
160 TableRowPainter(*row).paintOutline(paintInfoForDescendants, pain tOffset); 168 TableRowPainter(*row).paintOutline(paintInfoForDescendants, pain tOffset);
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 } 238 }
231 239
232 void TableSectionPainter::paintCell(const LayoutTableCell& cell, const PaintInfo & paintInfoForCells, const LayoutPoint& paintOffset) 240 void TableSectionPainter::paintCell(const LayoutTableCell& cell, const PaintInfo & paintInfoForCells, const LayoutPoint& paintOffset)
233 { 241 {
234 if (!cell.hasSelfPaintingLayer() && !cell.row()->hasSelfPaintingLayer()) { 242 if (!cell.hasSelfPaintingLayer() && !cell.row()->hasSelfPaintingLayer()) {
235 LayoutPoint cellPoint = m_layoutTableSection.flipForWritingModeForChild( &cell, paintOffset); 243 LayoutPoint cellPoint = m_layoutTableSection.flipForWritingModeForChild( &cell, paintOffset);
236 cell.paint(paintInfoForCells, cellPoint); 244 cell.paint(paintInfoForCells, cellPoint);
237 } 245 }
238 } 246 }
239 247
248 void TableSectionPainter::paintBoxShadow(const PaintInfo& paintInfo, const Layou tPoint& paintOffset, ShadowStyle shadowStyle)
249 {
250 DCHECK(shouldPaintSelfBlockBackground(paintInfo.phase));
251 if (!m_layoutTableSection.styleRef().boxShadow())
252 return;
253
254 DisplayItem::Type type = shadowStyle == Normal ? DisplayItem::TableSectionBo xShadowNormal : DisplayItem::TableSectionBoxShadowInset;
255 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.contex t, m_layoutTableSection, type))
256 return;
257
258 LayoutRect bounds = BoxPainter(m_layoutTableSection).boundsForDrawingRecorde r(paintOffset);
259 LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutTableSection , type, bounds);
260 BoxPainter::paintBoxShadow(paintInfo, LayoutRect(paintOffset, m_layoutTableS ection.size()), m_layoutTableSection.styleRef(), shadowStyle);
261 }
262
240 } // namespace blink 263 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698