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

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

Issue 16943008: Column balancing support in the region based multicol implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 6 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 49
50 unsigned computedColumnCount() const { return m_computedColumnCount; } 50 unsigned computedColumnCount() const { return m_computedColumnCount; }
51 LayoutUnit computedColumnWidth() const { return m_computedColumnWidth; } 51 LayoutUnit computedColumnWidth() const { return m_computedColumnWidth; }
52 LayoutUnit computedColumnHeight() const { return m_computedColumnHeight; } 52 LayoutUnit computedColumnHeight() const { return m_computedColumnHeight; }
53 53
54 void setComputedColumnWidthAndCount(LayoutUnit width, unsigned count) 54 void setComputedColumnWidthAndCount(LayoutUnit width, unsigned count)
55 { 55 {
56 m_computedColumnWidth = width; 56 m_computedColumnWidth = width;
57 m_computedColumnCount = count; 57 m_computedColumnCount = count;
58 } 58 }
59 void setComputedColumnHeight(LayoutUnit height) 59
60 { 60 LayoutUnit heightAdjustedForSetOffset(LayoutUnit height) const;
61 m_computedColumnHeight = height;
62 }
63 61
64 void updateMinimumColumnHeight(LayoutUnit height) { m_minimumColumnHeight = std::max(height, m_minimumColumnHeight); } 62 void updateMinimumColumnHeight(LayoutUnit height) { m_minimumColumnHeight = std::max(height, m_minimumColumnHeight); }
65 LayoutUnit minimumColumnHeight() const { return m_minimumColumnHeight; } 63 LayoutUnit minimumColumnHeight() const { return m_minimumColumnHeight; }
66 64
67 unsigned forcedBreaksCount() const { return m_forcedBreaksCount; } 65 unsigned forcedBreaksCount() const { return m_forcedBreaksCount; }
68 LayoutUnit forcedBreakOffset() const { return m_forcedBreakOffset; } 66 LayoutUnit forcedBreakOffset() const { return m_forcedBreakOffset; }
69 LayoutUnit maximumDistanceBetweenForcedBreaks() const { return m_maximumDist anceBetweenForcedBreaks; } 67 LayoutUnit maximumDistanceBetweenForcedBreaks() const { return m_maximumDist anceBetweenForcedBreaks; }
70 void clearForcedBreaks() 68 void clearForcedBreaks()
71 { 69 {
72 m_forcedBreaksCount = 0; 70 m_forcedBreaksCount = 0;
73 m_maximumDistanceBetweenForcedBreaks = 0; 71 m_maximumDistanceBetweenForcedBreaks = 0;
74 m_forcedBreakOffset = 0; 72 m_forcedBreakOffset = 0;
75 } 73 }
76 void addForcedBreak(LayoutUnit offsetFromFirstPage) 74 void addForcedBreak(LayoutUnit offsetFromFirstPage)
77 { 75 {
78 ASSERT(!computedColumnHeight()); 76 ASSERT(!computedColumnHeight());
79 LayoutUnit distanceFromLastBreak = offsetFromFirstPage - m_forcedBreakOf fset; 77 LayoutUnit distanceFromLastBreak = offsetFromFirstPage - m_forcedBreakOf fset;
80 if (!distanceFromLastBreak) 78 if (!distanceFromLastBreak)
81 return; 79 return;
82 m_forcedBreaksCount++; 80 m_forcedBreaksCount++;
83 m_maximumDistanceBetweenForcedBreaks = std::max(m_maximumDistanceBetween ForcedBreaks, distanceFromLastBreak); 81 m_maximumDistanceBetweenForcedBreaks = std::max(m_maximumDistanceBetween ForcedBreaks, distanceFromLastBreak);
84 m_forcedBreakOffset = offsetFromFirstPage; 82 m_forcedBreakOffset = offsetFromFirstPage;
85 } 83 }
86 84
87 bool requiresBalancing() const { return m_requiresBalancing; } 85 // Calculate the column height when contents are supposed to be balanced. If 'initial' is set,
88 void setRequiresBalancing(bool balancing) { m_requiresBalancing = balancing; } 86 // guess an initial column height; otherwise, stretch the column height a ta d. Return true if
87 // column height changed and another layout pass is required.
88 bool calculateBalancedHeight(bool initial);
89
90 // Record space shortage (the amount of space that would have been enough to prevent some
91 // element from being moved to the next column) at a column break. The small est amount of space
92 // shortage we find is the amount with which we will stretch the column heig ht, if it turns out
93 // after layout that the columns weren't tall enough.
94 void recordSpaceShortage(LayoutUnit spaceShortage);
89 95
90 virtual void updateLogicalWidth() OVERRIDE; 96 virtual void updateLogicalWidth() OVERRIDE;
91 virtual void updateLogicalHeight() OVERRIDE; 97
92 98 void prepareForLayout();
99
93 private: 100 private:
94 RenderMultiColumnSet(RenderFlowThread*); 101 RenderMultiColumnSet(RenderFlowThread*);
95 102
96 virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logic alTop, LogicalExtentComputedValues&) const OVERRIDE; 103 virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logic alTop, LogicalExtentComputedValues&) const OVERRIDE;
97 104
98 virtual void paintObject(PaintInfo&, const LayoutPoint& paintOffset) OVERRID E; 105 virtual void paintObject(PaintInfo&, const LayoutPoint& paintOffset) OVERRID E;
99 106
100 virtual LayoutUnit pageLogicalWidth() const OVERRIDE { return m_computedColu mnWidth; } 107 virtual LayoutUnit pageLogicalWidth() const OVERRIDE { return m_computedColu mnWidth; }
101 virtual LayoutUnit pageLogicalHeight() const OVERRIDE { return m_computedCol umnHeight; } 108 virtual LayoutUnit pageLogicalHeight() const OVERRIDE { return m_computedCol umnHeight; }
102 109
(...skipping 13 matching lines...) Expand all
116 virtual const char* renderName() const; 123 virtual const char* renderName() const;
117 124
118 void paintColumnRules(PaintInfo&, const LayoutPoint& paintOffset); 125 void paintColumnRules(PaintInfo&, const LayoutPoint& paintOffset);
119 126
120 LayoutUnit columnGap() const; 127 LayoutUnit columnGap() const;
121 LayoutRect columnRectAt(unsigned index) const; 128 LayoutRect columnRectAt(unsigned index) const;
122 unsigned columnCount() const; 129 unsigned columnCount() const;
123 130
124 LayoutRect flowThreadPortionRectAt(unsigned index) const; 131 LayoutRect flowThreadPortionRectAt(unsigned index) const;
125 LayoutRect flowThreadPortionOverflowRect(const LayoutRect& flowThreadPortion , unsigned index, unsigned colCount, LayoutUnit colGap) const; 132 LayoutRect flowThreadPortionOverflowRect(const LayoutRect& flowThreadPortion , unsigned index, unsigned colCount, LayoutUnit colGap) const;
126 133
127 unsigned columnIndexAtOffset(LayoutUnit) const; 134 enum ColumnIndexCalculationMode {
128 135 ClampToExistingColumns, // Stay within the range of already existing col umns.
136 AssumeNewColumns // Allow column indices outside the range of already ex isting columns.
137 };
138 unsigned columnIndexAtOffset(LayoutUnit, ColumnIndexCalculationMode = ClampT oExistingColumns) const;
139
140 void setAndConstrainColumnHeight(LayoutUnit);
141
129 unsigned m_computedColumnCount; 142 unsigned m_computedColumnCount;
130 LayoutUnit m_computedColumnWidth; 143 LayoutUnit m_computedColumnWidth;
131 LayoutUnit m_computedColumnHeight; 144 LayoutUnit m_computedColumnHeight;
132 145
133 // The following variables are used when balancing the column set. 146 // The following variables are used when balancing the column set.
134 bool m_requiresBalancing; // Whether or not the columns in the column set ha ve to be balanced, i.e., made to be similar logical heights. 147 LayoutUnit m_maxColumnHeight; // Maximum column height allowed.
148 LayoutUnit m_minSpaceShortage; // The smallest amout of space shortage that caused a column break.
135 LayoutUnit m_minimumColumnHeight; 149 LayoutUnit m_minimumColumnHeight;
136 unsigned m_forcedBreaksCount; // FIXME: We will ultimately need to cache mor e information to balance around forced breaks properly. 150 unsigned m_forcedBreaksCount; // FIXME: We will ultimately need to cache mor e information to balance around forced breaks properly.
137 LayoutUnit m_maximumDistanceBetweenForcedBreaks; 151 LayoutUnit m_maximumDistanceBetweenForcedBreaks;
138 LayoutUnit m_forcedBreakOffset; 152 LayoutUnit m_forcedBreakOffset;
139 }; 153 };
140 154
141 inline RenderMultiColumnSet* toRenderMultiColumnSet(RenderObject* object) 155 inline RenderMultiColumnSet* toRenderMultiColumnSet(RenderObject* object)
142 { 156 {
143 ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isRenderMultiColumnSet() ); 157 ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isRenderMultiColumnSet() );
144 return static_cast<RenderMultiColumnSet*>(object); 158 return static_cast<RenderMultiColumnSet*>(object);
145 } 159 }
146 160
147 inline const RenderMultiColumnSet* toRenderMultiColumnSet(const RenderObject* ob ject) 161 inline const RenderMultiColumnSet* toRenderMultiColumnSet(const RenderObject* ob ject)
148 { 162 {
149 ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isRenderMultiColumnSet() ); 163 ASSERT_WITH_SECURITY_IMPLICATION(!object || object->isRenderMultiColumnSet() );
150 return static_cast<const RenderMultiColumnSet*>(object); 164 return static_cast<const RenderMultiColumnSet*>(object);
151 } 165 }
152 166
153 // This will catch anyone doing an unnecessary cast. 167 // This will catch anyone doing an unnecessary cast.
154 void toRenderMultiColumnSet(const RenderMultiColumnSet*); 168 void toRenderMultiColumnSet(const RenderMultiColumnSet*);
155 169
156 } // namespace WebCore 170 } // namespace WebCore
157 171
158 #endif // RenderMultiColumnSet_h 172 #endif // RenderMultiColumnSet_h
159 173
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