StackingContext.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Vector.h>
  8. #include <LibGfx/Matrix4x4.h>
  9. #include <LibWeb/Layout/Node.h>
  10. #include <LibWeb/Painting/Paintable.h>
  11. namespace Web::Painting {
  12. class StackingContext {
  13. public:
  14. StackingContext(Layout::Box&, StackingContext* parent);
  15. StackingContext* parent() { return m_parent; }
  16. const StackingContext* parent() const { return m_parent; }
  17. enum class StackingContextPaintPhase {
  18. BackgroundAndBorders,
  19. Floats,
  20. BackgroundAndBordersForInlineLevelAndReplaced,
  21. Foreground,
  22. FocusAndOverlay,
  23. };
  24. void paint_descendants(PaintContext&, Layout::Node&, StackingContextPaintPhase) const;
  25. void paint(PaintContext&) const;
  26. Optional<HitTestResult> hit_test(Gfx::FloatPoint const&, HitTestType) const;
  27. void dump(int indent = 0) const;
  28. void sort();
  29. private:
  30. Layout::Box& m_box;
  31. StackingContext* const m_parent { nullptr };
  32. Vector<StackingContext*> m_children;
  33. void paint_internal(PaintContext&) const;
  34. Gfx::FloatMatrix4x4 get_transformation_matrix(CSS::Transformation const& transformation) const;
  35. Gfx::FloatMatrix4x4 combine_transformations(Vector<CSS::Transformation> const& transformations) const;
  36. Gfx::AffineTransform combine_transformations_2d(Vector<CSS::Transformation> const& transformations) const;
  37. Gfx::FloatPoint transform_origin() const;
  38. };
  39. }