Serenity Operating System
at master 35 lines 1.5 kB view raw
1/* 2 * Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org> 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7#pragma once 8 9#include <AK/DeprecatedString.h> 10#include <LibWeb/HTML/HTMLCanvasElement.h> 11#include <LibWeb/HTML/HTMLImageElement.h> 12#include <LibWeb/WebIDL/ExceptionOr.h> 13 14namespace Web::HTML { 15 16// https://html.spec.whatwg.org/multipage/canvas.html#canvasimagesource 17// NOTE: This is the Variant created by the IDL wrapper generator, and needs to be updated accordingly. 18using CanvasImageSource = Variant<JS::Handle<HTMLImageElement>, JS::Handle<HTMLCanvasElement>>; 19 20// https://html.spec.whatwg.org/multipage/canvas.html#canvasdrawimage 21class CanvasDrawImage { 22public: 23 virtual ~CanvasDrawImage() = default; 24 25 WebIDL::ExceptionOr<void> draw_image(CanvasImageSource const&, float destination_x, float destination_y); 26 WebIDL::ExceptionOr<void> draw_image(CanvasImageSource const&, float destination_x, float destination_y, float destination_width, float destination_height); 27 WebIDL::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); 28 29 virtual WebIDL::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; 30 31protected: 32 CanvasDrawImage() = default; 33}; 34 35}