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 15 matching lines...) Expand all Loading... | |
26 #include "core/layout/LayoutMultiColumnFlowThread.h" | 26 #include "core/layout/LayoutMultiColumnFlowThread.h" |
27 | 27 |
28 #include "core/layout/LayoutMultiColumnSet.h" | 28 #include "core/layout/LayoutMultiColumnSet.h" |
29 #include "core/layout/LayoutMultiColumnSpannerPlaceholder.h" | 29 #include "core/layout/LayoutMultiColumnSpannerPlaceholder.h" |
30 #include "core/layout/LayoutView.h" | 30 #include "core/layout/LayoutView.h" |
31 #include "core/layout/MultiColumnFragmentainerGroup.h" | 31 #include "core/layout/MultiColumnFragmentainerGroup.h" |
32 #include "core/layout/ViewFragmentationContext.h" | 32 #include "core/layout/ViewFragmentationContext.h" |
33 | 33 |
34 namespace blink { | 34 namespace blink { |
35 | 35 |
36 #if DCHECK_IS_ON() | |
37 const LayoutBox* LayoutMultiColumnFlowThread::s_styleChangedBox; | |
38 #endif | |
39 bool LayoutMultiColumnFlowThread::s_couldContainSpanners; | |
40 bool LayoutMultiColumnFlowThread::s_toggleSpannersIfNeeded; | |
mstensho (USE GERRIT)
2016/11/04 20:09:42
This is similar to the static bool s_affectsParent
| |
41 | |
36 LayoutMultiColumnFlowThread::LayoutMultiColumnFlowThread() | 42 LayoutMultiColumnFlowThread::LayoutMultiColumnFlowThread() |
37 : m_lastSetWorkedOn(nullptr), | 43 : m_lastSetWorkedOn(nullptr), |
38 m_columnCount(1), | 44 m_columnCount(1), |
39 m_columnHeightsChanged(false), | 45 m_columnHeightsChanged(false), |
40 m_progressionIsInline(true), | 46 m_progressionIsInline(true), |
41 m_isBeingEvacuated(false) { | 47 m_isBeingEvacuated(false) { |
42 setIsInsideFlowThread(true); | 48 setIsInsideFlowThread(true); |
43 } | 49 } |
44 | 50 |
45 LayoutMultiColumnFlowThread::~LayoutMultiColumnFlowThread() {} | 51 LayoutMultiColumnFlowThread::~LayoutMultiColumnFlowThread() {} |
(...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1092 // sets and spanner placeholders. | 1098 // sets and spanner placeholders. |
1093 return (!newStyle.hasOutOfFlowPosition() && | 1099 return (!newStyle.hasOutOfFlowPosition() && |
1094 oldStyle.hasOutOfFlowPosition()) || | 1100 oldStyle.hasOutOfFlowPosition()) || |
1095 needsToReinsertIntoFlowThread(oldStyle, newStyle); | 1101 needsToReinsertIntoFlowThread(oldStyle, newStyle); |
1096 } | 1102 } |
1097 | 1103 |
1098 void LayoutMultiColumnFlowThread::flowThreadDescendantStyleWillChange( | 1104 void LayoutMultiColumnFlowThread::flowThreadDescendantStyleWillChange( |
1099 LayoutBox* descendant, | 1105 LayoutBox* descendant, |
1100 StyleDifference diff, | 1106 StyleDifference diff, |
1101 const ComputedStyle& newStyle) { | 1107 const ComputedStyle& newStyle) { |
1102 if (needsToRemoveFromFlowThread(descendant->styleRef(), newStyle)) | 1108 s_toggleSpannersIfNeeded = false; |
1109 if (needsToRemoveFromFlowThread(descendant->styleRef(), newStyle)) { | |
1103 flowThreadDescendantWillBeRemoved(descendant); | 1110 flowThreadDescendantWillBeRemoved(descendant); |
1111 return; | |
1112 } | |
1113 #if DCHECK_IS_ON() | |
1114 s_styleChangedBox = descendant; | |
1115 #endif | |
1116 // Keep track of whether this object was of such a type that it could contain | |
1117 // column-span:all descendants. If the style change in progress changes this | |
1118 // state, we need to look for spanners to add or remove in the subtree of | |
1119 // |descendant|. | |
1120 s_toggleSpannersIfNeeded = true; | |
1121 s_couldContainSpanners = | |
1122 canContainSpannerInParentFragmentationContext(*descendant); | |
1104 } | 1123 } |
1105 | 1124 |
1106 void LayoutMultiColumnFlowThread::flowThreadDescendantStyleDidChange( | 1125 void LayoutMultiColumnFlowThread::flowThreadDescendantStyleDidChange( |
1107 LayoutBox* descendant, | 1126 LayoutBox* descendant, |
1108 StyleDifference diff, | 1127 StyleDifference diff, |
1109 const ComputedStyle& oldStyle) { | 1128 const ComputedStyle& oldStyle) { |
1129 bool toggleSpannersIfNeeded = s_toggleSpannersIfNeeded; | |
1130 s_toggleSpannersIfNeeded = false; | |
1131 | |
1110 if (needsToInsertIntoFlowThread(oldStyle, descendant->styleRef())) { | 1132 if (needsToInsertIntoFlowThread(oldStyle, descendant->styleRef())) { |
1111 flowThreadDescendantWasInserted(descendant); | 1133 flowThreadDescendantWasInserted(descendant); |
1112 return; | 1134 return; |
1113 } | 1135 } |
1114 if (descendantIsValidColumnSpanner(descendant)) { | 1136 if (descendantIsValidColumnSpanner(descendant)) { |
1115 // We went from being regular column content to becoming a spanner. | 1137 // We went from being regular column content to becoming a spanner. |
1116 ASSERT(!descendant->spannerPlaceholder()); | 1138 ASSERT(!descendant->spannerPlaceholder()); |
1117 | 1139 |
1118 // First remove this as regular column content. Note that this will walk the | 1140 // First remove this as regular column content. Note that this will walk the |
1119 // entire subtree of |descendant|. There might be spanners there (which | 1141 // entire subtree of |descendant|. There might be spanners there (which |
1120 // won't be spanners anymore, since we're not allowed to nest spanners), | 1142 // won't be spanners anymore, since we're not allowed to nest spanners), |
1121 // whose placeholders must die. | 1143 // whose placeholders must die. |
1122 flowThreadDescendantWillBeRemoved(descendant); | 1144 flowThreadDescendantWillBeRemoved(descendant); |
1123 | 1145 |
1124 createAndInsertSpannerPlaceholder( | 1146 createAndInsertSpannerPlaceholder( |
1125 descendant, | 1147 descendant, |
1126 nextInPreOrderAfterChildrenSkippingOutOfFlow(this, descendant)); | 1148 nextInPreOrderAfterChildrenSkippingOutOfFlow(this, descendant)); |
1149 return; | |
1150 } | |
1151 | |
1152 if (!toggleSpannersIfNeeded) | |
1153 return; | |
1154 #if DCHECK_IS_ON() | |
1155 // Make sure that we were preceded by a call to | |
1156 // flowThreadDescendantStyleWillChange() with the same descendant as we have | |
1157 // now. | |
1158 DCHECK(s_styleChangedBox == descendant); | |
1159 #endif | |
1160 | |
1161 if (s_couldContainSpanners != | |
1162 canContainSpannerInParentFragmentationContext(*descendant)) | |
1163 toggleSpannersInSubtree(descendant); | |
1164 } | |
1165 | |
1166 void LayoutMultiColumnFlowThread::toggleSpannersInSubtree( | |
1167 LayoutBox* descendant) { | |
1168 DCHECK(s_couldContainSpanners != | |
1169 canContainSpannerInParentFragmentationContext(*descendant)); | |
1170 | |
1171 // If there are no spanners at all in this multicol container, there's no | |
1172 // need to look for any to remove. | |
1173 if (s_couldContainSpanners && !hasAnyColumnSpanners(*this)) | |
1174 return; | |
1175 | |
1176 bool walkChildren; | |
1177 for (LayoutObject* object = descendant->nextInPreOrder(descendant); object; | |
1178 object = walkChildren | |
1179 ? object->nextInPreOrder(descendant) | |
1180 : object->nextInPreOrderAfterChildren(descendant)) { | |
1181 walkChildren = false; | |
1182 if (!object->isBox()) | |
1183 continue; | |
1184 LayoutBox& box = toLayoutBox(*object); | |
1185 if (s_couldContainSpanners) { | |
1186 // Remove all spanners (turn them into regular column content), as we can | |
1187 // no longer contain them. | |
1188 if (box.isColumnSpanAll()) { | |
1189 destroySpannerPlaceholder(box.spannerPlaceholder()); | |
1190 continue; | |
1191 } | |
1192 } else if (descendantIsValidColumnSpanner(object)) { | |
1193 // We can now contain spanners, and we found a candidate. Turn it into a | |
1194 // spanner. | |
1195 createAndInsertSpannerPlaceholder( | |
1196 &box, nextInPreOrderAfterChildrenSkippingOutOfFlow(this, &box)); | |
1197 continue; | |
1198 } | |
1199 walkChildren = canContainSpannerInParentFragmentationContext(box); | |
1127 } | 1200 } |
1128 } | 1201 } |
1129 | 1202 |
1130 void LayoutMultiColumnFlowThread::computePreferredLogicalWidths() { | 1203 void LayoutMultiColumnFlowThread::computePreferredLogicalWidths() { |
1131 LayoutFlowThread::computePreferredLogicalWidths(); | 1204 LayoutFlowThread::computePreferredLogicalWidths(); |
1132 | 1205 |
1133 // The min/max intrinsic widths calculated really tell how much space elements | 1206 // The min/max intrinsic widths calculated really tell how much space elements |
1134 // need when laid out inside the columns. In order to eventually end up with | 1207 // need when laid out inside the columns. In order to eventually end up with |
1135 // the desired column width, we need to convert them to values pertaining to | 1208 // the desired column width, we need to convert them to values pertaining to |
1136 // the multicol container. | 1209 // the multicol container. |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1251 const { | 1324 const { |
1252 return MultiColumnLayoutState(m_lastSetWorkedOn); | 1325 return MultiColumnLayoutState(m_lastSetWorkedOn); |
1253 } | 1326 } |
1254 | 1327 |
1255 void LayoutMultiColumnFlowThread::restoreMultiColumnLayoutState( | 1328 void LayoutMultiColumnFlowThread::restoreMultiColumnLayoutState( |
1256 const MultiColumnLayoutState& state) { | 1329 const MultiColumnLayoutState& state) { |
1257 m_lastSetWorkedOn = state.columnSet(); | 1330 m_lastSetWorkedOn = state.columnSet(); |
1258 } | 1331 } |
1259 | 1332 |
1260 } // namespace blink | 1333 } // namespace blink |
OLD | NEW |