Commit cbae617c authored by Fredrik Söderquist's avatar Fredrik Söderquist Committed by Commit Bot

Slimmer SVG enumeration tables

This replaces a Vector<std::pair<..., ...>> with a new SVGEnumerationMap
class that wraps a list of entries (also "pairs".) The setup of the map
is however not done runtime but rather compile time, saving a bunch of
code footprint in the process.

Change-Id: If2c77f1ebcf15dcf8fc75d6a25cacebf42401287
Reviewed-on: https://chromium-review.googlesource.com/c/1329974Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#607620}
parent 8f5d676f
......@@ -57,6 +57,7 @@
#include "third_party/blink/renderer/core/svg/radial_gradient_attributes.h"
#include "third_party/blink/renderer/core/svg/svg_circle_element.h"
#include "third_party/blink/renderer/core/svg/svg_ellipse_element.h"
#include "third_party/blink/renderer/core/svg/svg_enumeration_map.h"
#include "third_party/blink/renderer/core/svg/svg_filter_element.h"
#include "third_party/blink/renderer/core/svg/svg_line_element.h"
#include "third_party/blink/renderer/core/svg/svg_linear_gradient_element.h"
......@@ -172,40 +173,21 @@ static WTF::TextStream& operator<<(WTF::TextStream& ts, const WindRule rule) {
return ts;
}
namespace {
template <typename Enum>
String SVGEnumerationToString(Enum value) {
const SVGEnumerationStringEntries& entries = GetStaticStringEntries<Enum>();
SVGEnumerationStringEntries::const_iterator it = entries.begin();
SVGEnumerationStringEntries::const_iterator it_end = entries.end();
for (; it != it_end; ++it) {
if (value == it->first)
return it->second;
}
NOTREACHED();
return String();
}
} // namespace
static WTF::TextStream& operator<<(WTF::TextStream& ts,
const SVGUnitTypes::SVGUnitType& unit_type) {
ts << SVGEnumerationToString<SVGUnitTypes::SVGUnitType>(unit_type);
ts << GetEnumerationMap<SVGUnitTypes::SVGUnitType>().NameFromValue(unit_type);
return ts;
}
static WTF::TextStream& operator<<(WTF::TextStream& ts,
const SVGMarkerUnitsType& marker_unit) {
ts << SVGEnumerationToString<SVGMarkerUnitsType>(marker_unit);
ts << GetEnumerationMap<SVGMarkerUnitsType>().NameFromValue(marker_unit);
return ts;
}
static WTF::TextStream& operator<<(WTF::TextStream& ts,
const SVGMarkerOrientType& orient_type) {
ts << SVGEnumerationToString<SVGMarkerOrientType>(orient_type);
ts << GetEnumerationMap<SVGMarkerOrientType>().NameFromValue(orient_type);
return ts;
}
......@@ -243,7 +225,8 @@ static WTF::TextStream& operator<<(WTF::TextStream& ts, LineJoin style) {
static WTF::TextStream& operator<<(WTF::TextStream& ts,
const SVGSpreadMethodType& type) {
ts << SVGEnumerationToString<SVGSpreadMethodType>(type).UpperASCII();
auto* name = GetEnumerationMap<SVGSpreadMethodType>().NameFromValue(type);
ts << String(name).UpperASCII();
return ts;
}
......
......@@ -113,6 +113,8 @@ blink_core_sources("svg") {
"svg_ellipse_element.h",
"svg_enumeration.cc",
"svg_enumeration.h",
"svg_enumeration_map.cc",
"svg_enumeration_map.h",
"svg_fe_blend_element.cc",
"svg_fe_blend_element.h",
"svg_fe_color_matrix_element.cc",
......
......@@ -22,6 +22,7 @@
#include "third_party/blink/renderer/core/svg/svg_angle.h"
#include "third_party/blink/renderer/core/svg/svg_animation_element.h"
#include "third_party/blink/renderer/core/svg/svg_enumeration_map.h"
#include "third_party/blink/renderer/core/svg/svg_parser_utilities.h"
#include "third_party/blink/renderer/platform/wtf/math_extras.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
......@@ -29,23 +30,16 @@
namespace blink {
template <>
const SVGEnumerationStringEntries&
GetStaticStringEntries<SVGMarkerOrientType>() {
DEFINE_STATIC_LOCAL(SVGEnumerationStringEntries, entries, ());
if (entries.IsEmpty()) {
entries.push_back(std::make_pair(kSVGMarkerOrientAuto, "auto"));
entries.push_back(std::make_pair(kSVGMarkerOrientAngle, "angle"));
entries.push_back(
std::make_pair(kSVGMarkerOrientAutoStartReverse, "auto-start-reverse"));
}
const SVGEnumerationMap& GetEnumerationMap<SVGMarkerOrientType>() {
static const SVGEnumerationMap::Entry enum_items[] = {
{kSVGMarkerOrientAuto, "auto"},
{kSVGMarkerOrientAngle, "angle"},
{kSVGMarkerOrientAutoStartReverse, "auto-start-reverse"},
};
static const SVGEnumerationMap entries(enum_items, kSVGMarkerOrientAngle);
return entries;
}
template <>
unsigned short GetMaxExposedEnumValue<SVGMarkerOrientType>() {
return kSVGMarkerOrientAngle;
}
SVGMarkerOrientEnumeration::SVGMarkerOrientEnumeration(SVGAngle* angle)
: SVGEnumeration<SVGMarkerOrientType>(kSVGMarkerOrientAngle),
angle_(angle) {}
......
......@@ -38,11 +38,7 @@ enum SVGMarkerOrientType {
kSVGMarkerOrientAngle,
kSVGMarkerOrientAutoStartReverse
};
template <>
const SVGEnumerationStringEntries&
GetStaticStringEntries<SVGMarkerOrientType>();
template <>
unsigned short GetMaxExposedEnumValue<SVGMarkerOrientType>();
DECLARE_SVG_ENUM_MAP(SVGMarkerOrientType);
class SVGMarkerOrientEnumeration final
: public SVGEnumeration<SVGMarkerOrientType> {
......
......@@ -20,7 +20,7 @@
#include "third_party/blink/renderer/core/svg/svg_component_transfer_function_element.h"
#include "third_party/blink/renderer/core/dom/attribute.h"
#include "third_party/blink/renderer/core/svg/svg_enumeration_map.h"
#include "third_party/blink/renderer/core/svg/svg_fe_component_transfer_element.h"
#include "third_party/blink/renderer/core/svg/svg_number_list.h"
#include "third_party/blink/renderer/core/svg_names.h"
......@@ -28,19 +28,15 @@
namespace blink {
template <>
const SVGEnumerationStringEntries&
GetStaticStringEntries<ComponentTransferType>() {
DEFINE_STATIC_LOCAL(SVGEnumerationStringEntries, entries, ());
if (entries.IsEmpty()) {
entries.push_back(
std::make_pair(FECOMPONENTTRANSFER_TYPE_IDENTITY, "identity"));
entries.push_back(std::make_pair(FECOMPONENTTRANSFER_TYPE_TABLE, "table"));
entries.push_back(
std::make_pair(FECOMPONENTTRANSFER_TYPE_DISCRETE, "discrete"));
entries.push_back(
std::make_pair(FECOMPONENTTRANSFER_TYPE_LINEAR, "linear"));
entries.push_back(std::make_pair(FECOMPONENTTRANSFER_TYPE_GAMMA, "gamma"));
}
const SVGEnumerationMap& GetEnumerationMap<ComponentTransferType>() {
static const SVGEnumerationMap::Entry enum_items[] = {
{FECOMPONENTTRANSFER_TYPE_IDENTITY, "identity"},
{FECOMPONENTTRANSFER_TYPE_TABLE, "table"},
{FECOMPONENTTRANSFER_TYPE_DISCRETE, "discrete"},
{FECOMPONENTTRANSFER_TYPE_LINEAR, "linear"},
{FECOMPONENTTRANSFER_TYPE_GAMMA, "gamma"},
};
static const SVGEnumerationMap entries(enum_items);
return entries;
}
......
......@@ -30,9 +30,7 @@
namespace blink {
template <>
const SVGEnumerationStringEntries&
GetStaticStringEntries<ComponentTransferType>();
DECLARE_SVG_ENUM_MAP(ComponentTransferType);
class SVGComponentTransferFunctionElement : public SVGElement {
DEFINE_WRAPPERTYPEINFO();
......
......@@ -31,6 +31,7 @@
#include "third_party/blink/renderer/core/svg/svg_enumeration.h"
#include "third_party/blink/renderer/core/svg/svg_animation_element.h"
#include "third_party/blink/renderer/core/svg/svg_enumeration_map.h"
namespace blink {
......@@ -46,10 +47,8 @@ SVGPropertyBase* SVGEnumerationBase::CloneForAnimation(
}
String SVGEnumerationBase::ValueAsString() const {
for (const auto& entry : entries_) {
if (value_ == entry.first)
return entry.second;
}
if (const char* enum_name = map_.NameFromValue(value_))
return String(enum_name);
DCHECK_LT(value_, MaxInternalEnumValue());
return g_empty_string;
......@@ -61,17 +60,12 @@ void SVGEnumerationBase::SetValue(unsigned short value) {
}
SVGParsingError SVGEnumerationBase::SetValueAsString(const String& string) {
for (const auto& entry : entries_) {
if (string == entry.second) {
// 0 corresponds to _UNKNOWN enumeration values, and should not be
// settable.
DCHECK(entry.first);
value_ = entry.first;
NotifyChange();
return SVGParseStatus::kNoError;
}
unsigned short value = map_.ValueFromName(string);
if (value) {
value_ = value;
NotifyChange();
return SVGParseStatus::kNoError;
}
NotifyChange();
return SVGParseStatus::kExpectedEnumeration;
}
......@@ -104,4 +98,12 @@ float SVGEnumerationBase::CalculateDistance(SVGPropertyBase*, SVGElement*) {
return -1;
}
unsigned short SVGEnumerationBase::MaxExposedEnumValue() const {
return map_.MaxExposedValue();
}
unsigned short SVGEnumerationBase::MaxInternalEnumValue() const {
return map_.ValueOfLast();
}
} // namespace blink
......@@ -36,11 +36,10 @@
namespace blink {
class SVGEnumerationMap;
class SVGEnumerationBase : public SVGPropertyBase {
public:
typedef std::pair<unsigned short, String> StringEntry;
typedef Vector<StringEntry> StringEntries;
// SVGEnumeration does not have a tear-off type.
typedef void TearOffType;
typedef unsigned short PrimitiveType;
......@@ -72,13 +71,9 @@ class SVGEnumerationBase : public SVGPropertyBase {
static AnimatedPropertyType ClassType() { return kAnimatedEnumeration; }
AnimatedPropertyType GetType() const override { return ClassType(); }
static unsigned short ValueOfLastEnum(const StringEntries& entries) {
return entries.back().first;
}
// This is the maximum value that is exposed as an IDL constant on the
// relevant interface.
unsigned short MaxExposedEnumValue() const { return max_exposed_; }
unsigned short MaxExposedEnumValue() const;
void SetInitial(unsigned value) {
SetValue(static_cast<unsigned short>(value));
......@@ -86,32 +81,26 @@ class SVGEnumerationBase : public SVGPropertyBase {
static constexpr int kInitialValueBits = 3;
protected:
SVGEnumerationBase(unsigned short value,
const StringEntries& entries,
unsigned short max_exposed)
: value_(value), max_exposed_(max_exposed), entries_(entries) {}
SVGEnumerationBase(unsigned short value, const SVGEnumerationMap& map)
: value_(value), map_(map) {}
// This is the maximum value of all the internal enumeration values.
// This assumes that |m_entries| are sorted.
unsigned short MaxInternalEnumValue() const {
return ValueOfLastEnum(entries_);
}
// This assumes that the map is sorted on the enumeration value.
unsigned short MaxInternalEnumValue() const;
// Used by SVGMarkerOrientEnumeration.
virtual void NotifyChange() {}
unsigned short value_;
const unsigned short max_exposed_;
const StringEntries& entries_;
const SVGEnumerationMap& map_;
};
typedef SVGEnumerationBase::StringEntries SVGEnumerationStringEntries;
template <typename Enum>
const SVGEnumerationStringEntries& GetStaticStringEntries();
template <typename Enum>
unsigned short GetMaxExposedEnumValue() {
return SVGEnumerationBase::ValueOfLastEnum(GetStaticStringEntries<Enum>());
}
const SVGEnumerationMap& GetEnumerationMap();
#define DECLARE_SVG_ENUM_MAP(cpp_enum_type) \
template <> \
const SVGEnumerationMap& GetEnumerationMap<cpp_enum_type>()
template <typename Enum>
class SVGEnumeration : public SVGEnumerationBase {
......@@ -136,9 +125,7 @@ class SVGEnumeration : public SVGEnumerationBase {
protected:
explicit SVGEnumeration(Enum new_value)
: SVGEnumerationBase(new_value,
GetStaticStringEntries<Enum>(),
GetMaxExposedEnumValue<Enum>()) {}
: SVGEnumerationBase(new_value, GetEnumerationMap<Enum>()) {}
};
} // namespace blink
......
// Copyright 2018 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/svg/svg_enumeration_map.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace blink {
unsigned short SVGEnumerationMap::ValueFromName(const String& name) const {
for (const Entry& entry : *this) {
if (name == entry.name)
return entry.value;
}
return 0;
}
} // namespace blink
// Copyright 2018 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.
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_SVG_SVG_ENUMERATION_MAP_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_SVG_SVG_ENUMERATION_MAP_H_
#include "third_party/blink/renderer/platform/wtf/assertions.h"
#include "third_party/blink/renderer/platform/wtf/forward.h"
namespace blink {
// Helper class for SVG enumerations. Maps between name (string) and value.
//
// It is assumed that enumeration values are contiguous, non-zero and
// starting at 1.
//
// For enumerations that have had new values added since SVG 1.1, the
// |max_exposed_value| should be set to the last old value. From this also
// follow that the new values should sort last - after the |max_exposed_value|.
// (This is currently always the case in the spec too.)
class SVGEnumerationMap {
public:
struct Entry {
const unsigned short value;
const char* const name;
};
template <unsigned entries_length>
constexpr SVGEnumerationMap(const Entry (&entries)[entries_length])
: SVGEnumerationMap(entries, entries[entries_length - 1].value) {}
template <unsigned entries_length>
constexpr SVGEnumerationMap(const Entry (&entries)[entries_length],
unsigned short max_exposed_value)
: entries_(entries),
num_entries_(entries_length),
max_exposed_value_(max_exposed_value) {}
const char* NameFromValue(unsigned short value) const {
DCHECK(value); // We should never store 0 (*_UNKNOWN) in the map.
DCHECK_LT(value - 1, num_entries_);
DCHECK_EQ(entries_[value - 1].value, value);
return entries_[value - 1].name;
}
unsigned short ValueFromName(const String&) const;
unsigned short ValueOfLast() const {
return entries_[num_entries_ - 1].value;
}
unsigned short MaxExposedValue() const { return max_exposed_value_; }
private:
const Entry* begin() const { return entries_; }
const Entry* end() const { return entries_ + num_entries_; }
const Entry* const entries_;
const unsigned short num_entries_;
const unsigned short max_exposed_value_;
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_SVG_SVG_ENUMERATION_MAP_H_
......@@ -21,6 +21,7 @@
#include "third_party/blink/renderer/core/svg/svg_fe_blend_element.h"
#include "third_party/blink/renderer/core/svg/graphics/filters/svg_filter_builder.h"
#include "third_party/blink/renderer/core/svg/svg_enumeration_map.h"
#include "third_party/blink/renderer/core/svg_names.h"
#include "third_party/blink/renderer/platform/graphics/filters/fe_blend.h"
......@@ -56,46 +57,30 @@ static BlendMode ToBlendMode(SVGFEBlendElement::Mode mode) {
}
template <>
const SVGEnumerationStringEntries&
GetStaticStringEntries<SVGFEBlendElement::Mode>() {
DEFINE_STATIC_LOCAL(SVGEnumerationStringEntries, entries, ());
if (entries.IsEmpty()) {
entries.push_back(std::make_pair(SVGFEBlendElement::kModeNormal, "normal"));
entries.push_back(
std::make_pair(SVGFEBlendElement::kModeMultiply, "multiply"));
entries.push_back(std::make_pair(SVGFEBlendElement::kModeScreen, "screen"));
entries.push_back(std::make_pair(SVGFEBlendElement::kModeDarken, "darken"));
entries.push_back(
std::make_pair(SVGFEBlendElement::kModeLighten, "lighten"));
entries.push_back(
std::make_pair(SVGFEBlendElement::kModeOverlay, "overlay"));
entries.push_back(
std::make_pair(SVGFEBlendElement::kModeColorDodge, "color-dodge"));
entries.push_back(
std::make_pair(SVGFEBlendElement::kModeColorBurn, "color-burn"));
entries.push_back(
std::make_pair(SVGFEBlendElement::kModeHardLight, "hard-light"));
entries.push_back(
std::make_pair(SVGFEBlendElement::kModeSoftLight, "soft-light"));
entries.push_back(
std::make_pair(SVGFEBlendElement::kModeDifference, "difference"));
entries.push_back(
std::make_pair(SVGFEBlendElement::kModeExclusion, "exclusion"));
entries.push_back(std::make_pair(SVGFEBlendElement::kModeHue, "hue"));
entries.push_back(
std::make_pair(SVGFEBlendElement::kModeSaturation, "saturation"));
entries.push_back(std::make_pair(SVGFEBlendElement::kModeColor, "color"));
entries.push_back(
std::make_pair(SVGFEBlendElement::kModeLuminosity, "luminosity"));
}
const SVGEnumerationMap& GetEnumerationMap<SVGFEBlendElement::Mode>() {
static const SVGEnumerationMap::Entry enum_items[] = {
{SVGFEBlendElement::kModeNormal, "normal"},
{SVGFEBlendElement::kModeMultiply, "multiply"},
{SVGFEBlendElement::kModeScreen, "screen"},
{SVGFEBlendElement::kModeDarken, "darken"},
{SVGFEBlendElement::kModeLighten, "lighten"},
{SVGFEBlendElement::kModeOverlay, "overlay"},
{SVGFEBlendElement::kModeColorDodge, "color-dodge"},
{SVGFEBlendElement::kModeColorBurn, "color-burn"},
{SVGFEBlendElement::kModeHardLight, "hard-light"},
{SVGFEBlendElement::kModeSoftLight, "soft-light"},
{SVGFEBlendElement::kModeDifference, "difference"},
{SVGFEBlendElement::kModeExclusion, "exclusion"},
{SVGFEBlendElement::kModeHue, "hue"},
{SVGFEBlendElement::kModeSaturation, "saturation"},
{SVGFEBlendElement::kModeColor, "color"},
{SVGFEBlendElement::kModeLuminosity, "luminosity"},
};
static const SVGEnumerationMap entries(enum_items,
SVGFEBlendElement::kModeLighten);
return entries;
}
template <>
unsigned short GetMaxExposedEnumValue<SVGFEBlendElement::Mode>() {
return SVGFEBlendElement::kModeLighten;
}
inline SVGFEBlendElement::SVGFEBlendElement(Document& document)
: SVGFilterPrimitiveStandardAttributes(svg_names::kFEBlendTag, document),
in1_(SVGAnimatedString::Create(this, svg_names::kInAttr)),
......
......@@ -74,11 +74,7 @@ class SVGFEBlendElement final : public SVGFilterPrimitiveStandardAttributes {
Member<SVGAnimatedEnumeration<Mode>> mode_;
};
template <>
const SVGEnumerationStringEntries&
GetStaticStringEntries<SVGFEBlendElement::Mode>();
template <>
unsigned short GetMaxExposedEnumValue<SVGFEBlendElement::Mode>();
DECLARE_SVG_ENUM_MAP(SVGFEBlendElement::Mode);
} // namespace blink
......
......@@ -21,21 +21,20 @@
#include "third_party/blink/renderer/core/svg/svg_fe_color_matrix_element.h"
#include "third_party/blink/renderer/core/svg/graphics/filters/svg_filter_builder.h"
#include "third_party/blink/renderer/core/svg/svg_enumeration_map.h"
#include "third_party/blink/renderer/core/svg_names.h"
namespace blink {
template <>
const SVGEnumerationStringEntries& GetStaticStringEntries<ColorMatrixType>() {
DEFINE_STATIC_LOCAL(SVGEnumerationStringEntries, entries, ());
if (entries.IsEmpty()) {
entries.push_back(std::make_pair(FECOLORMATRIX_TYPE_MATRIX, "matrix"));
entries.push_back(std::make_pair(FECOLORMATRIX_TYPE_SATURATE, "saturate"));
entries.push_back(
std::make_pair(FECOLORMATRIX_TYPE_HUEROTATE, "hueRotate"));
entries.push_back(std::make_pair(FECOLORMATRIX_TYPE_LUMINANCETOALPHA,
"luminanceToAlpha"));
}
const SVGEnumerationMap& GetEnumerationMap<ColorMatrixType>() {
static const SVGEnumerationMap::Entry enum_items[] = {
{FECOLORMATRIX_TYPE_MATRIX, "matrix"},
{FECOLORMATRIX_TYPE_SATURATE, "saturate"},
{FECOLORMATRIX_TYPE_HUEROTATE, "hueRotate"},
{FECOLORMATRIX_TYPE_LUMINANCETOALPHA, "luminanceToAlpha"},
};
static const SVGEnumerationMap entries(enum_items);
return entries;
}
......
......@@ -29,8 +29,7 @@
namespace blink {
template <>
const SVGEnumerationStringEntries& GetStaticStringEntries<ColorMatrixType>();
DECLARE_SVG_ENUM_MAP(ColorMatrixType);
class SVGFEColorMatrixElement final
: public SVGFilterPrimitiveStandardAttributes {
......
......@@ -21,32 +21,27 @@
#include "third_party/blink/renderer/core/svg/svg_fe_composite_element.h"
#include "third_party/blink/renderer/core/svg/graphics/filters/svg_filter_builder.h"
#include "third_party/blink/renderer/core/svg/svg_enumeration_map.h"
#include "third_party/blink/renderer/core/svg_names.h"
namespace blink {
template <>
const SVGEnumerationStringEntries&
GetStaticStringEntries<CompositeOperationType>() {
DEFINE_STATIC_LOCAL(SVGEnumerationStringEntries, entries, ());
if (entries.IsEmpty()) {
entries.push_back(std::make_pair(FECOMPOSITE_OPERATOR_OVER, "over"));
entries.push_back(std::make_pair(FECOMPOSITE_OPERATOR_IN, "in"));
entries.push_back(std::make_pair(FECOMPOSITE_OPERATOR_OUT, "out"));
entries.push_back(std::make_pair(FECOMPOSITE_OPERATOR_ATOP, "atop"));
entries.push_back(std::make_pair(FECOMPOSITE_OPERATOR_XOR, "xor"));
entries.push_back(
std::make_pair(FECOMPOSITE_OPERATOR_ARITHMETIC, "arithmetic"));
entries.push_back(std::make_pair(FECOMPOSITE_OPERATOR_LIGHTER, "lighter"));
}
const SVGEnumerationMap& GetEnumerationMap<CompositeOperationType>() {
static const SVGEnumerationMap::Entry enum_items[] = {
{FECOMPOSITE_OPERATOR_OVER, "over"},
{FECOMPOSITE_OPERATOR_IN, "in"},
{FECOMPOSITE_OPERATOR_OUT, "out"},
{FECOMPOSITE_OPERATOR_ATOP, "atop"},
{FECOMPOSITE_OPERATOR_XOR, "xor"},
{FECOMPOSITE_OPERATOR_ARITHMETIC, "arithmetic"},
{FECOMPOSITE_OPERATOR_LIGHTER, "lighter"},
};
static const SVGEnumerationMap entries(enum_items,
FECOMPOSITE_OPERATOR_ARITHMETIC);
return entries;
}
template <>
unsigned short GetMaxExposedEnumValue<CompositeOperationType>() {
return FECOMPOSITE_OPERATOR_ARITHMETIC;
}
inline SVGFECompositeElement::SVGFECompositeElement(Document& document)
: SVGFilterPrimitiveStandardAttributes(svg_names::kFECompositeTag,
document),
......
......@@ -29,9 +29,7 @@
namespace blink {
template <>
const SVGEnumerationStringEntries&
GetStaticStringEntries<CompositeOperationType>();
DECLARE_SVG_ENUM_MAP(CompositeOperationType);
class SVGFECompositeElement final
: public SVGFilterPrimitiveStandardAttributes {
......
......@@ -21,6 +21,7 @@
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/svg/graphics/filters/svg_filter_builder.h"
#include "third_party/blink/renderer/core/svg/svg_enumeration_map.h"
#include "third_party/blink/renderer/core/svg_names.h"
#include "third_party/blink/renderer/platform/geometry/int_point.h"
#include "third_party/blink/renderer/platform/geometry/int_size.h"
......@@ -28,13 +29,13 @@
namespace blink {
template <>
const SVGEnumerationStringEntries& GetStaticStringEntries<EdgeModeType>() {
DEFINE_STATIC_LOCAL(SVGEnumerationStringEntries, entries, ());
if (entries.IsEmpty()) {
entries.push_back(std::make_pair(EDGEMODE_DUPLICATE, "duplicate"));
entries.push_back(std::make_pair(EDGEMODE_WRAP, "wrap"));
entries.push_back(std::make_pair(EDGEMODE_NONE, "none"));
}
const SVGEnumerationMap& GetEnumerationMap<EdgeModeType>() {
static const SVGEnumerationMap::Entry enum_items[] = {
{EDGEMODE_DUPLICATE, "duplicate"},
{EDGEMODE_WRAP, "wrap"},
{EDGEMODE_NONE, "none"},
};
static const SVGEnumerationMap entries(enum_items);
return entries;
}
......
......@@ -33,8 +33,7 @@
namespace blink {
template <>
const SVGEnumerationStringEntries& GetStaticStringEntries<EdgeModeType>();
DECLARE_SVG_ENUM_MAP(EdgeModeType);
class SVGFEConvolveMatrixElement final
: public SVGFilterPrimitiveStandardAttributes {
......
......@@ -20,20 +20,17 @@
#include "third_party/blink/renderer/core/svg/svg_fe_displacement_map_element.h"
#include "third_party/blink/renderer/core/svg/graphics/filters/svg_filter_builder.h"
#include "third_party/blink/renderer/core/svg/svg_enumeration_map.h"
#include "third_party/blink/renderer/core/svg_names.h"
namespace blink {
template <>
const SVGEnumerationStringEntries&
GetStaticStringEntries<ChannelSelectorType>() {
DEFINE_STATIC_LOCAL(SVGEnumerationStringEntries, entries, ());
if (entries.IsEmpty()) {
entries.push_back(std::make_pair(CHANNEL_R, "R"));
entries.push_back(std::make_pair(CHANNEL_G, "G"));
entries.push_back(std::make_pair(CHANNEL_B, "B"));
entries.push_back(std::make_pair(CHANNEL_A, "A"));
}
const SVGEnumerationMap& GetEnumerationMap<ChannelSelectorType>() {
static const SVGEnumerationMap::Entry enum_items[] = {
{CHANNEL_R, "R"}, {CHANNEL_G, "G"}, {CHANNEL_B, "B"}, {CHANNEL_A, "A"},
};
static const SVGEnumerationMap entries(enum_items);
return entries;
}
......
......@@ -28,9 +28,7 @@
namespace blink {
template <>
const SVGEnumerationStringEntries&
GetStaticStringEntries<ChannelSelectorType>();
DECLARE_SVG_ENUM_MAP(ChannelSelectorType);
class SVGFEDisplacementMapElement final
: public SVGFilterPrimitiveStandardAttributes {
......
......@@ -20,18 +20,18 @@
#include "third_party/blink/renderer/core/svg/svg_fe_morphology_element.h"
#include "third_party/blink/renderer/core/svg/graphics/filters/svg_filter_builder.h"
#include "third_party/blink/renderer/core/svg/svg_enumeration_map.h"
#include "third_party/blink/renderer/core/svg_names.h"
namespace blink {
template <>
const SVGEnumerationStringEntries&
GetStaticStringEntries<MorphologyOperatorType>() {
DEFINE_STATIC_LOCAL(SVGEnumerationStringEntries, entries, ());
if (entries.IsEmpty()) {
entries.push_back(std::make_pair(FEMORPHOLOGY_OPERATOR_ERODE, "erode"));
entries.push_back(std::make_pair(FEMORPHOLOGY_OPERATOR_DILATE, "dilate"));
}
const SVGEnumerationMap& GetEnumerationMap<MorphologyOperatorType>() {
static const SVGEnumerationMap::Entry enum_items[] = {
{FEMORPHOLOGY_OPERATOR_ERODE, "erode"},
{FEMORPHOLOGY_OPERATOR_DILATE, "dilate"},
};
static const SVGEnumerationMap entries(enum_items);
return entries;
}
......
......@@ -28,9 +28,7 @@
namespace blink {
template <>
const SVGEnumerationStringEntries&
GetStaticStringEntries<MorphologyOperatorType>();
DECLARE_SVG_ENUM_MAP(MorphologyOperatorType);
class SVGFEMorphologyElement final
: public SVGFilterPrimitiveStandardAttributes {
......
......@@ -20,29 +20,27 @@
#include "third_party/blink/renderer/core/svg/svg_fe_turbulence_element.h"
#include "third_party/blink/renderer/core/svg/svg_enumeration_map.h"
#include "third_party/blink/renderer/core/svg_names.h"
namespace blink {
template <>
const SVGEnumerationStringEntries& GetStaticStringEntries<SVGStitchOptions>() {
DEFINE_STATIC_LOCAL(SVGEnumerationStringEntries, entries, ());
if (entries.IsEmpty()) {
entries.push_back(std::make_pair(kSvgStitchtypeStitch, "stitch"));
entries.push_back(std::make_pair(kSvgStitchtypeNostitch, "noStitch"));
}
const SVGEnumerationMap& GetEnumerationMap<SVGStitchOptions>() {
static const SVGEnumerationMap::Entry enum_items[] = {
{kSvgStitchtypeStitch, "stitch"}, {kSvgStitchtypeNostitch, "noStitch"},
};
static const SVGEnumerationMap entries(enum_items);
return entries;
}
template <>
const SVGEnumerationStringEntries& GetStaticStringEntries<TurbulenceType>() {
DEFINE_STATIC_LOCAL(SVGEnumerationStringEntries, entries, ());
if (entries.IsEmpty()) {
entries.push_back(
std::make_pair(FETURBULENCE_TYPE_FRACTALNOISE, "fractalNoise"));
entries.push_back(
std::make_pair(FETURBULENCE_TYPE_TURBULENCE, "turbulence"));
}
const SVGEnumerationMap& GetEnumerationMap<TurbulenceType>() {
static const SVGEnumerationMap::Entry enum_items[] = {
{FETURBULENCE_TYPE_FRACTALNOISE, "fractalNoise"},
{FETURBULENCE_TYPE_TURBULENCE, "turbulence"},
};
static const SVGEnumerationMap entries(enum_items);
return entries;
}
......
......@@ -36,11 +36,9 @@ enum SVGStitchOptions {
kSvgStitchtypeStitch = 1,
kSvgStitchtypeNostitch = 2
};
template <>
const SVGEnumerationStringEntries& GetStaticStringEntries<SVGStitchOptions>();
DECLARE_SVG_ENUM_MAP(SVGStitchOptions);
template <>
const SVGEnumerationStringEntries& GetStaticStringEntries<TurbulenceType>();
DECLARE_SVG_ENUM_MAP(TurbulenceType);
class SVGFETurbulenceElement final
: public SVGFilterPrimitiveStandardAttributes {
......
......@@ -22,25 +22,24 @@
#include "third_party/blink/renderer/core/svg/svg_gradient_element.h"
#include "third_party/blink/renderer/core/css/style_change_reason.h"
#include "third_party/blink/renderer/core/dom/attribute.h"
#include "third_party/blink/renderer/core/dom/element_traversal.h"
#include "third_party/blink/renderer/core/dom/id_target_observer.h"
#include "third_party/blink/renderer/core/layout/svg/layout_svg_resource_container.h"
#include "third_party/blink/renderer/core/svg/gradient_attributes.h"
#include "third_party/blink/renderer/core/svg/svg_enumeration_map.h"
#include "third_party/blink/renderer/core/svg/svg_stop_element.h"
#include "third_party/blink/renderer/core/svg/svg_transform_list.h"
namespace blink {
template <>
const SVGEnumerationStringEntries&
GetStaticStringEntries<SVGSpreadMethodType>() {
DEFINE_STATIC_LOCAL(SVGEnumerationStringEntries, entries, ());
if (entries.IsEmpty()) {
entries.push_back(std::make_pair(kSVGSpreadMethodPad, "pad"));
entries.push_back(std::make_pair(kSVGSpreadMethodReflect, "reflect"));
entries.push_back(std::make_pair(kSVGSpreadMethodRepeat, "repeat"));
}
const SVGEnumerationMap& GetEnumerationMap<SVGSpreadMethodType>() {
static const SVGEnumerationMap::Entry enum_items[] = {
{kSVGSpreadMethodPad, "pad"},
{kSVGSpreadMethodReflect, "reflect"},
{kSVGSpreadMethodRepeat, "repeat"},
};
static const SVGEnumerationMap entries(enum_items);
return entries;
}
......
......@@ -41,9 +41,7 @@ enum SVGSpreadMethodType {
kSVGSpreadMethodReflect,
kSVGSpreadMethodRepeat
};
template <>
const SVGEnumerationStringEntries&
GetStaticStringEntries<SVGSpreadMethodType>();
DECLARE_SVG_ENUM_MAP(SVGSpreadMethodType);
class SVGGradientElement : public SVGElement, public SVGURIReference {
DEFINE_WRAPPERTYPEINFO();
......
......@@ -24,20 +24,18 @@
#include "third_party/blink/renderer/core/layout/svg/layout_svg_resource_marker.h"
#include "third_party/blink/renderer/core/svg/svg_angle_tear_off.h"
#include "third_party/blink/renderer/core/svg/svg_enumeration_map.h"
#include "third_party/blink/renderer/core/svg_names.h"
namespace blink {
template <>
const SVGEnumerationStringEntries&
GetStaticStringEntries<SVGMarkerUnitsType>() {
DEFINE_STATIC_LOCAL(SVGEnumerationStringEntries, entries, ());
if (entries.IsEmpty()) {
entries.push_back(
std::make_pair(kSVGMarkerUnitsUserSpaceOnUse, "userSpaceOnUse"));
entries.push_back(
std::make_pair(kSVGMarkerUnitsStrokeWidth, "strokeWidth"));
}
const SVGEnumerationMap& GetEnumerationMap<SVGMarkerUnitsType>() {
static const SVGEnumerationMap::Entry enum_items[] = {
{kSVGMarkerUnitsUserSpaceOnUse, "userSpaceOnUse"},
{kSVGMarkerUnitsStrokeWidth, "strokeWidth"},
};
static const SVGEnumerationMap entries(enum_items);
return entries;
}
......
......@@ -36,8 +36,7 @@ enum SVGMarkerUnitsType {
kSVGMarkerUnitsUserSpaceOnUse,
kSVGMarkerUnitsStrokeWidth
};
template <>
const SVGEnumerationStringEntries& GetStaticStringEntries<SVGMarkerUnitsType>();
DECLARE_SVG_ENUM_MAP(SVGMarkerUnitsType);
class SVGMarkerElement final : public SVGElement, public SVGFitToViewBox {
DEFINE_WRAPPERTYPEINFO();
......
......@@ -27,6 +27,7 @@
#include "third_party/blink/renderer/core/frame/use_counter.h"
#include "third_party/blink/renderer/core/layout/api/line_layout_item.h"
#include "third_party/blink/renderer/core/layout/svg/svg_text_query.h"
#include "third_party/blink/renderer/core/svg/svg_enumeration_map.h"
#include "third_party/blink/renderer/core/svg/svg_point_tear_off.h"
#include "third_party/blink/renderer/core/svg/svg_rect_tear_off.h"
#include "third_party/blink/renderer/core/svg_names.h"
......@@ -37,14 +38,12 @@
namespace blink {
template <>
const SVGEnumerationStringEntries&
GetStaticStringEntries<SVGLengthAdjustType>() {
DEFINE_STATIC_LOCAL(SVGEnumerationStringEntries, entries, ());
if (entries.IsEmpty()) {
entries.push_back(std::make_pair(kSVGLengthAdjustSpacing, "spacing"));
entries.push_back(
std::make_pair(kSVGLengthAdjustSpacingAndGlyphs, "spacingAndGlyphs"));
}
const SVGEnumerationMap& GetEnumerationMap<SVGLengthAdjustType>() {
static const SVGEnumerationMap::Entry enum_items[] = {
{kSVGLengthAdjustSpacing, "spacing"},
{kSVGLengthAdjustSpacingAndGlyphs, "spacingAndGlyphs"},
};
static const SVGEnumerationMap entries(enum_items);
return entries;
}
......
......@@ -37,9 +37,7 @@ enum SVGLengthAdjustType {
kSVGLengthAdjustSpacing,
kSVGLengthAdjustSpacingAndGlyphs
};
template <>
const SVGEnumerationStringEntries&
GetStaticStringEntries<SVGLengthAdjustType>();
DECLARE_SVG_ENUM_MAP(SVGLengthAdjustType);
class CORE_EXPORT SVGTextContentElement : public SVGGraphicsElement {
DEFINE_WRAPPERTYPEINFO();
......
......@@ -22,28 +22,26 @@
#include "third_party/blink/renderer/core/dom/id_target_observer.h"
#include "third_party/blink/renderer/core/layout/svg/layout_svg_text_path.h"
#include "third_party/blink/renderer/core/svg/svg_enumeration_map.h"
namespace blink {
template <>
const SVGEnumerationStringEntries&
GetStaticStringEntries<SVGTextPathMethodType>() {
DEFINE_STATIC_LOCAL(SVGEnumerationStringEntries, entries, ());
if (entries.IsEmpty()) {
entries.push_back(std::make_pair(kSVGTextPathMethodAlign, "align"));
entries.push_back(std::make_pair(kSVGTextPathMethodStretch, "stretch"));
}
const SVGEnumerationMap& GetEnumerationMap<SVGTextPathMethodType>() {
static const SVGEnumerationMap::Entry enum_items[] = {
{kSVGTextPathMethodAlign, "align"},
{kSVGTextPathMethodStretch, "stretch"},
};
static const SVGEnumerationMap entries(enum_items);
return entries;
}
template <>
const SVGEnumerationStringEntries&
GetStaticStringEntries<SVGTextPathSpacingType>() {
DEFINE_STATIC_LOCAL(SVGEnumerationStringEntries, entries, ());
if (entries.IsEmpty()) {
entries.push_back(std::make_pair(kSVGTextPathSpacingAuto, "auto"));
entries.push_back(std::make_pair(kSVGTextPathSpacingExact, "exact"));
}
const SVGEnumerationMap& GetEnumerationMap<SVGTextPathSpacingType>() {
static const SVGEnumerationMap::Entry enum_items[] = {
{kSVGTextPathSpacingAuto, "auto"}, {kSVGTextPathSpacingExact, "exact"},
};
static const SVGEnumerationMap entries(enum_items);
return entries;
}
......
......@@ -31,19 +31,14 @@ enum SVGTextPathMethodType {
kSVGTextPathMethodAlign,
kSVGTextPathMethodStretch
};
DECLARE_SVG_ENUM_MAP(SVGTextPathMethodType);
enum SVGTextPathSpacingType {
kSVGTextPathSpacingUnknown = 0,
kSVGTextPathSpacingAuto,
kSVGTextPathSpacingExact
};
template <>
const SVGEnumerationStringEntries&
GetStaticStringEntries<SVGTextPathMethodType>();
template <>
const SVGEnumerationStringEntries&
GetStaticStringEntries<SVGTextPathSpacingType>();
DECLARE_SVG_ENUM_MAP(SVGTextPathSpacingType);
class SVGTextPathElement final : public SVGTextContentElement,
public SVGURIReference {
......
......@@ -30,18 +30,17 @@
#include "third_party/blink/renderer/core/svg/svg_unit_types.h"
#include "third_party/blink/renderer/core/svg/svg_enumeration_map.h"
namespace blink {
template <>
const SVGEnumerationStringEntries&
GetStaticStringEntries<SVGUnitTypes::SVGUnitType>() {
DEFINE_STATIC_LOCAL(SVGEnumerationStringEntries, entries, ());
if (entries.IsEmpty()) {
entries.push_back(std::make_pair(SVGUnitTypes::kSvgUnitTypeUserspaceonuse,
"userSpaceOnUse"));
entries.push_back(std::make_pair(
SVGUnitTypes::kSvgUnitTypeObjectboundingbox, "objectBoundingBox"));
}
const SVGEnumerationMap& GetEnumerationMap<SVGUnitTypes::SVGUnitType>() {
static const SVGEnumerationMap::Entry enum_items[] = {
{SVGUnitTypes::kSvgUnitTypeUserspaceonuse, "userSpaceOnUse"},
{SVGUnitTypes::kSvgUnitTypeObjectboundingbox, "objectBoundingBox"},
};
static const SVGEnumerationMap entries(enum_items);
return entries;
}
......
......@@ -40,9 +40,7 @@ class SVGUnitTypes final : public ScriptWrappable {
SVGUnitTypes() = delete; // No instantiation.
};
template <>
const SVGEnumerationStringEntries&
GetStaticStringEntries<SVGUnitTypes::SVGUnitType>();
DECLARE_SVG_ENUM_MAP(SVGUnitTypes::SVGUnitType);
} // 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