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

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

Issue 792803002: [New Multicolumn] Layout support for column-span:all. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@347325-placeholder
Patch Set: Code review. If there are no sets, return early. Created 5 years, 11 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 RenderBlockFlow* multiColumnBlockFlow() const { return toRenderBlockFlow(par ent()); } 64 RenderBlockFlow* multiColumnBlockFlow() const { return toRenderBlockFlow(par ent()); }
65 RenderMultiColumnFlowThread* multiColumnFlowThread() const 65 RenderMultiColumnFlowThread* multiColumnFlowThread() const
66 { 66 {
67 ASSERT_WITH_SECURITY_IMPLICATION(!flowThread() || flowThread()->isRender MultiColumnFlowThread()); 67 ASSERT_WITH_SECURITY_IMPLICATION(!flowThread() || flowThread()->isRender MultiColumnFlowThread());
68 return static_cast<RenderMultiColumnFlowThread*>(flowThread()); 68 return static_cast<RenderMultiColumnFlowThread*>(flowThread());
69 } 69 }
70 70
71 RenderMultiColumnSet* nextSiblingMultiColumnSet() const; 71 RenderMultiColumnSet* nextSiblingMultiColumnSet() const;
72 RenderMultiColumnSet* previousSiblingMultiColumnSet() const; 72 RenderMultiColumnSet* previousSiblingMultiColumnSet() const;
73 73
74 void setLogicalTopInFlowThread(LayoutUnit);
74 LayoutUnit logicalTopInFlowThread() const { return isHorizontalWritingMode() ? flowThreadPortionRect().y() : flowThreadPortionRect().x(); } 75 LayoutUnit logicalTopInFlowThread() const { return isHorizontalWritingMode() ? flowThreadPortionRect().y() : flowThreadPortionRect().x(); }
76 LayoutUnit logicalHeightInFlowThread() const { return isHorizontalWritingMod e() ? flowThreadPortionRect().height() : flowThreadPortionRect().width(); }
77 void setLogicalBottomInFlowThread(LayoutUnit);
75 LayoutUnit logicalBottomInFlowThread() const { return isHorizontalWritingMod e() ? flowThreadPortionRect().maxY() : flowThreadPortionRect().maxX(); } 78 LayoutUnit logicalBottomInFlowThread() const { return isHorizontalWritingMod e() ? flowThreadPortionRect().maxY() : flowThreadPortionRect().maxX(); }
76 79
77 LayoutUnit logicalHeightInFlowThread() const { return isHorizontalWritingMod e() ? flowThreadPortionRect().height() : flowThreadPortionRect().width(); }
78
79 // The used CSS value of column-count, i.e. how many columns there are room for without overflowing. 80 // The used CSS value of column-count, i.e. how many columns there are room for without overflowing.
80 unsigned usedColumnCount() const { return multiColumnFlowThread()->columnCou nt(); } 81 unsigned usedColumnCount() const { return multiColumnFlowThread()->columnCou nt(); }
81 82
83 bool heightIsAuto() const;
84
82 // Find the column that contains the given block offset, and return the tran slation needed to 85 // Find the column that contains the given block offset, and return the tran slation needed to
83 // get from flow thread coordinates to visual coordinates. 86 // get from flow thread coordinates to visual coordinates.
84 LayoutSize flowThreadTranslationAtOffset(LayoutUnit) const; 87 LayoutSize flowThreadTranslationAtOffset(LayoutUnit) const;
85 88
86 LayoutUnit heightAdjustedForSetOffset(LayoutUnit height) const; 89 LayoutUnit heightAdjustedForSetOffset(LayoutUnit height) const;
87 90
88 void updateMinimumColumnHeight(LayoutUnit height) { m_minimumColumnHeight = std::max(height, m_minimumColumnHeight); } 91 void updateMinimumColumnHeight(LayoutUnit height) { m_minimumColumnHeight = std::max(height, m_minimumColumnHeight); }
89 LayoutUnit minimumColumnHeight() const { return m_minimumColumnHeight; } 92 LayoutUnit minimumColumnHeight() const { return m_minimumColumnHeight; }
90 93
91 // Add a content run, specified by its end position. A content run is append ed at every 94 // Add a content run, specified by its end position. A content run is append ed at every
92 // forced/explicit break and at the end of the column set. The content runs are used to 95 // forced/explicit break and at the end of the column set. The content runs are used to
93 // determine where implicit/soft breaks will occur, in order to calculate an initial column 96 // determine where implicit/soft breaks will occur, in order to calculate an initial column
94 // height. 97 // height.
95 void addContentRun(LayoutUnit endOffsetFromFirstPage); 98 void addContentRun(LayoutUnit endOffsetFromFirstPage);
96 99
97 // (Re-)calculate the column height if it's auto. 100 // (Re-)calculate the column height if it's auto. This is first and foremost needed by sets that
101 // are to balance the column height, but even when it isn't to be balanced, this is necessary if
102 // the multicol container's height is constrained.
98 virtual bool recalculateColumnHeight(BalancedHeightCalculation); 103 virtual bool recalculateColumnHeight(BalancedHeightCalculation);
99 104
100 // Record space shortage (the amount of space that would have been enough to prevent some 105 // Record space shortage (the amount of space that would have been enough to prevent some
101 // element from being moved to the next column) at a column break. The small est amount of space 106 // element from being moved to the next column) at a column break. The small est amount of space
102 // shortage we find is the amount with which we will stretch the column heig ht, if it turns out 107 // shortage we find is the amount with which we will stretch the column heig ht, if it turns out
103 // after layout that the columns weren't tall enough. 108 // after layout that the columns weren't tall enough.
104 void recordSpaceShortage(LayoutUnit spaceShortage); 109 void recordSpaceShortage(LayoutUnit spaceShortage);
105 110
106 // Reset previously calculated column height. Will mark for layout if needed . 111 // Reset previously calculated column height. Will mark for layout if needed .
107 void resetColumnHeight(); 112 void resetColumnHeight();
108 113
114 // Layout of flow thread content that's to be rendered inside this column se t begins. This
115 // happens at the beginning of flow thread layout, and when advancing from a previous column set
116 // or spanner to this one.
117 void beginFlow(LayoutUnit offsetInFlowThread);
118 // Layout of flow thread content that was to be rendered inside this column set has
119 // finished. This happens at end of flow thread layout, and when advancing t o the next column
120 // set or spanner.
121 void endFlow(LayoutUnit offsetInFlowThread);
122
109 // Expand this set's flow thread portion rectangle to contain all trailing f low thread 123 // Expand this set's flow thread portion rectangle to contain all trailing f low thread
110 // overflow. Only to be called on the last set. 124 // overflow. Only to be called on the last set.
111 void expandToEncompassFlowThreadContentsIfNeeded(); 125 void expandToEncompassFlowThreadContentsIfNeeded();
112 126
113 void attachRegion(); 127 void attachRegion();
114 void detachRegion(); 128 void detachRegion();
115 129
116 // The top of the nearest page inside the region. For RenderRegions, this is just the logical top of the 130 // The top of the nearest page inside the region. For RenderRegions, this is just the logical top of the
117 // flow thread portion we contain. For sets, we have to figure out the top o f the nearest column or 131 // flow thread portion we contain. For sets, we have to figure out the top o f the nearest column or
118 // page. 132 // page.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 // breaks assumed so far. 208 // breaks assumed so far.
195 LayoutUnit columnLogicalHeight(LayoutUnit startOffset) const { return ce ilf((m_breakOffset - startOffset).toFloat() / float(m_assumedImplicitBreaks + 1) ); } 209 LayoutUnit columnLogicalHeight(LayoutUnit startOffset) const { return ce ilf((m_breakOffset - startOffset).toFloat() / float(m_assumedImplicitBreaks + 1) ); }
196 210
197 private: 211 private:
198 LayoutUnit m_breakOffset; // Flow thread offset where this run ends. 212 LayoutUnit m_breakOffset; // Flow thread offset where this run ends.
199 unsigned m_assumedImplicitBreaks; // Number of implicit breaks in this r un assumed so far. 213 unsigned m_assumedImplicitBreaks; // Number of implicit breaks in this r un assumed so far.
200 }; 214 };
201 Vector<ContentRun, 1> m_contentRuns; 215 Vector<ContentRun, 1> m_contentRuns;
202 }; 216 };
203 217
218 inline void RenderMultiColumnSet::beginFlow(LayoutUnit offsetInFlowThread)
219 {
220 // At this point layout is exactly at the beginning of this set. Store block offset from flow
221 // thread start.
222 setLogicalTopInFlowThread(offsetInFlowThread);
223 }
224
225 inline void RenderMultiColumnSet::endFlow(LayoutUnit offsetInFlowThread)
226 {
227 // At this point layout is exactly at the end of this set. Store block offse t from flow thread
228 // start. This set is now considered "flowed", although we may have to revis it it later (with
229 // beginFlow()), e.g. if a subtree in the flow thread has to be laid out ove r again because the
230 // initial margin collapsing estimates were wrong.
231 setLogicalBottomInFlowThread(offsetInFlowThread);
232 }
233
204 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderMultiColumnSet, isRenderMultiColumnSet()); 234 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderMultiColumnSet, isRenderMultiColumnSet());
205 235
206 } // namespace blink 236 } // namespace blink
207 237
208 #endif // RenderMultiColumnSet_h 238 #endif // RenderMultiColumnSet_h
209 239
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderMultiColumnFlowThreadTest.cpp ('k') | Source/core/rendering/RenderMultiColumnSet.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698