Commit 9368016f authored by Jia's avatar Jia Committed by Commit Bot

Implement parseShorthand API for property "margin".

Shorthand property "margin" is parsed by delegating parsing logic to 
its component longhands API, using ConsumeShorthandVia4LonghandsAPI.
This cl also serves as a use case of ConsumeShorthandVia4LonghandsAPI.

This cl contains the following changes
* Implemented of "margin" parseShorthand API.
* Changed the system to use the new API for parsing.
- Changed CSSPropertyParser.cpp to use property API to parse "margin".
- Added api parsing to json file.
- Updated BUILD files to include the new API files.

Bug: 668012
Change-Id: Ide0737ab44088cc882191b53278e56c65a075208
Reviewed-on: https://chromium-review.googlesource.com/560801
Commit-Queue: Jia Meng <jiameng@chromium.org>
Reviewed-by: default avatarAlan Cutter <alancutter@chromium.org>
Reviewed-by: default avatarDarren Shen <shend@chromium.org>
Cr-Commit-Position: refs/heads/master@{#485241}
parent eaebd94d
......@@ -593,6 +593,7 @@ css_properties("make_core_generated_css_property_apis") {
"$blink_core_output_dir/css/properties/CSSShorthandPropertyAPIFlex.h",
"$blink_core_output_dir/css/properties/CSSShorthandPropertyAPIFont.h",
"$blink_core_output_dir/css/properties/CSSShorthandPropertyAPIFontVariant.h",
"$blink_core_output_dir/css/properties/CSSShorthandPropertyAPIMargin.h",
"$blink_core_output_dir/css/properties/CSSShorthandPropertyAPIOverflow.h",
"$blink_core_output_dir/css/properties/CSSShorthandPropertyAPIOffset.h",
"$blink_core_output_dir/css/properties/CSSShorthandPropertyAPITextDecoration.h",
......
......@@ -540,6 +540,7 @@ blink_core_sources("css") {
"properties/CSSShorthandPropertyAPIFlex.cpp",
"properties/CSSShorthandPropertyAPIFont.cpp",
"properties/CSSShorthandPropertyAPIFontVariant.cpp",
"properties/CSSShorthandPropertyAPIMargin.cpp",
"properties/CSSShorthandPropertyAPIOffset.cpp",
"properties/CSSShorthandPropertyAPIOverflow.cpp",
"properties/CSSShorthandPropertyAPITextDecoration.cpp",
......
......@@ -3782,6 +3782,8 @@
{
name: "margin",
longhands: ["margin-top", "margin-right", "margin-bottom", "margin-left"],
api_class: true,
api_methods: ["parseShorthand"],
},
{
name: "marker",
......
......@@ -2377,8 +2377,6 @@ bool CSSPropertyParser::ParseShorthand(CSSPropertyID unresolved_property,
case CSSPropertyTextDecoration:
DCHECK(RuntimeEnabledFeatures::CSS3TextDecorationsEnabled());
return ConsumeShorthandGreedily(textDecorationShorthand(), important);
case CSSPropertyMargin:
return Consume4Values(marginShorthand(), important);
case CSSPropertyPadding:
return Consume4Values(paddingShorthand(), important);
case CSSPropertyWebkitTextEmphasis:
......
// 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/CSSShorthandPropertyAPIMargin.h"
#include "core/StylePropertyShorthand.h"
#include "core/css/parser/CSSPropertyParserHelpers.h"
namespace blink {
bool CSSShorthandPropertyAPIMargin::parseShorthand(
bool important,
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context,
HeapVector<CSSProperty, 256>& properties) {
return CSSPropertyParserHelpers::ConsumeShorthandVia4LonghandsAPI(
marginShorthand(), important, context, range, properties);
}
} // 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