From abfd646c26f2e00484266507523c420bcb9ea7b8 Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sat, 3 Oct 2020 10:15:12 +0100 Subject: html_canvas_element: height and width have default values for canvasses Signed-off-by: Daniel Silverstone --- src/html/html_canvas_element.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/html/html_canvas_element.c b/src/html/html_canvas_element.c index 2543e5b..8e5d3fc 100644 --- a/src/html/html_canvas_element.c +++ b/src/html/html_canvas_element.c @@ -152,10 +152,22 @@ dom_exception dom_html_canvas_element_get_width(dom_html_canvas_element *canvas, dom_ulong *width) { - return dom_html_element_get_dom_ulong_property(&canvas->base, + dom_exception exc; + + exc = dom_html_element_get_dom_ulong_property(&canvas->base, "width", SLEN("width"), width); + + if (exc != DOM_NO_ERR) + return exc; + + if (*width == (dom_ulong)-1) { + /* width not set on the canvas, default is 300px */ + *width = 300; + } + + return DOM_NO_ERR; } dom_exception @@ -172,10 +184,22 @@ dom_exception dom_html_canvas_element_get_height(dom_html_canvas_element *canvas, dom_ulong *height) { - return dom_html_element_get_dom_ulong_property(&canvas->base, + dom_exception exc; + + exc = dom_html_element_get_dom_ulong_property(&canvas->base, "height", SLEN("height"), height); + + if (exc != DOM_NO_ERR) + return exc; + + if (*height == (dom_ulong)-1) { + /* height not set on the canvas, default is 150px */ + *height = 150; + } + + return DOM_NO_ERR; } dom_exception -- cgit v1.2.3