| OLD | NEW |
| 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 Loading... |
| 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 bool recalculateColumnHeight(BalancedHeightCalculation); | 103 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 // Prepare this set for flow thread layout. |
| 115 void resetFlow(); |
| 116 // Layout of flow thread content that's to be rendered inside this column se
t begins. This |
| 117 // happens at the beginning of flow thread layout, and when advancing from a
previous column set |
| 118 // or spanner to this one. |
| 119 void beginFlow(LayoutUnit offsetInFlowThread); |
| 120 // Layout of flow thread content that was to be rendered inside this column
set has |
| 121 // finished. This happens at end of flow thread layout, and when advancing t
o the next column |
| 122 // set or spanner. |
| 123 void endFlow(LayoutUnit offsetInFlowThread); |
| 124 |
| 109 // Expand this set's flow thread portion rectangle to contain all trailing f
low thread | 125 // 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. | 126 // overflow. Only to be called on the last set. |
| 111 void expandToEncompassFlowThreadContentsIfNeeded(); | 127 void expandToEncompassFlowThreadContentsIfNeeded(); |
| 112 | 128 |
| 113 void attachRegion(); | 129 void attachRegion(); |
| 114 void detachRegion(); | 130 void detachRegion(); |
| 115 | 131 |
| 116 // This method represents the logical height of the entire flow thread porti
on used by the region or set. | 132 // This method represents the logical height of the entire flow thread porti
on used by the region or set. |
| 117 // For RenderRegions it matches logicalPaginationHeight(), but for sets it i
s the height of all the pages | 133 // For RenderRegions it matches logicalPaginationHeight(), but for sets it i
s the height of all the pages |
| 118 // or columns added together. | 134 // or columns added together. |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 // breaks assumed so far. | 216 // breaks assumed so far. |
| 201 LayoutUnit columnLogicalHeight(LayoutUnit startOffset) const { return ce
ilf((m_breakOffset - startOffset).toFloat() / float(m_assumedImplicitBreaks + 1)
); } | 217 LayoutUnit columnLogicalHeight(LayoutUnit startOffset) const { return ce
ilf((m_breakOffset - startOffset).toFloat() / float(m_assumedImplicitBreaks + 1)
); } |
| 202 | 218 |
| 203 private: | 219 private: |
| 204 LayoutUnit m_breakOffset; // Flow thread offset where this run ends. | 220 LayoutUnit m_breakOffset; // Flow thread offset where this run ends. |
| 205 unsigned m_assumedImplicitBreaks; // Number of implicit breaks in this r
un assumed so far. | 221 unsigned m_assumedImplicitBreaks; // Number of implicit breaks in this r
un assumed so far. |
| 206 }; | 222 }; |
| 207 Vector<ContentRun, 1> m_contentRuns; | 223 Vector<ContentRun, 1> m_contentRuns; |
| 208 }; | 224 }; |
| 209 | 225 |
| 226 inline void RenderMultiColumnSet::resetFlow() |
| 227 { |
| 228 // Start with "infinite" flow thread portion height until height is known. |
| 229 setLogicalBottomInFlowThread(RenderFlowThread::maxLogicalHeight()); |
| 230 } |
| 231 |
| 232 inline void RenderMultiColumnSet::beginFlow(LayoutUnit offsetInFlowThread) |
| 233 { |
| 234 // At this point layout is exactly at the beginning of this set. Store block
offset from flow |
| 235 // thread start. |
| 236 setLogicalTopInFlowThread(offsetInFlowThread); |
| 237 } |
| 238 |
| 239 inline void RenderMultiColumnSet::endFlow(LayoutUnit offsetInFlowThread) |
| 240 { |
| 241 // At this point layout is exactly at the end of this set. Store block offse
t from flow thread |
| 242 // start. This set is now considered "flowed", although we may have to revis
it it later (with |
| 243 // beginFlow()), e.g. if a subtree in the flow thread has to be laid out ove
r again because the |
| 244 // initial margin collapsing estimates were wrong. |
| 245 setLogicalBottomInFlowThread(offsetInFlowThread); |
| 246 } |
| 247 |
| 210 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderMultiColumnSet, isRenderMultiColumnSet()); | 248 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderMultiColumnSet, isRenderMultiColumnSet()); |
| 211 | 249 |
| 212 } // namespace blink | 250 } // namespace blink |
| 213 | 251 |
| 214 #endif // RenderMultiColumnSet_h | 252 #endif // RenderMultiColumnSet_h |
| 215 | 253 |
| OLD | NEW |