CanvasDrawImage.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  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/String.h>
  8. #include <LibWeb/DOM/ExceptionOr.h>
  9. #include <LibWeb/HTML/HTMLCanvasElement.h>
  10. #include <LibWeb/HTML/HTMLImageElement.h>
  11. namespace Web::HTML {
  12. // https://html.spec.whatwg.org/multipage/canvas.html#canvasimagesource
  13. // NOTE: This is the Variant created by the IDL wrapper generator, and needs to be updated accordingly.
  14. using CanvasImageSource = Variant<JS::Handle<HTMLImageElement>, JS::Handle<HTMLCanvasElement>>;
  15. // https://html.spec.whatwg.org/multipage/canvas.html#canvasdrawimage
  16. class CanvasDrawImage {
  17. public:
  18. virtual ~CanvasDrawImage() = default;
  19. DOM::ExceptionOr<void> draw_image(CanvasImageSource const&, float destination_x, float destination_y);
  20. DOM::ExceptionOr<void> draw_image(CanvasImageSource const&, float destination_x, float destination_y, float destination_width, float destination_height);
  21. DOM::ExceptionOr<void> draw_image(CanvasImageSource const&, float source_x, float source_y, float source_width, float source_height, float destination_x, float destination_y, float destination_width, float destination_height);
  22. virtual DOM::ExceptionOr<void> draw_image_internal(CanvasImageSource const&, float source_x, float source_y, float source_width, float source_height, float destination_x, float destination_y, float destination_width, float destination_height) = 0;
  23. protected:
  24. CanvasDrawImage() = default;
  25. };
  26. }