/* HTML canvas element binding using duktape and libdom * * Copyright 2020 Vincent Sanders * Copyright 2020 Daniel Silverstone * * This file is part of NetSurf, http://www.netsurf-browser.org/ * * Released under the terms of the MIT License, * http://www.opensource.org/licenses/mit-license */ init HTMLCanvasElement(struct dom_html_element *html_canvas_element::html_element); getter HTMLCanvasElement::width(); /* setter HTMLCanvasElement::width(); */ getter HTMLCanvasElement::height(); /* setter HTMLCanvasElement::height(); */ method HTMLCanvasElement::getContext() %{ /* modetype[, {options}] */ const char *modetype = duk_to_string(ctx, 0); if (strcmp(modetype, "2d") != 0) { duk_push_null(ctx); return 1; } duk_push_this(ctx); duk_get_prop_string(ctx, -1, MAGIC(Context2D)); if (duk_is_undefined(ctx, -1)) { duk_pop(ctx); duk_push_pointer(ctx, ((node_private_t*)priv)->node); if (dukky_create_object(ctx, PROTO_NAME(CANVASRENDERINGCONTEXT2D), 1) != DUK_EXEC_SUCCESS) { return duk_error(ctx, DUK_ERR_ERROR, "Unable to create CanvasRenderingContext2D"); } duk_dup(ctx, -1); duk_put_prop_string(ctx, -3, MAGIC(Context2D)); } return 1; %}