mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +00:00
LibWeb: Rename FormattingState to LayoutState
This seems a bit more descriptive (and also a bit shorter).
This commit is contained in:
parent
0d8f9019c8
commit
52862c72d0
Notes:
sideshowbarker
2024-07-17 08:52:18 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/52862c72d0
25 changed files with 95 additions and 95 deletions
|
@ -139,7 +139,7 @@ When a line box is filled up, we insert a break and begin a new box after it.
|
||||||
|
|
||||||
We always keep track of how much space is available on the current line. When starting a new line, this is reset by computing the width of the IFC's containing block and then subtracting the size occupied by floating boxes on both sides. We get this information by querying the parent BFC about floating boxes intersecting the Y coordinate of the new line.
|
We always keep track of how much space is available on the current line. When starting a new line, this is reset by computing the width of the IFC's containing block and then subtracting the size occupied by floating boxes on both sides. We get this information by querying the parent BFC about floating boxes intersecting the Y coordinate of the new line.
|
||||||
|
|
||||||
The result of performing a layout is a FormattingState object. This object contains final metrics (including line boxes) for all layout nodes that were in scope of the layout. The FormattingState can either be committed (via `commit()`) or simply discarded. This allows us to perform non-destructive (or "immutable") layouts if we're only interested in measuring something.
|
The result of performing a layout is a LayoutState object. This object contains the CSS "used values" (final metrics, including line boxes) for all box that were in scope of the layout. The LayoutState can either be committed (via `commit()`) or simply discarded. This allows us to perform non-destructive (or "immutable") layouts if we're only interested in measuring something.
|
||||||
|
|
||||||
### Paintable and the paint tree
|
### Paintable and the paint tree
|
||||||
|
|
||||||
|
|
|
@ -257,7 +257,6 @@ set(SOURCES
|
||||||
Layout/CheckBox.cpp
|
Layout/CheckBox.cpp
|
||||||
Layout/FlexFormattingContext.cpp
|
Layout/FlexFormattingContext.cpp
|
||||||
Layout/FormattingContext.cpp
|
Layout/FormattingContext.cpp
|
||||||
Layout/FormattingState.cpp
|
|
||||||
Layout/FrameBox.cpp
|
Layout/FrameBox.cpp
|
||||||
Layout/ImageBox.cpp
|
Layout/ImageBox.cpp
|
||||||
Layout/InitialContainingBlock.cpp
|
Layout/InitialContainingBlock.cpp
|
||||||
|
@ -267,6 +266,7 @@ set(SOURCES
|
||||||
Layout/Label.cpp
|
Layout/Label.cpp
|
||||||
Layout/LabelableNode.cpp
|
Layout/LabelableNode.cpp
|
||||||
Layout/LayoutPosition.cpp
|
Layout/LayoutPosition.cpp
|
||||||
|
Layout/LayoutState.cpp
|
||||||
Layout/LineBox.cpp
|
Layout/LineBox.cpp
|
||||||
Layout/LineBoxFragment.cpp
|
Layout/LineBoxFragment.cpp
|
||||||
Layout/LineBuilder.cpp
|
Layout/LineBuilder.cpp
|
||||||
|
|
|
@ -614,7 +614,7 @@ void Document::update_layout()
|
||||||
m_layout_root = static_ptr_cast<Layout::InitialContainingBlock>(tree_builder.build(*this));
|
m_layout_root = static_ptr_cast<Layout::InitialContainingBlock>(tree_builder.build(*this));
|
||||||
}
|
}
|
||||||
|
|
||||||
Layout::FormattingState formatting_state;
|
Layout::LayoutState formatting_state;
|
||||||
formatting_state.nodes.resize(layout_node_count());
|
formatting_state.nodes.resize(layout_node_count());
|
||||||
Layout::BlockFormattingContext root_formatting_context(formatting_state, *m_layout_root, nullptr);
|
Layout::BlockFormattingContext root_formatting_context(formatting_state, *m_layout_root, nullptr);
|
||||||
|
|
||||||
|
|
|
@ -371,7 +371,7 @@ class ButtonBox;
|
||||||
class CheckBox;
|
class CheckBox;
|
||||||
class FlexFormattingContext;
|
class FlexFormattingContext;
|
||||||
class FormattingContext;
|
class FormattingContext;
|
||||||
struct FormattingState;
|
struct LayoutState;
|
||||||
class InitialContainingBlock;
|
class InitialContainingBlock;
|
||||||
class InlineFormattingContext;
|
class InlineFormattingContext;
|
||||||
class Label;
|
class Label;
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
namespace Web::Layout {
|
namespace Web::Layout {
|
||||||
|
|
||||||
BlockFormattingContext::BlockFormattingContext(FormattingState& state, BlockContainer const& root, FormattingContext* parent)
|
BlockFormattingContext::BlockFormattingContext(LayoutState& state, BlockContainer const& root, FormattingContext* parent)
|
||||||
: FormattingContext(Type::Block, state, root, parent)
|
: FormattingContext(Type::Block, state, root, parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -308,7 +308,7 @@ void BlockFormattingContext::compute_width_for_block_level_replaced_element_in_n
|
||||||
m_state.get_mutable(box).content_width = compute_width_for_replaced_element(m_state, box);
|
m_state.get_mutable(box).content_width = compute_width_for_replaced_element(m_state, box);
|
||||||
}
|
}
|
||||||
|
|
||||||
float BlockFormattingContext::compute_theoretical_height(FormattingState const& state, Box const& box)
|
float BlockFormattingContext::compute_theoretical_height(LayoutState const& state, Box const& box)
|
||||||
{
|
{
|
||||||
auto const& computed_values = box.computed_values();
|
auto const& computed_values = box.computed_values();
|
||||||
auto const& containing_block = *box.containing_block();
|
auto const& containing_block = *box.containing_block();
|
||||||
|
@ -342,7 +342,7 @@ float BlockFormattingContext::compute_theoretical_height(FormattingState const&
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockFormattingContext::compute_height(Box const& box, FormattingState& state)
|
void BlockFormattingContext::compute_height(Box const& box, LayoutState& state)
|
||||||
{
|
{
|
||||||
auto const& computed_values = box.computed_values();
|
auto const& computed_values = box.computed_values();
|
||||||
auto width_of_containing_block_as_length = CSS::Length::make_px(containing_block_width_for(box, state));
|
auto width_of_containing_block_as_length = CSS::Length::make_px(containing_block_width_for(box, state));
|
||||||
|
@ -609,7 +609,7 @@ void BlockFormattingContext::place_block_level_element_in_normal_flow_horizontal
|
||||||
box_state.offset = Gfx::FloatPoint { x, box_state.offset.y() };
|
box_state.offset = Gfx::FloatPoint { x, box_state.offset.y() };
|
||||||
}
|
}
|
||||||
|
|
||||||
static void measure_scrollable_overflow(FormattingState const& state, Box const& box, float& bottom_edge, float& right_edge)
|
static void measure_scrollable_overflow(LayoutState const& state, Box const& box, float& bottom_edge, float& right_edge)
|
||||||
{
|
{
|
||||||
auto const& child_state = state.get(box);
|
auto const& child_state = state.get(box);
|
||||||
auto child_rect = absolute_content_rect(box, state);
|
auto child_rect = absolute_content_rect(box, state);
|
||||||
|
@ -644,7 +644,7 @@ void BlockFormattingContext::layout_initial_containing_block(LayoutMode layout_m
|
||||||
measure_scrollable_overflow(m_state, icb, bottom_edge, right_edge);
|
measure_scrollable_overflow(m_state, icb, bottom_edge, right_edge);
|
||||||
|
|
||||||
if (bottom_edge >= viewport_rect.height() || right_edge >= viewport_rect.width()) {
|
if (bottom_edge >= viewport_rect.height() || right_edge >= viewport_rect.width()) {
|
||||||
// FIXME: Move overflow data to FormattingState!
|
// FIXME: Move overflow data to LayoutState!
|
||||||
auto& overflow_data = icb_state.ensure_overflow_data();
|
auto& overflow_data = icb_state.ensure_overflow_data();
|
||||||
overflow_data.scrollable_overflow_rect = viewport_rect.to_type<float>();
|
overflow_data.scrollable_overflow_rect = viewport_rect.to_type<float>();
|
||||||
// NOTE: The edges are *within* the rectangle, so we add 1 to get the width and height.
|
// NOTE: The edges are *within* the rectangle, so we add 1 to get the width and height.
|
||||||
|
|
|
@ -18,7 +18,7 @@ class LineBuilder;
|
||||||
// https://www.w3.org/TR/css-display/#block-formatting-context
|
// https://www.w3.org/TR/css-display/#block-formatting-context
|
||||||
class BlockFormattingContext : public FormattingContext {
|
class BlockFormattingContext : public FormattingContext {
|
||||||
public:
|
public:
|
||||||
explicit BlockFormattingContext(FormattingState&, BlockContainer const&, FormattingContext* parent);
|
explicit BlockFormattingContext(LayoutState&, BlockContainer const&, FormattingContext* parent);
|
||||||
~BlockFormattingContext();
|
~BlockFormattingContext();
|
||||||
|
|
||||||
virtual void run(Box const&, LayoutMode) override;
|
virtual void run(Box const&, LayoutMode) override;
|
||||||
|
@ -29,7 +29,7 @@ public:
|
||||||
auto const& left_side_floats() const { return m_left_floats; }
|
auto const& left_side_floats() const { return m_left_floats; }
|
||||||
auto const& right_side_floats() const { return m_right_floats; }
|
auto const& right_side_floats() const { return m_right_floats; }
|
||||||
|
|
||||||
static float compute_theoretical_height(FormattingState const&, Box const&);
|
static float compute_theoretical_height(LayoutState const&, Box const&);
|
||||||
void compute_width(Box const&, LayoutMode = LayoutMode::Normal);
|
void compute_width(Box const&, LayoutMode = LayoutMode::Normal);
|
||||||
|
|
||||||
// https://www.w3.org/TR/css-display/#block-formatting-context-root
|
// https://www.w3.org/TR/css-display/#block-formatting-context-root
|
||||||
|
@ -37,7 +37,7 @@ public:
|
||||||
|
|
||||||
virtual void parent_context_did_dimension_child_root_box() override;
|
virtual void parent_context_did_dimension_child_root_box() override;
|
||||||
|
|
||||||
static void compute_height(Box const&, FormattingState&);
|
static void compute_height(Box const&, LayoutState&);
|
||||||
|
|
||||||
void add_absolutely_positioned_box(Box const& box) { m_absolutely_positioned_boxes.append(box); }
|
void add_absolutely_positioned_box(Box const& box) { m_absolutely_positioned_boxes.append(box); }
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ template<typename T>
|
||||||
return ::max(min, ::min(value, max));
|
return ::max(min, ::min(value, max));
|
||||||
}
|
}
|
||||||
|
|
||||||
static float get_pixel_size(FormattingState const& state, Box const& box, Optional<CSS::LengthPercentage> const& length_percentage)
|
static float get_pixel_size(LayoutState const& state, Box const& box, Optional<CSS::LengthPercentage> const& length_percentage)
|
||||||
{
|
{
|
||||||
if (!length_percentage.has_value())
|
if (!length_percentage.has_value())
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -35,7 +35,7 @@ static float get_pixel_size(FormattingState const& state, Box const& box, Option
|
||||||
return length_percentage->resolved(box, inner_main_size).to_px(box);
|
return length_percentage->resolved(box, inner_main_size).to_px(box);
|
||||||
}
|
}
|
||||||
|
|
||||||
FlexFormattingContext::FlexFormattingContext(FormattingState& state, Box const& flex_container, FormattingContext* parent)
|
FlexFormattingContext::FlexFormattingContext(LayoutState& state, Box const& flex_container, FormattingContext* parent)
|
||||||
: FormattingContext(Type::Flex, state, flex_container, parent)
|
: FormattingContext(Type::Flex, state, flex_container, parent)
|
||||||
, m_flex_container_state(m_state.get_mutable(flex_container))
|
, m_flex_container_state(m_state.get_mutable(flex_container))
|
||||||
, m_flex_direction(flex_container.computed_values().flex_direction())
|
, m_flex_direction(flex_container.computed_values().flex_direction())
|
||||||
|
@ -526,7 +526,7 @@ float FlexFormattingContext::calculate_indefinite_main_size(FlexItem const& item
|
||||||
// then layout with that and see what height comes out of it.
|
// then layout with that and see what height comes out of it.
|
||||||
float fit_content_cross_size = calculate_fit_content_width(item.box, m_available_space->cross);
|
float fit_content_cross_size = calculate_fit_content_width(item.box, m_available_space->cross);
|
||||||
|
|
||||||
FormattingState throwaway_state(&m_state);
|
LayoutState throwaway_state(&m_state);
|
||||||
auto& box_state = throwaway_state.get_mutable(item.box);
|
auto& box_state = throwaway_state.get_mutable(item.box);
|
||||||
|
|
||||||
// Item has definite cross size, layout with that as the used cross size.
|
// Item has definite cross size, layout with that as the used cross size.
|
||||||
|
@ -619,7 +619,7 @@ void FlexFormattingContext::determine_flex_base_size_and_hypothetical_main_size(
|
||||||
return specified_main_size_of_child_box(child_box);
|
return specified_main_size_of_child_box(child_box);
|
||||||
|
|
||||||
// NOTE: To avoid repeated layout work, we keep a cache of flex item main sizes on the
|
// NOTE: To avoid repeated layout work, we keep a cache of flex item main sizes on the
|
||||||
// root FormattingState object. It's available through a full layout cycle.
|
// root LayoutState object. It's available through a full layout cycle.
|
||||||
// FIXME: Make sure this cache isn't overly permissive..
|
// FIXME: Make sure this cache isn't overly permissive..
|
||||||
auto& size_cache = m_state.m_root.flex_item_size_cache;
|
auto& size_cache = m_state.m_root.flex_item_size_cache;
|
||||||
auto it = size_cache.find(&flex_item.box);
|
auto it = size_cache.find(&flex_item.box);
|
||||||
|
@ -976,7 +976,7 @@ void FlexFormattingContext::determine_hypothetical_cross_size_of_item(FlexItem&
|
||||||
|
|
||||||
if (has_definite_main_size(item.box)) {
|
if (has_definite_main_size(item.box)) {
|
||||||
// For indefinite cross sizes, we perform a throwaway layout and then measure it.
|
// For indefinite cross sizes, we perform a throwaway layout and then measure it.
|
||||||
FormattingState throwaway_state(&m_state);
|
LayoutState throwaway_state(&m_state);
|
||||||
auto& box_state = throwaway_state.get_mutable(item.box);
|
auto& box_state = throwaway_state.get_mutable(item.box);
|
||||||
|
|
||||||
// Item has definite main size, layout with that as the used main size.
|
// Item has definite main size, layout with that as the used main size.
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace Web::Layout {
|
||||||
|
|
||||||
class FlexFormattingContext final : public FormattingContext {
|
class FlexFormattingContext final : public FormattingContext {
|
||||||
public:
|
public:
|
||||||
FlexFormattingContext(FormattingState&, Box const& flex_container, FormattingContext* parent);
|
FlexFormattingContext(LayoutState&, Box const& flex_container, FormattingContext* parent);
|
||||||
~FlexFormattingContext();
|
~FlexFormattingContext();
|
||||||
|
|
||||||
virtual bool inhibits_floating() const override { return true; }
|
virtual bool inhibits_floating() const override { return true; }
|
||||||
|
@ -155,7 +155,7 @@ private:
|
||||||
|
|
||||||
CSS::FlexBasisData used_flex_basis_for_item(FlexItem const&) const;
|
CSS::FlexBasisData used_flex_basis_for_item(FlexItem const&) const;
|
||||||
|
|
||||||
FormattingState::NodeState& m_flex_container_state;
|
LayoutState::NodeState& m_flex_container_state;
|
||||||
|
|
||||||
Vector<FlexLine> m_flex_lines;
|
Vector<FlexLine> m_flex_lines;
|
||||||
Vector<FlexItem> m_flex_items;
|
Vector<FlexItem> m_flex_items;
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
namespace Web::Layout {
|
namespace Web::Layout {
|
||||||
|
|
||||||
FormattingContext::FormattingContext(Type type, FormattingState& state, Box const& context_box, FormattingContext* parent)
|
FormattingContext::FormattingContext(Type type, LayoutState& state, Box const& context_box, FormattingContext* parent)
|
||||||
: m_type(type)
|
: m_type(type)
|
||||||
, m_parent(parent)
|
, m_parent(parent)
|
||||||
, m_context_box(context_box)
|
, m_context_box(context_box)
|
||||||
|
@ -85,7 +85,7 @@ bool FormattingContext::creates_block_formatting_context(Box const& box)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
OwnPtr<FormattingContext> FormattingContext::create_independent_formatting_context_if_needed(FormattingState& state, Box const& child_box)
|
OwnPtr<FormattingContext> FormattingContext::create_independent_formatting_context_if_needed(LayoutState& state, Box const& child_box)
|
||||||
{
|
{
|
||||||
if (child_box.is_replaced_box() && !child_box.can_have_children()) {
|
if (child_box.is_replaced_box() && !child_box.can_have_children()) {
|
||||||
// NOTE: This is a bit strange.
|
// NOTE: This is a bit strange.
|
||||||
|
@ -94,7 +94,7 @@ OwnPtr<FormattingContext> FormattingContext::create_independent_formatting_conte
|
||||||
// without having separate code to handle replaced elements.
|
// without having separate code to handle replaced elements.
|
||||||
// FIXME: Find a better abstraction for this.
|
// FIXME: Find a better abstraction for this.
|
||||||
struct ReplacedFormattingContext : public FormattingContext {
|
struct ReplacedFormattingContext : public FormattingContext {
|
||||||
ReplacedFormattingContext(FormattingState& state, Box const& box)
|
ReplacedFormattingContext(LayoutState& state, Box const& box)
|
||||||
: FormattingContext(Type::Block, state, box)
|
: FormattingContext(Type::Block, state, box)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@ OwnPtr<FormattingContext> FormattingContext::create_independent_formatting_conte
|
||||||
// FIXME: Remove this once it's no longer needed. It currently swallows problem with standalone
|
// FIXME: Remove this once it's no longer needed. It currently swallows problem with standalone
|
||||||
// table-related boxes that don't get fixed up by CSS anonymous table box generation.
|
// table-related boxes that don't get fixed up by CSS anonymous table box generation.
|
||||||
struct DummyFormattingContext : public FormattingContext {
|
struct DummyFormattingContext : public FormattingContext {
|
||||||
DummyFormattingContext(FormattingState& state, Box const& box)
|
DummyFormattingContext(LayoutState& state, Box const& box)
|
||||||
: FormattingContext(Type::Block, state, box)
|
: FormattingContext(Type::Block, state, box)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -181,7 +181,7 @@ FormattingContext::ShrinkToFitResult FormattingContext::calculate_shrink_to_fit_
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static Gfx::FloatSize solve_replaced_size_constraint(FormattingState const& state, float w, float h, ReplacedBox const& box)
|
static Gfx::FloatSize solve_replaced_size_constraint(LayoutState const& state, float w, float h, ReplacedBox const& box)
|
||||||
{
|
{
|
||||||
// 10.4 Minimum and maximum widths: 'min-width' and 'max-width'
|
// 10.4 Minimum and maximum widths: 'min-width' and 'max-width'
|
||||||
|
|
||||||
|
@ -223,7 +223,7 @@ static Gfx::FloatSize solve_replaced_size_constraint(FormattingState const& stat
|
||||||
return { w, h };
|
return { w, h };
|
||||||
}
|
}
|
||||||
|
|
||||||
float FormattingContext::compute_auto_height_for_block_level_element(FormattingState const& state, Box const& box)
|
float FormattingContext::compute_auto_height_for_block_level_element(LayoutState const& state, Box const& box)
|
||||||
{
|
{
|
||||||
if (creates_block_formatting_context(box))
|
if (creates_block_formatting_context(box))
|
||||||
return compute_auto_height_for_block_formatting_context_root(state, verify_cast<BlockContainer>(box));
|
return compute_auto_height_for_block_formatting_context_root(state, verify_cast<BlockContainer>(box));
|
||||||
|
@ -272,7 +272,7 @@ float FormattingContext::compute_auto_height_for_block_level_element(FormattingS
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://www.w3.org/TR/CSS22/visudet.html#root-height
|
// https://www.w3.org/TR/CSS22/visudet.html#root-height
|
||||||
float FormattingContext::compute_auto_height_for_block_formatting_context_root(FormattingState const& state, BlockContainer const& root)
|
float FormattingContext::compute_auto_height_for_block_formatting_context_root(LayoutState const& state, BlockContainer const& root)
|
||||||
{
|
{
|
||||||
// 10.6.7 'Auto' heights for block formatting context roots
|
// 10.6.7 'Auto' heights for block formatting context roots
|
||||||
Optional<float> top;
|
Optional<float> top;
|
||||||
|
@ -335,7 +335,7 @@ float FormattingContext::compute_auto_height_for_block_formatting_context_root(F
|
||||||
}
|
}
|
||||||
|
|
||||||
// 10.3.2 Inline, replaced elements, https://www.w3.org/TR/CSS22/visudet.html#inline-replaced-width
|
// 10.3.2 Inline, replaced elements, https://www.w3.org/TR/CSS22/visudet.html#inline-replaced-width
|
||||||
float FormattingContext::tentative_width_for_replaced_element(FormattingState const& state, ReplacedBox const& box, CSS::LengthPercentage const& computed_width)
|
float FormattingContext::tentative_width_for_replaced_element(LayoutState const& state, ReplacedBox const& box, CSS::LengthPercentage const& computed_width)
|
||||||
{
|
{
|
||||||
auto const& containing_block = *box.containing_block();
|
auto const& containing_block = *box.containing_block();
|
||||||
auto height_of_containing_block = CSS::Length::make_px(state.get(containing_block).content_height);
|
auto height_of_containing_block = CSS::Length::make_px(state.get(containing_block).content_height);
|
||||||
|
@ -392,7 +392,7 @@ void FormattingContext::compute_height_for_absolutely_positioned_element(Box con
|
||||||
compute_height_for_absolutely_positioned_non_replaced_element(box);
|
compute_height_for_absolutely_positioned_non_replaced_element(box);
|
||||||
}
|
}
|
||||||
|
|
||||||
float FormattingContext::compute_width_for_replaced_element(FormattingState const& state, ReplacedBox const& box)
|
float FormattingContext::compute_width_for_replaced_element(LayoutState const& state, ReplacedBox const& box)
|
||||||
{
|
{
|
||||||
// 10.3.4 Block-level, replaced elements in normal flow...
|
// 10.3.4 Block-level, replaced elements in normal flow...
|
||||||
// 10.3.2 Inline, replaced elements
|
// 10.3.2 Inline, replaced elements
|
||||||
|
@ -437,7 +437,7 @@ float FormattingContext::compute_width_for_replaced_element(FormattingState cons
|
||||||
|
|
||||||
// 10.6.2 Inline replaced elements, block-level replaced elements in normal flow, 'inline-block' replaced elements in normal flow and floating replaced elements
|
// 10.6.2 Inline replaced elements, block-level replaced elements in normal flow, 'inline-block' replaced elements in normal flow and floating replaced elements
|
||||||
// https://www.w3.org/TR/CSS22/visudet.html#inline-replaced-height
|
// https://www.w3.org/TR/CSS22/visudet.html#inline-replaced-height
|
||||||
float FormattingContext::tentative_height_for_replaced_element(FormattingState const& state, ReplacedBox const& box, CSS::LengthPercentage const& computed_height)
|
float FormattingContext::tentative_height_for_replaced_element(LayoutState const& state, ReplacedBox const& box, CSS::LengthPercentage const& computed_height)
|
||||||
{
|
{
|
||||||
auto computed_width = box.computed_values().width();
|
auto computed_width = box.computed_values().width();
|
||||||
|
|
||||||
|
@ -465,7 +465,7 @@ float FormattingContext::tentative_height_for_replaced_element(FormattingState c
|
||||||
return computed_height.resolved(box, CSS::Length::make_px(containing_block_height_for(box, state))).to_px(box);
|
return computed_height.resolved(box, CSS::Length::make_px(containing_block_height_for(box, state))).to_px(box);
|
||||||
}
|
}
|
||||||
|
|
||||||
float FormattingContext::compute_height_for_replaced_element(FormattingState const& state, ReplacedBox const& box)
|
float FormattingContext::compute_height_for_replaced_element(LayoutState const& state, ReplacedBox const& box)
|
||||||
{
|
{
|
||||||
// 10.6.2 Inline replaced elements, block-level replaced elements in normal flow,
|
// 10.6.2 Inline replaced elements, block-level replaced elements in normal flow,
|
||||||
// 'inline-block' replaced elements in normal flow and floating replaced elements
|
// 'inline-block' replaced elements in normal flow and floating replaced elements
|
||||||
|
@ -845,7 +845,7 @@ float FormattingContext::calculate_fit_content_height(Layout::Box const& box, Op
|
||||||
return calculate_fit_content_size(calculate_min_content_height(box), calculate_max_content_height(box), available_space);
|
return calculate_fit_content_size(calculate_min_content_height(box), calculate_max_content_height(box), available_space);
|
||||||
}
|
}
|
||||||
|
|
||||||
float FormattingContext::calculate_auto_height(FormattingState const& state, Box const& box)
|
float FormattingContext::calculate_auto_height(LayoutState const& state, Box const& box)
|
||||||
{
|
{
|
||||||
if (is<ReplacedBox>(box)) {
|
if (is<ReplacedBox>(box)) {
|
||||||
return compute_height_for_replaced_element(state, verify_cast<ReplacedBox>(box));
|
return compute_height_for_replaced_element(state, verify_cast<ReplacedBox>(box));
|
||||||
|
@ -861,11 +861,11 @@ float FormattingContext::calculate_min_content_width(Layout::Box const& box) con
|
||||||
|
|
||||||
auto& root_state = m_state.m_root;
|
auto& root_state = m_state.m_root;
|
||||||
|
|
||||||
auto& cache = *root_state.intrinsic_sizes.ensure(&box, [] { return adopt_own(*new FormattingState::IntrinsicSizes); });
|
auto& cache = *root_state.intrinsic_sizes.ensure(&box, [] { return adopt_own(*new LayoutState::IntrinsicSizes); });
|
||||||
if (cache.min_content_width.has_value())
|
if (cache.min_content_width.has_value())
|
||||||
return *cache.min_content_width;
|
return *cache.min_content_width;
|
||||||
|
|
||||||
FormattingState throwaway_state(&m_state);
|
LayoutState throwaway_state(&m_state);
|
||||||
auto const& containing_block = *box.containing_block();
|
auto const& containing_block = *box.containing_block();
|
||||||
auto& containing_block_state = throwaway_state.get_mutable(containing_block);
|
auto& containing_block_state = throwaway_state.get_mutable(containing_block);
|
||||||
containing_block_state.content_width = 0;
|
containing_block_state.content_width = 0;
|
||||||
|
@ -901,11 +901,11 @@ float FormattingContext::calculate_max_content_width(Layout::Box const& box) con
|
||||||
|
|
||||||
auto& root_state = m_state.m_root;
|
auto& root_state = m_state.m_root;
|
||||||
|
|
||||||
auto& cache = *root_state.intrinsic_sizes.ensure(&box, [] { return adopt_own(*new FormattingState::IntrinsicSizes); });
|
auto& cache = *root_state.intrinsic_sizes.ensure(&box, [] { return adopt_own(*new LayoutState::IntrinsicSizes); });
|
||||||
if (cache.max_content_width.has_value())
|
if (cache.max_content_width.has_value())
|
||||||
return *cache.max_content_width;
|
return *cache.max_content_width;
|
||||||
|
|
||||||
FormattingState throwaway_state(&m_state);
|
LayoutState throwaway_state(&m_state);
|
||||||
auto const& containing_block = *box.containing_block();
|
auto const& containing_block = *box.containing_block();
|
||||||
auto& containing_block_state = throwaway_state.get_mutable(containing_block);
|
auto& containing_block_state = throwaway_state.get_mutable(containing_block);
|
||||||
containing_block_state.content_width = INFINITY;
|
containing_block_state.content_width = INFINITY;
|
||||||
|
@ -941,11 +941,11 @@ float FormattingContext::calculate_min_content_height(Layout::Box const& box) co
|
||||||
|
|
||||||
auto& root_state = m_state.m_root;
|
auto& root_state = m_state.m_root;
|
||||||
|
|
||||||
auto& cache = *root_state.intrinsic_sizes.ensure(&box, [] { return adopt_own(*new FormattingState::IntrinsicSizes); });
|
auto& cache = *root_state.intrinsic_sizes.ensure(&box, [] { return adopt_own(*new LayoutState::IntrinsicSizes); });
|
||||||
if (cache.min_content_height.has_value())
|
if (cache.min_content_height.has_value())
|
||||||
return *cache.min_content_height;
|
return *cache.min_content_height;
|
||||||
|
|
||||||
FormattingState throwaway_state(&m_state);
|
LayoutState throwaway_state(&m_state);
|
||||||
auto const& containing_block = *box.containing_block();
|
auto const& containing_block = *box.containing_block();
|
||||||
auto& containing_block_state = throwaway_state.get_mutable(containing_block);
|
auto& containing_block_state = throwaway_state.get_mutable(containing_block);
|
||||||
containing_block_state.content_height = 0;
|
containing_block_state.content_height = 0;
|
||||||
|
@ -981,11 +981,11 @@ float FormattingContext::calculate_max_content_height(Layout::Box const& box) co
|
||||||
|
|
||||||
auto& root_state = m_state.m_root;
|
auto& root_state = m_state.m_root;
|
||||||
|
|
||||||
auto& cache = *root_state.intrinsic_sizes.ensure(&box, [] { return adopt_own(*new FormattingState::IntrinsicSizes); });
|
auto& cache = *root_state.intrinsic_sizes.ensure(&box, [] { return adopt_own(*new LayoutState::IntrinsicSizes); });
|
||||||
if (cache.max_content_height.has_value())
|
if (cache.max_content_height.has_value())
|
||||||
return *cache.max_content_height;
|
return *cache.max_content_height;
|
||||||
|
|
||||||
FormattingState throwaway_state(&m_state);
|
LayoutState throwaway_state(&m_state);
|
||||||
auto const& containing_block = *box.containing_block();
|
auto const& containing_block = *box.containing_block();
|
||||||
auto& containing_block_state = throwaway_state.get_mutable(containing_block);
|
auto& containing_block_state = throwaway_state.get_mutable(containing_block);
|
||||||
containing_block_state.content_height = INFINITY;
|
containing_block_state.content_height = INFINITY;
|
||||||
|
@ -1014,7 +1014,7 @@ float FormattingContext::calculate_max_content_height(Layout::Box const& box) co
|
||||||
return *cache.max_content_height;
|
return *cache.max_content_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
float FormattingContext::containing_block_width_for(Box const& box, FormattingState const& state)
|
float FormattingContext::containing_block_width_for(Box const& box, LayoutState const& state)
|
||||||
{
|
{
|
||||||
auto& containing_block_state = state.get(*box.containing_block());
|
auto& containing_block_state = state.get(*box.containing_block());
|
||||||
auto& box_state = state.get(box);
|
auto& box_state = state.get(box);
|
||||||
|
@ -1030,7 +1030,7 @@ float FormattingContext::containing_block_width_for(Box const& box, FormattingSt
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
float FormattingContext::containing_block_height_for(Box const& box, FormattingState const& state)
|
float FormattingContext::containing_block_height_for(Box const& box, LayoutState const& state)
|
||||||
{
|
{
|
||||||
auto& containing_block_state = state.get(*box.containing_block());
|
auto& containing_block_state = state.get(*box.containing_block());
|
||||||
auto& box_state = state.get(box);
|
auto& box_state = state.get(box);
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
#include <AK/OwnPtr.h>
|
#include <AK/OwnPtr.h>
|
||||||
#include <LibWeb/Forward.h>
|
#include <LibWeb/Forward.h>
|
||||||
#include <LibWeb/Layout/FormattingState.h>
|
#include <LibWeb/Layout/LayoutState.h>
|
||||||
|
|
||||||
namespace Web::Layout {
|
namespace Web::Layout {
|
||||||
|
|
||||||
|
@ -38,10 +38,10 @@ public:
|
||||||
|
|
||||||
static bool creates_block_formatting_context(Box const&);
|
static bool creates_block_formatting_context(Box const&);
|
||||||
|
|
||||||
static float compute_width_for_replaced_element(FormattingState const&, ReplacedBox const&);
|
static float compute_width_for_replaced_element(LayoutState const&, ReplacedBox const&);
|
||||||
static float compute_height_for_replaced_element(FormattingState const&, ReplacedBox const&);
|
static float compute_height_for_replaced_element(LayoutState const&, ReplacedBox const&);
|
||||||
|
|
||||||
OwnPtr<FormattingContext> create_independent_formatting_context_if_needed(FormattingState&, Box const& child_box);
|
OwnPtr<FormattingContext> create_independent_formatting_context_if_needed(LayoutState&, Box const& child_box);
|
||||||
|
|
||||||
virtual void parent_context_did_dimension_child_root_box() { }
|
virtual void parent_context_did_dimension_child_root_box() { }
|
||||||
|
|
||||||
|
@ -58,13 +58,13 @@ public:
|
||||||
float containing_block_width_for(Box const& box) const { return containing_block_width_for(box, m_state); }
|
float containing_block_width_for(Box const& box) const { return containing_block_width_for(box, m_state); }
|
||||||
float containing_block_height_for(Box const& box) const { return containing_block_height_for(box, m_state); }
|
float containing_block_height_for(Box const& box) const { return containing_block_height_for(box, m_state); }
|
||||||
|
|
||||||
static float containing_block_width_for(Box const&, FormattingState const&);
|
static float containing_block_width_for(Box const&, LayoutState const&);
|
||||||
static float containing_block_height_for(Box const&, FormattingState const&);
|
static float containing_block_height_for(Box const&, LayoutState const&);
|
||||||
|
|
||||||
virtual void run_intrinsic_size_determination(Box const&);
|
virtual void run_intrinsic_size_determination(Box const&);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
FormattingContext(Type, FormattingState&, Box const&, FormattingContext* parent = nullptr);
|
FormattingContext(Type, LayoutState&, Box const&, FormattingContext* parent = nullptr);
|
||||||
|
|
||||||
float calculate_fit_content_size(float min_content_size, float max_content_size, Optional<float> available_space) const;
|
float calculate_fit_content_size(float min_content_size, float max_content_size, Optional<float> available_space) const;
|
||||||
|
|
||||||
|
@ -81,11 +81,11 @@ protected:
|
||||||
float preferred_minimum_width { 0 };
|
float preferred_minimum_width { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
static float tentative_width_for_replaced_element(FormattingState const&, ReplacedBox const&, CSS::LengthPercentage const& computed_width);
|
static float tentative_width_for_replaced_element(LayoutState const&, ReplacedBox const&, CSS::LengthPercentage const& computed_width);
|
||||||
static float tentative_height_for_replaced_element(FormattingState const&, ReplacedBox const&, CSS::LengthPercentage const& computed_height);
|
static float tentative_height_for_replaced_element(LayoutState const&, ReplacedBox const&, CSS::LengthPercentage const& computed_height);
|
||||||
static float compute_auto_height_for_block_formatting_context_root(FormattingState const&, BlockContainer const&);
|
static float compute_auto_height_for_block_formatting_context_root(LayoutState const&, BlockContainer const&);
|
||||||
static float compute_auto_height_for_block_level_element(FormattingState const&, Box const&);
|
static float compute_auto_height_for_block_level_element(LayoutState const&, Box const&);
|
||||||
static float calculate_auto_height(FormattingState const& state, Box const& box);
|
static float calculate_auto_height(LayoutState const& state, Box const& box);
|
||||||
|
|
||||||
ShrinkToFitResult calculate_shrink_to_fit_widths(Box const&);
|
ShrinkToFitResult calculate_shrink_to_fit_widths(Box const&);
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ protected:
|
||||||
FormattingContext* m_parent { nullptr };
|
FormattingContext* m_parent { nullptr };
|
||||||
Box const& m_context_box;
|
Box const& m_context_box;
|
||||||
|
|
||||||
FormattingState& m_state;
|
LayoutState& m_state;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace Web::Layout {
|
||||||
|
|
||||||
constexpr float text_justification_threshold = 0.1;
|
constexpr float text_justification_threshold = 0.1;
|
||||||
|
|
||||||
InlineFormattingContext::InlineFormattingContext(FormattingState& state, BlockContainer const& containing_block, BlockFormattingContext& parent)
|
InlineFormattingContext::InlineFormattingContext(LayoutState& state, BlockContainer const& containing_block, BlockFormattingContext& parent)
|
||||||
: FormattingContext(Type::Inline, state, containing_block, &parent)
|
: FormattingContext(Type::Inline, state, containing_block, &parent)
|
||||||
, m_containing_block_state(state.get(containing_block))
|
, m_containing_block_state(state.get(containing_block))
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace Web::Layout {
|
||||||
|
|
||||||
class InlineFormattingContext final : public FormattingContext {
|
class InlineFormattingContext final : public FormattingContext {
|
||||||
public:
|
public:
|
||||||
InlineFormattingContext(FormattingState&, BlockContainer const& containing_block, BlockFormattingContext& parent);
|
InlineFormattingContext(LayoutState&, BlockContainer const& containing_block, BlockFormattingContext& parent);
|
||||||
~InlineFormattingContext();
|
~InlineFormattingContext();
|
||||||
|
|
||||||
BlockFormattingContext& parent();
|
BlockFormattingContext& parent();
|
||||||
|
@ -36,7 +36,7 @@ private:
|
||||||
void generate_line_boxes(LayoutMode);
|
void generate_line_boxes(LayoutMode);
|
||||||
void apply_justification_to_fragments(CSS::TextJustify, LineBox&, bool is_last_line);
|
void apply_justification_to_fragments(CSS::TextJustify, LineBox&, bool is_last_line);
|
||||||
|
|
||||||
FormattingState::NodeState const& m_containing_block_state;
|
LayoutState::NodeState const& m_containing_block_state;
|
||||||
float m_effective_containing_block_width { 0 };
|
float m_effective_containing_block_width { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
namespace Web::Layout {
|
namespace Web::Layout {
|
||||||
|
|
||||||
InlineLevelIterator::InlineLevelIterator(Layout::InlineFormattingContext& inline_formatting_context, Layout::FormattingState& formatting_state, Layout::BlockContainer const& container, LayoutMode layout_mode)
|
InlineLevelIterator::InlineLevelIterator(Layout::InlineFormattingContext& inline_formatting_context, Layout::LayoutState& formatting_state, Layout::BlockContainer const& container, LayoutMode layout_mode)
|
||||||
: m_inline_formatting_context(inline_formatting_context)
|
: m_inline_formatting_context(inline_formatting_context)
|
||||||
, m_formatting_state(formatting_state)
|
, m_formatting_state(formatting_state)
|
||||||
, m_container(container)
|
, m_container(container)
|
||||||
|
|
|
@ -48,7 +48,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
InlineLevelIterator(Layout::InlineFormattingContext&, FormattingState&, Layout::BlockContainer const&, LayoutMode);
|
InlineLevelIterator(Layout::InlineFormattingContext&, LayoutState&, Layout::BlockContainer const&, LayoutMode);
|
||||||
|
|
||||||
Optional<Item> next(float available_width);
|
Optional<Item> next(float available_width);
|
||||||
|
|
||||||
|
@ -66,9 +66,9 @@ private:
|
||||||
Layout::Node const* next_inline_node_in_pre_order(Layout::Node const& current, Layout::Node const* stay_within);
|
Layout::Node const* next_inline_node_in_pre_order(Layout::Node const& current, Layout::Node const* stay_within);
|
||||||
|
|
||||||
Layout::InlineFormattingContext& m_inline_formatting_context;
|
Layout::InlineFormattingContext& m_inline_formatting_context;
|
||||||
Layout::FormattingState& m_formatting_state;
|
Layout::LayoutState& m_formatting_state;
|
||||||
Layout::BlockContainer const& m_container;
|
Layout::BlockContainer const& m_container;
|
||||||
Layout::FormattingState::NodeState const& m_container_state;
|
Layout::LayoutState::NodeState const& m_container_state;
|
||||||
Layout::Node const* m_current_node { nullptr };
|
Layout::Node const* m_current_node { nullptr };
|
||||||
Layout::Node const* m_next_node { nullptr };
|
Layout::Node const* m_next_node { nullptr };
|
||||||
LayoutMode const m_layout_mode;
|
LayoutMode const m_layout_mode;
|
||||||
|
|
|
@ -5,12 +5,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <LibWeb/Layout/BlockContainer.h>
|
#include <LibWeb/Layout/BlockContainer.h>
|
||||||
#include <LibWeb/Layout/FormattingState.h>
|
#include <LibWeb/Layout/LayoutState.h>
|
||||||
#include <LibWeb/Layout/TextNode.h>
|
#include <LibWeb/Layout/TextNode.h>
|
||||||
|
|
||||||
namespace Web::Layout {
|
namespace Web::Layout {
|
||||||
|
|
||||||
FormattingState::NodeState& FormattingState::get_mutable(NodeWithStyleAndBoxModelMetrics const& box)
|
LayoutState::NodeState& LayoutState::get_mutable(NodeWithStyleAndBoxModelMetrics const& box)
|
||||||
{
|
{
|
||||||
auto serial_id = box.serial_id();
|
auto serial_id = box.serial_id();
|
||||||
if (nodes[serial_id])
|
if (nodes[serial_id])
|
||||||
|
@ -30,7 +30,7 @@ FormattingState::NodeState& FormattingState::get_mutable(NodeWithStyleAndBoxMode
|
||||||
return *nodes[serial_id];
|
return *nodes[serial_id];
|
||||||
}
|
}
|
||||||
|
|
||||||
FormattingState::NodeState const& FormattingState::get(NodeWithStyleAndBoxModelMetrics const& box) const
|
LayoutState::NodeState const& LayoutState::get(NodeWithStyleAndBoxModelMetrics const& box) const
|
||||||
{
|
{
|
||||||
auto serial_id = box.serial_id();
|
auto serial_id = box.serial_id();
|
||||||
if (nodes[serial_id])
|
if (nodes[serial_id])
|
||||||
|
@ -40,14 +40,14 @@ FormattingState::NodeState const& FormattingState::get(NodeWithStyleAndBoxModelM
|
||||||
if (ancestor->nodes[serial_id])
|
if (ancestor->nodes[serial_id])
|
||||||
return *ancestor->nodes[serial_id];
|
return *ancestor->nodes[serial_id];
|
||||||
}
|
}
|
||||||
const_cast<FormattingState*>(this)->nodes[serial_id] = adopt_own(*new NodeState);
|
const_cast<LayoutState*>(this)->nodes[serial_id] = adopt_own(*new NodeState);
|
||||||
const_cast<FormattingState*>(this)->nodes[serial_id]->node = const_cast<NodeWithStyleAndBoxModelMetrics*>(&box);
|
const_cast<LayoutState*>(this)->nodes[serial_id]->node = const_cast<NodeWithStyleAndBoxModelMetrics*>(&box);
|
||||||
return *nodes[serial_id];
|
return *nodes[serial_id];
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormattingState::commit()
|
void LayoutState::commit()
|
||||||
{
|
{
|
||||||
// Only the top-level FormattingState should ever be committed.
|
// Only the top-level LayoutState should ever be committed.
|
||||||
VERIFY(!m_parent);
|
VERIFY(!m_parent);
|
||||||
|
|
||||||
HashTable<Layout::TextNode*> text_nodes;
|
HashTable<Layout::TextNode*> text_nodes;
|
||||||
|
@ -91,7 +91,7 @@ void FormattingState::commit()
|
||||||
text_node->set_paintable(text_node->create_paintable());
|
text_node->set_paintable(text_node->create_paintable());
|
||||||
}
|
}
|
||||||
|
|
||||||
Gfx::FloatRect margin_box_rect(Box const& box, FormattingState const& state)
|
Gfx::FloatRect margin_box_rect(Box const& box, LayoutState const& state)
|
||||||
{
|
{
|
||||||
auto const& box_state = state.get(box);
|
auto const& box_state = state.get(box);
|
||||||
auto rect = Gfx::FloatRect { box_state.offset, { box_state.content_width, box_state.content_height } };
|
auto rect = Gfx::FloatRect { box_state.offset, { box_state.content_width, box_state.content_height } };
|
||||||
|
@ -102,7 +102,7 @@ Gfx::FloatRect margin_box_rect(Box const& box, FormattingState const& state)
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
Gfx::FloatRect margin_box_rect_in_ancestor_coordinate_space(Box const& box, Box const& ancestor_box, FormattingState const& state)
|
Gfx::FloatRect margin_box_rect_in_ancestor_coordinate_space(Box const& box, Box const& ancestor_box, LayoutState const& state)
|
||||||
{
|
{
|
||||||
auto rect = margin_box_rect(box, state);
|
auto rect = margin_box_rect(box, state);
|
||||||
for (auto const* current = box.parent(); current; current = current->parent()) {
|
for (auto const* current = box.parent(); current; current = current->parent()) {
|
||||||
|
@ -116,7 +116,7 @@ Gfx::FloatRect margin_box_rect_in_ancestor_coordinate_space(Box const& box, Box
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
Gfx::FloatRect absolute_content_rect(Box const& box, FormattingState const& state)
|
Gfx::FloatRect absolute_content_rect(Box const& box, LayoutState const& state)
|
||||||
{
|
{
|
||||||
auto const& box_state = state.get(box);
|
auto const& box_state = state.get(box);
|
||||||
Gfx::FloatRect rect { box_state.offset, { box_state.content_width, box_state.content_height } };
|
Gfx::FloatRect rect { box_state.offset, { box_state.content_width, box_state.content_height } };
|
|
@ -20,22 +20,22 @@ enum class SizeConstraint {
|
||||||
MaxContent,
|
MaxContent,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FormattingState {
|
struct LayoutState {
|
||||||
FormattingState()
|
LayoutState()
|
||||||
: m_root(*this)
|
: m_root(*this)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit FormattingState(FormattingState const* parent)
|
explicit LayoutState(LayoutState const* parent)
|
||||||
: m_parent(parent)
|
: m_parent(parent)
|
||||||
, m_root(find_root())
|
, m_root(find_root())
|
||||||
{
|
{
|
||||||
nodes.resize(m_root.nodes.size());
|
nodes.resize(m_root.nodes.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
FormattingState const& find_root() const
|
LayoutState const& find_root() const
|
||||||
{
|
{
|
||||||
FormattingState const* root = this;
|
LayoutState const* root = this;
|
||||||
for (auto* state = m_parent; state; state = state->m_parent)
|
for (auto* state = m_parent; state; state = state->m_parent)
|
||||||
root = state;
|
root = state;
|
||||||
return *root;
|
return *root;
|
||||||
|
@ -124,12 +124,12 @@ struct FormattingState {
|
||||||
|
|
||||||
HashMap<Box const*, float> mutable flex_item_size_cache;
|
HashMap<Box const*, float> mutable flex_item_size_cache;
|
||||||
|
|
||||||
FormattingState const* m_parent { nullptr };
|
LayoutState const* m_parent { nullptr };
|
||||||
FormattingState const& m_root;
|
LayoutState const& m_root;
|
||||||
};
|
};
|
||||||
|
|
||||||
Gfx::FloatRect absolute_content_rect(Box const&, FormattingState const&);
|
Gfx::FloatRect absolute_content_rect(Box const&, LayoutState const&);
|
||||||
Gfx::FloatRect margin_box_rect(Box const&, FormattingState const&);
|
Gfx::FloatRect margin_box_rect(Box const&, LayoutState const&);
|
||||||
Gfx::FloatRect margin_box_rect_in_ancestor_coordinate_space(Box const& box, Box const& ancestor_box, FormattingState const&);
|
Gfx::FloatRect margin_box_rect_in_ancestor_coordinate_space(Box const& box, Box const& ancestor_box, LayoutState const&);
|
||||||
|
|
||||||
}
|
}
|
|
@ -5,8 +5,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <AK/Utf8View.h>
|
#include <AK/Utf8View.h>
|
||||||
#include <LibWeb/Layout/FormattingState.h>
|
|
||||||
#include <LibWeb/Layout/InitialContainingBlock.h>
|
#include <LibWeb/Layout/InitialContainingBlock.h>
|
||||||
|
#include <LibWeb/Layout/LayoutState.h>
|
||||||
#include <LibWeb/Layout/LineBoxFragment.h>
|
#include <LibWeb/Layout/LineBoxFragment.h>
|
||||||
#include <LibWeb/Layout/TextNode.h>
|
#include <LibWeb/Layout/TextNode.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
|
@ -67,9 +67,9 @@ public:
|
||||||
|
|
||||||
Gfx::FloatRect selection_rect(Gfx::Font const&) const;
|
Gfx::FloatRect selection_rect(Gfx::Font const&) const;
|
||||||
|
|
||||||
float height_of_inline_level_box(FormattingState const&) const;
|
float height_of_inline_level_box(LayoutState const&) const;
|
||||||
float top_of_inline_level_box(FormattingState const&) const;
|
float top_of_inline_level_box(LayoutState const&) const;
|
||||||
float bottom_of_inline_level_box(FormattingState const&) const;
|
float bottom_of_inline_level_box(LayoutState const&) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Node const& m_layout_node;
|
Node const& m_layout_node;
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
namespace Web::Layout {
|
namespace Web::Layout {
|
||||||
|
|
||||||
LineBuilder::LineBuilder(InlineFormattingContext& context, FormattingState& formatting_state, LayoutMode layout_mode)
|
LineBuilder::LineBuilder(InlineFormattingContext& context, LayoutState& formatting_state, LayoutMode layout_mode)
|
||||||
: m_context(context)
|
: m_context(context)
|
||||||
, m_formatting_state(formatting_state)
|
, m_formatting_state(formatting_state)
|
||||||
, m_containing_block_state(formatting_state.get_mutable(context.containing_block()))
|
, m_containing_block_state(formatting_state.get_mutable(context.containing_block()))
|
||||||
|
@ -76,7 +76,7 @@ bool LineBuilder::should_break(float next_item_width)
|
||||||
return (current_line_width + next_item_width) > m_available_width_for_current_line;
|
return (current_line_width + next_item_width) > m_available_width_for_current_line;
|
||||||
}
|
}
|
||||||
|
|
||||||
static float box_baseline(FormattingState const& state, Box const& box)
|
static float box_baseline(LayoutState const& state, Box const& box)
|
||||||
{
|
{
|
||||||
auto const& box_state = state.get(box);
|
auto const& box_state = state.get(box);
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ class LineBuilder {
|
||||||
AK_MAKE_NONMOVABLE(LineBuilder);
|
AK_MAKE_NONMOVABLE(LineBuilder);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LineBuilder(InlineFormattingContext&, FormattingState&, LayoutMode);
|
LineBuilder(InlineFormattingContext&, LayoutState&, LayoutMode);
|
||||||
~LineBuilder();
|
~LineBuilder();
|
||||||
|
|
||||||
void break_line();
|
void break_line();
|
||||||
|
@ -50,8 +50,8 @@ private:
|
||||||
LineBox& ensure_last_line_box();
|
LineBox& ensure_last_line_box();
|
||||||
|
|
||||||
InlineFormattingContext& m_context;
|
InlineFormattingContext& m_context;
|
||||||
FormattingState& m_formatting_state;
|
LayoutState& m_formatting_state;
|
||||||
FormattingState::NodeState& m_containing_block_state;
|
LayoutState::NodeState& m_containing_block_state;
|
||||||
LayoutMode m_layout_mode {};
|
LayoutMode m_layout_mode {};
|
||||||
float m_available_width_for_current_line { 0 };
|
float m_available_width_for_current_line { 0 };
|
||||||
float m_current_y { 0 };
|
float m_current_y { 0 };
|
||||||
|
|
|
@ -25,7 +25,7 @@ enum class LayoutMode {
|
||||||
Normal,
|
Normal,
|
||||||
|
|
||||||
// Intrinsic size determination.
|
// Intrinsic size determination.
|
||||||
// Boxes honor min-content and max-content constraints (set via FormattingState::NodeState::{width,height}_constraint)
|
// Boxes honor min-content and max-content constraints (set via LayoutState::NodeState::{width,height}_constraint)
|
||||||
// by considering their containing block to be 0-sized or infinitely large in the relevant axis.
|
// by considering their containing block to be 0-sized or infinitely large in the relevant axis.
|
||||||
IntrinsicSizeDetermination,
|
IntrinsicSizeDetermination,
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
namespace Web::Layout {
|
namespace Web::Layout {
|
||||||
|
|
||||||
SVGFormattingContext::SVGFormattingContext(FormattingState& state, Box const& box, FormattingContext* parent)
|
SVGFormattingContext::SVGFormattingContext(LayoutState& state, Box const& box, FormattingContext* parent)
|
||||||
: FormattingContext(Type::SVG, state, box, parent)
|
: FormattingContext(Type::SVG, state, box, parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace Web::Layout {
|
||||||
|
|
||||||
class SVGFormattingContext : public FormattingContext {
|
class SVGFormattingContext : public FormattingContext {
|
||||||
public:
|
public:
|
||||||
explicit SVGFormattingContext(FormattingState&, Box const&, FormattingContext* parent);
|
explicit SVGFormattingContext(LayoutState&, Box const&, FormattingContext* parent);
|
||||||
~SVGFormattingContext();
|
~SVGFormattingContext();
|
||||||
|
|
||||||
virtual void run(Box const&, LayoutMode) override;
|
virtual void run(Box const&, LayoutMode) override;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
|
|
||||||
namespace Web::Layout {
|
namespace Web::Layout {
|
||||||
|
|
||||||
TableFormattingContext::TableFormattingContext(FormattingState& state, BlockContainer const& block_container, FormattingContext* parent)
|
TableFormattingContext::TableFormattingContext(LayoutState& state, BlockContainer const& block_container, FormattingContext* parent)
|
||||||
: BlockFormattingContext(state, block_container, parent)
|
: BlockFormattingContext(state, block_container, parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ struct ColumnWidth {
|
||||||
|
|
||||||
class TableFormattingContext final : public BlockFormattingContext {
|
class TableFormattingContext final : public BlockFormattingContext {
|
||||||
public:
|
public:
|
||||||
explicit TableFormattingContext(FormattingState&, BlockContainer const&, FormattingContext* parent);
|
explicit TableFormattingContext(LayoutState&, BlockContainer const&, FormattingContext* parent);
|
||||||
~TableFormattingContext();
|
~TableFormattingContext();
|
||||||
|
|
||||||
virtual void run(Box const&, LayoutMode) override;
|
virtual void run(Box const&, LayoutMode) override;
|
||||||
|
|
Loading…
Reference in a new issue