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

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

Issue 267373005: [New Multicolumn] Use the term "content run" in favor of "forced break". (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 7 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
1 /* 1 /*
2 * Copyright (C) 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 RenderBlockFlow* multiColumnBlockFlow() const { return toRenderBlockFlow(par ent()); } 59 RenderBlockFlow* multiColumnBlockFlow() const { return toRenderBlockFlow(par ent()); }
60 RenderMultiColumnFlowThread* multiColumnFlowThread() const 60 RenderMultiColumnFlowThread* multiColumnFlowThread() const
61 { 61 {
62 ASSERT_WITH_SECURITY_IMPLICATION(!flowThread() || flowThread()->isRender MultiColumnFlowThread()); 62 ASSERT_WITH_SECURITY_IMPLICATION(!flowThread() || flowThread()->isRender MultiColumnFlowThread());
63 return static_cast<RenderMultiColumnFlowThread*>(flowThread()); 63 return static_cast<RenderMultiColumnFlowThread*>(flowThread());
64 } 64 }
65 65
66 RenderMultiColumnSet* nextSiblingMultiColumnSet() const; 66 RenderMultiColumnSet* nextSiblingMultiColumnSet() const;
67 67
68 LayoutUnit logicalTopInFlowThread() const { return isHorizontalWritingMode() ? flowThreadPortionRect().y() : flowThreadPortionRect().x(); }
68 LayoutUnit logicalBottomInFlowThread() const { return isHorizontalWritingMod e() ? flowThreadPortionRect().maxY() : flowThreadPortionRect().maxX(); } 69 LayoutUnit logicalBottomInFlowThread() const { return isHorizontalWritingMod e() ? flowThreadPortionRect().maxY() : flowThreadPortionRect().maxX(); }
69 70
70 unsigned computedColumnCount() const { return m_computedColumnCount; } 71 unsigned computedColumnCount() const { return m_computedColumnCount; }
71 LayoutUnit computedColumnWidth() const { return m_computedColumnWidth; } 72 LayoutUnit computedColumnWidth() const { return m_computedColumnWidth; }
72 LayoutUnit computedColumnHeight() const { return m_computedColumnHeight; } 73 LayoutUnit computedColumnHeight() const { return m_computedColumnHeight; }
73 74
74 void setComputedColumnWidthAndCount(LayoutUnit width, unsigned count) 75 void setComputedColumnWidthAndCount(LayoutUnit width, unsigned count)
75 { 76 {
76 m_computedColumnWidth = width; 77 m_computedColumnWidth = width;
77 m_computedColumnCount = count; 78 m_computedColumnCount = count;
78 } 79 }
79 80
80 // Find the column that contains the given block offset, and return the tran slation needed to 81 // Find the column that contains the given block offset, and return the tran slation needed to
81 // get from flow thread coordinates to visual coordinates. 82 // get from flow thread coordinates to visual coordinates.
82 LayoutSize flowThreadTranslationAtOffset(LayoutUnit) const; 83 LayoutSize flowThreadTranslationAtOffset(LayoutUnit) const;
83 84
84 LayoutUnit heightAdjustedForSetOffset(LayoutUnit height) const; 85 LayoutUnit heightAdjustedForSetOffset(LayoutUnit height) const;
85 86
86 void updateMinimumColumnHeight(LayoutUnit height) { m_minimumColumnHeight = std::max(height, m_minimumColumnHeight); } 87 void updateMinimumColumnHeight(LayoutUnit height) { m_minimumColumnHeight = std::max(height, m_minimumColumnHeight); }
87 LayoutUnit minimumColumnHeight() const { return m_minimumColumnHeight; } 88 LayoutUnit minimumColumnHeight() const { return m_minimumColumnHeight; }
88 89
89 unsigned forcedBreaksCount() const { return m_contentRuns.size(); } 90 // Add a content run, specified by its end position. A content run is append ed at every
90 void clearForcedBreaks(); 91 // forced/explicit break and at the end of the column set. The content runs are used to
91 void addForcedBreak(LayoutUnit offsetFromFirstPage); 92 // determine where implicit/soft breaks will occur, in order to calculate an initial column
93 // height.
94 void addContentRun(LayoutUnit endOffsetFromFirstPage);
92 95
93 // (Re-)calculate the column height if it's auto. If 'initial' is set, guess an initial column 96 // (Re-)calculate the column height if it's auto. If 'initial' is set, guess an initial column
94 // height; otherwise, stretch the column height a tad. Return true if column height changed and 97 // height; otherwise, stretch the column height a tad. Return true if column height changed and
95 // another layout pass is required. 98 // another layout pass is required.
96 bool recalculateColumnHeight(bool initial); 99 bool recalculateColumnHeight(bool initial);
97 100
98 // Record space shortage (the amount of space that would have been enough to prevent some 101 // Record space shortage (the amount of space that would have been enough to prevent some
99 // element from being moved to the next column) at a column break. The small est amount of space 102 // element from being moved to the next column) at a column break. The small est amount of space
100 // shortage we find is the amount with which we will stretch the column heig ht, if it turns out 103 // shortage we find is the amount with which we will stretch the column heig ht, if it turns out
101 // after layout that the columns weren't tall enough. 104 // after layout that the columns weren't tall enough.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 LayoutUnit m_computedColumnWidth; // Used column width (the resulting 'W' fr om the pseudo-algorithm in the multicol spec) 165 LayoutUnit m_computedColumnWidth; // Used column width (the resulting 'W' fr om the pseudo-algorithm in the multicol spec)
163 LayoutUnit m_computedColumnHeight; 166 LayoutUnit m_computedColumnHeight;
164 167
165 // The following variables are used when balancing the column set. 168 // The following variables are used when balancing the column set.
166 LayoutUnit m_maxColumnHeight; // Maximum column height allowed. 169 LayoutUnit m_maxColumnHeight; // Maximum column height allowed.
167 LayoutUnit m_minSpaceShortage; // The smallest amout of space shortage that caused a column break. 170 LayoutUnit m_minSpaceShortage; // The smallest amout of space shortage that caused a column break.
168 LayoutUnit m_minimumColumnHeight; 171 LayoutUnit m_minimumColumnHeight;
169 172
170 // A run of content without explicit (forced) breaks; i.e. a flow thread por tion between two 173 // A run of content without explicit (forced) breaks; i.e. a flow thread por tion between two
171 // explicit breaks, between flow thread start and an explicit break, between an explicit break 174 // explicit breaks, between flow thread start and an explicit break, between an explicit break
172 // and flow thread end, or, in cases when there are no explicit breaks at al l: between flow flow 175 // and flow thread end, or, in cases when there are no explicit breaks at al l: between flow
173 // thread start and flow thread end. We need to know where the explicit brea ks are, in order to 176 // thread portion start and flow thread portion end. We need to know where t he explicit breaks
174 // figure out where the implicit breaks will end up, so that we get the colu mns properly 177 // are, in order to figure out where the implicit breaks will end up, so tha t we get the columns
175 // balanced. A content run starts out as representing one single column, and will represent one 178 // properly balanced. A content run starts out as representing one single co lumn, and will
176 // additional column for each implicit break "inserted" there. 179 // represent one additional column for each implicit break "inserted" there.
177 class ContentRun { 180 class ContentRun {
178 public: 181 public:
179 ContentRun(LayoutUnit breakOffset) 182 ContentRun(LayoutUnit breakOffset)
180 : m_breakOffset(breakOffset) 183 : m_breakOffset(breakOffset)
181 , m_assumedImplicitBreaks(0) { } 184 , m_assumedImplicitBreaks(0) { }
182 185
183 unsigned assumedImplicitBreaks() const { return m_assumedImplicitBreaks; } 186 unsigned assumedImplicitBreaks() const { return m_assumedImplicitBreaks; }
184 void assumeAnotherImplicitBreak() { m_assumedImplicitBreaks++; } 187 void assumeAnotherImplicitBreak() { m_assumedImplicitBreaks++; }
185 LayoutUnit breakOffset() const { return m_breakOffset; } 188 LayoutUnit breakOffset() const { return m_breakOffset; }
186 189
187 // Return the column height that this content run would require, conside ring the implicit 190 // Return the column height that this content run would require, conside ring the implicit
188 // breaks assumed so far. 191 // breaks assumed so far.
189 LayoutUnit columnLogicalHeight(LayoutUnit startOffset) const { return ce ilf((m_breakOffset - startOffset).toFloat() / float(m_assumedImplicitBreaks + 1) ); } 192 LayoutUnit columnLogicalHeight(LayoutUnit startOffset) const { return ce ilf((m_breakOffset - startOffset).toFloat() / float(m_assumedImplicitBreaks + 1) ); }
190 193
191 private: 194 private:
192 LayoutUnit m_breakOffset; // Flow thread offset where this run ends. 195 LayoutUnit m_breakOffset; // Flow thread offset where this run ends.
193 unsigned m_assumedImplicitBreaks; // Number of implicit breaks in this r un assumed so far. 196 unsigned m_assumedImplicitBreaks; // Number of implicit breaks in this r un assumed so far.
194 }; 197 };
195 Vector<ContentRun, 1> m_contentRuns; 198 Vector<ContentRun, 1> m_contentRuns;
196 }; 199 };
197 200
198 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderMultiColumnSet, isRenderMultiColumnSet()); 201 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderMultiColumnSet, isRenderMultiColumnSet());
199 202
200 } // namespace WebCore 203 } // namespace WebCore
201 204
202 #endif // RenderMultiColumnSet_h 205 #endif // RenderMultiColumnSet_h
203 206
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderMultiColumnFlowThread.cpp ('k') | Source/core/rendering/RenderMultiColumnSet.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698