Index: third_party/WebKit/Source/build/scripts/templates/BaseComputedStyle.h.tmpl |
diff --git a/third_party/WebKit/Source/build/scripts/templates/BaseComputedStyle.h.tmpl b/third_party/WebKit/Source/build/scripts/templates/BaseComputedStyle.h.tmpl |
new file mode 100644 |
index 0000000000000000000000000000000000000000..06fefccc20a07c788f514aa3049aa712b07ab244 |
--- /dev/null |
+++ b/third_party/WebKit/Source/build/scripts/templates/BaseComputedStyle.h.tmpl |
@@ -0,0 +1,96 @@ |
+{% from 'macros.tmpl' import license %} |
sashab
2016/07/27 03:23:19
Ugh, this is so hard to read with no syntax highli
|
+{{license()}} |
+ |
+#ifndef BaseComputedStyle_h |
+#define BaseComputedStyle_h |
+ |
+#include "core/BaseComputedStyleConstants.h" |
+#include "core/CoreExport.h" |
+#include "wtf/RefCounted.h" |
+ |
+{# Returns the default value for the field, converted to fit in the storage container. #} |
+{% macro default_value(field) %} |
+{# We only support enum fields for now. #} |
+static_cast<unsigned>({{field.default_value}}){% endmacro %} |
+ |
+namespace blink { |
+ |
+// The generated portion of ComputedStyle. For more info, see the header comment |
+// in ComputedStyle.h. |
+class CORE_EXPORT BaseComputedStyle : public RefCounted<BaseComputedStyle> { |
+public: |
+ ALWAYS_INLINE BaseComputedStyle() : |
+ RefCounted<BaseComputedStyle>(), |
+ {% for field in fields %} |
+ {% set trailing_comma = "," if field != fields[-1] else "" %} |
+ {{field.name}}({{default_value(field)}}){{trailing_comma}} |
+ {% endfor %} |
+ {} |
+ ~BaseComputedStyle() {} |
+ |
+ ALWAYS_INLINE BaseComputedStyle(const BaseComputedStyle& o) : |
+ {% for field in fields %} |
+ {% set trailing_comma = "," if field != fields[-1] else "" %} |
+ {{field.name}}(o.{{field.name}}){{trailing_comma}} |
+ {% endfor %} |
+ {} |
+ |
+ bool operator==(const BaseComputedStyle& o) const |
+ { |
+ return true |
+ {% for field in fields %} |
+ && {{field.name}} == o.{{field.name}} |
+ {% endfor %} |
+ && true; |
sashab
2016/07/27 03:23:19
This && true stuff was just my not-so-clever way o
|
+ } |
+ |
+ bool operator!=(const BaseComputedStyle& o) const { return !(*this == o); } |
+ |
+ inline bool inheritedEqual(const BaseComputedStyle& o) const |
+ { |
+ return true |
+ {% for field in fields if field.property['inherited'] %} |
+ && {{field.name}} == o.{{field.name}} |
+ {% endfor %} |
+ && true; |
+ } |
+ |
+ inline bool nonInheritedEqual(const BaseComputedStyle& o) const |
+ { |
+ return true |
+ {% for field in fields if not field.property['inherited'] %} |
+ && {{field.name}} == o.{{field.name}} |
+ {% endfor %} |
+ && true; |
+ } |
+ |
+ void setBitDefaults() |
+ { |
+ {% for field in fields %} |
+ reset{{field.property['upper_camel_name']}}(); |
+ {% endfor %} |
+ } |
+ |
+ void inheritFrom(const BaseComputedStyle& inheritParent, IsAtShadowBoundary isAtShadowBoundary = NotAtShadowBoundary); |
+ |
+ // Fields. |
+ // TODO(sashab): Remove initialFoo() static methods and update callers to |
+ // use resetFoo(), which can be more efficient. |
+ {% for field in fields %} |
+ // {{field.property['name']}} |
+ inline static {{field.type}} initial{{field.property['upper_camel_name']}}() { return {{field.default_value}}; } |
+ {{field.type}} {{field.property['lower_camel_name']}}() const { return static_cast<{{field.type}}>({{field.name}}); } |
+ void set{{field.property['upper_camel_name']}}({{field.type}} v) { {{field.name}} = static_cast<unsigned>(v); } |
+ inline void reset{{field.property['upper_camel_name']}}() { {{field.name}} = {{default_value(field)}}; } |
+ |
+ {% endfor %} |
+protected: |
+ // Storage. |
+ {% for field in fields %} |
+ unsigned {{field.name}} : {{field.size}}; // {{field.type}} |
+ {% endfor %} |
+}; |
+ |
+} // namespace blink |
+ |
+#endif // BaseComputedStyle_h |