@@ -32,6 +32,7 @@ const DataSet = @import("DataSet.zig");
3232
3333const StyleSheet = @import ("../cssom/StyleSheet.zig" );
3434const CSSStyleDeclaration = @import ("../cssom/CSSStyleDeclaration.zig" );
35+ const CanvasRenderingContext2D = @import ("../canvas/CanvasRenderingContext2D.zig" );
3536
3637// HTMLElement interfaces
3738pub const Interfaces = .{
@@ -487,6 +488,23 @@ pub const HTMLCanvasElement = struct {
487488 pub const Self = parser .Canvas ;
488489 pub const prototype = * HTMLElement ;
489490 pub const subtype = .node ;
491+
492+ /// This should be a union once we support other context types.
493+ const ContextAttributes = struct {
494+ alpha : bool ,
495+ color_space : []const u8 = "srgb" ,
496+ };
497+
498+ pub fn _getContext (
499+ ctx_type : []const u8 ,
500+ _ : ? ContextAttributes ,
501+ ) ! CanvasRenderingContext2D {
502+ if (! std .mem .eql (u8 , ctx_type , "2d" )) {
503+ return error .NotSupported ;
504+ }
505+
506+ return .{};
507+ }
490508};
491509
492510pub const HTMLDListElement = struct {
@@ -1356,3 +1374,7 @@ test "Browser: HTML.HtmlScriptElement" {
13561374test "Browser: HTML.HtmlSlotElement" {
13571375 try testing .htmlRunner ("html/slot.html" );
13581376}
1377+
1378+ test "Browser: HTML.HTMLCanvasElement" {
1379+ try testing .htmlRunner ("html/canvas.html" );
1380+ }
0 commit comments