OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/LayoutMultiColumnSpannerPlaceholder.h" | 5 #include "core/layout/LayoutMultiColumnSpannerPlaceholder.h" |
6 | 6 |
7 #include "core/layout/LayoutMultiColumnFlowThread.h" | 7 #include "core/layout/LayoutMultiColumnFlowThread.h" |
8 | 8 |
9 namespace blink { | 9 namespace blink { |
10 | 10 |
11 static void copyMarginProperties(ComputedStyle& placeholderStyle, | 11 static void copyMarginProperties(ComputedStyle& placeholderStyle, |
12 const ComputedStyle& spannerStyle) { | 12 const ComputedStyle& spannerStyle) { |
13 // We really only need the block direction margins, but there are no setters f
or that in | 13 // We really only need the block direction margins, but there are no setters |
14 // ComputedStyle. Just copy all margin sides. The inline ones don't matter any
way. | 14 // for that in ComputedStyle. Just copy all margin sides. The inline ones |
| 15 // don't matter anyway. |
15 placeholderStyle.setMarginLeft(spannerStyle.marginLeft()); | 16 placeholderStyle.setMarginLeft(spannerStyle.marginLeft()); |
16 placeholderStyle.setMarginRight(spannerStyle.marginRight()); | 17 placeholderStyle.setMarginRight(spannerStyle.marginRight()); |
17 placeholderStyle.setMarginTop(spannerStyle.marginTop()); | 18 placeholderStyle.setMarginTop(spannerStyle.marginTop()); |
18 placeholderStyle.setMarginBottom(spannerStyle.marginBottom()); | 19 placeholderStyle.setMarginBottom(spannerStyle.marginBottom()); |
19 } | 20 } |
20 | 21 |
21 LayoutMultiColumnSpannerPlaceholder* | 22 LayoutMultiColumnSpannerPlaceholder* |
22 LayoutMultiColumnSpannerPlaceholder::createAnonymous( | 23 LayoutMultiColumnSpannerPlaceholder::createAnonymous( |
23 const ComputedStyle& parentStyle, | 24 const ComputedStyle& parentStyle, |
24 LayoutBox& layoutObjectInFlowThread) { | 25 LayoutBox& layoutObjectInFlowThread) { |
(...skipping 15 matching lines...) Expand all Loading... |
40 m_layoutObjectInFlowThread(layoutObjectInFlowThread) {} | 41 m_layoutObjectInFlowThread(layoutObjectInFlowThread) {} |
41 | 42 |
42 void LayoutMultiColumnSpannerPlaceholder:: | 43 void LayoutMultiColumnSpannerPlaceholder:: |
43 layoutObjectInFlowThreadStyleDidChange(const ComputedStyle* oldStyle) { | 44 layoutObjectInFlowThreadStyleDidChange(const ComputedStyle* oldStyle) { |
44 LayoutBox* objectInFlowThread = m_layoutObjectInFlowThread; | 45 LayoutBox* objectInFlowThread = m_layoutObjectInFlowThread; |
45 if (flowThread()->removeSpannerPlaceholderIfNoLongerValid( | 46 if (flowThread()->removeSpannerPlaceholderIfNoLongerValid( |
46 objectInFlowThread)) { | 47 objectInFlowThread)) { |
47 // No longer a valid spanner, due to style changes. |this| is now dead. | 48 // No longer a valid spanner, due to style changes. |this| is now dead. |
48 if (objectInFlowThread->style()->hasOutOfFlowPosition() && | 49 if (objectInFlowThread->style()->hasOutOfFlowPosition() && |
49 !oldStyle->hasOutOfFlowPosition()) { | 50 !oldStyle->hasOutOfFlowPosition()) { |
50 // We went from being a spanner to being out-of-flow positioned. When an o
bject becomes | 51 // We went from being a spanner to being out-of-flow positioned. When an |
51 // out-of-flow positioned, we need to lay out its parent, since that's whe
re the | 52 // object becomes out-of-flow positioned, we need to lay out its parent, |
52 // now-out-of-flow object gets added to the right containing block for out
-of-flow | 53 // since that's where the now-out-of-flow object gets added to the right |
53 // positioned objects. Since neither a spanner nor an out-of-flow object i
s guaranteed | 54 // containing block for out-of-flow positioned objects. Since neither a |
54 // to have this parent in its containing block chain, we need to mark it h
ere, or we | 55 // spanner nor an out-of-flow object is guaranteed to have this parent in |
55 // risk that the object isn't laid out. | 56 // its containing block chain, we need to mark it here, or we risk that |
| 57 // the object isn't laid out. |
56 objectInFlowThread->parent()->setNeedsLayout( | 58 objectInFlowThread->parent()->setNeedsLayout( |
57 LayoutInvalidationReason::ColumnsChanged); | 59 LayoutInvalidationReason::ColumnsChanged); |
58 } | 60 } |
59 return; | 61 return; |
60 } | 62 } |
61 updateMarginProperties(); | 63 updateMarginProperties(); |
62 } | 64 } |
63 | 65 |
64 void LayoutMultiColumnSpannerPlaceholder::updateMarginProperties() { | 66 void LayoutMultiColumnSpannerPlaceholder::updateMarginProperties() { |
65 RefPtr<ComputedStyle> newStyle = ComputedStyle::clone(styleRef()); | 67 RefPtr<ComputedStyle> newStyle = ComputedStyle::clone(styleRef()); |
66 copyMarginProperties(*newStyle, m_layoutObjectInFlowThread->styleRef()); | 68 copyMarginProperties(*newStyle, m_layoutObjectInFlowThread->styleRef()); |
67 setStyle(newStyle); | 69 setStyle(newStyle); |
68 } | 70 } |
69 | 71 |
70 void LayoutMultiColumnSpannerPlaceholder::insertedIntoTree() { | 72 void LayoutMultiColumnSpannerPlaceholder::insertedIntoTree() { |
71 LayoutBox::insertedIntoTree(); | 73 LayoutBox::insertedIntoTree(); |
72 // The object may previously have been laid out as a non-spanner, but since it
's a spanner now, | 74 // The object may previously have been laid out as a non-spanner, but since |
73 // it needs to be relaid out. | 75 // it's a spanner now, it needs to be relaid out. |
74 m_layoutObjectInFlowThread->setNeedsLayoutAndPrefWidthsRecalc( | 76 m_layoutObjectInFlowThread->setNeedsLayoutAndPrefWidthsRecalc( |
75 LayoutInvalidationReason::ColumnsChanged); | 77 LayoutInvalidationReason::ColumnsChanged); |
76 } | 78 } |
77 | 79 |
78 void LayoutMultiColumnSpannerPlaceholder::willBeRemovedFromTree() { | 80 void LayoutMultiColumnSpannerPlaceholder::willBeRemovedFromTree() { |
79 if (m_layoutObjectInFlowThread) { | 81 if (m_layoutObjectInFlowThread) { |
80 LayoutBox* exSpanner = m_layoutObjectInFlowThread; | 82 LayoutBox* exSpanner = m_layoutObjectInFlowThread; |
81 m_layoutObjectInFlowThread->clearSpannerPlaceholder(); | 83 m_layoutObjectInFlowThread->clearSpannerPlaceholder(); |
82 // Even if the placeholder is going away, the object in the flow thread migh
t live on. Since | 84 // Even if the placeholder is going away, the object in the flow thread |
83 // it's not a spanner anymore, it needs to be relaid out. | 85 // might live on. Since it's not a spanner anymore, it needs to be relaid |
| 86 // out. |
84 exSpanner->setNeedsLayoutAndPrefWidthsRecalc( | 87 exSpanner->setNeedsLayoutAndPrefWidthsRecalc( |
85 LayoutInvalidationReason::ColumnsChanged); | 88 LayoutInvalidationReason::ColumnsChanged); |
86 } | 89 } |
87 LayoutBox::willBeRemovedFromTree(); | 90 LayoutBox::willBeRemovedFromTree(); |
88 } | 91 } |
89 | 92 |
90 bool LayoutMultiColumnSpannerPlaceholder::needsPreferredWidthsRecalculation() | 93 bool LayoutMultiColumnSpannerPlaceholder::needsPreferredWidthsRecalculation() |
91 const { | 94 const { |
92 return m_layoutObjectInFlowThread->needsPreferredWidthsRecalculation(); | 95 return m_layoutObjectInFlowThread->needsPreferredWidthsRecalculation(); |
93 } | 96 } |
94 | 97 |
95 LayoutUnit LayoutMultiColumnSpannerPlaceholder::minPreferredLogicalWidth() | 98 LayoutUnit LayoutMultiColumnSpannerPlaceholder::minPreferredLogicalWidth() |
96 const { | 99 const { |
97 return m_layoutObjectInFlowThread->minPreferredLogicalWidth(); | 100 return m_layoutObjectInFlowThread->minPreferredLogicalWidth(); |
98 } | 101 } |
99 | 102 |
100 LayoutUnit LayoutMultiColumnSpannerPlaceholder::maxPreferredLogicalWidth() | 103 LayoutUnit LayoutMultiColumnSpannerPlaceholder::maxPreferredLogicalWidth() |
101 const { | 104 const { |
102 return m_layoutObjectInFlowThread->maxPreferredLogicalWidth(); | 105 return m_layoutObjectInFlowThread->maxPreferredLogicalWidth(); |
103 } | 106 } |
104 | 107 |
105 void LayoutMultiColumnSpannerPlaceholder::layout() { | 108 void LayoutMultiColumnSpannerPlaceholder::layout() { |
106 ASSERT(needsLayout()); | 109 ASSERT(needsLayout()); |
107 | 110 |
108 // The placeholder, like any other block level object, has its logical top cal
culated and set | 111 // The placeholder, like any other block level object, has its logical top |
109 // before layout. Copy this to the actual column-span:all object before laying
it out, so that | 112 // calculated and set before layout. Copy this to the actual column-span:all |
110 // it gets paginated correctly, in case we have an enclosing fragmentation con
text. | 113 // object before laying it out, so that it gets paginated correctly, in case |
| 114 // we have an enclosing fragmentation context. |
111 m_layoutObjectInFlowThread->setLogicalTop(logicalTop()); | 115 m_layoutObjectInFlowThread->setLogicalTop(logicalTop()); |
112 | 116 |
113 // Lay out the actual column-span:all element. | 117 // Lay out the actual column-span:all element. |
114 m_layoutObjectInFlowThread->layoutIfNeeded(); | 118 m_layoutObjectInFlowThread->layoutIfNeeded(); |
115 | 119 |
116 // The spanner has now been laid out, so its height is known. Time to update t
he placeholder's | 120 // The spanner has now been laid out, so its height is known. Time to update |
117 // height as well, so that we take up the correct amount of space in the multi
col container. | 121 // the placeholder's height as well, so that we take up the correct amount of |
| 122 // space in the multicol container. |
118 updateLogicalHeight(); | 123 updateLogicalHeight(); |
119 | 124 |
120 // Take the overflow from the spanner, so that it gets | 125 // Take the overflow from the spanner, so that it gets propagated to the |
121 // propagated to the multicol container and beyond. | 126 // multicol container and beyond. |
122 m_overflow.reset(); | 127 m_overflow.reset(); |
123 addContentsVisualOverflow(m_layoutObjectInFlowThread->visualOverflowRect()); | 128 addContentsVisualOverflow(m_layoutObjectInFlowThread->visualOverflowRect()); |
124 addLayoutOverflow(m_layoutObjectInFlowThread->layoutOverflowRect()); | 129 addLayoutOverflow(m_layoutObjectInFlowThread->layoutOverflowRect()); |
125 | 130 |
126 clearNeedsLayout(); | 131 clearNeedsLayout(); |
127 } | 132 } |
128 | 133 |
129 void LayoutMultiColumnSpannerPlaceholder::computeLogicalHeight( | 134 void LayoutMultiColumnSpannerPlaceholder::computeLogicalHeight( |
130 LayoutUnit, | 135 LayoutUnit, |
131 LayoutUnit logicalTop, | 136 LayoutUnit logicalTop, |
(...skipping 22 matching lines...) Expand all Loading... |
154 HitTestResult& result, | 159 HitTestResult& result, |
155 const HitTestLocation& locationInContainer, | 160 const HitTestLocation& locationInContainer, |
156 const LayoutPoint& accumulatedOffset, | 161 const LayoutPoint& accumulatedOffset, |
157 HitTestAction action) { | 162 HitTestAction action) { |
158 return !m_layoutObjectInFlowThread->hasSelfPaintingLayer() && | 163 return !m_layoutObjectInFlowThread->hasSelfPaintingLayer() && |
159 m_layoutObjectInFlowThread->nodeAtPoint(result, locationInContainer, | 164 m_layoutObjectInFlowThread->nodeAtPoint(result, locationInContainer, |
160 accumulatedOffset, action); | 165 accumulatedOffset, action); |
161 } | 166 } |
162 | 167 |
163 } // namespace blink | 168 } // namespace blink |
OLD | NEW |