Commit 997462ff authored by nainar's avatar nainar Committed by Commit bot

Add macro to diff the groups (and their members) in ComputedStyleBase

This patch adds the fieldwise_diff macro and then uses it to generate
the diff functions on the groups that have been generated so far
(StyleSurroundData) in ComputedStyleBase.

Please note that it can only be used for memebers of those groups too
that have already been generated. This is why the diffing for
BorderData has been left to a later CL.

Diff: https://gist.github.com/nainar/04f49165c4cb5ecb30371fbde1491ddf/revisions

BUG=710938

Review-Url: https://codereview.chromium.org/2858863002
Cr-Commit-Position: refs/heads/master@{#469286}
parent a854766f
{% from 'macros.tmpl' import license %}
{% from 'fields/field.tmpl' import getter_expression, setter_expression, fieldwise_copy %}
{% from 'fields/field.tmpl' import getter_expression, setter_expression, fieldwise_copy, fieldwise_diff %}
{{license()}}
#include "core/ComputedStyleBase.h"
......@@ -48,4 +48,23 @@ void ComputedStyleBase::PropagateIndependentInheritedProperties(
{% endfor %}
}
bool ComputedStyleBase::ScrollAnchorDisablingPropertyChanged(
const ComputedStyleBase& other,
const StyleDifference& diff) const {
{{fieldwise_diff(computed_style, computed_style.all_fields
|selectattr("property_name", "in", ["margin-top", "margin-left", "margin-right", "margin-bottom", "left", "right", "top", "bottom", "padding-top", "padding-left", "padding-right", "padding-bottom"])
|list
)|indent(2)}}
return false;
}
bool ComputedStyleBase::DiffNeedsFullLayoutAndPaintInvalidation(
const ComputedStyleBase& other) const {
{{fieldwise_diff(computed_style, computed_style.all_fields
|selectattr("property_name", "in", ["padding-top", "padding-left", "padding-right", "padding-bottom"])
|list
)|indent(2)}}
return false;
}
} // namespace blink
......@@ -9,6 +9,7 @@
#include "core/style/ComputedStyleConstants.h"
#include "core/CoreExport.h"
#include "core/style/DataRef.h"
#include "core/style/StyleDifference.h"
{% for path in include_paths %}
#include "{{path}}"
{% endfor %}
......@@ -84,6 +85,10 @@ class CORE_EXPORT ComputedStyleBase {
IsAtShadowBoundary isAtShadowBoundary = kNotAtShadowBoundary);
void CopyNonInheritedFromCached(const ComputedStyleBase& other);
bool DiffNeedsFullLayoutAndPaintInvalidation(
const ComputedStyleBase& other) const;
bool ScrollAnchorDisablingPropertyChanged(const ComputedStyleBase& other,
const StyleDifference&) const;
// Copies the values of any independent inherited properties from the parent
// style that are marked as inherited by this style.
......
......@@ -86,3 +86,17 @@ unsigned {{field.name}} : {{field.size}}; // {{field.type_name}}
{{setter_expression(field)}} = other.{{getter_expression(field)}};
{% endfor %}
{% endmacro %}
{% macro fieldwise_diff(group, fields_to_diff) %}
{% for subgroup in group.subgroups %}
{% if subgroup.all_fields|select("in", fields_to_diff)|list|length > 0 -%}
if ({{subgroup.member_name}}.Get() != other.{{subgroup.member_name}}.Get()) {
{{fieldwise_diff(subgroup, fields_to_diff)|indent(2, true)}}
}
{% endif -%}
{% endfor %}
{% for field in group.fields|select("in", fields_to_diff) %}
if ({{getter_expression(field)}} != other.{{getter_expression(field)}})
return true;
{% endfor %}
{% endmacro %}
\ No newline at end of file
......@@ -579,10 +579,8 @@ bool ComputedStyle::ScrollAnchorDisablingPropertyChanged(
return true;
}
if (surround_data_.Get() != other.surround_data_.Get()) {
if (!MarginEqual(other) || !OffsetEqual(other) || !PaddingEqual(other))
return true;
}
if (ComputedStyleBase::ScrollAnchorDisablingPropertyChanged(other, diff))
return true;
if (diff.TransformChanged())
return true;
......@@ -607,11 +605,11 @@ bool ComputedStyle::DiffNeedsFullLayoutAndPaintInvalidation(
BorderBottomWidth() != other.BorderBottomWidth() ||
BorderRightWidth() != other.BorderRightWidth())
return true;
if (!PaddingEqual(other))
return true;
}
if (ComputedStyleBase::DiffNeedsFullLayoutAndPaintInvalidation(other))
return true;
if (rare_non_inherited_data_.Get() != other.rare_non_inherited_data_.Get()) {
if (rare_non_inherited_data_->appearance_ !=
other.rare_non_inherited_data_->appearance_ ||
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment