1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:07:35 +00:00

LibWeb: Move CSS classes into the Web::CSS namespace

This commit is contained in:
Andreas Kling 2020-07-26 20:01:35 +02:00
parent 3e389f4cdc
commit 1f008c95b6
100 changed files with 358 additions and 366 deletions

View file

@ -40,15 +40,14 @@ struct PixelBox {
struct BoxModelMetrics {
public:
LengthBox margin;
LengthBox padding;
LengthBox border;
LengthBox offset;
CSS::LengthBox margin;
CSS::LengthBox padding;
CSS::LengthBox border;
CSS::LengthBox offset;
PixelBox margin_box(const LayoutNode&) const;
PixelBox padding_box(const LayoutNode&) const;
PixelBox border_box(const LayoutNode&) const;
};
}

View file

@ -38,7 +38,7 @@
namespace Web {
LayoutBlock::LayoutBlock(DOM::Document& document, const DOM::Node* node, NonnullRefPtr<StyleProperties> style)
LayoutBlock::LayoutBlock(DOM::Document& document, const DOM::Node* node, NonnullRefPtr<CSS::StyleProperties> style)
: LayoutBox(document, node, move(style))
{
}
@ -69,7 +69,7 @@ void LayoutBlock::layout_absolutely_positioned_descendant(LayoutBox& box)
{
box.layout(LayoutMode::Default);
auto& box_model = box.box_model();
auto zero_value = Length::make_px(0);
auto zero_value = CSS::Length::make_px(0);
auto specified_width = box.style().width().resolved_or_auto(box, width());
@ -78,10 +78,10 @@ void LayoutBlock::layout_absolutely_positioned_descendant(LayoutBox& box)
box_model.margin.right = box.style().margin().right.resolved_or_auto(box, width());
box_model.margin.bottom = box.style().margin().bottom.resolved_or_auto(box, height());
box_model.border.left = Length::make_px(box.style().border_left().width);
box_model.border.right = Length::make_px(box.style().border_right().width);
box_model.border.top = Length::make_px(box.style().border_top().width);
box_model.border.bottom = Length::make_px(box.style().border_bottom().width);
box_model.border.left = CSS::Length::make_px(box.style().border_left().width);
box_model.border.right = CSS::Length::make_px(box.style().border_right().width);
box_model.border.top = CSS::Length::make_px(box.style().border_top().width);
box_model.border.bottom = CSS::Length::make_px(box.style().border_bottom().width);
box_model.offset.left = box.style().offset().left.resolved_or_auto(box, width());
box_model.offset.top = box.style().offset().top.resolved_or_auto(box, height());
@ -283,10 +283,10 @@ void LayoutBlock::layout_inline_children(LayoutMode layout_mode)
void LayoutBlock::compute_width_for_absolutely_positioned_block()
{
auto& containing_block = *this->containing_block();
auto zero_value = Length::make_px(0);
auto zero_value = CSS::Length::make_px(0);
auto margin_left = Length::make_auto();
auto margin_right = Length::make_auto();
auto margin_left = CSS::Length::make_auto();
auto margin_right = CSS::Length::make_auto();
const auto border_left = style().border_left().width;
const auto border_right = style().border_right().width;
const auto padding_left = style().padding().left.resolved(zero_value, *this, containing_block.width());
@ -301,29 +301,29 @@ void LayoutBlock::compute_width_for_absolutely_positioned_block()
auto width = a_width;
auto solve_for_left = [&] {
return Length(containing_block.width() - margin_left.to_px(*this) - border_left - padding_left.to_px(*this) - width.to_px(*this) - padding_right.to_px(*this) - border_right - margin_right.to_px(*this) - right.to_px(*this), Length::Type::Px);
return CSS::Length(containing_block.width() - margin_left.to_px(*this) - border_left - padding_left.to_px(*this) - width.to_px(*this) - padding_right.to_px(*this) - border_right - margin_right.to_px(*this) - right.to_px(*this), CSS::Length::Type::Px);
};
auto solve_for_width = [&] {
return Length(containing_block.width() - left.to_px(*this) - margin_left.to_px(*this) - border_left - padding_left.to_px(*this) - padding_right.to_px(*this) - border_right - margin_right.to_px(*this) - right.to_px(*this), Length::Type::Px);
return CSS::Length(containing_block.width() - left.to_px(*this) - margin_left.to_px(*this) - border_left - padding_left.to_px(*this) - padding_right.to_px(*this) - border_right - margin_right.to_px(*this) - right.to_px(*this), CSS::Length::Type::Px);
};
auto solve_for_right = [&] {
return Length(containing_block.width() - left.to_px(*this) - margin_left.to_px(*this) - border_left - padding_left.to_px(*this) - width.to_px(*this) - padding_right.to_px(*this) - border_right - margin_right.to_px(*this), Length::Type::Px);
return CSS::Length(containing_block.width() - left.to_px(*this) - margin_left.to_px(*this) - border_left - padding_left.to_px(*this) - width.to_px(*this) - padding_right.to_px(*this) - border_right - margin_right.to_px(*this), CSS::Length::Type::Px);
};
// If all three of 'left', 'width', and 'right' are 'auto':
if (left.is_auto() && width.is_auto() && right.is_auto()) {
// First set any 'auto' values for 'margin-left' and 'margin-right' to 0.
if (margin_left.is_auto())
margin_left = Length::make_px(0);
margin_left = CSS::Length::make_px(0);
if (margin_right.is_auto())
margin_right = Length::make_px(0);
margin_right = CSS::Length::make_px(0);
// Then, if the 'direction' property of the element establishing the static-position containing block
// is 'ltr' set 'left' to the static position and apply rule number three below;
// otherwise, set 'right' to the static position and apply rule number one below.
// FIXME: This is very hackish.
left = Length::make_px(0);
left = CSS::Length::make_px(0);
goto Rule3;
}
@ -333,9 +333,9 @@ void LayoutBlock::compute_width_for_absolutely_positioned_block()
}
if (margin_left.is_auto())
margin_left = Length::make_px(0);
margin_left = CSS::Length::make_px(0);
if (margin_right.is_auto())
margin_right = Length::make_px(0);
margin_right = CSS::Length::make_px(0);
// 1. 'left' and 'width' are 'auto' and 'right' is not 'auto',
// then the width is shrink-to-fit. Then solve for 'left'
@ -343,7 +343,7 @@ void LayoutBlock::compute_width_for_absolutely_positioned_block()
auto result = calculate_shrink_to_fit_width();
solve_for_left();
auto available_width = solve_for_width();
width = Length(min(max(result.preferred_minimum_width, available_width.to_px(*this)), result.preferred_width), Length::Type::Px);
width = CSS::Length(min(max(result.preferred_minimum_width, available_width.to_px(*this)), result.preferred_width), CSS::Length::Type::Px);
}
// 2. 'left' and 'right' are 'auto' and 'width' is not 'auto',
@ -365,7 +365,7 @@ void LayoutBlock::compute_width_for_absolutely_positioned_block()
auto result = calculate_shrink_to_fit_width();
right = solve_for_right();
auto available_width = solve_for_width();
width = Length(min(max(result.preferred_minimum_width, available_width.to_px(*this)), result.preferred_width), Length::Type::Px);
width = CSS::Length(min(max(result.preferred_minimum_width, available_width.to_px(*this)), result.preferred_width), CSS::Length::Type::Px);
}
// 4. 'left' is 'auto', 'width' and 'right' are not 'auto', then solve for 'left'
@ -413,8 +413,8 @@ void LayoutBlock::compute_width_for_absolutely_positioned_block()
box_model().margin.left = margin_left;
box_model().margin.right = margin_right;
box_model().border.left = Length::make_px(border_left);
box_model().border.right = Length::make_px(border_right);
box_model().border.left = CSS::Length::make_px(border_left);
box_model().border.right = CSS::Length::make_px(border_right);
box_model().padding.left = padding_left;
box_model().padding.right = padding_right;
}
@ -433,15 +433,15 @@ void LayoutBlock::compute_width()
float width_of_containing_block = this->width_of_logical_containing_block();
auto zero_value = Length::make_px(0);
auto zero_value = CSS::Length::make_px(0);
auto margin_left = Length::make_auto();
auto margin_right = Length::make_auto();
auto margin_left = CSS::Length::make_auto();
auto margin_right = CSS::Length::make_auto();
const auto padding_left = style().padding().left.resolved_or_zero(*this, width_of_containing_block);
const auto padding_right = style().padding().right.resolved_or_zero(*this, width_of_containing_block);
auto try_compute_width = [&](const auto& a_width) {
Length width = a_width;
CSS::Length width = a_width;
margin_left = style().margin().left.resolved_or_zero(*this, width_of_containing_block);
margin_right = style().margin().right.resolved_or_zero(*this, width_of_containing_block);
@ -473,20 +473,20 @@ void LayoutBlock::compute_width()
if (margin_right.is_auto())
margin_right = zero_value;
if (underflow_px >= 0) {
width = Length(underflow_px, Length::Type::Px);
width = CSS::Length(underflow_px, CSS::Length::Type::Px);
} else {
width = zero_value;
margin_right = Length(margin_right.to_px(*this) + underflow_px, Length::Type::Px);
margin_right = CSS::Length(margin_right.to_px(*this) + underflow_px, CSS::Length::Type::Px);
}
} else {
if (!margin_left.is_auto() && !margin_right.is_auto()) {
margin_right = Length(margin_right.to_px(*this) + underflow_px, Length::Type::Px);
margin_right = CSS::Length(margin_right.to_px(*this) + underflow_px, CSS::Length::Type::Px);
} else if (!margin_left.is_auto() && margin_right.is_auto()) {
margin_right = Length(underflow_px, Length::Type::Px);
margin_right = CSS::Length(underflow_px, CSS::Length::Type::Px);
} else if (margin_left.is_auto() && !margin_right.is_auto()) {
margin_left = Length(underflow_px, Length::Type::Px);
margin_left = CSS::Length(underflow_px, CSS::Length::Type::Px);
} else { // margin_left.is_auto() && margin_right.is_auto()
auto half_of_the_underflow = Length(underflow_px / 2, Length::Type::Px);
auto half_of_the_underflow = CSS::Length(underflow_px / 2, CSS::Length::Type::Px);
margin_left = half_of_the_underflow;
margin_right = half_of_the_underflow;
}
@ -514,7 +514,7 @@ void LayoutBlock::compute_width()
auto result = calculate_shrink_to_fit_width();
// Then the shrink-to-fit width is: min(max(preferred minimum width, available width), preferred width).
width = Length(min(max(result.preferred_minimum_width, available_width), result.preferred_width), Length::Type::Px);
width = CSS::Length(min(max(result.preferred_minimum_width, available_width), result.preferred_width), CSS::Length::Type::Px);
}
}
@ -547,8 +547,8 @@ void LayoutBlock::compute_width()
set_width(used_width.to_px(*this));
box_model().margin.left = margin_left;
box_model().margin.right = margin_right;
box_model().border.left = Length::make_px(style().border_left().width);
box_model().border.right = Length::make_px(style().border_right().width);
box_model().border.left = CSS::Length::make_px(style().border_left().width);
box_model().border.right = CSS::Length::make_px(style().border_right().width);
box_model().padding.left = padding_left;
box_model().padding.right = padding_right;
}
@ -561,8 +561,8 @@ void LayoutBlock::place_block_level_replaced_element_in_normal_flow(LayoutReplac
replaced_element_box_model.margin.top = box.style().margin().top.resolved_or_zero(*this, containing_block.width());
replaced_element_box_model.margin.bottom = box.style().margin().bottom.resolved_or_zero(*this, containing_block.width());
replaced_element_box_model.border.top = Length::make_px(box.style().border_top().width);
replaced_element_box_model.border.bottom = Length::make_px(box.style().border_bottom().width);
replaced_element_box_model.border.top = CSS::Length::make_px(box.style().border_top().width);
replaced_element_box_model.border.bottom = CSS::Length::make_px(box.style().border_bottom().width);
replaced_element_box_model.padding.top = box.style().padding().top.resolved_or_zero(*this, containing_block.width());
replaced_element_box_model.padding.bottom = box.style().padding().bottom.resolved_or_zero(*this, containing_block.width());
@ -609,15 +609,15 @@ LayoutBlock::ShrinkToFitResult LayoutBlock::calculate_shrink_to_fit_width()
void LayoutBlock::place_block_level_non_replaced_element_in_normal_flow(LayoutBlock& block)
{
auto zero_value = Length::make_px(0);
auto zero_value = CSS::Length::make_px(0);
auto& containing_block = *this;
auto& box = block.box_model();
auto& style = block.style();
box.margin.top = style.margin().top.resolved(zero_value, *this, containing_block.width());
box.margin.bottom = style.margin().bottom.resolved(zero_value, *this, containing_block.width());
box.border.top = Length::make_px(style.border_top().width);
box.border.bottom = Length::make_px(style.border_bottom().width);
box.border.top = CSS::Length::make_px(style.border_top().width);
box.border.bottom = CSS::Length::make_px(style.border_bottom().width);
box.padding.top = style.padding().top.resolved(zero_value, *this, containing_block.width());
box.padding.bottom = style.padding().bottom.resolved(zero_value, *this, containing_block.width());
@ -671,10 +671,10 @@ void LayoutBlock::compute_height()
{
auto& containing_block = *this->containing_block();
Length specified_height;
CSS::Length specified_height;
if (style().height().is_percentage() && !containing_block.style().height().is_absolute()) {
specified_height = Length::make_auto();
specified_height = CSS::Length::make_auto();
} else {
specified_height = style().height().resolved_or_auto(*this, containing_block.height());
}
@ -683,8 +683,8 @@ void LayoutBlock::compute_height()
box_model().margin.top = style().margin().top.resolved_or_zero(*this, containing_block.width());
box_model().margin.bottom = style().margin().bottom.resolved_or_zero(*this, containing_block.width());
box_model().border.top = Length::make_px(style().border_top().width);
box_model().border.bottom = Length::make_px(style().border_bottom().width);
box_model().border.top = CSS::Length::make_px(style().border_top().width);
box_model().border.bottom = CSS::Length::make_px(style().border_bottom().width);
box_model().padding.top = style().padding().top.resolved_or_zero(*this, containing_block.width());
box_model().padding.bottom = style().padding().bottom.resolved_or_zero(*this, containing_block.width());
@ -742,12 +742,12 @@ HitTestResult LayoutBlock::hit_test(const Gfx::IntPoint& position) const
return { absolute_rect().contains(position.x(), position.y()) ? this : nullptr };
}
NonnullRefPtr<StyleProperties> LayoutBlock::style_for_anonymous_block() const
NonnullRefPtr<CSS::StyleProperties> LayoutBlock::style_for_anonymous_block() const
{
auto new_style = StyleProperties::create();
auto new_style = CSS::StyleProperties::create();
specified_style().for_each_property([&](auto property_id, auto& value) {
if (StyleResolver::is_inherited_property(property_id))
if (CSS::StyleResolver::is_inherited_property(property_id))
new_style->set_property(property_id, value);
});

View file

@ -33,7 +33,7 @@ namespace Web {
class LayoutBlock : public LayoutBox {
public:
LayoutBlock(DOM::Document&, const DOM::Node*, NonnullRefPtr<StyleProperties>);
LayoutBlock(DOM::Document&, const DOM::Node*, NonnullRefPtr<CSS::StyleProperties>);
virtual ~LayoutBlock() override;
virtual const char* class_name() const override { return "LayoutBlock"; }
@ -87,7 +87,7 @@ private:
void place_block_level_replaced_element_in_normal_flow(LayoutReplaced&);
void layout_absolutely_positioned_descendant(LayoutBox&);
NonnullRefPtr<StyleProperties> style_for_anonymous_block() const;
NonnullRefPtr<CSS::StyleProperties> style_for_anonymous_block() const;
void layout_inline_children(LayoutMode);
void layout_contained_boxes(LayoutMode);

View file

@ -186,7 +186,7 @@ void LayoutBox::paint(PaintContext& context, PaintPhase phase)
auto bgimage = specified_style().property(CSS::PropertyID::BackgroundImage);
if (bgimage.has_value() && bgimage.value()->is_image()) {
auto& image_value = static_cast<const ImageStyleValue&>(*bgimage.value());
auto& image_value = static_cast<const CSS::ImageStyleValue&>(*bgimage.value());
if (image_value.bitmap()) {
context.painter().draw_tiled_bitmap(enclosing_int_rect(padded_rect), *image_value.bitmap());
}

View file

@ -71,7 +71,7 @@ public:
virtual void paint(PaintContext&, PaintPhase) override;
protected:
LayoutBox(DOM::Document& document, const DOM::Node* node, NonnullRefPtr<StyleProperties> style)
LayoutBox(DOM::Document& document, const DOM::Node* node, NonnullRefPtr<CSS::StyleProperties> style)
: LayoutNodeWithStyleAndBoxModelMetrics(document, node, move(style))
{
}

View file

@ -30,7 +30,7 @@
namespace Web {
LayoutBreak::LayoutBreak(DOM::Document& document, const HTMLBRElement& element)
: LayoutNodeWithStyleAndBoxModelMetrics(document, &element, StyleProperties::create())
: LayoutNodeWithStyleAndBoxModelMetrics(document, &element, CSS::StyleProperties::create())
{
set_inline(true);
}

View file

@ -31,7 +31,7 @@
namespace Web {
LayoutCanvas::LayoutCanvas(DOM::Document& document, const HTMLCanvasElement& element, NonnullRefPtr<StyleProperties> style)
LayoutCanvas::LayoutCanvas(DOM::Document& document, const HTMLCanvasElement& element, NonnullRefPtr<CSS::StyleProperties> style)
: LayoutReplaced(document, element, move(style))
{
}

View file

@ -35,7 +35,7 @@ class HTMLCanvasElement;
class LayoutCanvas : public LayoutReplaced {
public:
LayoutCanvas(DOM::Document&, const HTMLCanvasElement&, NonnullRefPtr<StyleProperties>);
LayoutCanvas(DOM::Document&, const HTMLCanvasElement&, NonnullRefPtr<CSS::StyleProperties>);
virtual ~LayoutCanvas() override;
virtual void layout(LayoutMode = LayoutMode::Default) override;

View file

@ -33,7 +33,7 @@
namespace Web {
LayoutDocument::LayoutDocument(DOM::Document& document, NonnullRefPtr<StyleProperties> style)
LayoutDocument::LayoutDocument(DOM::Document& document, NonnullRefPtr<CSS::StyleProperties> style)
: LayoutBlock(document, &document, move(style))
{
}

View file

@ -33,7 +33,7 @@ namespace Web {
class LayoutDocument final : public LayoutBlock {
public:
explicit LayoutDocument(DOM::Document&, NonnullRefPtr<StyleProperties>);
explicit LayoutDocument(DOM::Document&, NonnullRefPtr<CSS::StyleProperties>);
virtual ~LayoutDocument() override;
const DOM::Document& node() const { return static_cast<const DOM::Document&>(*LayoutNode::node()); }

View file

@ -37,7 +37,7 @@
namespace Web {
LayoutFrame::LayoutFrame(DOM::Document& document, const DOM::Element& element, NonnullRefPtr<StyleProperties> style)
LayoutFrame::LayoutFrame(DOM::Document& document, const DOM::Element& element, NonnullRefPtr<CSS::StyleProperties> style)
: LayoutReplaced(document, element, move(style))
{
}

View file

@ -33,7 +33,7 @@ namespace Web {
class LayoutFrame final : public LayoutReplaced {
public:
LayoutFrame(DOM::Document&, const DOM::Element&, NonnullRefPtr<StyleProperties>);
LayoutFrame(DOM::Document&, const DOM::Element&, NonnullRefPtr<CSS::StyleProperties>);
virtual ~LayoutFrame() override;
virtual void paint(PaintContext&, PaintPhase) override;

View file

@ -32,7 +32,7 @@
namespace Web {
LayoutImage::LayoutImage(DOM::Document& document, const DOM::Element& element, NonnullRefPtr<StyleProperties> style, const ImageLoader& image_loader)
LayoutImage::LayoutImage(DOM::Document& document, const DOM::Element& element, NonnullRefPtr<CSS::StyleProperties> style, const ImageLoader& image_loader)
: LayoutReplaced(document, element, move(style))
, m_image_loader(image_loader)
{

View file

@ -35,7 +35,7 @@ class HTMLImageElement;
class LayoutImage : public LayoutReplaced {
public:
LayoutImage(DOM::Document&, const DOM::Element&, NonnullRefPtr<StyleProperties>, const ImageLoader&);
LayoutImage(DOM::Document&, const DOM::Element&, NonnullRefPtr<CSS::StyleProperties>, const ImageLoader&);
virtual ~LayoutImage() override;
virtual void layout(LayoutMode = LayoutMode::Default) override;

View file

@ -30,7 +30,7 @@
namespace Web {
LayoutInline::LayoutInline(DOM::Document& document, const DOM::Element& element, NonnullRefPtr<StyleProperties> style)
LayoutInline::LayoutInline(DOM::Document& document, const DOM::Element& element, NonnullRefPtr<CSS::StyleProperties> style)
: LayoutNodeWithStyleAndBoxModelMetrics(document, &element, move(style))
{
set_inline(true);

View file

@ -34,7 +34,7 @@ class LayoutBlock;
class LayoutInline : public LayoutNodeWithStyleAndBoxModelMetrics {
public:
LayoutInline(DOM::Document&, const DOM::Element&, NonnullRefPtr<StyleProperties>);
LayoutInline(DOM::Document&, const DOM::Element&, NonnullRefPtr<CSS::StyleProperties>);
virtual ~LayoutInline() override;
virtual const char* class_name() const override { return "LayoutInline"; }
};

View file

@ -29,7 +29,7 @@
namespace Web {
LayoutListItem::LayoutListItem(DOM::Document& document, const DOM::Element& element, NonnullRefPtr<StyleProperties> style)
LayoutListItem::LayoutListItem(DOM::Document& document, const DOM::Element& element, NonnullRefPtr<CSS::StyleProperties> style)
: LayoutBlock(document, &element, move(style))
{
}

View file

@ -35,7 +35,7 @@ class LayoutListItemMarker;
class LayoutListItem final : public LayoutBlock {
public:
LayoutListItem(DOM::Document&, const DOM::Element&, NonnullRefPtr<StyleProperties>);
LayoutListItem(DOM::Document&, const DOM::Element&, NonnullRefPtr<CSS::StyleProperties>);
virtual ~LayoutListItem() override;
virtual void layout(LayoutMode = LayoutMode::Default) override;

View file

@ -30,7 +30,7 @@
namespace Web {
LayoutListItemMarker::LayoutListItemMarker(DOM::Document& document)
: LayoutBox(document, nullptr, StyleProperties::create())
: LayoutBox(document, nullptr, CSS::StyleProperties::create())
{
}

View file

@ -163,7 +163,7 @@ void LayoutNode::set_needs_display()
float LayoutNode::font_size() const
{
// FIXME: This doesn't work right for relative font-sizes
auto length = specified_style().length_or_fallback(CSS::PropertyID::FontSize, Length(10, Length::Type::Px));
auto length = specified_style().length_or_fallback(CSS::PropertyID::FontSize, CSS::Length(10, CSS::Length::Type::Px));
return length.raw_value();
}
@ -208,7 +208,7 @@ bool LayoutNode::is_fixed_position() const
return position == CSS::Position::Fixed;
}
LayoutNodeWithStyle::LayoutNodeWithStyle(DOM::Document& document, const DOM::Node* node, NonnullRefPtr<StyleProperties> specified_style)
LayoutNodeWithStyle::LayoutNodeWithStyle(DOM::Document& document, const DOM::Node* node, NonnullRefPtr<CSS::StyleProperties> specified_style)
: LayoutNode(document, node)
, m_specified_style(move(specified_style))
{
@ -216,7 +216,7 @@ LayoutNodeWithStyle::LayoutNodeWithStyle(DOM::Document& document, const DOM::Nod
apply_style(*m_specified_style);
}
void LayoutNodeWithStyle::apply_style(const StyleProperties& specified_style)
void LayoutNodeWithStyle::apply_style(const CSS::StyleProperties& specified_style)
{
auto& style = static_cast<MutableLayoutStyle&>(m_style);

View file

@ -147,7 +147,7 @@ public:
virtual LayoutNode& inline_wrapper() { return *this; }
const StyleProperties& specified_style() const;
const CSS::StyleProperties& specified_style() const;
const ImmutableLayoutStyle& style() const;
LayoutNodeWithStyle* parent();
@ -214,20 +214,20 @@ class LayoutNodeWithStyle : public LayoutNode {
public:
virtual ~LayoutNodeWithStyle() override { }
const StyleProperties& specified_style() const { return m_specified_style; }
void set_specified_style(const StyleProperties& style) { m_specified_style = style; }
const CSS::StyleProperties& specified_style() const { return m_specified_style; }
void set_specified_style(const CSS::StyleProperties& style) { m_specified_style = style; }
const ImmutableLayoutStyle& style() const { return static_cast<const ImmutableLayoutStyle&>(m_style); }
void apply_style(const StyleProperties&);
void apply_style(const CSS::StyleProperties&);
protected:
LayoutNodeWithStyle(DOM::Document&, const DOM::Node*, NonnullRefPtr<StyleProperties>);
LayoutNodeWithStyle(DOM::Document&, const DOM::Node*, NonnullRefPtr<CSS::StyleProperties>);
private:
LayoutStyle m_style;
NonnullRefPtr<StyleProperties> m_specified_style;
NonnullRefPtr<CSS::StyleProperties> m_specified_style;
CSS::Position m_position;
CSS::TextAlign m_text_align;
};
@ -238,7 +238,7 @@ public:
const BoxModelMetrics& box_model() const { return m_box_model; }
protected:
LayoutNodeWithStyleAndBoxModelMetrics(DOM::Document& document, const DOM::Node* node, NonnullRefPtr<StyleProperties> style)
LayoutNodeWithStyleAndBoxModelMetrics(DOM::Document& document, const DOM::Node* node, NonnullRefPtr<CSS::StyleProperties> style)
: LayoutNodeWithStyle(document, node, move(style))
{
}
@ -247,7 +247,7 @@ private:
BoxModelMetrics m_box_model;
};
inline const StyleProperties& LayoutNode::specified_style() const
inline const CSS::StyleProperties& LayoutNode::specified_style() const
{
if (m_has_style)
return static_cast<const LayoutNodeWithStyle*>(this)->specified_style();

View file

@ -30,7 +30,7 @@
namespace Web {
LayoutReplaced::LayoutReplaced(DOM::Document& document, const DOM::Element& element, NonnullRefPtr<StyleProperties> style)
LayoutReplaced::LayoutReplaced(DOM::Document& document, const DOM::Element& element, NonnullRefPtr<CSS::StyleProperties> style)
: LayoutBox(document, &element, move(style))
{
// FIXME: Allow non-inline replaced elements.
@ -45,7 +45,7 @@ float LayoutReplaced::calculate_width() const
{
// 10.3.2 [Inline,] replaced elements
auto zero_value = Length::make_px(0);
auto zero_value = CSS::Length::make_px(0);
auto& containing_block = *this->containing_block();
auto margin_left = style().margin().left.resolved_or_zero(*this, containing_block.width());

View file

@ -33,7 +33,7 @@ namespace Web {
class LayoutReplaced : public LayoutBox {
public:
LayoutReplaced(DOM::Document&, const DOM::Element&, NonnullRefPtr<StyleProperties>);
LayoutReplaced(DOM::Document&, const DOM::Element&, NonnullRefPtr<CSS::StyleProperties>);
virtual ~LayoutReplaced() override;
const DOM::Element& node() const { return downcast<DOM::Element>(*LayoutNode::node()); }

View file

@ -31,7 +31,7 @@
namespace Web {
LayoutSVG::LayoutSVG(DOM::Document& document, const SVG::SVGSVGElement& element, NonnullRefPtr<StyleProperties> style)
LayoutSVG::LayoutSVG(DOM::Document& document, const SVG::SVGSVGElement& element, NonnullRefPtr<CSS::StyleProperties> style)
: LayoutReplaced(document, element, move(style))
{
}

View file

@ -36,7 +36,7 @@ class SVGSVGElement;
class LayoutSVG : public LayoutReplaced {
public:
LayoutSVG(DOM::Document&, const SVG::SVGSVGElement&, NonnullRefPtr<StyleProperties>);
LayoutSVG(DOM::Document&, const SVG::SVGSVGElement&, NonnullRefPtr<CSS::StyleProperties>);
virtual ~LayoutSVG() override = default;
virtual void layout(LayoutMode = LayoutMode::Default) override;
virtual void paint(PaintContext&, PaintPhase) override;

View file

@ -51,16 +51,16 @@ public:
CSS::TextAlign text_align() const { return m_text_align; }
CSS::Position position() const { return m_position; }
CSS::WhiteSpace white_space() const { return m_white_space; }
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; }
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; }
const LengthBox& offset() const { return m_offset; }
const LengthBox& margin() const { return m_margin; }
const LengthBox& padding() const { return m_padding; }
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 BorderData& border_left() const { return m_border_left; }
const BorderData& border_top() const { return m_border_top; }
@ -73,15 +73,15 @@ protected:
CSS::TextAlign m_text_align;
CSS::Position m_position;
CSS::WhiteSpace m_white_space { InitialValues::white_space() };
Length m_width;
Length m_min_width;
Length m_max_width;
Length m_height;
Length m_min_height;
Length m_max_height;
LengthBox m_offset;
LengthBox m_margin;
LengthBox m_padding;
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;
@ -98,15 +98,15 @@ public:
void set_text_align(CSS::TextAlign text_align) { m_text_align = text_align; }
void set_position(CSS::Position position) { m_position = position; }
void set_white_space(CSS::WhiteSpace value) { m_white_space = value; }
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; }
void set_offset(const LengthBox& offset) { m_offset = offset; }
void set_margin(const LengthBox& margin) { m_margin = margin; }
void set_padding(const LengthBox& padding) { m_padding = padding; }
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; }
BorderData& border_left() { return m_border_left; }
BorderData& border_top() { return m_border_top; }
BorderData& border_right() { return m_border_right; }

View file

@ -30,7 +30,7 @@
namespace Web {
LayoutTable::LayoutTable(DOM::Document& document, const DOM::Element& element, NonnullRefPtr<StyleProperties> style)
LayoutTable::LayoutTable(DOM::Document& document, const DOM::Element& element, NonnullRefPtr<CSS::StyleProperties> style)
: LayoutBlock(document, &element, move(style))
{
}

View file

@ -34,7 +34,7 @@ class LayoutTableRow;
class LayoutTable final : public LayoutBlock {
public:
LayoutTable(DOM::Document&, const DOM::Element&, NonnullRefPtr<StyleProperties>);
LayoutTable(DOM::Document&, const DOM::Element&, NonnullRefPtr<CSS::StyleProperties>);
virtual ~LayoutTable() override;
virtual void layout(LayoutMode = LayoutMode::Default) override;

View file

@ -30,7 +30,7 @@
namespace Web {
LayoutTableCell::LayoutTableCell(DOM::Document& document, const DOM::Element& element, NonnullRefPtr<StyleProperties> style)
LayoutTableCell::LayoutTableCell(DOM::Document& document, const DOM::Element& element, NonnullRefPtr<CSS::StyleProperties> style)
: LayoutBlock(document, &element, move(style))
{
}

View file

@ -32,7 +32,7 @@ namespace Web {
class LayoutTableCell final : public LayoutBlock {
public:
LayoutTableCell(DOM::Document&, const DOM::Element&, NonnullRefPtr<StyleProperties>);
LayoutTableCell(DOM::Document&, const DOM::Element&, NonnullRefPtr<CSS::StyleProperties>);
virtual ~LayoutTableCell() override;
LayoutTableCell* next_cell() { return next_sibling_of_type<LayoutTableCell>(); }

View file

@ -31,7 +31,7 @@
namespace Web {
LayoutTableRow::LayoutTableRow(DOM::Document& document, const DOM::Element& element, NonnullRefPtr<StyleProperties> style)
LayoutTableRow::LayoutTableRow(DOM::Document& document, const DOM::Element& element, NonnullRefPtr<CSS::StyleProperties> style)
: LayoutBox(document, &element, move(style))
{
}

View file

@ -34,7 +34,7 @@ class LayoutTableCell;
class LayoutTableRow final : public LayoutBox {
public:
LayoutTableRow(DOM::Document&, const DOM::Element&, NonnullRefPtr<StyleProperties>);
LayoutTableRow(DOM::Document&, const DOM::Element&, NonnullRefPtr<CSS::StyleProperties>);
virtual ~LayoutTableRow() override;
void layout_row(const Vector<float>& column_widths);

View file

@ -31,7 +31,7 @@
namespace Web {
LayoutTableRowGroup::LayoutTableRowGroup(DOM::Document& document, const DOM::Element& element, NonnullRefPtr<StyleProperties> style)
LayoutTableRowGroup::LayoutTableRowGroup(DOM::Document& document, const DOM::Element& element, NonnullRefPtr<CSS::StyleProperties> style)
: LayoutBlock(document, &element, move(style))
{
}

View file

@ -32,7 +32,7 @@ namespace Web {
class LayoutTableRowGroup final : public LayoutBlock {
public:
LayoutTableRowGroup(DOM::Document&, const DOM::Element&, NonnullRefPtr<StyleProperties>);
LayoutTableRowGroup(DOM::Document&, const DOM::Element&, NonnullRefPtr<CSS::StyleProperties>);
virtual ~LayoutTableRowGroup() override;
virtual void layout(LayoutMode = LayoutMode::Default) override;

View file

@ -55,7 +55,7 @@ static bool is_all_whitespace(const StringView& string)
return true;
}
const String& LayoutText::text_for_style(const StyleProperties& style) const
const String& LayoutText::text_for_style(const CSS::StyleProperties& style) const
{
static String one_space = " ";
if (is_all_whitespace(node().data())) {

View file

@ -40,7 +40,7 @@ public:
const DOM::Text& node() const { return static_cast<const DOM::Text&>(*LayoutNode::node()); }
const String& text_for_style(const StyleProperties&) const;
const String& text_for_style(const CSS::StyleProperties&) const;
const String& text_for_rendering() const { return m_text_for_rendering; }
virtual const char* class_name() const override { return "LayoutText"; }
@ -50,7 +50,7 @@ public:
virtual void split_into_lines(LayoutBlock& container, LayoutMode) override;
const StyleProperties& specified_style() const { return parent()->specified_style(); }
const CSS::StyleProperties& specified_style() const { return parent()->specified_style(); }
private:
void split_into_lines_by_rules(LayoutBlock& container, LayoutMode, bool do_collapse, bool do_wrap_lines, bool do_wrap_breaks);

View file

@ -37,7 +37,7 @@ LayoutTreeBuilder::LayoutTreeBuilder()
{
}
static RefPtr<LayoutNode> create_layout_tree(DOM::Node& node, const StyleProperties* parent_style)
static RefPtr<LayoutNode> create_layout_tree(DOM::Node& node, const CSS::StyleProperties* parent_style)
{
auto layout_node = node.create_layout_node(parent_style);
if (!layout_node)

View file

@ -37,7 +37,7 @@
namespace Web {
LayoutWidget::LayoutWidget(DOM::Document& document, const DOM::Element& element, GUI::Widget& widget)
: LayoutReplaced(document, element, StyleProperties::create())
: LayoutReplaced(document, element, CSS::StyleProperties::create())
, m_widget(widget)
{
set_has_intrinsic_width(true);