Path2D.h 1004 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/RefCounted.h>
  8. #include <LibGfx/Path.h>
  9. #include <LibWeb/Bindings/Wrappable.h>
  10. #include <LibWeb/HTML/Canvas/CanvasPath.h>
  11. namespace Web::HTML {
  12. // https://html.spec.whatwg.org/multipage/canvas.html#path2d
  13. class Path2D
  14. : public RefCounted<Path2D>
  15. , public Bindings::Wrappable
  16. , public CanvasPath {
  17. AK_MAKE_NONCOPYABLE(Path2D);
  18. AK_MAKE_NONMOVABLE(Path2D);
  19. public:
  20. using WrapperType = Bindings::Path2DWrapper;
  21. static NonnullRefPtr<Path2D> create_with_global_object(HTML::Window&, Optional<Variant<NonnullRefPtr<Path2D>, String>> const& path) { return adopt_ref(*new Path2D(path)); }
  22. static NonnullRefPtr<Path2D> create(Optional<Variant<NonnullRefPtr<Path2D>, String>> const& path) { return adopt_ref(*new Path2D(path)); }
  23. ~Path2D() = default;
  24. private:
  25. Path2D(Optional<Variant<NonnullRefPtr<Path2D>, String>> const&);
  26. };
  27. }