Commit c6ded0c2 authored by Manuel Rego Casasnovas's avatar Manuel Rego Casasnovas Committed by Commit Bot

[css-grid] Fix use counter for percentage rows and indefinite height

In the past we added a use counter to check the usage of percentage rows
on grid containers with indefinite height.
The name of the use counter is kGridRowTrackPercentIndefiniteHeight,
however it was also counting the cases of percentage columns
on grid containers with indefinite width.

This patch removes the last case from the use counter, as it was wrong.
In addition, the patch adds a new unit test for the use counter
to verify that is only triggered for percentage rows.

JFTR this use counter is related to issue:
https://github.com/w3c/csswg-drafts/issues/1921

Change-Id: I2ab2cc28195e0b5e4f51ea37fff4c838e553cb8a
Reviewed-on: https://chromium-review.googlesource.com/1124840Reviewed-by: default avatarJavier Fernandez <jfernandez@igalia.com>
Commit-Queue: Manuel Rego Casasnovas <rego@igalia.com>
Cr-Commit-Position: refs/heads/master@{#572332}
parent a8bccdc9
...@@ -283,6 +283,34 @@ TEST_F(UseCounterTest, ...@@ -283,6 +283,34 @@ TEST_F(UseCounterTest,
EXPECT_FALSE(UseCounter::IsCounted(document, feature)); EXPECT_FALSE(UseCounter::IsCounted(document, feature));
} }
TEST_F(UseCounterTest, CSSGridLayoutPercentageColumnIndefiniteWidth) {
std::unique_ptr<DummyPageHolder> dummy_page_holder =
DummyPageHolder::Create(IntSize(800, 600));
Page::InsertOrdinaryPageForTesting(&dummy_page_holder->GetPage());
Document& document = dummy_page_holder->GetDocument();
WebFeature feature = WebFeature::kGridRowTrackPercentIndefiniteHeight;
EXPECT_FALSE(UseCounter::IsCounted(document, feature));
document.documentElement()->SetInnerHTMLFromString(
"<div style='display: inline-grid; grid-template-columns: 50%;'>"
"</div>");
document.View()->UpdateAllLifecyclePhases();
EXPECT_FALSE(UseCounter::IsCounted(document, feature));
}
TEST_F(UseCounterTest, CSSGridLayoutPercentageRowIndefiniteHeight) {
std::unique_ptr<DummyPageHolder> dummy_page_holder =
DummyPageHolder::Create(IntSize(800, 600));
Page::InsertOrdinaryPageForTesting(&dummy_page_holder->GetPage());
Document& document = dummy_page_holder->GetDocument();
WebFeature feature = WebFeature::kGridRowTrackPercentIndefiniteHeight;
EXPECT_FALSE(UseCounter::IsCounted(document, feature));
document.documentElement()->SetInnerHTMLFromString(
"<div style='display: inline-grid; grid-template-rows: 50%;'>"
"</div>");
document.View()->UpdateAllLifecyclePhases();
EXPECT_TRUE(UseCounter::IsCounted(document, feature));
}
class DeprecationTest : public testing::Test { class DeprecationTest : public testing::Test {
public: public:
DeprecationTest() DeprecationTest()
......
...@@ -826,8 +826,10 @@ GridTrackSize GridTrackSizingAlgorithm::GetGridTrackSize( ...@@ -826,8 +826,10 @@ GridTrackSize GridTrackSizingAlgorithm::GetGridTrackSize(
// If the logical width/height of the grid container is indefinite, percentage // If the logical width/height of the grid container is indefinite, percentage
// values are treated as <auto>. // values are treated as <auto>.
if (IsRelativeSizedTrackAsAuto(track_size, direction)) { if (IsRelativeSizedTrackAsAuto(track_size, direction)) {
UseCounter::Count(layout_grid_->GetDocument(), if (direction == kForRows) {
WebFeature::kGridRowTrackPercentIndefiniteHeight); UseCounter::Count(layout_grid_->GetDocument(),
WebFeature::kGridRowTrackPercentIndefiniteHeight);
}
if (min_track_breadth.HasPercentage()) if (min_track_breadth.HasPercentage())
min_track_breadth = Length(kAuto); min_track_breadth = Length(kAuto);
if (max_track_breadth.HasPercentage()) if (max_track_breadth.HasPercentage())
......
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