mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:37:35 +00:00
LibWeb: Make grid containers be Layout::Box
Grid containers were incorrectly represented as BlockContainer before. Furthermore, GridFormattingContext had a bogus inheritance relationship with BlockFormattingContext. This patch brings our architecture closer to spec by making grid containers be plain boxes and making GFC not inherit from BFC.
This commit is contained in:
parent
44cf418975
commit
8fe748bb89
6 changed files with 10 additions and 10 deletions
|
@ -320,10 +320,10 @@ JS::GCPtr<Layout::Node> Element::create_layout_node_for_display_type(DOM::Docume
|
|||
return document.heap().allocate_without_realm<Layout::InlineNode>(document, element, move(style));
|
||||
}
|
||||
|
||||
if (display.is_flex_inside())
|
||||
if (display.is_flex_inside() || display.is_grid_inside())
|
||||
return document.heap().allocate_without_realm<Layout::Box>(document, element, move(style));
|
||||
|
||||
if (display.is_flow_inside() || display.is_flow_root_inside() || display.is_grid_inside())
|
||||
if (display.is_flow_inside() || display.is_flow_root_inside())
|
||||
return document.heap().allocate_without_realm<Layout::BlockContainer>(document, element, move(style));
|
||||
|
||||
TODO();
|
||||
|
|
|
@ -151,7 +151,7 @@ OwnPtr<FormattingContext> FormattingContext::create_independent_formatting_conte
|
|||
return make<TableFormattingContext>(state, verify_cast<TableBox>(child_box), this);
|
||||
|
||||
if (child_display.is_grid_inside()) {
|
||||
return make<GridFormattingContext>(state, verify_cast<BlockContainer>(child_box), this);
|
||||
return make<GridFormattingContext>(state, child_box, this);
|
||||
}
|
||||
|
||||
VERIFY(is_block_formatting_context());
|
||||
|
|
|
@ -21,6 +21,7 @@ public:
|
|||
Block,
|
||||
Inline,
|
||||
Flex,
|
||||
Grid,
|
||||
Table,
|
||||
SVG,
|
||||
};
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
|
||||
namespace Web::Layout {
|
||||
|
||||
GridFormattingContext::GridFormattingContext(LayoutState& state, BlockContainer const& block_container, FormattingContext* parent)
|
||||
: BlockFormattingContext(state, block_container, parent)
|
||||
GridFormattingContext::GridFormattingContext(LayoutState& state, Box const& grid_container, FormattingContext* parent)
|
||||
: FormattingContext(Type::Grid, state, grid_container, parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <LibWeb/CSS/Length.h>
|
||||
#include <LibWeb/Layout/BlockFormattingContext.h>
|
||||
#include <LibWeb/Layout/Box.h>
|
||||
#include <LibWeb/Layout/FormattingContext.h>
|
||||
|
||||
namespace Web::Layout {
|
||||
|
@ -31,9 +29,9 @@ private:
|
|||
Vector<Vector<bool>> m_occupation_grid;
|
||||
};
|
||||
|
||||
class GridFormattingContext final : public BlockFormattingContext {
|
||||
class GridFormattingContext final : public FormattingContext {
|
||||
public:
|
||||
explicit GridFormattingContext(LayoutState&, BlockContainer const&, FormattingContext* parent);
|
||||
explicit GridFormattingContext(LayoutState&, Box const& grid_container, FormattingContext* parent);
|
||||
~GridFormattingContext();
|
||||
|
||||
virtual void run(Box const&, LayoutMode, AvailableSpace const& available_space) override;
|
||||
|
|
|
@ -66,7 +66,8 @@ static Box const* nearest_ancestor_capable_of_forming_a_containing_block(Node co
|
|||
{
|
||||
for (auto const* ancestor = node.parent(); ancestor; ancestor = ancestor->parent()) {
|
||||
if (ancestor->is_block_container()
|
||||
|| ancestor->display().is_flex_inside()) {
|
||||
|| ancestor->display().is_flex_inside()
|
||||
|| ancestor->display().is_grid_inside()) {
|
||||
return verify_cast<Box>(ancestor);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue