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

Side by Side Diff: Source/core/rendering/MultiColumnRow.h

Issue 883293004: [New Multicolumn] Preparatory work for nested multicol support. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: no find copies, please Created 5 years, 10 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef MultiColumnRow_h
6 #define MultiColumnRow_h
7
8 #include "core/rendering/RenderMultiColumnFlowThread.h"
9
10 namespace blink {
11
12 class MultiColumnRow {
Julien - ping for review 2015/01/29 17:37:47 We would need a class comment about this. I still
mstensho (USE GERRIT) 2015/02/02 17:57:23 Done.
13 public:
14 MultiColumnRow(RenderMultiColumnSet&);
15
16 // FIXME: implement these. For now we only support one row.
17 MultiColumnRow* previousRow() { return 0; }
18 MultiColumnRow* nextRow() { return 0; }
19 const MultiColumnRow* previousRow() const { return 0; }
20 const MultiColumnRow* nextRow() const { return 0; }
21
22 // Position within the RenderMultiColumnSet.
23 LayoutUnit logicalTop() const { return m_logicalTop; }
24
25 LayoutUnit logicalHeight() const { return m_columnHeight; }
26
27 LayoutSize offsetFromColumnSet() const;
28
29 // The top of our flow thread portion
30 LayoutUnit logicalTopInFlowThread() const { return m_logicalTopInFlowThread; }
31 void setLogicalTopInFlowThread(LayoutUnit logicalTopInFlowThread) { m_logica lTopInFlowThread = logicalTopInFlowThread; }
32
33 // The bottom of our flow thread portion
34 LayoutUnit logicalBottomInFlowThread() const { return m_logicalBottomInFlowT hread; }
35 void setLogicalBottomInFlowThread(LayoutUnit logicalBottomInFlowThread) { m_ logicalBottomInFlowThread = logicalBottomInFlowThread; }
36
37 // The height of our flow thread portion
38 LayoutUnit logicalHeightInFlowThread() const { return m_logicalBottomInFlowT hread - m_logicalTopInFlowThread; }
39
40 bool heightIsAuto() const;
41 void resetColumnHeight();
42 void addContentRun(LayoutUnit endOffsetInFlowThread);
43 void updateMinimumColumnHeight(LayoutUnit height) { m_minimumColumnHeight = std::max(height, m_minimumColumnHeight); }
44 void recordSpaceShortage(LayoutUnit);
45 bool recalculateColumnHeight(BalancedColumnHeightCalculation calculationMode );
46
47 void expandToEncompassFlowThreadOverflow();
48
49 LayoutSize flowThreadTranslationAtOffset(LayoutUnit offsetInFlowThread) cons t;
50 LayoutUnit columnLogicalTopForOffset(LayoutUnit offsetInFlowThread) const;
51 void collectLayerFragments(LayerFragments&, const LayoutRect& layerBoundingB ox, const LayoutRect& dirtyRect);
52 LayoutRect calculateOverflow() const;
53
54 // The "CSS actual" value of column-count. This includes overflowing columns , if any.
55 unsigned actualColumnCount() const;
56
57 private:
58 LayoutUnit heightAdjustedForRowOffset(LayoutUnit height) const;
59 LayoutUnit calculateMaxColumnHeight() const;
60 void setAndConstrainColumnHeight(LayoutUnit);
61
62 // Return the index of the content run with the currently tallest columns, t aking all implicit
63 // breaks assumed so far into account.
64 unsigned findRunWithTallestColumns() const;
65
66 // Given the current list of content runs, make assumptions about where we n eed to insert
67 // implicit breaks (if there's room for any at all; depending on the number of explicit breaks),
68 // and store the results. This is needed in order to balance the columns.
69 void distributeImplicitBreaks();
70
71 LayoutUnit calculateColumnHeight(BalancedColumnHeightCalculation) const;
72
73 LayoutRect columnRectAt(unsigned columnIndex) const;
74 LayoutRect flowThreadPortionRectAt(unsigned columnIndex) const;
75 LayoutRect flowThreadPortionOverflowRect(const LayoutRect& flowThreadPortion , unsigned columnIndex, unsigned columnCount, LayoutUnit columnGap) const;
76
77 enum ColumnIndexCalculationMode {
78 ClampToExistingColumns, // Stay within the range of already existing col umns.
79 AssumeNewColumns // Allow column indices outside the range of already ex isting columns.
80 };
81 unsigned columnIndexAtOffset(LayoutUnit offsetInFlowThread, ColumnIndexCalcu lationMode = ClampToExistingColumns) const;
82
83 RenderMultiColumnSet& m_columnSet;
84
85 LayoutUnit m_logicalTop;
86 LayoutUnit m_logicalTopInFlowThread;
87 LayoutUnit m_logicalBottomInFlowThread;
88
89 LayoutUnit m_columnHeight;
90
91 // The following variables are used when balancing the column set.
92 LayoutUnit m_maxColumnHeight; // Maximum column height allowed.
93 LayoutUnit m_minSpaceShortage; // The smallest amout of space shortage that caused a column break.
94 LayoutUnit m_minimumColumnHeight;
95
96 // A run of content without explicit (forced) breaks; i.e. a flow thread por tion between two
97 // explicit breaks, between flow thread start and an explicit break, between an explicit break
98 // and flow thread end, or, in cases when there are no explicit breaks at al l: between flow
99 // thread portion start and flow thread portion end. We need to know where t he explicit breaks
100 // are, in order to figure out where the implicit breaks will end up, so tha t we get the columns
101 // properly balanced. A content run starts out as representing one single co lumn, and will
102 // represent one additional column for each implicit break "inserted" there.
103 class ContentRun {
104 public:
105 ContentRun(LayoutUnit breakOffset)
106 : m_breakOffset(breakOffset)
107 , m_assumedImplicitBreaks(0) { }
108
109 unsigned assumedImplicitBreaks() const { return m_assumedImplicitBreaks; }
110 void assumeAnotherImplicitBreak() { m_assumedImplicitBreaks++; }
111 LayoutUnit breakOffset() const { return m_breakOffset; }
112
113 // Return the column height that this content run would require, conside ring the implicit
114 // breaks assumed so far.
115 LayoutUnit columnLogicalHeight(LayoutUnit startOffset) const { return ce ilf((m_breakOffset - startOffset).toFloat() / float(m_assumedImplicitBreaks + 1) ); }
116
117 private:
118 LayoutUnit m_breakOffset; // Flow thread offset where this run ends.
119 unsigned m_assumedImplicitBreaks; // Number of implicit breaks in this r un assumed so far.
120 };
121 Vector<ContentRun, 1> m_contentRuns;
122 };
123
124 } // namespace blink
125
126 #endif // MultiColumnRow_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698