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

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

Issue 2665133003: [css-grid] Fix behavior of positioned items without specific dimensions (Closed)
Patch Set: Applied suggested changes Created 3 years, 7 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
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBox.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 LayoutUnit column_breadth = LayoutUnit(); 1256 LayoutUnit column_breadth = LayoutUnit();
1257 OffsetAndBreadthForPositionedChild(*child, kForColumns, column_offset, 1257 OffsetAndBreadthForPositionedChild(*child, kForColumns, column_offset,
1258 column_breadth); 1258 column_breadth);
1259 LayoutUnit row_offset = LayoutUnit(); 1259 LayoutUnit row_offset = LayoutUnit();
1260 LayoutUnit row_breadth = LayoutUnit(); 1260 LayoutUnit row_breadth = LayoutUnit();
1261 OffsetAndBreadthForPositionedChild(*child, kForRows, row_offset, 1261 OffsetAndBreadthForPositionedChild(*child, kForRows, row_offset,
1262 row_breadth); 1262 row_breadth);
1263 1263
1264 child->SetOverrideContainingBlockContentLogicalWidth(column_breadth); 1264 child->SetOverrideContainingBlockContentLogicalWidth(column_breadth);
1265 child->SetOverrideContainingBlockContentLogicalHeight(row_breadth); 1265 child->SetOverrideContainingBlockContentLogicalHeight(row_breadth);
1266 child->SetExtraInlineOffset(column_offset);
1267 child->SetExtraBlockOffset(row_offset);
1268 1266
1269 if (child->Parent() == this) { 1267 // Mark for layout as we're resetting the position before and we relay in
1270 PaintLayer* child_layer = child->Layer(); 1268 // generic layout logic for positioned items in order to get the offsets
1271 child_layer->SetStaticInlinePosition(BorderStart() + column_offset); 1269 // properly resolved.
1272 child_layer->SetStaticBlockPosition(BorderBefore() + row_offset); 1270 child->SetNeedsLayout(LayoutInvalidationReason::kGridChanged,
1273 } 1271 kMarkOnlyThis);
1274 1272
1275 LayoutPositionedObject(child, relayout_children, info); 1273 LayoutPositionedObject(child, relayout_children, info);
1274
1275 child->SetLogicalLocation(LayoutPoint(child->LogicalLeft() + column_offset,
1276 child->LogicalTop() + row_offset));
1276 } 1277 }
1277 } 1278 }
1278 1279
1279 void LayoutGrid::OffsetAndBreadthForPositionedChild( 1280 void LayoutGrid::OffsetAndBreadthForPositionedChild(
1280 const LayoutBox& child, 1281 const LayoutBox& child,
1281 GridTrackSizingDirection direction, 1282 GridTrackSizingDirection direction,
1282 LayoutUnit& offset, 1283 LayoutUnit& offset,
1283 LayoutUnit& breadth) { 1284 LayoutUnit& breadth) {
1284 DCHECK(!IsOrthogonalChild(child)); 1285 DCHECK(!IsOrthogonalChild(child));
1285 bool is_for_columns = direction == kForColumns; 1286 bool is_for_columns = direction == kForColumns;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1357 DCHECK(!grid_.NeedsItemsPlacement()); 1358 DCHECK(!grid_.NeedsItemsPlacement());
1358 end -= GuttersSize(grid_, direction, end_line - 1, 2, 1359 end -= GuttersSize(grid_, direction, end_line - 1, 2,
1359 available_size_for_gutters); 1360 available_size_for_gutters);
1360 end -= is_for_columns ? offset_between_columns_ : offset_between_rows_; 1361 end -= is_for_columns ? offset_between_columns_ : offset_between_rows_;
1361 } 1362 }
1362 } 1363 }
1363 1364
1364 breadth = std::max(end - start, LayoutUnit()); 1365 breadth = std::max(end - start, LayoutUnit());
1365 offset = start; 1366 offset = start;
1366 1367
1367 if (is_for_columns && !StyleRef().IsLeftToRightDirection() && 1368 if (is_for_columns && !StyleRef().IsLeftToRightDirection()) {
1368 !child.StyleRef().HasStaticInlinePosition( 1369 // We always want to calculate the static position from the left
1369 child.IsHorizontalWritingMode())) {
1370 // If the child doesn't have a static inline position (i.e. "left" and/or
1371 // "right" aren't "auto", we need to calculate the offset from the left
1372 // (even if we're in RTL). 1370 // (even if we're in RTL).
1373 if (end_is_auto) { 1371 if (end_is_auto) {
1374 offset = LayoutUnit(); 1372 offset = LayoutUnit();
1375 } else { 1373 } else {
1376 offset = TranslateRTLCoordinate(column_positions_[end_line]) - 1374 offset = TranslateRTLCoordinate(column_positions_[end_line]) -
1377 BorderLogicalLeft(); 1375 BorderLogicalLeft();
1378 1376
1379 if (end_line > 0 && end_line < last_line) { 1377 if (end_line > 0 && end_line < last_line) {
1380 DCHECK(!grid_.NeedsItemsPlacement()); 1378 DCHECK(!grid_.NeedsItemsPlacement());
1381 offset += GuttersSize(grid_, direction, end_line - 1, 2, 1379 offset += GuttersSize(grid_, direction, end_line - 1, 2,
(...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after
2404 if (direction == kForRows) 2402 if (direction == kForRows)
2405 return grid.NumTracks(kForRows); 2403 return grid.NumTracks(kForRows);
2406 2404
2407 return grid.NumTracks(kForRows) 2405 return grid.NumTracks(kForRows)
2408 ? grid.NumTracks(kForColumns) 2406 ? grid.NumTracks(kForColumns)
2409 : GridPositionsResolver::ExplicitGridColumnCount( 2407 : GridPositionsResolver::ExplicitGridColumnCount(
2410 StyleRef(), grid.AutoRepeatTracks(kForColumns)); 2408 StyleRef(), grid.AutoRepeatTracks(kForColumns));
2411 } 2409 }
2412 2410
2413 } // namespace blink 2411 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutBox.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698