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

Unified Diff: Source/core/rendering/RenderBlock.cpp

Issue 23763002: Improve multicol preferred/intrinsic width calculation. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Code review Created 7 years, 4 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
« no previous file with comments | « Source/core/rendering/RenderBlock.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderBlock.cpp
diff --git a/Source/core/rendering/RenderBlock.cpp b/Source/core/rendering/RenderBlock.cpp
index e0d02f6d870ea9ff9a3ad3318a8ab27db2b15446..967e669c5fa58f34e4c80478d56fecf99ead6c5c 100644
--- a/Source/core/rendering/RenderBlock.cpp
+++ b/Source/core/rendering/RenderBlock.cpp
@@ -5711,6 +5711,8 @@ void RenderBlock::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Lay
maxLogicalWidth = max(minLogicalWidth, maxLogicalWidth);
+ adjustIntrinsicLogicalWidthsForColumns(minLogicalWidth, maxLogicalWidth);
+
// A horizontal marquee with inline children has no minimum width.
if (childrenInline() && isMarquee() && toRenderMarquee(this)->isHorizontal())
minLogicalWidth = 0;
@@ -5767,6 +5769,33 @@ void RenderBlock::computePreferredLogicalWidths()
clearPreferredLogicalWidthsDirty();
}
+void RenderBlock::adjustIntrinsicLogicalWidthsForColumns(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const
+{
+ // FIXME: make this method virtual and move the code to RenderMultiColumnBlock once the old
+ // multicol code is gone.
+
+ if (!style()->hasAutoColumnCount() || !style()->hasAutoColumnWidth()) {
+ // The min/max intrinsic widths calculated really tell how much space elements need when
+ // laid out inside the columns. In order to eventually end up with the desired column width,
+ // we need to convert them to values pertaining to the multicol container.
+ int columnCount = style()->hasAutoColumnCount() ? 1 : style()->columnCount();
+ LayoutUnit columnWidth;
+ LayoutUnit gapExtra = (columnCount - 1) * columnGap();
+ if (style()->hasAutoColumnWidth()) {
+ minLogicalWidth = minLogicalWidth * columnCount + gapExtra;
+ } else {
+ columnWidth = style()->columnWidth();
+ minLogicalWidth = min(minLogicalWidth, columnWidth);
+ }
+ // FIXME: If column-count is auto here, we should resolve it to calculate the maximum
+ // intrinsic width, instead of pretending that it's 1. The only way to do that is by
+ // performing a layout pass, but this is not an appropriate time or place for layout. The
+ // good news is that if height is unconstrained and there are no explicit breaks, the
+ // resolved column-count really should be 1.
+ maxLogicalWidth = max(maxLogicalWidth, columnWidth) * columnCount + gapExtra;
+ }
+}
+
struct InlineMinMaxIterator {
/* InlineMinMaxIterator is a class that will iterate over all render objects that contribute to
inline min/max width calculations. Note the following about the way it walks:
« no previous file with comments | « Source/core/rendering/RenderBlock.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698