Commit 427ea09a authored by aazzam's avatar aazzam Committed by Commit bot

Made CSSPropertyAPIWillChange which implements API for will-change

Made implementation of CSSPropertyAPI for the will change property. The
logic for this was taken out of CSSPropertyParser.cpp and moved into
CSSPropertyAPIWillChange.cpp.

Also fixed error in CSSPropertyDescriptor.cpp.tmpl which meant only one
class could be implemented (missing comma in array).

BUG=668012

Review-Url: https://codereview.chromium.org/2550313003
Cr-Commit-Position: refs/heads/master@{#439387}
parent d7843414
...@@ -21,7 +21,7 @@ static CSSPropertyDescriptor cssPropertyDescriptors[] = { ...@@ -21,7 +21,7 @@ static CSSPropertyDescriptor cssPropertyDescriptors[] = {
// When functions are added to CSSPropertyAPI, also add them to the struct // When functions are added to CSSPropertyAPI, also add them to the struct
// initaliser below. // initaliser below.
{% for api_class in api_classes %} {% for api_class in api_classes %}
{ {{api_class.classname}}::parseSingleValue, true } { {{api_class.classname}}::parseSingleValue, true },
{% endfor %} {% endfor %}
}; };
......
...@@ -344,6 +344,7 @@ blink_core_sources("css") { ...@@ -344,6 +344,7 @@ blink_core_sources("css") {
"parser/SizesCalcParser.cpp", "parser/SizesCalcParser.cpp",
"properties/CSSPropertyAPI.h", "properties/CSSPropertyAPI.h",
"properties/CSSPropertyAPIWebkitPadding.cpp", "properties/CSSPropertyAPIWebkitPadding.cpp",
"properties/CSSPropertyAPIWillChange.cpp",
"properties/CSSPropertyDescriptor.h", "properties/CSSPropertyDescriptor.h",
"resolver/AnimatedStyleBuilder.cpp", "resolver/AnimatedStyleBuilder.cpp",
"resolver/AnimatedStyleBuilder.h", "resolver/AnimatedStyleBuilder.h",
......
...@@ -457,7 +457,7 @@ user-select inherited ...@@ -457,7 +457,7 @@ user-select inherited
white-space inherited, independent, keyword_only, keywords=[normal|pre|pre-wrap|pre-line|nowrap|-webkit-nowrap], initial_keyword=normal white-space inherited, independent, keyword_only, keywords=[normal|pre|pre-wrap|pre-line|nowrap|-webkit-nowrap], initial_keyword=normal
widows interpolable, inherited, type_name=short widows interpolable, inherited, type_name=short
width interpolable, initial=initialSize, converter=convertLengthSizing, typedom_types=[Length], keywords=[auto], supports_percentage width interpolable, initial=initialSize, converter=convertLengthSizing, typedom_types=[Length], keywords=[auto], supports_percentage
will-change custom_all will-change custom_all, api_class
word-break inherited word-break inherited
word-spacing interpolable, inherited, initial=initialLetterWordSpacing, converter=convertSpacing word-spacing interpolable, inherited, initial=initialLetterWordSpacing, converter=convertSpacing
// UAs must treat 'word-wrap' as an alternate name for the 'overflow-wrap' property. So using the same handlers. // UAs must treat 'word-wrap' as an alternate name for the 'overflow-wrap' property. So using the same handlers.
......
...@@ -302,57 +302,6 @@ static CSSValueList* consumeTransformOrigin(CSSParserTokenRange& range, ...@@ -302,57 +302,6 @@ static CSSValueList* consumeTransformOrigin(CSSParserTokenRange& range,
return nullptr; return nullptr;
} }
// Methods for consuming non-shorthand properties starts here.
static CSSValue* consumeWillChange(CSSParserTokenRange& range) {
if (range.peek().id() == CSSValueAuto)
return consumeIdent(range);
CSSValueList* values = CSSValueList::createCommaSeparated();
// Every comma-separated list of identifiers is a valid will-change value,
// unless the list includes an explicitly disallowed identifier.
while (true) {
if (range.peek().type() != IdentToken)
return nullptr;
CSSPropertyID unresolvedProperty =
unresolvedCSSPropertyID(range.peek().value());
if (unresolvedProperty != CSSPropertyInvalid &&
unresolvedProperty != CSSPropertyVariable) {
ASSERT(CSSPropertyMetadata::isEnabledProperty(unresolvedProperty));
// Now "all" is used by both CSSValue and CSSPropertyValue.
// Need to return nullptr when currentValue is CSSPropertyAll.
if (unresolvedProperty == CSSPropertyWillChange ||
unresolvedProperty == CSSPropertyAll)
return nullptr;
values->append(*CSSCustomIdentValue::create(unresolvedProperty));
range.consumeIncludingWhitespace();
} else {
switch (range.peek().id()) {
case CSSValueNone:
case CSSValueAll:
case CSSValueAuto:
case CSSValueDefault:
case CSSValueInitial:
case CSSValueInherit:
return nullptr;
case CSSValueContents:
case CSSValueScrollPosition:
values->append(*consumeIdent(range));
break;
default:
range.consumeIncludingWhitespace();
break;
}
}
if (range.atEnd())
break;
if (!consumeCommaIncludingWhitespace(range))
return nullptr;
}
return values;
}
static CSSFontFeatureValue* consumeFontFeatureTag(CSSParserTokenRange& range) { static CSSFontFeatureValue* consumeFontFeatureTag(CSSParserTokenRange& range) {
// Feature tag name consists of 4-letter characters. // Feature tag name consists of 4-letter characters.
static const unsigned tagNameLength = 4; static const unsigned tagNameLength = 4;
...@@ -3484,8 +3433,6 @@ const CSSValue* CSSPropertyParser::parseSingleValue( ...@@ -3484,8 +3433,6 @@ const CSSValue* CSSPropertyParser::parseSingleValue(
return cssPropertyDesc.parseSingleValue(m_range, m_context); return cssPropertyDesc.parseSingleValue(m_range, m_context);
switch (property) { switch (property) {
case CSSPropertyWillChange:
return consumeWillChange(m_range);
case CSSPropertyPage: case CSSPropertyPage:
return consumePage(m_range); return consumePage(m_range);
case CSSPropertyQuotes: case CSSPropertyQuotes:
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "core/css/properties/CSSPropertyAPIWillChange.h"
#include "core/css/CSSValueList.h"
#include "core/css/parser/CSSParserTokenRange.h"
#include "core/css/parser/CSSPropertyParser.h"
#include "core/css/parser/CSSPropertyParserHelpers.h"
namespace blink {
const CSSValue* CSSPropertyAPIWillChange::parseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context) {
if (range.peek().id() == CSSValueAuto)
return CSSPropertyParserHelpers::consumeIdent(range);
CSSValueList* values = CSSValueList::createCommaSeparated();
// Every comma-separated list of identifiers is a valid will-change value,
// unless the list includes an explicitly disallowed identifier.
while (true) {
if (range.peek().type() != IdentToken)
return nullptr;
CSSPropertyID unresolvedProperty =
unresolvedCSSPropertyID(range.peek().value());
if (unresolvedProperty != CSSPropertyInvalid &&
unresolvedProperty != CSSPropertyVariable) {
DCHECK(CSSPropertyMetadata::isEnabledProperty(unresolvedProperty));
// Now "all" is used by both CSSValue and CSSPropertyValue.
// Need to return nullptr when currentValue is CSSPropertyAll.
if (unresolvedProperty == CSSPropertyWillChange ||
unresolvedProperty == CSSPropertyAll)
return nullptr;
values->append(*CSSCustomIdentValue::create(unresolvedProperty));
range.consumeIncludingWhitespace();
} else {
switch (range.peek().id()) {
case CSSValueNone:
case CSSValueAll:
case CSSValueAuto:
case CSSValueDefault:
case CSSValueInitial:
case CSSValueInherit:
return nullptr;
case CSSValueContents:
case CSSValueScrollPosition:
values->append(*CSSPropertyParserHelpers::consumeIdent(range));
break;
default:
range.consumeIncludingWhitespace();
break;
}
}
if (range.atEnd())
break;
if (!CSSPropertyParserHelpers::consumeCommaIncludingWhitespace(range))
return nullptr;
}
return values;
}
} // namespace blink
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