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

LibWeb: Add ViewportPaintable to represent viewports in the paint tree

This patch just adds the new root paintable and updates the tests
expectations. The next patch will move painting logic from the layout
viewport to the paint viewport.
This commit is contained in:
Andreas Kling 2023-08-18 15:52:40 +02:00
parent 136ac1a6a5
commit c01c4b41e2
389 changed files with 441 additions and 384 deletions

View file

@ -493,6 +493,7 @@ set(SOURCES
Painting/TableBordersPainting.cpp
Painting/TextPaintable.cpp
Painting/VideoPaintable.cpp
Painting/ViewportPaintable.cpp
PerformanceTimeline/EntryTypes.cpp
PerformanceTimeline/PerformanceEntry.cpp
PermissionsPolicy/AutoplayAllowlist.cpp

View file

@ -9,6 +9,7 @@
#include <LibWeb/Layout/Viewport.h>
#include <LibWeb/Painting/PaintableBox.h>
#include <LibWeb/Painting/StackingContext.h>
#include <LibWeb/Painting/ViewportPaintable.h>
namespace Web::Layout {
@ -126,4 +127,9 @@ void Viewport::recompute_selection_states()
}
}
JS::GCPtr<Painting::Paintable> Viewport::create_paintable() const
{
return Painting::ViewportPaintable::create(*this);
}
}

View file

@ -29,6 +29,8 @@ public:
void recompute_selection_states();
private:
virtual JS::GCPtr<Painting::Paintable> create_paintable() const override;
void build_stacking_context_tree();
virtual bool is_viewport() const override { return true; }
};

View file

@ -218,7 +218,7 @@ private:
Optional<TableCellCoordinates> m_table_cell_coordinates;
};
class PaintableWithLines final : public PaintableBox {
class PaintableWithLines : public PaintableBox {
JS_CELL(PaintableWithLines, PaintableBox);
public:

View file

@ -0,0 +1,24 @@
/*
* Copyright (c) 2023, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Layout/Viewport.h>
#include <LibWeb/Painting/ViewportPaintable.h>
namespace Web::Painting {
JS::NonnullGCPtr<ViewportPaintable> ViewportPaintable::create(Layout::Viewport const& layout_viewport)
{
return layout_viewport.heap().allocate_without_realm<ViewportPaintable>(layout_viewport);
}
ViewportPaintable::ViewportPaintable(Layout::Viewport const& layout_viewport)
: PaintableWithLines(layout_viewport)
{
}
ViewportPaintable::~ViewportPaintable() = default;
}

View file

@ -0,0 +1,24 @@
/*
* Copyright (c) 2023, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/Painting/PaintableBox.h>
namespace Web::Painting {
class ViewportPaintable final : public PaintableWithLines {
JS_CELL(ViewportPaintable, PaintableWithLines);
public:
static JS::NonnullGCPtr<ViewportPaintable> create(Layout::Viewport const&);
virtual ~ViewportPaintable() override;
private:
explicit ViewportPaintable(Layout::Viewport const&);
};
}