| 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..6ec9a7322643feead5c8c5378a03ab5277481676 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,10 +141,12 @@ 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 (!backgroundObject)
|
| + if (RuntimeEnabledFeatures::newTableCellBackgroundPaintingEnabled() && &backgroundObject != &m_layoutTableCell) {
|
| + paintParentBackgroundsBehindCell(paintInfo, paintOffset, backgroundObject, type);
|
| return;
|
| + }
|
|
|
| if (m_layoutTableCell.style()->visibility() != VISIBLE)
|
| return;
|
| @@ -152,11 +155,11 @@ void TableCellPainter::paintBackgroundsBehindCell(const PaintInfo& paintInfo, co
|
| if (!tableElt->collapseBorders() && m_layoutTableCell.style()->emptyCells() == EmptyCellsHide && !m_layoutTableCell.firstChild())
|
| return;
|
|
|
| - LayoutRect paintRect = paintBounds(paintOffset, backgroundObject != &m_layoutTableCell ? AddOffsetFromParent : DoNotAddOffsetFromParent);
|
| + LayoutRect paintRect = paintBounds(paintOffset, &backgroundObject != &m_layoutTableCell ? AddOffsetFromParent : DoNotAddOffsetFromParent);
|
|
|
| // Record drawing only if the cell is painting background from containers.
|
| Optional<LayoutObjectDrawingRecorder> recorder;
|
| - if (backgroundObject != &m_layoutTableCell) {
|
| + if (&backgroundObject != &m_layoutTableCell) {
|
| if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.context, m_layoutTableCell, type))
|
| return;
|
| recorder.emplace(paintInfo.context, m_layoutTableCell, type, paintRect);
|
| @@ -164,19 +167,62 @@ void TableCellPainter::paintBackgroundsBehindCell(const PaintInfo& paintInfo, co
|
| ASSERT(paintRect.location() == paintOffset);
|
| }
|
|
|
| - Color c = backgroundObject->resolveColor(CSSPropertyBackgroundColor);
|
| - const FillLayer& bgLayer = backgroundObject->style()->backgroundLayers();
|
| + Color c = backgroundObject.resolveColor(CSSPropertyBackgroundColor);
|
| + const FillLayer& bgLayer = backgroundObject.style()->backgroundLayers();
|
| if (bgLayer.hasImage() || c.alpha()) {
|
| // We have to clip here because the background would paint
|
| // on top of the borders otherwise. This only matters for cells and rows.
|
| - bool shouldClip = backgroundObject->hasLayer() && (backgroundObject == &m_layoutTableCell || backgroundObject == m_layoutTableCell.parent()) && tableElt->collapseBorders();
|
| + bool shouldClip = backgroundObject.hasLayer() && (&backgroundObject == &m_layoutTableCell || &backgroundObject == m_layoutTableCell.parent()) && tableElt->collapseBorders();
|
| GraphicsContextStateSaver stateSaver(paintInfo.context, shouldClip);
|
| if (shouldClip) {
|
| LayoutRect clipRect(paintRect.location(), m_layoutTableCell.size());
|
| clipRect.expand(m_layoutTableCell.borderInsets());
|
| paintInfo.context.clip(pixelSnappedIntRect(clipRect));
|
| }
|
| - BoxPainter(m_layoutTableCell).paintFillLayers(paintInfo, c, bgLayer, paintRect, BackgroundBleedNone, SkXfermode::kSrcOver_Mode, backgroundObject);
|
| + BoxPainter(m_layoutTableCell).paintFillLayers(paintInfo, c, bgLayer, paintRect, BackgroundBleedNone, SkXfermode::kSrcOver_Mode, &backgroundObject);
|
| + }
|
| +}
|
| +
|
| +void TableCellPainter::paintParentBackgroundsBehindCell(const PaintInfo& paintInfo, const LayoutPoint& paintOffset, const LayoutBox& backgroundObject, DisplayItem::Type type)
|
| +{
|
| +
|
| + if (m_layoutTableCell.style()->visibility() != VISIBLE)
|
| + return;
|
| +
|
| + LayoutTable* table = m_layoutTableCell.table();
|
| + if (!table->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()));
|
| +
|
| + LayoutRect paintRect = backgroundRect;
|
| + paintRect.unite(cellRect);
|
| +
|
| + if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(paintInfo.context, m_layoutTableCell, type)) {
|
| + return;
|
| + }
|
| + LayoutObjectDrawingRecorder recorder(paintInfo.context, m_layoutTableCell, type, paintRect);
|
| +
|
| + Color color = backgroundObject.resolveColor(CSSPropertyBackgroundColor);
|
| + const FillLayer& backgroundLayer = backgroundObject.style()->backgroundLayers();
|
| +
|
| + // TODO(crbug.com/598489) background image paints incorrectly when rowspan/colspan > 1,
|
| + // and background-image-size is in '%'
|
| +
|
| + if (backgroundLayer.hasImage() || color.alpha()) {
|
| +
|
| + GraphicsContextStateSaver stateSaver(paintInfo.context, true);
|
| + LayoutRect clipRect(m_layoutTableCell.location(), m_layoutTableCell.size());
|
| + clipRect.moveBy(paintOffset);
|
| + paintInfo.context.clip(pixelSnappedIntRect(clipRect));
|
| +
|
| + BoxPainter(backgroundObject).paintFillLayers(paintInfo, color, backgroundLayer, paintRect, BackgroundBleedNone, SkXfermode::kSrcOver_Mode, &backgroundObject);
|
| }
|
| }
|
|
|
| @@ -203,7 +249,7 @@ void TableCellPainter::paintBoxDecorationBackground(const PaintInfo& paintInfo,
|
| BoxPainter::paintBoxShadow(paintInfo, paintRect, m_layoutTableCell.styleRef(), Normal);
|
|
|
| // Paint our cell background.
|
| - paintBackgroundsBehindCell(paintInfo, paintOffset, &m_layoutTableCell, DisplayItem::BoxDecorationBackground);
|
| + paintBackgroundsBehindCell(paintInfo, paintOffset, m_layoutTableCell, DisplayItem::BoxDecorationBackground);
|
|
|
| BoxPainter::paintBoxShadow(paintInfo, paintRect, m_layoutTableCell.styleRef(), Inset);
|
|
|
| @@ -238,5 +284,42 @@ 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).positionForBackgroundDrawing(
|
| + 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).positionForBackgroundDrawing();
|
| + position.moveBy(paintOffset);
|
| + break;
|
| + }
|
| + case DisplayItem::TableCellBackgroundFromRow: {
|
| + position = static_cast<const LayoutTableRow&>(backgroundObject).positionForBackgroundDrawing();
|
| + position.moveBy(paintOffset);
|
| + break;
|
| + }
|
| + case DisplayItem::BoxDecorationBackground: {
|
| + LayoutPoint adjustedPaintOffset = paintOffset;
|
| + adjustedPaintOffset.moveBy(m_layoutTableCell.location());
|
| + position = LayoutRect(adjustedPaintOffset, LayoutSize(m_layoutTableCell.size()));
|
| + break;
|
| + }
|
| + default:
|
| + ASSERT_NOT_REACHED();
|
| + break;
|
| + }
|
| + return LayoutRect(position.pixelSnappedLocation(), position.pixelSnappedSize());
|
| +}
|
| +
|
| } // namespace blink
|
|
|
|
|