Commit 5275eb16 authored by Rob Buis's avatar Rob Buis Committed by Commit Bot

Implements CSSPropertyAPI for -webkit-perspective/perspective

As part of Project Ribbon, separate the parsing logic for CSS
properties -webkit-perspective and perspective from
the parser into an API.

Bug: 668012
Signed-off-by: default avatarRob Buis <rob.buis@samsung.com>
Change-Id: I504248e8561a9f97f741a5b5e3338b29d6caa395
Reviewed-on: https://chromium-review.googlesource.com/578213Reviewed-by: default avatarBugs Nash <bugsnash@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488440}
parent 5e5e78b2
...@@ -2004,7 +2004,8 @@ ...@@ -2004,7 +2004,8 @@
}, },
{ {
name: "perspective", name: "perspective",
api_class: "CSSPropertyAPIPerspective", api_class: true,
api_methods: ["parseSingleValue"],
converter: "ConvertPerspective", converter: "ConvertPerspective",
interpolable: true, interpolable: true,
field_template: "primitive", field_template: "primitive",
......
...@@ -375,27 +375,6 @@ static CSSValue* ConsumeFilter(CSSParserTokenRange& range, ...@@ -375,27 +375,6 @@ static CSSValue* ConsumeFilter(CSSParserTokenRange& range,
return list; return list;
} }
static CSSValue* ConsumePerspective(CSSParserTokenRange& range,
const CSSParserContext* context,
bool use_legacy_parsing) {
if (range.Peek().Id() == CSSValueNone)
return ConsumeIdent(range);
CSSPrimitiveValue* parsed_value =
ConsumeLength(range, context->Mode(), kValueRangeAll);
if (!parsed_value && use_legacy_parsing) {
double perspective;
if (!ConsumeNumberRaw(range, perspective))
return nullptr;
context->Count(WebFeature::kUnitlessPerspectiveInPerspectiveProperty);
parsed_value = CSSPrimitiveValue::Create(
perspective, CSSPrimitiveValue::UnitType::kPixels);
}
if (parsed_value &&
(parsed_value->IsCalculated() || parsed_value->GetDoubleValue() > 0))
return parsed_value;
return nullptr;
}
static CSSValue* ConsumeBackgroundBlendMode(CSSParserTokenRange& range) { static CSSValue* ConsumeBackgroundBlendMode(CSSParserTokenRange& range) {
CSSValueID id = range.Peek().Id(); CSSValueID id = range.Peek().Id();
if (id == CSSValueNormal || id == CSSValueOverlay || if (id == CSSValueNormal || id == CSSValueOverlay ||
...@@ -1046,10 +1025,6 @@ const CSSValue* CSSPropertyParser::ParseSingleValue( ...@@ -1046,10 +1025,6 @@ const CSSValue* CSSPropertyParser::ParseSingleValue(
case CSSPropertyR: case CSSPropertyR:
return ConsumeLengthOrPercent(range_, kSVGAttributeMode, kValueRangeAll, return ConsumeLengthOrPercent(range_, kSVGAttributeMode, kValueRangeAll,
UnitlessQuirk::kForbid); UnitlessQuirk::kForbid);
case CSSPropertyPerspective:
return ConsumePerspective(
range_, context_,
unresolved_property == CSSPropertyAliasWebkitPerspective);
case CSSPropertyBorderImageRepeat: case CSSPropertyBorderImageRepeat:
case CSSPropertyWebkitMaskBoxImageRepeat: case CSSPropertyWebkitMaskBoxImageRepeat:
return CSSPropertyBorderImageUtils::ConsumeBorderImageRepeat(range_); return CSSPropertyBorderImageUtils::ConsumeBorderImageRepeat(range_);
......
...@@ -4,4 +4,34 @@ ...@@ -4,4 +4,34 @@
#include "core/css/properties/CSSPropertyAPIPerspective.h" #include "core/css/properties/CSSPropertyAPIPerspective.h"
namespace blink {} // namespace blink #include "core/css/parser/CSSParserContext.h"
#include "core/css/parser/CSSParserLocalContext.h"
#include "core/css/parser/CSSPropertyParserHelpers.h"
#include "core/frame/UseCounter.h"
namespace blink {
const CSSValue* CSSPropertyAPIPerspective::parseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& localContext) {
if (range.Peek().Id() == CSSValueNone)
return CSSPropertyParserHelpers::ConsumeIdent(range);
CSSPrimitiveValue* parsed_value = CSSPropertyParserHelpers::ConsumeLength(
range, context.Mode(), kValueRangeAll);
bool use_legacy_parsing = localContext.UseAliasParsing();
if (!parsed_value && use_legacy_parsing) {
double perspective;
if (!CSSPropertyParserHelpers::ConsumeNumberRaw(range, perspective))
return nullptr;
context.Count(WebFeature::kUnitlessPerspectiveInPerspectiveProperty);
parsed_value = CSSPrimitiveValue::Create(
perspective, CSSPrimitiveValue::UnitType::kPixels);
}
if (parsed_value &&
(parsed_value->IsCalculated() || parsed_value->GetDoubleValue() > 0))
return parsed_value;
return nullptr;
}
} // 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