1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:28:12 +00:00

LibHTML: Rename LayoutNode::style_properties() to LayoutNode::style()

This commit is contained in:
Andreas Kling 2019-10-04 15:56:36 +02:00
parent 9c0e9a1a20
commit a7ca719c4e
7 changed files with 21 additions and 21 deletions

View file

@ -56,7 +56,7 @@ RefPtr<LayoutNode> Node::create_layout_tree(const StyleResolver& resolver, const
bool have_block_children = false;
static_cast<const ParentNode&>(*this).for_each_child([&](const Node& child) {
auto layout_child = child.create_layout_tree(resolver, &layout_node->style_properties());
auto layout_child = child.create_layout_tree(resolver, &layout_node->style());
if (!layout_child)
return;
if (!layout_child->is_block())

View file

@ -114,7 +114,7 @@ void dump_tree(const LayoutNode& layout_node)
}
}
layout_node.style_properties().for_each_property([&](auto& key, auto& value) {
layout_node.style().for_each_property([&](auto& key, auto& value) {
for (int i = 0; i < indent; ++i)
dbgprintf(" ");
dbgprintf(" (%s: %s)\n", key.characters(), value.to_string().characters());

View file

@ -15,7 +15,7 @@ LayoutBlock::~LayoutBlock()
LayoutNode& LayoutBlock::inline_wrapper()
{
if (!last_child() || !last_child()->is_block() || last_child()->node() != nullptr) {
append_child(adopt(*new LayoutBlock(nullptr, style_properties())));
append_child(adopt(*new LayoutBlock(nullptr, style())));
}
return *last_child();
}
@ -75,7 +75,7 @@ void LayoutBlock::layout_inline_children()
void LayoutBlock::compute_width()
{
auto& style_properties = this->style_properties();
auto& style_properties = this->style();
auto auto_value = Length();
auto zero_value = Length(0, Length::Type::Absolute);
@ -149,7 +149,7 @@ void LayoutBlock::compute_width()
void LayoutBlock::compute_position()
{
auto& style_properties = this->style_properties();
auto& style_properties = this->style();
auto auto_value = Length();
auto zero_value = Length(0, Length::Type::Absolute);
@ -178,7 +178,7 @@ void LayoutBlock::compute_position()
void LayoutBlock::compute_height()
{
auto& style_properties = this->style_properties();
auto& style_properties = this->style();
auto height_property = style_properties.property("height");
if (!height_property.has_value())
@ -193,7 +193,7 @@ void LayoutBlock::render(RenderingContext& context)
LayoutNode::render(context);
// FIXME: position this properly
if (style_properties().string_or_fallback("display", "block") == "list-item") {
if (style().string_or_fallback("display", "block") == "list-item") {
Rect bullet_rect {
rect().x() - 8,
rect().y() + 4,

View file

@ -49,14 +49,14 @@ void LayoutNode::render(RenderingContext& context)
padded_rect.set_y(rect().y() - box_model().padding().top.to_px());
padded_rect.set_height(rect().height() + box_model().padding().top.to_px() + box_model().padding().bottom.to_px());
auto bgcolor = style_properties().property("background-color");
auto bgcolor = style().property("background-color");
if (bgcolor.has_value() && bgcolor.value()->is_color()) {
context.painter().fill_rect(padded_rect, bgcolor.value()->to_color());
}
auto border_width_value = style_properties().property("border-width");
auto border_color_value = style_properties().property("border-color");
auto border_style_value = style_properties().property("border-style");
auto border_width_value = style().property("border-width");
auto border_color_value = style().property("border-color");
auto border_style_value = style().property("border-style");
if (border_width_value.has_value() && border_color_value.has_value()) {
int border_width = border_width_value.value()->to_length().to_px();
Color border_color = border_color_value.value()->to_color();

View file

@ -62,11 +62,11 @@ public:
virtual LayoutNode& inline_wrapper() { return *this; }
const StyleProperties& style_properties() const
const StyleProperties& style() const
{
if (m_style_properties)
return *m_style_properties;
return parent()->style_properties();
return parent()->style();
}
void inserted_into(LayoutNode&) {}

View file

@ -18,8 +18,8 @@ LayoutText::~LayoutText()
void LayoutText::load_font()
{
auto font_family = style_properties().string_or_fallback("font-family", "Katica");
auto font_weight = style_properties().string_or_fallback("font-weight", "normal");
auto font_family = style().string_or_fallback("font-family", "Katica");
auto font_weight = style().string_or_fallback("font-weight", "normal");
String weight;
if (font_weight == "lighter")
@ -78,11 +78,11 @@ static bool is_all_whitespace(const String& string)
return true;
}
const String& LayoutText::text_for_style(const StyleProperties& style_properties) const
const String& LayoutText::text_for_style(const StyleProperties& style) const
{
static String one_space = " ";
if (is_all_whitespace(node().data())) {
if (style_properties.string_or_fallback("white-space", "normal") == "normal")
if (style.string_or_fallback("white-space", "normal") == "normal")
return one_space;
}
return node().data();
@ -93,8 +93,8 @@ void LayoutText::render_fragment(RenderingContext& context, const LineBoxFragmen
auto& painter = context.painter();
painter.set_font(*m_font);
auto color = style_properties().color_or_fallback("color", Color::Black);
auto text_decoration = style_properties().string_or_fallback("text-decoration", "none");
auto color = style().color_or_fallback("color", Color::Black);
auto text_decoration = style().string_or_fallback("text-decoration", "none");
bool is_underline = text_decoration == "underline";
if (is_underline)
@ -185,7 +185,7 @@ void LayoutText::split_into_lines(LayoutBlock& container)
line_boxes.append(LineBox());
int available_width = container.rect().width() - line_boxes.last().width();
bool is_preformatted = style_properties().string_or_fallback("white-space", "normal") == "pre";
bool is_preformatted = style().string_or_fallback("white-space", "normal") == "pre";
if (is_preformatted) {
for_each_source_line([&](const Utf8View& view, int start, int length) {
line_boxes.last().add_fragment(*this, start, length, m_font->width(view), line_height);

View file

@ -22,7 +22,7 @@ public:
virtual void split_into_lines(LayoutBlock& container) override;
const StyleProperties& style_properties() const { return parent()->style_properties(); }
const StyleProperties& style() const { return parent()->style(); }
private:
template<typename Callback>