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

Side by Side Diff: Source/core/layout/MultiColumnFragmentainerGroup.h

Issue 883293004: [New Multicolumn] Preparatory work for nested multicol support. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Place the new files in ../layout/ , since that's where they'll end up soon anyway. 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 MultiColumnFragmentainerGroup_h
6 #define MultiColumnFragmentainerGroup_h
7
8 #include "core/rendering/RenderMultiColumnFlowThread.h"
9
10 namespace blink {
11
12 // A group of columns, that are laid out in the inline progression direction, al l with the same
13 // column height.
14 //
15 // When a multicol container is inside another fragmentation context, and said m ulticol container
16 // lives in multiple outer fragmentainers (pages / columns), we need to put thes e inner columns into
17 // separate groups, with one group per outer fragmentainer. Such a group of colu mns is what
18 // comprises a "row of column boxes" in spec lingo.
19 //
20 // Column balancing, when enabled, takes place within a column fragmentainer gro up.
21 //
22 // Each fragmentainer group may have its own actual column count (if there are u nused columns
23 // because of forced breaks, for example). If there are multiple fragmentainer g roups, the actual
24 // column count must not exceed the used column count (the one calculated based on column-count and
25 // column-width from CSS), or they'd overflow the outer fragmentainer in the inl ine direction. If we
26 // need more columns than what a group has room for, we'll create another group and put them there
27 // (and make them appear in the next outer fragmentainer).
28 class MultiColumnFragmentainerGroup {
29 public:
30 MultiColumnFragmentainerGroup(RenderMultiColumnSet&);
31
32 bool isLastGroup() const;
33
34 // Position within the RenderMultiColumnSet.
35 LayoutUnit logicalTop() const { return m_logicalTop; }
36
37 LayoutUnit logicalHeight() const { return m_columnHeight; }
38
39 LayoutSize offsetFromColumnSet() const;
40
41 // The top of our flow thread portion
42 LayoutUnit logicalTopInFlowThread() const { return m_logicalTopInFlowThread; }
43 void setLogicalTopInFlowThread(LayoutUnit logicalTopInFlowThread) { m_logica lTopInFlowThread = logicalTopInFlowThread; }
44
45 // The bottom of our flow thread portion
46 LayoutUnit logicalBottomInFlowThread() const { return m_logicalBottomInFlowT hread; }
47 void setLogicalBottomInFlowThread(LayoutUnit logicalBottomInFlowThread) { m_ logicalBottomInFlowThread = logicalBottomInFlowThread; }
48
49 // The height of our flow thread portion
50 LayoutUnit logicalHeightInFlowThread() const { return m_logicalBottomInFlowT hread - m_logicalTopInFlowThread; }
51
52 bool heightIsAuto() const;
53 void resetColumnHeight();
54 void addContentRun(LayoutUnit endOffsetInFlowThread);
55 void updateMinimumColumnHeight(LayoutUnit height) { m_minimumColumnHeight = std::max(height, m_minimumColumnHeight); }
56 void recordSpaceShortage(LayoutUnit);
57 bool recalculateColumnHeight(BalancedColumnHeightCalculation calculationMode );
58
59 void expandToEncompassFlowThreadOverflow();
60
61 LayoutSize flowThreadTranslationAtOffset(LayoutUnit offsetInFlowThread) cons t;
62 LayoutUnit columnLogicalTopForOffset(LayoutUnit offsetInFlowThread) const;
63 void collectLayerFragments(LayerFragments&, const LayoutRect& layerBoundingB ox, const LayoutRect& dirtyRect) const;
64 LayoutRect calculateOverflow() const;
65
66 // The "CSS actual" value of column-count. This includes overflowing columns , if any.
67 unsigned actualColumnCount() const;
68
69 private:
70 LayoutUnit heightAdjustedForRowOffset(LayoutUnit height) const;
71 LayoutUnit calculateMaxColumnHeight() const;
72 void setAndConstrainColumnHeight(LayoutUnit);
73
74 // Return the index of the content run with the currently tallest columns, t aking all implicit
75 // breaks assumed so far into account.
76 unsigned findRunWithTallestColumns() const;
Julien - ping for review 2015/02/11 07:25:29 I think we should use size_t for indexes (we are i
mstensho (USE GERRIT) 2015/02/11 09:49:55 This is just code that got moved. Let's fix this i
77
78 // Given the current list of content runs, make assumptions about where we n eed to insert
79 // implicit breaks (if there's room for any at all; depending on the number of explicit breaks),
80 // and store the results. This is needed in order to balance the columns.
81 void distributeImplicitBreaks();
82
83 LayoutUnit calculateColumnHeight(BalancedColumnHeightCalculation) const;
84
85 LayoutRect columnRectAt(unsigned columnIndex) const;
86 LayoutRect flowThreadPortionRectAt(unsigned columnIndex) const;
87 LayoutRect flowThreadPortionOverflowRect(const LayoutRect& flowThreadPortion , unsigned columnIndex, unsigned columnCount, LayoutUnit columnGap) const;
88
89 enum ColumnIndexCalculationMode {
90 ClampToExistingColumns, // Stay within the range of already existing col umns.
91 AssumeNewColumns // Allow column indices outside the range of already ex isting columns.
92 };
93 unsigned columnIndexAtOffset(LayoutUnit offsetInFlowThread, ColumnIndexCalcu lationMode = ClampToExistingColumns) const;
94
95 RenderMultiColumnSet& m_columnSet;
96
97 LayoutUnit m_logicalTop;
98 LayoutUnit m_logicalTopInFlowThread;
99 LayoutUnit m_logicalBottomInFlowThread;
100
101 LayoutUnit m_columnHeight;
102
103 // The following variables are used when balancing the column set.
104 LayoutUnit m_maxColumnHeight; // Maximum column height allowed.
105 LayoutUnit m_minSpaceShortage; // The smallest amout of space shortage that caused a column break.
106 LayoutUnit m_minimumColumnHeight;
107
108 // A run of content without explicit (forced) breaks; i.e. a flow thread por tion between two
109 // explicit breaks, between flow thread start and an explicit break, between an explicit break
110 // and flow thread end, or, in cases when there are no explicit breaks at al l: between flow
111 // thread portion start and flow thread portion end. We need to know where t he explicit breaks
112 // are, in order to figure out where the implicit breaks will end up, so tha t we get the columns
113 // properly balanced. A content run starts out as representing one single co lumn, and will
114 // represent one additional column for each implicit break "inserted" there.
115 class ContentRun {
116 public:
117 ContentRun(LayoutUnit breakOffset)
118 : m_breakOffset(breakOffset)
119 , m_assumedImplicitBreaks(0) { }
120
121 unsigned assumedImplicitBreaks() const { return m_assumedImplicitBreaks; }
122 void assumeAnotherImplicitBreak() { m_assumedImplicitBreaks++; }
123 LayoutUnit breakOffset() const { return m_breakOffset; }
124
125 // Return the column height that this content run would require, conside ring the implicit
126 // breaks assumed so far.
127 LayoutUnit columnLogicalHeight(LayoutUnit startOffset) const { return ce ilf((m_breakOffset - startOffset).toFloat() / float(m_assumedImplicitBreaks + 1) ); }
128
129 private:
130 LayoutUnit m_breakOffset; // Flow thread offset where this run ends.
131 unsigned m_assumedImplicitBreaks; // Number of implicit breaks in this r un assumed so far.
132 };
133 Vector<ContentRun, 1> m_contentRuns;
134 };
135
136 // List of all fragmentainer groups within a column set. There will always be at least one
137 // group. Deleting the one group is not allowed (or possible). There will be mor e than one group if
138 // the owning column set lives in multiple outer fragmentainers (e.g. multicol i nside paged media).
139 class MultiColumnFragmentainerGroupList : public Vector<MultiColumnFragmentainer Group, 1> {
Nico 2015/04/09 04:39:34 Let's not derive from container types. If your cla
140 public:
141 MultiColumnFragmentainerGroupList(RenderMultiColumnSet&);
142
143 // Add an additional fragmentainer group to the end of the list, and return it.
144 MultiColumnFragmentainerGroup& addExtraGroup();
145
146 // Remove all fragmentainer groups but the first one.
147 void deleteExtraGroups();
148
149 private:
150 RenderMultiColumnSet& m_columnSet;
151 };
152
153 } // namespace blink
154
155 #endif // MultiColumnFragmentainerGroup_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698