OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 // 1- First, the track sizing algorithm is used to resolve the sizes of the | 258 // 1- First, the track sizing algorithm is used to resolve the sizes of the |
259 // grid columns. | 259 // grid columns. |
260 // At this point the logical width is always definite as the above call to | 260 // At this point the logical width is always definite as the above call to |
261 // updateLogicalWidth() properly resolves intrinsic sizes. We cannot do the | 261 // updateLogicalWidth() properly resolves intrinsic sizes. We cannot do the |
262 // same for heights though because many code paths inside | 262 // same for heights though because many code paths inside |
263 // updateLogicalHeight() require a previous call to setLogicalHeight() to | 263 // updateLogicalHeight() require a previous call to setLogicalHeight() to |
264 // resolve heights properly (like for positioned items for example). | 264 // resolve heights properly (like for positioned items for example). |
265 LayoutUnit available_space_for_columns = AvailableLogicalWidth(); | 265 LayoutUnit available_space_for_columns = AvailableLogicalWidth(); |
266 ComputeTrackSizesForDefiniteSize(kForColumns, available_space_for_columns); | 266 ComputeTrackSizesForDefiniteSize(kForColumns, available_space_for_columns); |
267 | 267 |
| 268 // We take the chance to store the intrinsic sizes as they are just an |
| 269 // intermediate result of the track sizing algorithm. Apart from eventually |
| 270 // saving an algorithm execution (if {min|max}PreferredLogicalWidth() are |
| 271 // called later), it fixes the use case of computing the preferred logical |
| 272 // widths *after* the layout process. Although not very common, this happens |
| 273 // in the Mac (content::RenderViewImpl::didUpdateLayout()) or under some |
| 274 // circumstances when grids are also flex items (crbug.com/708159). |
| 275 if (PreferredLogicalWidthsDirty()) { |
| 276 LayoutUnit scrollbar_width = LayoutUnit(ScrollbarLogicalWidth()); |
| 277 min_preferred_logical_width_ = |
| 278 track_sizing_algorithm_.MinContentSize() + scrollbar_width; |
| 279 max_preferred_logical_width_ = |
| 280 track_sizing_algorithm_.MaxContentSize() + scrollbar_width; |
| 281 ClearPreferredLogicalWidthsDirty(); |
| 282 } |
| 283 |
268 // 2- Next, the track sizing algorithm resolves the sizes of the grid rows, | 284 // 2- Next, the track sizing algorithm resolves the sizes of the grid rows, |
269 // using the grid column sizes calculated in the previous step. | 285 // using the grid column sizes calculated in the previous step. |
270 if (CachedHasDefiniteLogicalHeight()) { | 286 if (CachedHasDefiniteLogicalHeight()) { |
271 ComputeTrackSizesForDefiniteSize( | 287 ComputeTrackSizesForDefiniteSize( |
272 kForRows, AvailableLogicalHeight(kExcludeMarginBorderPadding)); | 288 kForRows, AvailableLogicalHeight(kExcludeMarginBorderPadding)); |
273 } else { | 289 } else { |
274 ComputeTrackSizesForIndefiniteSize(track_sizing_algorithm_, kForRows, | 290 ComputeTrackSizesForIndefiniteSize(track_sizing_algorithm_, kForRows, |
275 grid_, min_content_height_, | 291 grid_, min_content_height_, |
276 max_content_height_); | 292 max_content_height_); |
277 } | 293 } |
(...skipping 2079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2357 if (direction == kForRows) | 2373 if (direction == kForRows) |
2358 return grid.NumTracks(kForRows); | 2374 return grid.NumTracks(kForRows); |
2359 | 2375 |
2360 return grid.NumTracks(kForRows) | 2376 return grid.NumTracks(kForRows) |
2361 ? grid.NumTracks(kForColumns) | 2377 ? grid.NumTracks(kForColumns) |
2362 : GridPositionsResolver::ExplicitGridColumnCount( | 2378 : GridPositionsResolver::ExplicitGridColumnCount( |
2363 StyleRef(), grid.AutoRepeatTracks(kForColumns)); | 2379 StyleRef(), grid.AutoRepeatTracks(kForColumns)); |
2364 } | 2380 } |
2365 | 2381 |
2366 } // namespace blink | 2382 } // namespace blink |
OLD | NEW |