Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Side by Side Diff: third_party/WebKit/Source/core/layout/FragmentainerIterator.cpp

Issue 2395683002: Revert of Reformat comments in core/layout up until LayoutBox (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 FragmentainerIterator::FragmentainerIterator( 11 FragmentainerIterator::FragmentainerIterator(
12 const LayoutFlowThread& flowThread, 12 const LayoutFlowThread& flowThread,
13 const LayoutRect& physicalBoundingBoxInFlowThread, 13 const LayoutRect& physicalBoundingBoxInFlowThread,
14 const LayoutRect& clipRectInMulticolContainer) 14 const LayoutRect& clipRectInMulticolContainer)
15 : m_flowThread(flowThread), 15 : m_flowThread(flowThread),
16 m_clipRectInMulticolContainer(clipRectInMulticolContainer), 16 m_clipRectInMulticolContainer(clipRectInMulticolContainer),
17 m_currentFragmentainerGroupIndex(0) { 17 m_currentFragmentainerGroupIndex(0) {
18 // Put the bounds into flow thread-local coordinates by flipping it first. 18 // Put the bounds into flow thread-local coordinates by flipping it first. Thi s is how
19 // This is how rectangles typically are represented in layout, i.e. with the 19 // rectangles typically are represented in layout, i.e. with the block directi on coordinate
20 // block direction coordinate flipped, if writing mode is vertical-rl. 20 // flipped, if writing mode is vertical-rl.
21 LayoutRect boundsInFlowThread = physicalBoundingBoxInFlowThread; 21 LayoutRect boundsInFlowThread = physicalBoundingBoxInFlowThread;
22 m_flowThread.flipForWritingMode(boundsInFlowThread); 22 m_flowThread.flipForWritingMode(boundsInFlowThread);
23 23
24 if (m_flowThread.isHorizontalWritingMode()) { 24 if (m_flowThread.isHorizontalWritingMode()) {
25 m_logicalTopInFlowThread = boundsInFlowThread.y(); 25 m_logicalTopInFlowThread = boundsInFlowThread.y();
26 m_logicalBottomInFlowThread = boundsInFlowThread.maxY(); 26 m_logicalBottomInFlowThread = boundsInFlowThread.maxY();
27 } else { 27 } else {
28 m_logicalTopInFlowThread = boundsInFlowThread.x(); 28 m_logicalTopInFlowThread = boundsInFlowThread.x();
29 m_logicalBottomInFlowThread = boundsInFlowThread.maxX(); 29 m_logicalBottomInFlowThread = boundsInFlowThread.maxX();
30 } 30 }
31 31
32 // Jump to the first interesting column set. 32 // Jump to the first interesting column set.
33 m_currentColumnSet = flowThread.columnSetAtBlockOffset( 33 m_currentColumnSet = flowThread.columnSetAtBlockOffset(
34 m_logicalTopInFlowThread, LayoutBox::AssociateWithLatterPage); 34 m_logicalTopInFlowThread, LayoutBox::AssociateWithLatterPage);
35 if (!m_currentColumnSet || 35 if (!m_currentColumnSet ||
36 m_currentColumnSet->logicalTopInFlowThread() >= 36 m_currentColumnSet->logicalTopInFlowThread() >=
37 m_logicalBottomInFlowThread) { 37 m_logicalBottomInFlowThread) {
38 setAtEnd(); 38 setAtEnd();
39 return; 39 return;
40 } 40 }
41 // Then find the first interesting fragmentainer group. 41 // Then find the first interesting fragmentainer group.
42 m_currentFragmentainerGroupIndex = 42 m_currentFragmentainerGroupIndex =
43 m_currentColumnSet->fragmentainerGroupIndexAtFlowThreadOffset( 43 m_currentColumnSet->fragmentainerGroupIndexAtFlowThreadOffset(
44 m_logicalTopInFlowThread, LayoutBox::AssociateWithLatterPage); 44 m_logicalTopInFlowThread, LayoutBox::AssociateWithLatterPage);
45 45
46 // Now find the first and last fragmentainer we're interested in. We'll also 46 // Now find the first and last fragmentainer we're interested in. We'll also c lip against
47 // clip against the clip rect here. In case the clip rect doesn't intersect 47 // the clip rect here. In case the clip rect doesn't intersect with any of the
48 // with any of the fragmentainers, we have to move on to the next 48 // fragmentainers, we have to move on to the next fragmentainer group, and see if we find
49 // fragmentainer group, and see if we find something there. 49 // something there.
50 if (!setFragmentainersOfInterest()) { 50 if (!setFragmentainersOfInterest()) {
51 moveToNextFragmentainerGroup(); 51 moveToNextFragmentainerGroup();
52 if (atEnd()) 52 if (atEnd())
53 return; 53 return;
54 } 54 }
55 } 55 }
56 56
57 void FragmentainerIterator::advance() { 57 void FragmentainerIterator::advance() {
58 DCHECK(!atEnd()); 58 DCHECK(!atEnd());
59 59
60 if (m_currentFragmentainerIndex < m_endFragmentainerIndex) { 60 if (m_currentFragmentainerIndex < m_endFragmentainerIndex) {
61 m_currentFragmentainerIndex++; 61 m_currentFragmentainerIndex++;
62 } else { 62 } else {
63 // That was the last fragmentainer to visit in this fragmentainer group. 63 // That was the last fragmentainer to visit in this fragmentainer group. Adv ance to the
64 // Advance to the next group. 64 // next group.
65 moveToNextFragmentainerGroup(); 65 moveToNextFragmentainerGroup();
66 if (atEnd()) 66 if (atEnd())
67 return; 67 return;
68 } 68 }
69 } 69 }
70 70
71 LayoutSize FragmentainerIterator::paginationOffset() const { 71 LayoutSize FragmentainerIterator::paginationOffset() const {
72 DCHECK(!atEnd()); 72 DCHECK(!atEnd());
73 const MultiColumnFragmentainerGroup& group = currentGroup(); 73 const MultiColumnFragmentainerGroup& group = currentGroup();
74 LayoutUnit fragmentainerLogicalTopInFlowThread = 74 LayoutUnit fragmentainerLogicalTopInFlowThread =
(...skipping 25 matching lines...) Expand all
100 DCHECK(!atEnd()); 100 DCHECK(!atEnd());
101 return m_currentColumnSet 101 return m_currentColumnSet
102 ->fragmentainerGroups()[m_currentFragmentainerGroupIndex]; 102 ->fragmentainerGroups()[m_currentFragmentainerGroupIndex];
103 } 103 }
104 104
105 void FragmentainerIterator::moveToNextFragmentainerGroup() { 105 void FragmentainerIterator::moveToNextFragmentainerGroup() {
106 do { 106 do {
107 m_currentFragmentainerGroupIndex++; 107 m_currentFragmentainerGroupIndex++;
108 if (m_currentFragmentainerGroupIndex >= 108 if (m_currentFragmentainerGroupIndex >=
109 m_currentColumnSet->fragmentainerGroups().size()) { 109 m_currentColumnSet->fragmentainerGroups().size()) {
110 // That was the last fragmentainer group in this set. Advance to the next. 110 // That was the last fragmentainer group in this set. Advance to the next set.
111 m_currentColumnSet = m_currentColumnSet->nextSiblingMultiColumnSet(); 111 m_currentColumnSet = m_currentColumnSet->nextSiblingMultiColumnSet();
112 m_currentFragmentainerGroupIndex = 0; 112 m_currentFragmentainerGroupIndex = 0;
113 if (!m_currentColumnSet || 113 if (!m_currentColumnSet ||
114 m_currentColumnSet->logicalTopInFlowThread() >= 114 m_currentColumnSet->logicalTopInFlowThread() >=
115 m_logicalBottomInFlowThread) { 115 m_logicalBottomInFlowThread) {
116 setAtEnd(); 116 setAtEnd();
117 return; // No more sets or next set out of range. We're done. 117 return; // No more sets or next set out of range. We're done.
118 } 118 }
119 } 119 }
120 if (currentGroup().logicalTopInFlowThread() >= 120 if (currentGroup().logicalTopInFlowThread() >=
121 m_logicalBottomInFlowThread) { 121 m_logicalBottomInFlowThread) {
122 // This fragmentainer group doesn't intersect with the range we're 122 setAtEnd(); // This fragmentainer group doesn't intersect with the range we're interested in. We're done.
123 // interested in. We're done.
124 setAtEnd();
125 return; 123 return;
126 } 124 }
127 } while (!setFragmentainersOfInterest()); 125 } while (!setFragmentainersOfInterest());
128 } 126 }
129 127
130 bool FragmentainerIterator::setFragmentainersOfInterest() { 128 bool FragmentainerIterator::setFragmentainersOfInterest() {
131 const MultiColumnFragmentainerGroup& group = currentGroup(); 129 const MultiColumnFragmentainerGroup& group = currentGroup();
132 130
133 // Figure out the start and end fragmentainers for the block range we're 131 // Figure out the start and end fragmentainers for the block range we're inter ested in. We
134 // interested in. We might not have to walk the entire fragmentainer group. 132 // might not have to walk the entire fragmentainer group.
135 group.columnIntervalForBlockRangeInFlowThread( 133 group.columnIntervalForBlockRangeInFlowThread(
136 m_logicalTopInFlowThread, m_logicalBottomInFlowThread, 134 m_logicalTopInFlowThread, m_logicalBottomInFlowThread,
137 m_currentFragmentainerIndex, m_endFragmentainerIndex); 135 m_currentFragmentainerIndex, m_endFragmentainerIndex);
138 136
139 if (hasClipRect()) { 137 if (hasClipRect()) {
140 // Now intersect with the fragmentainers that actually intersect with the 138 // Now intersect with the fragmentainers that actually intersect with the vi sual clip rect, to
141 // visual clip rect, to narrow it down even further. The clip rect needs to 139 // narrow it down even further. The clip rect needs to be relative to the cu rrent fragmentainer
142 // be relative to the current fragmentainer group. 140 // group.
143 LayoutRect clipRect = m_clipRectInMulticolContainer; 141 LayoutRect clipRect = m_clipRectInMulticolContainer;
144 LayoutSize offset = group.flowThreadTranslationAtOffset( 142 LayoutSize offset = group.flowThreadTranslationAtOffset(
145 group.logicalTopInFlowThread(), LayoutBox::AssociateWithFormerPage, 143 group.logicalTopInFlowThread(), LayoutBox::AssociateWithFormerPage,
146 CoordinateSpaceConversion::Visual); 144 CoordinateSpaceConversion::Visual);
147 clipRect.move(-offset); 145 clipRect.move(-offset);
148 unsigned firstFragmentainerInClipRect, lastFragmentainerInClipRect; 146 unsigned firstFragmentainerInClipRect, lastFragmentainerInClipRect;
149 group.columnIntervalForVisualRect(clipRect, firstFragmentainerInClipRect, 147 group.columnIntervalForVisualRect(clipRect, firstFragmentainerInClipRect,
150 lastFragmentainerInClipRect); 148 lastFragmentainerInClipRect);
151 // If the two fragmentainer intervals are disjoint, there's nothing of 149 // If the two fragmentainer intervals are disjoint, there's nothing of inter est in this
152 // interest in this fragmentainer group. 150 // fragmentainer group.
153 if (firstFragmentainerInClipRect > m_endFragmentainerIndex || 151 if (firstFragmentainerInClipRect > m_endFragmentainerIndex ||
154 lastFragmentainerInClipRect < m_currentFragmentainerIndex) 152 lastFragmentainerInClipRect < m_currentFragmentainerIndex)
155 return false; 153 return false;
156 if (m_currentFragmentainerIndex < firstFragmentainerInClipRect) 154 if (m_currentFragmentainerIndex < firstFragmentainerInClipRect)
157 m_currentFragmentainerIndex = firstFragmentainerInClipRect; 155 m_currentFragmentainerIndex = firstFragmentainerInClipRect;
158 if (m_endFragmentainerIndex > lastFragmentainerInClipRect) 156 if (m_endFragmentainerIndex > lastFragmentainerInClipRect)
159 m_endFragmentainerIndex = lastFragmentainerInClipRect; 157 m_endFragmentainerIndex = lastFragmentainerInClipRect;
160 } 158 }
161 DCHECK(m_endFragmentainerIndex >= m_currentFragmentainerIndex); 159 DCHECK(m_endFragmentainerIndex >= m_currentFragmentainerIndex);
162 return true; 160 return true;
163 } 161 }
164 162
165 } // namespace blink 163 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698