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

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

Issue 1549693002: Optimize collapsed border painting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Field instead of global HashMap Created 5 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 c6372e500b97001ce68ee42e1abf060f151e5c78..e74b7276729c5d992ce566e91142fc3641ceede3 100644
--- a/third_party/WebKit/Source/core/paint/TableCellPainter.cpp
+++ b/third_party/WebKit/Source/core/paint/TableCellPainter.cpp
@@ -13,41 +13,32 @@
namespace blink {
-inline const CollapsedBorderValue& TableCellPainter::cachedCollapsedLeftBorder(const ComputedStyle& styleForCellFlow) const
+static const CollapsedBorderValue& collapsedLeftBorder(const ComputedStyle& styleForCellFlow, const LayoutTableCell::CollapsedBorderValues& values)
{
- if (styleForCellFlow.isHorizontalWritingMode()) {
- return styleForCellFlow.isLeftToRightDirection() ? m_layoutTableCell.section()->cachedCollapsedBorder(&m_layoutTableCell, CBSStart)
- : m_layoutTableCell.section()->cachedCollapsedBorder(&m_layoutTableCell, CBSEnd);
- }
- return styleForCellFlow.isFlippedBlocksWritingMode() ? m_layoutTableCell.section()->cachedCollapsedBorder(&m_layoutTableCell, CBSAfter)
- : m_layoutTableCell.section()->cachedCollapsedBorder(&m_layoutTableCell, CBSBefore);
+ if (styleForCellFlow.isHorizontalWritingMode())
+ return styleForCellFlow.isLeftToRightDirection() ? values.startBorder : values.endBorder;
+ return styleForCellFlow.isFlippedBlocksWritingMode() ? values.afterBorder : values.beforeBorder;
}
-inline const CollapsedBorderValue& TableCellPainter::cachedCollapsedRightBorder(const ComputedStyle& styleForCellFlow) const
+static const CollapsedBorderValue& collapsedRightBorder(const ComputedStyle& styleForCellFlow, const LayoutTableCell::CollapsedBorderValues& values)
{
- if (styleForCellFlow.isHorizontalWritingMode()) {
- return styleForCellFlow.isLeftToRightDirection() ? m_layoutTableCell.section()->cachedCollapsedBorder(&m_layoutTableCell, CBSEnd)
- : m_layoutTableCell.section()->cachedCollapsedBorder(&m_layoutTableCell, CBSStart);
- }
- return styleForCellFlow.isFlippedBlocksWritingMode() ? m_layoutTableCell.section()->cachedCollapsedBorder(&m_layoutTableCell, CBSBefore)
- : m_layoutTableCell.section()->cachedCollapsedBorder(&m_layoutTableCell, CBSAfter);
+ if (styleForCellFlow.isHorizontalWritingMode())
+ return styleForCellFlow.isLeftToRightDirection() ? values.endBorder : values.startBorder;
+ return styleForCellFlow.isFlippedBlocksWritingMode() ? values.beforeBorder : values.afterBorder;
}
-inline const CollapsedBorderValue& TableCellPainter::cachedCollapsedTopBorder(const ComputedStyle& styleForCellFlow) const
+static const CollapsedBorderValue& collapsedTopBorder(const ComputedStyle& styleForCellFlow, const LayoutTableCell::CollapsedBorderValues& values)
{
if (styleForCellFlow.isHorizontalWritingMode())
- return styleForCellFlow.isFlippedBlocksWritingMode() ? m_layoutTableCell.section()->cachedCollapsedBorder(&m_layoutTableCell, CBSAfter) : m_layoutTableCell.section()->cachedCollapsedBorder(&m_layoutTableCell, CBSBefore);
- return styleForCellFlow.isLeftToRightDirection() ? m_layoutTableCell.section()->cachedCollapsedBorder(&m_layoutTableCell, CBSStart) : m_layoutTableCell.section()->cachedCollapsedBorder(&m_layoutTableCell, CBSEnd);
+ return styleForCellFlow.isFlippedBlocksWritingMode() ? values.afterBorder : values.beforeBorder;
+ return styleForCellFlow.isLeftToRightDirection() ? values.startBorder : values.endBorder;
}
-inline const CollapsedBorderValue& TableCellPainter::cachedCollapsedBottomBorder(const ComputedStyle& styleForCellFlow) const
+static const CollapsedBorderValue& collapsedBottomBorder(const ComputedStyle& styleForCellFlow, const LayoutTableCell::CollapsedBorderValues& values)
{
- if (styleForCellFlow.isHorizontalWritingMode()) {
- return styleForCellFlow.isFlippedBlocksWritingMode() ? m_layoutTableCell.section()->cachedCollapsedBorder(&m_layoutTableCell, CBSBefore)
- : m_layoutTableCell.section()->cachedCollapsedBorder(&m_layoutTableCell, CBSAfter);
- }
- return styleForCellFlow.isLeftToRightDirection() ? m_layoutTableCell.section()->cachedCollapsedBorder(&m_layoutTableCell, CBSEnd)
- : m_layoutTableCell.section()->cachedCollapsedBorder(&m_layoutTableCell, CBSStart);
+ if (styleForCellFlow.isHorizontalWritingMode())
+ return styleForCellFlow.isFlippedBlocksWritingMode() ? values.beforeBorder : values.afterBorder;
+ return styleForCellFlow.isLeftToRightDirection() ? values.endBorder : values.startBorder;
}
void TableCellPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
@@ -69,11 +60,15 @@ void TableCellPainter::paintCollapsedBorders(const PaintInfo& paintInfo, const L
if (!paintInfo.shouldPaintWithinRoot(&m_layoutTableCell) || m_layoutTableCell.style()->visibility() != VISIBLE)
return;
+ const LayoutTableCell::CollapsedBorderValues* values = m_layoutTableCell.collapsedBorderValues();
+ if (!values)
+ return;
+
const ComputedStyle& styleForCellFlow = m_layoutTableCell.styleForCellFlow();
- const CollapsedBorderValue& leftBorderValue = cachedCollapsedLeftBorder(styleForCellFlow);
- const CollapsedBorderValue& rightBorderValue = cachedCollapsedRightBorder(styleForCellFlow);
- const CollapsedBorderValue& topBorderValue = cachedCollapsedTopBorder(styleForCellFlow);
- const CollapsedBorderValue& bottomBorderValue = cachedCollapsedBottomBorder(styleForCellFlow);
+ const CollapsedBorderValue& leftBorderValue = collapsedLeftBorder(styleForCellFlow, *values);
+ const CollapsedBorderValue& rightBorderValue = collapsedRightBorder(styleForCellFlow, *values);
+ const CollapsedBorderValue& topBorderValue = collapsedTopBorder(styleForCellFlow, *values);
+ const CollapsedBorderValue& bottomBorderValue = collapsedBottomBorder(styleForCellFlow, *values);
int displayItemType = DisplayItem::TableCollapsedBorderBase;
if (topBorderValue.shouldPaint(currentBorderValue))

Powered by Google App Engine
This is Rietveld 408576698