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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 LayoutMultiColumnSet* LayoutMultiColumnSet::previousSiblingMultiColumnSet() | 233 LayoutMultiColumnSet* LayoutMultiColumnSet::previousSiblingMultiColumnSet() |
234 const { | 234 const { |
235 for (LayoutObject* sibling = previousSibling(); sibling; | 235 for (LayoutObject* sibling = previousSibling(); sibling; |
236 sibling = sibling->previousSibling()) { | 236 sibling = sibling->previousSibling()) { |
237 if (sibling->isLayoutMultiColumnSet()) | 237 if (sibling->isLayoutMultiColumnSet()) |
238 return toLayoutMultiColumnSet(sibling); | 238 return toLayoutMultiColumnSet(sibling); |
239 } | 239 } |
240 return nullptr; | 240 return nullptr; |
241 } | 241 } |
242 | 242 |
243 bool LayoutMultiColumnSet::hasFragmentainerGroupForColumnAt( | 243 bool LayoutMultiColumnSet::needsNewFragmentainerGroupAt( |
244 LayoutUnit offsetInFlowThread, | 244 LayoutUnit offsetInFlowThread, |
245 PageBoundaryRule pageBoundaryRule) const { | 245 PageBoundaryRule pageBoundaryRule) const { |
| 246 // First the cheap check: Perhaps the last fragmentainer group has sufficient |
| 247 // capacity? |
246 const MultiColumnFragmentainerGroup& lastRow = lastFragmentainerGroup(); | 248 const MultiColumnFragmentainerGroup& lastRow = lastFragmentainerGroup(); |
247 LayoutUnit maxLogicalBottomInFlowThread = | 249 LayoutUnit maxLogicalBottomInFlowThread = |
248 lastRow.logicalTopInFlowThread() + fragmentainerGroupCapacity(lastRow); | 250 lastRow.logicalTopInFlowThread() + fragmentainerGroupCapacity(lastRow); |
249 if (pageBoundaryRule == AssociateWithFormerPage) | 251 if (pageBoundaryRule == AssociateWithFormerPage) { |
250 return offsetInFlowThread <= maxLogicalBottomInFlowThread; | 252 if (offsetInFlowThread <= maxLogicalBottomInFlowThread) |
251 return offsetInFlowThread < maxLogicalBottomInFlowThread; | 253 return false; |
| 254 } else if (offsetInFlowThread < maxLogicalBottomInFlowThread) { |
| 255 return false; |
| 256 } |
| 257 |
| 258 // So, there's not enough room in the last fragmentainer group. However, |
| 259 // there can only ever be one fragmentainer group per column set if we're not |
| 260 // nested inside another fragmentation context. We'll just create overflowing |
| 261 // columns if the fragmentainer group cannot hold all the content. |
| 262 if (!multiColumnFlowThread()->enclosingFragmentationContext()) |
| 263 return false; |
| 264 |
| 265 // We're in a nested fragmentation context, and the last fragmentainer group |
| 266 // cannot hold content at the specified offset without overflowing. This |
| 267 // usually warrants a new fragmentainer group; however, this will not be the |
| 268 // case if we have already allocated all available block space in this |
| 269 // multicol container. When setting up a new fragmentainer group, we always |
| 270 // constrain against the remaining portion of any specified |
| 271 // height/max-height. This means that we shouldn't allow creation of |
| 272 // fragmentainer groups below the bottom of the multicol container, or we'd |
| 273 // end up with zero-height fragmentainer groups (or actually 1px; see |
| 274 // heightAdjustedForRowOffset() in MultiColumnFragmentainerGroup, which |
| 275 // guards against zero-height groups), i.e. potentially a lot of pretty |
| 276 // useless fragmentainer groups, and possibly broken layout too. Instead, |
| 277 // we'll just allow additional (overflowing) columns to be created in the |
| 278 // last fragmentainer group, similar to what we do when we're not nested. |
| 279 LayoutUnit logicalBottom = lastRow.logicalTop() + lastRow.logicalHeight(); |
| 280 LayoutUnit spaceUsed = logicalBottom + logicalTopFromMulticolContentEdge(); |
| 281 LayoutUnit maxColumnHeight = multiColumnFlowThread()->maxColumnLogicalHeight()
; |
| 282 return maxColumnHeight - spaceUsed > LayoutUnit(); |
252 } | 283 } |
253 | 284 |
254 MultiColumnFragmentainerGroup& | 285 MultiColumnFragmentainerGroup& |
255 LayoutMultiColumnSet::appendNewFragmentainerGroup() { | 286 LayoutMultiColumnSet::appendNewFragmentainerGroup() { |
256 MultiColumnFragmentainerGroup newGroup(*this); | 287 MultiColumnFragmentainerGroup newGroup(*this); |
257 { // Extra scope here for previousGroup; it's potentially invalid once we | 288 { // Extra scope here for previousGroup; it's potentially invalid once we |
258 // modify the m_fragmentainerGroups Vector. | 289 // modify the m_fragmentainerGroups Vector. |
259 MultiColumnFragmentainerGroup& previousGroup = m_fragmentainerGroups.last(); | 290 MultiColumnFragmentainerGroup& previousGroup = m_fragmentainerGroups.last(); |
260 | 291 |
261 // This is the flow thread block offset where |previousGroup| ends and | 292 // This is the flow thread block offset where |previousGroup| ends and |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 // Now add in column rule bounds, if present. | 614 // Now add in column rule bounds, if present. |
584 Vector<LayoutRect> columnRuleBounds; | 615 Vector<LayoutRect> columnRuleBounds; |
585 if (computeColumnRuleBounds(LayoutPoint(), columnRuleBounds)) { | 616 if (computeColumnRuleBounds(LayoutPoint(), columnRuleBounds)) { |
586 for (auto& bound : columnRuleBounds) | 617 for (auto& bound : columnRuleBounds) |
587 blockFlowBounds.unite(bound); | 618 blockFlowBounds.unite(bound); |
588 } | 619 } |
589 return blockFlowBounds; | 620 return blockFlowBounds; |
590 } | 621 } |
591 | 622 |
592 } // namespace blink | 623 } // namespace blink |
OLD | NEW |