mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 11:45:11 +00:00

This resolves a long-standing architectural problem in LibWeb that made it unable to place CSS floating objects correctly due to not having final vertical position information when computing the amount of available horizontal space for each line.
41 lines
1.1 KiB
C++
41 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(BlockContainer& containing_block, FormattingContext* parent);
|
|
~InlineFormattingContext();
|
|
|
|
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;
|
|
|
|
float available_width_at_line(size_t line_index) const;
|
|
|
|
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);
|
|
};
|
|
|
|
}
|