/src/serenity/Userland/Libraries/LibWeb/Painting/StackingContext.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) 2020, Andreas Kling <kling@serenityos.org> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #pragma once |
8 | | |
9 | | #include <AK/Vector.h> |
10 | | #include <LibGfx/Matrix4x4.h> |
11 | | #include <LibWeb/Painting/InlinePaintable.h> |
12 | | #include <LibWeb/Painting/Paintable.h> |
13 | | |
14 | | namespace Web::Painting { |
15 | | |
16 | | class StackingContext { |
17 | | friend class ViewportPaintable; |
18 | | |
19 | | public: |
20 | | StackingContext(Paintable&, StackingContext* parent, size_t index_in_tree_order); |
21 | | |
22 | 0 | StackingContext* parent() { return m_parent; } |
23 | 0 | StackingContext const* parent() const { return m_parent; } |
24 | | |
25 | 0 | Paintable const& paintable() const { return *m_paintable; } |
26 | 0 | PaintableBox const& paintable_box() const { return verify_cast<PaintableBox>(*m_paintable); } |
27 | 0 | InlinePaintable const& inline_paintable() const { return verify_cast<InlinePaintable>(*m_paintable); } |
28 | | |
29 | | enum class StackingContextPaintPhase { |
30 | | BackgroundAndBorders, |
31 | | Floats, |
32 | | BackgroundAndBordersForInlineLevelAndReplaced, |
33 | | Foreground, |
34 | | FocusAndOverlay, |
35 | | }; |
36 | | |
37 | | static void paint_node_as_stacking_context(Paintable const&, PaintContext&); |
38 | | static void paint_descendants(PaintContext&, Paintable const&, StackingContextPaintPhase); |
39 | | void paint(PaintContext&) const; |
40 | | |
41 | | [[nodiscard]] TraversalDecision hit_test(CSSPixelPoint, HitTestType, Function<TraversalDecision(HitTestResult)> const& callback) const; |
42 | | |
43 | | Gfx::AffineTransform affine_transform_matrix() const; |
44 | | |
45 | | void dump(int indent = 0) const; |
46 | | |
47 | | void sort(); |
48 | | |
49 | | void set_last_paint_generation_id(u64 generation_id); |
50 | | |
51 | | private: |
52 | | JS::NonnullGCPtr<Paintable> m_paintable; |
53 | | StackingContext* const m_parent { nullptr }; |
54 | | Vector<StackingContext*> m_children; |
55 | | size_t m_index_in_tree_order { 0 }; |
56 | | Optional<u64> m_last_paint_generation_id; |
57 | | |
58 | | Vector<JS::NonnullGCPtr<Paintable const>> m_positioned_descendants_with_stack_level_0_and_stacking_contexts; |
59 | | Vector<JS::NonnullGCPtr<Paintable const>> m_non_positioned_floating_descendants; |
60 | | |
61 | | static void paint_child(PaintContext&, StackingContext const&); |
62 | | void paint_internal(PaintContext&) const; |
63 | | }; |
64 | | |
65 | | } |