1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:58:11 +00:00
serenity/Userland/Libraries/LibWeb/Layout/InlineFormattingContext.h
Andreas Kling 561612f219 LibWeb: Add Layout::FormattingState
The purpose of this new object will be to keep track of various states
during an ongoing layout.

Until now, we've been updating layout tree nodes as we go during layout,
which adds an invisible layer of implicit serialization to the whole
layout system.

My idea with FormattingState is that running layout will produce a
result entirely contained within the FormattingState object. At the end
of layout, it can then be applied to the layout tree, or simply queried
for some metrics we were trying to determine.

When doing subtree layouts to determine intrinsic sizes, we will
eventually be able to clone the current FormattingState, and run the
subtree layout in isolation, opening up opportunities for parallelism.

This first patch doesn't go very far though, it merely adds the object
as a skeleton class, and makes sure the root BFC has one. :^)
2022-02-21 18:35:12 +01:00

42 lines
1.1 KiB
C++

/*
* Copyright (c) 2020-2022, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Types.h>
#include <LibWeb/Forward.h>
#include <LibWeb/Layout/BlockContainer.h>
#include <LibWeb/Layout/FormattingContext.h>
namespace Web::Layout {
class InlineFormattingContext final : public FormattingContext {
public:
InlineFormattingContext(FormattingState&, BlockContainer& containing_block, BlockFormattingContext& parent);
~InlineFormattingContext();
BlockFormattingContext& parent();
BlockFormattingContext const& parent() const;
BlockContainer& containing_block() { return static_cast<BlockContainer&>(context_box()); }
BlockContainer const& containing_block() const { return static_cast<BlockContainer const&>(context_box()); }
virtual void run(Box&, LayoutMode) override;
void dimension_box_on_line(Box&, LayoutMode);
struct AvailableSpaceForLineInfo {
float left { 0 };
float right { 0 };
};
AvailableSpaceForLineInfo available_space_for_line(float y) const;
private:
void generate_line_boxes(LayoutMode);
};
}