mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:07:44 +00:00
LibHTML: Start fleshing out a basic layout tree.
This commit is contained in:
parent
f8a86b5164
commit
8a0e21b22b
24 changed files with 338 additions and 18 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue