LibHTML: Start fleshing out a basic layout tree.

This commit is contained in:
Andreas Kling
2019-06-15 22:49:44 +02:00
parent f8a86b5164
commit 8a0e21b22b
24 changed files with 338 additions and 18 deletions

View File

@@ -1,4 +1,6 @@
#include <LibHTML/Element.h>
#include <LibHTML/LayoutBlock.h>
#include <LibHTML/LayoutInline.h>
Element::Element(const String& tag_name)
: ParentNode(NodeType::ELEMENT_NODE)
@@ -47,3 +49,18 @@ void Element::set_attributes(Vector<Attribute>&& attributes)
{
m_attributes = move(attributes);
}
RetainPtr<LayoutNode> Element::create_layout_node()
{
if (m_tag_name == "html")
return adopt(*new LayoutBlock(*this));
if (m_tag_name == "body")
return adopt(*new LayoutBlock(*this));
if (m_tag_name == "h1")
return adopt(*new LayoutBlock(*this));
if (m_tag_name == "p")
return adopt(*new LayoutBlock(*this));
if (m_tag_name == "b")
return adopt(*new LayoutInline(*this));
return nullptr;
}