Commit 8976caef authored by shend's avatar shend Committed by Commit bot

Generate StyleBackgroundData in ComputedStyleBase.

This patch generates the following fields as part of a group:
- background ('storage_only' of type FillLayer)
- background_color ('storage_only' of type Color)

Since both fields correspond to shorthands, we specify them in
ComputedStyleExtraFields.json5.

All deleted code are correspondingly generated in
ComputedStyleBase, apart from the line

  background_data_(o.background_data_)

which is implicit in the compiler generated ComputedStyleBase
copy constructor.

Diff of generated files:
https://gist.github.com/darrnshn/c2d2e7f7429b6281987c8f1ff6e2c313/revisions

BUG=628043

Review-Url: https://codereview.chromium.org/2861623002
Cr-Commit-Position: refs/heads/master@{#469566}
parent 19e8945a
......@@ -169,5 +169,19 @@
field_group: "surround",
default_value: "BorderData()",
},
{
name: "Background",
field_template: "storage_only",
field_type_path: "core/style/FillLayer",
default_value: "FillLayer(kBackgroundFillLayer, true)",
field_group: "background",
},
{
name: "BackgroundColor",
field_template: "storage_only",
field_type_path: "core/css/StyleColor",
default_value: "Color::kTransparent",
field_group: "background",
},
],
}
......@@ -116,7 +116,6 @@ ALWAYS_INLINE ComputedStyle::ComputedStyle()
: ComputedStyleBase(), RefCounted<ComputedStyle>() {
box_data_.Init();
visual_data_.Init();
background_data_.Init();
rare_non_inherited_data_.Init();
rare_non_inherited_data_.Access()->deprecated_flexible_box_.Init();
rare_non_inherited_data_.Access()->flexible_box_.Init();
......@@ -138,7 +137,6 @@ ALWAYS_INLINE ComputedStyle::ComputedStyle(const ComputedStyle& o)
RefCounted<ComputedStyle>(),
box_data_(o.box_data_),
visual_data_(o.visual_data_),
background_data_(o.background_data_),
rare_non_inherited_data_(o.rare_non_inherited_data_),
rare_inherited_data_(o.rare_inherited_data_),
inherited_data_(o.inherited_data_),
......@@ -333,7 +331,6 @@ void ComputedStyle::CopyNonInheritedFromCached(const ComputedStyle& other) {
ComputedStyleBase::CopyNonInheritedFromCached(other);
box_data_ = other.box_data_;
visual_data_ = other.visual_data_;
background_data_ = other.background_data_;
rare_non_inherited_data_ = other.rare_non_inherited_data_;
// The flags are copied one-by-one because they contain
......@@ -475,7 +472,6 @@ bool ComputedStyle::NonInheritedEqual(const ComputedStyle& other) const {
return ComputedStyleBase::NonInheritedEqual(other) &&
box_data_ == other.box_data_ &&
visual_data_ == other.visual_data_ &&
background_data_ == other.background_data_ &&
rare_non_inherited_data_ == other.rare_non_inherited_data_ &&
svg_style_->NonInheritedEqual(*other.svg_style_);
}
......
......@@ -181,40 +181,10 @@ class CORE_EXPORT ComputedStyle : public ComputedStyleBase,
friend class StyleResolverState;
friend class StyleResolver;
private:
class StyleBackgroundData : public RefCountedCopyable<StyleBackgroundData> {
public:
static PassRefPtr<StyleBackgroundData> Create() {
return AdoptRef(new StyleBackgroundData);
}
PassRefPtr<StyleBackgroundData> Copy() const {
return AdoptRef(new StyleBackgroundData(*this));
}
bool operator==(const StyleBackgroundData& other) const {
return background_ == other.background_ &&
background_color_ == other.background_color_;
}
bool operator!=(const StyleBackgroundData& other) const {
return !(*this == other);
}
FillLayer background_;
StyleColor background_color_;
private:
StyleBackgroundData()
: background_(FillLayer(kBackgroundFillLayer, true)),
background_color_(Color::kTransparent) {}
StyleBackgroundData(const StyleBackgroundData&) = default;
};
protected:
// non-inherited attributes
DataRef<StyleBoxData> box_data_;
DataRef<StyleVisualData> visual_data_;
DataRef<StyleBackgroundData> background_data_;
DataRef<StyleRareNonInheritedData> rare_non_inherited_data_;
// inherited attributes
......
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