1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:07:35 +00:00

LibWeb: Rename LayoutNode classes and move them into Layout namespace

Bring the names of various boxes closer to spec language. This should
hopefully make things easier to understand and hack on. :^)

Some notable changes:

- LayoutNode -> Layout::Node
- LayoutBox -> Layout::Box
- LayoutBlock -> Layout::BlockBox
- LayoutReplaced -> Layout::ReplacedBox
- LayoutDocument -> Layout::InitialContainingBlockBox
- LayoutText -> Layout::TextNode
- LayoutInline -> Layout::InlineNode

Note that this is not strictly a "box tree" as we also hang inline/text
nodes in the same tree, and they don't generate boxes. (Instead, they
contribute line box fragments to their containing block!)
This commit is contained in:
Andreas Kling 2020-11-22 15:53:01 +01:00
parent f358f2255f
commit 5aeab9878e
114 changed files with 863 additions and 880 deletions

View file

@ -34,14 +34,14 @@
#include <LibWeb/DOM/Text.h>
#include <LibWeb/Dump.h>
#include <LibWeb/HTML/Parser/HTMLDocumentParser.h>
#include <LibWeb/Layout/LayoutBlock.h>
#include <LibWeb/Layout/LayoutInline.h>
#include <LibWeb/Layout/LayoutListItem.h>
#include <LibWeb/Layout/LayoutTable.h>
#include <LibWeb/Layout/LayoutTableCell.h>
#include <LibWeb/Layout/LayoutTableRow.h>
#include <LibWeb/Layout/LayoutTableRowGroup.h>
#include <LibWeb/Layout/BlockBox.h>
#include <LibWeb/Layout/InlineNode.h>
#include <LibWeb/Layout/LayoutTreeBuilder.h>
#include <LibWeb/Layout/ListItemBox.h>
#include <LibWeb/Layout/TableBox.h>
#include <LibWeb/Layout/TableCellBox.h>
#include <LibWeb/Layout/TableRowBox.h>
#include <LibWeb/Layout/TableRowGroupBox.h>
namespace Web::DOM {
@ -112,7 +112,7 @@ bool Element::has_class(const FlyString& class_name) const
return false;
}
RefPtr<LayoutNode> Element::create_layout_node(const CSS::StyleProperties* parent_style)
RefPtr<Layout::Node> Element::create_layout_node(const CSS::StyleProperties* parent_style)
{
auto style = document().style_resolver().resolve_style(*this, parent_style);
const_cast<Element&>(*this).m_resolved_style = style;
@ -125,26 +125,26 @@ RefPtr<LayoutNode> Element::create_layout_node(const CSS::StyleProperties* paren
return nullptr;
if (display == CSS::Display::Block)
return adopt(*new LayoutBlock(document(), this, move(style)));
return adopt(*new Layout::BlockBox(document(), this, move(style)));
if (display == CSS::Display::Inline) {
if (style->float_().value_or(CSS::Float::None) != CSS::Float::None)
return adopt(*new LayoutBlock(document(), this, move(style)));
return adopt(*new LayoutInline(document(), *this, move(style)));
return adopt(*new Layout::BlockBox(document(), this, move(style)));
return adopt(*new Layout::InlineNode(document(), *this, move(style)));
}
if (display == CSS::Display::ListItem)
return adopt(*new LayoutListItem(document(), *this, move(style)));
return adopt(*new Layout::ListItemBox(document(), *this, move(style)));
if (display == CSS::Display::Table)
return adopt(*new LayoutTable(document(), *this, move(style)));
return adopt(*new Layout::TableBox(document(), *this, move(style)));
if (display == CSS::Display::TableRow)
return adopt(*new LayoutTableRow(document(), *this, move(style)));
return adopt(*new Layout::TableRowBox(document(), *this, move(style)));
if (display == CSS::Display::TableCell)
return adopt(*new LayoutTableCell(document(), *this, move(style)));
return adopt(*new Layout::TableCellBox(document(), *this, move(style)));
if (display == CSS::Display::TableRowGroup || display == CSS::Display::TableHeaderGroup || display == CSS::Display::TableFooterGroup)
return adopt(*new LayoutTableRowGroup(document(), *this, move(style)));
return adopt(*new Layout::TableRowGroupBox(document(), *this, move(style)));
if (display == CSS::Display::InlineBlock) {
auto inline_block = adopt(*new LayoutBlock(document(), this, move(style)));
auto inline_block = adopt(*new Layout::BlockBox(document(), this, move(style)));
inline_block->set_inline(true);
return inline_block;
}
@ -206,7 +206,7 @@ void Element::recompute_style()
if (style->display() == CSS::Display::None)
return;
// We need a new layout tree here!
LayoutTreeBuilder tree_builder;
Layout::LayoutTreeBuilder tree_builder;
tree_builder.build(*this);
return;
}