mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:37:35 +00:00
LibWeb: Add support for 'definite size' determination
This is pretty naive and there are more nuances in the spec but should be enough for now.
This commit is contained in:
parent
ead864acf3
commit
27704f5f9e
2 changed files with 18 additions and 1 deletions
|
@ -264,8 +264,13 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& specified_style)
|
||||||
computed_values.set_flex_wrap(flex_wrap.value());
|
computed_values.set_flex_wrap(flex_wrap.value());
|
||||||
|
|
||||||
auto position = specified_style.position();
|
auto position = specified_style.position();
|
||||||
if (position.has_value())
|
if (position.has_value()) {
|
||||||
computed_values.set_position(position.value());
|
computed_values.set_position(position.value());
|
||||||
|
if (position.value() == CSS::Position::Absolute) {
|
||||||
|
m_has_definite_width = true;
|
||||||
|
m_has_definite_height = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto text_align = specified_style.text_align();
|
auto text_align = specified_style.text_align();
|
||||||
if (text_align.has_value())
|
if (text_align.has_value())
|
||||||
|
@ -310,9 +315,15 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& specified_style)
|
||||||
computed_values.set_background_color(specified_style.color_or_fallback(CSS::PropertyID::BackgroundColor, document(), Color::Transparent));
|
computed_values.set_background_color(specified_style.color_or_fallback(CSS::PropertyID::BackgroundColor, document(), Color::Transparent));
|
||||||
|
|
||||||
computed_values.set_z_index(specified_style.z_index());
|
computed_values.set_z_index(specified_style.z_index());
|
||||||
|
|
||||||
|
if (auto width = specified_style.property(CSS::PropertyID::Width); width.has_value())
|
||||||
|
m_has_definite_width = true;
|
||||||
computed_values.set_width(specified_style.length_or_fallback(CSS::PropertyID::Width, {}));
|
computed_values.set_width(specified_style.length_or_fallback(CSS::PropertyID::Width, {}));
|
||||||
computed_values.set_min_width(specified_style.length_or_fallback(CSS::PropertyID::MinWidth, {}));
|
computed_values.set_min_width(specified_style.length_or_fallback(CSS::PropertyID::MinWidth, {}));
|
||||||
computed_values.set_max_width(specified_style.length_or_fallback(CSS::PropertyID::MaxWidth, {}));
|
computed_values.set_max_width(specified_style.length_or_fallback(CSS::PropertyID::MaxWidth, {}));
|
||||||
|
|
||||||
|
if (auto height = specified_style.property(CSS::PropertyID::Height); height.has_value())
|
||||||
|
m_has_definite_height = true;
|
||||||
computed_values.set_height(specified_style.length_or_fallback(CSS::PropertyID::Height, {}));
|
computed_values.set_height(specified_style.length_or_fallback(CSS::PropertyID::Height, {}));
|
||||||
computed_values.set_min_height(specified_style.length_or_fallback(CSS::PropertyID::MinHeight, {}));
|
computed_values.set_min_height(specified_style.length_or_fallback(CSS::PropertyID::MinHeight, {}));
|
||||||
computed_values.set_max_height(specified_style.length_or_fallback(CSS::PropertyID::MaxHeight, {}));
|
computed_values.set_max_height(specified_style.length_or_fallback(CSS::PropertyID::MaxHeight, {}));
|
||||||
|
|
|
@ -204,6 +204,9 @@ public:
|
||||||
|
|
||||||
NonnullRefPtr<NodeWithStyle> create_anonymous_wrapper() const;
|
NonnullRefPtr<NodeWithStyle> create_anonymous_wrapper() const;
|
||||||
|
|
||||||
|
bool has_definite_height() const { return m_has_definite_height; }
|
||||||
|
bool has_definite_width() const { return m_has_definite_width; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
NodeWithStyle(DOM::Document&, DOM::Node*, NonnullRefPtr<CSS::StyleProperties>);
|
NodeWithStyle(DOM::Document&, DOM::Node*, NonnullRefPtr<CSS::StyleProperties>);
|
||||||
NodeWithStyle(DOM::Document&, DOM::Node*, CSS::ComputedValues);
|
NodeWithStyle(DOM::Document&, DOM::Node*, CSS::ComputedValues);
|
||||||
|
@ -216,6 +219,9 @@ private:
|
||||||
RefPtr<CSS::ImageStyleValue> m_background_image;
|
RefPtr<CSS::ImageStyleValue> m_background_image;
|
||||||
|
|
||||||
CSS::Position m_position;
|
CSS::Position m_position;
|
||||||
|
|
||||||
|
bool m_has_definite_height { false };
|
||||||
|
bool m_has_definite_width { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
class NodeWithStyleAndBoxModelMetrics : public NodeWithStyle {
|
class NodeWithStyleAndBoxModelMetrics : public NodeWithStyle {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue