mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 16:07:34 +00:00
LibWeb: Add GridFormattingContext
This commit is contained in:
parent
e4541d83d3
commit
e4c5799026
5 changed files with 61 additions and 2 deletions
|
@ -266,6 +266,7 @@ set(SOURCES
|
||||||
Layout/FlexFormattingContext.cpp
|
Layout/FlexFormattingContext.cpp
|
||||||
Layout/FormattingContext.cpp
|
Layout/FormattingContext.cpp
|
||||||
Layout/FrameBox.cpp
|
Layout/FrameBox.cpp
|
||||||
|
Layout/GridFormattingContext.cpp
|
||||||
Layout/ImageBox.cpp
|
Layout/ImageBox.cpp
|
||||||
Layout/InitialContainingBlock.cpp
|
Layout/InitialContainingBlock.cpp
|
||||||
Layout/InlineFormattingContext.cpp
|
Layout/InlineFormattingContext.cpp
|
||||||
|
|
|
@ -287,7 +287,7 @@ RefPtr<Layout::Node> Element::create_layout_node_for_display_type(DOM::Document&
|
||||||
return adopt_ref(*new Layout::InlineNode(document, element, move(style)));
|
return adopt_ref(*new Layout::InlineNode(document, element, move(style)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (display.is_flow_inside() || display.is_flow_root_inside() || display.is_flex_inside())
|
if (display.is_flow_inside() || display.is_flow_root_inside() || display.is_flex_inside() || display.is_grid_inside())
|
||||||
return adopt_ref(*new Layout::BlockContainer(document, element, move(style)));
|
return adopt_ref(*new Layout::BlockContainer(document, element, move(style)));
|
||||||
|
|
||||||
TODO();
|
TODO();
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include <LibWeb/Layout/Box.h>
|
#include <LibWeb/Layout/Box.h>
|
||||||
#include <LibWeb/Layout/FlexFormattingContext.h>
|
#include <LibWeb/Layout/FlexFormattingContext.h>
|
||||||
#include <LibWeb/Layout/FormattingContext.h>
|
#include <LibWeb/Layout/FormattingContext.h>
|
||||||
|
#include <LibWeb/Layout/GridFormattingContext.h>
|
||||||
#include <LibWeb/Layout/ReplacedBox.h>
|
#include <LibWeb/Layout/ReplacedBox.h>
|
||||||
#include <LibWeb/Layout/SVGFormattingContext.h>
|
#include <LibWeb/Layout/SVGFormattingContext.h>
|
||||||
#include <LibWeb/Layout/SVGSVGBox.h>
|
#include <LibWeb/Layout/SVGSVGBox.h>
|
||||||
|
@ -74,12 +75,16 @@ bool FormattingContext::creates_block_formatting_context(Box const& box)
|
||||||
if (!display.is_flex_inside())
|
if (!display.is_flex_inside())
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (parent_display.is_grid_inside()) {
|
||||||
|
if (!display.is_grid_inside()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: table-caption
|
// FIXME: table-caption
|
||||||
// FIXME: anonymous table cells
|
// FIXME: anonymous table cells
|
||||||
// FIXME: Elements with contain: layout, content, or paint.
|
// FIXME: Elements with contain: layout, content, or paint.
|
||||||
// FIXME: grid
|
|
||||||
// FIXME: multicol
|
// FIXME: multicol
|
||||||
// FIXME: column-span: all
|
// FIXME: column-span: all
|
||||||
return false;
|
return false;
|
||||||
|
@ -120,6 +125,10 @@ OwnPtr<FormattingContext> FormattingContext::create_independent_formatting_conte
|
||||||
if (child_display.is_table_inside())
|
if (child_display.is_table_inside())
|
||||||
return make<TableFormattingContext>(state, verify_cast<TableBox>(child_box), this);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
VERIFY(is_block_formatting_context());
|
VERIFY(is_block_formatting_context());
|
||||||
VERIFY(!child_box.children_are_inline());
|
VERIFY(!child_box.children_are_inline());
|
||||||
|
|
||||||
|
|
26
Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp
Normal file
26
Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022, Martin Falisse <mfalisse@outlook.com>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <LibWeb/Layout/Box.h>
|
||||||
|
#include <LibWeb/Layout/GridFormattingContext.h>
|
||||||
|
|
||||||
|
namespace Web::Layout {
|
||||||
|
|
||||||
|
GridFormattingContext::GridFormattingContext(LayoutState& state, BlockContainer const& block_container, FormattingContext* parent)
|
||||||
|
: BlockFormattingContext(state, block_container, parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
GridFormattingContext::~GridFormattingContext() = default;
|
||||||
|
|
||||||
|
void GridFormattingContext::run(Box const& box, LayoutMode)
|
||||||
|
{
|
||||||
|
box.for_each_child_of_type<Box>([&](Box& child_box) {
|
||||||
|
(void)layout_inside(child_box, LayoutMode::Normal);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
23
Userland/Libraries/LibWeb/Layout/GridFormattingContext.h
Normal file
23
Userland/Libraries/LibWeb/Layout/GridFormattingContext.h
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2022, Martin Falisse <mfalisse@outlook.com>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <LibWeb/Layout/BlockFormattingContext.h>
|
||||||
|
#include <LibWeb/Layout/Box.h>
|
||||||
|
#include <LibWeb/Layout/FormattingContext.h>
|
||||||
|
|
||||||
|
namespace Web::Layout {
|
||||||
|
|
||||||
|
class GridFormattingContext final : public BlockFormattingContext {
|
||||||
|
public:
|
||||||
|
explicit GridFormattingContext(LayoutState&, BlockContainer const&, FormattingContext* parent);
|
||||||
|
~GridFormattingContext();
|
||||||
|
|
||||||
|
virtual void run(Box const&, LayoutMode) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue