From 15f3e64862e7fd292849f149fc0a251111fd59da Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 7 Oct 2019 09:23:53 +0200 Subject: [PATCH] LibHTML: Rename "style_properties" to "style" everywhere --- Libraries/LibHTML/CSS/StyleResolver.cpp | 18 +++++----- Libraries/LibHTML/CSS/StyleResolver.h | 2 +- Libraries/LibHTML/DOM/Document.h | 2 +- Libraries/LibHTML/DOM/Element.cpp | 10 +++--- Libraries/LibHTML/DOM/Element.h | 2 +- Libraries/LibHTML/DOM/Node.cpp | 6 ++-- Libraries/LibHTML/DOM/Node.h | 4 +-- Libraries/LibHTML/DOM/Text.h | 2 +- Libraries/LibHTML/Layout/LayoutBlock.cpp | 40 ++++++++++----------- Libraries/LibHTML/Layout/LayoutDocument.cpp | 4 +-- Libraries/LibHTML/Layout/LayoutNode.cpp | 4 +-- Libraries/LibHTML/Layout/LayoutNode.h | 12 +++---- 12 files changed, 53 insertions(+), 53 deletions(-) diff --git a/Libraries/LibHTML/CSS/StyleResolver.cpp b/Libraries/LibHTML/CSS/StyleResolver.cpp index 28dd0f2534c..58e5a6cee7e 100644 --- a/Libraries/LibHTML/CSS/StyleResolver.cpp +++ b/Libraries/LibHTML/CSS/StyleResolver.cpp @@ -151,23 +151,23 @@ bool StyleResolver::is_inherited_property(const StringView& name) return inherited_properties.contains(name); } -NonnullRefPtr StyleResolver::resolve_style(const Element& element, const StyleProperties* parent_properties) const +NonnullRefPtr StyleResolver::resolve_style(const Element& element, const StyleProperties* parent_style) const { - auto style_properties = StyleProperties::create(); + auto style = StyleProperties::create(); - if (parent_properties) { - parent_properties->for_each_property([&](const StringView& name, auto& value) { + if (parent_style) { + parent_style->for_each_property([&](const StringView& name, auto& value) { if (is_inherited_property(name)) - style_properties->set_property(name, value); + style->set_property(name, value); }); } - element.apply_presentational_hints(*style_properties); + element.apply_presentational_hints(*style); auto matching_rules = collect_matching_rules(element); for (auto& rule : matching_rules) { for (auto& property : rule.declaration().properties()) { - style_properties->set_property(property.name, property.value); + style->set_property(property.name, property.value); } } @@ -175,10 +175,10 @@ NonnullRefPtr StyleResolver::resolve_style(const Element& eleme if (!style_attribute.is_null()) { if (auto declaration = parse_css_declaration(style_attribute)) { for (auto& property : declaration->properties()) { - style_properties->set_property(property.name, property.value); + style->set_property(property.name, property.value); } } } - return style_properties; + return style; } diff --git a/Libraries/LibHTML/CSS/StyleResolver.h b/Libraries/LibHTML/CSS/StyleResolver.h index d91470ccdf4..fd0a358374b 100644 --- a/Libraries/LibHTML/CSS/StyleResolver.h +++ b/Libraries/LibHTML/CSS/StyleResolver.h @@ -18,7 +18,7 @@ public: Document& document() { return m_document; } const Document& document() const { return m_document; } - NonnullRefPtr resolve_style(const Element&, const StyleProperties* parent_properties) const; + NonnullRefPtr resolve_style(const Element&, const StyleProperties* parent_style) const; NonnullRefPtrVector collect_matching_rules(const Element&) const; diff --git a/Libraries/LibHTML/DOM/Document.h b/Libraries/LibHTML/DOM/Document.h index 1c54caae775..bfef5ec43b2 100644 --- a/Libraries/LibHTML/DOM/Document.h +++ b/Libraries/LibHTML/DOM/Document.h @@ -68,7 +68,7 @@ public: Function on_invalidate_layout; private: - virtual RefPtr create_layout_node(const StyleResolver&, const StyleProperties* parent_properties) const override; + virtual RefPtr create_layout_node(const StyleResolver&, const StyleProperties* parent_style) const override; OwnPtr m_style_resolver; NonnullRefPtrVector m_sheets; diff --git a/Libraries/LibHTML/DOM/Element.cpp b/Libraries/LibHTML/DOM/Element.cpp index 2662562f4d1..19dd68d121c 100644 --- a/Libraries/LibHTML/DOM/Element.cpp +++ b/Libraries/LibHTML/DOM/Element.cpp @@ -69,19 +69,19 @@ bool Element::has_class(const StringView& class_name) const return false; } -RefPtr Element::create_layout_node(const StyleResolver& resolver, const StyleProperties* parent_properties) const +RefPtr Element::create_layout_node(const StyleResolver& resolver, const StyleProperties* parent_style) const { - auto style_properties = resolver.resolve_style(*this, parent_properties); + auto style = resolver.resolve_style(*this, parent_style); - auto display_property = style_properties->property("display"); + auto display_property = style->property("display"); String display = display_property.has_value() ? display_property.release_value()->to_string() : "inline"; if (display == "none") return nullptr; if (display == "block" || display == "list-item") - return adopt(*new LayoutBlock(this, move(style_properties))); + return adopt(*new LayoutBlock(this, move(style))); if (display == "inline") - return adopt(*new LayoutInline(*this, move(style_properties))); + return adopt(*new LayoutInline(*this, move(style))); ASSERT_NOT_REACHED(); } diff --git a/Libraries/LibHTML/DOM/Element.h b/Libraries/LibHTML/DOM/Element.h index 2b0027d2e38..db3e260ed8c 100644 --- a/Libraries/LibHTML/DOM/Element.h +++ b/Libraries/LibHTML/DOM/Element.h @@ -46,7 +46,7 @@ public: virtual void parse_attribute(const String& name, const String& value); private: - RefPtr create_layout_node(const StyleResolver&, const StyleProperties* parent_properties) const override; + RefPtr create_layout_node(const StyleResolver&, const StyleProperties* parent_style) const override; Attribute* find_attribute(const String& name); const Attribute* find_attribute(const String& name) const; diff --git a/Libraries/LibHTML/DOM/Node.cpp b/Libraries/LibHTML/DOM/Node.cpp index 630a4cded91..af590b39b4b 100644 --- a/Libraries/LibHTML/DOM/Node.cpp +++ b/Libraries/LibHTML/DOM/Node.cpp @@ -19,9 +19,9 @@ Node::~Node() { } -RefPtr Node::create_layout_tree(const StyleResolver& resolver, const StyleProperties* parent_properties) const +RefPtr Node::create_layout_tree(const StyleResolver& resolver, const StyleProperties* parent_style) const { - auto layout_node = create_layout_node(resolver, parent_properties); + auto layout_node = create_layout_node(resolver, parent_style); if (!layout_node) return nullptr; @@ -45,7 +45,7 @@ RefPtr Node::create_layout_tree(const StyleResolver& resolver, const for (auto layout_child : layout_children) if (have_block_children && have_inline_children && !layout_child->is_block()) { - if (layout_child->is_text() && static_cast(*layout_child).text_for_style(*parent_properties) == " ") + if (layout_child->is_text() && static_cast(*layout_child).text_for_style(*parent_style) == " ") continue; layout_node->inline_wrapper().append_child(*layout_child); } else { diff --git a/Libraries/LibHTML/DOM/Node.h b/Libraries/LibHTML/DOM/Node.h index 5d4eac4c3ad..68f24b4c6f1 100644 --- a/Libraries/LibHTML/DOM/Node.h +++ b/Libraries/LibHTML/DOM/Node.h @@ -32,8 +32,8 @@ public: bool is_document() const { return type() == NodeType::DOCUMENT_NODE; } bool is_parent_node() const { return is_element() || is_document(); } - virtual RefPtr create_layout_node(const StyleResolver&, const StyleProperties* parent_properties) const = 0; - RefPtr create_layout_tree(const StyleResolver&, const StyleProperties* parent_properties) const; + virtual RefPtr create_layout_node(const StyleResolver&, const StyleProperties* parent_style) const = 0; + RefPtr create_layout_tree(const StyleResolver&, const StyleProperties* parent_style) const; virtual String tag_name() const = 0; diff --git a/Libraries/LibHTML/DOM/Text.h b/Libraries/LibHTML/DOM/Text.h index b7b55f1f70f..c507dbb3ba6 100644 --- a/Libraries/LibHTML/DOM/Text.h +++ b/Libraries/LibHTML/DOM/Text.h @@ -15,7 +15,7 @@ public: virtual String text_content() const override { return m_data; } private: - virtual RefPtr create_layout_node(const StyleResolver&, const StyleProperties* parent_properties) const override; + virtual RefPtr create_layout_node(const StyleResolver&, const StyleProperties* parent_style) const override; String m_data; }; diff --git a/Libraries/LibHTML/Layout/LayoutBlock.cpp b/Libraries/LibHTML/Layout/LayoutBlock.cpp index 626ea2e737a..ecf117b2c20 100644 --- a/Libraries/LibHTML/Layout/LayoutBlock.cpp +++ b/Libraries/LibHTML/Layout/LayoutBlock.cpp @@ -4,8 +4,8 @@ #include #include -LayoutBlock::LayoutBlock(const Node* node, NonnullRefPtr style_properties) - : LayoutNode(node, move(style_properties)) +LayoutBlock::LayoutBlock(const Node* node, NonnullRefPtr style) + : LayoutNode(node, move(style)) { } @@ -79,17 +79,17 @@ void LayoutBlock::layout_inline_children() void LayoutBlock::compute_width() { - auto& style_properties = this->style(); + auto& style = this->style(); auto auto_value = Length(); auto zero_value = Length(0, Length::Type::Absolute); - auto width = style_properties.length_or_fallback("width", auto_value); - auto margin_left = style_properties.length_or_fallback("margin-left", zero_value); - auto margin_right = style_properties.length_or_fallback("margin-right", zero_value); - auto border_left = style_properties.length_or_fallback("border-left", zero_value); - auto border_right = style_properties.length_or_fallback("border-right", zero_value); - auto padding_left = style_properties.length_or_fallback("padding-left", zero_value); - auto padding_right = style_properties.length_or_fallback("padding-right", zero_value); + auto width = style.length_or_fallback("width", auto_value); + auto margin_left = style.length_or_fallback("margin-left", zero_value); + auto margin_right = style.length_or_fallback("margin-right", zero_value); + auto border_left = style.length_or_fallback("border-left", zero_value); + auto border_right = style.length_or_fallback("border-right", zero_value); + auto padding_left = style.length_or_fallback("padding-left", zero_value); + auto padding_right = style.length_or_fallback("padding-right", zero_value); #ifdef HTML_DEBUG dbg() << " Left: " << margin_left << "+" << border_left << "+" << padding_left; @@ -153,19 +153,19 @@ void LayoutBlock::compute_width() void LayoutBlock::compute_position() { - auto& style_properties = this->style(); + auto& style = this->style(); auto auto_value = Length(); auto zero_value = Length(0, Length::Type::Absolute); - auto width = style_properties.length_or_fallback("width", auto_value); + auto width = style.length_or_fallback("width", auto_value); - box_model().margin().top = style_properties.length_or_fallback("margin-top", zero_value); - box_model().margin().bottom = style_properties.length_or_fallback("margin-bottom", zero_value); - box_model().border().top = style_properties.length_or_fallback("border-top", zero_value); - box_model().border().bottom = style_properties.length_or_fallback("border-bottom", zero_value); - box_model().padding().top = style_properties.length_or_fallback("padding-top", zero_value); - box_model().padding().bottom = style_properties.length_or_fallback("padding-bottom", zero_value); + box_model().margin().top = style.length_or_fallback("margin-top", zero_value); + box_model().margin().bottom = style.length_or_fallback("margin-bottom", zero_value); + box_model().border().top = style.length_or_fallback("border-top", zero_value); + box_model().border().bottom = style.length_or_fallback("border-bottom", zero_value); + box_model().padding().top = style.length_or_fallback("padding-top", zero_value); + box_model().padding().bottom = style.length_or_fallback("padding-bottom", zero_value); rect().set_x(containing_block()->rect().x() + box_model().margin().left.to_px() + box_model().border().left.to_px() + box_model().padding().left.to_px()); int top_border = -1; @@ -182,9 +182,9 @@ void LayoutBlock::compute_position() void LayoutBlock::compute_height() { - auto& style_properties = this->style(); + auto& style = this->style(); - auto height_property = style_properties.property("height"); + auto height_property = style.property("height"); if (!height_property.has_value()) return; auto height_length = height_property.value()->to_length(); diff --git a/Libraries/LibHTML/Layout/LayoutDocument.cpp b/Libraries/LibHTML/Layout/LayoutDocument.cpp index 4fc43aca315..afd39456dd9 100644 --- a/Libraries/LibHTML/Layout/LayoutDocument.cpp +++ b/Libraries/LibHTML/Layout/LayoutDocument.cpp @@ -1,8 +1,8 @@ #include #include -LayoutDocument::LayoutDocument(const Document& document, NonnullRefPtr style_properties) - : LayoutBlock(&document, move(style_properties)) +LayoutDocument::LayoutDocument(const Document& document, NonnullRefPtr style) + : LayoutBlock(&document, move(style)) { } diff --git a/Libraries/LibHTML/Layout/LayoutNode.cpp b/Libraries/LibHTML/Layout/LayoutNode.cpp index 9373b521deb..e8e678457f4 100644 --- a/Libraries/LibHTML/Layout/LayoutNode.cpp +++ b/Libraries/LibHTML/Layout/LayoutNode.cpp @@ -7,9 +7,9 @@ //#define DRAW_BOXES_AROUND_LAYOUT_NODES //#define DRAW_BOXES_AROUND_HOVERED_NODES -LayoutNode::LayoutNode(const Node* node, RefPtr style_properties) +LayoutNode::LayoutNode(const Node* node, RefPtr style) : m_node(node) - , m_style_properties(move(style_properties)) + , m_style(move(style)) { if (m_node) m_node->set_layout_node({}, this); diff --git a/Libraries/LibHTML/Layout/LayoutNode.h b/Libraries/LibHTML/Layout/LayoutNode.h index f8a19d3edab..9c56408b330 100644 --- a/Libraries/LibHTML/Layout/LayoutNode.h +++ b/Libraries/LibHTML/Layout/LayoutNode.h @@ -27,8 +27,8 @@ public: Rect& rect() { return m_rect; } void set_rect(const Rect& rect) { m_rect = rect; } - BoxModelMetrics& box_model() { return m_style; } - const BoxModelMetrics& box_model() const { return m_style; } + BoxModelMetrics& box_model() { return m_box_metrics; } + const BoxModelMetrics& box_model() const { return m_box_metrics; } virtual HitTestResult hit_test(const Point&) const; @@ -68,8 +68,8 @@ public: const StyleProperties& style() const { - if (m_style_properties) - return *m_style_properties; + if (m_style) + return *m_style; return parent()->style(); } @@ -84,8 +84,8 @@ protected: private: const Node* m_node { nullptr }; - RefPtr m_style_properties; - BoxModelMetrics m_style; + RefPtr m_style; + BoxModelMetrics m_box_metrics; Rect m_rect; bool m_inline { false }; };