Skip to content

Commit

Permalink
[css-grid] Fix use counter for percentage rows and indefinite height
Browse files Browse the repository at this point in the history
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:
w3c/csswg-drafts#1921

Change-Id: I2ab2cc28195e0b5e4f51ea37fff4c838e553cb8a
Reviewed-on: https://chromium-review.googlesource.com/1124840
Reviewed-by: Javier Fernandez <jfernandez@igalia.com>
Commit-Queue: Manuel Rego Casasnovas <rego@igalia.com>
Cr-Commit-Position: refs/heads/master@{#572332}
  • Loading branch information
mrego authored and Commit Bot committed Jul 3, 2018
1 parent a8bccdc commit c6ded0c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
28 changes: 28 additions & 0 deletions third_party/blink/renderer/core/frame/use_counter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,34 @@ TEST_F(UseCounterTest,
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 {
public:
DeprecationTest()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -826,8 +826,10 @@ GridTrackSize GridTrackSizingAlgorithm::GetGridTrackSize(
// If the logical width/height of the grid container is indefinite, percentage
// values are treated as <auto>.
if (IsRelativeSizedTrackAsAuto(track_size, direction)) {
UseCounter::Count(layout_grid_->GetDocument(),
WebFeature::kGridRowTrackPercentIndefiniteHeight);
if (direction == kForRows) {
UseCounter::Count(layout_grid_->GetDocument(),
WebFeature::kGridRowTrackPercentIndefiniteHeight);
}
if (min_track_breadth.HasPercentage())
min_track_breadth = Length(kAuto);
if (max_track_breadth.HasPercentage())
Expand Down

0 comments on commit c6ded0c

Please sign in to comment.