2020-11-22 09:38:18 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-11-22 09:38:18 -03:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2020-12-05 16:10:39 -03:00
|
|
|
#include <AK/Vector.h>
|
2020-11-22 09:38:18 -03:00
|
|
|
#include <LibWeb/Forward.h>
|
|
|
|
|
#include <LibWeb/Layout/FormattingContext.h>
|
|
|
|
|
|
|
|
|
|
namespace Web::Layout {
|
|
|
|
|
|
|
|
|
|
class BlockFormattingContext : public FormattingContext {
|
|
|
|
|
public:
|
2020-11-25 16:08:52 -03:00
|
|
|
explicit BlockFormattingContext(Box&, FormattingContext* parent);
|
2020-11-22 09:38:18 -03:00
|
|
|
~BlockFormattingContext();
|
|
|
|
|
|
2020-12-06 15:48:02 -03:00
|
|
|
virtual void run(Box&, LayoutMode) override;
|
2020-11-22 09:38:18 -03:00
|
|
|
|
|
|
|
|
bool is_initial() const;
|
|
|
|
|
|
2020-12-05 16:10:39 -03:00
|
|
|
const Vector<Box*>& left_floating_boxes() const { return m_left_floating_boxes; }
|
|
|
|
|
const Vector<Box*>& right_floating_boxes() const { return m_right_floating_boxes; }
|
|
|
|
|
|
2021-05-30 16:57:13 -03:00
|
|
|
static float compute_theoretical_height(const Box&);
|
2020-11-22 11:53:01 -03:00
|
|
|
void compute_width(Box&);
|
2021-05-30 16:57:13 -03:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
static void compute_height(Box&);
|
2021-03-29 13:04:26 -03:00
|
|
|
void compute_position(Box&);
|
2020-11-22 09:38:18 -03:00
|
|
|
|
|
|
|
|
private:
|
2020-12-05 16:10:39 -03:00
|
|
|
virtual bool is_block_formatting_context() const final { return true; }
|
|
|
|
|
|
2020-12-05 21:08:14 -03:00
|
|
|
void compute_width_for_floating_box(Box&);
|
2020-11-22 09:38:18 -03:00
|
|
|
|
2020-12-11 18:27:09 -03:00
|
|
|
void compute_width_for_block_level_replaced_element_in_normal_flow(ReplacedBox&);
|
2021-03-08 18:49:34 -03:00
|
|
|
|
2020-11-22 09:38:18 -03:00
|
|
|
void layout_initial_containing_block(LayoutMode);
|
|
|
|
|
|
2020-12-06 15:48:02 -03:00
|
|
|
void layout_block_level_children(Box&, LayoutMode);
|
|
|
|
|
void layout_inline_children(Box&, LayoutMode);
|
2020-11-22 09:38:18 -03:00
|
|
|
|
2020-12-06 15:48:02 -03:00
|
|
|
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);
|
2020-12-05 16:10:39 -03:00
|
|
|
|
2021-09-18 13:42:27 -03:00
|
|
|
void apply_transformations_to_children(Box&);
|
|
|
|
|
|
2020-12-05 16:10:39 -03:00
|
|
|
Vector<Box*> m_left_floating_boxes;
|
|
|
|
|
Vector<Box*> m_right_floating_boxes;
|
2020-11-22 09:38:18 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|