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

Unified Diff: third_party/WebKit/Source/core/css/StylePropertySet.h

Issue 1455053003: Custom property CSSOM patch with templates [not for landing] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@_levisPatch
Patch Set: Created 5 years, 1 month 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
Index: third_party/WebKit/Source/core/css/StylePropertySet.h
diff --git a/third_party/WebKit/Source/core/css/StylePropertySet.h b/third_party/WebKit/Source/core/css/StylePropertySet.h
index 951a63a29fd760d533dd226f1a89ff758308e874..b587dfc58007a4d3cdaffc8f7cba2448ab57572c 100644
--- a/third_party/WebKit/Source/core/css/StylePropertySet.h
+++ b/third_party/WebKit/Source/core/css/StylePropertySet.h
@@ -23,7 +23,6 @@
#include "core/CSSPropertyNames.h"
#include "core/CoreExport.h"
-#include "core/css/CSSCustomPropertyDeclaration.h"
#include "core/css/CSSPrimitiveValue.h"
#include "core/css/CSSProperty.h"
#include "core/css/PropertySetCSSStyleDeclaration.h"
@@ -91,17 +90,24 @@ public:
unsigned propertyCount() const;
bool isEmpty() const;
PropertyReference propertyAt(unsigned index) const { return PropertyReference(*this, index); }
- int findPropertyIndex(CSSPropertyID) const;
- int findCustomPropertyIndex(const AtomicString& propertyName) const;
+
+ template<typename T> // CSSPropertyID or AtomicString
+ int findPropertyIndex(T property) const;
+
bool hasProperty(CSSPropertyID property) const { return findPropertyIndex(property) != -1; }
- PassRefPtrWillBeRawPtr<CSSValue> getPropertyCSSValue(CSSPropertyID) const;
- PassRefPtrWillBeRawPtr<CSSCustomPropertyDeclaration> getCustomPropertyCSSValue(const AtomicString&) const;
- String getPropertyValue(CSSPropertyID) const;
- String getCustomPropertyValue(const AtomicString&) const;
+ template<typename T> // CSSPropertyID or AtomicString
+ PassRefPtrWillBeRawPtr<CSSValue> getPropertyCSSValue(T property) const;
+
+ template<typename T> // CSSPropertyID or AtomicString
+ String getPropertyValue(T property) const;
+
+ template<typename T> // CSSPropertyID or AtomicString
+ bool propertyIsImportant(T property) const;
+
+ bool shorthandIsImportant(CSSPropertyID) const;
+ bool shorthandIsImportant(const AtomicString& customPropertyName) const;
- bool propertyIsImportant(CSSPropertyID) const;
- bool customPropertyIsImportant(const AtomicString&) const;
CSSPropertyID getPropertyShorthand(CSSPropertyID) const;
bool isPropertyImplicit(CSSPropertyID) const;
@@ -161,8 +167,9 @@ public:
const RawPtrWillBeMember<CSSValue>* valueArray() const;
const StylePropertyMetadata* metadataArray() const;
- int findPropertyIndex(CSSPropertyID) const;
- int findCustomPropertyIndex(const AtomicString& propertyName) const;
+
+ template<typename T> // CSSPropertyID or AtomicString
+ int findPropertyIndex(T property) const;
DECLARE_TRACE_AFTER_DISPATCH();
@@ -203,15 +210,15 @@ public:
// These expand shorthand properties into multiple properties.
bool setProperty(CSSPropertyID unresolvedProperty, const String& value, bool important = false, StyleSheetContents* contextStyleSheet = 0);
+ bool setProperty(const AtomicString& customPropertyName, const String& value, bool important = false, StyleSheetContents* contextStyleSheet = 0);
void setProperty(CSSPropertyID, PassRefPtrWillBeRawPtr<CSSValue>, bool important = false);
- bool setCustomProperty(const AtomicString& propertyName, const String& value, bool important = false, StyleSheetContents* contextStyleSheet = 0);
// These do not. FIXME: This is too messy, we can do better.
bool setProperty(CSSPropertyID, CSSValueID identifier, bool important = false);
bool setProperty(const CSSProperty&, CSSProperty* slot = 0);
- bool removeProperty(CSSPropertyID, String* returnText = 0);
- bool removeCustomProperty(const AtomicString&, String* returnText = 0);
+ template<typename T> // CSSPropertyID or AtomicString
+ bool removeProperty(T property, String* returnText = 0);
bool removePropertiesInSet(const CSSPropertyID* set, unsigned length);
void removeEquivalentProperties(const StylePropertySet*);
void removeEquivalentProperties(const CSSStyleDeclaration*);
@@ -222,8 +229,9 @@ public:
void parseDeclarationList(const String& styleDeclaration, StyleSheetContents* contextStyleSheet);
CSSStyleDeclaration* ensureCSSStyleDeclaration();
- int findPropertyIndex(CSSPropertyID) const;
- int findCustomPropertyIndex(const AtomicString& propertyName) const;
+
+ template<typename T> // CSSPropertyID or AtomicString
+ int findPropertyIndex(T property) const;
DECLARE_TRACE_AFTER_DISPATCH();
@@ -235,6 +243,7 @@ private:
bool removePropertyAtIndex(int, String* returnText);
bool removeShorthandProperty(CSSPropertyID);
+ bool removeShorthandProperty(const AtomicString& customPropertyName) { return false; }
CSSProperty* findCSSPropertyWithID(CSSPropertyID);
OwnPtrWillBeMember<PropertySetCSSStyleDeclaration> m_cssomWrapper;
@@ -299,18 +308,12 @@ inline void StylePropertySet::deref()
}
#endif // !ENABLE(OILPAN)
-inline int StylePropertySet::findPropertyIndex(CSSPropertyID propertyID) const
-{
- if (m_isMutable)
- return toMutableStylePropertySet(this)->findPropertyIndex(propertyID);
- return toImmutableStylePropertySet(this)->findPropertyIndex(propertyID);
-}
-
-inline int StylePropertySet::findCustomPropertyIndex(const AtomicString& propertyName) const
+template<typename T>
+inline int StylePropertySet::findPropertyIndex(T property) const
{
if (m_isMutable)
- return toMutableStylePropertySet(this)->findCustomPropertyIndex(propertyName);
- return toImmutableStylePropertySet(this)->findCustomPropertyIndex(propertyName);
+ return toMutableStylePropertySet(this)->findPropertyIndex(property);
+ return toImmutableStylePropertySet(this)->findPropertyIndex(property);
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698