mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:47: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:
parent
f358f2255f
commit
5aeab9878e
114 changed files with 863 additions and 880 deletions
|
@ -25,7 +25,7 @@
|
|||
*/
|
||||
|
||||
#include <LibWeb/DOM/Comment.h>
|
||||
#include <LibWeb/Layout/LayoutText.h>
|
||||
#include <LibWeb/Layout/TextNode.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
#include <LibWeb/HTML/HTMLTitleElement.h>
|
||||
#include <LibWeb/InProcessWebView.h>
|
||||
#include <LibWeb/Layout/BlockFormattingContext.h>
|
||||
#include <LibWeb/Layout/LayoutDocument.h>
|
||||
#include <LibWeb/Layout/InitialContainingBlockBox.h>
|
||||
#include <LibWeb/Layout/LayoutTreeBuilder.h>
|
||||
#include <LibWeb/Namespace.h>
|
||||
#include <LibWeb/Origin.h>
|
||||
|
@ -271,7 +271,7 @@ void Document::tear_down_layout_tree()
|
|||
// Gather up all the layout nodes in a vector and detach them from parents
|
||||
// while the vector keeps them alive.
|
||||
|
||||
NonnullRefPtrVector<LayoutNode> layout_nodes;
|
||||
NonnullRefPtrVector<Layout::Node> layout_nodes;
|
||||
|
||||
m_layout_root->for_each_in_subtree([&](auto& layout_node) {
|
||||
layout_nodes.append(layout_node);
|
||||
|
@ -347,12 +347,12 @@ void Document::layout()
|
|||
return;
|
||||
|
||||
if (!m_layout_root) {
|
||||
LayoutTreeBuilder tree_builder;
|
||||
m_layout_root = static_ptr_cast<LayoutDocument>(tree_builder.build(*this));
|
||||
Layout::LayoutTreeBuilder tree_builder;
|
||||
m_layout_root = static_ptr_cast<Layout::InitialContainingBlockBox>(tree_builder.build(*this));
|
||||
}
|
||||
|
||||
Layout::BlockFormattingContext root_formatting_context(*m_layout_root);
|
||||
root_formatting_context.run(LayoutMode::Default);
|
||||
root_formatting_context.run(Layout::LayoutMode::Default);
|
||||
|
||||
m_layout_root->set_needs_display();
|
||||
|
||||
|
@ -380,9 +380,9 @@ void Document::update_layout()
|
|||
layout();
|
||||
}
|
||||
|
||||
RefPtr<LayoutNode> Document::create_layout_node(const CSS::StyleProperties*)
|
||||
RefPtr<Layout::Node> Document::create_layout_node(const CSS::StyleProperties*)
|
||||
{
|
||||
return adopt(*new LayoutDocument(*this, CSS::StyleProperties::create()));
|
||||
return adopt(*new Layout::InitialContainingBlockBox(*this, CSS::StyleProperties::create()));
|
||||
}
|
||||
|
||||
void Document::set_link_color(Color color)
|
||||
|
@ -400,14 +400,14 @@ void Document::set_visited_link_color(Color color)
|
|||
m_visited_link_color = color;
|
||||
}
|
||||
|
||||
const LayoutDocument* Document::layout_node() const
|
||||
const Layout::InitialContainingBlockBox* Document::layout_node() const
|
||||
{
|
||||
return static_cast<const LayoutDocument*>(Node::layout_node());
|
||||
return static_cast<const Layout::InitialContainingBlockBox*>(Node::layout_node());
|
||||
}
|
||||
|
||||
LayoutDocument* Document::layout_node()
|
||||
Layout::InitialContainingBlockBox* Document::layout_node()
|
||||
{
|
||||
return static_cast<LayoutDocument*>(Node::layout_node());
|
||||
return static_cast<Layout::InitialContainingBlockBox*>(Node::layout_node());
|
||||
}
|
||||
|
||||
void Document::set_inspected_node(Node* node)
|
||||
|
|
|
@ -125,8 +125,8 @@ public:
|
|||
|
||||
virtual bool is_child_allowed(const Node&) const override;
|
||||
|
||||
const LayoutDocument* layout_node() const;
|
||||
LayoutDocument* layout_node();
|
||||
const Layout::InitialContainingBlockBox* layout_node() const;
|
||||
Layout::InitialContainingBlockBox* layout_node();
|
||||
|
||||
void schedule_style_update();
|
||||
|
||||
|
@ -212,7 +212,7 @@ public:
|
|||
private:
|
||||
explicit Document(const URL&);
|
||||
|
||||
virtual RefPtr<LayoutNode> create_layout_node(const CSS::StyleProperties* parent_style) override;
|
||||
virtual RefPtr<Layout::Node> create_layout_node(const CSS::StyleProperties* parent_style) override;
|
||||
|
||||
void tear_down_layout_tree();
|
||||
|
||||
|
@ -244,7 +244,7 @@ private:
|
|||
|
||||
RefPtr<Window> m_window;
|
||||
|
||||
RefPtr<LayoutDocument> m_layout_root;
|
||||
RefPtr<Layout::InitialContainingBlockBox> m_layout_root;
|
||||
|
||||
Optional<Color> m_link_color;
|
||||
Optional<Color> m_active_link_color;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include <LibWeb/DOM/ParentNode.h>
|
||||
#include <LibWeb/DOM/TagNames.h>
|
||||
#include <LibWeb/HTML/AttributeNames.h>
|
||||
#include <LibWeb/Layout/LayoutNode.h>
|
||||
#include <LibWeb/Layout/Node.h>
|
||||
#include <LibWeb/QualifiedName.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
@ -82,8 +82,8 @@ public:
|
|||
|
||||
void recompute_style();
|
||||
|
||||
LayoutNodeWithStyle* layout_node() { return static_cast<LayoutNodeWithStyle*>(Node::layout_node()); }
|
||||
const LayoutNodeWithStyle* layout_node() const { return static_cast<const LayoutNodeWithStyle*>(Node::layout_node()); }
|
||||
Layout::NodeWithStyle* layout_node() { return static_cast<Layout::NodeWithStyle*>(Node::layout_node()); }
|
||||
const Layout::NodeWithStyle* layout_node() const { return static_cast<const Layout::NodeWithStyle*>(Node::layout_node()); }
|
||||
|
||||
String name() const { return attribute(HTML::AttributeNames::name); }
|
||||
|
||||
|
@ -97,7 +97,7 @@ public:
|
|||
virtual bool is_focusable() const { return false; }
|
||||
|
||||
protected:
|
||||
RefPtr<LayoutNode> create_layout_node(const CSS::StyleProperties* parent_style) override;
|
||||
RefPtr<Layout::Node> create_layout_node(const CSS::StyleProperties* parent_style) override;
|
||||
|
||||
private:
|
||||
Attribute* find_attribute(const FlyString& name);
|
||||
|
|
|
@ -39,11 +39,11 @@
|
|||
#include <LibWeb/DOM/EventListener.h>
|
||||
#include <LibWeb/DOM/Node.h>
|
||||
#include <LibWeb/HTML/HTMLAnchorElement.h>
|
||||
#include <LibWeb/Layout/LayoutBlock.h>
|
||||
#include <LibWeb/Layout/LayoutDocument.h>
|
||||
#include <LibWeb/Layout/LayoutInline.h>
|
||||
#include <LibWeb/Layout/LayoutNode.h>
|
||||
#include <LibWeb/Layout/LayoutText.h>
|
||||
#include <LibWeb/Layout/BlockBox.h>
|
||||
#include <LibWeb/Layout/InitialContainingBlockBox.h>
|
||||
#include <LibWeb/Layout/InlineNode.h>
|
||||
#include <LibWeb/Layout/Node.h>
|
||||
#include <LibWeb/Layout/TextNode.h>
|
||||
|
||||
//#define EVENT_DEBUG
|
||||
|
||||
|
@ -105,7 +105,7 @@ void Node::set_text_content(const String& content)
|
|||
document().invalidate_layout();
|
||||
}
|
||||
|
||||
RefPtr<LayoutNode> Node::create_layout_node(const CSS::StyleProperties*)
|
||||
RefPtr<Layout::Node> Node::create_layout_node(const CSS::StyleProperties*)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ void Node::removed_last_ref()
|
|||
delete this;
|
||||
}
|
||||
|
||||
void Node::set_layout_node(Badge<LayoutNode>, LayoutNode* layout_node) const
|
||||
void Node::set_layout_node(Badge<Layout::Node>, Layout::Node* layout_node) const
|
||||
{
|
||||
if (layout_node)
|
||||
m_layout_node = layout_node->make_weak_ptr();
|
||||
|
|
|
@ -84,7 +84,7 @@ public:
|
|||
RefPtr<Node> insert_before(NonnullRefPtr<Node> node, RefPtr<Node> child, bool notify = true);
|
||||
void remove_all_children();
|
||||
|
||||
virtual RefPtr<LayoutNode> create_layout_node(const CSS::StyleProperties* parent_style);
|
||||
virtual RefPtr<Layout::Node> create_layout_node(const CSS::StyleProperties* parent_style);
|
||||
|
||||
virtual FlyString node_name() const = 0;
|
||||
|
||||
|
@ -115,10 +115,10 @@ public:
|
|||
virtual void removed_from(Node&) { }
|
||||
virtual void children_changed() { }
|
||||
|
||||
const LayoutNode* layout_node() const { return m_layout_node; }
|
||||
LayoutNode* layout_node() { return m_layout_node; }
|
||||
const Layout::Node* layout_node() const { return m_layout_node; }
|
||||
Layout::Node* layout_node() { return m_layout_node; }
|
||||
|
||||
void set_layout_node(Badge<LayoutNode>, LayoutNode*) const;
|
||||
void set_layout_node(Badge<Layout::Node>, Layout::Node*) const;
|
||||
|
||||
virtual bool is_child_allowed(const Node&) const { return true; }
|
||||
|
||||
|
@ -138,7 +138,7 @@ protected:
|
|||
Node(Document&, NodeType);
|
||||
|
||||
Document* m_document { nullptr };
|
||||
mutable WeakPtr<LayoutNode> m_layout_node;
|
||||
mutable WeakPtr<Layout::Node> m_layout_node;
|
||||
NodeType m_type { NodeType::INVALID };
|
||||
bool m_needs_style_update { true };
|
||||
};
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
*/
|
||||
|
||||
#include <LibWeb/DOM/Text.h>
|
||||
#include <LibWeb/Layout/LayoutText.h>
|
||||
#include <LibWeb/Layout/TextNode.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
||||
|
@ -38,9 +38,9 @@ Text::~Text()
|
|||
{
|
||||
}
|
||||
|
||||
RefPtr<LayoutNode> Text::create_layout_node(const CSS::StyleProperties*)
|
||||
RefPtr<Layout::Node> Text::create_layout_node(const CSS::StyleProperties*)
|
||||
{
|
||||
return adopt(*new LayoutText(document(), *this));
|
||||
return adopt(*new Layout::TextNode(document(), *this));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
virtual FlyString node_name() const override { return "#text"; }
|
||||
|
||||
private:
|
||||
virtual RefPtr<LayoutNode> create_layout_node(const CSS::StyleProperties* parent_style) override;
|
||||
virtual RefPtr<Layout::Node> create_layout_node(const CSS::StyleProperties* parent_style) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue