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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 // Being a "region", a column set has no children on its own, but is merely used
to slice a portion | 43 // Being a "region", a column set has no children on its own, but is merely used
to slice a portion |
44 // of the tall "single-column" flow thread into actual columns visually, to conv
ert from flow thread | 44 // of the tall "single-column" flow thread into actual columns visually, to conv
ert from flow thread |
45 // coordinates to visual ones. It is in charge of both positioning columns corre
ctly relatively to | 45 // coordinates to visual ones. It is in charge of both positioning columns corre
ctly relatively to |
46 // the parent multicol container, and to calculate the correct translation for e
ach column's | 46 // the parent multicol container, and to calculate the correct translation for e
ach column's |
47 // contents, and to paint any rules between them. RenderMultiColumnSet objects a
re used for | 47 // contents, and to paint any rules between them. RenderMultiColumnSet objects a
re used for |
48 // painting, hit testing, and any other type of operation that requires mapping
from flow thread | 48 // painting, hit testing, and any other type of operation that requires mapping
from flow thread |
49 // coordinates to visual coordinates. | 49 // coordinates to visual coordinates. |
50 // | 50 // |
51 // Column spans result in the creation of new column sets, since a spanning rend
erer has to be | 51 // Column spans result in the creation of new column sets, since a spanning rend
erer has to be |
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 FINAL : 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 isRenderMultiColumnSet() const OVERRIDE { return true; } | 59 virtual bool isRenderMultiColumnSet() const OVERRIDE { return true; } |
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 |
98 bool recalculateColumnHeight(BalancedHeightCalculation); | 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. |
| 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 // Prepare this set for flow thread layout. |
| 117 void resetFlow(); |
| 118 // Layout of flow thread content that's to be rendered inside this column se
t begins. This |
| 119 // happens at the beginning of flow thread layout, and when advancing from a
previous column set |
| 120 // or spanner to this one. |
| 121 void beginFlow(LayoutUnit offsetInFlowThread); |
| 122 // Layout of flow thread content that was to be rendered inside this column
set has |
| 123 // finished. This happens at end of flow thread layout, and when advancing t
o the next column |
| 124 // set or spanner. |
| 125 void endFlow(LayoutUnit offsetInFlowThread); |
| 126 |
109 // Expand this set's flow thread portion rectangle to contain all trailing f
low thread | 127 // 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. | 128 // overflow. Only to be called on the last set. |
111 void expandToEncompassFlowThreadContentsIfNeeded(); | 129 void expandToEncompassFlowThreadContentsIfNeeded(); |
112 | 130 |
113 void attachRegion(); | 131 void attachRegion(); |
114 void detachRegion(); | 132 void detachRegion(); |
115 | 133 |
116 // This method represents the logical height of the entire flow thread porti
on used by the region or set. | 134 // 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 | 135 // For RenderRegions it matches logicalPaginationHeight(), but for sets it i
s the height of all the pages |
118 // or columns added together. | 136 // or columns added together. |
119 LayoutUnit logicalHeightOfAllFlowThreadContent() const { return logicalHeigh
tInFlowThread(); } | 137 LayoutUnit logicalHeightOfAllFlowThreadContent() const { return logicalHeigh
tInFlowThread(); } |
120 | 138 |
121 void paintInvalidationForFlowThreadContent(const LayoutRect& paintInvalidati
onRect) const; | 139 void paintInvalidationForFlowThreadContent(const LayoutRect& paintInvalidati
onRect) const; |
122 | 140 |
123 // The top of the nearest page inside the region. For RenderRegions, this is
just the logical top of the | 141 // The top of the nearest page inside the region. For RenderRegions, this is
just the logical top of the |
124 // flow thread portion we contain. For sets, we have to figure out the top o
f the nearest column or | 142 // flow thread portion we contain. For sets, we have to figure out the top o
f the nearest column or |
125 // page. | 143 // page. |
126 LayoutUnit pageLogicalTopForOffset(LayoutUnit offset) const; | 144 LayoutUnit pageLogicalTopForOffset(LayoutUnit offset) const; |
127 | 145 |
128 void collectLayerFragments(LayerFragments&, const LayoutRect& layerBoundingB
ox, const LayoutRect& dirtyRect); | 146 void collectLayerFragments(LayerFragments&, const LayoutRect& layerBoundingB
ox, const LayoutRect& dirtyRect); |
129 | 147 |
130 private: | 148 protected: |
131 RenderMultiColumnSet(RenderFlowThread*); | 149 RenderMultiColumnSet(RenderFlowThread*); |
132 | 150 |
| 151 private: |
133 virtual void insertedIntoTree() OVERRIDE FINAL; | 152 virtual void insertedIntoTree() OVERRIDE FINAL; |
134 virtual void willBeRemovedFromTree() OVERRIDE FINAL; | 153 virtual void willBeRemovedFromTree() OVERRIDE FINAL; |
135 | 154 |
136 virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logic
alTop, LogicalExtentComputedValues&) const OVERRIDE; | 155 virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logic
alTop, LogicalExtentComputedValues&) const OVERRIDE; |
137 | 156 |
138 virtual void paintObject(PaintInfo&, const LayoutPoint& paintOffset) OVERRID
E; | 157 virtual void paintObject(PaintInfo&, const LayoutPoint& paintOffset) OVERRID
E; |
139 | 158 |
140 virtual void addOverflowFromChildren() OVERRIDE; | 159 virtual void addOverflowFromChildren() OVERRIDE; |
141 | 160 |
142 virtual const char* renderName() const OVERRIDE; | 161 virtual const char* renderName() const OVERRIDE; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 // breaks assumed so far. | 219 // breaks assumed so far. |
201 LayoutUnit columnLogicalHeight(LayoutUnit startOffset) const { return ce
ilf((m_breakOffset - startOffset).toFloat() / float(m_assumedImplicitBreaks + 1)
); } | 220 LayoutUnit columnLogicalHeight(LayoutUnit startOffset) const { return ce
ilf((m_breakOffset - startOffset).toFloat() / float(m_assumedImplicitBreaks + 1)
); } |
202 | 221 |
203 private: | 222 private: |
204 LayoutUnit m_breakOffset; // Flow thread offset where this run ends. | 223 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. | 224 unsigned m_assumedImplicitBreaks; // Number of implicit breaks in this r
un assumed so far. |
206 }; | 225 }; |
207 Vector<ContentRun, 1> m_contentRuns; | 226 Vector<ContentRun, 1> m_contentRuns; |
208 }; | 227 }; |
209 | 228 |
| 229 inline void RenderMultiColumnSet::resetFlow() |
| 230 { |
| 231 // Start with "infinite" flow thread portion height until height is known. |
| 232 setLogicalBottomInFlowThread(RenderFlowThread::maxLogicalHeight()); |
| 233 } |
| 234 |
| 235 inline void RenderMultiColumnSet::beginFlow(LayoutUnit offsetInFlowThread) |
| 236 { |
| 237 // At this point layout is exactly at the beginning of this set. Store block
offset from flow |
| 238 // thread start. |
| 239 setLogicalTopInFlowThread(offsetInFlowThread); |
| 240 } |
| 241 |
| 242 inline void RenderMultiColumnSet::endFlow(LayoutUnit offsetInFlowThread) |
| 243 { |
| 244 // At this point layout is exactly at the end of this set. Store block offse
t from flow thread |
| 245 // start. This set is now considered "flowed", although we may have to revis
it it later (with |
| 246 // beginFlow()), e.g. if a subtree in the flow thread has to be laid out ove
r again because the |
| 247 // initial margin collapsing estimates were wrong. |
| 248 setLogicalBottomInFlowThread(offsetInFlowThread); |
| 249 } |
| 250 |
210 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderMultiColumnSet, isRenderMultiColumnSet()); | 251 DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderMultiColumnSet, isRenderMultiColumnSet()); |
211 | 252 |
212 } // namespace blink | 253 } // namespace blink |
213 | 254 |
214 #endif // RenderMultiColumnSet_h | 255 #endif // RenderMultiColumnSet_h |
215 | 256 |
OLD | NEW |