OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/FragmentainerIterator.h" | 5 #include "core/layout/FragmentainerIterator.h" |
6 | 6 |
7 #include "core/layout/LayoutMultiColumnSet.h" | 7 #include "core/layout/LayoutMultiColumnSet.h" |
8 | 8 |
9 namespace blink { | 9 namespace blink { |
10 | 10 |
(...skipping 27 matching lines...) Expand all Loading... |
38 | 38 |
39 // Now find the first and last fragmentainer we're interested in. We'll also
clip against | 39 // Now find the first and last fragmentainer we're interested in. We'll also
clip against |
40 // the clip rect here. In case the clip rect doesn't intersect with any of t
he | 40 // the clip rect here. In case the clip rect doesn't intersect with any of t
he |
41 // fragmentainers, we have to move on to the next fragmentainer group, and s
ee if we find | 41 // fragmentainers, we have to move on to the next fragmentainer group, and s
ee if we find |
42 // something there. | 42 // something there. |
43 if (!setFragmentainersOfInterest()) { | 43 if (!setFragmentainersOfInterest()) { |
44 moveToNextFragmentainerGroup(); | 44 moveToNextFragmentainerGroup(); |
45 if (atEnd()) | 45 if (atEnd()) |
46 return; | 46 return; |
47 } | 47 } |
48 | |
49 updateOutput(); | |
50 } | 48 } |
51 | 49 |
52 void FragmentainerIterator::advance() | 50 void FragmentainerIterator::advance() |
53 { | 51 { |
54 DCHECK(!atEnd()); | 52 DCHECK(!atEnd()); |
55 | 53 |
56 if (m_currentFragmentainerIndex < m_endFragmentainerIndex) { | 54 if (m_currentFragmentainerIndex < m_endFragmentainerIndex) { |
57 m_currentFragmentainerIndex++; | 55 m_currentFragmentainerIndex++; |
58 } else { | 56 } else { |
59 // That was the last fragmentainer to visit in this fragmentainer group.
Advance to the | 57 // That was the last fragmentainer to visit in this fragmentainer group.
Advance to the |
60 // next group. | 58 // next group. |
61 moveToNextFragmentainerGroup(); | 59 moveToNextFragmentainerGroup(); |
62 if (atEnd()) | 60 if (atEnd()) |
63 return; | 61 return; |
64 } | 62 } |
65 updateOutput(); | 63 } |
| 64 |
| 65 LayoutSize FragmentainerIterator::paginationOffset() const |
| 66 { |
| 67 DCHECK(!atEnd()); |
| 68 const MultiColumnFragmentainerGroup& group = currentGroup(); |
| 69 LayoutUnit fragmentainerLogicalTopInFlowThread = group.logicalTopInFlowThrea
d() + m_currentFragmentainerIndex * group.logicalHeight(); |
| 70 return group.flowThreadTranslationAtOffset(fragmentainerLogicalTopInFlowThre
ad, LayoutBox::AssociateWithLatterPage, CoordinateSpaceConversion::Visual); |
| 71 } |
| 72 |
| 73 LayoutRect FragmentainerIterator::fragmentainerInFlowThread() const |
| 74 { |
| 75 DCHECK(!atEnd()); |
| 76 LayoutRect fragmentainerInFlowThread = currentGroup().flowThreadPortionRectA
t(m_currentFragmentainerIndex); |
| 77 m_flowThread.flipForWritingMode(fragmentainerInFlowThread); |
| 78 return fragmentainerInFlowThread; |
| 79 } |
| 80 |
| 81 LayoutRect FragmentainerIterator::clipRectInFlowThread() const |
| 82 { |
| 83 DCHECK(!atEnd()); |
| 84 LayoutRect clipRect = currentGroup().flowThreadPortionOverflowRectAt(m_curre
ntFragmentainerIndex); |
| 85 m_flowThread.flipForWritingMode(clipRect); |
| 86 return clipRect; |
66 } | 87 } |
67 | 88 |
68 const MultiColumnFragmentainerGroup& FragmentainerIterator::currentGroup() const | 89 const MultiColumnFragmentainerGroup& FragmentainerIterator::currentGroup() const |
69 { | 90 { |
70 DCHECK(!atEnd()); | 91 DCHECK(!atEnd()); |
71 return m_currentColumnSet->fragmentainerGroups()[m_currentFragmentainerGroup
Index]; | 92 return m_currentColumnSet->fragmentainerGroups()[m_currentFragmentainerGroup
Index]; |
72 } | 93 } |
73 | 94 |
74 void FragmentainerIterator::moveToNextFragmentainerGroup() | 95 void FragmentainerIterator::moveToNextFragmentainerGroup() |
75 { | 96 { |
(...skipping 16 matching lines...) Expand all Loading... |
92 } | 113 } |
93 | 114 |
94 bool FragmentainerIterator::setFragmentainersOfInterest() | 115 bool FragmentainerIterator::setFragmentainersOfInterest() |
95 { | 116 { |
96 const MultiColumnFragmentainerGroup& group = currentGroup(); | 117 const MultiColumnFragmentainerGroup& group = currentGroup(); |
97 | 118 |
98 // Figure out the start and end fragmentainers for the block range we're int
erested in. We | 119 // Figure out the start and end fragmentainers for the block range we're int
erested in. We |
99 // might not have to walk the entire fragmentainer group. | 120 // might not have to walk the entire fragmentainer group. |
100 group.columnIntervalForBlockRangeInFlowThread(m_logicalTopInFlowThread, m_lo
gicalBottomInFlowThread, m_currentFragmentainerIndex, m_endFragmentainerIndex); | 121 group.columnIntervalForBlockRangeInFlowThread(m_logicalTopInFlowThread, m_lo
gicalBottomInFlowThread, m_currentFragmentainerIndex, m_endFragmentainerIndex); |
101 | 122 |
102 // Now intersect with the fragmentainers that actually intersect with the vi
sual clip rect, to | 123 if (hasClipRect()) { |
103 // narrow it down even further. The clip rect needs to be relative to the cu
rrent fragmentainer | 124 // Now intersect with the fragmentainers that actually intersect with th
e visual clip rect, to |
104 // group. | 125 // narrow it down even further. The clip rect needs to be relative to th
e current fragmentainer |
105 LayoutRect clipRect = m_clipRectInMulticolContainer; | 126 // group. |
106 LayoutSize offset = group.flowThreadTranslationAtOffset(group.logicalTopInFl
owThread(), LayoutBox::AssociateWithFormerPage, CoordinateSpaceConversion::Visua
l); | 127 LayoutRect clipRect = m_clipRectInMulticolContainer; |
107 clipRect.move(-offset); | 128 LayoutSize offset = group.flowThreadTranslationAtOffset(group.logicalTop
InFlowThread(), LayoutBox::AssociateWithFormerPage, CoordinateSpaceConversion::V
isual); |
108 unsigned firstFragmentainerInClipRect, lastFragmentainerInClipRect; | 129 clipRect.move(-offset); |
109 group.columnIntervalForVisualRect(clipRect, firstFragmentainerInClipRect, la
stFragmentainerInClipRect); | 130 unsigned firstFragmentainerInClipRect, lastFragmentainerInClipRect; |
110 // If the two fragmentainer intervals are disjoint, there's nothing of inter
est in this | 131 group.columnIntervalForVisualRect(clipRect, firstFragmentainerInClipRect
, lastFragmentainerInClipRect); |
111 // fragmentainer group. | 132 // If the two fragmentainer intervals are disjoint, there's nothing of i
nterest in this |
112 if (firstFragmentainerInClipRect > m_endFragmentainerIndex || lastFragmentai
nerInClipRect < m_currentFragmentainerIndex) | 133 // fragmentainer group. |
113 return false; | 134 if (firstFragmentainerInClipRect > m_endFragmentainerIndex || lastFragme
ntainerInClipRect < m_currentFragmentainerIndex) |
114 if (m_currentFragmentainerIndex < firstFragmentainerInClipRect) | 135 return false; |
115 m_currentFragmentainerIndex = firstFragmentainerInClipRect; | 136 if (m_currentFragmentainerIndex < firstFragmentainerInClipRect) |
116 if (m_endFragmentainerIndex > lastFragmentainerInClipRect) | 137 m_currentFragmentainerIndex = firstFragmentainerInClipRect; |
117 m_endFragmentainerIndex = lastFragmentainerInClipRect; | 138 if (m_endFragmentainerIndex > lastFragmentainerInClipRect) |
| 139 m_endFragmentainerIndex = lastFragmentainerInClipRect; |
| 140 } |
118 DCHECK(m_endFragmentainerIndex >= m_currentFragmentainerIndex); | 141 DCHECK(m_endFragmentainerIndex >= m_currentFragmentainerIndex); |
119 return true; | 142 return true; |
120 } | 143 } |
121 | 144 |
122 void FragmentainerIterator::updateOutput() | |
123 { | |
124 const MultiColumnFragmentainerGroup& group = currentGroup(); | |
125 | |
126 // Set the physical translation offset. | |
127 LayoutUnit fragmentainerLogicalTopInFlowThread = group.logicalTopInFlowThrea
d() + m_currentFragmentainerIndex * group.logicalHeight(); | |
128 m_paginationOffset = group.flowThreadTranslationAtOffset(fragmentainerLogica
lTopInFlowThread, LayoutBox::AssociateWithLatterPage, CoordinateSpaceConversion:
:Visual); | |
129 | |
130 // Set the overflow clip rect that corresponds to the fragmentainer. | |
131 m_clipRectInFlowThread = group.flowThreadPortionOverflowRectAt(m_currentFrag
mentainerIndex); | |
132 | |
133 // Flip it into a physical rectangle. | |
134 m_flowThread.flipForWritingMode(m_clipRectInFlowThread); | |
135 } | |
136 | |
137 } // namespace blink | 145 } // namespace blink |
OLD | NEW |