Ver código fonte

LibHTML: Rename "style_properties" to "style" everywhere

Andreas Kling 5 anos atrás
pai
commit
15f3e64862

+ 9 - 9
Libraries/LibHTML/CSS/StyleResolver.cpp

@@ -151,23 +151,23 @@ bool StyleResolver::is_inherited_property(const StringView& name)
     return inherited_properties.contains(name);
 }
 
-NonnullRefPtr<StyleProperties> StyleResolver::resolve_style(const Element& element, const StyleProperties* parent_properties) const
+NonnullRefPtr<StyleProperties> 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<StyleProperties> 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;
 }

+ 1 - 1
Libraries/LibHTML/CSS/StyleResolver.h

@@ -18,7 +18,7 @@ public:
     Document& document() { return m_document; }
     const Document& document() const { return m_document; }
 
-    NonnullRefPtr<StyleProperties> resolve_style(const Element&, const StyleProperties* parent_properties) const;
+    NonnullRefPtr<StyleProperties> resolve_style(const Element&, const StyleProperties* parent_style) const;
 
     NonnullRefPtrVector<StyleRule> collect_matching_rules(const Element&) const;
 

+ 1 - 1
Libraries/LibHTML/DOM/Document.h

@@ -68,7 +68,7 @@ public:
     Function<void()> on_invalidate_layout;
 
 private:
-    virtual RefPtr<LayoutNode> create_layout_node(const StyleResolver&, const StyleProperties* parent_properties) const override;
+    virtual RefPtr<LayoutNode> create_layout_node(const StyleResolver&, const StyleProperties* parent_style) const override;
 
     OwnPtr<StyleResolver> m_style_resolver;
     NonnullRefPtrVector<StyleSheet> m_sheets;

+ 5 - 5
Libraries/LibHTML/DOM/Element.cpp

@@ -69,19 +69,19 @@ bool Element::has_class(const StringView& class_name) const
     return false;
 }
 
-RefPtr<LayoutNode> Element::create_layout_node(const StyleResolver& resolver, const StyleProperties* parent_properties) const
+RefPtr<LayoutNode> 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();
 }

+ 1 - 1
Libraries/LibHTML/DOM/Element.h

@@ -46,7 +46,7 @@ public:
     virtual void parse_attribute(const String& name, const String& value);
 
 private:
-    RefPtr<LayoutNode> create_layout_node(const StyleResolver&, const StyleProperties* parent_properties) const override;
+    RefPtr<LayoutNode> 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;

+ 3 - 3
Libraries/LibHTML/DOM/Node.cpp

@@ -19,9 +19,9 @@ Node::~Node()
 {
 }
 
-RefPtr<LayoutNode> Node::create_layout_tree(const StyleResolver& resolver, const StyleProperties* parent_properties) const
+RefPtr<LayoutNode> 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<LayoutNode> 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<const LayoutText&>(*layout_child).text_for_style(*parent_properties) == " ")
+            if (layout_child->is_text() && static_cast<const LayoutText&>(*layout_child).text_for_style(*parent_style) == " ")
                 continue;
             layout_node->inline_wrapper().append_child(*layout_child);
         } else {

+ 2 - 2
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<LayoutNode> create_layout_node(const StyleResolver&, const StyleProperties* parent_properties) const = 0;
-    RefPtr<LayoutNode> create_layout_tree(const StyleResolver&, const StyleProperties* parent_properties) const;
+    virtual RefPtr<LayoutNode> create_layout_node(const StyleResolver&, const StyleProperties* parent_style) const = 0;
+    RefPtr<LayoutNode> create_layout_tree(const StyleResolver&, const StyleProperties* parent_style) const;
 
     virtual String tag_name() const = 0;
 

+ 1 - 1
Libraries/LibHTML/DOM/Text.h

@@ -15,7 +15,7 @@ public:
     virtual String text_content() const override { return m_data; }
 
 private:
-    virtual RefPtr<LayoutNode> create_layout_node(const StyleResolver&, const StyleProperties* parent_properties) const override;
+    virtual RefPtr<LayoutNode> create_layout_node(const StyleResolver&, const StyleProperties* parent_style) const override;
 
     String m_data;
 };

+ 20 - 20
Libraries/LibHTML/Layout/LayoutBlock.cpp

@@ -4,8 +4,8 @@
 #include <LibHTML/Layout/LayoutBlock.h>
 #include <LibHTML/Layout/LayoutInline.h>
 
-LayoutBlock::LayoutBlock(const Node* node, NonnullRefPtr<StyleProperties> style_properties)
-    : LayoutNode(node, move(style_properties))
+LayoutBlock::LayoutBlock(const Node* node, NonnullRefPtr<StyleProperties> 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();

+ 2 - 2
Libraries/LibHTML/Layout/LayoutDocument.cpp

@@ -1,8 +1,8 @@
 #include <LibHTML/Frame.h>
 #include <LibHTML/Layout/LayoutDocument.h>
 
-LayoutDocument::LayoutDocument(const Document& document, NonnullRefPtr<StyleProperties> style_properties)
-    : LayoutBlock(&document, move(style_properties))
+LayoutDocument::LayoutDocument(const Document& document, NonnullRefPtr<StyleProperties> style)
+    : LayoutBlock(&document, move(style))
 {
 }
 

+ 2 - 2
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<StyleProperties> style_properties)
+LayoutNode::LayoutNode(const Node* node, RefPtr<StyleProperties> style)
     : m_node(node)
-    , m_style_properties(move(style_properties))
+    , m_style(move(style))
 {
     if (m_node)
         m_node->set_layout_node({}, this);

+ 6 - 6
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<StyleProperties> m_style_properties;
-    BoxModelMetrics m_style;
+    RefPtr<StyleProperties> m_style;
+    BoxModelMetrics m_box_metrics;
     Rect m_rect;
     bool m_inline { false };
 };