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

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

Issue 2868283002: [css-grid] Check if baseline alignment affects grid areas sizing (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
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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 // intrinsic width may also affect the extra Track Sizing algorithm cycles we 212 // intrinsic width may also affect the extra Track Sizing algorithm cycles we
213 // are about to execute. 213 // are about to execute.
214 // https://crbug.com/704713 214 // https://crbug.com/704713
215 // https://github.com/w3c/csswg-drafts/issues/1039 215 // https://github.com/w3c/csswg-drafts/issues/1039
216 216
217 // Hence we need to repeat computeUsedBreadthOfGridTracks for both, columns 217 // Hence we need to repeat computeUsedBreadthOfGridTracks for both, columns
218 // and rows, to determine the final values. 218 // and rows, to determine the final values.
219 ComputeTrackSizesForDefiniteSize(kForColumns, available_space_for_columns); 219 ComputeTrackSizesForDefiniteSize(kForColumns, available_space_for_columns);
220 ComputeTrackSizesForDefiniteSize(kForRows, available_space_for_rows); 220 ComputeTrackSizesForDefiniteSize(kForRows, available_space_for_rows);
221 221
222 if (baseline_affect_intrinsic_height) { 222 if (baseline_affect_intrinsic_height &&
223 StyleRef().LogicalHeight().IsIntrinsicOrAuto()) {
223 SetLogicalHeight(ComputeTrackBasedLogicalHeight() + 224 SetLogicalHeight(ComputeTrackBasedLogicalHeight() +
224 BorderAndPaddingLogicalHeight() + 225 BorderAndPaddingLogicalHeight() +
225 ScrollbarLogicalHeight()); 226 ScrollbarLogicalHeight());
226 } 227 }
227 } 228 }
228 229
229 void LayoutGrid::UpdateBlockLayout(bool relayout_children) { 230 void LayoutGrid::UpdateBlockLayout(bool relayout_children) {
230 DCHECK(NeedsLayout()); 231 DCHECK(NeedsLayout());
231 232
232 // We cannot perform a simplifiedLayout() on a dirty grid that 233 // We cannot perform a simplifiedLayout() on a dirty grid that
(...skipping 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after
1855 return child.MarginLogicalHeight() + child.LogicalHeight() - ascent; 1856 return child.MarginLogicalHeight() + child.LogicalHeight() - ascent;
1856 return child.MarginLogicalWidth() + child.LogicalWidth() - ascent; 1857 return child.MarginLogicalWidth() + child.LogicalWidth() - ascent;
1857 } 1858 }
1858 1859
1859 bool LayoutGrid::IsBaselineContextComputed(GridAxis baseline_axis) const { 1860 bool LayoutGrid::IsBaselineContextComputed(GridAxis baseline_axis) const {
1860 return baseline_axis == kGridColumnAxis 1861 return baseline_axis == kGridColumnAxis
1861 ? !row_axis_alignment_context_.IsEmpty() 1862 ? !row_axis_alignment_context_.IsEmpty()
1862 : !col_axis_alignment_context_.IsEmpty(); 1863 : !col_axis_alignment_context_.IsEmpty();
1863 } 1864 }
1864 1865
1866 // TODO (lajava): Maybe refactoring these methods based on direction.
svillar 2017/05/25 07:26:27 I think it's better to do the refactoring in this
jfernandez 2017/05/30 10:39:30 Acknowledged.
1865 bool LayoutGrid::BaselineMayAffectIntrinsicWidth() const { 1867 bool LayoutGrid::BaselineMayAffectIntrinsicWidth() const {
1866 if (!StyleRef().LogicalWidth().IsIntrinsicOrAuto())
1867 return false;
1868 for (const auto& context : col_axis_alignment_context_) { 1868 for (const auto& context : col_axis_alignment_context_) {
1869 auto track_size =
1870 track_sizing_algorithm_.GetGridTrackSize(kForColumns, context.key);
1871 if (!track_size.IsContentSized())
1872 continue;
1869 for (const auto& group : context.value->SharedGroups()) { 1873 for (const auto& group : context.value->SharedGroups()) {
1870 if (group.size() > 1) 1874 auto track_size =
svillar 2017/05/25 07:26:27 Having two "auto track_size" in the same method is
jfernandez 2017/05/30 10:39:30 Acknowledged.
1875 track_sizing_algorithm_.Tracks(kForColumns)[context.key].BaseSize();
1876 if ((group.size() > 1) &&
svillar 2017/05/25 07:26:27 Perhaps is a dumb question and the code was alread
jfernandez 2017/05/30 10:39:30 group is the baseline-sharing group [1] which cont
1877 (group.MaxAscent() + group.MaxDescent() > track_size))
1871 return true; 1878 return true;
1872 } 1879 }
1873 } 1880 }
1874 return false; 1881 return false;
1875 } 1882 }
1876 1883
1884 // TODO (lajava): Maybe refactoring these methods based on direction.
1877 bool LayoutGrid::BaselineMayAffectIntrinsicHeight() const { 1885 bool LayoutGrid::BaselineMayAffectIntrinsicHeight() const {
1878 if (!StyleRef().LogicalHeight().IsIntrinsicOrAuto())
1879 return false;
1880 for (const auto& context : row_axis_alignment_context_) { 1886 for (const auto& context : row_axis_alignment_context_) {
1887 auto track_size =
1888 track_sizing_algorithm_.GetGridTrackSize(kForRows, context.key);
1889 if (!track_size.IsContentSized())
1890 continue;
1881 for (const auto& group : context.value->SharedGroups()) { 1891 for (const auto& group : context.value->SharedGroups()) {
1882 if (group.size() > 1) 1892 auto track_size =
1893 track_sizing_algorithm_.Tracks(kForRows)[context.key].BaseSize();
1894 if ((group.size() > 1) &&
1895 (group.MaxAscent() + group.MaxDescent() > track_size))
1883 return true; 1896 return true;
1884 } 1897 }
1885 } 1898 }
1886 return false; 1899 return false;
1887 } 1900 }
1888 1901
1889 void LayoutGrid::ComputeBaselineAlignmentContext() { 1902 void LayoutGrid::ComputeBaselineAlignmentContext() {
1890 for (auto* child = FirstInFlowChildBox(); child; 1903 for (auto* child = FirstInFlowChildBox(); child;
1891 child = child->NextInFlowSiblingBox()) { 1904 child = child->NextInFlowSiblingBox()) {
1892 UpdateBaselineAlignmentContextIfNeeded(*child, kGridRowAxis); 1905 UpdateBaselineAlignmentContextIfNeeded(*child, kGridRowAxis);
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
2391 if (direction == kForRows) 2404 if (direction == kForRows)
2392 return grid.NumTracks(kForRows); 2405 return grid.NumTracks(kForRows);
2393 2406
2394 return grid.NumTracks(kForRows) 2407 return grid.NumTracks(kForRows)
2395 ? grid.NumTracks(kForColumns) 2408 ? grid.NumTracks(kForColumns)
2396 : GridPositionsResolver::ExplicitGridColumnCount( 2409 : GridPositionsResolver::ExplicitGridColumnCount(
2397 StyleRef(), grid.AutoRepeatTracks(kForColumns)); 2410 StyleRef(), grid.AutoRepeatTracks(kForColumns));
2398 } 2411 }
2399 2412
2400 } // namespace blink 2413 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698