1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:27: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

@ -27,15 +27,15 @@
#include <LibWeb/CSS/Length.h>
#include <LibWeb/DOM/Node.h>
#include <LibWeb/Dump.h>
#include <LibWeb/Layout/BlockBox.h>
#include <LibWeb/Layout/Box.h>
#include <LibWeb/Layout/InlineFormattingContext.h>
#include <LibWeb/Layout/LayoutBlock.h>
#include <LibWeb/Layout/LayoutBox.h>
#include <LibWeb/Layout/LayoutInline.h>
#include <LibWeb/Layout/LayoutReplaced.h>
#include <LibWeb/Layout/InlineNode.h>
#include <LibWeb/Layout/ReplacedBox.h>
namespace Web::Layout {
InlineFormattingContext::InlineFormattingContext(LayoutBox& containing_block)
InlineFormattingContext::InlineFormattingContext(Box& containing_block)
: FormattingContext(containing_block)
{
}
@ -46,7 +46,7 @@ InlineFormattingContext::~InlineFormattingContext()
void InlineFormattingContext::run(LayoutMode layout_mode)
{
auto& containing_block = downcast<LayoutBlock>(context_box());
auto& containing_block = downcast<BlockBox>(context_box());
ASSERT(containing_block.children_are_inline());
containing_block.line_boxes().clear();
@ -129,7 +129,7 @@ void InlineFormattingContext::run(LayoutMode layout_mode)
}
if (fragment.layout_node().is_box())
dimension_box_on_line(const_cast<LayoutBox&>(downcast<LayoutBox>(fragment.layout_node())), layout_mode);
dimension_box_on_line(const_cast<Box&>(downcast<Box>(fragment.layout_node())), layout_mode);
float final_line_box_width = 0;
for (auto& fragment : line_box.fragments())
@ -149,19 +149,19 @@ void InlineFormattingContext::run(LayoutMode layout_mode)
containing_block.set_height(content_height);
}
void InlineFormattingContext::dimension_box_on_line(LayoutBox& box, LayoutMode layout_mode)
void InlineFormattingContext::dimension_box_on_line(Box& box, LayoutMode layout_mode)
{
auto& containing_block = downcast<LayoutBlock>(context_box());
auto& containing_block = downcast<BlockBox>(context_box());
if (box.is_replaced()) {
auto& replaced = const_cast<LayoutReplaced&>(downcast<LayoutReplaced>(box));
auto& replaced = const_cast<ReplacedBox&>(downcast<ReplacedBox>(box));
replaced.set_width(replaced.calculate_width());
replaced.set_height(replaced.calculate_height());
return;
}
if (box.is_inline_block()) {
auto& inline_block = const_cast<LayoutBlock&>(downcast<LayoutBlock>(box));
auto& inline_block = const_cast<BlockBox&>(downcast<BlockBox>(box));
if (inline_block.style().width().is_undefined_or_auto()) {
auto result = calculate_shrink_to_fit_widths(inline_block);