Commit 06d4b710 authored by aazzam's avatar aazzam Committed by Commit bot

Implements CSSPropertyAPI for the flex-basis property.

A part of Project Ribbon, separating the parsing logic for CSS
properties from the parser into an API. This patch removes
CSSPropertyFlexBasis from the switch statement in parseSingleValue,
and calls the API instead.

A function pointer to the parseSingleValue function from the API for the
page property is stored in a CSSPropertyDescriptor, and is called from
CSSPropertyParser.

This patch:
- Adds CSSPropertyAPIFlexBasis.cpp to the BUILD.gn file.
- Adds api_class flag to CSSProperties.in, which indicates that
  CSSPropertyAPIFlexBasis.h is generated.
- Moves the parsing logic for page from CSSPropertyParser.cpp to
  CSSPropertyAPIFlexBasis.cpp, which implements CSSPropertyAPI.h.

BUG=668012

Review-Url: https://codereview.chromium.org/2613843002
Cr-Commit-Position: refs/heads/master@{#442815}
parent 7995bd56
...@@ -347,6 +347,7 @@ blink_core_sources("css") { ...@@ -347,6 +347,7 @@ blink_core_sources("css") {
"properties/CSSPropertyAPICaretColor.cpp", "properties/CSSPropertyAPICaretColor.cpp",
"properties/CSSPropertyAPIClip.cpp", "properties/CSSPropertyAPIClip.cpp",
"properties/CSSPropertyAPIColumnGap.cpp", "properties/CSSPropertyAPIColumnGap.cpp",
"properties/CSSPropertyAPIFlexBasis.cpp",
"properties/CSSPropertyAPIFontSizeAdjust.cpp", "properties/CSSPropertyAPIFontSizeAdjust.cpp",
"properties/CSSPropertyAPISize.cpp", "properties/CSSPropertyAPISize.cpp",
"properties/CSSPropertyAPITextDecorationColor.cpp", "properties/CSSPropertyAPITextDecorationColor.cpp",
......
...@@ -256,7 +256,7 @@ fill interpolable, inherited, svg, setter=setFillPaint, custom_all ...@@ -256,7 +256,7 @@ fill interpolable, inherited, svg, setter=setFillPaint, custom_all
fill-opacity interpolable, inherited, svg, converter=convertNumberOrPercentage fill-opacity interpolable, inherited, svg, converter=convertNumberOrPercentage
fill-rule inherited, svg, type_name=WindRule fill-rule inherited, svg, type_name=WindRule
filter interpolable, converter=convertFilterOperations filter interpolable, converter=convertFilterOperations
flex-basis interpolable, converter=convertLengthOrAuto flex-basis interpolable, converter=convertLengthOrAuto, api_class
flex-direction flex-direction
flex-grow interpolable, type_name=float flex-grow interpolable, type_name=float
flex-shrink interpolable, type_name=float flex-shrink interpolable, type_name=float
......
...@@ -1872,14 +1872,6 @@ static CSSValue* consumeNoneOrURI(CSSParserTokenRange& range) { ...@@ -1872,14 +1872,6 @@ static CSSValue* consumeNoneOrURI(CSSParserTokenRange& range) {
return consumeUrl(range); return consumeUrl(range);
} }
static CSSValue* consumeFlexBasis(CSSParserTokenRange& range,
CSSParserMode cssParserMode) {
// FIXME: Support intrinsic dimensions too.
if (range.peek().id() == CSSValueAuto)
return consumeIdent(range);
return consumeLengthOrPercent(range, cssParserMode, ValueRangeNonNegative);
}
static CSSValue* consumeStrokeDasharray(CSSParserTokenRange& range) { static CSSValue* consumeStrokeDasharray(CSSParserTokenRange& range) {
CSSValueID id = range.peek().id(); CSSValueID id = range.peek().id();
if (id == CSSValueNone) if (id == CSSValueNone)
...@@ -3534,8 +3526,6 @@ const CSSValue* CSSPropertyParser::parseSingleValue( ...@@ -3534,8 +3526,6 @@ const CSSValue* CSSPropertyParser::parseSingleValue(
case CSSPropertyMarkerEnd: case CSSPropertyMarkerEnd:
case CSSPropertyMask: case CSSPropertyMask:
return consumeNoneOrURI(m_range); return consumeNoneOrURI(m_range);
case CSSPropertyFlexBasis:
return consumeFlexBasis(m_range, m_context.mode());
case CSSPropertyFlexGrow: case CSSPropertyFlexGrow:
case CSSPropertyFlexShrink: case CSSPropertyFlexShrink:
return consumeNumber(m_range, ValueRangeNonNegative); return consumeNumber(m_range, ValueRangeNonNegative);
......
// Copyright 2017 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/CSSPropertyAPIFlexBasis.h"
#include "core/css/parser/CSSParserContext.h"
#include "core/css/parser/CSSPropertyParserHelpers.h"
namespace blink {
const CSSValue* CSSPropertyAPIFlexBasis::parseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context) {
// FIXME: Support intrinsic dimensions too.
if (range.peek().id() == CSSValueAuto)
return CSSPropertyParserHelpers::consumeIdent(range);
return CSSPropertyParserHelpers::consumeLengthOrPercent(
range, context.mode(), ValueRangeNonNegative);
}
} // 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