Commit 07f3c988 authored by aazzam's avatar aazzam Committed by Commit bot

Implements CSSPropertyAPI for the column-gap property.

A part of Project Ribbon, separating the parsing logic for CSS
properties from the parser into an API. This patch removes
CSSPropertyColumnGap 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 CSSPropertyAPIColumnGap.cpp to the BUILD.gn file.
- Adds api_class flag to CSSProperties.in, which indicates that
  CSSPropertyAPIColumnGap.h is generated.
- Moves the parsing logic for page from CSSPropertyParser.cpp to
  CSSPropertyAPIColumnGap.cpp, which implements CSSPropertyAPI.h.

BUG=668012

Review-Url: https://codereview.chromium.org/2609933004
Cr-Commit-Position: refs/heads/master@{#442812}
parent 8405306d
......@@ -346,6 +346,7 @@ blink_core_sources("css") {
"properties/CSSPropertyAPI.h",
"properties/CSSPropertyAPICaretColor.cpp",
"properties/CSSPropertyAPIClip.cpp",
"properties/CSSPropertyAPIColumnGap.cpp",
"properties/CSSPropertyAPISize.cpp",
"properties/CSSPropertyAPITextDecorationColor.cpp",
"properties/CSSPropertyAPITextDecorationSkip.cpp",
......
......@@ -417,7 +417,7 @@ y interpolable, svg, converter=convertLength
-webkit-box-pack
-webkit-box-reflect converter=convertBoxReflect
column-count interpolable, type_name=unsigned short, custom_all
column-gap interpolable, converter=convertComputedLength<float>, custom_all
column-gap interpolable, converter=convertComputedLength<float>, custom_all, api_class
column-rule-color interpolable, custom_all
column-rule-style type_name=EBorderStyle, initial=initialBorderStyle
column-rule-width interpolable, converter=convertLineWidth<unsigned short>
......
......@@ -878,6 +878,41 @@ static CSSValue* consumeMarginOrOffset(CSSParserTokenRange& range,
return consumeLengthOrPercent(range, cssParserMode, ValueRangeAll, unitless);
}
static CSSValue* consumeClipComponent(CSSParserTokenRange& range,
CSSParserMode cssParserMode) {
if (range.peek().id() == CSSValueAuto)
return consumeIdent(range);
return consumeLength(range, cssParserMode, ValueRangeAll,
UnitlessQuirk::Allow);
}
static CSSValue* consumeClip(CSSParserTokenRange& range,
CSSParserMode cssParserMode) {
if (range.peek().id() == CSSValueAuto)
return consumeIdent(range);
if (range.peek().functionId() != CSSValueRect)
return nullptr;
CSSParserTokenRange args = consumeFunction(range);
// rect(t, r, b, l) || rect(t r b l)
CSSValue* top = consumeClipComponent(args, cssParserMode);
if (!top)
return nullptr;
bool needsComma = consumeCommaIncludingWhitespace(args);
CSSValue* right = consumeClipComponent(args, cssParserMode);
if (!right || (needsComma && !consumeCommaIncludingWhitespace(args)))
return nullptr;
CSSValue* bottom = consumeClipComponent(args, cssParserMode);
if (!bottom || (needsComma && !consumeCommaIncludingWhitespace(args)))
return nullptr;
CSSValue* left = consumeClipComponent(args, cssParserMode);
if (!left || !args.atEnd())
return nullptr;
return CSSQuadValue::create(top, right, bottom, left,
CSSQuadValue::SerializeAsRect);
}
static bool consumePan(CSSParserTokenRange& range,
CSSValue*& panX,
CSSValue*& panY,
......@@ -968,13 +1003,6 @@ static CSSValue* consumeColumnCount(CSSParserTokenRange& range) {
return consumePositiveInteger(range);
}
static CSSValue* consumeColumnGap(CSSParserTokenRange& range,
CSSParserMode cssParserMode) {
if (range.peek().id() == CSSValueNormal)
return consumeIdent(range);
return consumeLength(range, cssParserMode, ValueRangeNonNegative);
}
static CSSValue* consumeColumnSpan(CSSParserTokenRange& range) {
return consumeIdent<CSSValueAll, CSSValueNone>(range);
}
......@@ -3360,6 +3388,8 @@ const CSSValue* CSSPropertyParser::parseSingleValue(
return consumeLengthOrPercent(m_range, m_context.mode(),
ValueRangeNonNegative,
UnitlessQuirk::Allow);
case CSSPropertyClip:
return consumeClip(m_range, m_context.mode());
case CSSPropertyTouchAction:
return consumeTouchAction(m_range);
case CSSPropertyScrollSnapDestination:
......@@ -3378,8 +3408,6 @@ const CSSValue* CSSPropertyParser::parseSingleValue(
return consumeColumnWidth(m_range);
case CSSPropertyColumnCount:
return consumeColumnCount(m_range);
case CSSPropertyColumnGap:
return consumeColumnGap(m_range, m_context.mode());
case CSSPropertyColumnSpan:
return consumeColumnSpan(m_range);
case CSSPropertyAnimationDelay:
......
......@@ -20,7 +20,8 @@ CSSValue* consumeClipComponent(CSSParserTokenRange& range,
range, cssParserMode, ValueRangeAll,
CSSPropertyParserHelpers::UnitlessQuirk::Allow);
}
}
} // namespace
const CSSValue* CSSPropertyAPIClip::parseSingleValue(
CSSParserTokenRange& range,
......
// 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/CSSPropertyAPIColumnGap.h"
#include "core/css/parser/CSSParserContext.h"
#include "core/css/parser/CSSPropertyParserHelpers.h"
namespace blink {
const CSSValue* CSSPropertyAPIColumnGap::parseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context) {
if (range.peek().id() == CSSValueNormal)
return CSSPropertyParserHelpers::consumeIdent(range);
return CSSPropertyParserHelpers::consumeLength(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