blob: aab8da20c0e140f5164923da33ea5416e13b1a1d [file] [log] [blame]
// 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 "third_party/blink/renderer/core/css/properties/shorthands/border_radius.h"
#include "third_party/blink/renderer/core/css/css_value_pair.h"
#include "third_party/blink/renderer/core/css/parser/css_parser_context.h"
#include "third_party/blink/renderer/core/css/parser/css_parser_local_context.h"
#include "third_party/blink/renderer/core/css/parser/css_property_parser_helpers.h"
#include "third_party/blink/renderer/core/css/properties/computed_style_utils.h"
#include "third_party/blink/renderer/core/css/properties/css_parsing_utils.h"
#include "third_party/blink/renderer/core/style/computed_style.h"
namespace blink {
namespace css_shorthand {
bool BorderRadius::ParseShorthand(
bool important,
CSSParserTokenRange& range,
const CSSParserContext& context,
const CSSParserLocalContext& local_context,
HeapVector<CSSPropertyValue, 256>& properties) const {
CSSValue* horizontal_radii[4] = {nullptr};
CSSValue* vertical_radii[4] = {nullptr};
if (!css_parsing_utils::ConsumeRadii(horizontal_radii, vertical_radii, range,
context.Mode(),
local_context.UseAliasParsing()))
return false;
css_property_parser_helpers::AddProperty(
CSSPropertyID::kBorderTopLeftRadius, CSSPropertyID::kBorderRadius,
*CSSValuePair::Create(horizontal_radii[0], vertical_radii[0],
CSSValuePair::kDropIdenticalValues),
important, css_property_parser_helpers::IsImplicitProperty::kNotImplicit,
properties);
css_property_parser_helpers::AddProperty(
CSSPropertyID::kBorderTopRightRadius, CSSPropertyID::kBorderRadius,
*CSSValuePair::Create(horizontal_radii[1], vertical_radii[1],
CSSValuePair::kDropIdenticalValues),
important, css_property_parser_helpers::IsImplicitProperty::kNotImplicit,
properties);
css_property_parser_helpers::AddProperty(
CSSPropertyID::kBorderBottomRightRadius, CSSPropertyID::kBorderRadius,
*CSSValuePair::Create(horizontal_radii[2], vertical_radii[2],
CSSValuePair::kDropIdenticalValues),
important, css_property_parser_helpers::IsImplicitProperty::kNotImplicit,
properties);
css_property_parser_helpers::AddProperty(
CSSPropertyID::kBorderBottomLeftRadius, CSSPropertyID::kBorderRadius,
*CSSValuePair::Create(horizontal_radii[3], vertical_radii[3],
CSSValuePair::kDropIdenticalValues),
important, css_property_parser_helpers::IsImplicitProperty::kNotImplicit,
properties);
return true;
}
const CSSValue* BorderRadius::CSSValueFromComputedStyleInternal(
const ComputedStyle& style,
const SVGComputedStyle&,
const LayoutObject*,
Node* styled_node,
bool allow_visited_style) const {
return ComputedStyleUtils::ValueForBorderRadiusShorthand(style);
}
} // namespace css_shorthand
} // namespace blink