1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 17:45:07 +00:00

LibWeb: Rename Layout::BlockBox => BlockContainer

There's a subtle difference here. A "block box" in the spec is a
block-level box, while a "block container" is a box whose children are
either all inline-level boxes in an IFC, or all block-level boxes
participating in a BFC.

Notably, an "inline-block" box is a "block container" but not a "block
box" since it is itself inline-level.
This commit is contained in:
Andreas Kling 2021-10-06 20:02:41 +02:00
parent 5408913b22
commit c4826eae4f
38 changed files with 95 additions and 94 deletions

View file

@ -30,7 +30,7 @@
#include <LibGUI/Window.h>
#include <LibJS/Interpreter.h>
#include <LibWeb/HTML/SyntaxHighlighter/SyntaxHighlighter.h>
#include <LibWeb/Layout/BlockBox.h>
#include <LibWeb/Layout/BlockContainer.h>
#include <LibWeb/Layout/InitialContainingBlock.h>
#include <LibWeb/Loader/ResourceLoader.h>
#include <LibWeb/OutOfProcessWebView.h>

View file

@ -183,7 +183,7 @@ set(SOURCES
HTML/WebSocket.cpp
HighResolutionTime/Performance.cpp
InProcessWebView.cpp
Layout/BlockBox.cpp
Layout/BlockContainer.cpp
Layout/BlockFormattingContext.cpp
Layout/Box.cpp
Layout/BoxModelMetrics.cpp

View file

@ -10,7 +10,7 @@
#include <LibGfx/FontDatabase.h>
#include <LibWeb/CSS/StyleProperties.h>
#include <LibWeb/FontCache.h>
#include <LibWeb/Layout/BlockBox.h>
#include <LibWeb/Layout/BlockContainer.h>
#include <LibWeb/Layout/Node.h>
namespace Web::CSS {

View file

@ -22,7 +22,7 @@
#include <LibWeb/Geometry/DOMRect.h>
#include <LibWeb/HTML/EventLoop/EventLoop.h>
#include <LibWeb/HTML/Parser/HTMLParser.h>
#include <LibWeb/Layout/BlockBox.h>
#include <LibWeb/Layout/BlockContainer.h>
#include <LibWeb/Layout/InlineNode.h>
#include <LibWeb/Layout/ListItemBox.h>
#include <LibWeb/Layout/TableBox.h>
@ -133,12 +133,12 @@ RefPtr<Layout::Node> Element::create_layout_node()
if (display.is_table_column() || display.is_table_column_group() || display.is_table_caption()) {
// FIXME: This is just an incorrect placeholder until we improve table layout support.
return adopt_ref(*new Layout::BlockBox(document(), this, move(style)));
return adopt_ref(*new Layout::BlockContainer(document(), this, move(style)));
}
if (display.is_inline_outside()) {
if (display.is_flow_root_inside()) {
auto block = adopt_ref(*new Layout::BlockBox(document(), this, move(style)));
auto block = adopt_ref(*new Layout::BlockContainer(document(), this, move(style)));
block->set_inline(true);
return block;
}
@ -149,7 +149,7 @@ RefPtr<Layout::Node> Element::create_layout_node()
}
if (display.is_flow_inside() || display.is_flow_root_inside() || display.is_flex_inside())
return adopt_ref(*new Layout::BlockBox(document(), this, move(style)));
return adopt_ref(*new Layout::BlockContainer(document(), this, move(style)));
TODO();
}

View file

@ -8,7 +8,7 @@
#include <LibWeb/DOM/Event.h>
#include <LibWeb/DOM/ShadowRoot.h>
#include <LibWeb/DOMParsing/InnerHTML.h>
#include <LibWeb/Layout/BlockBox.h>
#include <LibWeb/Layout/BlockContainer.h>
namespace Web::DOM {
@ -32,7 +32,7 @@ EventTarget* ShadowRoot::get_parent(const Event& event)
RefPtr<Layout::Node> ShadowRoot::create_layout_node()
{
return adopt_ref(*new Layout::BlockBox(document(), this, CSS::ComputedValues {}));
return adopt_ref(*new Layout::BlockContainer(document(), this, CSS::ComputedValues {}));
}
// https://w3c.github.io/DOM-Parsing/#dom-innerhtml-innerhtml

View file

@ -21,7 +21,7 @@
#include <LibWeb/DOM/Text.h>
#include <LibWeb/Dump.h>
#include <LibWeb/HTML/HTMLTemplateElement.h>
#include <LibWeb/Layout/BlockBox.h>
#include <LibWeb/Layout/BlockContainer.h>
#include <LibWeb/Layout/Node.h>
#include <LibWeb/Layout/SVGBox.h>
#include <LibWeb/Layout/TextNode.h>
@ -206,8 +206,8 @@ void dump_tree(StringBuilder& builder, Layout::Node const& layout_node, bool sho
builder.append("\n");
}
if (is<Layout::BlockBox>(layout_node) && static_cast<Layout::BlockBox const&>(layout_node).children_are_inline()) {
auto& block = static_cast<Layout::BlockBox const&>(layout_node);
if (is<Layout::BlockContainer>(layout_node) && static_cast<Layout::BlockContainer const&>(layout_node).children_are_inline()) {
auto& block = static_cast<Layout::BlockContainer const&>(layout_node);
for (size_t line_box_index = 0; line_box_index < block.line_boxes().size(); ++line_box_index) {
auto& line_box = block.line_boxes()[line_box_index];
for (size_t i = 0; i < indent; ++i)

View file

@ -219,7 +219,7 @@ class SVGSVGElement;
namespace Web::Layout {
enum class LayoutMode;
enum class PaintPhase;
class BlockBox;
class BlockContainer;
class BlockFormattingContext;
class Box;
class ButtonBox;

View file

@ -11,7 +11,7 @@
#include <LibWeb/HTML/EventNames.h>
#include <LibWeb/HTML/HTMLFormElement.h>
#include <LibWeb/HTML/HTMLInputElement.h>
#include <LibWeb/Layout/BlockBox.h>
#include <LibWeb/Layout/BlockContainer.h>
#include <LibWeb/Layout/ButtonBox.h>
#include <LibWeb/Layout/CheckBox.h>
#include <LibWeb/Layout/RadioButton.h>
@ -60,7 +60,7 @@ RefPtr<Layout::Node> HTMLInputElement::create_layout_node()
return adopt_ref(*new Layout::RadioButton(document(), *this, move(style)));
create_shadow_tree_if_needed();
auto layout_node = adopt_ref(*new Layout::BlockBox(document(), this, move(style)));
auto layout_node = adopt_ref(*new Layout::BlockContainer(document(), this, move(style)));
layout_node->set_inline(true);
return layout_node;
}

View file

@ -1,12 +1,12 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibGfx/Painter.h>
#include <LibWeb/Dump.h>
#include <LibWeb/Layout/BlockBox.h>
#include <LibWeb/Layout/BlockContainer.h>
#include <LibWeb/Layout/InitialContainingBlock.h>
#include <LibWeb/Layout/InlineFormattingContext.h>
#include <LibWeb/Layout/ReplacedBox.h>
@ -14,26 +14,26 @@
namespace Web::Layout {
BlockBox::BlockBox(DOM::Document& document, DOM::Node* node, NonnullRefPtr<CSS::StyleProperties> style)
BlockContainer::BlockContainer(DOM::Document& document, DOM::Node* node, NonnullRefPtr<CSS::StyleProperties> style)
: Box(document, node, move(style))
{
}
BlockBox::BlockBox(DOM::Document& document, DOM::Node* node, CSS::ComputedValues computed_values)
BlockContainer::BlockContainer(DOM::Document& document, DOM::Node* node, CSS::ComputedValues computed_values)
: Box(document, node, move(computed_values))
{
}
BlockBox::~BlockBox()
BlockContainer::~BlockContainer()
{
}
bool BlockBox::should_clip_overflow() const
bool BlockContainer::should_clip_overflow() const
{
return computed_values().overflow_x() != CSS::Overflow::Visible && computed_values().overflow_y() != CSS::Overflow::Visible;
}
void BlockBox::paint(PaintContext& context, PaintPhase phase)
void BlockContainer::paint(PaintContext& context, PaintPhase phase)
{
if (!is_visible())
return;
@ -79,7 +79,7 @@ void BlockBox::paint(PaintContext& context, PaintPhase phase)
}
}
HitTestResult BlockBox::hit_test(const Gfx::IntPoint& position, HitTestType type) const
HitTestResult BlockContainer::hit_test(const Gfx::IntPoint& position, HitTestType type) const
{
if (!children_are_inline())
return Box::hit_test(position, type);
@ -90,8 +90,8 @@ HitTestResult BlockBox::hit_test(const Gfx::IntPoint& position, HitTestType type
if (is<Box>(fragment.layout_node()) && verify_cast<Box>(fragment.layout_node()).stacking_context())
continue;
if (enclosing_int_rect(fragment.absolute_rect()).contains(position)) {
if (is<BlockBox>(fragment.layout_node()))
return verify_cast<BlockBox>(fragment.layout_node()).hit_test(position, type);
if (is<BlockContainer>(fragment.layout_node()))
return verify_cast<BlockContainer>(fragment.layout_node()).hit_test(position, type);
return { fragment.layout_node(), fragment.text_index_at(position.x()) };
}
if (fragment.absolute_rect().top() <= position.y())
@ -104,7 +104,7 @@ HitTestResult BlockBox::hit_test(const Gfx::IntPoint& position, HitTestType type
return { absolute_rect().contains(position.x(), position.y()) ? this : nullptr };
}
void BlockBox::split_into_lines(InlineFormattingContext& context, LayoutMode layout_mode)
void BlockContainer::split_into_lines(InlineFormattingContext& context, LayoutMode layout_mode)
{
auto& containing_block = context.containing_block();
auto* line_box = &containing_block.ensure_last_line_box();
@ -121,13 +121,13 @@ void BlockBox::split_into_lines(InlineFormattingContext& context, LayoutMode lay
line_box->add_fragment(*this, 0, 0, border_box_width(), height());
}
bool BlockBox::is_scrollable() const
bool BlockContainer::is_scrollable() const
{
// FIXME: Support horizontal scroll as well (overflow-x)
return computed_values().overflow_y() == CSS::Overflow::Scroll;
}
void BlockBox::set_scroll_offset(const Gfx::FloatPoint& offset)
void BlockContainer::set_scroll_offset(const Gfx::FloatPoint& offset)
{
// FIXME: If there is horizontal and vertical scroll ignore only part of the new offset
if (offset.y() < 0 || m_scroll_offset == offset)
@ -136,7 +136,7 @@ void BlockBox::set_scroll_offset(const Gfx::FloatPoint& offset)
set_needs_display();
}
bool BlockBox::handle_mousewheel(Badge<EventHandler>, const Gfx::IntPoint&, unsigned int, unsigned int, int wheel_delta)
bool BlockContainer::handle_mousewheel(Badge<EventHandler>, const Gfx::IntPoint&, unsigned int, unsigned int, int wheel_delta)
{
if (!is_scrollable())
return false;

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -11,20 +11,21 @@
namespace Web::Layout {
class BlockBox : public Box {
// https://drafts.csswg.org/css-display/#block-container
class BlockContainer : public Box {
public:
BlockBox(DOM::Document&, DOM::Node*, NonnullRefPtr<CSS::StyleProperties>);
BlockBox(DOM::Document&, DOM::Node*, CSS::ComputedValues);
virtual ~BlockBox() override;
BlockContainer(DOM::Document&, DOM::Node*, NonnullRefPtr<CSS::StyleProperties>);
BlockContainer(DOM::Document&, DOM::Node*, CSS::ComputedValues);
virtual ~BlockContainer() override;
virtual void paint(PaintContext&, PaintPhase) override;
virtual HitTestResult hit_test(const Gfx::IntPoint&, HitTestType) const override;
BlockBox* previous_sibling() { return verify_cast<BlockBox>(Node::previous_sibling()); }
const BlockBox* previous_sibling() const { return verify_cast<BlockBox>(Node::previous_sibling()); }
BlockBox* next_sibling() { return verify_cast<BlockBox>(Node::next_sibling()); }
const BlockBox* next_sibling() const { return verify_cast<BlockBox>(Node::next_sibling()); }
BlockContainer* previous_sibling() { return verify_cast<BlockContainer>(Node::previous_sibling()); }
const BlockContainer* previous_sibling() const { return verify_cast<BlockContainer>(Node::previous_sibling()); }
BlockContainer* next_sibling() { return verify_cast<BlockContainer>(Node::next_sibling()); }
const BlockContainer* next_sibling() const { return verify_cast<BlockContainer>(Node::next_sibling()); }
template<typename Callback>
void for_each_fragment(Callback);
@ -48,10 +49,10 @@ private:
};
template<>
inline bool Node::fast_is<BlockBox>() const { return is_block_box(); }
inline bool Node::fast_is<BlockContainer>() const { return is_block_box(); }
template<typename Callback>
void BlockBox::for_each_fragment(Callback callback)
void BlockContainer::for_each_fragment(Callback callback)
{
for (auto& line_box : line_boxes()) {
for (auto& fragment : line_box.fragments()) {
@ -62,7 +63,7 @@ void BlockBox::for_each_fragment(Callback callback)
}
template<typename Callback>
void BlockBox::for_each_fragment(Callback callback) const
void BlockContainer::for_each_fragment(Callback callback) const
{
for (auto& line_box : line_boxes()) {
for (auto& fragment : line_box.fragments()) {

View file

@ -6,7 +6,7 @@
#include <LibWeb/CSS/Length.h>
#include <LibWeb/DOM/Node.h>
#include <LibWeb/Layout/BlockBox.h>
#include <LibWeb/Layout/BlockContainer.h>
#include <LibWeb/Layout/BlockFormattingContext.h>
#include <LibWeb/Layout/Box.h>
#include <LibWeb/Layout/InitialContainingBlock.h>
@ -444,7 +444,7 @@ void BlockFormattingContext::layout_block_level_children(Box& box, LayoutMode la
if (is<ReplacedBox>(child_box))
place_block_level_replaced_element_in_normal_flow(child_box, box);
else if (is<BlockBox>(child_box))
else if (is<BlockContainer>(child_box))
place_block_level_non_replaced_element_in_normal_flow(child_box, box);
// FIXME: This should be factored differently. It's uncool that we mutate the tree *during* layout!
@ -512,7 +512,7 @@ void BlockFormattingContext::place_block_level_non_replaced_element_in_normal_fl
// NOTE: Empty (0-height) preceding siblings have their margins collapsed with *their* preceding sibling, etc.
float collapsed_bottom_margin_of_preceding_siblings = 0;
auto* relevant_sibling = child_box.previous_sibling_of_type<Layout::BlockBox>();
auto* relevant_sibling = child_box.previous_sibling_of_type<Layout::BlockContainer>();
while (relevant_sibling != nullptr) {
if (!relevant_sibling->is_absolutely_positioned() && !relevant_sibling->is_floating()) {
collapsed_bottom_margin_of_preceding_siblings = max(collapsed_bottom_margin_of_preceding_siblings, relevant_sibling->box_model().margin.bottom);

View file

@ -9,7 +9,7 @@
#include <LibWeb/DOM/Document.h>
#include <LibWeb/HTML/HTMLBodyElement.h>
#include <LibWeb/HTML/HTMLHtmlElement.h>
#include <LibWeb/Layout/BlockBox.h>
#include <LibWeb/Layout/BlockContainer.h>
#include <LibWeb/Layout/Box.h>
#include <LibWeb/Layout/FormattingContext.h>
#include <LibWeb/Page/BrowsingContext.h>

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Layout/BlockBox.h>
#include <LibWeb/Layout/BlockContainer.h>
#include <LibWeb/Layout/BreakNode.h>
#include <LibWeb/Layout/InlineFormattingContext.h>

View file

@ -8,7 +8,7 @@
#include "InlineFormattingContext.h"
#include <AK/Function.h>
#include <AK/StdLibExtras.h>
#include <LibWeb/Layout/BlockBox.h>
#include <LibWeb/Layout/BlockContainer.h>
#include <LibWeb/Layout/BlockFormattingContext.h>
#include <LibWeb/Layout/Box.h>
#include <LibWeb/Layout/FlexFormattingContext.h>
@ -312,7 +312,7 @@ void FlexFormattingContext::run(Box& box, LayoutMode)
box.for_each_child_of_type<Box>([&](Box& child_box) {
layout_inside(child_box, LayoutMode::Default);
// Skip anonymous text runs that are only whitespace.
if (child_box.is_anonymous() && !child_box.first_child_of_type<BlockBox>()) {
if (child_box.is_anonymous() && !child_box.first_child_of_type<BlockContainer>()) {
bool contains_only_white_space = true;
child_box.for_each_in_inclusive_subtree_of_type<TextNode>([&contains_only_white_space](auto& text_node) {
if (!text_node.text_for_rendering().is_whitespace()) {

View file

@ -13,7 +13,7 @@
namespace Web::Layout {
InitialContainingBlock::InitialContainingBlock(DOM::Document& document, NonnullRefPtr<CSS::StyleProperties> style)
: BlockBox(document, &document, move(style))
: BlockContainer(document, &document, move(style))
{
}

View file

@ -7,11 +7,11 @@
#pragma once
#include <LibWeb/DOM/Document.h>
#include <LibWeb/Layout/BlockBox.h>
#include <LibWeb/Layout/BlockContainer.h>
namespace Web::Layout {
class InitialContainingBlock final : public BlockBox {
class InitialContainingBlock final : public BlockContainer {
public:
explicit InitialContainingBlock(DOM::Document&, NonnullRefPtr<CSS::StyleProperties>);
virtual ~InitialContainingBlock() override;

View file

@ -7,7 +7,7 @@
#include <LibWeb/CSS/Length.h>
#include <LibWeb/DOM/Node.h>
#include <LibWeb/Dump.h>
#include <LibWeb/Layout/BlockBox.h>
#include <LibWeb/Layout/BlockContainer.h>
#include <LibWeb/Layout/BlockFormattingContext.h>
#include <LibWeb/Layout/Box.h>
#include <LibWeb/Layout/InlineFormattingContext.h>
@ -191,7 +191,7 @@ void InlineFormattingContext::dimension_box_on_line(Box& box, LayoutMode layout_
}
if (box.is_inline_block()) {
auto& inline_block = const_cast<BlockBox&>(verify_cast<BlockBox>(box));
auto& inline_block = const_cast<BlockContainer&>(verify_cast<BlockContainer>(box));
if (inline_block.computed_values().width().is_undefined_or_auto()) {
auto result = calculate_shrink_to_fit_widths(inline_block);

View file

@ -8,7 +8,7 @@
#include <LibGfx/Painter.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/Element.h>
#include <LibWeb/Layout/BlockBox.h>
#include <LibWeb/Layout/BlockContainer.h>
#include <LibWeb/Layout/InlineFormattingContext.h>
#include <LibWeb/Layout/InlineNode.h>
#include <LibWeb/Painting/BackgroundPainting.h>

View file

@ -18,7 +18,7 @@
namespace Web::Layout {
Label::Label(DOM::Document& document, HTML::HTMLLabelElement* element, NonnullRefPtr<CSS::StyleProperties> style)
: BlockBox(document, element, move(style))
: BlockContainer(document, element, move(style))
{
}

View file

@ -7,11 +7,11 @@
#pragma once
#include <LibWeb/HTML/HTMLLabelElement.h>
#include <LibWeb/Layout/BlockBox.h>
#include <LibWeb/Layout/BlockContainer.h>
namespace Web::Layout {
class Label : public BlockBox {
class Label : public BlockContainer {
public:
Label(DOM::Document&, HTML::HTMLLabelElement*, NonnullRefPtr<CSS::StyleProperties>);
virtual ~Label() override;
@ -19,8 +19,8 @@ public:
static bool is_inside_associated_label(LabelableNode&, const Gfx::IntPoint&);
static bool is_associated_label_hovered(LabelableNode&);
const HTML::HTMLLabelElement& dom_node() const { return static_cast<const HTML::HTMLLabelElement&>(*BlockBox::dom_node()); }
HTML::HTMLLabelElement& dom_node() { return static_cast<HTML::HTMLLabelElement&>(*BlockBox::dom_node()); }
const HTML::HTMLLabelElement& dom_node() const { return static_cast<const HTML::HTMLLabelElement&>(*BlockContainer::dom_node()); }
HTML::HTMLLabelElement& dom_node() { return static_cast<HTML::HTMLLabelElement&>(*BlockContainer::dom_node()); }
void handle_mousedown_on_label(Badge<TextNode>, const Gfx::IntPoint&, unsigned button);
void handle_mouseup_on_label(Badge<TextNode>, const Gfx::IntPoint&, unsigned button);

View file

@ -28,7 +28,7 @@ public:
bool is_empty_or_ends_in_whitespace() const;
private:
friend class BlockBox;
friend class BlockContainer;
friend class InlineFormattingContext;
NonnullOwnPtrVector<LineBoxFragment> m_fragments;
float m_width { 0 };

View file

@ -11,7 +11,7 @@
namespace Web::Layout {
ListItemBox::ListItemBox(DOM::Document& document, DOM::Element& element, NonnullRefPtr<CSS::StyleProperties> style)
: Layout::BlockBox(document, &element, move(style))
: Layout::BlockContainer(document, &element, move(style))
{
}

View file

@ -7,21 +7,21 @@
#pragma once
#include <LibWeb/DOM/Element.h>
#include <LibWeb/Layout/BlockBox.h>
#include <LibWeb/Layout/BlockContainer.h>
namespace Web::Layout {
class ListItemMarkerBox;
class ListItemBox final : public BlockBox {
class ListItemBox final : public BlockContainer {
public:
ListItemBox(DOM::Document&, DOM::Element&, NonnullRefPtr<CSS::StyleProperties>);
virtual ~ListItemBox() override;
void layout_marker();
DOM::Element& dom_node() { return static_cast<DOM::Element&>(*BlockBox::dom_node()); }
DOM::Element const& dom_node() const { return static_cast<DOM::Element const&>(*BlockBox::dom_node()); }
DOM::Element& dom_node() { return static_cast<DOM::Element&>(*BlockContainer::dom_node()); }
DOM::Element const& dom_node() const { return static_cast<DOM::Element const&>(*BlockContainer::dom_node()); }
private:
RefPtr<ListItemMarkerBox> m_marker;

View file

@ -10,7 +10,7 @@
#include <LibWeb/DOM/Document.h>
#include <LibWeb/Dump.h>
#include <LibWeb/HTML/HTMLHtmlElement.h>
#include <LibWeb/Layout/BlockBox.h>
#include <LibWeb/Layout/BlockContainer.h>
#include <LibWeb/Layout/FormattingContext.h>
#include <LibWeb/Layout/InitialContainingBlock.h>
#include <LibWeb/Layout/Node.h>
@ -39,13 +39,13 @@ bool Node::can_contain_boxes_with_position_absolute() const
return computed_values().position() != CSS::Position::Static || is<InitialContainingBlock>(*this);
}
const BlockBox* Node::containing_block() const
const BlockContainer* Node::containing_block() const
{
auto nearest_block_ancestor = [this] {
auto* ancestor = parent();
while (ancestor && !is<BlockBox>(*ancestor))
while (ancestor && !is<BlockContainer>(*ancestor))
ancestor = ancestor->parent();
return static_cast<const BlockBox*>(ancestor);
return static_cast<const BlockContainer*>(ancestor);
};
if (is<TextNode>(*this))
@ -57,9 +57,9 @@ const BlockBox* Node::containing_block() const
auto* ancestor = parent();
while (ancestor && !ancestor->can_contain_boxes_with_position_absolute())
ancestor = ancestor->parent();
while (ancestor && (!is<BlockBox>(*ancestor) || ancestor->is_anonymous()))
while (ancestor && (!is<BlockContainer>(*ancestor) || ancestor->is_anonymous()))
ancestor = ancestor->containing_block();
return static_cast<const BlockBox*>(ancestor);
return static_cast<const BlockContainer*>(ancestor);
}
if (position == CSS::Position::Fixed)
@ -422,12 +422,12 @@ String Node::class_name() const
bool Node::is_inline_block() const
{
return is_inline() && is<BlockBox>(*this);
return is_inline() && is<BlockContainer>(*this);
}
NonnullRefPtr<NodeWithStyle> NodeWithStyle::create_anonymous_wrapper() const
{
auto wrapper = adopt_ref(*new BlockBox(const_cast<DOM::Document&>(document()), nullptr, m_computed_values.clone_inherited_values()));
auto wrapper = adopt_ref(*new BlockContainer(const_cast<DOM::Document&>(document()), nullptr, m_computed_values.clone_inherited_values()));
wrapper->m_font = m_font;
wrapper->m_font_size = m_font_size;
wrapper->m_line_height = m_line_height;

View file

@ -113,8 +113,8 @@ public:
bool is_flex_item() const { return m_is_flex_item; }
void set_flex_item(bool b) { m_is_flex_item = b; }
const BlockBox* containing_block() const;
BlockBox* containing_block() { return const_cast<BlockBox*>(const_cast<const Node*>(this)->containing_block()); }
const BlockContainer* containing_block() const;
BlockContainer* containing_block() { return const_cast<BlockContainer*>(const_cast<const Node*>(this)->containing_block()); }
bool establishes_stacking_context() const;

View file

@ -5,7 +5,7 @@
*/
#include <LibWeb/DOM/Element.h>
#include <LibWeb/Layout/BlockBox.h>
#include <LibWeb/Layout/BlockContainer.h>
#include <LibWeb/Layout/InlineFormattingContext.h>
#include <LibWeb/Layout/ReplacedBox.h>

View file

@ -10,7 +10,7 @@
namespace Web::Layout {
SVGBox::SVGBox(DOM::Document& document, SVG::SVGElement& element, NonnullRefPtr<CSS::StyleProperties> style)
: BlockBox(document, &element, move(style))
: BlockContainer(document, &element, move(style))
{
set_inline(true);
}

View file

@ -6,13 +6,13 @@
#pragma once
#include <LibWeb/Layout/BlockBox.h>
#include <LibWeb/Layout/BlockContainer.h>
#include <LibWeb/SVG/SVGElement.h>
#include <LibWeb/SVG/SVGGraphicsElement.h>
namespace Web::Layout {
class SVGBox : public BlockBox {
class SVGBox : public BlockContainer {
public:
SVGBox(DOM::Document&, SVG::SVGElement&, NonnullRefPtr<CSS::StyleProperties>);
virtual ~SVGBox() override = default;

View file

@ -10,12 +10,12 @@
namespace Web::Layout {
TableBox::TableBox(DOM::Document& document, DOM::Element* element, NonnullRefPtr<CSS::StyleProperties> style)
: Layout::BlockBox(document, element, move(style))
: Layout::BlockContainer(document, element, move(style))
{
}
TableBox::TableBox(DOM::Document& document, DOM::Element* element, CSS::ComputedValues computed_values)
: Layout::BlockBox(document, element, move(computed_values))
: Layout::BlockContainer(document, element, move(computed_values))
{
}

View file

@ -6,11 +6,11 @@
#pragma once
#include <LibWeb/Layout/BlockBox.h>
#include <LibWeb/Layout/BlockContainer.h>
namespace Web::Layout {
class TableBox final : public Layout::BlockBox {
class TableBox final : public Layout::BlockContainer {
public:
TableBox(DOM::Document&, DOM::Element*, NonnullRefPtr<CSS::StyleProperties>);
TableBox(DOM::Document&, DOM::Element*, CSS::ComputedValues);

View file

@ -11,12 +11,12 @@
namespace Web::Layout {
TableCellBox::TableCellBox(DOM::Document& document, DOM::Element* element, NonnullRefPtr<CSS::StyleProperties> style)
: Layout::BlockBox(document, element, move(style))
: Layout::BlockContainer(document, element, move(style))
{
}
TableCellBox::TableCellBox(DOM::Document& document, DOM::Element* element, CSS::ComputedValues computed_values)
: Layout::BlockBox(document, element, move(computed_values))
: Layout::BlockContainer(document, element, move(computed_values))
{
}

View file

@ -6,11 +6,11 @@
#pragma once
#include <LibWeb/Layout/BlockBox.h>
#include <LibWeb/Layout/BlockContainer.h>
namespace Web::Layout {
class TableCellBox final : public BlockBox {
class TableCellBox final : public BlockContainer {
public:
TableCellBox(DOM::Document&, DOM::Element*, NonnullRefPtr<CSS::StyleProperties>);
TableCellBox(DOM::Document&, DOM::Element*, CSS::ComputedValues);

View file

@ -12,7 +12,7 @@
namespace Web::Layout {
TableRowGroupBox::TableRowGroupBox(DOM::Document& document, DOM::Element& element, NonnullRefPtr<CSS::StyleProperties> style)
: Layout::BlockBox(document, &element, move(style))
: Layout::BlockContainer(document, &element, move(style))
{
}

View file

@ -6,11 +6,11 @@
#pragma once
#include <LibWeb/Layout/BlockBox.h>
#include <LibWeb/Layout/BlockContainer.h>
namespace Web::Layout {
class TableRowGroupBox final : public BlockBox {
class TableRowGroupBox final : public BlockContainer {
public:
TableRowGroupBox(DOM::Document&, DOM::Element&, NonnullRefPtr<CSS::StyleProperties>);
virtual ~TableRowGroupBox() override;

View file

@ -8,7 +8,7 @@
#include <AK/StringBuilder.h>
#include <LibGfx/Painter.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/Layout/BlockBox.h>
#include <LibWeb/Layout/BlockContainer.h>
#include <LibWeb/Layout/InlineFormattingContext.h>
#include <LibWeb/Layout/Label.h>
#include <LibWeb/Layout/TextNode.h>

View file

@ -66,7 +66,7 @@ static Layout::Node& insertion_parent_for_block_node(Layout::Node& layout_parent
layout_parent.remove_child(*child);
children.append(child.release_nonnull());
}
layout_parent.append_child(adopt_ref(*new BlockBox(layout_node.document(), nullptr, layout_parent.computed_values().clone_inherited_values())));
layout_parent.append_child(adopt_ref(*new BlockContainer(layout_node.document(), nullptr, layout_parent.computed_values().clone_inherited_values())));
layout_parent.set_children_are_inline(false);
for (auto& child : children) {
layout_parent.last_child()->append_child(child);

View file

@ -246,7 +246,7 @@ String BrowsingContext::selected_text() const
while (layout_node && layout_node != selection.end().layout_node) {
if (is<Layout::TextNode>(*layout_node))
builder.append(verify_cast<Layout::TextNode>(*layout_node).text_for_rendering());
else if (is<Layout::BreakNode>(*layout_node) || is<Layout::BlockBox>(*layout_node))
else if (is<Layout::BreakNode>(*layout_node) || is<Layout::BlockContainer>(*layout_node))
builder.append('\n');
layout_node = layout_node->next_in_pre_order();

View file

@ -133,7 +133,7 @@ HitTestResult StackingContext::hit_test(const Gfx::IntPoint& position, HitTestTy
} else {
// NOTE: InitialContainingBlock::hit_test() merely calls StackingContext::hit_test()
// so we call its base class instead.
result = verify_cast<InitialContainingBlock>(m_box).BlockBox::hit_test(position, type);
result = verify_cast<InitialContainingBlock>(m_box).BlockContainer::hit_test(position, type);
}
int z_index = m_box.computed_values().z_index().value_or(0);