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

Unified Diff: third_party/WebKit/Source/core/layout/LayoutMultiColumnSet.cpp

Issue 2115013002: Include column rules for LayoutMultiColumnSet paint invalidation rects. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: none Created 4 years, 6 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/layout/LayoutMultiColumnSet.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutMultiColumnSet.cpp b/third_party/WebKit/Source/core/layout/LayoutMultiColumnSet.cpp
index c2ffb57d6b0f1d4e116b43903d8f17fd1b3ab2ff..d3452bcc13463522bd1bbbb9d673da64e22637b8 100644
--- a/third_party/WebKit/Source/core/layout/LayoutMultiColumnSet.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutMultiColumnSet.cpp
@@ -476,4 +476,75 @@ LayoutRect LayoutMultiColumnSet::flowThreadPortionRect() const
return portionRect;
}
+bool LayoutMultiColumnSet::computeColumnRuleBounds(const LayoutPoint& paintOffset, Vector<LayoutRect>& columnRuleBounds) const
+{
+ if (flowThread()->isLayoutPagedFlowThread())
+ return false;
+
+ // Reference: https://www.w3.org/TR/css3-multicol/#column-gaps-and-rules
+ const ComputedStyle& blockStyle = multiColumnBlockFlow()->styleRef();
+ bool ruleTransparent = blockStyle.columnRuleIsTransparent();
+ EBorderStyle ruleStyle = blockStyle.columnRuleStyle();
+ LayoutUnit ruleThickness(blockStyle.columnRuleWidth());
+ LayoutUnit colGap = columnGap();
+ bool renderRule = ruleStyle > BorderStyleHidden && !ruleTransparent;
+ if (!renderRule)
+ return false;
+
+ unsigned colCount = actualColumnCount();
+ if (colCount <= 1)
+ return false;
+
+ bool leftToRight = style()->isLeftToRightDirection();
+ LayoutUnit currLogicalLeftOffset = leftToRight ? LayoutUnit() : contentLogicalWidth();
+ LayoutUnit ruleAdd = borderAndPaddingLogicalLeft();
+ LayoutUnit ruleLogicalLeft = leftToRight ? LayoutUnit() : contentLogicalWidth();
+ LayoutUnit inlineDirectionSize = pageLogicalWidth();
+
+ for (unsigned i = 0; i < colCount; i++) {
+ // Move to the next position.
+ if (leftToRight) {
+ ruleLogicalLeft += inlineDirectionSize + colGap / 2;
+ currLogicalLeftOffset += inlineDirectionSize + colGap;
+ } else {
+ ruleLogicalLeft -= (inlineDirectionSize + colGap / 2);
+ currLogicalLeftOffset -= (inlineDirectionSize + colGap);
+ }
+
+ // Now compute the final bounds.
+ if (i < colCount - 1) {
+ LayoutUnit ruleLeft, ruleRight, ruleTop, ruleBottom;
+ if (isHorizontalWritingMode()) {
+ ruleLeft = paintOffset.x() + ruleLogicalLeft - ruleThickness / 2 + ruleAdd;
+ ruleRight = ruleLeft + ruleThickness;
+ ruleTop = paintOffset.y() + borderTop() + paddingTop();
+ ruleBottom = ruleTop + contentHeight();
+ } else {
+ ruleLeft = paintOffset.x() + borderLeft() + paddingLeft();
+ ruleRight = ruleLeft + contentWidth();
+ ruleTop = paintOffset.y() + ruleLogicalLeft - ruleThickness / 2 + ruleAdd;
+ ruleBottom = ruleTop + ruleThickness;
+ }
+
+ columnRuleBounds.append(LayoutRect(ruleLeft, ruleTop, ruleRight - ruleLeft, ruleBottom - ruleTop));
+ }
+
+ ruleLogicalLeft = currLogicalLeftOffset;
+ }
+ return true;
+}
+
+LayoutRect LayoutMultiColumnSet::localOverflowRectForPaintInvalidation() const
+{
+ LayoutRect blockFlowBounds = LayoutBlockFlow::localOverflowRectForPaintInvalidation();
+
+ // Now add in column rule bounds, if present.
+ Vector<LayoutRect> columnRuleBounds;
+ if (computeColumnRuleBounds(LayoutPoint(), columnRuleBounds)) {
+ for (auto& bound : columnRuleBounds)
+ blockFlowBounds.unite(bound);
+ }
+ return blockFlowBounds;
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698