Serenity Operating System
at master 49 lines 1.6 kB view raw
1/* 2 * Copyright (c) 2020-2022, Andreas Kling <kling@serenityos.org> 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7#pragma once 8 9#include <AK/Types.h> 10#include <LibWeb/Forward.h> 11#include <LibWeb/Layout/BlockContainer.h> 12#include <LibWeb/Layout/FormattingContext.h> 13 14namespace Web::Layout { 15 16class InlineFormattingContext final : public FormattingContext { 17public: 18 InlineFormattingContext(LayoutState&, BlockContainer const& containing_block, BlockFormattingContext& parent); 19 ~InlineFormattingContext(); 20 21 BlockFormattingContext& parent(); 22 BlockFormattingContext const& parent() const; 23 24 BlockContainer const& containing_block() const { return static_cast<BlockContainer const&>(context_box()); } 25 26 virtual void run(Box const&, LayoutMode, AvailableSpace const&) override; 27 virtual CSSPixels automatic_content_height() const override; 28 virtual CSSPixels automatic_content_width() const override; 29 30 void dimension_box_on_line(Box const&, LayoutMode); 31 32 CSSPixels leftmost_x_offset_at(CSSPixels y) const; 33 CSSPixels available_space_for_line(CSSPixels y) const; 34 bool any_floats_intrude_at_y(CSSPixels y) const; 35 bool can_fit_new_line_at_y(CSSPixels y) const; 36 37private: 38 void generate_line_boxes(LayoutMode); 39 void apply_justification_to_fragments(CSS::TextJustify, LineBox&, bool is_last_line); 40 41 LayoutState::UsedValues const& m_containing_block_state; 42 43 Optional<AvailableSpace> m_available_space; 44 45 CSSPixels m_automatic_content_width { 0 }; 46 CSSPixels m_automatic_content_height { 0 }; 47}; 48 49}