Path2D.h 1015 B

1234567891011121314151617181920212223242526272829303132333435363738
  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/PlatformObject.h>
  10. #include <LibWeb/Geometry/DOMMatrixReadOnly.h>
  11. #include <LibWeb/HTML/Canvas/CanvasPath.h>
  12. namespace Web::HTML {
  13. // https://html.spec.whatwg.org/multipage/canvas.html#path2d
  14. class Path2D final
  15. : public Bindings::PlatformObject
  16. , public CanvasPath {
  17. WEB_PLATFORM_OBJECT(Path2D, Bindings::PlatformObject);
  18. JS_DECLARE_ALLOCATOR(Path2D);
  19. public:
  20. static WebIDL::ExceptionOr<JS::NonnullGCPtr<Path2D>> construct_impl(JS::Realm&, Optional<Variant<JS::Handle<Path2D>, String>> const& path);
  21. virtual ~Path2D() override;
  22. WebIDL::ExceptionOr<void> add_path(JS::NonnullGCPtr<Path2D> path, Geometry::DOMMatrix2DInit& transform);
  23. private:
  24. Path2D(JS::Realm&, Optional<Variant<JS::Handle<Path2D>, String>> const&);
  25. virtual void initialize(JS::Realm&) override;
  26. };
  27. }