Commit 3717cfcc authored by Manuel Rego Casasnovas's avatar Manuel Rego Casasnovas Committed by Commit Bot

[css-grid] Modify use counter kGridRowTrackPercentIndefiniteHeight

The use counter was counting all the cases in which we have
a percentage row track in a grid container with indefinite height.
However some of these cases render the same independently if
we resolve the percentages against the intrinsic grid container height
(like it happens right now for grid layout row gutters and tracks)
or not (like it happens for flexbox row gutters).

This patch modifies the use counter so we count only the cases
that will change the output depending on how we resolve the percentages.
So the cases in which we have a single row with 100% percent
are not counted anymore.

This is similar to what we do for kGridRowGapPercentIndefinite,
where we only count cases when there are more than 1 row.

This will give us a better understanding of the web compat risk
if we decide to change this behavior in the future.

Change-Id: I07ff2c914b39b2e27084afad39c949a95072ce19
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2212128Reviewed-by: default avatarOriol Brufau <obrufau@igalia.com>
Reviewed-by: default avatarJavier Fernandez <jfernandez@igalia.com>
Commit-Queue: Manuel Rego <rego@igalia.com>
Cr-Commit-Position: refs/heads/master@{#771350}
parent a8df1228
......@@ -262,7 +262,7 @@ TEST_F(UseCounterHelperTest, CSSGridLayoutPercentageColumnIndefiniteWidth) {
EXPECT_FALSE(document.IsUseCounted(feature));
}
TEST_F(UseCounterHelperTest, CSSGridLayoutPercentageRowIndefiniteHeight) {
TEST_F(UseCounterHelperTest, CSSGridLayoutPercentageRowIndefiniteHeight1) {
auto dummy_page_holder = std::make_unique<DummyPageHolder>(IntSize(800, 600));
Page::InsertOrdinaryPageForTesting(&dummy_page_holder->GetPage());
Document& document = dummy_page_holder->GetDocument();
......@@ -275,6 +275,87 @@ TEST_F(UseCounterHelperTest, CSSGridLayoutPercentageRowIndefiniteHeight) {
EXPECT_TRUE(document.IsUseCounted(feature));
}
TEST_F(UseCounterHelperTest, CSSGridLayoutPercentageRowIndefiniteHeight2) {
auto dummy_page_holder = std::make_unique<DummyPageHolder>(IntSize(800, 600));
Page::InsertOrdinaryPageForTesting(&dummy_page_holder->GetPage());
Document& document = dummy_page_holder->GetDocument();
WebFeature feature = WebFeature::kGridRowTrackPercentIndefiniteHeight;
EXPECT_FALSE(document.IsUseCounted(feature));
document.documentElement()->setInnerHTML(
"<div style='display: inline-grid; grid-template-rows: 50% 50%;'>"
"</div>");
UpdateAllLifecyclePhases(document);
EXPECT_TRUE(document.IsUseCounted(feature));
}
TEST_F(UseCounterHelperTest, CSSGridLayoutPercentageRowIndefiniteHeight3) {
auto dummy_page_holder = std::make_unique<DummyPageHolder>(IntSize(800, 600));
Page::InsertOrdinaryPageForTesting(&dummy_page_holder->GetPage());
Document& document = dummy_page_holder->GetDocument();
WebFeature feature = WebFeature::kGridRowTrackPercentIndefiniteHeight;
EXPECT_FALSE(document.IsUseCounted(feature));
document.documentElement()->setInnerHTML(
"<div style='display: inline-grid; grid-template-rows: 100% 100%;'>"
"</div>");
UpdateAllLifecyclePhases(document);
EXPECT_TRUE(document.IsUseCounted(feature));
}
TEST_F(UseCounterHelperTest, CSSGridLayoutPercentageRowIndefiniteHeight4) {
auto dummy_page_holder = std::make_unique<DummyPageHolder>(IntSize(800, 600));
Page::InsertOrdinaryPageForTesting(&dummy_page_holder->GetPage());
Document& document = dummy_page_holder->GetDocument();
WebFeature feature = WebFeature::kGridRowTrackPercentIndefiniteHeight;
EXPECT_FALSE(document.IsUseCounted(feature));
document.documentElement()->setInnerHTML(
"<div style='display: inline-grid; grid-template-rows: minmax(50%, "
"100%);'>"
"</div>");
UpdateAllLifecyclePhases(document);
EXPECT_TRUE(document.IsUseCounted(feature));
}
TEST_F(UseCounterHelperTest, CSSGridLayoutPercentageRowIndefiniteHeight5) {
auto dummy_page_holder = std::make_unique<DummyPageHolder>(IntSize(800, 600));
Page::InsertOrdinaryPageForTesting(&dummy_page_holder->GetPage());
Document& document = dummy_page_holder->GetDocument();
WebFeature feature = WebFeature::kGridRowTrackPercentIndefiniteHeight;
EXPECT_FALSE(document.IsUseCounted(feature));
document.documentElement()->setInnerHTML(
"<div style='display: inline-grid; max-height: 0; grid-template-rows: "
"100%;'>"
"</div>");
UpdateAllLifecyclePhases(document);
EXPECT_TRUE(document.IsUseCounted(feature));
}
TEST_F(UseCounterHelperTest, CSSGridLayoutPercentageRowIndefiniteHeight6) {
auto dummy_page_holder = std::make_unique<DummyPageHolder>(IntSize(800, 600));
Page::InsertOrdinaryPageForTesting(&dummy_page_holder->GetPage());
Document& document = dummy_page_holder->GetDocument();
WebFeature feature = WebFeature::kGridRowTrackPercentIndefiniteHeight;
EXPECT_FALSE(document.IsUseCounted(feature));
document.documentElement()->setInnerHTML(
"<div style='display: inline-grid; grid-template-rows: 100%;'>"
"</div>");
UpdateAllLifecyclePhases(document);
EXPECT_FALSE(document.IsUseCounted(feature));
}
TEST_F(UseCounterHelperTest, CSSGridLayoutPercentageRowIndefiniteHeight7) {
auto dummy_page_holder = std::make_unique<DummyPageHolder>(IntSize(800, 600));
Page::InsertOrdinaryPageForTesting(&dummy_page_holder->GetPage());
Document& document = dummy_page_holder->GetDocument();
WebFeature feature = WebFeature::kGridRowTrackPercentIndefiniteHeight;
EXPECT_FALSE(document.IsUseCounted(feature));
document.documentElement()->setInnerHTML(
"<div style='display: inline-grid; grid-template-rows: minmax(100%, "
"100%);'>"
"</div>");
UpdateAllLifecyclePhases(document);
EXPECT_FALSE(document.IsUseCounted(feature));
}
TEST_F(UseCounterHelperTest, CSSFlexibleBox) {
auto dummy_page_holder = std::make_unique<DummyPageHolder>(IntSize(800, 600));
Page::InsertOrdinaryPageForTesting(&dummy_page_holder->GetPage());
......
......@@ -946,8 +946,20 @@ GridTrackSize GridTrackSizingAlgorithm::CalculateGridTrackSize(
// values are treated as <auto>.
if (IsRelativeSizedTrackAsAuto(track_size, direction)) {
if (direction == kForRows) {
UseCounter::Count(layout_grid_->GetDocument(),
WebFeature::kGridRowTrackPercentIndefiniteHeight);
// We avoid counting the cases in which it doesn't matter if we resolve
// the percentages row tracks against the intrinsic height of the grid
// container or we treat them as auto. Basically if we have just one row,
// it has 100% size and the max-block-size is none.
if ((grid_.NumTracks(direction) != 1) || !min_track_breadth.IsLength() ||
!min_track_breadth.length().IsPercent() ||
(min_track_breadth.length().Percent() != 100.0f) ||
!max_track_breadth.IsLength() ||
!max_track_breadth.length().IsPercent() ||
(max_track_breadth.length().Percent() != 100.0f) ||
!layout_grid_->StyleRef().LogicalMaxHeight().IsNone()) {
UseCounter::Count(layout_grid_->GetDocument(),
WebFeature::kGridRowTrackPercentIndefiniteHeight);
}
}
if (min_track_breadth.HasPercentage())
min_track_breadth = Length::Auto();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment