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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 const auto& row = m_fragmentainerGroups[index]; | 81 const auto& row = m_fragmentainerGroups[index]; |
82 if (row.logicalTop() + row.logicalHeight() > blockOffset) | 82 if (row.logicalTop() + row.logicalHeight() > blockOffset) |
83 return row; | 83 return row; |
84 } | 84 } |
85 return m_fragmentainerGroups.last(); | 85 return m_fragmentainerGroups.last(); |
86 } | 86 } |
87 | 87 |
88 LayoutUnit LayoutMultiColumnSet::pageLogicalHeightForOffset( | 88 LayoutUnit LayoutMultiColumnSet::pageLogicalHeightForOffset( |
89 LayoutUnit offsetInFlowThread) const { | 89 LayoutUnit offsetInFlowThread) const { |
90 const MultiColumnFragmentainerGroup& lastRow = lastFragmentainerGroup(); | 90 const MultiColumnFragmentainerGroup& lastRow = lastFragmentainerGroup(); |
91 if (!lastRow.logicalHeight()) { | 91 if (!lastRow.logicalHeight() && m_fragmentainerGroups.size() == 1) { |
92 // In the first layout pass of an auto-height multicol container, height | 92 // In the first layout pass of an auto-height multicol container, height |
93 // isn't set. No need to perform the series of complicated dance steps below | 93 // isn't set. No need to perform the series of complicated dance steps below |
94 // to figure out that we should simply return 0. Bail now. | 94 // to figure out that we should simply return 0. Bail now. |
95 ASSERT(m_fragmentainerGroups.size() == 1); | |
96 return LayoutUnit(); | 95 return LayoutUnit(); |
97 } | 96 } |
98 if (offsetInFlowThread >= | 97 if (offsetInFlowThread >= |
99 lastRow.logicalTopInFlowThread() + fragmentainerGroupCapacity(lastRow)) { | 98 lastRow.logicalTopInFlowThread() + fragmentainerGroupCapacity(lastRow)) { |
100 // The offset is outside the bounds of the fragmentainer groups that we have | 99 // The offset is outside the bounds of the fragmentainer groups that we have |
101 // established at this point. If we're nested inside another fragmentation | 100 // established at this point. If we're nested inside another fragmentation |
102 // context, we need to calculate the height on our own. | 101 // context, we need to calculate the height on our own. |
103 const LayoutMultiColumnFlowThread* flowThread = multiColumnFlowThread(); | 102 const LayoutMultiColumnFlowThread* flowThread = multiColumnFlowThread(); |
104 if (FragmentationContext* enclosingFragmentationContext = | 103 if (FragmentationContext* enclosingFragmentationContext = |
105 flowThread->enclosingFragmentationContext()) { | 104 flowThread->enclosingFragmentationContext()) { |
(...skipping 24 matching lines...) Expand all Loading... |
130 .logicalHeight(); | 129 .logicalHeight(); |
131 } | 130 } |
132 | 131 |
133 LayoutUnit LayoutMultiColumnSet::pageRemainingLogicalHeightForOffset( | 132 LayoutUnit LayoutMultiColumnSet::pageRemainingLogicalHeightForOffset( |
134 LayoutUnit offsetInFlowThread, | 133 LayoutUnit offsetInFlowThread, |
135 PageBoundaryRule pageBoundaryRule) const { | 134 PageBoundaryRule pageBoundaryRule) const { |
136 const MultiColumnFragmentainerGroup& row = | 135 const MultiColumnFragmentainerGroup& row = |
137 fragmentainerGroupAtFlowThreadOffset(offsetInFlowThread, | 136 fragmentainerGroupAtFlowThreadOffset(offsetInFlowThread, |
138 pageBoundaryRule); | 137 pageBoundaryRule); |
139 LayoutUnit pageLogicalHeight = row.logicalHeight(); | 138 LayoutUnit pageLogicalHeight = row.logicalHeight(); |
140 // It's not allowed to call this method if the height is unknown. | |
141 DCHECK(pageLogicalHeight); | |
142 LayoutUnit pageLogicalBottom = | 139 LayoutUnit pageLogicalBottom = |
143 row.columnLogicalTopForOffset(offsetInFlowThread) + pageLogicalHeight; | 140 row.columnLogicalTopForOffset(offsetInFlowThread) + pageLogicalHeight; |
144 LayoutUnit remainingLogicalHeight = pageLogicalBottom - offsetInFlowThread; | 141 LayoutUnit remainingLogicalHeight = pageLogicalBottom - offsetInFlowThread; |
145 | 142 |
146 if (pageBoundaryRule == AssociateWithFormerPage) { | 143 if (pageBoundaryRule == AssociateWithFormerPage) { |
147 // An offset exactly at a column boundary will act as being part of the | 144 // An offset exactly at a column boundary will act as being part of the |
148 // former column in question (i.e. no remaining space), rather than being | 145 // former column in question (i.e. no remaining space), rather than being |
149 // part of the latter (i.e. one whole column length of remaining space). | 146 // part of the latter (i.e. one whole column length of remaining space). |
150 remainingLogicalHeight = intMod(remainingLogicalHeight, pageLogicalHeight); | 147 remainingLogicalHeight = intMod(remainingLogicalHeight, pageLogicalHeight); |
151 } else if (!remainingLogicalHeight) { | 148 } else if (!remainingLogicalHeight) { |
152 // When pageBoundaryRule is AssociateWithLatterPage, we should never return | 149 // When pageBoundaryRule is AssociateWithLatterPage, we shouldn't just |
153 // 0, because if there's no space left, it means that we should be at a | 150 // return 0 if there's no space left, because in that case we're at a |
154 // column boundary, in which case we should return the amount of space | 151 // column boundary, in which case we should return the amount of space |
155 // remaining in the *next* column. But this is not true if the offset is | 152 // remaining in the *next* column. Note that the page height itself may be |
156 // "infinite" (saturated), so allow this to happen in that case. | 153 // 0, though. |
157 ASSERT(offsetInFlowThread.mightBeSaturated()); | |
158 remainingLogicalHeight = pageLogicalHeight; | 154 remainingLogicalHeight = pageLogicalHeight; |
159 } | 155 } |
160 return remainingLogicalHeight; | 156 return remainingLogicalHeight; |
161 } | 157 } |
162 | 158 |
163 bool LayoutMultiColumnSet::isPageLogicalHeightKnown() const { | 159 bool LayoutMultiColumnSet::isPageLogicalHeightKnown() const { |
164 return firstFragmentainerGroup().logicalHeight(); | 160 return firstFragmentainerGroup().logicalHeight(); |
165 } | 161 } |
166 | 162 |
167 bool LayoutMultiColumnSet::newFragmentainerGroupsAllowed() const { | 163 bool LayoutMultiColumnSet::newFragmentainerGroupsAllowed() const { |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 // Now add in column rule bounds, if present. | 579 // Now add in column rule bounds, if present. |
584 Vector<LayoutRect> columnRuleBounds; | 580 Vector<LayoutRect> columnRuleBounds; |
585 if (computeColumnRuleBounds(LayoutPoint(), columnRuleBounds)) { | 581 if (computeColumnRuleBounds(LayoutPoint(), columnRuleBounds)) { |
586 for (auto& bound : columnRuleBounds) | 582 for (auto& bound : columnRuleBounds) |
587 blockFlowBounds.unite(bound); | 583 blockFlowBounds.unite(bound); |
588 } | 584 } |
589 return blockFlowBounds; | 585 return blockFlowBounds; |
590 } | 586 } |
591 | 587 |
592 } // namespace blink | 588 } // namespace blink |
OLD | NEW |