OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/layout/MultiColumnFragmentainerGroup.h" | 5 #include "core/layout/MultiColumnFragmentainerGroup.h" |
6 | 6 |
7 #include "core/layout/ColumnBalancer.h" | 7 #include "core/layout/ColumnBalancer.h" |
8 #include "core/layout/FragmentationContext.h" | 8 #include "core/layout/FragmentationContext.h" |
9 #include "core/layout/LayoutMultiColumnSet.h" | 9 #include "core/layout/LayoutMultiColumnSet.h" |
10 | 10 |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
285 unsigned count = (flowThreadPortionHeight / m_columnHeight).floor(); | 285 unsigned count = (flowThreadPortionHeight / m_columnHeight).floor(); |
286 // flowThreadPortionHeight may be saturated, so detect the remainder manuall y. | 286 // flowThreadPortionHeight may be saturated, so detect the remainder manuall y. |
287 if (count * m_columnHeight < flowThreadPortionHeight) | 287 if (count * m_columnHeight < flowThreadPortionHeight) |
288 count++; | 288 count++; |
289 ASSERT(count >= 1); | 289 ASSERT(count >= 1); |
290 return count; | 290 return count; |
291 } | 291 } |
292 | 292 |
293 LayoutUnit MultiColumnFragmentainerGroup::heightAdjustedForRowOffset(LayoutUnit height) const | 293 LayoutUnit MultiColumnFragmentainerGroup::heightAdjustedForRowOffset(LayoutUnit height) const |
294 { | 294 { |
295 // Adjust for the top offset within the content box of the multicol containe r (containing | 295 // Let's avoid zero height, as that would cause an infinite amount of column s to be created. |
leviw_travelin_and_unemployed
2016/01/26 23:00:29
Where's the fun in that?
If we can just sell the
mstensho (USE GERRIT)
2016/01/27 09:51:45
I can do that in a follow-up patch. You're right.
| |
296 // block), unless we're in the first set. We know that the top offset for th e first set will be | 296 return std::max(height - logicalTop() - m_columnSet.logicalTopFromMulticolCo ntentEdge(), LayoutUnit(1)); |
297 // zero, but if the multicol container has non-zero top border or padding, t he set's top offset | |
298 // (initially being 0 and relative to the border box) will be negative until it has been laid | |
299 // out. Had we used this bogus offset, we would calculate the wrong height, and risk performing | |
300 // a wasted layout iteration. Of course all other sets (if any) have this pr oblem in the first | |
301 // layout pass too, but there's really nothing we can do there until the flo w thread has been | |
302 // laid out anyway. | |
303 if (m_columnSet.previousSiblingMultiColumnSet()) { | |
304 LayoutBlockFlow* multicolBlock = m_columnSet.multiColumnBlockFlow(); | |
305 LayoutUnit contentLogicalTop = m_columnSet.logicalTop() - multicolBlock- >borderAndPaddingBefore(); | |
306 height -= contentLogicalTop; | |
307 } | |
308 height -= logicalTop(); | |
309 return max(height, LayoutUnit(1)); // Let's avoid zero height, as that would probably cause an infinite amount of columns to be created. | |
310 } | 297 } |
311 | 298 |
312 LayoutUnit MultiColumnFragmentainerGroup::calculateMaxColumnHeight() const | 299 LayoutUnit MultiColumnFragmentainerGroup::calculateMaxColumnHeight() const |
313 { | 300 { |
314 LayoutBlockFlow* multicolBlock = m_columnSet.multiColumnBlockFlow(); | 301 LayoutBlockFlow* multicolBlock = m_columnSet.multiColumnBlockFlow(); |
315 const ComputedStyle& multicolStyle = multicolBlock->styleRef(); | 302 const ComputedStyle& multicolStyle = multicolBlock->styleRef(); |
316 LayoutMultiColumnFlowThread* flowThread = m_columnSet.multiColumnFlowThread( ); | 303 LayoutMultiColumnFlowThread* flowThread = m_columnSet.multiColumnFlowThread( ); |
317 LayoutUnit availableHeight = flowThread->columnHeightAvailable(); | 304 LayoutUnit availableHeight = flowThread->columnHeightAvailable(); |
318 LayoutUnit maxColumnHeight = availableHeight ? availableHeight : LayoutUnit: :max(); | 305 LayoutUnit maxColumnHeight = availableHeight ? availableHeight : LayoutUnit: :max(); |
319 if (!multicolStyle.logicalMaxHeight().isMaxSizeNone()) { | 306 if (!multicolStyle.logicalMaxHeight().isMaxSizeNone()) { |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
552 append(MultiColumnFragmentainerGroup(m_columnSet)); | 539 append(MultiColumnFragmentainerGroup(m_columnSet)); |
553 return last(); | 540 return last(); |
554 } | 541 } |
555 | 542 |
556 void MultiColumnFragmentainerGroupList::deleteExtraGroups() | 543 void MultiColumnFragmentainerGroupList::deleteExtraGroups() |
557 { | 544 { |
558 shrink(1); | 545 shrink(1); |
559 } | 546 } |
560 | 547 |
561 } // namespace blink | 548 } // namespace blink |
OLD | NEW |