mirror of
https://github.com/RGBCube/serenity
synced 2025-05-26 01:55:08 +00:00
LibWeb: Rename LayoutNode::style() => specified_style()
Let's make way for a slightly-more-cooked style() that will eventually replace the raw specified_style() for layout and paint purposes.
This commit is contained in:
parent
90edaabc4b
commit
5e83a97fa2
17 changed files with 53 additions and 53 deletions
|
@ -190,7 +190,7 @@ Color Document::background_color(const Palette& palette) const
|
||||||
if (!body_layout_node)
|
if (!body_layout_node)
|
||||||
return default_color;
|
return default_color;
|
||||||
|
|
||||||
auto background_color = body_layout_node->style().property(CSS::PropertyID::BackgroundColor);
|
auto background_color = body_layout_node->specified_style().property(CSS::PropertyID::BackgroundColor);
|
||||||
if (!background_color.has_value() || !background_color.value()->is_color())
|
if (!background_color.has_value() || !background_color.value()->is_color())
|
||||||
return default_color;
|
return default_color;
|
||||||
|
|
||||||
|
@ -207,7 +207,7 @@ RefPtr<Gfx::Bitmap> Document::background_image() const
|
||||||
if (!body_layout_node)
|
if (!body_layout_node)
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
auto background_image = body_layout_node->style().property(CSS::PropertyID::BackgroundImage);
|
auto background_image = body_layout_node->specified_style().property(CSS::PropertyID::BackgroundImage);
|
||||||
if (!background_image.has_value() || !background_image.value()->is_image())
|
if (!background_image.has_value() || !background_image.value()->is_image())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
|
|
|
@ -192,7 +192,7 @@ void Element::recompute_style()
|
||||||
if (!parent_layout_node)
|
if (!parent_layout_node)
|
||||||
return;
|
return;
|
||||||
ASSERT(parent_layout_node);
|
ASSERT(parent_layout_node);
|
||||||
auto style = document().style_resolver().resolve_style(*this, &parent_layout_node->style());
|
auto style = document().style_resolver().resolve_style(*this, &parent_layout_node->specified_style());
|
||||||
m_resolved_style = style;
|
m_resolved_style = style;
|
||||||
if (!layout_node()) {
|
if (!layout_node()) {
|
||||||
if (style->string_or_fallback(CSS::PropertyID::Display, "inline") == "none")
|
if (style->string_or_fallback(CSS::PropertyID::Display, "inline") == "none")
|
||||||
|
@ -207,10 +207,10 @@ void Element::recompute_style()
|
||||||
if (layout_node()->is_widget())
|
if (layout_node()->is_widget())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto diff = compute_style_difference(layout_node()->style(), *style, document());
|
auto diff = compute_style_difference(layout_node()->specified_style(), *style, document());
|
||||||
if (diff == StyleDifference::None)
|
if (diff == StyleDifference::None)
|
||||||
return;
|
return;
|
||||||
layout_node()->set_style(*style);
|
layout_node()->set_specified_style(*style);
|
||||||
if (diff == StyleDifference::NeedsRelayout) {
|
if (diff == StyleDifference::NeedsRelayout) {
|
||||||
document().force_layout();
|
document().force_layout();
|
||||||
return;
|
return;
|
||||||
|
@ -239,7 +239,7 @@ NonnullRefPtr<StyleProperties> Element::computed_style()
|
||||||
CSS::PropertyID::BorderRightWidth,
|
CSS::PropertyID::BorderRightWidth,
|
||||||
};
|
};
|
||||||
for (CSS::PropertyID id : box_model_metrics) {
|
for (CSS::PropertyID id : box_model_metrics) {
|
||||||
auto prop = layout_node()->style().property(id);
|
auto prop = layout_node()->specified_style().property(id);
|
||||||
if (prop.has_value())
|
if (prop.has_value())
|
||||||
properties->set_property(id, prop.value());
|
properties->set_property(id, prop.value());
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,7 +181,7 @@ void dump_tree(const LayoutNode& layout_node)
|
||||||
String value;
|
String value;
|
||||||
};
|
};
|
||||||
Vector<NameAndValue> properties;
|
Vector<NameAndValue> properties;
|
||||||
layout_node.style().for_each_property([&](auto property_id, auto& value) {
|
layout_node.specified_style().for_each_property([&](auto property_id, auto& value) {
|
||||||
properties.append({ CSS::string_from_property_id(property_id), value.to_string() });
|
properties.append({ CSS::string_from_property_id(property_id), value.to_string() });
|
||||||
});
|
});
|
||||||
quick_sort(properties, [](auto& a, auto& b) { return a.name < b.name; });
|
quick_sort(properties, [](auto& a, auto& b) { return a.name < b.name; });
|
||||||
|
|
|
@ -69,7 +69,7 @@ void LayoutBlock::layout_absolutely_positioned_descendant(LayoutBox& box)
|
||||||
{
|
{
|
||||||
box.layout(LayoutMode::Default);
|
box.layout(LayoutMode::Default);
|
||||||
auto& box_model = box.box_model();
|
auto& box_model = box.box_model();
|
||||||
auto& style = box.style();
|
auto& style = box.specified_style();
|
||||||
auto zero_value = Length::make_px(0);
|
auto zero_value = Length::make_px(0);
|
||||||
|
|
||||||
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());
|
||||||
|
@ -164,7 +164,7 @@ void LayoutBlock::layout_contained_boxes(LayoutMode layout_mode)
|
||||||
});
|
});
|
||||||
|
|
||||||
if (layout_mode != LayoutMode::Default) {
|
if (layout_mode != LayoutMode::Default) {
|
||||||
auto specified_width = style().length_or_fallback(CSS::PropertyID::Width, Length::make_auto(), containing_block()->width());
|
auto specified_width = specified_style().length_or_fallback(CSS::PropertyID::Width, Length::make_auto(), containing_block()->width());
|
||||||
if (specified_width.is_auto())
|
if (specified_width.is_auto())
|
||||||
set_width(content_width);
|
set_width(content_width);
|
||||||
}
|
}
|
||||||
|
@ -188,8 +188,8 @@ void LayoutBlock::layout_inline_children(LayoutMode layout_mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
auto text_align = this->text_align();
|
auto text_align = this->text_align();
|
||||||
float min_line_height = style().line_height(*this);
|
float min_line_height = specified_style().line_height(*this);
|
||||||
float line_spacing = min_line_height - style().font().glyph_height();
|
float line_spacing = min_line_height - specified_style().font().glyph_height();
|
||||||
float content_height = 0;
|
float content_height = 0;
|
||||||
float max_linebox_width = 0;
|
float max_linebox_width = 0;
|
||||||
|
|
||||||
|
@ -277,7 +277,7 @@ void LayoutBlock::layout_inline_children(LayoutMode layout_mode)
|
||||||
|
|
||||||
void LayoutBlock::compute_width_for_absolutely_positioned_block()
|
void LayoutBlock::compute_width_for_absolutely_positioned_block()
|
||||||
{
|
{
|
||||||
auto& style = this->style();
|
auto& style = this->specified_style();
|
||||||
auto& containing_block = *this->containing_block();
|
auto& containing_block = *this->containing_block();
|
||||||
auto zero_value = Length::make_px(0);
|
auto zero_value = Length::make_px(0);
|
||||||
|
|
||||||
|
@ -424,7 +424,7 @@ void LayoutBlock::compute_width()
|
||||||
if (is_absolutely_positioned())
|
if (is_absolutely_positioned())
|
||||||
return compute_width_for_absolutely_positioned_block();
|
return compute_width_for_absolutely_positioned_block();
|
||||||
|
|
||||||
auto& style = this->style();
|
auto& style = this->specified_style();
|
||||||
auto auto_value = Length::make_auto();
|
auto auto_value = Length::make_auto();
|
||||||
auto zero_value = Length::make_px(0);
|
auto zero_value = Length::make_px(0);
|
||||||
|
|
||||||
|
@ -561,7 +561,7 @@ void LayoutBlock::compute_width()
|
||||||
void LayoutBlock::place_block_level_replaced_element_in_normal_flow(LayoutReplaced& box)
|
void LayoutBlock::place_block_level_replaced_element_in_normal_flow(LayoutReplaced& box)
|
||||||
{
|
{
|
||||||
ASSERT(!is_absolutely_positioned());
|
ASSERT(!is_absolutely_positioned());
|
||||||
auto& style = box.style();
|
auto& style = box.specified_style();
|
||||||
auto zero_value = Length::make_px(0);
|
auto zero_value = Length::make_px(0);
|
||||||
auto& containing_block = *this;
|
auto& containing_block = *this;
|
||||||
auto& replaced_element_box_model = box.box_model();
|
auto& replaced_element_box_model = box.box_model();
|
||||||
|
@ -616,7 +616,7 @@ LayoutBlock::ShrinkToFitResult LayoutBlock::calculate_shrink_to_fit_width()
|
||||||
|
|
||||||
void LayoutBlock::place_block_level_non_replaced_element_in_normal_flow(LayoutBlock& block)
|
void LayoutBlock::place_block_level_non_replaced_element_in_normal_flow(LayoutBlock& block)
|
||||||
{
|
{
|
||||||
auto& style = block.style();
|
auto& style = block.specified_style();
|
||||||
auto zero_value = Length::make_px(0);
|
auto zero_value = Length::make_px(0);
|
||||||
auto& containing_block = *this;
|
auto& containing_block = *this;
|
||||||
auto& box = block.box_model();
|
auto& box = block.box_model();
|
||||||
|
@ -672,7 +672,7 @@ void LayoutBlock::place_block_level_non_replaced_element_in_normal_flow(LayoutBl
|
||||||
|
|
||||||
void LayoutBlock::compute_height()
|
void LayoutBlock::compute_height()
|
||||||
{
|
{
|
||||||
auto& style = this->style();
|
auto& style = this->specified_style();
|
||||||
|
|
||||||
auto specified_height = style.length_or_fallback(CSS::PropertyID::Height, Length::make_auto(), containing_block()->height());
|
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_max_height = style.length_or_fallback(CSS::PropertyID::MaxHeight, Length::make_auto(), containing_block()->height());
|
||||||
|
@ -740,7 +740,7 @@ NonnullRefPtr<StyleProperties> LayoutBlock::style_for_anonymous_block() const
|
||||||
{
|
{
|
||||||
auto new_style = StyleProperties::create();
|
auto new_style = StyleProperties::create();
|
||||||
|
|
||||||
style().for_each_property([&](auto property_id, auto& value) {
|
specified_style().for_each_property([&](auto property_id, auto& value) {
|
||||||
if (StyleResolver::is_inherited_property(property_id))
|
if (StyleResolver::is_inherited_property(property_id))
|
||||||
new_style->set_property(property_id, value);
|
new_style->set_property(property_id, value);
|
||||||
});
|
});
|
||||||
|
|
|
@ -35,11 +35,11 @@ namespace Web {
|
||||||
|
|
||||||
void LayoutBox::paint_border(PaintContext& context, Edge edge, const Gfx::FloatRect& rect, CSS::PropertyID style_property_id, CSS::PropertyID color_property_id, CSS::PropertyID width_property_id)
|
void LayoutBox::paint_border(PaintContext& context, Edge edge, const Gfx::FloatRect& rect, CSS::PropertyID style_property_id, CSS::PropertyID color_property_id, CSS::PropertyID width_property_id)
|
||||||
{
|
{
|
||||||
auto border_width = style().property(width_property_id);
|
auto border_width = specified_style().property(width_property_id);
|
||||||
if (!border_width.has_value())
|
if (!border_width.has_value())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto border_style = style().property(style_property_id);
|
auto border_style = specified_style().property(style_property_id);
|
||||||
float width = border_width.value()->to_length().to_px(*this);
|
float width = border_width.value()->to_length().to_px(*this);
|
||||||
if (width <= 0)
|
if (width <= 0)
|
||||||
return;
|
return;
|
||||||
|
@ -47,13 +47,13 @@ void LayoutBox::paint_border(PaintContext& context, Edge edge, const Gfx::FloatR
|
||||||
int int_width = max((int)width, 1);
|
int int_width = max((int)width, 1);
|
||||||
|
|
||||||
Color color;
|
Color color;
|
||||||
auto border_color = style().property(color_property_id);
|
auto border_color = specified_style().property(color_property_id);
|
||||||
if (border_color.has_value()) {
|
if (border_color.has_value()) {
|
||||||
color = border_color.value()->to_color(document());
|
color = border_color.value()->to_color(document());
|
||||||
} else {
|
} else {
|
||||||
// FIXME: This is basically CSS "currentColor" which should be handled elsewhere
|
// FIXME: This is basically CSS "currentColor" which should be handled elsewhere
|
||||||
// in a much more reusable way.
|
// in a much more reusable way.
|
||||||
auto current_color = style().property(CSS::PropertyID::Color);
|
auto current_color = specified_style().property(CSS::PropertyID::Color);
|
||||||
if (current_color.has_value())
|
if (current_color.has_value())
|
||||||
color = current_color.value()->to_color(document());
|
color = current_color.value()->to_color(document());
|
||||||
else
|
else
|
||||||
|
@ -137,7 +137,7 @@ void LayoutBox::paint_border(PaintContext& context, Edge edge, const Gfx::FloatR
|
||||||
};
|
};
|
||||||
|
|
||||||
auto width_for = [&](CSS::PropertyID property_id) -> float {
|
auto width_for = [&](CSS::PropertyID property_id) -> float {
|
||||||
auto width = style().property(property_id);
|
auto width = specified_style().property(property_id);
|
||||||
if (!width.has_value())
|
if (!width.has_value())
|
||||||
return 0;
|
return 0;
|
||||||
return width.value()->to_length().to_px(*this);
|
return width.value()->to_length().to_px(*this);
|
||||||
|
@ -203,12 +203,12 @@ void LayoutBox::paint(PaintContext& context, PaintPhase phase)
|
||||||
|
|
||||||
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.
|
||||||
auto bgcolor = style().property(CSS::PropertyID::BackgroundColor);
|
auto bgcolor = specified_style().property(CSS::PropertyID::BackgroundColor);
|
||||||
if (bgcolor.has_value() && bgcolor.value()->is_color()) {
|
if (bgcolor.has_value() && bgcolor.value()->is_color()) {
|
||||||
context.painter().fill_rect(enclosing_int_rect(padded_rect), bgcolor.value()->to_color(document()));
|
context.painter().fill_rect(enclosing_int_rect(padded_rect), bgcolor.value()->to_color(document()));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto bgimage = style().property(CSS::PropertyID::BackgroundImage);
|
auto bgimage = specified_style().property(CSS::PropertyID::BackgroundImage);
|
||||||
if (bgimage.has_value() && bgimage.value()->is_image()) {
|
if (bgimage.has_value() && bgimage.value()->is_image()) {
|
||||||
auto& image_value = static_cast<const ImageStyleValue&>(*bgimage.value());
|
auto& image_value = static_cast<const ImageStyleValue&>(*bgimage.value());
|
||||||
if (image_value.bitmap()) {
|
if (image_value.bitmap()) {
|
||||||
|
@ -324,7 +324,7 @@ bool LayoutBox::establishes_stacking_context() const
|
||||||
if (node() == document().root())
|
if (node() == document().root())
|
||||||
return true;
|
return true;
|
||||||
auto position = this->position();
|
auto position = this->position();
|
||||||
auto z_index = style().z_index();
|
auto z_index = specified_style().z_index();
|
||||||
if (position == CSS::Position::Absolute || position == CSS::Position::Relative) {
|
if (position == CSS::Position::Absolute || position == CSS::Position::Relative) {
|
||||||
if (z_index.has_value())
|
if (z_index.has_value())
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -94,7 +94,7 @@ void LayoutImage::paint(PaintContext& context, PaintPhase phase)
|
||||||
auto alt = image_element.alt();
|
auto alt = image_element.alt();
|
||||||
if (alt.is_empty())
|
if (alt.is_empty())
|
||||||
alt = image_element.src();
|
alt = image_element.src();
|
||||||
context.painter().draw_text(enclosing_int_rect(absolute_rect()), alt, Gfx::TextAlignment::Center, style().color_or_fallback(CSS::PropertyID::Color, document(), Color::Black), Gfx::TextElision::Right);
|
context.painter().draw_text(enclosing_int_rect(absolute_rect()), alt, Gfx::TextAlignment::Center, specified_style().color_or_fallback(CSS::PropertyID::Color, document(), Color::Black), Gfx::TextElision::Right);
|
||||||
} else if (auto* bitmap = m_image_loader.bitmap()) {
|
} else if (auto* bitmap = m_image_loader.bitmap()) {
|
||||||
context.painter().draw_scaled_bitmap(enclosing_int_rect(absolute_rect()), *bitmap, bitmap->rect());
|
context.painter().draw_scaled_bitmap(enclosing_int_rect(absolute_rect()), *bitmap, bitmap->rect());
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ void LayoutListItem::layout(LayoutMode layout_mode)
|
||||||
|
|
||||||
LayoutBlock::layout(layout_mode);
|
LayoutBlock::layout(layout_mode);
|
||||||
|
|
||||||
if (style().string_or_fallback(CSS::PropertyID::ListStyleType, "disc") == "none") {
|
if (specified_style().string_or_fallback(CSS::PropertyID::ListStyleType, "disc") == "none") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ void LayoutListItemMarker::paint(PaintContext& context, PaintPhase phase)
|
||||||
Gfx::IntRect bullet_rect { 0, 0, 4, 4 };
|
Gfx::IntRect bullet_rect { 0, 0, 4, 4 };
|
||||||
bullet_rect.center_within(enclosing_int_rect(absolute_rect()));
|
bullet_rect.center_within(enclosing_int_rect(absolute_rect()));
|
||||||
// FIXME: It would be nicer to not have to go via the parent here to get our inherited style.
|
// FIXME: It would be nicer to not have to go via the parent here to get our inherited style.
|
||||||
auto color = parent()->style().color_or_fallback(CSS::PropertyID::Color, document(), context.palette().base_text());
|
auto color = parent()->specified_style().color_or_fallback(CSS::PropertyID::Color, document(), context.palette().base_text());
|
||||||
context.painter().fill_rect(bullet_rect, color);
|
context.painter().fill_rect(bullet_rect, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -173,7 +173,7 @@ void LayoutNode::set_needs_display()
|
||||||
float LayoutNode::font_size() const
|
float LayoutNode::font_size() const
|
||||||
{
|
{
|
||||||
// FIXME: This doesn't work right for relative font-sizes
|
// FIXME: This doesn't work right for relative font-sizes
|
||||||
auto length = style().length_or_fallback(CSS::PropertyID::FontSize, Length(10, Length::Type::Px));
|
auto length = specified_style().length_or_fallback(CSS::PropertyID::FontSize, Length(10, Length::Type::Px));
|
||||||
return length.raw_value();
|
return length.raw_value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,11 +213,11 @@ bool LayoutNode::is_fixed_position() const
|
||||||
|
|
||||||
LayoutNodeWithStyle::LayoutNodeWithStyle(const Node* node, NonnullRefPtr<StyleProperties> style)
|
LayoutNodeWithStyle::LayoutNodeWithStyle(const Node* node, NonnullRefPtr<StyleProperties> style)
|
||||||
: LayoutNode(node)
|
: LayoutNode(node)
|
||||||
, m_style(move(style))
|
, m_specified_style(move(style))
|
||||||
{
|
{
|
||||||
m_has_style = true;
|
m_has_style = true;
|
||||||
m_position = m_style->position();
|
m_position = m_specified_style->position();
|
||||||
m_text_align = m_style->text_align();
|
m_text_align = m_specified_style->text_align();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,7 +189,7 @@ public:
|
||||||
|
|
||||||
virtual LayoutNode& inline_wrapper() { return *this; }
|
virtual LayoutNode& inline_wrapper() { return *this; }
|
||||||
|
|
||||||
const StyleProperties& style() const;
|
const StyleProperties& specified_style() const;
|
||||||
CSS::Position position() const;
|
CSS::Position position() const;
|
||||||
CSS::TextAlign text_align() const;
|
CSS::TextAlign text_align() const;
|
||||||
|
|
||||||
|
@ -256,8 +256,8 @@ class LayoutNodeWithStyle : public LayoutNode {
|
||||||
public:
|
public:
|
||||||
virtual ~LayoutNodeWithStyle() override { }
|
virtual ~LayoutNodeWithStyle() override { }
|
||||||
|
|
||||||
const StyleProperties& style() const { return m_style; }
|
const StyleProperties& specified_style() const { return m_specified_style; }
|
||||||
void set_style(const StyleProperties& style) { m_style = style; }
|
void set_specified_style(const StyleProperties& style) { m_specified_style = style; }
|
||||||
|
|
||||||
CSS::Position position() const { return m_position; }
|
CSS::Position position() const { return m_position; }
|
||||||
CSS::TextAlign text_align() const { return m_text_align; }
|
CSS::TextAlign text_align() const { return m_text_align; }
|
||||||
|
@ -266,7 +266,7 @@ protected:
|
||||||
explicit LayoutNodeWithStyle(const Node*, NonnullRefPtr<StyleProperties>);
|
explicit LayoutNodeWithStyle(const Node*, NonnullRefPtr<StyleProperties>);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NonnullRefPtr<StyleProperties> m_style;
|
NonnullRefPtr<StyleProperties> m_specified_style;
|
||||||
CSS::Position m_position;
|
CSS::Position m_position;
|
||||||
CSS::TextAlign m_text_align;
|
CSS::TextAlign m_text_align;
|
||||||
};
|
};
|
||||||
|
@ -286,11 +286,11 @@ private:
|
||||||
BoxModelMetrics m_box_model;
|
BoxModelMetrics m_box_model;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline const StyleProperties& LayoutNode::style() const
|
inline const StyleProperties& LayoutNode::specified_style() const
|
||||||
{
|
{
|
||||||
if (m_has_style)
|
if (m_has_style)
|
||||||
return static_cast<const LayoutNodeWithStyle*>(this)->style();
|
return static_cast<const LayoutNodeWithStyle*>(this)->specified_style();
|
||||||
return parent()->style();
|
return parent()->specified_style();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline CSS::Position LayoutNode::position() const
|
inline CSS::Position LayoutNode::position() const
|
||||||
|
|
|
@ -45,7 +45,7 @@ float LayoutReplaced::calculate_width() const
|
||||||
{
|
{
|
||||||
// 10.3.2 [Inline,] replaced elements
|
// 10.3.2 [Inline,] replaced elements
|
||||||
|
|
||||||
auto& style = this->style();
|
auto& style = this->specified_style();
|
||||||
auto auto_value = Length::make_auto();
|
auto auto_value = Length::make_auto();
|
||||||
auto zero_value = Length::make_px(0);
|
auto zero_value = Length::make_px(0);
|
||||||
auto& containing_block = *this->containing_block();
|
auto& containing_block = *this->containing_block();
|
||||||
|
@ -98,7 +98,7 @@ float LayoutReplaced::calculate_height() const
|
||||||
{
|
{
|
||||||
// 10.6.2 Inline replaced elements, block-level replaced elements in normal flow,
|
// 10.6.2 Inline replaced elements, block-level replaced elements in normal flow,
|
||||||
// 'inline-block' replaced elements in normal flow and floating replaced elements
|
// 'inline-block' replaced elements in normal flow and floating replaced elements
|
||||||
auto& style = this->style();
|
auto& style = this->specified_style();
|
||||||
auto auto_value = Length::make_auto();
|
auto auto_value = Length::make_auto();
|
||||||
auto& containing_block = *this->containing_block();
|
auto& containing_block = *this->containing_block();
|
||||||
|
|
||||||
|
|
|
@ -68,14 +68,14 @@ const String& LayoutText::text_for_style(const StyleProperties& style) const
|
||||||
void LayoutText::render_fragment(PaintContext& context, const LineBoxFragment& fragment) const
|
void LayoutText::render_fragment(PaintContext& context, const LineBoxFragment& fragment) const
|
||||||
{
|
{
|
||||||
auto& painter = context.painter();
|
auto& painter = context.painter();
|
||||||
painter.set_font(style().font());
|
painter.set_font(specified_style().font());
|
||||||
|
|
||||||
auto background_color = style().property(CSS::PropertyID::BackgroundColor);
|
auto background_color = specified_style().property(CSS::PropertyID::BackgroundColor);
|
||||||
if (background_color.has_value() && background_color.value()->is_color())
|
if (background_color.has_value() && background_color.value()->is_color())
|
||||||
painter.fill_rect(enclosing_int_rect(fragment.absolute_rect()), background_color.value()->to_color(document()));
|
painter.fill_rect(enclosing_int_rect(fragment.absolute_rect()), background_color.value()->to_color(document()));
|
||||||
|
|
||||||
auto color = style().color_or_fallback(CSS::PropertyID::Color, document(), context.palette().base_text());
|
auto color = specified_style().color_or_fallback(CSS::PropertyID::Color, document(), context.palette().base_text());
|
||||||
auto text_decoration = style().string_or_fallback(CSS::PropertyID::TextDecoration, "none");
|
auto text_decoration = specified_style().string_or_fallback(CSS::PropertyID::TextDecoration, "none");
|
||||||
|
|
||||||
if (document().inspected_node() == &node())
|
if (document().inspected_node() == &node())
|
||||||
context.painter().draw_rect(enclosing_int_rect(fragment.absolute_rect()), Color::Magenta);
|
context.painter().draw_rect(enclosing_int_rect(fragment.absolute_rect()), Color::Magenta);
|
||||||
|
@ -85,7 +85,7 @@ void LayoutText::render_fragment(PaintContext& context, const LineBoxFragment& f
|
||||||
painter.draw_line(enclosing_int_rect(fragment.absolute_rect()).bottom_left().translated(0, 1), enclosing_int_rect(fragment.absolute_rect()).bottom_right().translated(0, 1), color);
|
painter.draw_line(enclosing_int_rect(fragment.absolute_rect()).bottom_left().translated(0, 1), enclosing_int_rect(fragment.absolute_rect()).bottom_right().translated(0, 1), color);
|
||||||
|
|
||||||
auto text = m_text_for_rendering;
|
auto text = m_text_for_rendering;
|
||||||
auto text_transform = style().string_or_fallback(CSS::PropertyID::TextTransform, "none");
|
auto text_transform = specified_style().string_or_fallback(CSS::PropertyID::TextTransform, "none");
|
||||||
if (text_transform == "uppercase")
|
if (text_transform == "uppercase")
|
||||||
text = m_text_for_rendering.to_uppercase();
|
text = m_text_for_rendering.to_uppercase();
|
||||||
if (text_transform == "lowercase")
|
if (text_transform == "lowercase")
|
||||||
|
@ -149,7 +149,7 @@ void LayoutText::for_each_chunk(Callback callback, LayoutMode layout_mode, bool
|
||||||
|
|
||||||
void LayoutText::split_into_lines_by_rules(LayoutBlock& container, LayoutMode layout_mode, bool do_collapse, bool do_wrap_lines, bool do_wrap_breaks)
|
void LayoutText::split_into_lines_by_rules(LayoutBlock& container, LayoutMode layout_mode, bool do_collapse, bool do_wrap_lines, bool do_wrap_breaks)
|
||||||
{
|
{
|
||||||
auto& font = style().font();
|
auto& font = specified_style().font();
|
||||||
float space_width = font.glyph_width(' ') + font.glyph_spacing();
|
float space_width = font.glyph_width(' ') + font.glyph_spacing();
|
||||||
|
|
||||||
auto& line_boxes = container.line_boxes();
|
auto& line_boxes = container.line_boxes();
|
||||||
|
@ -253,7 +253,7 @@ void LayoutText::split_into_lines(LayoutBlock& container, LayoutMode layout_mode
|
||||||
bool do_collapse = true;
|
bool do_collapse = true;
|
||||||
bool do_wrap_lines = true;
|
bool do_wrap_lines = true;
|
||||||
bool do_wrap_breaks = false;
|
bool do_wrap_breaks = false;
|
||||||
auto white_space_prop = style().string_or_fallback(CSS::PropertyID::WhiteSpace, "normal");
|
auto white_space_prop = specified_style().string_or_fallback(CSS::PropertyID::WhiteSpace, "normal");
|
||||||
|
|
||||||
if (white_space_prop == "nowrap") {
|
if (white_space_prop == "nowrap") {
|
||||||
do_collapse = true;
|
do_collapse = true;
|
||||||
|
|
|
@ -50,7 +50,7 @@ public:
|
||||||
|
|
||||||
virtual void split_into_lines(LayoutBlock& container, LayoutMode) override;
|
virtual void split_into_lines(LayoutBlock& container, LayoutMode) override;
|
||||||
|
|
||||||
const StyleProperties& style() const { return parent()->style(); }
|
const StyleProperties& specified_style() const { return parent()->specified_style(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void split_into_lines_by_rules(LayoutBlock& container, LayoutMode, bool do_collapse, bool do_wrap_lines, bool do_wrap_breaks);
|
void split_into_lines_by_rules(LayoutBlock& container, LayoutMode, bool do_collapse, bool do_wrap_lines, bool do_wrap_breaks);
|
||||||
|
|
|
@ -51,7 +51,7 @@ static RefPtr<LayoutNode> create_layout_tree(Node& node, const StyleProperties*
|
||||||
bool have_noninline_children = false;
|
bool have_noninline_children = false;
|
||||||
|
|
||||||
to<ParentNode>(node).for_each_child([&](Node& child) {
|
to<ParentNode>(node).for_each_child([&](Node& child) {
|
||||||
auto layout_child = create_layout_tree(child, &layout_node->style());
|
auto layout_child = create_layout_tree(child, &layout_node->specified_style());
|
||||||
if (!layout_child)
|
if (!layout_child)
|
||||||
return;
|
return;
|
||||||
if (layout_child->is_inline())
|
if (layout_child->is_inline())
|
||||||
|
|
|
@ -65,7 +65,7 @@ void LineBox::trim_trailing_whitespace()
|
||||||
return;
|
return;
|
||||||
auto& last_fragment = m_fragments.last();
|
auto& last_fragment = m_fragments.last();
|
||||||
|
|
||||||
int space_width = last_fragment.layout_node().style().font().glyph_width(' ');
|
int space_width = last_fragment.layout_node().specified_style().font().glyph_width(' ');
|
||||||
while (last_fragment.length() && isspace(last_text[last_fragment.length() - 1])) {
|
while (last_fragment.length() && isspace(last_text[last_fragment.length() - 1])) {
|
||||||
last_fragment.m_length -= 1;
|
last_fragment.m_length -= 1;
|
||||||
last_fragment.set_width(last_fragment.width() - space_width);
|
last_fragment.set_width(last_fragment.width() - space_width);
|
||||||
|
|
|
@ -79,7 +79,7 @@ int LineBoxFragment::text_index_at(float x) const
|
||||||
if (!layout_node().is_text())
|
if (!layout_node().is_text())
|
||||||
return 0;
|
return 0;
|
||||||
auto& layout_text = to<LayoutText>(layout_node());
|
auto& layout_text = to<LayoutText>(layout_node());
|
||||||
auto& font = layout_text.style().font();
|
auto& font = layout_text.specified_style().font();
|
||||||
Utf8View view(text());
|
Utf8View view(text());
|
||||||
|
|
||||||
float relative_x = x - absolute_x();
|
float relative_x = x - absolute_x();
|
||||||
|
|
|
@ -42,7 +42,7 @@ StackingContext::StackingContext(LayoutBox& box, StackingContext* parent)
|
||||||
|
|
||||||
// FIXME: Don't sort on every append..
|
// FIXME: Don't sort on every append..
|
||||||
quick_sort(m_children, [](auto& a, auto& b) {
|
quick_sort(m_children, [](auto& a, auto& b) {
|
||||||
return a->m_box.style().z_index().value_or(0) < b->m_box.style().z_index().value_or(0);
|
return a->m_box.specified_style().z_index().value_or(0) < b->m_box.specified_style().z_index().value_or(0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue