Commit 54cb2328 authored by aazzam's avatar aazzam Committed by Commit bot

Implements CSSPropertyAPI for the rotate property.

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

BUG=668012

Review-Url: https://codereview.chromium.org/2614833003
Cr-Commit-Position: refs/heads/master@{#443418}
parent 456acc90
......@@ -354,6 +354,7 @@ blink_core_sources("css") {
"properties/CSSPropertyAPIOutlineOffset.cpp",
"properties/CSSPropertyAPIPage.cpp",
"properties/CSSPropertyAPIPaintOrder.cpp",
"properties/CSSPropertyAPIRotate.cpp",
"properties/CSSPropertyAPISize.cpp",
"properties/CSSPropertyAPITextDecorationColor.cpp",
"properties/CSSPropertyAPITextDecorationSkip.cpp",
......
......@@ -391,7 +391,7 @@ transform typedom_types=[Transform], keywords=[none], interpolable, converter=co
transform-origin interpolable, converter=convertTransformOrigin, api_class
transform-style name_for_methods=TransformStyle3D
translate runtime_flag=CSSIndependentTransformProperties, converter=convertTranslate, interpolable, api_class
rotate runtime_flag=CSSIndependentTransformProperties, converter=convertRotate, interpolable
rotate runtime_flag=CSSIndependentTransformProperties, converter=convertRotate, interpolable, api_class
scale runtime_flag=CSSIndependentTransformProperties, converter=convertScale, interpolable
unicode-bidi type_name=UnicodeBidi, keyword_only, keywords=[normal|embed|bidi-override|isolate|plaintext|isolate-override], initial_keyword=normal, field_storage_type=platform/text/UnicodeBidi
vector-effect svg
......
......@@ -652,28 +652,6 @@ static CSSValue* consumeLineHeight(CSSParserTokenRange& range,
return consumeLengthOrPercent(range, cssParserMode, ValueRangeNonNegative);
}
static CSSValueList* consumeRotation(CSSParserTokenRange& range) {
ASSERT(RuntimeEnabledFeatures::cssIndependentTransformPropertiesEnabled());
CSSValueList* list = CSSValueList::createSpaceSeparated();
for (unsigned i = 0; i < 3; i++) { // 3 dimensions of rotation
CSSValue* dimension = consumeNumber(range, ValueRangeAll);
if (!dimension) {
if (i == 0)
break;
return nullptr;
}
list->append(*dimension);
}
CSSValue* rotation = consumeAngle(range);
if (!rotation)
return nullptr;
list->append(*rotation);
return list;
}
static CSSValue* consumeScale(CSSParserTokenRange& range) {
ASSERT(RuntimeEnabledFeatures::cssIndependentTransformPropertiesEnabled());
......@@ -3203,8 +3181,6 @@ const CSSValue* CSSPropertyParser::parseSingleValue(
return consumeFontSize(m_range, m_context.mode(), UnitlessQuirk::Allow);
case CSSPropertyLineHeight:
return consumeLineHeight(m_range, m_context.mode());
case CSSPropertyRotate:
return consumeRotation(m_range);
case CSSPropertyScale:
return consumeScale(m_range);
case CSSPropertyWebkitBorderHorizontalSpacing:
......
// 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/CSSPropertyAPIRotate.h"
#include "core/css/CSSValueList.h"
#include "core/css/parser/CSSPropertyParserHelpers.h"
#include "platform/RuntimeEnabledFeatures.h"
namespace blink {
const CSSValue* CSSPropertyAPIRotate::parseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context) {
DCHECK(RuntimeEnabledFeatures::cssIndependentTransformPropertiesEnabled());
CSSValueList* list = CSSValueList::createSpaceSeparated();
for (unsigned i = 0; i < 3; i++) { // 3 dimensions of rotation
CSSValue* dimension =
CSSPropertyParserHelpers::consumeNumber(range, ValueRangeAll);
if (!dimension) {
if (i == 0)
break;
return nullptr;
}
list->append(*dimension);
}
CSSValue* rotation = CSSPropertyParserHelpers::consumeAngle(range);
if (!rotation)
return nullptr;
list->append(*rotation);
return list;
}
} // 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