| 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 // Get the first renderer in the flow thread that's rendered inside this set
. |
| 75 RenderObject* firstRendererInFlowThread() const; |
| 76 // Get the last renderer in the flow thread that's rendered inside this set. |
| 77 RenderObject* lastRendererInFlowThread() const; |
| 78 // True if the specified renderer in the flow thread is rendered inside this
set. |
| 79 bool renders(RenderObject*) const; |
| 80 |
| 81 void setLogicalTopInFlowThread(LayoutUnit); |
| 74 LayoutUnit logicalTopInFlowThread() const { return isHorizontalWritingMode()
? flowThreadPortionRect().y() : flowThreadPortionRect().x(); } | 82 LayoutUnit logicalTopInFlowThread() const { return isHorizontalWritingMode()
? flowThreadPortionRect().y() : flowThreadPortionRect().x(); } |
| 83 LayoutUnit logicalHeightInFlowThread() const { return isHorizontalWritingMod
e() ? flowThreadPortionRect().height() : flowThreadPortionRect().width(); } |
| 84 void setLogicalBottomInFlowThread(LayoutUnit); |
| 75 LayoutUnit logicalBottomInFlowThread() const { return isHorizontalWritingMod
e() ? flowThreadPortionRect().maxY() : flowThreadPortionRect().maxX(); } | 85 LayoutUnit logicalBottomInFlowThread() const { return isHorizontalWritingMod
e() ? flowThreadPortionRect().maxY() : flowThreadPortionRect().maxX(); } |
| 76 | 86 |
| 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. | 87 // 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(); } | 88 unsigned usedColumnCount() const { return multiColumnFlowThread()->columnCou
nt(); } |
| 81 | 89 |
| 90 bool heightIsAuto() const; |
| 91 |
| 82 // Find the column that contains the given block offset, and return the tran
slation needed to | 92 // 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. | 93 // get from flow thread coordinates to visual coordinates. |
| 84 LayoutSize flowThreadTranslationAtOffset(LayoutUnit) const; | 94 LayoutSize flowThreadTranslationAtOffset(LayoutUnit) const; |
| 85 | 95 |
| 86 LayoutUnit heightAdjustedForSetOffset(LayoutUnit height) const; | 96 LayoutUnit heightAdjustedForSetOffset(LayoutUnit height) const; |
| 87 | 97 |
| 88 void updateMinimumColumnHeight(LayoutUnit height) { m_minimumColumnHeight =
std::max(height, m_minimumColumnHeight); } | 98 void updateMinimumColumnHeight(LayoutUnit height) { m_minimumColumnHeight =
std::max(height, m_minimumColumnHeight); } |
| 89 LayoutUnit minimumColumnHeight() const { return m_minimumColumnHeight; } | 99 LayoutUnit minimumColumnHeight() const { return m_minimumColumnHeight; } |
| 90 | 100 |
| 91 // Add a content run, specified by its end position. A content run is append
ed at every | 101 // 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 | 102 // 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 | 103 // determine where implicit/soft breaks will occur, in order to calculate an
initial column |
| 94 // height. | 104 // height. |
| 95 void addContentRun(LayoutUnit endOffsetFromFirstPage); | 105 void addContentRun(LayoutUnit endOffsetFromFirstPage); |
| 96 | 106 |
| 97 // (Re-)calculate the column height if it's auto. | 107 // (Re-)calculate the column height if it's auto. This is first and foremost
needed by sets that |
| 108 // are to balance the column height, but even when it isn't to be balanced,
this is necessary if |
| 109 // the multicol container's height is constrained. |
| 98 bool recalculateColumnHeight(BalancedHeightCalculation); | 110 bool recalculateColumnHeight(BalancedHeightCalculation); |
| 99 | 111 |
| 100 // Record space shortage (the amount of space that would have been enough to
prevent some | 112 // 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 | 113 // 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 | 114 // 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. | 115 // after layout that the columns weren't tall enough. |
| 104 void recordSpaceShortage(LayoutUnit spaceShortage); | 116 void recordSpaceShortage(LayoutUnit spaceShortage); |
| 105 | 117 |
| 106 // Reset previously calculated column height. Will mark for layout if needed
. | 118 // Reset previously calculated column height. Will mark for layout if needed
. |
| 107 void resetColumnHeight(); | 119 void resetColumnHeight(); |
| 108 | 120 |
| 121 // Has this set been flowed in this layout pass? |
| 122 bool hasBeenFlowed() const; |
| 123 // Prepare this set for flow thread layout. Mark it as "not flowed". |
| 124 void resetFlow(); |
| 125 // Layout of flow thread content that's to be rendered inside this column se
t begins. This |
| 126 // happens at the beginning of flow thread layout, and when advancing from a
previous column set |
| 127 // or spanner to this one. |
| 128 void beginFlow(LayoutUnit offsetInFlowThread); |
| 129 // Layout of flow thread content that was to be rendered inside this column
set has |
| 130 // finished. This happens at end of flow thread layout, and when advancing t
o the next column |
| 131 // set or spanner. |
| 132 void endFlow(LayoutUnit offsetInFlowThread); |
| 133 |
| 109 // Expand this set's flow thread portion rectangle to contain all trailing f
low thread | 134 // 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. | 135 // overflow. Only to be called on the last set. |
| 111 void expandToEncompassFlowThreadContentsIfNeeded(); | 136 void expandToEncompassFlowThreadContentsIfNeeded(); |
| 112 | 137 |
| 113 private: | 138 private: |
| 114 RenderMultiColumnSet(RenderFlowThread*); | 139 RenderMultiColumnSet(RenderFlowThread*); |
| 115 | 140 |
| 116 virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logic
alTop, LogicalExtentComputedValues&) const OVERRIDE; | 141 virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logic
alTop, LogicalExtentComputedValues&) const OVERRIDE; |
| 117 | 142 |
| 118 virtual void paintObject(PaintInfo&, const LayoutPoint& paintOffset) OVERRID
E; | 143 virtual void paintObject(PaintInfo&, const LayoutPoint& paintOffset) OVERRID
E; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 // breaks assumed so far. | 213 // breaks assumed so far. |
| 189 LayoutUnit columnLogicalHeight(LayoutUnit startOffset) const { return ce
ilf((m_breakOffset - startOffset).toFloat() / float(m_assumedImplicitBreaks + 1)
); } | 214 LayoutUnit columnLogicalHeight(LayoutUnit startOffset) const { return ce
ilf((m_breakOffset - startOffset).toFloat() / float(m_assumedImplicitBreaks + 1)
); } |
| 190 | 215 |
| 191 private: | 216 private: |
| 192 LayoutUnit m_breakOffset; // Flow thread offset where this run ends. | 217 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. | 218 unsigned m_assumedImplicitBreaks; // Number of implicit breaks in this r
un assumed so far. |
| 194 }; | 219 }; |
| 195 Vector<ContentRun, 1> m_contentRuns; | 220 Vector<ContentRun, 1> m_contentRuns; |
| 196 }; | 221 }; |
| 197 | 222 |
| 223 inline bool RenderMultiColumnSet::hasBeenFlowed() const |
| 224 { |
| 225 return logicalBottomInFlowThread() != RenderFlowThread::maxLogicalHeight(); |
| 226 } |
| 227 |
| 228 inline void RenderMultiColumnSet::resetFlow() |
| 229 { |
| 230 // Start with "infinite" flow thread portion height until height is known. |
| 231 setLogicalBottomInFlowThread(RenderFlowThread::maxLogicalHeight()); |
| 232 } |
| 233 |
| 234 inline void RenderMultiColumnSet::beginFlow(LayoutUnit offsetInFlowThread) |
| 235 { |
| 236 // At this point layout is exactly at the beginning of this set. Store block
offset from flow |
| 237 // thread start. |
| 238 setLogicalTopInFlowThread(offsetInFlowThread); |
| 239 } |
| 240 |
| 241 inline void RenderMultiColumnSet::endFlow(LayoutUnit offsetInFlowThread) |
| 242 { |
| 243 // At this point layout is exactly at the end of this set. Store block offse
t from flow thread |
| 244 // start. This set is now considered "flowed", although we may have to revis
it it later (with |
| 245 // beginFlow()), e.g. if a subtree in the flow thread has to be laid out ove
r again because the |
| 246 // initial margin collapsing estimates were wrong. |
| 247 setLogicalBottomInFlowThread(offsetInFlowThread); |
| 248 } |
| 249 |
| 198 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderMultiColumnSet, isRenderMultiColumnSet()); | 250 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderMultiColumnSet, isRenderMultiColumnSet()); |
| 199 | 251 |
| 200 } // namespace WebCore | 252 } // namespace WebCore |
| 201 | 253 |
| 202 #endif // RenderMultiColumnSet_h | 254 #endif // RenderMultiColumnSet_h |
| 203 | 255 |
| OLD | NEW |