| Index: third_party/WebKit/Source/core/paint/TableCellPainter.cpp
|
| diff --git a/third_party/WebKit/Source/core/paint/TableCellPainter.cpp b/third_party/WebKit/Source/core/paint/TableCellPainter.cpp
|
| index d30a77340c74afe4822b12116fa57d3f56be879b..973527f990cc7a4b48ca121ab3e34827aa4eb35c 100644
|
| --- a/third_party/WebKit/Source/core/paint/TableCellPainter.cpp
|
| +++ b/third_party/WebKit/Source/core/paint/TableCellPainter.cpp
|
| @@ -5,6 +5,7 @@
|
| #include "core/paint/TableCellPainter.h"
|
|
|
| #include "core/layout/LayoutTableCell.h"
|
| +#include "core/layout/LayoutTableCol.h"
|
| #include "core/paint/BlockPainter.h"
|
| #include "core/paint/BoxPainter.h"
|
| #include "core/paint/LayoutObjectDrawingRecorder.h"
|
| @@ -140,8 +141,13 @@ void TableCellPainter::paintCollapsedBorders(const PaintInfo& paintInfo, const L
|
| }
|
| }
|
|
|
| -void TableCellPainter::paintBackgroundsBehindCell(const PaintInfo& paintInfo, const LayoutPoint& paintOffset, const LayoutObject* backgroundObject, DisplayItem::Type type)
|
| +void TableCellPainter::paintBackgroundsBehindCell(const PaintInfo& paintInfo, const LayoutPoint& paintOffset, const LayoutBox* backgroundObject, DisplayItem::Type type)
|
| {
|
| + if (RuntimeEnabledFeatures::newTableCellBackgroundPaintingEnabled() && backgroundObject != &m_layoutTableCell) {
|
| + paintParentBackgroundsBehindCell(paintInfo, paintOffset, backgroundObject, type);
|
| + return;
|
| + }
|
| +
|
| if (!backgroundObject)
|
| return;
|
|
|
| @@ -180,6 +186,68 @@ void TableCellPainter::paintBackgroundsBehindCell(const PaintInfo& paintInfo, co
|
| }
|
| }
|
|
|
| +void TableCellPainter::paintParentBackgroundsBehindCell(const PaintInfo& paintInfo, const LayoutPoint& paintOffset, const LayoutBox* backgroundObject, DisplayItem::Type type)
|
| +{
|
| + if (!backgroundObject)
|
| + return;
|
| +
|
| + if (m_layoutTableCell.style()->visibility() != VISIBLE)
|
| + return;
|
| +
|
| + LayoutTable* tableElt = m_layoutTableCell.table();
|
| + if (!tableElt->collapseBorders() && m_layoutTableCell.style()->emptyCells() == EmptyCellsHide && !m_layoutTableCell.firstChild())
|
| + return;
|
| +
|
| + LayoutRect backgroundRect = paintBoundsParent(paintOffset, backgroundObject, type);
|
| +
|
| + LayoutRect cellRect = m_layoutTableCell.frameRect();
|
| + cellRect.moveBy(paintOffset);
|
| +
|
| + cellRect.setLocation(LayoutPoint(cellRect.pixelSnappedLocation()));
|
| + cellRect.setSize(LayoutSize(cellRect.pixelSnappedSize()));
|
| +
|
| + // We paint background LTR, top->bottom.
|
| + // This makes code much simpler, but is not spec-conformant.
|
| + // The spec-conformant code would have to handle all writing-mode
|
| + // painting directions correctly.
|
| +
|
| + if (backgroundRect.x() > cellRect.x())
|
| + backgroundRect.setX(cellRect.x());
|
| + if (backgroundRect.y() > cellRect.y())
|
| + backgroundRect.setY(cellRect.y());
|
| +
|
| + Optional<LayoutObjectDrawingRecorder> recorder;
|
| + if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.context, m_layoutTableCell, type)) {
|
| + return;
|
| + }
|
| + recorder.emplace(paintInfo.context, m_layoutTableCell, type, cellRect);
|
| +
|
| + Color c = backgroundObject->resolveColor(CSSPropertyBackgroundColor);
|
| + const FillLayer& bgLayer = backgroundObject->style()->backgroundLayers();
|
| + FillLayer bgAdjustedLayer(bgLayer);
|
| +
|
| + if (bgLayer.hasImage() || c.alpha()) {
|
| +
|
| + GraphicsContextStateSaver stateSaver(paintInfo.context, true);
|
| + LayoutRect clipRect(m_layoutTableCell.location(), m_layoutTableCell.size());
|
| + clipRect.moveBy(paintOffset);
|
| + paintInfo.context.clip(pixelSnappedIntRect(clipRect));
|
| +
|
| + // If cell is larger than background, we might have to paint multiple times.
|
| + LayoutUnit colExtraPixels = std::max(LayoutUnit(0), cellRect.maxX() - backgroundRect.maxX());
|
| + unsigned colRepeat = 1 + (colExtraPixels / backgroundRect.width()) + (colExtraPixels % backgroundRect.width() != 0);
|
| + LayoutUnit rowExtraPixels = std::max(LayoutUnit(0), cellRect.maxY() - backgroundRect.maxY());
|
| + unsigned rowRepeat = 1 + (rowExtraPixels / backgroundRect.height()) + (rowExtraPixels % backgroundRect.height() != 0);
|
| + for (unsigned row = 0; row < rowRepeat; row++) {
|
| + for (unsigned col = 0; col < colRepeat; col++) {
|
| + LayoutRect paintRect = backgroundRect;
|
| + paintRect.move(col * paintRect.width(), row * paintRect.height());
|
| + BoxPainter(*backgroundObject).paintFillLayers(paintInfo, c, bgLayer, paintRect, BackgroundBleedNone, SkXfermode::kSrcOver_Mode, backgroundObject);
|
| + }
|
| + }
|
| + }
|
| +}
|
| +
|
| void TableCellPainter::paintBoxDecorationBackground(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
|
| {
|
| LayoutTable* table = m_layoutTableCell.table();
|
| @@ -238,5 +306,41 @@ LayoutRect TableCellPainter::paintBounds(const LayoutPoint& paintOffset, PaintBo
|
| return LayoutRect(adjustedPaintOffset, LayoutSize(m_layoutTableCell.pixelSnappedSize()));
|
| }
|
|
|
| +LayoutRect TableCellPainter::paintBoundsParent(const LayoutPoint& paintOffset, const LayoutBox* backgroundObject, DisplayItem::Type type)
|
| +{
|
| + LayoutRect position;
|
| + switch (type) {
|
| + case DisplayItem::TableCellBackgroundFromColumnGroup:
|
| + case DisplayItem::TableCellBackgroundFromColumn:
|
| + {
|
| + position = static_cast<const LayoutTableCol*>(backgroundObject)->positionByCellSpan(
|
| + m_layoutTableCell.absoluteColumnIndex());
|
| + // position is relative to table, must correct for section location
|
| + LayoutPoint sectionLocation = m_layoutTableCell.section()->location();
|
| + position.moveBy(-sectionLocation);
|
| + position.moveBy(paintOffset);
|
| + }
|
| + break;
|
| + case DisplayItem::TableCellBackgroundFromSection:
|
| + position = static_cast<const LayoutTableSection*>(backgroundObject)->positionByCellSpan();
|
| + position.moveBy(paintOffset);
|
| + break;
|
| + case DisplayItem::TableCellBackgroundFromRow:
|
| + position = static_cast<const LayoutTableRow*>(backgroundObject)->positionByCellSpan();
|
| + position.moveBy(paintOffset);
|
| + break;
|
| + case DisplayItem::BoxDecorationBackground: {
|
| + LayoutPoint adjustedPaintOffset = paintOffset;
|
| + adjustedPaintOffset.moveBy(m_layoutTableCell.location());
|
| + position = LayoutRect(adjustedPaintOffset, LayoutSize(m_layoutTableCell.pixelSnappedSize()));
|
| + }
|
| + break;
|
| + default:
|
| + ASSERT(false);
|
| + break;
|
| + }
|
| + return LayoutRect(position.pixelSnappedLocation(), position.pixelSnappedSize());
|
| +}
|
| +
|
| } // namespace blink
|
|
|
|
|