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

Unified Diff: third_party/WebKit/Source/build/scripts/templates/ComputedStyleBase.cpp.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
Index: third_party/WebKit/Source/build/scripts/templates/ComputedStyleBase.cpp.tmpl
diff --git a/third_party/WebKit/Source/build/scripts/templates/ComputedStyleBase.cpp.tmpl b/third_party/WebKit/Source/build/scripts/templates/ComputedStyleBase.cpp.tmpl
index c9af826d04dbc71108e499c45fd85fd69cb25558..e28efac956d4d2f552fd7210d5f3f19659ee7a4c 100644
--- a/third_party/WebKit/Source/build/scripts/templates/ComputedStyleBase.cpp.tmpl
+++ b/third_party/WebKit/Source/build/scripts/templates/ComputedStyleBase.cpp.tmpl
@@ -1,5 +1,5 @@
{% from 'macros.tmpl' import license %}
-{% from 'fields/field.tmpl' import getter_expression, setter_expression %}
+{% from 'fields/field.tmpl' import getter_expression, setter_expression, fieldwise_copy %}
{{license()}}
#include "core/ComputedStyleBase.h"
@@ -22,18 +22,21 @@ struct SameSizeAsComputedStyleBase {
// ensure that the buckets are placed so that each takes up at most 1 word.
ASSERT_SIZE(ComputedStyleBase, SameSizeAsComputedStyleBase);
-void ComputedStyleBase::InheritFrom(const ComputedStyleBase& inheritParent,
+void ComputedStyleBase::InheritFrom(const ComputedStyleBase& other,
IsAtShadowBoundary isAtShadowBoundary) {
- {% for field in computed_style.all_fields if field.is_inherited %}
- {{setter_expression(field)}} = inheritParent.{{getter_expression(field)}};
- {% endfor %}
+ {{fieldwise_copy(computed_style, computed_style.all_fields
+ |selectattr("is_inherited")
+ |list
+ )|indent(2)}}
}
void ComputedStyleBase::CopyNonInheritedFromCached(
const ComputedStyleBase& other) {
- {% for field in computed_style.all_fields if (field.is_property and not field.is_inherited) or field.is_inherited_flag %}
- {{setter_expression(field)}} = other.{{getter_expression(field)}};
- {% endfor %}
+ {{fieldwise_copy(computed_style, computed_style.all_fields
+ |rejectattr("is_nonproperty")
+ |rejectattr("is_inherited")
+ |list
+ )|indent(2)}}
}
void ComputedStyleBase::PropagateIndependentInheritedProperties(

Powered by Google App Engine
This is Rietveld 408576698