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

Unified Diff: third_party/WebKit/Source/core/paint/TableCellPainter.cpp

Issue 2556633002: Revert of Paint collapsed borders of a table as one display item (Closed)
Patch Set: Created 4 years 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/TableCellPainter.cpp
diff --git a/third_party/WebKit/Source/core/paint/TableCellPainter.cpp b/third_party/WebKit/Source/core/paint/TableCellPainter.cpp
index f3102f662b98f69c1976647792faf46641fe5ee1..856d8ecc505eefe05024aef689e0f969fb1690ff 100644
--- a/third_party/WebKit/Source/core/paint/TableCellPainter.cpp
+++ b/third_party/WebKit/Source/core/paint/TableCellPainter.cpp
@@ -19,40 +19,40 @@
const ComputedStyle& styleForCellFlow,
const LayoutTableCell::CollapsedBorderValues& values) {
if (styleForCellFlow.isHorizontalWritingMode()) {
- return styleForCellFlow.isLeftToRightDirection() ? values.startBorder
- : values.endBorder;
- }
- return styleForCellFlow.isFlippedBlocksWritingMode() ? values.afterBorder
- : values.beforeBorder;
+ return styleForCellFlow.isLeftToRightDirection() ? values.startBorder()
+ : values.endBorder();
+ }
+ return styleForCellFlow.isFlippedBlocksWritingMode() ? values.afterBorder()
+ : values.beforeBorder();
}
static const CollapsedBorderValue& collapsedRightBorder(
const ComputedStyle& styleForCellFlow,
const LayoutTableCell::CollapsedBorderValues& values) {
if (styleForCellFlow.isHorizontalWritingMode()) {
- return styleForCellFlow.isLeftToRightDirection() ? values.endBorder
- : values.startBorder;
- }
- return styleForCellFlow.isFlippedBlocksWritingMode() ? values.beforeBorder
- : values.afterBorder;
+ return styleForCellFlow.isLeftToRightDirection() ? values.endBorder()
+ : values.startBorder();
+ }
+ return styleForCellFlow.isFlippedBlocksWritingMode() ? values.beforeBorder()
+ : values.afterBorder();
}
static const CollapsedBorderValue& collapsedTopBorder(
const ComputedStyle& styleForCellFlow,
const LayoutTableCell::CollapsedBorderValues& values) {
if (styleForCellFlow.isHorizontalWritingMode())
- return values.beforeBorder;
- return styleForCellFlow.isLeftToRightDirection() ? values.startBorder
- : values.endBorder;
+ return values.beforeBorder();
+ return styleForCellFlow.isLeftToRightDirection() ? values.startBorder()
+ : values.endBorder();
}
static const CollapsedBorderValue& collapsedBottomBorder(
const ComputedStyle& styleForCellFlow,
const LayoutTableCell::CollapsedBorderValues& values) {
if (styleForCellFlow.isHorizontalWritingMode())
- return values.afterBorder;
- return styleForCellFlow.isLeftToRightDirection() ? values.endBorder
- : values.startBorder;
+ return values.afterBorder();
+ return styleForCellFlow.isLeftToRightDirection() ? values.endBorder()
+ : values.startBorder();
}
void TableCellPainter::paint(const PaintInfo& paintInfo,
@@ -66,6 +66,15 @@
if (style == BorderStyleInset)
return BorderStyleRidge;
return style;
+}
+
+const DisplayItemClient& TableCellPainter::displayItemClientForBorders() const {
+ // TODO(wkorman): We may need to handle PaintInvalidationDelayedFull.
+ // http://crbug.com/657186
+ return m_layoutTableCell.usesCompositedCellDisplayItemClients()
+ ? static_cast<const DisplayItemClient&>(
+ *m_layoutTableCell.collapsedBorderValues())
+ : m_layoutTableCell;
}
void TableCellPainter::paintCollapsedBorders(
@@ -95,6 +104,18 @@
const CollapsedBorderValue& bottomBorderValue =
collapsedBottomBorder(styleForCellFlow, *values);
+ int displayItemType = DisplayItem::kTableCollapsedBorderBase;
+ if (topBorderValue.shouldPaint(currentBorderValue))
+ displayItemType |= DisplayItem::TableCollapsedBorderTop;
+ if (bottomBorderValue.shouldPaint(currentBorderValue))
+ displayItemType |= DisplayItem::TableCollapsedBorderBottom;
+ if (leftBorderValue.shouldPaint(currentBorderValue))
+ displayItemType |= DisplayItem::TableCollapsedBorderLeft;
+ if (rightBorderValue.shouldPaint(currentBorderValue))
+ displayItemType |= DisplayItem::TableCollapsedBorderRight;
+ if (displayItemType == DisplayItem::kTableCollapsedBorderBase)
+ return;
+
int topWidth = topBorderValue.width();
int bottomWidth = bottomBorderValue.width();
int leftWidth = leftBorderValue.width();
@@ -110,32 +131,41 @@
paintRect.height() + topWidth / 2 + (bottomWidth + 1) / 2);
GraphicsContext& graphicsContext = paintInfo.context;
+ const DisplayItemClient& client = displayItemClientForBorders();
+ if (DrawingRecorder::useCachedDrawingIfPossible(
+ graphicsContext, client,
+ static_cast<DisplayItem::Type>(displayItemType)))
+ return;
+
+ DrawingRecorder recorder(graphicsContext, client,
+ static_cast<DisplayItem::Type>(displayItemType),
+ borderRect);
Color cellColor = m_layoutTableCell.resolveColor(CSSPropertyColor);
// We never paint diagonals at the joins. We simply let the border with the
// highest precedence paint on top of borders with lower precedence.
- if (topBorderValue.shouldPaint(currentBorderValue)) {
+ if (displayItemType & DisplayItem::TableCollapsedBorderTop) {
ObjectPainter::drawLineForBoxSide(
graphicsContext, borderRect.x(), borderRect.y(), borderRect.maxX(),
borderRect.y() + topWidth, BSTop,
topBorderValue.color().resolve(cellColor),
collapsedBorderStyle(topBorderValue.style()), 0, 0, true);
}
- if (bottomBorderValue.shouldPaint(currentBorderValue)) {
+ if (displayItemType & DisplayItem::TableCollapsedBorderBottom) {
ObjectPainter::drawLineForBoxSide(
graphicsContext, borderRect.x(), borderRect.maxY() - bottomWidth,
borderRect.maxX(), borderRect.maxY(), BSBottom,
bottomBorderValue.color().resolve(cellColor),
collapsedBorderStyle(bottomBorderValue.style()), 0, 0, true);
}
- if (leftBorderValue.shouldPaint(currentBorderValue)) {
+ if (displayItemType & DisplayItem::TableCollapsedBorderLeft) {
ObjectPainter::drawLineForBoxSide(
graphicsContext, borderRect.x(), borderRect.y(),
borderRect.x() + leftWidth, borderRect.maxY(), BSLeft,
leftBorderValue.color().resolve(cellColor),
collapsedBorderStyle(leftBorderValue.style()), 0, 0, true);
}
- if (rightBorderValue.shouldPaint(currentBorderValue)) {
+ if (displayItemType & DisplayItem::TableCollapsedBorderRight) {
ObjectPainter::drawLineForBoxSide(
graphicsContext, borderRect.maxX() - rightWidth, borderRect.y(),
borderRect.maxX(), borderRect.maxY(), BSRight,
« no previous file with comments | « third_party/WebKit/Source/core/paint/TableCellPainter.h ('k') | third_party/WebKit/Source/core/paint/TableCellPainterTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698