Commit bf4bb81b authored by Jia's avatar Jia Committed by Commit Bot

Implement parseShorthand API for marker and grid-gap.

For marker property, CSSPropertyInvalid was used as the 
"current_shorthand" in the old/non-API parsing method 
because it's not used. In its API, we use 
CSSPropertyMarker just to avoid confusion.  There is no 
real difference.

Bug: 668012
Change-Id: I528f7da64d6dc6537a248e8b6a08b3940c0f3b90
Reviewed-on: https://chromium-review.googlesource.com/597092
Commit-Queue: Jia Meng <jiameng@chromium.org>
Reviewed-by: default avatarBugs Nash <bugsnash@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491688}
parent 3d47c219
......@@ -581,9 +581,11 @@ blink_core_sources("css") {
"properties/CSSShorthandPropertyAPIFontVariant.cpp",
"properties/CSSShorthandPropertyAPIGridArea.cpp",
"properties/CSSShorthandPropertyAPIGridColumn.cpp",
"properties/CSSShorthandPropertyAPIGridGap.cpp",
"properties/CSSShorthandPropertyAPIGridRow.cpp",
"properties/CSSShorthandPropertyAPIListStyle.cpp",
"properties/CSSShorthandPropertyAPIMargin.cpp",
"properties/CSSShorthandPropertyAPIMarker.cpp",
"properties/CSSShorthandPropertyAPIOffset.cpp",
"properties/CSSShorthandPropertyAPIOutline.cpp",
"properties/CSSShorthandPropertyAPIOverflow.cpp",
......
......@@ -3900,6 +3900,7 @@
name: "grid-gap",
longhands: ["grid-row-gap", "grid-column-gap"],
api_class: true,
api_methods: ["parseShorthand"],
runtime_flag: "CSSGridLayout",
},
{
......@@ -3931,6 +3932,7 @@
name: "marker",
longhands: ["marker-start", "marker-mid", "marker-end"],
api_class: true,
api_methods: ["parseShorthand"],
},
{
name: "offset",
......
......@@ -1378,18 +1378,6 @@ bool CSSPropertyParser::ParseShorthand(CSSPropertyID unresolved_property,
}
switch (property) {
case CSSPropertyMarker: {
const CSSValue* marker = ParseSingleValue(CSSPropertyMarkerStart);
if (!marker || !range_.AtEnd())
return false;
AddParsedProperty(CSSPropertyMarkerStart, CSSPropertyMarker, *marker,
important);
AddParsedProperty(CSSPropertyMarkerMid, CSSPropertyMarker, *marker,
important);
AddParsedProperty(CSSPropertyMarkerEnd, CSSPropertyMarker, *marker,
important);
return true;
}
case CSSPropertyBorder:
return ConsumeBorder(important);
case CSSPropertyBackgroundRepeat:
......@@ -1414,23 +1402,6 @@ bool CSSPropertyParser::ParseShorthand(CSSPropertyID unresolved_property,
return ConsumeBackgroundShorthand(backgroundShorthand(), important);
case CSSPropertyWebkitMask:
return ConsumeBackgroundShorthand(webkitMaskShorthand(), important);
case CSSPropertyGridGap: {
DCHECK(RuntimeEnabledFeatures::CSSGridLayoutEnabled());
DCHECK_EQ(shorthandForProperty(CSSPropertyGridGap).length(), 2u);
CSSValue* row_gap = ConsumeLengthOrPercent(range_, context_->Mode(),
kValueRangeNonNegative);
CSSValue* column_gap = ConsumeLengthOrPercent(range_, context_->Mode(),
kValueRangeNonNegative);
if (!row_gap || !range_.AtEnd())
return false;
if (!column_gap)
column_gap = row_gap;
AddParsedProperty(CSSPropertyGridRowGap, CSSPropertyGridGap, *row_gap,
important);
AddParsedProperty(CSSPropertyGridColumnGap, CSSPropertyGridGap,
*column_gap, important);
return true;
}
case CSSPropertyGridTemplate:
return ConsumeGridTemplateShorthand(CSSPropertyGridTemplate, important);
case CSSPropertyGrid:
......
// 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/CSSShorthandPropertyAPIGridGap.h"
#include "core/StylePropertyShorthand.h"
#include "core/css/parser/CSSParserContext.h"
#include "core/css/parser/CSSPropertyParserHelpers.h"
#include "platform/RuntimeEnabledFeatures.h"
namespace blink {
bool CSSShorthandPropertyAPIGridGap::parseShorthand(
bool important,
CSSParserTokenRange& range,
const CSSParserContext& context,
bool use_legacy_parsing,
HeapVector<CSSProperty, 256>& properties) {
DCHECK(RuntimeEnabledFeatures::CSSGridLayoutEnabled());
DCHECK_EQ(shorthandForProperty(CSSPropertyGridGap).length(), 2u);
CSSValue* row_gap = CSSPropertyParserHelpers::ConsumeLengthOrPercent(
range, context.Mode(), kValueRangeNonNegative);
CSSValue* column_gap = CSSPropertyParserHelpers::ConsumeLengthOrPercent(
range, context.Mode(), kValueRangeNonNegative);
if (!row_gap || !range.AtEnd())
return false;
if (!column_gap)
column_gap = row_gap;
CSSPropertyParserHelpers::AddProperty(
CSSPropertyGridRowGap, CSSPropertyGridGap, *row_gap, important,
CSSPropertyParserHelpers::IsImplicitProperty::kNotImplicit, properties);
CSSPropertyParserHelpers::AddProperty(
CSSPropertyGridColumnGap, CSSPropertyGridGap, *column_gap, important,
CSSPropertyParserHelpers::IsImplicitProperty::kNotImplicit, properties);
return true;
}
} // namespace blink
// 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/CSSShorthandPropertyAPIMarker.h"
#include "core/css/parser/CSSPropertyParserHelpers.h"
namespace blink {
bool CSSShorthandPropertyAPIMarker::parseShorthand(
bool important,
CSSParserTokenRange& range,
const CSSParserContext& context,
bool use_legacy_parsing,
HeapVector<CSSProperty, 256>& properties) {
bool needs_legacy_parsing = false;
const CSSValue* marker = CSSPropertyParserHelpers::ParseLonghandViaAPI(
CSSPropertyMarkerStart, CSSPropertyMarker, context, range,
needs_legacy_parsing);
if (!marker || !range.AtEnd())
return false;
DCHECK(!needs_legacy_parsing);
CSSPropertyParserHelpers::AddProperty(
CSSPropertyMarkerStart, CSSPropertyMarker, *marker, important,
CSSPropertyParserHelpers::IsImplicitProperty::kNotImplicit, properties);
CSSPropertyParserHelpers::AddProperty(
CSSPropertyMarkerMid, CSSPropertyMarker, *marker, important,
CSSPropertyParserHelpers::IsImplicitProperty::kNotImplicit, properties);
CSSPropertyParserHelpers::AddProperty(
CSSPropertyMarkerEnd, CSSPropertyMarker, *marker, important,
CSSPropertyParserHelpers::IsImplicitProperty::kNotImplicit, properties);
return true;
}
} // 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