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

Unified Diff: third_party/WebKit/Source/build/scripts/templates/fields/field.tmpl

Issue 2826633002: Exploit sharing when comparing and copying groups in ComputedStyle. (Closed)
Patch Set: Rebase Created 3 years, 8 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 | « third_party/WebKit/Source/build/scripts/templates/ComputedStyleBase.h.tmpl ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/build/scripts/templates/fields/field.tmpl
diff --git a/third_party/WebKit/Source/build/scripts/templates/fields/field.tmpl b/third_party/WebKit/Source/build/scripts/templates/fields/field.tmpl
index 9ded9eaa63683bd3fcf314347bd275ad3e251695..ff20cf6ed7180fb05620e3236b94254183c67165 100644
--- a/third_party/WebKit/Source/build/scripts/templates/fields/field.tmpl
+++ b/third_party/WebKit/Source/build/scripts/templates/fields/field.tmpl
@@ -53,3 +53,36 @@ unsigned {{field.name}} : {{field.size}}; // {{field.type_name}}
{{field.type_name}} {{field.name}};
{%- endif %}
{% endmacro %}
+
+{# Given a group and a list of fields to compare, this generates a set of
+ equality comparisons on those fields. The generated comparisons take
+ advantage of group sharing. #}
+{% macro fieldwise_compare(group, fields_to_compare) %}
+{% for subgroup in group.subgroups %}
+ {# If every field in this subgroup is to be compared, we can compare the
+ group pointer instead. #}
+ {% if subgroup.all_fields|reject("in", fields_to_compare)|list|length == 0 -%}
+ {{subgroup.member_name}} == o.{{subgroup.member_name}} &&
+ {# Otherwise, we would have to recursively generate comparison operations
+ on fields in the subgroup. #}
+ {% elif subgroup.fields|select("in", fields_to_compare)|list|length > 0 -%}
+ {{fieldwise_compare(subgroup, fields_to_compare)}}
+ {% endif %}
+{% endfor %}
+{% for field in group.fields|select("in", fields_to_compare) -%}
+ {{getter_expression(field)}} == o.{{getter_expression(field)}} &&
+{% endfor %}
+{% endmacro %}
+
+{% macro fieldwise_copy(group, fields_to_copy) %}
+{% for subgroup in group.subgroups %}
+ {% if subgroup.all_fields|reject("in", fields_to_copy)|list|length == 0 -%}
+ {{subgroup.member_name}} = other.{{subgroup.member_name}};
+ {% elif subgroup.fields|select("in", fields_to_copy)|list|length > 0 -%}
+ {{fieldwise_copy(subgroup, fields_to_copy)}}
+ {% endif %}
+{% endfor %}
+{% for field in group.fields|select("in", fields_to_copy) -%}
+ {{setter_expression(field)}} = other.{{getter_expression(field)}};
+{% endfor %}
+{% endmacro %}
« no previous file with comments | « third_party/WebKit/Source/build/scripts/templates/ComputedStyleBase.h.tmpl ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698