1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 11:27:34 +00:00

LibWeb: Factor out creation of independent formatting contexts

This patch breaks FormattingContext::layout_inside() into two functions,
one that creates an independent formatting context (if needed), and
another that calls the former and then performs the inside layout within
the appropriate context.

The main goal here was to make layout_inside() return the independent
formatting context if one was created. This will allow us to defer
certain operations in child contexts until the parent context has
finished formatting the child root box.
This commit is contained in:
Andreas Kling 2021-10-17 18:24:07 +02:00
parent f2d0e8d0ee
commit dabbade05c
2 changed files with 36 additions and 32 deletions

View file

@ -12,6 +12,8 @@ namespace Web::Layout {
class FormattingContext {
public:
virtual ~FormattingContext();
enum class Type {
Block,
Inline,
@ -38,11 +40,12 @@ public:
static float compute_width_for_replaced_element(const ReplacedBox&);
static float compute_height_for_replaced_element(const ReplacedBox&);
OwnPtr<FormattingContext> create_independent_formatting_context_if_needed(Box& child_box);
protected:
FormattingContext(Type, Box&, FormattingContext* parent = nullptr);
virtual ~FormattingContext();
void layout_inside(Box&, LayoutMode);
OwnPtr<FormattingContext> layout_inside(Box&, LayoutMode);
struct ShrinkToFitResult {
float preferred_width { 0 };