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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 LayoutMultiColumnSet* LayoutMultiColumnSet::createAnonymous(LayoutFlowThread& fl
owThread, const ComputedStyle& parentStyle) | 44 LayoutMultiColumnSet* LayoutMultiColumnSet::createAnonymous(LayoutFlowThread& fl
owThread, const ComputedStyle& parentStyle) |
45 { | 45 { |
46 Document& document = flowThread.document(); | 46 Document& document = flowThread.document(); |
47 LayoutMultiColumnSet* layoutObject = new LayoutMultiColumnSet(&flowThread); | 47 LayoutMultiColumnSet* layoutObject = new LayoutMultiColumnSet(&flowThread); |
48 layoutObject->setDocumentForAnonymous(&document); | 48 layoutObject->setDocumentForAnonymous(&document); |
49 layoutObject->setStyle(ComputedStyle::createAnonymousStyleWithDisplay(parent
Style, BLOCK)); | 49 layoutObject->setStyle(ComputedStyle::createAnonymousStyleWithDisplay(parent
Style, BLOCK)); |
50 return layoutObject; | 50 return layoutObject; |
51 } | 51 } |
52 | 52 |
53 unsigned LayoutMultiColumnSet::fragmentainerGroupIndexAtFlowThreadOffset(LayoutU
nit flowThreadOffset) const | 53 unsigned LayoutMultiColumnSet::fragmentainerGroupIndexAtFlowThreadOffset(LayoutU
nit flowThreadOffset, PageBoundaryRule rule) const |
54 { | 54 { |
55 ASSERT(m_fragmentainerGroups.size() > 0); | 55 ASSERT(m_fragmentainerGroups.size() > 0); |
56 if (flowThreadOffset <= 0) | 56 if (flowThreadOffset <= 0) |
57 return 0; | 57 return 0; |
58 // TODO(mstensho): Introduce an interval tree or similar to speed up this. | 58 // TODO(mstensho): Introduce an interval tree or similar to speed up this. |
59 for (unsigned index = 0; index < m_fragmentainerGroups.size(); index++) { | 59 for (unsigned index = 0; index < m_fragmentainerGroups.size(); index++) { |
60 const auto& row = m_fragmentainerGroups[index]; | 60 const auto& row = m_fragmentainerGroups[index]; |
61 if (row.logicalTopInFlowThread() <= flowThreadOffset && row.logicalBotto
mInFlowThread() > flowThreadOffset) | 61 if (rule == AssociateWithLatterPage) { |
| 62 if (row.logicalTopInFlowThread() <= flowThreadOffset && row.logicalB
ottomInFlowThread() > flowThreadOffset) |
| 63 return index; |
| 64 } else if (row.logicalTopInFlowThread() < flowThreadOffset && row.logica
lBottomInFlowThread() >= flowThreadOffset) { |
62 return index; | 65 return index; |
| 66 } |
63 } | 67 } |
64 return m_fragmentainerGroups.size() - 1; | 68 return m_fragmentainerGroups.size() - 1; |
65 } | 69 } |
66 | 70 |
67 const MultiColumnFragmentainerGroup& LayoutMultiColumnSet::fragmentainerGroupAtV
isualPoint(const LayoutPoint& visualPoint) const | 71 const MultiColumnFragmentainerGroup& LayoutMultiColumnSet::fragmentainerGroupAtV
isualPoint(const LayoutPoint& visualPoint) const |
68 { | 72 { |
69 ASSERT(m_fragmentainerGroups.size() > 0); | 73 ASSERT(m_fragmentainerGroups.size() > 0); |
70 LayoutUnit blockOffset = isHorizontalWritingMode() ? visualPoint.y() : visua
lPoint.x(); | 74 LayoutUnit blockOffset = isHorizontalWritingMode() ? visualPoint.y() : visua
lPoint.x(); |
71 for (unsigned index = 0; index < m_fragmentainerGroups.size(); index++) { | 75 for (unsigned index = 0; index < m_fragmentainerGroups.size(); index++) { |
72 const auto& row = m_fragmentainerGroups[index]; | 76 const auto& row = m_fragmentainerGroups[index]; |
(...skipping 24 matching lines...) Expand all Loading... |
97 // is out of bounds. So just use the bottom we have found so far. | 101 // is out of bounds. So just use the bottom we have found so far. |
98 LayoutUnit enclosingContextBottom = lastRow.blockOffsetInEnclosingFr
agmentationContext() + lastRow.logicalHeight(); | 102 LayoutUnit enclosingContextBottom = lastRow.blockOffsetInEnclosingFr
agmentationContext() + lastRow.logicalHeight(); |
99 LayoutUnit enclosingFragmentainerHeight = enclosingFragmentationCont
ext->fragmentainerLogicalHeightAt(enclosingContextBottom); | 103 LayoutUnit enclosingFragmentainerHeight = enclosingFragmentationCont
ext->fragmentainerLogicalHeightAt(enclosingContextBottom); |
100 // Constrain against specified height / max-height. | 104 // Constrain against specified height / max-height. |
101 LayoutUnit currentMulticolHeight = logicalTopFromMulticolContentEdge
() + lastRow.logicalTop() + lastRow.logicalHeight(); | 105 LayoutUnit currentMulticolHeight = logicalTopFromMulticolContentEdge
() + lastRow.logicalTop() + lastRow.logicalHeight(); |
102 LayoutUnit multicolHeightWithExtraRow = currentMulticolHeight + encl
osingFragmentainerHeight; | 106 LayoutUnit multicolHeightWithExtraRow = currentMulticolHeight + encl
osingFragmentainerHeight; |
103 multicolHeightWithExtraRow = std::min(multicolHeightWithExtraRow, fl
owThread->maxColumnLogicalHeight()); | 107 multicolHeightWithExtraRow = std::min(multicolHeightWithExtraRow, fl
owThread->maxColumnLogicalHeight()); |
104 return std::max(LayoutUnit(1), multicolHeightWithExtraRow - currentM
ulticolHeight); | 108 return std::max(LayoutUnit(1), multicolHeightWithExtraRow - currentM
ulticolHeight); |
105 } | 109 } |
106 } | 110 } |
107 return fragmentainerGroupAtFlowThreadOffset(offsetInFlowThread).logicalHeigh
t(); | 111 return fragmentainerGroupAtFlowThreadOffset(offsetInFlowThread, AssociateWit
hLatterPage).logicalHeight(); |
108 } | 112 } |
109 | 113 |
110 LayoutUnit LayoutMultiColumnSet::pageRemainingLogicalHeightForOffset(LayoutUnit
offsetInFlowThread, PageBoundaryRule pageBoundaryRule) const | 114 LayoutUnit LayoutMultiColumnSet::pageRemainingLogicalHeightForOffset(LayoutUnit
offsetInFlowThread, PageBoundaryRule pageBoundaryRule) const |
111 { | 115 { |
112 const MultiColumnFragmentainerGroup& row = fragmentainerGroupAtFlowThreadOff
set(offsetInFlowThread); | 116 const MultiColumnFragmentainerGroup& row = fragmentainerGroupAtFlowThreadOff
set(offsetInFlowThread, pageBoundaryRule); |
113 LayoutUnit pageLogicalHeight = row.logicalHeight(); | 117 LayoutUnit pageLogicalHeight = row.logicalHeight(); |
114 ASSERT(pageLogicalHeight); // It's not allowed to call this method if the he
ight is unknown. | 118 ASSERT(pageLogicalHeight); // It's not allowed to call this method if the he
ight is unknown. |
115 LayoutUnit pageLogicalBottom = row.columnLogicalTopForOffset(offsetInFlowThr
ead) + pageLogicalHeight; | 119 LayoutUnit pageLogicalBottom = row.columnLogicalTopForOffset(offsetInFlowThr
ead) + pageLogicalHeight; |
116 LayoutUnit remainingLogicalHeight = pageLogicalBottom - offsetInFlowThread; | 120 LayoutUnit remainingLogicalHeight = pageLogicalBottom - offsetInFlowThread; |
117 | 121 |
118 if (pageBoundaryRule == AssociateWithFormerPage) { | 122 if (pageBoundaryRule == AssociateWithFormerPage) { |
119 // An offset exactly at a column boundary will act as being part of the
former column in | 123 // An offset exactly at a column boundary will act as being part of the
former column in |
120 // question (i.e. no remaining space), rather than being part of the lat
ter (i.e. one whole | 124 // question (i.e. no remaining space), rather than being part of the lat
ter (i.e. one whole |
121 // column length of remaining space). | 125 // column length of remaining space). |
122 remainingLogicalHeight = intMod(remainingLogicalHeight, pageLogicalHeigh
t); | 126 remainingLogicalHeight = intMod(remainingLogicalHeight, pageLogicalHeigh
t); |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 // If we're followed by a spanner, we need to balance. | 288 // If we're followed by a spanner, we need to balance. |
285 return true; | 289 return true; |
286 } | 290 } |
287 } | 291 } |
288 } | 292 } |
289 return !flowThread->columnHeightAvailable(); | 293 return !flowThread->columnHeightAvailable(); |
290 } | 294 } |
291 | 295 |
292 LayoutSize LayoutMultiColumnSet::flowThreadTranslationAtOffset(LayoutUnit blockO
ffset, PageBoundaryRule rule, CoordinateSpaceConversion mode) const | 296 LayoutSize LayoutMultiColumnSet::flowThreadTranslationAtOffset(LayoutUnit blockO
ffset, PageBoundaryRule rule, CoordinateSpaceConversion mode) const |
293 { | 297 { |
294 return fragmentainerGroupAtFlowThreadOffset(blockOffset).flowThreadTranslati
onAtOffset(blockOffset, rule, mode); | 298 return fragmentainerGroupAtFlowThreadOffset(blockOffset, rule).flowThreadTra
nslationAtOffset(blockOffset, rule, mode); |
295 } | 299 } |
296 | 300 |
297 LayoutPoint LayoutMultiColumnSet::visualPointToFlowThreadPoint(const LayoutPoint
& visualPoint) const | 301 LayoutPoint LayoutMultiColumnSet::visualPointToFlowThreadPoint(const LayoutPoint
& visualPoint) const |
298 { | 302 { |
299 const MultiColumnFragmentainerGroup& row = fragmentainerGroupAtVisualPoint(v
isualPoint); | 303 const MultiColumnFragmentainerGroup& row = fragmentainerGroupAtVisualPoint(v
isualPoint); |
300 return row.visualPointToFlowThreadPoint(visualPoint - row.offsetFromColumnSe
t()); | 304 return row.visualPointToFlowThreadPoint(visualPoint - row.offsetFromColumnSe
t()); |
301 } | 305 } |
302 | 306 |
303 LayoutUnit LayoutMultiColumnSet::pageLogicalTopForOffset(LayoutUnit offset) cons
t | 307 LayoutUnit LayoutMultiColumnSet::pageLogicalTopForOffset(LayoutUnit offset) cons
t |
304 { | 308 { |
305 return fragmentainerGroupAtFlowThreadOffset(offset).columnLogicalTopForOffse
t(offset); | 309 return fragmentainerGroupAtFlowThreadOffset(offset, AssociateWithLatterPage)
.columnLogicalTopForOffset(offset); |
306 } | 310 } |
307 | 311 |
308 bool LayoutMultiColumnSet::recalculateColumnHeight() | 312 bool LayoutMultiColumnSet::recalculateColumnHeight() |
309 { | 313 { |
310 if (m_oldLogicalTop != logicalTop() && multiColumnFlowThread()->enclosingFra
gmentationContext()) { | 314 if (m_oldLogicalTop != logicalTop() && multiColumnFlowThread()->enclosingFra
gmentationContext()) { |
311 // Preceding spanners or column sets have been moved or resized. This me
ans that the | 315 // Preceding spanners or column sets have been moved or resized. This me
ans that the |
312 // fragmentainer groups that we have inserted need to be re-inserted. Re
start column | 316 // fragmentainer groups that we have inserted need to be re-inserted. Re
start column |
313 // balancing. | 317 // balancing. |
314 resetColumnHeight(); | 318 resetColumnHeight(); |
315 return true; | 319 return true; |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 // Now add in column rule bounds, if present. | 539 // Now add in column rule bounds, if present. |
536 Vector<LayoutRect> columnRuleBounds; | 540 Vector<LayoutRect> columnRuleBounds; |
537 if (computeColumnRuleBounds(LayoutPoint(), columnRuleBounds)) { | 541 if (computeColumnRuleBounds(LayoutPoint(), columnRuleBounds)) { |
538 for (auto& bound : columnRuleBounds) | 542 for (auto& bound : columnRuleBounds) |
539 blockFlowBounds.unite(bound); | 543 blockFlowBounds.unite(bound); |
540 } | 544 } |
541 return blockFlowBounds; | 545 return blockFlowBounds; |
542 } | 546 } |
543 | 547 |
544 } // namespace blink | 548 } // namespace blink |
OLD | NEW |