| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 // placed in between the column sets that come before and after the span. | 52 // placed in between the column sets that come before and after the span. |
| 53 class RenderMultiColumnSet : public RenderRegion { | 53 class RenderMultiColumnSet : public RenderRegion { |
| 54 public: | 54 public: |
| 55 enum BalancedHeightCalculation { GuessFromFlowThreadPortion, StretchBySpaceS
hortage }; | 55 enum BalancedHeightCalculation { GuessFromFlowThreadPortion, StretchBySpaceS
hortage }; |
| 56 | 56 |
| 57 static RenderMultiColumnSet* createAnonymous(RenderFlowThread*, RenderStyle*
parentStyle); | 57 static RenderMultiColumnSet* createAnonymous(RenderFlowThread*, RenderStyle*
parentStyle); |
| 58 | 58 |
| 59 virtual bool isOfType(RenderObjectType type) const override { return type ==
RenderObjectRenderMultiColumnSet || RenderRegion::isOfType(type); } | 59 virtual bool isOfType(RenderObjectType type) const override { return type ==
RenderObjectRenderMultiColumnSet || RenderRegion::isOfType(type); } |
| 60 | 60 |
| 61 virtual LayoutUnit pageLogicalWidth() const override final { return flowThre
ad()->logicalWidth(); } | 61 virtual LayoutUnit pageLogicalWidth() const override final { return flowThre
ad()->logicalWidth(); } |
| 62 virtual LayoutUnit pageLogicalHeight() const override final { return m_colum
nHeight; } | 62 virtual LayoutUnit pageLogicalHeight() const override { return m_columnHeigh
t; } |
| 63 | 63 |
| 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 |
| 85 bool requiresBalancing() const { return !isRenderMultiColumnSpannerSet() &&
heightIsAuto(); } |
| 86 |
| 82 // Find the column that contains the given block offset, and return the tran
slation needed to | 87 // 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. | 88 // get from flow thread coordinates to visual coordinates. |
| 84 LayoutSize flowThreadTranslationAtOffset(LayoutUnit) const; | 89 LayoutSize flowThreadTranslationAtOffset(LayoutUnit) const; |
| 85 | 90 |
| 86 LayoutUnit heightAdjustedForSetOffset(LayoutUnit height) const; | 91 LayoutUnit heightAdjustedForSetOffset(LayoutUnit height) const; |
| 87 | 92 |
| 88 void updateMinimumColumnHeight(LayoutUnit height) { m_minimumColumnHeight =
std::max(height, m_minimumColumnHeight); } | 93 void updateMinimumColumnHeight(LayoutUnit height) { m_minimumColumnHeight =
std::max(height, m_minimumColumnHeight); } |
| 89 LayoutUnit minimumColumnHeight() const { return m_minimumColumnHeight; } | 94 LayoutUnit minimumColumnHeight() const { return m_minimumColumnHeight; } |
| 90 | 95 |
| 91 // Add a content run, specified by its end position. A content run is append
ed at every | 96 // 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 | 97 // 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 | 98 // determine where implicit/soft breaks will occur, in order to calculate an
initial column |
| 94 // height. | 99 // height. |
| 95 void addContentRun(LayoutUnit endOffsetFromFirstPage); | 100 void addContentRun(LayoutUnit endOffsetFromFirstPage); |
| 96 | 101 |
| 97 // (Re-)calculate the column height if it's auto. | 102 // (Re-)calculate the column height if it's auto. This is first and foremost
needed by sets that |
| 103 // are to balance the column height, but even when it isn't to be balanced,
this is necessary if |
| 104 // the multicol container's height is constrained. |
| 98 virtual bool recalculateColumnHeight(BalancedHeightCalculation); | 105 virtual bool recalculateColumnHeight(BalancedHeightCalculation); |
| 99 | 106 |
| 100 // Record space shortage (the amount of space that would have been enough to
prevent some | 107 // 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 | 108 // 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 | 109 // 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. | 110 // after layout that the columns weren't tall enough. |
| 104 void recordSpaceShortage(LayoutUnit spaceShortage); | 111 void recordSpaceShortage(LayoutUnit spaceShortage); |
| 105 | 112 |
| 106 // Reset previously calculated column height. Will mark for layout if needed
. | 113 // Reset previously calculated column height. Will mark for layout if needed
. |
| 107 void resetColumnHeight(); | 114 void resetColumnHeight(); |
| 108 | 115 |
| 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 void paintInvalidationForFlowThreadContent(const LayoutRect& paintInvalidati
onRect) const; | 132 void paintInvalidationForFlowThreadContent(const LayoutRect& paintInvalidati
onRect) const; |
| 117 | 133 |
| 118 // The top of the nearest page inside the region. For RenderRegions, this is
just the logical top of the | 134 // The top of the nearest page inside the region. For RenderRegions, this is
just the logical top of the |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 // breaks assumed so far. | 212 // breaks assumed so far. |
| 197 LayoutUnit columnLogicalHeight(LayoutUnit startOffset) const { return ce
ilf((m_breakOffset - startOffset).toFloat() / float(m_assumedImplicitBreaks + 1)
); } | 213 LayoutUnit columnLogicalHeight(LayoutUnit startOffset) const { return ce
ilf((m_breakOffset - startOffset).toFloat() / float(m_assumedImplicitBreaks + 1)
); } |
| 198 | 214 |
| 199 private: | 215 private: |
| 200 LayoutUnit m_breakOffset; // Flow thread offset where this run ends. | 216 LayoutUnit m_breakOffset; // Flow thread offset where this run ends. |
| 201 unsigned m_assumedImplicitBreaks; // Number of implicit breaks in this r
un assumed so far. | 217 unsigned m_assumedImplicitBreaks; // Number of implicit breaks in this r
un assumed so far. |
| 202 }; | 218 }; |
| 203 Vector<ContentRun, 1> m_contentRuns; | 219 Vector<ContentRun, 1> m_contentRuns; |
| 204 }; | 220 }; |
| 205 | 221 |
| 222 inline void RenderMultiColumnSet::beginFlow(LayoutUnit offsetInFlowThread) |
| 223 { |
| 224 // At this point layout is exactly at the beginning of this set. Store block
offset from flow |
| 225 // thread start. |
| 226 setLogicalTopInFlowThread(offsetInFlowThread); |
| 227 } |
| 228 |
| 229 inline void RenderMultiColumnSet::endFlow(LayoutUnit offsetInFlowThread) |
| 230 { |
| 231 // At this point layout is exactly at the end of this set. Store block offse
t from flow thread |
| 232 // start. This set is now considered "flowed", although we may have to revis
it it later (with |
| 233 // beginFlow()), e.g. if a subtree in the flow thread has to be laid out ove
r again because the |
| 234 // initial margin collapsing estimates were wrong. |
| 235 setLogicalBottomInFlowThread(offsetInFlowThread); |
| 236 } |
| 237 |
| 206 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderMultiColumnSet, isRenderMultiColumnSet()); | 238 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderMultiColumnSet, isRenderMultiColumnSet()); |
| 207 | 239 |
| 208 } // namespace blink | 240 } // namespace blink |
| 209 | 241 |
| 210 #endif // RenderMultiColumnSet_h | 242 #endif // RenderMultiColumnSet_h |
| 211 | 243 |
| OLD | NEW |