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

Side by Side Diff: third_party/WebKit/Source/core/layout/ColumnBalancer.h

Issue 1461923005: When balancing columns, we must check inner multicols for unbreakable content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: code review - std::max FTW Created 5 years, 1 month 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/layout/MultiColumnFragmentainerGroup.h" 5 #include "core/layout/MultiColumnFragmentainerGroup.h"
6 6
7 namespace blink { 7 namespace blink {
8 8
9 // A column balancer traverses the portion of the subtree of a flow thread that belongs to a given 9 // A column balancer traverses the portion of the subtree of a flow thread that belongs to a given
10 // fragmentainer group, in order to collect certain data to be used for column b alancing. This is an 10 // fragmentainer group, in order to collect certain data to be used for column b alancing. This is an
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 // After an initial layout pass, we know the height of the contents of a flow th read. Based on 55 // After an initial layout pass, we know the height of the contents of a flow th read. Based on
56 // this, we can estimate an initial minimal column height. This class will colle ct the necessary 56 // this, we can estimate an initial minimal column height. This class will colle ct the necessary
57 // information from the layout objects to make this estimate. This estimate may be used to perform 57 // information from the layout objects to make this estimate. This estimate may be used to perform
58 // another layout iteration. If we after such a layout iteration cannot fit the contents with the 58 // another layout iteration. If we after such a layout iteration cannot fit the contents with the
59 // given column height without creating overflowing columns, we will have to str etch the columns by 59 // given column height without creating overflowing columns, we will have to str etch the columns by
60 // some amount and lay out again. We may need to do this several times (but typi cally not more 60 // some amount and lay out again. We may need to do this several times (but typi cally not more
61 // times than the number of columns that we have). The amount to stretch is prov ided by the sister 61 // times than the number of columns that we have). The amount to stretch is prov ided by the sister
62 // of this class, named MinimumSpaceShortageFinder. 62 // of this class, named MinimumSpaceShortageFinder.
63 class InitialColumnHeightFinder final : public ColumnBalancer { 63 class InitialColumnHeightFinder final : public ColumnBalancer {
64 public: 64 public:
65 static LayoutUnit initialMinimalBalancedHeight(const MultiColumnFragmentaine rGroup& group)
66 {
67 return InitialColumnHeightFinder(group).initialMinimalBalancedHeight();
68 }
69
70 private:
71 InitialColumnHeightFinder(const MultiColumnFragmentainerGroup&); 65 InitialColumnHeightFinder(const MultiColumnFragmentainerGroup&);
72 66
73 LayoutUnit initialMinimalBalancedHeight() const; 67 LayoutUnit initialMinimalBalancedHeight() const;
74 68
69 // Height of the tallest piece of unbreakable content. This is the minimum c olumn logical height
70 // required to avoid fragmentation where it shouldn't occur (inside unbreaka ble content, between
71 // orphans and widows, etc.). This will be used as a hint to the column bala ncer to help set a
72 // good initial column height.
73 LayoutUnit tallestUnbreakableLogicalHeight() const { return m_tallestUnbreak ableLogicalHeight; }
74
75 private:
75 void examineBoxAfterEntering(const LayoutBox&); 76 void examineBoxAfterEntering(const LayoutBox&);
76 void examineBoxBeforeLeaving(const LayoutBox&); 77 void examineBoxBeforeLeaving(const LayoutBox&);
77 void examineLine(const RootInlineBox&); 78 void examineLine(const RootInlineBox&);
78 79
79 // Record that there's a pagination strut that ends at the specified |offset InFlowThread|, which 80 // Record that there's a pagination strut that ends at the specified |offset InFlowThread|, which
80 // is an offset exactly at the top of some column. 81 // is an offset exactly at the top of some column.
81 void recordStrutBeforeOffset(LayoutUnit offsetInFlowThread, LayoutUnit strut ); 82 void recordStrutBeforeOffset(LayoutUnit offsetInFlowThread, LayoutUnit strut );
82 83
83 // Return the accumulated space used by struts at all column boundaries prec eding the specified 84 // Return the accumulated space used by struts at all column boundaries prec eding the specified
84 // flowthread offset. 85 // flowthread offset.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 // interested in the shortest one. For example, when having a float beside r egular in-flow 133 // interested in the shortest one. For example, when having a float beside r egular in-flow
133 // content, we end up with two parallel fragmentation flows [1]. The shortes t strut found at a 134 // content, we end up with two parallel fragmentation flows [1]. The shortes t strut found at a
134 // column boundary is the amount of space that we wasted at said column boun dary, and it needs 135 // column boundary is the amount of space that we wasted at said column boun dary, and it needs
135 // to be deducted when estimating the initial balanced column height, or we risk making the 136 // to be deducted when estimating the initial balanced column height, or we risk making the
136 // column row too tall. An entry set to LayoutUnit::max() means that we didn 't detect any object 137 // column row too tall. An entry set to LayoutUnit::max() means that we didn 't detect any object
137 // crossing that boundary. 138 // crossing that boundary.
138 // 139 //
139 // [1] http://www.w3.org/TR/css3-break/#parallel-flows 140 // [1] http://www.w3.org/TR/css3-break/#parallel-flows
140 Vector<LayoutUnit, 32> m_shortestStruts; 141 Vector<LayoutUnit, 32> m_shortestStruts;
141 142
142 LayoutUnit m_minimumColumnLogicalHeight; 143 LayoutUnit m_tallestUnbreakableLogicalHeight;
143 }; 144 };
144 145
145 // If we have previously used InitialColumnHeightFinder to estimate an initial c olumn height, and 146 // If we have previously used InitialColumnHeightFinder to estimate an initial c olumn height, and
146 // that didn't result in tall enough columns, we need subsequent layout passes w here we increase 147 // that didn't result in tall enough columns, we need subsequent layout passes w here we increase
147 // the column height by the minimum space shortage at column breaks. This class finds the minimum 148 // the column height by the minimum space shortage at column breaks. This class finds the minimum
148 // space shortage after having laid out with the current column height. 149 // space shortage after having laid out with the current column height.
149 class MinimumSpaceShortageFinder final : public ColumnBalancer { 150 class MinimumSpaceShortageFinder final : public ColumnBalancer {
150 public: 151 public:
151 MinimumSpaceShortageFinder(const MultiColumnFragmentainerGroup&); 152 MinimumSpaceShortageFinder(const MultiColumnFragmentainerGroup&);
152 153
(...skipping 18 matching lines...) Expand all
171 LayoutUnit m_minimumSpaceShortage; 172 LayoutUnit m_minimumSpaceShortage;
172 173
173 // Set when breaking before a block, and we're looking for the first unbreak able descendant, in 174 // Set when breaking before a block, and we're looking for the first unbreak able descendant, in
174 // order to report correct space shortage for that one. 175 // order to report correct space shortage for that one.
175 LayoutUnit m_pendingStrut; 176 LayoutUnit m_pendingStrut;
176 177
177 unsigned m_forcedBreaksCount; 178 unsigned m_forcedBreaksCount;
178 }; 179 };
179 180
180 } // namespace blink 181 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698