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

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

Issue 2394263004: Reformat comments in core/layout up until LayoutMultiColumnFlowThread (Closed)
Patch Set: Rebase w/HEAD 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 /** 1 /**
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Simon Hausmann <hausmann@kde.org> 3 * (C) 2000 Simon Hausmann <hausmann@kde.org>
4 * (C) 2000 Stefan Schimanski (1Stein@gmx.de) 4 * (C) 2000 Stefan Schimanski (1Stein@gmx.de)
5 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. 5 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 m_minPreferredLogicalWidth = LayoutUnit(); 59 m_minPreferredLogicalWidth = LayoutUnit();
60 m_maxPreferredLogicalWidth = LayoutUnit(); 60 m_maxPreferredLogicalWidth = LayoutUnit();
61 clearPreferredLogicalWidthsDirty(); 61 clearPreferredLogicalWidthsDirty();
62 } 62 }
63 63
64 void LayoutFrameSet::GridAxis::resize(int size) { 64 void LayoutFrameSet::GridAxis::resize(int size) {
65 m_sizes.resize(size); 65 m_sizes.resize(size);
66 m_deltas.resize(size); 66 m_deltas.resize(size);
67 m_deltas.fill(0); 67 m_deltas.fill(0);
68 68
69 // To track edges for resizability and borders, we need to be (size + 1). This is because a parent frameset 69 // To track edges for resizability and borders, we need to be (size + 1). This
70 // may ask us for information about our left/top/right/bottom edges in order t o make its own decisions about 70 // is because a parent frameset may ask us for information about our left/top/
71 // what to do. We are capable of tainting that parent frameset's borders, so w e have to cache this info. 71 // right/bottom edges in order to make its own decisions about what to do. We
72 // are capable of tainting that parent frameset's borders, so we have to cache
73 // this info.
72 m_preventResize.resize(size + 1); 74 m_preventResize.resize(size + 1);
73 m_allowBorder.resize(size + 1); 75 m_allowBorder.resize(size + 1);
74 } 76 }
75 77
76 void LayoutFrameSet::layOutAxis(GridAxis& axis, 78 void LayoutFrameSet::layOutAxis(GridAxis& axis,
77 const Vector<HTMLDimension>& grid, 79 const Vector<HTMLDimension>& grid,
78 int availableLen) { 80 int availableLen) {
79 availableLen = max(availableLen, 0); 81 availableLen = max(availableLen, 0);
80 82
81 int* gridLayout = axis.m_sizes.data(); 83 int* gridLayout = axis.m_sizes.data();
(...skipping 11 matching lines...) Expand all
93 int totalPercent = 0; 95 int totalPercent = 0;
94 int countRelative = 0; 96 int countRelative = 0;
95 int countFixed = 0; 97 int countFixed = 0;
96 int countPercent = 0; 98 int countPercent = 0;
97 99
98 float effectiveZoom = style()->effectiveZoom(); 100 float effectiveZoom = style()->effectiveZoom();
99 101
100 // First we need to investigate how many columns of each type we have and 102 // First we need to investigate how many columns of each type we have and
101 // how much space these columns are going to require. 103 // how much space these columns are going to require.
102 for (int i = 0; i < gridLen; ++i) { 104 for (int i = 0; i < gridLen; ++i) {
103 // Count the total length of all of the fixed columns/rows -> totalFixed 105 // Count the total length of all of the fixed columns/rows -> totalFixed.
104 // Count the number of columns/rows which are fixed -> countFixed 106 // Count the number of columns/rows which are fixed -> countFixed.
105 if (grid[i].isAbsolute()) { 107 if (grid[i].isAbsolute()) {
106 gridLayout[i] = max<int>(grid[i].value() * effectiveZoom, 0); 108 gridLayout[i] = max<int>(grid[i].value() * effectiveZoom, 0);
107 totalFixed += gridLayout[i]; 109 totalFixed += gridLayout[i];
108 countFixed++; 110 countFixed++;
109 } 111 }
110 112
111 // Count the total percentage of all of the percentage columns/rows -> total Percent 113 // Count the total percentage of all of the percentage columns/rows ->
112 // Count the number of columns/rows which are percentages -> countPercent 114 // totalPercent. Count the number of columns/rows which are percentages ->
115 // countPercent.
113 if (grid[i].isPercentage()) { 116 if (grid[i].isPercentage()) {
114 gridLayout[i] = max<int>(grid[i].value() * availableLen / 100., 0); 117 gridLayout[i] = max<int>(grid[i].value() * availableLen / 100., 0);
115 totalPercent += gridLayout[i]; 118 totalPercent += gridLayout[i];
116 countPercent++; 119 countPercent++;
117 } 120 }
118 121
119 // Count the total relative of all the relative columns/rows -> totalRelativ e 122 // Count the total relative of all the relative columns/rows ->
120 // Count the number of columns/rows which are relative -> countRelative 123 // totalRelative. Count the number of columns/rows which are relative ->
124 // countRelative.
121 if (grid[i].isRelative()) { 125 if (grid[i].isRelative()) {
122 totalRelative += max<int>(grid[i].value(), 1); 126 totalRelative += max<int>(grid[i].value(), 1);
123 countRelative++; 127 countRelative++;
124 } 128 }
125 } 129 }
126 130
127 int remainingLen = availableLen; 131 int remainingLen = availableLen;
128 132
129 // Fixed columns/rows are our first priority. If there is not enough space to fit all fixed 133 // Fixed columns/rows are our first priority. If there is not enough space to
130 // columns/rows we need to proportionally adjust their size. 134 // fit all fixed columns/rows we need to proportionally adjust their size.
131 if (totalFixed > remainingLen) { 135 if (totalFixed > remainingLen) {
132 int remainingFixed = remainingLen; 136 int remainingFixed = remainingLen;
133 137
134 for (int i = 0; i < gridLen; ++i) { 138 for (int i = 0; i < gridLen; ++i) {
135 if (grid[i].isAbsolute()) { 139 if (grid[i].isAbsolute()) {
136 gridLayout[i] = (gridLayout[i] * remainingFixed) / totalFixed; 140 gridLayout[i] = (gridLayout[i] * remainingFixed) / totalFixed;
137 remainingLen -= gridLayout[i]; 141 remainingLen -= gridLayout[i];
138 } 142 }
139 } 143 }
140 } else { 144 } else {
141 remainingLen -= totalFixed; 145 remainingLen -= totalFixed;
142 } 146 }
143 147
144 // Percentage columns/rows are our second priority. Divide the remaining space proportionally 148 // Percentage columns/rows are our second priority. Divide the remaining space
145 // over all percentage columns/rows. IMPORTANT: the size of each column/row is not relative 149 // proportionally over all percentage columns/rows.
146 // to 100%, but to the total percentage. For example, if there are three colum ns, each of 75%, 150 // NOTE: the size of each column/row is not relative to 100%, but to the total
147 // and the available space is 300px, each column will become 100px in width. 151 // percentage. For example, if there are three columns, each of 75%, and the
152 // available space is 300px, each column will become 100px in width.
148 if (totalPercent > remainingLen) { 153 if (totalPercent > remainingLen) {
149 int remainingPercent = remainingLen; 154 int remainingPercent = remainingLen;
150 155
151 for (int i = 0; i < gridLen; ++i) { 156 for (int i = 0; i < gridLen; ++i) {
152 if (grid[i].isPercentage()) { 157 if (grid[i].isPercentage()) {
153 gridLayout[i] = (gridLayout[i] * remainingPercent) / totalPercent; 158 gridLayout[i] = (gridLayout[i] * remainingPercent) / totalPercent;
154 remainingLen -= gridLayout[i]; 159 remainingLen -= gridLayout[i];
155 } 160 }
156 } 161 }
157 } else { 162 } else {
158 remainingLen -= totalPercent; 163 remainingLen -= totalPercent;
159 } 164 }
160 165
161 // Relative columns/rows are our last priority. Divide the remaining space pro portionally 166 // Relative columns/rows are our last priority. Divide the remaining space
162 // over all relative columns/rows. IMPORTANT: the relative value of 0* is trea ted as 1*. 167 // proportionally over all relative columns/rows.
168 // NOTE: the relative value of 0* is treated as 1*.
163 if (countRelative) { 169 if (countRelative) {
164 int lastRelative = 0; 170 int lastRelative = 0;
165 int remainingRelative = remainingLen; 171 int remainingRelative = remainingLen;
166 172
167 for (int i = 0; i < gridLen; ++i) { 173 for (int i = 0; i < gridLen; ++i) {
168 if (grid[i].isRelative()) { 174 if (grid[i].isRelative()) {
169 gridLayout[i] = 175 gridLayout[i] =
170 (max(grid[i].value(), 1.) * remainingRelative) / totalRelative; 176 (max(grid[i].value(), 1.) * remainingRelative) / totalRelative;
171 remainingLen -= gridLayout[i]; 177 remainingLen -= gridLayout[i];
172 lastRelative = i; 178 lastRelative = i;
173 } 179 }
174 } 180 }
175 181
176 // If we could not evenly distribute the available space of all of the relat ive 182 // If we could not evenly distribute the available space of all of the
177 // columns/rows, the remainder will be added to the last column/row. 183 // relative columns/rows, the remainder will be added to the last column/
178 // For example: if we have a space of 100px and three columns (*,*,*), the r emainder will 184 // row. For example: if we have a space of 100px and three columns (*,*,*),
179 // be 1px and will be added to the last column: 33px, 33px, 34px. 185 // the remainder will be 1px and will be added to the last column: 33px,
186 // 33px, 34px.
180 if (remainingLen) { 187 if (remainingLen) {
181 gridLayout[lastRelative] += remainingLen; 188 gridLayout[lastRelative] += remainingLen;
182 remainingLen = 0; 189 remainingLen = 0;
183 } 190 }
184 } 191 }
185 192
186 // If we still have some left over space we need to divide it over the already existing 193 // If we still have some left over space we need to divide it over the already
187 // columns/rows 194 // existing columns/rows
188 if (remainingLen) { 195 if (remainingLen) {
189 // Our first priority is to spread if over the percentage columns. The remai ning 196 // Our first priority is to spread if over the percentage columns. The
190 // space is spread evenly, for example: if we have a space of 100px, the col umns 197 // remaining space is spread evenly, for example: if we have a space of
191 // definition of 25%,25% used to result in two columns of 25px. After this t he 198 // 100px, the columns definition of 25%,25% used to result in two columns of
192 // columns will each be 50px in width. 199 // 25px. After this the columns will each be 50px in width.
193 if (countPercent && totalPercent) { 200 if (countPercent && totalPercent) {
194 int remainingPercent = remainingLen; 201 int remainingPercent = remainingLen;
195 int changePercent = 0; 202 int changePercent = 0;
196 203
197 for (int i = 0; i < gridLen; ++i) { 204 for (int i = 0; i < gridLen; ++i) {
198 if (grid[i].isPercentage()) { 205 if (grid[i].isPercentage()) {
199 changePercent = (remainingPercent * gridLayout[i]) / totalPercent; 206 changePercent = (remainingPercent * gridLayout[i]) / totalPercent;
200 gridLayout[i] += changePercent; 207 gridLayout[i] += changePercent;
201 remainingLen -= changePercent; 208 remainingLen -= changePercent;
202 } 209 }
203 } 210 }
204 } else if (totalFixed) { 211 } else if (totalFixed) {
205 // Our last priority is to spread the remaining space over the fixed colum ns. 212 // Our last priority is to spread the remaining space over the fixed
206 // For example if we have 100px of space and two column of each 40px, both 213 // columns. For example if we have 100px of space and two column of each
207 // columns will become exactly 50px. 214 // 40px, both columns will become exactly 50px.
208 int remainingFixed = remainingLen; 215 int remainingFixed = remainingLen;
209 int changeFixed = 0; 216 int changeFixed = 0;
210 217
211 for (int i = 0; i < gridLen; ++i) { 218 for (int i = 0; i < gridLen; ++i) {
212 if (grid[i].isAbsolute()) { 219 if (grid[i].isAbsolute()) {
213 changeFixed = (remainingFixed * gridLayout[i]) / totalFixed; 220 changeFixed = (remainingFixed * gridLayout[i]) / totalFixed;
214 gridLayout[i] += changeFixed; 221 gridLayout[i] += changeFixed;
215 remainingLen -= changeFixed; 222 remainingLen -= changeFixed;
216 } 223 }
217 } 224 }
218 } 225 }
219 } 226 }
220 227
221 // If we still have some left over space we probably ended up with a remainder of 228 // If we still have some left over space we probably ended up with a remainder
222 // a division. We cannot spread it evenly anymore. If we have any percentage 229 // of a division. We cannot spread it evenly anymore. If we have any
223 // columns/rows simply spread the remainder equally over all available percent age columns, 230 // percentage columns/rows simply spread the remainder equally over all
224 // regardless of their size. 231 // available percentage columns, regardless of their size.
225 if (remainingLen && countPercent) { 232 if (remainingLen && countPercent) {
226 int remainingPercent = remainingLen; 233 int remainingPercent = remainingLen;
227 int changePercent = 0; 234 int changePercent = 0;
228 235
229 for (int i = 0; i < gridLen; ++i) { 236 for (int i = 0; i < gridLen; ++i) {
230 if (grid[i].isPercentage()) { 237 if (grid[i].isPercentage()) {
231 changePercent = remainingPercent / countPercent; 238 changePercent = remainingPercent / countPercent;
232 gridLayout[i] += changePercent; 239 gridLayout[i] += changePercent;
233 remainingLen -= changePercent; 240 remainingLen -= changePercent;
234 } 241 }
235 } 242 }
236 } else if (remainingLen && countFixed) { 243 } else if (remainingLen && countFixed) {
237 // If we don't have any percentage columns/rows we only have 244 // If we don't have any percentage columns/rows we only have fixed columns.
238 // fixed columns. Spread the remainder equally over all fixed 245 // Spread the remainder equally over all fixed columns/rows.
239 // columns/rows.
240 int remainingFixed = remainingLen; 246 int remainingFixed = remainingLen;
241 int changeFixed = 0; 247 int changeFixed = 0;
242 248
243 for (int i = 0; i < gridLen; ++i) { 249 for (int i = 0; i < gridLen; ++i) {
244 if (grid[i].isAbsolute()) { 250 if (grid[i].isAbsolute()) {
245 changeFixed = remainingFixed / countFixed; 251 changeFixed = remainingFixed / countFixed;
246 gridLayout[i] += changeFixed; 252 gridLayout[i] += changeFixed;
247 remainingLen -= changeFixed; 253 remainingLen -= changeFixed;
248 } 254 }
249 } 255 }
(...skipping 16 matching lines...) Expand all
266 if (!worked) { 272 if (!worked) {
267 for (int i = 0; i < gridLen; ++i) 273 for (int i = 0; i < gridLen; ++i)
268 gridLayout[i] -= gridDelta[i]; 274 gridLayout[i] -= gridDelta[i];
269 axis.m_deltas.fill(0); 275 axis.m_deltas.fill(0);
270 } 276 }
271 } 277 }
272 278
273 void LayoutFrameSet::notifyFrameEdgeInfoChanged() { 279 void LayoutFrameSet::notifyFrameEdgeInfoChanged() {
274 if (needsLayout()) 280 if (needsLayout())
275 return; 281 return;
276 // FIXME: We should only recompute the edge info with respect to the frame tha t changed 282 // FIXME: We should only recompute the edge info with respect to the frame
277 // and its adjacent frame(s) instead of recomputing the edge info for the enti re frameset. 283 // that changed and its adjacent frame(s) instead of recomputing the edge info
284 // for the entire frameset.
278 computeEdgeInfo(); 285 computeEdgeInfo();
279 } 286 }
280 287
281 void LayoutFrameSet::fillFromEdgeInfo(const FrameEdgeInfo& edgeInfo, 288 void LayoutFrameSet::fillFromEdgeInfo(const FrameEdgeInfo& edgeInfo,
282 int r, 289 int r,
283 int c) { 290 int c) {
284 if (edgeInfo.allowBorder(LeftFrameEdge)) 291 if (edgeInfo.allowBorder(LeftFrameEdge))
285 m_cols.m_allowBorder[c] = true; 292 m_cols.m_allowBorder[c] = true;
286 if (edgeInfo.allowBorder(RightFrameEdge)) 293 if (edgeInfo.allowBorder(RightFrameEdge))
287 m_cols.m_allowBorder[c + 1] = true; 294 m_cols.m_allowBorder[c + 1] = true;
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 int borderThickness = frameSet()->border(); 406 int borderThickness = frameSet()->border();
400 LayoutSize size; 407 LayoutSize size;
401 LayoutPoint position; 408 LayoutPoint position;
402 for (int r = 0; r < rows; r++) { 409 for (int r = 0; r < rows; r++) {
403 position.setX(LayoutUnit()); 410 position.setX(LayoutUnit());
404 size.setHeight(LayoutUnit(m_rows.m_sizes[r])); 411 size.setHeight(LayoutUnit(m_rows.m_sizes[r]));
405 for (int c = 0; c < cols; c++) { 412 for (int c = 0; c < cols; c++) {
406 child->setLocation(position); 413 child->setLocation(position);
407 size.setWidth(LayoutUnit(m_cols.m_sizes[c])); 414 size.setWidth(LayoutUnit(m_cols.m_sizes[c]));
408 415
409 // If we have a new size, we need to resize and layout the child. If the s ize is 0x0 we 416 // If we have a new size, we need to resize and layout the child. If the
410 // also need to lay out, since this may mean that we're dealing with a chi ld frameset 417 // size is 0x0 we also need to lay out, since this may mean that we're
411 // that wasn't previously initialized properly, because it was previously hidden, but 418 // dealing with a child frameset that wasn't previously initialized
412 // no longer is, because rows * cols may have increased. 419 // properly, because it was previously hidden, but no longer is, because
420 // rows * cols may have increased.
413 if (size != child->size() || size.isEmpty()) { 421 if (size != child->size() || size.isEmpty()) {
414 child->setSize(size); 422 child->setSize(size);
415 child->setNeedsLayoutAndFullPaintInvalidation( 423 child->setNeedsLayoutAndFullPaintInvalidation(
416 LayoutInvalidationReason::SizeChanged); 424 LayoutInvalidationReason::SizeChanged);
417 child->layout(); 425 child->layout();
418 } 426 }
419 427
420 position.setX(position.x() + size.width() + borderThickness); 428 position.setX(position.x() + size.width() + borderThickness);
421 429
422 child = child->nextSiblingBox(); 430 child = child->nextSiblingBox();
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 return SetCursor; 571 return SetCursor;
564 } 572 }
565 if (canResizeColumn(roundedPoint)) { 573 if (canResizeColumn(roundedPoint)) {
566 cursor = columnResizeCursor(); 574 cursor = columnResizeCursor();
567 return SetCursor; 575 return SetCursor;
568 } 576 }
569 return LayoutBox::getCursor(point, cursor); 577 return LayoutBox::getCursor(point, cursor);
570 } 578 }
571 579
572 } // namespace blink 580 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutFrame.cpp ('k') | third_party/WebKit/Source/core/layout/LayoutFullScreen.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698