summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Layout/BlockFormattingContext.h
blob: b3247963d61827036937b2d290b324107220bb7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
 * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/Vector.h>
#include <LibWeb/Forward.h>
#include <LibWeb/Layout/FormattingContext.h>

namespace Web::Layout {

class BlockFormattingContext : public FormattingContext {
public:
    explicit BlockFormattingContext(Box&, FormattingContext* parent);
    ~BlockFormattingContext();

    virtual void run(Box&, LayoutMode) override;

    bool is_initial() const;

    const Vector<Box*>& left_floating_boxes() const { return m_left_floating_boxes; }
    const Vector<Box*>& right_floating_boxes() const { return m_right_floating_boxes; }

    static float compute_theoretical_height(const Box&);
    void compute_width(Box&);

protected:
    static void compute_height(Box&);
    void compute_position(Box&);

private:
    virtual bool is_block_formatting_context() const final { return true; }

    void compute_width_for_floating_box(Box&);

    void compute_width_for_block_level_replaced_element_in_normal_flow(ReplacedBox&);

    void layout_initial_containing_block(LayoutMode);

    void layout_block_level_children(Box&, LayoutMode);
    void layout_inline_children(Box&, LayoutMode);

    void place_block_level_replaced_element_in_normal_flow(Box& child, Box& container);
    void place_block_level_non_replaced_element_in_normal_flow(Box& child, Box& container);

    void layout_floating_child(Box&, Box& containing_block);

    void apply_transformations_to_children(Box&);

    Vector<Box*> m_left_floating_boxes;
    Vector<Box*> m_right_floating_boxes;
};

}