Commit 82e425e1 authored by Naina Raisinghani's avatar Naina Raisinghani Committed by Commit Bot

Make all groups on ComputedStyle private

This patch makes all subgroups on ComputedStyle private to ensure that
no function depends on the way grouping happens in ComputedStyle.

Diff: https://gist.github.com/nainar/13876826757ad4d2c99520f99a8ac875/revisions

Bug: 710938
Change-Id: I2d2d7d5cff3fc64361b9bf42c4ea2496f3130f7f
Reviewed-on: https://chromium-review.googlesource.com/544450Reviewed-by: default avatarDarren Shen <shend@chromium.org>
Commit-Queue: nainar <nainar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#481803}
parent 0df82202
...@@ -170,12 +170,12 @@ class CORE_EXPORT ComputedStyleBase { ...@@ -170,12 +170,12 @@ class CORE_EXPORT ComputedStyleBase {
~ComputedStyleBase() = default; ~ComputedStyleBase() = default;
private:
// Storage. // Storage.
{% for subgroup in computed_style.subgroups %} {% for subgroup in computed_style.subgroups %}
DataRef<{{subgroup.type_name}}> {{subgroup.member_name}}; DataRef<{{subgroup.type_name}}> {{subgroup.member_name}};
{% endfor %} {% endfor %}
private:
{% for field in computed_style.fields %} {% for field in computed_style.fields %}
{{declare_storage(field)}} {{declare_storage(field)}}
{% endfor %} {% endfor %}
......
...@@ -633,10 +633,10 @@ class CORE_EXPORT ComputedStyle : public ComputedStyleBase, ...@@ -633,10 +633,10 @@ class CORE_EXPORT ComputedStyle : public ComputedStyleBase,
// opacity (aka -webkit-opacity) // opacity (aka -webkit-opacity)
static float InitialOpacity() { return 1.0f; } static float InitialOpacity() { return 1.0f; }
float Opacity() const { return rare_non_inherited_data_->opacity_; } float Opacity() const { return OpacityInternal(); }
void SetOpacity(float f) { void SetOpacity(float f) {
float v = clampTo<float>(f, 0, 1); float v = clampTo<float>(f, 0, 1);
SET_VAR(rare_non_inherited_data_, opacity_, v); SetOpacityInternal(v);
} }
bool OpacityChangedStackingContext(const ComputedStyle& other) const { bool OpacityChangedStackingContext(const ComputedStyle& other) const {
...@@ -659,12 +659,11 @@ class CORE_EXPORT ComputedStyle : public ComputedStyleBase, ...@@ -659,12 +659,11 @@ class CORE_EXPORT ComputedStyle : public ComputedStyleBase,
// order (aka -webkit-order) // order (aka -webkit-order)
static int InitialOrder() { return 0; } static int InitialOrder() { return 0; }
int Order() const { return rare_non_inherited_data_->order_; } int Order() const { return OrderInternal(); }
// We restrict the smallest value to int min + 2 because we use int min and // We restrict the smallest value to int min + 2 because we use int min and
// int min + 1 as special values in a hash set. // int min + 1 as special values in a hash set.
void SetOrder(int o) { void SetOrder(int o) {
SET_VAR(rare_non_inherited_data_, order_, SetOrderInternal(max(std::numeric_limits<int>::min() + 2, o));
max(std::numeric_limits<int>::min() + 2, o));
} }
// Outline properties. // Outline properties.
...@@ -888,14 +887,11 @@ class CORE_EXPORT ComputedStyle : public ComputedStyleBase, ...@@ -888,14 +887,11 @@ class CORE_EXPORT ComputedStyle : public ComputedStyleBase,
// shape-image-threshold (aka -webkit-shape-image-threshold) // shape-image-threshold (aka -webkit-shape-image-threshold)
static float InitialShapeImageThreshold() { return 0; } static float InitialShapeImageThreshold() { return 0; }
float ShapeImageThreshold() const { float ShapeImageThreshold() const { return ShapeImageThresholdInternal(); }
return rare_non_inherited_data_->shape_image_threshold_;
}
void SetShapeImageThreshold(float shape_image_threshold) { void SetShapeImageThreshold(float shape_image_threshold) {
float clamped_shape_image_threshold = float clamped_shape_image_threshold =
clampTo<float>(shape_image_threshold, 0, 1); clampTo<float>(shape_image_threshold, 0, 1);
SET_VAR(rare_non_inherited_data_, shape_image_threshold_, SetShapeImageThresholdInternal(clamped_shape_image_threshold);
clamped_shape_image_threshold);
} }
// shape-outside (aka -webkit-shape-outside) // shape-outside (aka -webkit-shape-outside)
...@@ -1010,10 +1006,10 @@ class CORE_EXPORT ComputedStyle : public ComputedStyleBase, ...@@ -1010,10 +1006,10 @@ class CORE_EXPORT ComputedStyle : public ComputedStyleBase,
// -webkit-mask-box-image-width // -webkit-mask-box-image-width
const BorderImageLengthBox& MaskBoxImageWidth() const { const BorderImageLengthBox& MaskBoxImageWidth() const {
return rare_non_inherited_data_->mask_box_image_.BorderSlices(); return MaskBoxImageInternal().BorderSlices();
} }
void SetMaskBoxImageWidth(const BorderImageLengthBox& slices) { void SetMaskBoxImageWidth(const BorderImageLengthBox& slices) {
rare_non_inherited_data_.Access()->mask_box_image_.SetBorderSlices(slices); MutableMaskBoxImageInternal().SetBorderSlices(slices);
} }
// Inherited properties. // Inherited properties.
...@@ -1341,8 +1337,19 @@ class CORE_EXPORT ComputedStyle : public ComputedStyleBase, ...@@ -1341,8 +1337,19 @@ class CORE_EXPORT ComputedStyle : public ComputedStyleBase,
} }
bool ColumnRuleEquivalent(const ComputedStyle* other_style) const; bool ColumnRuleEquivalent(const ComputedStyle* other_style) const;
void InheritColumnPropertiesFrom(const ComputedStyle& parent) { void InheritColumnPropertiesFrom(const ComputedStyle& parent) {
rare_non_inherited_data_.Access()->multi_col_data_ = SetColumnGapInternal(parent.ColumnGapInternal());
parent.rare_non_inherited_data_->multi_col_data_; SetColumnWidthInternal(parent.ColumnWidthInternal());
SetVisitedLinkColumnRuleColorInternal(
parent.VisitedLinkColumnRuleColorInternal());
SetColumnRuleColorInternal(parent.ColumnRuleColorInternal());
SetColumnCountInternal(parent.ColumnCountInternal());
SetColumnRuleStyle(parent.ColumnRuleStyle());
SetColumnAutoCountInternal(parent.ColumnAutoCountInternal());
SetColumnAutoWidthInternal(parent.ColumnAutoWidthInternal());
SetColumnFill(parent.GetColumnFill());
SetColumnNormalGapInternal(parent.ColumnNormalGapInternal());
SetColumnRuleColorIsCurrentColor(parent.ColumnRuleColorIsCurrentColor());
SetColumnSpan(parent.GetColumnSpan());
} }
// Flex utility functions. // Flex utility functions.
...@@ -1361,35 +1368,22 @@ class CORE_EXPORT ComputedStyle : public ComputedStyleBase, ...@@ -1361,35 +1368,22 @@ class CORE_EXPORT ComputedStyle : public ComputedStyleBase,
// Mask utility functions. // Mask utility functions.
bool HasMask() const { bool HasMask() const {
return rare_non_inherited_data_->mask_.HasImage() || return MaskInternal().HasImage() || MaskBoxImageInternal().HasImage();
rare_non_inherited_data_->mask_box_image_.HasImage();
}
StyleImage* MaskImage() const {
return rare_non_inherited_data_->mask_.GetImage();
}
FillLayer& AccessMaskLayers() {
return rare_non_inherited_data_.Access()->mask_;
}
const FillLayer& MaskLayers() const {
return rare_non_inherited_data_->mask_;
}
const NinePieceImage& MaskBoxImage() const {
return rare_non_inherited_data_->mask_box_image_;
}
bool MaskBoxImageSlicesFill() const {
return rare_non_inherited_data_->mask_box_image_.Fill();
} }
StyleImage* MaskImage() const { return MaskInternal().GetImage(); }
FillLayer& AccessMaskLayers() { return MutableMaskInternal(); }
const FillLayer& MaskLayers() const { return MaskInternal(); }
const NinePieceImage& MaskBoxImage() const { return MaskBoxImageInternal(); }
bool MaskBoxImageSlicesFill() const { return MaskBoxImageInternal().Fill(); }
void AdjustMaskLayers() { void AdjustMaskLayers() {
if (MaskLayers().Next()) { if (MaskLayers().Next()) {
AccessMaskLayers().CullEmptyLayers(); AccessMaskLayers().CullEmptyLayers();
AccessMaskLayers().FillUnsetProperties(); AccessMaskLayers().FillUnsetProperties();
} }
} }
void SetMaskBoxImage(const NinePieceImage& b) { void SetMaskBoxImage(const NinePieceImage& b) { SetMaskBoxImageInternal(b); }
SET_VAR(rare_non_inherited_data_, mask_box_image_, b);
}
void SetMaskBoxImageSlicesFill(bool fill) { void SetMaskBoxImageSlicesFill(bool fill) {
rare_non_inherited_data_.Access()->mask_box_image_.SetFill(fill); MutableMaskBoxImageInternal().SetFill(fill);
} }
// Text-combine utility functions. // Text-combine utility functions.
......
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