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 "config.h" | 5 #include "config.h" |
6 #include "core/layout/LayoutMultiColumnSpannerPlaceholder.h" | 6 #include "core/layout/LayoutMultiColumnSpannerPlaceholder.h" |
7 | 7 |
8 namespace blink { | 8 namespace blink { |
9 | 9 |
10 static void copyMarginProperties(ComputedStyle& placeholderStyle, const Computed
Style& spannerStyle) | 10 static void copyMarginProperties(ComputedStyle& placeholderStyle, const Computed
Style& spannerStyle) |
(...skipping 16 matching lines...) Expand all Loading... |
27 newSpanner->setStyle(newStyle); | 27 newSpanner->setStyle(newStyle); |
28 return newSpanner; | 28 return newSpanner; |
29 } | 29 } |
30 | 30 |
31 LayoutMultiColumnSpannerPlaceholder::LayoutMultiColumnSpannerPlaceholder(LayoutB
ox* layoutObjectInFlowThread) | 31 LayoutMultiColumnSpannerPlaceholder::LayoutMultiColumnSpannerPlaceholder(LayoutB
ox* layoutObjectInFlowThread) |
32 : LayoutBox(nullptr) | 32 : LayoutBox(nullptr) |
33 , m_layoutObjectInFlowThread(layoutObjectInFlowThread) | 33 , m_layoutObjectInFlowThread(layoutObjectInFlowThread) |
34 { | 34 { |
35 } | 35 } |
36 | 36 |
| 37 void LayoutMultiColumnSpannerPlaceholder::layoutObjectInFlowThreadStyleDidChange
(const ComputedStyle* oldStyle) |
| 38 { |
| 39 LayoutBox* objectInFlowThread = m_layoutObjectInFlowThread; |
| 40 if (flowThread()->removeSpannerPlaceholderIfNoLongerValid(objectInFlowThread
)) { |
| 41 // No longer a valid spanner, due to style changes. |this| is now dead. |
| 42 if (objectInFlowThread->style()->hasOutOfFlowPosition() && !oldStyle->ha
sOutOfFlowPosition()) { |
| 43 // We went from being a spanner to being out-of-flow positioned. Whe
n an object becomes |
| 44 // out-of-flow positioned, we need to lay out its parent, since that
's where the |
| 45 // now-out-of-flow object gets added to the right containing block f
or out-of-flow |
| 46 // positioned objects. Since neither a spanner nor an out-of-flow ob
ject is guaranteed |
| 47 // to have this parent in its containing block chain, we need to mar
k it here, or we |
| 48 // risk that the object isn't laid out. |
| 49 objectInFlowThread->parent()->setNeedsLayout(LayoutInvalidationReaso
n::ColumnsChanged); |
| 50 } |
| 51 return; |
| 52 } |
| 53 updateMarginProperties(); |
| 54 } |
| 55 |
37 void LayoutMultiColumnSpannerPlaceholder::updateMarginProperties() | 56 void LayoutMultiColumnSpannerPlaceholder::updateMarginProperties() |
38 { | 57 { |
39 RefPtr<ComputedStyle> newStyle = ComputedStyle::clone(styleRef()); | 58 RefPtr<ComputedStyle> newStyle = ComputedStyle::clone(styleRef()); |
40 copyMarginProperties(*newStyle, m_layoutObjectInFlowThread->styleRef()); | 59 copyMarginProperties(*newStyle, m_layoutObjectInFlowThread->styleRef()); |
41 setStyle(newStyle); | 60 setStyle(newStyle); |
42 } | 61 } |
43 | 62 |
44 void LayoutMultiColumnSpannerPlaceholder::willBeRemovedFromTree() | 63 void LayoutMultiColumnSpannerPlaceholder::willBeRemovedFromTree() |
45 { | 64 { |
46 if (m_layoutObjectInFlowThread) | 65 if (m_layoutObjectInFlowThread) { |
| 66 LayoutBox* exSpanner = m_layoutObjectInFlowThread; |
47 m_layoutObjectInFlowThread->clearSpannerPlaceholder(); | 67 m_layoutObjectInFlowThread->clearSpannerPlaceholder(); |
| 68 // Even if the placeholder is going away, the object in the flow thread
might live on. Since |
| 69 // it's not a spanner anymore, it needs to be relaid out. |
| 70 exSpanner->setNeedsLayoutAndPrefWidthsRecalc(LayoutInvalidationReason::C
olumnsChanged); |
| 71 } |
48 LayoutBox::willBeRemovedFromTree(); | 72 LayoutBox::willBeRemovedFromTree(); |
49 } | 73 } |
50 | 74 |
51 bool LayoutMultiColumnSpannerPlaceholder::needsPreferredWidthsRecalculation() co
nst | 75 bool LayoutMultiColumnSpannerPlaceholder::needsPreferredWidthsRecalculation() co
nst |
52 { | 76 { |
53 return m_layoutObjectInFlowThread->needsPreferredWidthsRecalculation(); | 77 return m_layoutObjectInFlowThread->needsPreferredWidthsRecalculation(); |
54 } | 78 } |
55 | 79 |
56 LayoutUnit LayoutMultiColumnSpannerPlaceholder::minPreferredLogicalWidth() const | 80 LayoutUnit LayoutMultiColumnSpannerPlaceholder::minPreferredLogicalWidth() const |
57 { | 81 { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 if (!m_layoutObjectInFlowThread->hasSelfPaintingLayer()) | 127 if (!m_layoutObjectInFlowThread->hasSelfPaintingLayer()) |
104 m_layoutObjectInFlowThread->paint(paintInfo, paintOffset); | 128 m_layoutObjectInFlowThread->paint(paintInfo, paintOffset); |
105 } | 129 } |
106 | 130 |
107 bool LayoutMultiColumnSpannerPlaceholder::nodeAtPoint(HitTestResult& result, con
st HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, H
itTestAction action) | 131 bool LayoutMultiColumnSpannerPlaceholder::nodeAtPoint(HitTestResult& result, con
st HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, H
itTestAction action) |
108 { | 132 { |
109 return !m_layoutObjectInFlowThread->hasSelfPaintingLayer() && m_layoutObject
InFlowThread->nodeAtPoint(result, locationInContainer, accumulatedOffset, action
); | 133 return !m_layoutObjectInFlowThread->hasSelfPaintingLayer() && m_layoutObject
InFlowThread->nodeAtPoint(result, locationInContainer, accumulatedOffset, action
); |
110 } | 134 } |
111 | 135 |
112 } | 136 } |
OLD | NEW |