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