Commit 6f246deb authored by Bugs Nash's avatar Bugs Nash Committed by Commit Bot

Implemented parsing in BorderColor and BorderWidth property group APIs

This patch
- Added CSSPropertyAPIBorderColor
- Implemented parseSingleValue method on CSSPropertyAPIBorderColor and
  CSSPropertyAPIBorderWidth, moving parsing logic from CSSPropertyParser
  legacy switch
- Added details of API implementations to CSSProperties.json5 so that
  generated files will be updated

Bug: 668012
Change-Id: I05487329dab8542022d2750ddb1d81a4dbc65a1f
Reviewed-on: https://chromium-review.googlesource.com/566346Reviewed-by: default avatarmeade_UTC10 <meade@chromium.org>
Commit-Queue: Bugs Nash <bugsnash@chromium.org>
Cr-Commit-Position: refs/heads/master@{#486696}
parent e6b12333
......@@ -471,6 +471,7 @@ css_properties("make_core_generated_css_property_apis") {
"$blink_core_output_dir/css/properties/CSSPropertyAPIAnimationName.h",
"$blink_core_output_dir/css/properties/CSSPropertyAPIAnimationPlayState.h",
"$blink_core_output_dir/css/properties/CSSPropertyAPIBaselineShift.h",
"$blink_core_output_dir/css/properties/CSSPropertyAPIBorderColor.h",
"$blink_core_output_dir/css/properties/CSSPropertyAPIBorderImageOutset.h",
"$blink_core_output_dir/css/properties/CSSPropertyAPIBorderImageRepeat.h",
"$blink_core_output_dir/css/properties/CSSPropertyAPIBorderImageSlice.h",
......
......@@ -381,6 +381,7 @@ blink_core_sources("css") {
"properties/CSSPropertyAPIAnimationName.cpp",
"properties/CSSPropertyAPIAnimationPlayState.cpp",
"properties/CSSPropertyAPIBaselineShift.cpp",
"properties/CSSPropertyAPIBorderColor.cpp",
"properties/CSSPropertyAPIBorderImageOutset.cpp",
"properties/CSSPropertyAPIBorderImageRepeat.cpp",
"properties/CSSPropertyAPIBorderImageSlice.cpp",
......
......@@ -748,6 +748,8 @@
},
{
name: "border-bottom-color",
api_class: "CSSPropertyAPIBorderColor",
api_methods: ["parseSingleValue"],
custom_all: true,
interpolable: true,
type_name: "Color",
......@@ -792,6 +794,7 @@
{
name: "border-bottom-width",
api_class: "CSSPropertyAPIBorderWidth",
api_methods: ["parseSingleValue"],
converter: "ConvertBorderWidth",
interpolable: true,
keywords: ["thin", "medium", "thick"],
......@@ -844,6 +847,8 @@
},
{
name: "border-left-color",
api_class: "CSSPropertyAPIBorderColor",
api_methods: ["parseSingleValue"],
custom_all: true,
interpolable: true,
field_template: "storage_only",
......@@ -864,6 +869,7 @@
{
name: "border-left-width",
api_class: "CSSPropertyAPIBorderWidth",
api_methods: ["parseSingleValue"],
converter: "ConvertBorderWidth",
interpolable: true,
keywords: ["thin", "medium", "thick"],
......@@ -876,6 +882,8 @@
},
{
name: "border-right-color",
api_class: "CSSPropertyAPIBorderColor",
api_methods: ["parseSingleValue"],
custom_all: true,
interpolable: true,
field_template: "storage_only",
......@@ -896,6 +904,7 @@
{
name: "border-right-width",
api_class: "CSSPropertyAPIBorderWidth",
api_methods: ["parseSingleValue"],
converter: "ConvertBorderWidth",
interpolable: true,
keywords: ["thin", "medium", "thick"],
......@@ -908,6 +917,8 @@
},
{
name: "border-top-color",
api_class: "CSSPropertyAPIBorderColor",
api_methods: ["parseSingleValue"],
custom_all: true,
interpolable: true,
field_template: "storage_only",
......@@ -952,6 +963,7 @@
{
name: "border-top-width",
api_class: "CSSPropertyAPIBorderWidth",
api_methods: ["parseSingleValue"],
converter: "ConvertBorderWidth",
interpolable: true,
keywords: ["thin", "medium", "thick"],
......
......@@ -47,7 +47,6 @@
#include "core/css/properties/CSSPropertyPositionUtils.h"
#include "core/css/properties/CSSPropertyTextDecorationLineUtils.h"
#include "core/css/properties/CSSPropertyTransitionPropertyUtils.h"
#include "core/css/properties/CSSPropertyWebkitBorderWidthUtils.h"
#include "core/frame/UseCounter.h"
#include "core/layout/LayoutTheme.h"
#include "platform/wtf/text/StringBuilder.h"
......@@ -1222,27 +1221,6 @@ const CSSValue* CSSPropertyParser::ParseSingleValue(
case CSSPropertyGridRowGap:
return ConsumeLengthOrPercent(range_, context_->Mode(),
kValueRangeNonNegative);
case CSSPropertyBorderBottomColor:
case CSSPropertyBorderLeftColor:
case CSSPropertyBorderRightColor:
case CSSPropertyBorderTopColor: {
bool allow_quirky_colors =
InQuirksMode() && (current_shorthand == CSSPropertyInvalid ||
current_shorthand == CSSPropertyBorderColor);
return ConsumeColor(range_, context_->Mode(), allow_quirky_colors);
}
case CSSPropertyBorderBottomWidth:
case CSSPropertyBorderLeftWidth:
case CSSPropertyBorderRightWidth:
case CSSPropertyBorderTopWidth: {
bool allow_quirky_lengths =
InQuirksMode() && (current_shorthand == CSSPropertyInvalid ||
current_shorthand == CSSPropertyBorderWidth);
UnitlessQuirk unitless =
allow_quirky_lengths ? UnitlessQuirk::kAllow : UnitlessQuirk::kForbid;
return CSSPropertyWebkitBorderWidthUtils::ConsumeBorderWidth(
range_, context_->Mode(), unitless);
}
case CSSPropertyFilter:
case CSSPropertyBackdropFilter:
return ConsumeFilter(range_, context_);
......
// 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/CSSPropertyAPIBorderColor.h"
#include "core/CSSPropertyNames.h"
#include "core/css/parser/CSSParserContext.h"
#include "core/css/parser/CSSParserLocalContext.h"
#include "core/css/parser/CSSParserMode.h"
#include "core/css/parser/CSSPropertyParserHelpers.h"
namespace blink {
const CSSValue* CSSPropertyAPIBorderColor::parseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) {
CSSPropertyID shorthand = local_context.CurrentShorthand();
bool allow_quirky_colors =
IsQuirksModeBehavior(context.Mode()) &&
(shorthand == CSSPropertyInvalid || shorthand == CSSPropertyBorderColor);
return CSSPropertyParserHelpers::ConsumeColor(range, context.Mode(),
allow_quirky_colors);
}
} // namespace blink
......@@ -4,4 +4,27 @@
#include "core/css/properties/CSSPropertyAPIBorderWidth.h"
namespace blink {} // namespace blink
#include "core/css/parser/CSSParserContext.h"
#include "core/css/parser/CSSParserLocalContext.h"
#include "core/css/parser/CSSParserMode.h"
#include "core/css/parser/CSSPropertyParserHelpers.h"
#include "core/css/properties/CSSPropertyWebkitBorderWidthUtils.h"
namespace blink {
const CSSValue* CSSPropertyAPIBorderWidth::parseSingleValue(
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context) {
CSSPropertyID shorthand = local_context.CurrentShorthand();
bool allow_quirky_lengths =
IsQuirksModeBehavior(context.Mode()) &&
(shorthand == CSSPropertyInvalid || shorthand == CSSPropertyBorderWidth);
CSSPropertyParserHelpers::UnitlessQuirk unitless =
allow_quirky_lengths ? CSSPropertyParserHelpers::UnitlessQuirk::kAllow
: CSSPropertyParserHelpers::UnitlessQuirk::kForbid;
return CSSPropertyWebkitBorderWidthUtils::ConsumeBorderWidth(
range, context.Mode(), unitless);
}
} // 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