mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 09:35:09 +00:00
LibWeb: Turn BoxModelMetrics into a simple struct
Using getters for this thing was just cumbersome and didn't achieve anything of value so just turn it into a plain struct.
This commit is contained in:
parent
5744dd43c5
commit
f742b245b7
5 changed files with 115 additions and 136 deletions
|
@ -123,23 +123,23 @@ void dump_tree(const LayoutNode& layout_node)
|
||||||
|
|
||||||
// Dump the horizontal box properties
|
// Dump the horizontal box properties
|
||||||
dbgprintf(" [%g+%g+%g %g %g+%g+%g]",
|
dbgprintf(" [%g+%g+%g %g %g+%g+%g]",
|
||||||
layout_box.box_model().margin().left.to_px(layout_box),
|
layout_box.box_model().margin.left.to_px(layout_box),
|
||||||
layout_box.box_model().border().left.to_px(layout_box),
|
layout_box.box_model().border.left.to_px(layout_box),
|
||||||
layout_box.box_model().padding().left.to_px(layout_box),
|
layout_box.box_model().padding.left.to_px(layout_box),
|
||||||
layout_box.width(),
|
layout_box.width(),
|
||||||
layout_box.box_model().padding().right.to_px(layout_box),
|
layout_box.box_model().padding.right.to_px(layout_box),
|
||||||
layout_box.box_model().border().right.to_px(layout_box),
|
layout_box.box_model().border.right.to_px(layout_box),
|
||||||
layout_box.box_model().margin().right.to_px(layout_box));
|
layout_box.box_model().margin.right.to_px(layout_box));
|
||||||
|
|
||||||
// And the vertical box properties
|
// And the vertical box properties
|
||||||
dbgprintf(" [%g+%g+%g %g %g+%g+%g]",
|
dbgprintf(" [%g+%g+%g %g %g+%g+%g]",
|
||||||
layout_box.box_model().margin().top.to_px(layout_box),
|
layout_box.box_model().margin.top.to_px(layout_box),
|
||||||
layout_box.box_model().border().top.to_px(layout_box),
|
layout_box.box_model().border.top.to_px(layout_box),
|
||||||
layout_box.box_model().padding().top.to_px(layout_box),
|
layout_box.box_model().padding.top.to_px(layout_box),
|
||||||
layout_box.height(),
|
layout_box.height(),
|
||||||
layout_box.box_model().padding().bottom.to_px(layout_box),
|
layout_box.box_model().padding.bottom.to_px(layout_box),
|
||||||
layout_box.box_model().border().bottom.to_px(layout_box),
|
layout_box.box_model().border.bottom.to_px(layout_box),
|
||||||
layout_box.box_model().margin().bottom.to_px(layout_box));
|
layout_box.box_model().margin.bottom.to_px(layout_box));
|
||||||
|
|
||||||
dbgprintf("\n");
|
dbgprintf("\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,41 +28,33 @@
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
|
||||||
BoxModelMetrics::BoxModelMetrics()
|
PixelBox BoxModelMetrics::margin_box(const LayoutNode& layout_node) const
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
BoxModelMetrics::~BoxModelMetrics()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
BoxModelMetrics::PixelBox BoxModelMetrics::margin_box(const LayoutNode& layout_node) const
|
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
m_margin.top.to_px(layout_node) + m_border.top.to_px(layout_node) + m_padding.top.to_px(layout_node),
|
margin.top.to_px(layout_node) + border.top.to_px(layout_node) + padding.top.to_px(layout_node),
|
||||||
m_margin.right.to_px(layout_node) + m_border.right.to_px(layout_node) + m_padding.right.to_px(layout_node),
|
margin.right.to_px(layout_node) + border.right.to_px(layout_node) + padding.right.to_px(layout_node),
|
||||||
m_margin.bottom.to_px(layout_node) + m_border.bottom.to_px(layout_node) + m_padding.bottom.to_px(layout_node),
|
margin.bottom.to_px(layout_node) + border.bottom.to_px(layout_node) + padding.bottom.to_px(layout_node),
|
||||||
m_margin.left.to_px(layout_node) + m_border.left.to_px(layout_node) + m_padding.left.to_px(layout_node),
|
margin.left.to_px(layout_node) + border.left.to_px(layout_node) + padding.left.to_px(layout_node),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
BoxModelMetrics::PixelBox BoxModelMetrics::padding_box(const LayoutNode& layout_node) const
|
PixelBox BoxModelMetrics::padding_box(const LayoutNode& layout_node) const
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
m_padding.top.to_px(layout_node),
|
padding.top.to_px(layout_node),
|
||||||
m_padding.right.to_px(layout_node),
|
padding.right.to_px(layout_node),
|
||||||
m_padding.bottom.to_px(layout_node),
|
padding.bottom.to_px(layout_node),
|
||||||
m_padding.left.to_px(layout_node),
|
padding.left.to_px(layout_node),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
BoxModelMetrics::PixelBox BoxModelMetrics::border_box(const LayoutNode& layout_node) const
|
PixelBox BoxModelMetrics::border_box(const LayoutNode& layout_node) const
|
||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
m_border.top.to_px(layout_node) + m_padding.top.to_px(layout_node),
|
border.top.to_px(layout_node) + padding.top.to_px(layout_node),
|
||||||
m_border.right.to_px(layout_node) + m_padding.right.to_px(layout_node),
|
border.right.to_px(layout_node) + padding.right.to_px(layout_node),
|
||||||
m_border.bottom.to_px(layout_node) + m_padding.bottom.to_px(layout_node),
|
border.bottom.to_px(layout_node) + padding.bottom.to_px(layout_node),
|
||||||
m_border.left.to_px(layout_node) + m_padding.left.to_px(layout_node),
|
border.left.to_px(layout_node) + padding.left.to_px(layout_node),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,37 +31,24 @@
|
||||||
|
|
||||||
namespace Web {
|
namespace Web {
|
||||||
|
|
||||||
class BoxModelMetrics {
|
struct PixelBox {
|
||||||
|
float top;
|
||||||
|
float right;
|
||||||
|
float bottom;
|
||||||
|
float left;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct BoxModelMetrics {
|
||||||
public:
|
public:
|
||||||
BoxModelMetrics();
|
LengthBox margin;
|
||||||
~BoxModelMetrics();
|
LengthBox padding;
|
||||||
|
LengthBox border;
|
||||||
LengthBox& margin() { return m_margin; }
|
LengthBox offset;
|
||||||
LengthBox& padding() { return m_padding; }
|
|
||||||
LengthBox& border() { return m_border; }
|
|
||||||
LengthBox& offset() { return m_offset; }
|
|
||||||
|
|
||||||
const LengthBox& margin() const { return m_margin; }
|
|
||||||
const LengthBox& padding() const { return m_padding; }
|
|
||||||
const LengthBox& border() const { return m_border; }
|
|
||||||
const LengthBox& offset() const { return m_offset; }
|
|
||||||
|
|
||||||
struct PixelBox {
|
|
||||||
float top;
|
|
||||||
float right;
|
|
||||||
float bottom;
|
|
||||||
float left;
|
|
||||||
};
|
|
||||||
|
|
||||||
PixelBox margin_box(const LayoutNode&) const;
|
PixelBox margin_box(const LayoutNode&) const;
|
||||||
PixelBox padding_box(const LayoutNode&) const;
|
PixelBox padding_box(const LayoutNode&) const;
|
||||||
PixelBox border_box(const LayoutNode&) const;
|
PixelBox border_box(const LayoutNode&) const;
|
||||||
|
|
||||||
private:
|
|
||||||
LengthBox m_margin;
|
|
||||||
LengthBox m_padding;
|
|
||||||
LengthBox m_border;
|
|
||||||
LengthBox m_offset;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,53 +74,53 @@ void LayoutBlock::layout_absolutely_positioned_descendant(LayoutBox& box)
|
||||||
|
|
||||||
auto specified_width = style.length_or_fallback(CSS::PropertyID::Width, Length::make_auto(), width());
|
auto specified_width = style.length_or_fallback(CSS::PropertyID::Width, Length::make_auto(), width());
|
||||||
|
|
||||||
box_model.margin().top = style.length_or_fallback(CSS::PropertyID::MarginTop, Length::make_auto(), height());
|
box_model.margin.top = style.length_or_fallback(CSS::PropertyID::MarginTop, Length::make_auto(), height());
|
||||||
box_model.margin().right = style.length_or_fallback(CSS::PropertyID::MarginRight, Length::make_auto(), width());
|
box_model.margin.right = style.length_or_fallback(CSS::PropertyID::MarginRight, Length::make_auto(), width());
|
||||||
box_model.margin().bottom = style.length_or_fallback(CSS::PropertyID::MarginBottom, Length::make_auto(), height());
|
box_model.margin.bottom = style.length_or_fallback(CSS::PropertyID::MarginBottom, Length::make_auto(), height());
|
||||||
box_model.margin().left = style.length_or_fallback(CSS::PropertyID::MarginLeft, Length::make_auto(), width());
|
box_model.margin.left = style.length_or_fallback(CSS::PropertyID::MarginLeft, Length::make_auto(), width());
|
||||||
|
|
||||||
box_model.offset().top = style.length_or_fallback(CSS::PropertyID::Top, Length::make_auto(), height());
|
box_model.offset.top = style.length_or_fallback(CSS::PropertyID::Top, Length::make_auto(), height());
|
||||||
box_model.offset().right = style.length_or_fallback(CSS::PropertyID::Right, Length::make_auto(), width());
|
box_model.offset.right = style.length_or_fallback(CSS::PropertyID::Right, Length::make_auto(), width());
|
||||||
box_model.offset().bottom = style.length_or_fallback(CSS::PropertyID::Bottom, Length::make_auto(), height());
|
box_model.offset.bottom = style.length_or_fallback(CSS::PropertyID::Bottom, Length::make_auto(), height());
|
||||||
box_model.offset().left = style.length_or_fallback(CSS::PropertyID::Left, Length::make_auto(), width());
|
box_model.offset.left = style.length_or_fallback(CSS::PropertyID::Left, Length::make_auto(), width());
|
||||||
|
|
||||||
if (box_model.offset().left.is_auto() && specified_width.is_auto() && box_model.offset().right.is_auto()) {
|
if (box_model.offset.left.is_auto() && specified_width.is_auto() && box_model.offset.right.is_auto()) {
|
||||||
if (box_model.margin().left.is_auto())
|
if (box_model.margin.left.is_auto())
|
||||||
box_model.margin().left = zero_value;
|
box_model.margin.left = zero_value;
|
||||||
if (box_model.margin().right.is_auto())
|
if (box_model.margin.right.is_auto())
|
||||||
box_model.margin().right = zero_value;
|
box_model.margin.right = zero_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
Gfx::FloatPoint used_offset;
|
Gfx::FloatPoint used_offset;
|
||||||
|
|
||||||
float x_offset = box_model.offset().left.to_px(box)
|
float x_offset = box_model.offset.left.to_px(box)
|
||||||
+ box_model.border_box(box).left
|
+ box_model.border_box(box).left
|
||||||
- box_model.offset().right.to_px(box)
|
- box_model.offset.right.to_px(box)
|
||||||
- box_model.border_box(box).right;
|
- box_model.border_box(box).right;
|
||||||
|
|
||||||
float y_offset = box_model.offset().top.to_px(box)
|
float y_offset = box_model.offset.top.to_px(box)
|
||||||
+ box_model.border_box(box).top
|
+ box_model.border_box(box).top
|
||||||
- box_model.offset().bottom.to_px(box)
|
- box_model.offset.bottom.to_px(box)
|
||||||
- box_model.border_box(box).bottom;
|
- box_model.border_box(box).bottom;
|
||||||
|
|
||||||
bool has_left_side_constraints = !box_model.offset().left.is_auto() || !box_model.margin().left.is_auto();
|
bool has_left_side_constraints = !box_model.offset.left.is_auto() || !box_model.margin.left.is_auto();
|
||||||
bool has_right_side_constraints = !box_model.offset().right.is_auto() || !box_model.margin().right.is_auto();
|
bool has_right_side_constraints = !box_model.offset.right.is_auto() || !box_model.margin.right.is_auto();
|
||||||
|
|
||||||
if (has_left_side_constraints && has_right_side_constraints) {
|
if (has_left_side_constraints && has_right_side_constraints) {
|
||||||
// If both 'left' and 'right' are set, we will have stretched the width to accomodate both.
|
// If both 'left' and 'right' are set, we will have stretched the width to accomodate both.
|
||||||
x_offset += box_model.offset().right.to_px(box);
|
x_offset += box_model.offset.right.to_px(box);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has_left_side_constraints) {
|
if (has_left_side_constraints) {
|
||||||
used_offset.set_x(x_offset + box_model.margin().left.to_px(box));
|
used_offset.set_x(x_offset + box_model.margin.left.to_px(box));
|
||||||
} else if (has_right_side_constraints) {
|
} else if (has_right_side_constraints) {
|
||||||
used_offset.set_x(width() + x_offset - box.width() - box_model.margin().right.to_px(box));
|
used_offset.set_x(width() + x_offset - box.width() - box_model.margin.right.to_px(box));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!box_model.offset().top.is_auto()) {
|
if (!box_model.offset.top.is_auto()) {
|
||||||
used_offset.set_y(y_offset + box_model.margin().top.to_px(box));
|
used_offset.set_y(y_offset + box_model.margin.top.to_px(box));
|
||||||
} else if (!box_model.offset().bottom.is_auto()) {
|
} else if (!box_model.offset.bottom.is_auto()) {
|
||||||
used_offset.set_y(height() + y_offset - box.height() - box_model.margin().bottom.to_px(box));
|
used_offset.set_y(height() + y_offset - box.height() - box_model.margin.bottom.to_px(box));
|
||||||
}
|
}
|
||||||
|
|
||||||
box.set_offset(used_offset);
|
box.set_offset(used_offset);
|
||||||
|
@ -411,12 +411,12 @@ void LayoutBlock::compute_width_for_absolutely_positioned_block()
|
||||||
|
|
||||||
set_width(used_width.to_px(*this));
|
set_width(used_width.to_px(*this));
|
||||||
|
|
||||||
box_model().margin().left = margin_left;
|
box_model().margin.left = margin_left;
|
||||||
box_model().margin().right = margin_right;
|
box_model().margin.right = margin_right;
|
||||||
box_model().border().left = border_left;
|
box_model().border.left = border_left;
|
||||||
box_model().border().right = border_right;
|
box_model().border.right = border_right;
|
||||||
box_model().padding().left = padding_left;
|
box_model().padding.left = padding_left;
|
||||||
box_model().padding().right = padding_right;
|
box_model().padding.right = padding_right;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayoutBlock::compute_width()
|
void LayoutBlock::compute_width()
|
||||||
|
@ -550,12 +550,12 @@ void LayoutBlock::compute_width()
|
||||||
}
|
}
|
||||||
|
|
||||||
set_width(used_width.to_px(*this));
|
set_width(used_width.to_px(*this));
|
||||||
box_model().margin().left = margin_left;
|
box_model().margin.left = margin_left;
|
||||||
box_model().margin().right = margin_right;
|
box_model().margin.right = margin_right;
|
||||||
box_model().border().left = border_left;
|
box_model().border.left = border_left;
|
||||||
box_model().border().right = border_right;
|
box_model().border.right = border_right;
|
||||||
box_model().padding().left = padding_left;
|
box_model().padding.left = padding_left;
|
||||||
box_model().padding().right = padding_right;
|
box_model().padding.right = padding_right;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LayoutBlock::place_block_level_replaced_element_in_normal_flow(LayoutReplaced& box)
|
void LayoutBlock::place_block_level_replaced_element_in_normal_flow(LayoutReplaced& box)
|
||||||
|
@ -566,19 +566,19 @@ void LayoutBlock::place_block_level_replaced_element_in_normal_flow(LayoutReplac
|
||||||
auto& containing_block = *this;
|
auto& containing_block = *this;
|
||||||
auto& replaced_element_box_model = box.box_model();
|
auto& replaced_element_box_model = box.box_model();
|
||||||
|
|
||||||
replaced_element_box_model.margin().top = style.length_or_fallback(CSS::PropertyID::MarginTop, zero_value, containing_block.width());
|
replaced_element_box_model.margin.top = style.length_or_fallback(CSS::PropertyID::MarginTop, zero_value, containing_block.width());
|
||||||
replaced_element_box_model.margin().bottom = style.length_or_fallback(CSS::PropertyID::MarginBottom, zero_value, containing_block.width());
|
replaced_element_box_model.margin.bottom = style.length_or_fallback(CSS::PropertyID::MarginBottom, zero_value, containing_block.width());
|
||||||
replaced_element_box_model.border().top = style.length_or_fallback(CSS::PropertyID::BorderTopWidth, zero_value);
|
replaced_element_box_model.border.top = style.length_or_fallback(CSS::PropertyID::BorderTopWidth, zero_value);
|
||||||
replaced_element_box_model.border().bottom = style.length_or_fallback(CSS::PropertyID::BorderBottomWidth, zero_value);
|
replaced_element_box_model.border.bottom = style.length_or_fallback(CSS::PropertyID::BorderBottomWidth, zero_value);
|
||||||
replaced_element_box_model.padding().top = style.length_or_fallback(CSS::PropertyID::PaddingTop, zero_value, containing_block.width());
|
replaced_element_box_model.padding.top = style.length_or_fallback(CSS::PropertyID::PaddingTop, zero_value, containing_block.width());
|
||||||
replaced_element_box_model.padding().bottom = style.length_or_fallback(CSS::PropertyID::PaddingBottom, zero_value, containing_block.width());
|
replaced_element_box_model.padding.bottom = style.length_or_fallback(CSS::PropertyID::PaddingBottom, zero_value, containing_block.width());
|
||||||
|
|
||||||
float x = replaced_element_box_model.margin().left.to_px(*this)
|
float x = replaced_element_box_model.margin.left.to_px(*this)
|
||||||
+ replaced_element_box_model.border().left.to_px(*this)
|
+ replaced_element_box_model.border.left.to_px(*this)
|
||||||
+ replaced_element_box_model.padding().left.to_px(*this)
|
+ replaced_element_box_model.padding.left.to_px(*this)
|
||||||
+ replaced_element_box_model.offset().left.to_px(*this);
|
+ replaced_element_box_model.offset.left.to_px(*this);
|
||||||
|
|
||||||
float y = replaced_element_box_model.margin_box(*this).top + box_model().offset().top.to_px(*this);
|
float y = replaced_element_box_model.margin_box(*this).top + box_model().offset.top.to_px(*this);
|
||||||
|
|
||||||
box.set_offset(x, y);
|
box.set_offset(x, y);
|
||||||
}
|
}
|
||||||
|
@ -621,24 +621,24 @@ void LayoutBlock::place_block_level_non_replaced_element_in_normal_flow(LayoutBl
|
||||||
auto& containing_block = *this;
|
auto& containing_block = *this;
|
||||||
auto& box = block.box_model();
|
auto& box = block.box_model();
|
||||||
|
|
||||||
box.margin().top = style.length_or_fallback(CSS::PropertyID::MarginTop, zero_value, containing_block.width());
|
box.margin.top = style.length_or_fallback(CSS::PropertyID::MarginTop, zero_value, containing_block.width());
|
||||||
box.margin().bottom = style.length_or_fallback(CSS::PropertyID::MarginBottom, zero_value, containing_block.width());
|
box.margin.bottom = style.length_or_fallback(CSS::PropertyID::MarginBottom, zero_value, containing_block.width());
|
||||||
box.border().top = style.length_or_fallback(CSS::PropertyID::BorderTopWidth, zero_value);
|
box.border.top = style.length_or_fallback(CSS::PropertyID::BorderTopWidth, zero_value);
|
||||||
box.border().bottom = style.length_or_fallback(CSS::PropertyID::BorderBottomWidth, zero_value);
|
box.border.bottom = style.length_or_fallback(CSS::PropertyID::BorderBottomWidth, zero_value);
|
||||||
box.padding().top = style.length_or_fallback(CSS::PropertyID::PaddingTop, zero_value, containing_block.width());
|
box.padding.top = style.length_or_fallback(CSS::PropertyID::PaddingTop, zero_value, containing_block.width());
|
||||||
box.padding().bottom = style.length_or_fallback(CSS::PropertyID::PaddingBottom, zero_value, containing_block.width());
|
box.padding.bottom = style.length_or_fallback(CSS::PropertyID::PaddingBottom, zero_value, containing_block.width());
|
||||||
|
|
||||||
float x = box.margin().left.to_px(*this)
|
float x = box.margin.left.to_px(*this)
|
||||||
+ box.border().left.to_px(*this)
|
+ box.border.left.to_px(*this)
|
||||||
+ box.padding().left.to_px(*this)
|
+ box.padding.left.to_px(*this)
|
||||||
+ box.offset().left.to_px(*this);
|
+ box.offset.left.to_px(*this);
|
||||||
|
|
||||||
if (text_align() == CSS::TextAlign::VendorSpecificCenter) {
|
if (text_align() == CSS::TextAlign::VendorSpecificCenter) {
|
||||||
x = (containing_block.width() / 2) - block.width() / 2;
|
x = (containing_block.width() / 2) - block.width() / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
float y = box.margin_box(*this).top
|
float y = box.margin_box(*this).top
|
||||||
+ box.offset().top.to_px(*this);
|
+ box.offset.top.to_px(*this);
|
||||||
|
|
||||||
auto* relevant_sibling = block.previous_sibling();
|
auto* relevant_sibling = block.previous_sibling();
|
||||||
while (relevant_sibling != nullptr) {
|
while (relevant_sibling != nullptr) {
|
||||||
|
@ -652,8 +652,8 @@ void LayoutBlock::place_block_level_non_replaced_element_in_normal_flow(LayoutBl
|
||||||
y += relevant_sibling->effective_offset().y() + relevant_sibling->height();
|
y += relevant_sibling->effective_offset().y() + relevant_sibling->height();
|
||||||
|
|
||||||
// Collapse top margin with bottom margin of previous sibling if necessary
|
// Collapse top margin with bottom margin of previous sibling if necessary
|
||||||
float previous_sibling_margin_bottom = sibling_box.margin().bottom.to_px(*relevant_sibling);
|
float previous_sibling_margin_bottom = sibling_box.margin.bottom.to_px(*relevant_sibling);
|
||||||
float my_margin_top = box.margin().top.to_px(*this);
|
float my_margin_top = box.margin.top.to_px(*this);
|
||||||
|
|
||||||
if (my_margin_top < 0 || previous_sibling_margin_bottom < 0) {
|
if (my_margin_top < 0 || previous_sibling_margin_bottom < 0) {
|
||||||
// Negative margins present.
|
// Negative margins present.
|
||||||
|
@ -679,12 +679,12 @@ void LayoutBlock::compute_height()
|
||||||
|
|
||||||
auto& containing_block = *this->containing_block();
|
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.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().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.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().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.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().padding.bottom = style.length_or_fallback(CSS::PropertyID::PaddingBottom, Length::make_px(0), containing_block.width());
|
||||||
|
|
||||||
if (!specified_height.is_auto()) {
|
if (!specified_height.is_auto()) {
|
||||||
float used_height = specified_height.to_px(*this);
|
float used_height = specified_height.to_px(*this);
|
||||||
|
|
|
@ -196,10 +196,10 @@ void LayoutBox::paint(PaintContext& context, PaintPhase phase)
|
||||||
context.painter().translate(context.scroll_offset());
|
context.painter().translate(context.scroll_offset());
|
||||||
|
|
||||||
Gfx::FloatRect padded_rect;
|
Gfx::FloatRect padded_rect;
|
||||||
padded_rect.set_x(absolute_x() - box_model().padding().left.to_px(*this));
|
padded_rect.set_x(absolute_x() - box_model().padding.left.to_px(*this));
|
||||||
padded_rect.set_width(width() + box_model().padding().left.to_px(*this) + box_model().padding().right.to_px(*this));
|
padded_rect.set_width(width() + box_model().padding.left.to_px(*this) + box_model().padding.right.to_px(*this));
|
||||||
padded_rect.set_y(absolute_y() - box_model().padding().top.to_px(*this));
|
padded_rect.set_y(absolute_y() - box_model().padding.top.to_px(*this));
|
||||||
padded_rect.set_height(height() + box_model().padding().top.to_px(*this) + box_model().padding().bottom.to_px(*this));
|
padded_rect.set_height(height() + box_model().padding.top.to_px(*this) + box_model().padding.bottom.to_px(*this));
|
||||||
|
|
||||||
if (phase == PaintPhase::Background && !is_body()) {
|
if (phase == PaintPhase::Background && !is_body()) {
|
||||||
// FIXME: We should paint the body here too, but that currently happens at the view layer.
|
// FIXME: We should paint the body here too, but that currently happens at the view layer.
|
||||||
|
@ -219,10 +219,10 @@ void LayoutBox::paint(PaintContext& context, PaintPhase phase)
|
||||||
|
|
||||||
if (phase == PaintPhase::Border) {
|
if (phase == PaintPhase::Border) {
|
||||||
Gfx::FloatRect bordered_rect;
|
Gfx::FloatRect bordered_rect;
|
||||||
bordered_rect.set_x(padded_rect.x() - box_model().border().left.to_px(*this));
|
bordered_rect.set_x(padded_rect.x() - box_model().border.left.to_px(*this));
|
||||||
bordered_rect.set_width(padded_rect.width() + box_model().border().left.to_px(*this) + box_model().border().right.to_px(*this));
|
bordered_rect.set_width(padded_rect.width() + box_model().border.left.to_px(*this) + box_model().border.right.to_px(*this));
|
||||||
bordered_rect.set_y(padded_rect.y() - box_model().border().top.to_px(*this));
|
bordered_rect.set_y(padded_rect.y() - box_model().border.top.to_px(*this));
|
||||||
bordered_rect.set_height(padded_rect.height() + box_model().border().top.to_px(*this) + box_model().border().bottom.to_px(*this));
|
bordered_rect.set_height(padded_rect.height() + box_model().border.top.to_px(*this) + box_model().border.bottom.to_px(*this));
|
||||||
|
|
||||||
paint_border(context, Edge::Left, bordered_rect, CSS::PropertyID::BorderLeftStyle, CSS::PropertyID::BorderLeftColor, CSS::PropertyID::BorderLeftWidth);
|
paint_border(context, Edge::Left, bordered_rect, CSS::PropertyID::BorderLeftStyle, CSS::PropertyID::BorderLeftColor, CSS::PropertyID::BorderLeftWidth);
|
||||||
paint_border(context, Edge::Right, bordered_rect, CSS::PropertyID::BorderRightStyle, CSS::PropertyID::BorderRightColor, CSS::PropertyID::BorderRightWidth);
|
paint_border(context, Edge::Right, bordered_rect, CSS::PropertyID::BorderRightStyle, CSS::PropertyID::BorderRightColor, CSS::PropertyID::BorderRightWidth);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue