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

Unified Diff: third_party/WebKit/Source/build/scripts/templates/ComputedStyleBase.h.tmpl

Issue 2680123002: Add Jinja2 macro for adding trailing strings. (Closed)
Patch Set: Change to print_if Created 3 years, 10 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 | « no previous file | third_party/WebKit/Source/build/scripts/templates/macros.tmpl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/build/scripts/templates/ComputedStyleBase.h.tmpl
diff --git a/third_party/WebKit/Source/build/scripts/templates/ComputedStyleBase.h.tmpl b/third_party/WebKit/Source/build/scripts/templates/ComputedStyleBase.h.tmpl
index b72300c1096ea9e3790bef6a13b2bde3bb33fe0b..f63c28002717349e74675ca33c86465e5fc96c9f 100644
--- a/third_party/WebKit/Source/build/scripts/templates/ComputedStyleBase.h.tmpl
+++ b/third_party/WebKit/Source/build/scripts/templates/ComputedStyleBase.h.tmpl
@@ -1,4 +1,4 @@
-{% from 'macros.tmpl' import license %}
+{% from 'macros.tmpl' import license, print_if %}
{{license()}}
#ifndef ComputedStyleBase_h
@@ -11,9 +11,10 @@
{% endfor %}
{# Returns the default value for the field, converted to fit in the storage container. #}
-{% macro default_value(field) %}
+{% macro default_value(field) -%}
sashab 2017/02/19 23:17:03 What's the dashes for?
shend 2017/02/19 23:20:17 They strip out leading/trailing whitespace so you
{# We only support enum fields for now. #}
-static_cast<unsigned>({{field.default_value}}){% endmacro %}
+static_cast<unsigned>({{field.default_value}})
+{%- endmacro %}
namespace blink {
@@ -23,25 +24,23 @@ class CORE_EXPORT ComputedStyleBase {
public:
ALWAYS_INLINE ComputedStyleBase() :
{% for field in fields %}
- {% set trailing_comma = "," if field != fields[-1] else "" %}
- {{field.name}}({{default_value(field)}}){{trailing_comma}}
+ {{field.name}}({{default_value(field)}}){{print_if(not loop.last, ',')}}
sashab 2017/02/19 23:17:03 Woah loop.last awesome!!
shend 2017/02/19 23:20:17 \o/
{% endfor %}
{}
~ComputedStyleBase() {}
ALWAYS_INLINE ComputedStyleBase(const ComputedStyleBase& o) :
{% for field in fields %}
- {% set trailing_comma = "," if field != fields[-1] else "" %}
- {{field.name}}(o.{{field.name}}){{trailing_comma}}
+ {{field.name}}(o.{{field.name}}){{print_if(not loop.last, ',')}}
{% endfor %}
{}
bool operator==(const ComputedStyleBase& o) const {
return true &&
{% for field in fields %}
- {{field.name}} == o.{{field.name}} &&
+ {{field.name}} == o.{{field.name}}{{print_if(not loop.last, ' &&')}}
{% endfor %}
- true;
+ ;
}
bool operator!=(const ComputedStyleBase& o) const { return !(*this == o); }
@@ -49,33 +48,33 @@ class CORE_EXPORT ComputedStyleBase {
inline bool inheritedEqual(const ComputedStyleBase& o) const {
return true &&
{% for field in fields if field.is_property and field.is_inherited %}
- {{field.name}} == o.{{field.name}} &&
+ {{field.name}} == o.{{field.name}}{{print_if(not loop.last, ' &&')}}
{% endfor %}
- true;
+ ;
}
inline bool independentInheritedEqual(const ComputedStyleBase& o) const {
return true &&
{% for field in fields if field.is_property and field.is_inherited and field.is_independent %}
- {{field.name}} == o.{{field.name}} &&
+ {{field.name}} == o.{{field.name}}{{print_if(not loop.last, ' &&')}}
{% endfor %}
- true;
+ ;
}
inline bool nonIndependentInheritedEqual(const ComputedStyleBase& o) const {
return true &&
{% for field in fields if field.is_property and field.is_inherited and not field.is_independent %}
- {{field.name}} == o.{{field.name}} &&
+ {{field.name}} == o.{{field.name}}{{print_if(not loop.last, ' &&')}}
{% endfor %}
- true;
+ ;
}
inline bool nonInheritedEqual(const ComputedStyleBase& o) const {
return true &&
{% for field in fields if field.is_property and not field.is_inherited %}
- {{field.name}} == o.{{field.name}} &&
+ {{field.name}} == o.{{field.name}}{{print_if(not loop.last, ' &&')}}
{% endfor %}
- true;
+ ;
}
void setBitDefaults() {
« no previous file with comments | « no previous file | third_party/WebKit/Source/build/scripts/templates/macros.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698