2020-06-15 17:29:35 +02:00
|
|
|
/*
|
2024-10-04 13:19:50 +02:00
|
|
|
* Copyright (c) 2020, Andreas Kling <andreas@ladybird.org>
|
2020-06-15 17:29:35 +02:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-06-15 17:29:35 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <AK/Vector.h>
|
2022-03-18 01:29:20 +01:00
|
|
|
#include <LibGfx/Matrix4x4.h>
|
2022-03-11 00:03:28 +01:00
|
|
|
#include <LibWeb/Painting/Paintable.h>
|
2020-06-15 17:29:35 +02:00
|
|
|
|
2022-03-10 02:13:28 +01:00
|
|
|
namespace Web::Painting {
|
|
|
|
|
|
2020-06-15 17:29:35 +02:00
|
|
|
class StackingContext {
|
2024-03-01 11:54:44 +01:00
|
|
|
friend class ViewportPaintable;
|
|
|
|
|
|
2020-06-15 17:29:35 +02:00
|
|
|
public:
|
2024-11-18 16:05:22 +01:00
|
|
|
StackingContext(PaintableBox&, StackingContext* parent, size_t index_in_tree_order);
|
2020-06-15 17:29:35 +02:00
|
|
|
|
|
|
|
|
StackingContext* parent() { return m_parent; }
|
2022-04-01 20:58:27 +03:00
|
|
|
StackingContext const* parent() const { return m_parent; }
|
2020-06-15 17:29:35 +02:00
|
|
|
|
2024-11-18 16:05:22 +01:00
|
|
|
PaintableBox const& paintable_box() const { return *m_paintable; }
|
2022-04-08 15:56:18 +02:00
|
|
|
|
2021-05-07 19:03:25 +03:00
|
|
|
enum class StackingContextPaintPhase {
|
|
|
|
|
BackgroundAndBorders,
|
|
|
|
|
Floats,
|
2022-02-14 16:39:45 +01:00
|
|
|
BackgroundAndBordersForInlineLevelAndReplaced,
|
2021-05-07 19:03:25 +03:00
|
|
|
Foreground,
|
|
|
|
|
FocusAndOverlay,
|
|
|
|
|
};
|
|
|
|
|
|
2023-09-10 13:41:00 +01:00
|
|
|
static void paint_node_as_stacking_context(Paintable const&, PaintContext&);
|
|
|
|
|
static void paint_descendants(PaintContext&, Paintable const&, StackingContextPaintPhase);
|
2024-10-09 02:57:57 +02:00
|
|
|
static void paint_svg(PaintContext&, PaintableBox const&, PaintPhase);
|
2022-03-10 15:44:43 +01:00
|
|
|
void paint(PaintContext&) const;
|
2024-02-13 21:34:07 +01:00
|
|
|
|
|
|
|
|
[[nodiscard]] TraversalDecision hit_test(CSSPixelPoint, HitTestType, Function<TraversalDecision(HitTestResult)> const& callback) const;
|
2020-06-15 17:29:35 +02:00
|
|
|
|
2022-07-19 15:18:20 +01:00
|
|
|
Gfx::AffineTransform affine_transform_matrix() const;
|
|
|
|
|
|
2020-06-15 17:29:35 +02:00
|
|
|
void dump(int indent = 0) const;
|
|
|
|
|
|
2022-03-13 16:19:54 +01:00
|
|
|
void sort();
|
|
|
|
|
|
2024-04-29 17:33:50 +02:00
|
|
|
void set_last_paint_generation_id(u64 generation_id);
|
|
|
|
|
|
2020-06-15 17:29:35 +02:00
|
|
|
private:
|
2024-11-18 16:05:22 +01:00
|
|
|
GC::Ref<PaintableBox> m_paintable;
|
2020-06-15 17:29:35 +02:00
|
|
|
StackingContext* const m_parent { nullptr };
|
|
|
|
|
Vector<StackingContext*> m_children;
|
2023-06-02 12:01:14 +02:00
|
|
|
size_t m_index_in_tree_order { 0 };
|
2024-04-29 17:33:50 +02:00
|
|
|
Optional<u64> m_last_paint_generation_id;
|
2021-07-23 13:19:16 +03:00
|
|
|
|
2024-11-18 16:05:22 +01:00
|
|
|
Vector<GC::Ref<PaintableBox const>> m_positioned_descendants_and_stacking_contexts_with_stack_level_0;
|
|
|
|
|
Vector<GC::Ref<PaintableBox const>> m_non_positioned_floating_descendants;
|
2024-03-01 11:54:44 +01:00
|
|
|
|
2023-09-10 13:41:00 +01:00
|
|
|
static void paint_child(PaintContext&, StackingContext const&);
|
2022-03-10 15:44:43 +01:00
|
|
|
void paint_internal(PaintContext&) const;
|
2020-06-15 17:29:35 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|