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

Unified 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, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutGrid.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/LayoutGrid.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutGrid.cpp b/third_party/WebKit/Source/core/layout/LayoutGrid.cpp
index 8436b88dd8aa4c66d5c7bd7ffd4253a5a9a50d07..f760d79bd2826dcda4561da1c6bb094f9a01404e 100644
--- a/third_party/WebKit/Source/core/layout/LayoutGrid.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutGrid.cpp
@@ -252,8 +252,10 @@ void LayoutGrid::RepeatTracksSizingIfNeeded(
// min-content contribution.
// https://drafts.csswg.org/css-align-3/#baseline-align-content
// https://drafts.csswg.org/css-align-3/#baseline-align-self
- bool baseline_affect_intrinsic_width = BaselineMayAffectIntrinsicWidth();
- bool baseline_affect_intrinsic_height = BaselineMayAffectIntrinsicHeight();
+ bool baseline_affect_intrinsic_width =
+ BaselineMayAffectIntrinsicSize(kForColumns);
+ bool baseline_affect_intrinsic_height =
+ BaselineMayAffectIntrinsicSize(kForRows);
// In orthogonal flow cases column track's size is determined by using the
// computed row track's size, which it was estimated during the first cycle of
@@ -282,7 +284,8 @@ void LayoutGrid::RepeatTracksSizingIfNeeded(
ComputeTrackSizesForDefiniteSize(kForColumns, available_space_for_columns);
ComputeTrackSizesForDefiniteSize(kForRows, available_space_for_rows);
- if (baseline_affect_intrinsic_height) {
+ if (baseline_affect_intrinsic_height &&
+ StyleRef().LogicalHeight().IsIntrinsicOrAuto()) {
SetLogicalHeight(ComputeTrackBasedLogicalHeight() +
BorderAndPaddingLogicalHeight() +
ScrollbarLogicalHeight());
@@ -1872,29 +1875,29 @@ bool LayoutGrid::IsBaselineContextComputed(GridAxis baseline_axis) const {
: !col_axis_alignment_context_.IsEmpty();
}
-bool LayoutGrid::BaselineMayAffectIntrinsicWidth() const {
- if (!StyleRef().LogicalWidth().IsIntrinsicOrAuto())
- return false;
- for (const auto& context : col_axis_alignment_context_) {
+bool LayoutGrid::BaselineMayAffectIntrinsicSize(
+ GridTrackSizingDirection direction) const {
+ const auto& contexts_map = direction == kForColumns
+ ? col_axis_alignment_context_
+ : row_axis_alignment_context_;
+ for (const auto& context : contexts_map) {
+ auto track_size =
+ track_sizing_algorithm_.GetGridTrackSize(direction, context.key);
+ // TODO(lajava): Should we consider flexible tracks as well ?
+ if (!track_size.IsContentSized())
+ continue;
for (const auto& group : context.value->SharedGroups()) {
- if (group.size() > 1)
- return true;
+ if (group.size() > 1) {
+ auto grid_area_size =
+ track_sizing_algorithm_.Tracks(direction)[context.key].BaseSize();
+ if (group.MaxAscent() + group.MaxDescent() > grid_area_size)
+ return true;
+ }
}
}
return false;
}
-bool LayoutGrid::BaselineMayAffectIntrinsicHeight() const {
- if (!StyleRef().LogicalHeight().IsIntrinsicOrAuto())
- return false;
- for (const auto& context : row_axis_alignment_context_) {
- for (const auto& group : context.value->SharedGroups()) {
- if (group.size() > 1)
- return true;
- }
- }
- return false;
-}
void LayoutGrid::ComputeBaselineAlignmentContext() {
for (auto* child = FirstInFlowChildBox(); child;
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutGrid.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698