summaryrefslogtreecommitdiff
path: root/Libraries/LibWeb/Layout
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-06-24 16:11:15 +0200
committerAndreas Kling <kling@serenityos.org>2020-06-24 16:49:51 +0200
commit5d86305a7247032c026899bf5ada39afd2964a89 (patch)
tree8f142c64f70245c65474fdaf6b7c76de1c93430c /Libraries/LibWeb/Layout
parentec466c0385c76213579a9418e32182e316f20cc6 (diff)
downloadserenity-5d86305a7247032c026899bf5ada39afd2964a89.zip
LibWeb: Move height, min-height and max-height into LayoutStyle
Diffstat (limited to 'Libraries/LibWeb/Layout')
-rw-r--r--Libraries/LibWeb/Layout/LayoutBlock.cpp20
-rw-r--r--Libraries/LibWeb/Layout/LayoutNode.cpp3
-rw-r--r--Libraries/LibWeb/Layout/LayoutReplaced.cpp9
-rw-r--r--Libraries/LibWeb/Layout/LayoutStyle.h9
4 files changed, 25 insertions, 16 deletions
diff --git a/Libraries/LibWeb/Layout/LayoutBlock.cpp b/Libraries/LibWeb/Layout/LayoutBlock.cpp
index c66fe3d356..41890ee32a 100644
--- a/Libraries/LibWeb/Layout/LayoutBlock.cpp
+++ b/Libraries/LibWeb/Layout/LayoutBlock.cpp
@@ -670,19 +670,19 @@ void LayoutBlock::place_block_level_non_replaced_element_in_normal_flow(LayoutBl
void LayoutBlock::compute_height()
{
- auto& style = this->specified_style();
+ auto& specified_style = this->specified_style();
+ auto& containing_block = *this->containing_block();
- auto specified_height = style.length_or_fallback(CSS::PropertyID::Height, Length::make_auto(), containing_block()->height());
- auto specified_max_height = style.length_or_fallback(CSS::PropertyID::MaxHeight, Length::make_auto(), containing_block()->height());
+ auto specified_height = style().height().resolved_or_auto(*this, containing_block.height());
+ auto specified_max_height = style().max_height().resolved_or_auto(*this, containing_block.height());
- auto& containing_block = *this->containing_block();
- box_model().margin.top = style.length_or_fallback(CSS::PropertyID::MarginTop, Length::make_px(0), containing_block.width());
- box_model().margin.bottom = style.length_or_fallback(CSS::PropertyID::MarginBottom, Length::make_px(0), containing_block.width());
- box_model().border.top = style.length_or_fallback(CSS::PropertyID::BorderTopWidth, Length::make_px(0));
- box_model().border.bottom = style.length_or_fallback(CSS::PropertyID::BorderBottomWidth, Length::make_px(0));
- box_model().padding.top = style.length_or_fallback(CSS::PropertyID::PaddingTop, Length::make_px(0), containing_block.width());
- box_model().padding.bottom = style.length_or_fallback(CSS::PropertyID::PaddingBottom, Length::make_px(0), containing_block.width());
+ box_model().margin.top = specified_style.length_or_fallback(CSS::PropertyID::MarginTop, Length::make_px(0), containing_block.width());
+ box_model().margin.bottom = specified_style.length_or_fallback(CSS::PropertyID::MarginBottom, Length::make_px(0), containing_block.width());
+ box_model().border.top = specified_style.length_or_fallback(CSS::PropertyID::BorderTopWidth, Length::make_px(0));
+ box_model().border.bottom = specified_style.length_or_fallback(CSS::PropertyID::BorderBottomWidth, Length::make_px(0));
+ box_model().padding.top = specified_style.length_or_fallback(CSS::PropertyID::PaddingTop, Length::make_px(0), containing_block.width());
+ box_model().padding.bottom = specified_style.length_or_fallback(CSS::PropertyID::PaddingBottom, Length::make_px(0), containing_block.width());
if (!specified_height.is_auto()) {
float used_height = specified_height.to_px(*this);
diff --git a/Libraries/LibWeb/Layout/LayoutNode.cpp b/Libraries/LibWeb/Layout/LayoutNode.cpp
index 21dbe49891..6a64a97dba 100644
--- a/Libraries/LibWeb/Layout/LayoutNode.cpp
+++ b/Libraries/LibWeb/Layout/LayoutNode.cpp
@@ -229,6 +229,9 @@ void LayoutNodeWithStyle::apply_style(const StyleProperties& specified_style)
style.set_width(specified_style.length_or_fallback(CSS::PropertyID::Width, {}));
style.set_min_width(specified_style.length_or_fallback(CSS::PropertyID::MinWidth, {}));
style.set_max_width(specified_style.length_or_fallback(CSS::PropertyID::MaxWidth, {}));
+ style.set_height(specified_style.length_or_fallback(CSS::PropertyID::Height, {}));
+ style.set_min_height(specified_style.length_or_fallback(CSS::PropertyID::MinHeight, {}));
+ style.set_max_height(specified_style.length_or_fallback(CSS::PropertyID::MaxHeight, {}));
}
}
diff --git a/Libraries/LibWeb/Layout/LayoutReplaced.cpp b/Libraries/LibWeb/Layout/LayoutReplaced.cpp
index eb17156dff..c9d279a762 100644
--- a/Libraries/LibWeb/Layout/LayoutReplaced.cpp
+++ b/Libraries/LibWeb/Layout/LayoutReplaced.cpp
@@ -46,7 +46,6 @@ float LayoutReplaced::calculate_width() const
// 10.3.2 [Inline,] replaced elements
auto& specified_style = this->specified_style();
- auto auto_value = Length::make_auto();
auto zero_value = Length::make_px(0);
auto& containing_block = *this->containing_block();
@@ -60,7 +59,7 @@ float LayoutReplaced::calculate_width() const
margin_right = zero_value;
auto specified_width = style().width().resolved_or_auto(*this, containing_block.width());
- auto specified_height = specified_style.length_or_fallback(CSS::PropertyID::Height, auto_value, containing_block.height());
+ auto specified_height = style().height().resolved_or_auto(*this, containing_block.height());
// FIXME: Actually compute 'width'
auto computed_width = specified_width;
@@ -98,12 +97,10 @@ float LayoutReplaced::calculate_height() const
{
// 10.6.2 Inline replaced elements, block-level replaced elements in normal flow,
// 'inline-block' replaced elements in normal flow and floating replaced elements
- auto& style = this->specified_style();
- auto auto_value = Length::make_auto();
auto& containing_block = *this->containing_block();
- auto specified_width = style.length_or_fallback(CSS::PropertyID::Width, auto_value, containing_block.width());
- auto specified_height = style.length_or_fallback(CSS::PropertyID::Height, auto_value, containing_block.height());
+ auto specified_width = style().width().resolved_or_auto(*this, containing_block.width());
+ auto specified_height = style().height().resolved_or_auto(*this, containing_block.height());
float used_height = specified_height.to_px(*this);
diff --git a/Libraries/LibWeb/Layout/LayoutStyle.h b/Libraries/LibWeb/Layout/LayoutStyle.h
index 41a0b44ad7..619086d878 100644
--- a/Libraries/LibWeb/Layout/LayoutStyle.h
+++ b/Libraries/LibWeb/Layout/LayoutStyle.h
@@ -39,6 +39,9 @@ public:
const Length& width() const { return m_width; }
const Length& min_width() const { return m_min_width; }
const Length& max_width() const { return m_max_width; }
+ const Length& height() const { return m_height; }
+ const Length& min_height() const { return m_min_height; }
+ const Length& max_height() const { return m_max_height; }
protected:
Optional<int> m_z_index;
@@ -47,6 +50,9 @@ protected:
Length m_width;
Length m_min_width;
Length m_max_width;
+ Length m_height;
+ Length m_min_height;
+ Length m_max_height;
};
class ImmutableLayoutStyle final : public LayoutStyle {
@@ -60,6 +66,9 @@ public:
void set_width(const Length& width) { m_width = width; }
void set_min_width(const Length& width) { m_min_width = width; }
void set_max_width(const Length& width) { m_max_width = width; }
+ void set_height(const Length& height) { m_height = height; }
+ void set_min_height(const Length& height) { m_min_height = height; }
+ void set_max_height(const Length& height) { m_max_height = height; }
};
}