Browse Source

LibHTML: Non-element (Text) Nodes should get style from their parent

Text nodes don't have style of their own, so just inherit all the style
from the parent element.
Andreas Kling 5 năm trước cách đây
mục cha
commit
ed39e0f6f7
1 tập tin đã thay đổi với 6 bổ sung1 xóa
  1. 6 1
      Libraries/LibHTML/DOM/Node.cpp

+ 6 - 1
Libraries/LibHTML/DOM/Node.cpp

@@ -24,7 +24,12 @@ RefPtr<LayoutNode> Node::create_layout_node(const StyleResolver& resolver, const
     if (is_document())
         return adopt(*new LayoutDocument(static_cast<const Document&>(*this), {}));
 
-    auto style_properties = resolver.resolve_style(static_cast<const Element&>(*this), parent_properties);
+    StyleProperties style_properties;
+    if (is_element())
+        style_properties = resolver.resolve_style(static_cast<const Element&>(*this), parent_properties);
+    else
+        style_properties = *parent_properties;
+
     auto display_property = style_properties.property("display");
     String display = display_property.has_value() ? display_property.release_value()->to_string() : "inline";