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

Unified Diff: third_party/WebKit/Source/core/paint/TableRowPainter.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, 7 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/paint/TableRowPainter.cpp
diff --git a/third_party/WebKit/Source/core/paint/TableRowPainter.cpp b/third_party/WebKit/Source/core/paint/TableRowPainter.cpp
index b7c333e0b4a8f13c7777cdf8bc27d333803d3d09..7e2db4a99f93b305162fe459d5805ee3a6b8965e 100644
--- a/third_party/WebKit/Source/core/paint/TableRowPainter.cpp
+++ b/third_party/WebKit/Source/core/paint/TableRowPainter.cpp
@@ -6,6 +6,7 @@
#include "core/layout/LayoutTableCell.h"
#include "core/layout/LayoutTableRow.h"
+#include "core/paint/BoxPainter.h"
#include "core/paint/LayoutObjectDrawingRecorder.h"
#include "core/paint/ObjectPainter.h"
#include "core/paint/PaintInfo.h"
@@ -17,29 +18,60 @@ void TableRowPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paint
{
ASSERT(m_layoutTableRow.hasSelfPaintingLayer());
- // TODO(wangxianzhu): This painting order is inconsistent with other outlines. crbug.com/577282.
- paintOutlineForRowIfNeeded(paintInfo, paintOffset);
+ // TODO(crbug.com/577282): This painting order is inconsistent with other outlines.
+ if (shouldPaintSelfOutline(paintInfo.phase))
+ paintOutline(paintInfo, paintOffset);
if (paintInfo.phase == PaintPhaseSelfOutlineOnly)
return;
PaintInfo paintInfoForCells = paintInfo.forDescendants();
- bool shouldPaintRowBackground = shouldPaintSelfBlockBackground(paintInfo.phase) && m_layoutTableRow.hasBackground();
- bool shouldPaintCells = paintInfo.phase != PaintPhaseSelfBlockBackgroundOnly;
+ if (shouldPaintSelfBlockBackground(paintInfo.phase)) {
+ paintBoxShadow(paintInfo, paintOffset, Normal);
+ if (m_layoutTableRow.hasBackground()) {
+ // Paint row background of behind the cells.
+ for (LayoutTableCell* cell = m_layoutTableRow.firstCell(); cell; cell = cell->nextCell())
+ TableCellPainter(*cell).paintContainerBackgroundBehindCell(paintInfoForCells, paintOffset, m_layoutTableRow, DisplayItem::TableCellBackgroundFromRow);
+ }
+ paintBoxShadow(paintInfo, paintOffset, Inset);
+ }
+
+ if (paintInfo.phase == PaintPhaseSelfBlockBackgroundOnly)
+ return;
+
for (LayoutTableCell* cell = m_layoutTableRow.firstCell(); cell; cell = cell->nextCell()) {
- if (shouldPaintRowBackground)
- TableCellPainter(*cell).paintBackgroundsBehindCell(paintInfoForCells, paintOffset, &m_layoutTableRow, DisplayItem::TableCellBackgroundFromRow);
- if (shouldPaintCells && !cell->hasSelfPaintingLayer())
+ if (!cell->hasSelfPaintingLayer())
cell->paint(paintInfoForCells, paintOffset);
}
}
-void TableRowPainter::paintOutlineForRowIfNeeded(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
+void TableRowPainter::paintOutline(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
- PaintPhase paintPhase = paintInfo.phase;
- if (shouldPaintSelfOutline(paintPhase)) {
- LayoutPoint adjustedPaintOffset = paintOffset + m_layoutTableRow.location();
- ObjectPainter(m_layoutTableRow).paintOutline(paintInfo, adjustedPaintOffset);
- }
+ ASSERT(shouldPaintSelfOutline(paintInfo.phase));
+ LayoutPoint adjustedPaintOffset = paintOffset + m_layoutTableRow.location();
+ ObjectPainter(m_layoutTableRow).paintOutline(paintInfo, adjustedPaintOffset);
+}
+
+void TableRowPainter::paintBoxShadow(const PaintInfo& paintInfo, const LayoutPoint& paintOffset, ShadowStyle shadowStyle)
+{
+ ASSERT(shouldPaintSelfBlockBackground(paintInfo.phase));
+ if (!m_layoutTableRow.styleRef().boxShadow())
+ return;
+
+ DisplayItem::Type type = shadowStyle == Normal ? DisplayItem::TableRowBoxShadowNormal : DisplayItem::TableRowBoxShadowInset;
+ if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.context, m_layoutTableRow, type))
+ return;
+
+ LayoutPoint adjustedPaintOffset = paintOffset + m_layoutTableRow.location();
+ LayoutRect bounds = BoxPainter(m_layoutTableRow).boundsForDrawingRecorder(adjustedPaintOffset);
+ LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutTableRow, type, bounds);
+ BoxPainter::paintBoxShadow(paintInfo, LayoutRect(adjustedPaintOffset, m_layoutTableRow.size()), m_layoutTableRow.styleRef(), shadowStyle);
+}
+
+void TableRowPainter::paintBackgroundBehindCell(const LayoutTableCell& cell, const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
+{
+ ASSERT(m_layoutTableRow.hasBackground() && !m_layoutTableRow.hasSelfPaintingLayer());
+ LayoutPoint cellPoint = m_layoutTableRow.section()->flipForWritingModeForChild(&cell, paintOffset);
+ TableCellPainter(cell).paintContainerBackgroundBehindCell(paintInfo, cellPoint, m_layoutTableRow, DisplayItem::TableCellBackgroundFromRow);
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698