Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Side by Side Diff: third_party/WebKit/Source/core/layout/MultiColumnFragmentainerGroup.cpp

Issue 1424913003: Don't set bogus height on new fragmentainer groups initially. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase master Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/layout/MultiColumnFragmentainerGroup.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "config.h" 5 #include "config.h"
6 6
7 #include "core/layout/MultiColumnFragmentainerGroup.h" 7 #include "core/layout/MultiColumnFragmentainerGroup.h"
8 8
9 #include "core/layout/ColumnBalancer.h" 9 #include "core/layout/ColumnBalancer.h"
10 #include "core/layout/LayoutMultiColumnSet.h" 10 #include "core/layout/LayoutMultiColumnSet.h"
(...skipping 21 matching lines...) Expand all
32 if (!m_columnSet.flowThread()->isHorizontalWritingMode()) 32 if (!m_columnSet.flowThread()->isHorizontalWritingMode())
33 return offset.transposedSize(); 33 return offset.transposedSize();
34 return offset; 34 return offset;
35 } 35 }
36 36
37 LayoutUnit MultiColumnFragmentainerGroup::blockOffsetInEnclosingFlowThread() con st 37 LayoutUnit MultiColumnFragmentainerGroup::blockOffsetInEnclosingFlowThread() con st
38 { 38 {
39 return logicalTop() + m_columnSet.logicalTop() + m_columnSet.multiColumnFlow Thread()->blockOffsetInEnclosingFlowThread(); 39 return logicalTop() + m_columnSet.logicalTop() + m_columnSet.multiColumnFlow Thread()->blockOffsetInEnclosingFlowThread();
40 } 40 }
41 41
42 bool MultiColumnFragmentainerGroup::heightIsAuto() const
43 {
44 // Only the last row may have auto height, and thus be balanced. There are n o good reasons to
45 // balance the preceding rows, and that could potentially lead to an insane number of layout
46 // passes as well.
47 return isLastGroup() && m_columnSet.heightIsAuto();
48 }
49
50 void MultiColumnFragmentainerGroup::resetColumnHeight() 42 void MultiColumnFragmentainerGroup::resetColumnHeight()
51 { 43 {
52 m_maxColumnHeight = calculateMaxColumnHeight(); 44 m_maxColumnHeight = calculateMaxColumnHeight();
53 45
54 LayoutMultiColumnFlowThread* flowThread = m_columnSet.multiColumnFlowThread( ); 46 LayoutMultiColumnFlowThread* flowThread = m_columnSet.multiColumnFlowThread( );
55 if (heightIsAuto()) { 47 if (m_columnSet.heightIsAuto()) {
56 LayoutMultiColumnFlowThread* enclosingFlowThread = flowThread->enclosing FlowThread(); 48 LayoutMultiColumnFlowThread* enclosingFlowThread = flowThread->enclosing FlowThread();
57 if (enclosingFlowThread && enclosingFlowThread->isPageLogicalHeightKnown ()) { 49 if (enclosingFlowThread && enclosingFlowThread->isPageLogicalHeightKnown ()) {
58 // Even if height is auto, we set an initial height, in order to tel l how much content 50 // Even if height is auto, we set an initial height, in order to tel l how much content
59 // this MultiColumnFragmentainerGroup can hold, and when we need to append a new one. 51 // this MultiColumnFragmentainerGroup can hold, and when we need to append a new one.
60 m_columnHeight = m_maxColumnHeight; 52 m_columnHeight = m_maxColumnHeight;
61 } else { 53 } else {
62 m_columnHeight = LayoutUnit(); 54 m_columnHeight = LayoutUnit();
63 } 55 }
64 } else { 56 } else {
65 setAndConstrainColumnHeight(heightAdjustedForRowOffset(flowThread->colum nHeightAvailable())); 57 setAndConstrainColumnHeight(heightAdjustedForRowOffset(flowThread->colum nHeightAvailable()));
66 } 58 }
67 } 59 }
68 60
69 bool MultiColumnFragmentainerGroup::recalculateColumnHeight(BalancedColumnHeight Calculation calculationMode) 61 bool MultiColumnFragmentainerGroup::recalculateColumnHeight(BalancedColumnHeight Calculation calculationMode)
70 { 62 {
71 LayoutUnit oldColumnHeight = m_columnHeight; 63 LayoutUnit oldColumnHeight = m_columnHeight;
72 64
73 m_maxColumnHeight = calculateMaxColumnHeight(); 65 m_maxColumnHeight = calculateMaxColumnHeight();
74 66
75 if (heightIsAuto()) { 67 // Only the last row may have auto height, and thus be balanced. There are n o good reasons to
68 // balance the preceding rows, and that could potentially lead to an insane number of layout
69 // passes as well.
70 if (isLastGroup() && m_columnSet.heightIsAuto()) {
76 LayoutUnit newColumnHeight = calculateColumnHeight(calculationMode); 71 LayoutUnit newColumnHeight = calculateColumnHeight(calculationMode);
77 setAndConstrainColumnHeight(newColumnHeight); 72 setAndConstrainColumnHeight(newColumnHeight);
78 // After having calculated an initial column height, the multicol contai ner typically needs at 73 // After having calculated an initial column height, the multicol contai ner typically needs at
79 // least one more layout pass with a new column height, but if a height was specified, we only 74 // least one more layout pass with a new column height, but if a height was specified, we only
80 // need to do this if we think that we need less space than specified. C onversely, if we 75 // need to do this if we think that we need less space than specified. C onversely, if we
81 // determined that the columns need to be as tall as the specified heigh t of the container, we 76 // determined that the columns need to be as tall as the specified heigh t of the container, we
82 // have already laid it out correctly, and there's no need for another p ass. 77 // have already laid it out correctly, and there's no need for another p ass.
83 } else { 78 } else {
84 // The position of the column set may have changed, in which case height available for 79 // The position of the column set may have changed, in which case height available for
85 // columns may have changed as well. 80 // columns may have changed as well.
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 append(MultiColumnFragmentainerGroup(m_columnSet)); 549 append(MultiColumnFragmentainerGroup(m_columnSet));
555 return last(); 550 return last();
556 } 551 }
557 552
558 void MultiColumnFragmentainerGroupList::deleteExtraGroups() 553 void MultiColumnFragmentainerGroupList::deleteExtraGroups()
559 { 554 {
560 shrink(1); 555 shrink(1);
561 } 556 }
562 557
563 } // namespace blink 558 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/MultiColumnFragmentainerGroup.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698