Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1681)

Unified Diff: Source/core/svg/SVGEnumeration.h

Issue 447193002: Add support for additional blend modes to SVGFEBlendElement (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/svg/filters/feBlend-all-modes.html ('k') | Source/core/svg/SVGEnumeration.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/svg/SVGEnumeration.h
diff --git a/Source/core/svg/SVGEnumeration.h b/Source/core/svg/SVGEnumeration.h
index 44cacbc5212413fff8d5741bfe1209d139782bb3..f2f9461cfb062f45d28b889aca6a56069eaeefa8 100644
--- a/Source/core/svg/SVGEnumeration.h
+++ b/Source/core/svg/SVGEnumeration.h
@@ -46,12 +46,9 @@ public:
virtual ~SVGEnumerationBase();
- unsigned short value() const { return m_value; }
+ unsigned short value() const { return m_value <= maxExposedEnumValue() ? m_value : 0; }
void setValue(unsigned short, ExceptionState&);
- // This assumes that |m_entries| are sorted.
- unsigned short maxEnumValue() const { return m_entries.last().first; }
-
// SVGPropertyBase:
virtual PassRefPtr<SVGEnumerationBase> clone() const = 0;
virtual PassRefPtr<SVGPropertyBase> cloneForAnimation(const String&) const OVERRIDE;
@@ -68,23 +65,38 @@ public:
// Ensure that |SVGAnimatedEnumerationBase::setBaseVal| is used instead of |SVGAnimatedProperty<SVGEnumerationBase>::setBaseVal|.
void setValue(unsigned short) { ASSERT_NOT_REACHED(); }
+ static unsigned short valueOfLastEnum(const StringEntries& entries) { return entries.last().first; }
+
protected:
- SVGEnumerationBase(unsigned short value, const StringEntries& entries)
+ SVGEnumerationBase(unsigned short value, const StringEntries& entries, unsigned short maxExposed)
: SVGPropertyBase(classType())
, m_value(value)
+ , m_maxExposed(maxExposed)
, m_entries(entries)
{
}
+ // This is the maximum value of all the internal enumeration values.
+ // This assumes that |m_entries| are sorted.
+ unsigned short maxInternalEnumValue() const { return valueOfLastEnum(m_entries); }
+
+ // This is the maximum value that is exposed as an IDL constant on the relevant interface.
+ unsigned short maxExposedEnumValue() const { return m_maxExposed; }
+
// Used by SVGMarkerOrientEnumeration.
virtual void notifyChange() { }
unsigned short m_value;
+ const unsigned short m_maxExposed;
const StringEntries& m_entries;
};
typedef SVGEnumerationBase::StringEntries SVGEnumerationStringEntries;
template<typename Enum> const SVGEnumerationStringEntries& getStaticStringEntries();
+template<typename Enum> unsigned short getMaxExposedEnumValue()
+{
+ return SVGEnumerationBase::valueOfLastEnum(getStaticStringEntries<Enum>());
+}
template<typename Enum>
class SVGEnumeration : public SVGEnumerationBase {
@@ -105,7 +117,7 @@ public:
Enum enumValue() const
{
- ASSERT(m_value <= maxEnumValue());
+ ASSERT(m_value <= maxInternalEnumValue());
return static_cast<Enum>(m_value);
}
@@ -117,7 +129,7 @@ public:
protected:
explicit SVGEnumeration(Enum newValue)
- : SVGEnumerationBase(newValue, getStaticStringEntries<Enum>())
+ : SVGEnumerationBase(newValue, getStaticStringEntries<Enum>(), getMaxExposedEnumValue<Enum>())
{
}
};
« no previous file with comments | « LayoutTests/svg/filters/feBlend-all-modes.html ('k') | Source/core/svg/SVGEnumeration.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698