Commit f4fd3e2d authored by rob.buis's avatar rob.buis Committed by Commit bot

Move some grid-column/grid-row related longhands into CSSPropertyParser

Move the following grid-column/grid-row related longhands from
LegacyCSSPropertyParser into CSSPropertyParser:
grid-column-start, grid-column-end,
grid-row-start, grid-row-end

BUG=499780

Review URL: https://codereview.chromium.org/1798863005

Cr-Commit-Position: refs/heads/master@{#381645}
parent ae515892
...@@ -76,6 +76,36 @@ PASS getComputedStyle(gridItemWithArea, '').getPropertyValue('grid-column-end') ...@@ -76,6 +76,36 @@ PASS getComputedStyle(gridItemWithArea, '').getPropertyValue('grid-column-end')
PASS getComputedStyle(gridItemWithArea, '').getPropertyValue('grid-row') is "auto / thirdArea" PASS getComputedStyle(gridItemWithArea, '').getPropertyValue('grid-row') is "auto / thirdArea"
PASS getComputedStyle(gridItemWithArea, '').getPropertyValue('grid-row-start') is "auto" PASS getComputedStyle(gridItemWithArea, '').getPropertyValue('grid-row-start') is "auto"
PASS getComputedStyle(gridItemWithArea, '').getPropertyValue('grid-row-end') is "thirdArea" PASS getComputedStyle(gridItemWithArea, '').getPropertyValue('grid-row-end') is "thirdArea"
PASS getComputedStyle(gridItemWithCSSWideKeyword, '').getPropertyValue('grid-column') is "auto / auto"
PASS getComputedStyle(gridItemWithCSSWideKeyword, '').getPropertyValue('grid-column-start') is "auto"
PASS getComputedStyle(gridItemWithCSSWideKeyword, '').getPropertyValue('grid-column-end') is "auto"
PASS getComputedStyle(gridItemWithCSSWideKeyword, '').getPropertyValue('grid-row') is "auto / auto"
PASS getComputedStyle(gridItemWithCSSWideKeyword, '').getPropertyValue('grid-row-start') is "auto"
PASS getComputedStyle(gridItemWithCSSWideKeyword, '').getPropertyValue('grid-row-end') is "auto"
PASS getComputedStyle(gridItemWithCSSWideKeyword2, '').getPropertyValue('grid-column') is "auto / auto"
PASS getComputedStyle(gridItemWithCSSWideKeyword2, '').getPropertyValue('grid-column-start') is "auto"
PASS getComputedStyle(gridItemWithCSSWideKeyword2, '').getPropertyValue('grid-column-end') is "auto"
PASS getComputedStyle(gridItemWithCSSWideKeyword2, '').getPropertyValue('grid-row') is "auto / auto"
PASS getComputedStyle(gridItemWithCSSWideKeyword2, '').getPropertyValue('grid-row-start') is "auto"
PASS getComputedStyle(gridItemWithCSSWideKeyword2, '').getPropertyValue('grid-row-end') is "auto"
PASS getComputedStyle(gridItemWithSpanAuto, '').getPropertyValue('grid-column') is "auto / auto"
PASS getComputedStyle(gridItemWithSpanAuto, '').getPropertyValue('grid-column-start') is "auto"
PASS getComputedStyle(gridItemWithSpanAuto, '').getPropertyValue('grid-column-end') is "auto"
PASS getComputedStyle(gridItemWithSpanAuto, '').getPropertyValue('grid-row') is "auto / auto"
PASS getComputedStyle(gridItemWithSpanAuto, '').getPropertyValue('grid-row-start') is "auto"
PASS getComputedStyle(gridItemWithSpanAuto, '').getPropertyValue('grid-row-end') is "auto"
PASS getComputedStyle(gridItemWithOneAuto, '').getPropertyValue('grid-column') is "auto / auto"
PASS getComputedStyle(gridItemWithOneAuto, '').getPropertyValue('grid-column-start') is "auto"
PASS getComputedStyle(gridItemWithOneAuto, '').getPropertyValue('grid-column-end') is "auto"
PASS getComputedStyle(gridItemWithOneAuto, '').getPropertyValue('grid-row') is "auto / auto"
PASS getComputedStyle(gridItemWithOneAuto, '').getPropertyValue('grid-row-start') is "auto"
PASS getComputedStyle(gridItemWithOneAuto, '').getPropertyValue('grid-row-end') is "auto"
PASS getComputedStyle(gridItemWithSpanAutoOne, '').getPropertyValue('grid-column') is "auto / auto"
PASS getComputedStyle(gridItemWithSpanAutoOne, '').getPropertyValue('grid-column-start') is "auto"
PASS getComputedStyle(gridItemWithSpanAutoOne, '').getPropertyValue('grid-column-end') is "auto"
PASS getComputedStyle(gridItemWithSpanAutoOne, '').getPropertyValue('grid-row') is "auto / auto"
PASS getComputedStyle(gridItemWithSpanAutoOne, '').getPropertyValue('grid-row-start') is "auto"
PASS getComputedStyle(gridItemWithSpanAutoOne, '').getPropertyValue('grid-row-end') is "auto"
Test the initial value Test the initial value
PASS getComputedStyle(element, '').getPropertyValue('grid-column-end') is 'auto' PASS getComputedStyle(element, '').getPropertyValue('grid-column-end') is 'auto'
......
...@@ -52,6 +52,26 @@ ...@@ -52,6 +52,26 @@
grid-column-end: firstArea; grid-column-end: firstArea;
grid-row-end: thirdArea; grid-row-end: thirdArea;
} }
.gridItemWithCSSWideKeyword {
grid-column-end: 2 inherit;
grid-row-end: 2 initial;
}
.gridItemWithCSSWideKeyword2 {
grid-column-end: 2 unset;
grid-row-end: 2 default;
}
.gridItemWithSpanAuto {
grid-column-end: span auto;
grid-row-end: auto span;
}
.gridItemWithOneAuto {
grid-column-end: 1 auto;
grid-row-end: auto 1;
}
.gridItemWithSpanAutoOne {
grid-column-end: span 1 auto;
grid-row-end: span auto 1;
}
</style> </style>
<script src="resources/grid-item-column-row-parsing-utils.js"></script> <script src="resources/grid-item-column-row-parsing-utils.js"></script>
<script src="../../resources/js-test.js"></script> <script src="../../resources/js-test.js"></script>
...@@ -71,6 +91,11 @@ ...@@ -71,6 +91,11 @@
<div class="gridItemWithSpanCustomIdent" id="gridItemWithSpanCustomIdentElement"></div> <div class="gridItemWithSpanCustomIdent" id="gridItemWithSpanCustomIdentElement"></div>
<div class="gridItemWithSpanNumberCustomIdent" id="gridItemWithSpanNumberCustomIdentElement"></div> <div class="gridItemWithSpanNumberCustomIdent" id="gridItemWithSpanNumberCustomIdentElement"></div>
<div class="gridItemWithArea" id="gridItemWithArea"></div> <div class="gridItemWithArea" id="gridItemWithArea"></div>
<div class="gridItemWithCSSWideKeyword" id="gridItemWithCSSWideKeyword"></div>
<div class="gridItemWithCSSWideKeyword2" id="gridItemWithCSSWideKeyword2"></div>
<div class="gridItemWithSpanAuto" id="gridItemWithSpanAuto"></div>
<div class="gridItemWithOneAuto" id="gridItemWithOneAuto"></div>
<div class="gridItemWithSpanAutoOne" id="gridItemWithSpanAutoOne"></div>
</div> </div>
<script> <script>
description('Test that setting and getting grid-column-end and grid-row-end works as expected'); description('Test that setting and getting grid-column-end and grid-row-end works as expected');
...@@ -88,6 +113,11 @@ ...@@ -88,6 +113,11 @@
testColumnRowCSSParsing("gridItemWithSpanCustomIdentElement", "auto / span 1 first", "auto / span 1 last"); testColumnRowCSSParsing("gridItemWithSpanCustomIdentElement", "auto / span 1 first", "auto / span 1 last");
testColumnRowCSSParsing("gridItemWithSpanNumberCustomIdentElement", "auto / span 2 first", "auto / span 3 last"); testColumnRowCSSParsing("gridItemWithSpanNumberCustomIdentElement", "auto / span 2 first", "auto / span 3 last");
testColumnRowCSSParsing("gridItemWithArea", "auto / firstArea", "auto / thirdArea"); testColumnRowCSSParsing("gridItemWithArea", "auto / firstArea", "auto / thirdArea");
testColumnRowCSSParsing("gridItemWithCSSWideKeyword", "auto / auto", "auto / auto");
testColumnRowCSSParsing("gridItemWithCSSWideKeyword2", "auto / auto", "auto / auto");
testColumnRowCSSParsing("gridItemWithSpanAuto", "auto / auto", "auto / auto");
testColumnRowCSSParsing("gridItemWithOneAuto", "auto / auto", "auto / auto");
testColumnRowCSSParsing("gridItemWithSpanAutoOne", "auto / auto", "auto / auto");
debug(""); debug("");
debug("Test the initial value"); debug("Test the initial value");
......
...@@ -3278,6 +3278,54 @@ static PassRefPtrWillBeRawPtr<CSSValue> consumeJustifyItems(CSSParserTokenRange& ...@@ -3278,6 +3278,54 @@ static PassRefPtrWillBeRawPtr<CSSValue> consumeJustifyItems(CSSParserTokenRange&
return consumeSelfPositionOverflowPosition(range); return consumeSelfPositionOverflowPosition(range);
} }
static PassRefPtrWillBeRawPtr<CSSCustomIdentValue> consumeCustomIdentForGridLine(CSSParserTokenRange& range)
{
if (range.peek().id() == CSSValueAuto || range.peek().id() == CSSValueSpan)
return nullptr;
return consumeCustomIdent(range);
}
static PassRefPtrWillBeRawPtr<CSSValue> consumeGridLine(CSSParserTokenRange& range)
{
if (range.peek().id() == CSSValueAuto)
return consumeIdent(range);
RefPtrWillBeRawPtr<CSSPrimitiveValue> spanValue = nullptr;
RefPtrWillBeRawPtr<CSSCustomIdentValue> gridLineName = nullptr;
RefPtrWillBeRawPtr<CSSPrimitiveValue> numericValue = consumeInteger(range);
if (numericValue) {
gridLineName = consumeCustomIdentForGridLine(range);
spanValue = consumeIdent<CSSValueSpan>(range);
} else if ((spanValue = consumeIdent<CSSValueSpan>(range))) {
numericValue = consumeInteger(range);
gridLineName = consumeCustomIdentForGridLine(range);
if (!numericValue)
numericValue = consumeInteger(range);
} else if ((gridLineName = consumeCustomIdentForGridLine(range))) {
numericValue = consumeInteger(range);
spanValue = consumeIdent<CSSValueSpan>(range);
if (!spanValue && !numericValue)
return gridLineName.release();
} else {
return nullptr;
}
if (spanValue && numericValue && numericValue->getIntValue() < 0)
return nullptr; // Negative numbers are not allowed for span.
if (numericValue && numericValue->getIntValue() == 0)
return nullptr; // An <integer> value of zero makes the declaration invalid.
RefPtrWillBeRawPtr<CSSValueList> values = CSSValueList::createSpaceSeparated();
if (spanValue)
values->append(spanValue.release());
if (numericValue)
values->append(numericValue.release());
if (gridLineName)
values->append(gridLineName.release());
ASSERT(values->length());
return values.release();
}
PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSPropertyID unresolvedProperty) PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSPropertyID unresolvedProperty)
{ {
CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty); CSSPropertyID property = resolveCSSPropertyID(unresolvedProperty);
...@@ -3640,6 +3688,12 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty ...@@ -3640,6 +3688,12 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::parseSingleValue(CSSProperty
case CSSPropertyJustifyItems: case CSSPropertyJustifyItems:
ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
return consumeJustifyItems(m_range); return consumeJustifyItems(m_range);
case CSSPropertyGridColumnEnd:
case CSSPropertyGridColumnStart:
case CSSPropertyGridRowEnd:
case CSSPropertyGridRowStart:
ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
return consumeGridLine(m_range);
default: default:
CSSParserValueList valueList(m_range); CSSParserValueList valueList(m_range);
if (valueList.size()) { if (valueList.size()) {
......
...@@ -276,14 +276,6 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::legacyParseValue(CSSProperty ...@@ -276,14 +276,6 @@ PassRefPtrWillBeRawPtr<CSSValue> CSSPropertyParser::legacyParseValue(CSSProperty
parsedValue = parseGridTrackList(); parsedValue = parseGridTrackList();
break; break;
case CSSPropertyGridColumnEnd:
case CSSPropertyGridColumnStart:
case CSSPropertyGridRowEnd:
case CSSPropertyGridRowStart:
ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
parsedValue = parseGridPosition();
break;
case CSSPropertyGridTemplateAreas: case CSSPropertyGridTemplateAreas:
ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled()); ASSERT(RuntimeEnabledFeatures::cssGridLayoutEnabled());
parsedValue = parseGridTemplateAreas(); parsedValue = parseGridTemplateAreas();
......
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