mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
LibWeb: Split CSS::ComputedValues members into structs by inheritance
Put all the inherited members in one struct and all the non-inherited ones in another. This makes it clear which is which, and also makes it easy to copy all the inherited values while ignoring the non-inherited ones.
This commit is contained in:
parent
981758a8b1
commit
cc024bdcc0
Notes:
sideshowbarker
2024-07-19 00:04:37 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/cc024bdcc01
1 changed files with 77 additions and 72 deletions
|
@ -55,60 +55,65 @@ public:
|
|||
|
||||
class ComputedValues {
|
||||
public:
|
||||
CSS::Float float_() const { return m_float; }
|
||||
CSS::Clear clear() const { return m_clear; }
|
||||
Optional<int> z_index() const { return m_z_index; }
|
||||
CSS::TextAlign text_align() const { return m_text_align; }
|
||||
CSS::TextDecorationLine text_decoration_line() const { return m_text_decoration_line; }
|
||||
CSS::TextTransform text_transform() const { return m_text_transform; }
|
||||
CSS::Position position() const { return m_position; }
|
||||
CSS::WhiteSpace white_space() const { return m_white_space; }
|
||||
const CSS::Length& width() const { return m_width; }
|
||||
const CSS::Length& min_width() const { return m_min_width; }
|
||||
const CSS::Length& max_width() const { return m_max_width; }
|
||||
const CSS::Length& height() const { return m_height; }
|
||||
const CSS::Length& min_height() const { return m_min_height; }
|
||||
const CSS::Length& max_height() const { return m_max_height; }
|
||||
CSS::Float float_() const { return m_noninherited.float_; }
|
||||
CSS::Clear clear() const { return m_noninherited.clear; }
|
||||
Optional<int> z_index() const { return m_noninherited.z_index; }
|
||||
CSS::TextAlign text_align() const { return m_inherited.text_align; }
|
||||
CSS::TextDecorationLine text_decoration_line() const { return m_noninherited.text_decoration_line; }
|
||||
CSS::TextTransform text_transform() const { return m_inherited.text_transform; }
|
||||
CSS::Position position() const { return m_noninherited.position; }
|
||||
CSS::WhiteSpace white_space() const { return m_inherited.white_space; }
|
||||
const CSS::Length& width() const { return m_noninherited.width; }
|
||||
const CSS::Length& min_width() const { return m_noninherited.min_width; }
|
||||
const CSS::Length& max_width() const { return m_noninherited.max_width; }
|
||||
const CSS::Length& height() const { return m_noninherited.height; }
|
||||
const CSS::Length& min_height() const { return m_noninherited.min_height; }
|
||||
const CSS::Length& max_height() const { return m_noninherited.max_height; }
|
||||
|
||||
const CSS::LengthBox& offset() const { return m_offset; }
|
||||
const CSS::LengthBox& margin() const { return m_margin; }
|
||||
const CSS::LengthBox& padding() const { return m_padding; }
|
||||
const CSS::LengthBox& offset() const { return m_noninherited.offset; }
|
||||
const CSS::LengthBox& margin() const { return m_noninherited.margin; }
|
||||
const CSS::LengthBox& padding() const { return m_noninherited.padding; }
|
||||
|
||||
const BorderData& border_left() const { return m_border_left; }
|
||||
const BorderData& border_top() const { return m_border_top; }
|
||||
const BorderData& border_right() const { return m_border_right; }
|
||||
const BorderData& border_bottom() const { return m_border_bottom; }
|
||||
const BorderData& border_left() const { return m_noninherited.border_left; }
|
||||
const BorderData& border_top() const { return m_noninherited.border_top; }
|
||||
const BorderData& border_right() const { return m_noninherited.border_right; }
|
||||
const BorderData& border_bottom() const { return m_noninherited.border_bottom; }
|
||||
|
||||
Color color() const { return m_color; }
|
||||
Color background_color() const { return m_background_color; }
|
||||
Color color() const { return m_inherited.color; }
|
||||
Color background_color() const { return m_noninherited.background_color; }
|
||||
|
||||
CSS::ListStyleType list_style_type() const { return m_list_style_type; }
|
||||
CSS::ListStyleType list_style_type() const { return m_inherited.list_style_type; }
|
||||
|
||||
protected:
|
||||
CSS::Float m_float { InitialValues::float_() };
|
||||
CSS::Clear m_clear { InitialValues::clear() };
|
||||
Optional<int> m_z_index;
|
||||
CSS::TextAlign m_text_align { InitialValues::text_align() };
|
||||
CSS::TextDecorationLine m_text_decoration_line { InitialValues::text_decoration_line() };
|
||||
CSS::TextTransform m_text_transform { InitialValues::text_transform() };
|
||||
CSS::Position m_position { InitialValues::position() };
|
||||
CSS::WhiteSpace m_white_space { InitialValues::white_space() };
|
||||
CSS::Length m_width;
|
||||
CSS::Length m_min_width;
|
||||
CSS::Length m_max_width;
|
||||
CSS::Length m_height;
|
||||
CSS::Length m_min_height;
|
||||
CSS::Length m_max_height;
|
||||
CSS::LengthBox m_offset;
|
||||
CSS::LengthBox m_margin;
|
||||
CSS::LengthBox m_padding;
|
||||
BorderData m_border_left;
|
||||
BorderData m_border_top;
|
||||
BorderData m_border_right;
|
||||
BorderData m_border_bottom;
|
||||
Color m_color { InitialValues::color() };
|
||||
Color m_background_color { InitialValues::background_color() };
|
||||
CSS::ListStyleType m_list_style_type { InitialValues::list_style_type() };
|
||||
struct {
|
||||
Color color { InitialValues::color() };
|
||||
CSS::TextAlign text_align { InitialValues::text_align() };
|
||||
CSS::TextTransform text_transform { InitialValues::text_transform() };
|
||||
CSS::WhiteSpace white_space { InitialValues::white_space() };
|
||||
CSS::ListStyleType list_style_type { InitialValues::list_style_type() };
|
||||
} m_inherited;
|
||||
|
||||
struct {
|
||||
CSS::Float float_ { InitialValues::float_() };
|
||||
CSS::Clear clear { InitialValues::clear() };
|
||||
Optional<int> z_index;
|
||||
CSS::TextDecorationLine text_decoration_line { InitialValues::text_decoration_line() };
|
||||
CSS::Position position { InitialValues::position() };
|
||||
CSS::Length width;
|
||||
CSS::Length min_width;
|
||||
CSS::Length max_width;
|
||||
CSS::Length height;
|
||||
CSS::Length min_height;
|
||||
CSS::Length max_height;
|
||||
CSS::LengthBox offset;
|
||||
CSS::LengthBox margin;
|
||||
CSS::LengthBox padding;
|
||||
BorderData border_left;
|
||||
BorderData border_top;
|
||||
BorderData border_right;
|
||||
BorderData border_bottom;
|
||||
Color background_color { InitialValues::background_color() };
|
||||
} m_noninherited;
|
||||
};
|
||||
|
||||
class ImmutableComputedValues final : public ComputedValues {
|
||||
|
@ -116,30 +121,30 @@ class ImmutableComputedValues final : public ComputedValues {
|
|||
|
||||
class MutableComputedValues final : public ComputedValues {
|
||||
public:
|
||||
void set_color(const Color& color) { m_color = color; }
|
||||
void set_background_color(const Color& color) { m_background_color = color; }
|
||||
void set_float(CSS::Float value) { m_float = value; }
|
||||
void set_clear(CSS::Clear value) { m_clear = value; }
|
||||
void set_z_index(Optional<int> value) { m_z_index = value; }
|
||||
void set_text_align(CSS::TextAlign text_align) { m_text_align = text_align; }
|
||||
void set_text_decoration_line(CSS::TextDecorationLine value) { m_text_decoration_line = value; }
|
||||
void set_text_transform(CSS::TextTransform value) { m_text_transform = value; }
|
||||
void set_position(CSS::Position position) { m_position = position; }
|
||||
void set_white_space(CSS::WhiteSpace value) { m_white_space = value; }
|
||||
void set_width(const CSS::Length& width) { m_width = width; }
|
||||
void set_min_width(const CSS::Length& width) { m_min_width = width; }
|
||||
void set_max_width(const CSS::Length& width) { m_max_width = width; }
|
||||
void set_height(const CSS::Length& height) { m_height = height; }
|
||||
void set_min_height(const CSS::Length& height) { m_min_height = height; }
|
||||
void set_max_height(const CSS::Length& height) { m_max_height = height; }
|
||||
void set_offset(const CSS::LengthBox& offset) { m_offset = offset; }
|
||||
void set_margin(const CSS::LengthBox& margin) { m_margin = margin; }
|
||||
void set_padding(const CSS::LengthBox& padding) { m_padding = padding; }
|
||||
void set_list_style_type(CSS::ListStyleType value) { m_list_style_type = value; }
|
||||
BorderData& border_left() { return m_border_left; }
|
||||
BorderData& border_top() { return m_border_top; }
|
||||
BorderData& border_right() { return m_border_right; }
|
||||
BorderData& border_bottom() { return m_border_bottom; }
|
||||
void set_color(const Color& color) { m_inherited.color = color; }
|
||||
void set_background_color(const Color& color) { m_noninherited.background_color = color; }
|
||||
void set_float(CSS::Float value) { m_noninherited.float_ = value; }
|
||||
void set_clear(CSS::Clear value) { m_noninherited.clear = value; }
|
||||
void set_z_index(Optional<int> value) { m_noninherited.z_index = value; }
|
||||
void set_text_align(CSS::TextAlign text_align) { m_inherited.text_align = text_align; }
|
||||
void set_text_decoration_line(CSS::TextDecorationLine value) { m_noninherited.text_decoration_line = value; }
|
||||
void set_text_transform(CSS::TextTransform value) { m_inherited.text_transform = value; }
|
||||
void set_position(CSS::Position position) { m_noninherited.position = position; }
|
||||
void set_white_space(CSS::WhiteSpace value) { m_inherited.white_space = value; }
|
||||
void set_width(const CSS::Length& width) { m_noninherited.width = width; }
|
||||
void set_min_width(const CSS::Length& width) { m_noninherited.min_width = width; }
|
||||
void set_max_width(const CSS::Length& width) { m_noninherited.max_width = width; }
|
||||
void set_height(const CSS::Length& height) { m_noninherited.height = height; }
|
||||
void set_min_height(const CSS::Length& height) { m_noninherited.min_height = height; }
|
||||
void set_max_height(const CSS::Length& height) { m_noninherited.max_height = height; }
|
||||
void set_offset(const CSS::LengthBox& offset) { m_noninherited.offset = offset; }
|
||||
void set_margin(const CSS::LengthBox& margin) { m_noninherited.margin = margin; }
|
||||
void set_padding(const CSS::LengthBox& padding) { m_noninherited.padding = padding; }
|
||||
void set_list_style_type(CSS::ListStyleType value) { m_inherited.list_style_type = value; }
|
||||
BorderData& border_left() { return m_noninherited.border_left; }
|
||||
BorderData& border_top() { return m_noninherited.border_top; }
|
||||
BorderData& border_right() { return m_noninherited.border_right; }
|
||||
BorderData& border_bottom() { return m_noninherited.border_bottom; }
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue