Use LXB_TAG to determine HTMLElement kind

Signed-off-by: Francis Bouvier <francis.bouvier@gmail.com>
This commit is contained in:
Francis Bouvier
2023-04-19 12:57:54 +02:00
parent 0e8bee0799
commit fe1ccd974e
2 changed files with 81 additions and 143 deletions

View File

@@ -761,3 +761,83 @@ pub const HTMLVideoElement = struct {
return .{ .proto = HTMLMediaElement.init(elem_base) };
}
};
const c = @cImport({
@cInclude("lexbor/html/html.h");
});
pub fn ElementToHTMLElementInterface(base: *parser.Element) HTMLElements {
return switch (base.*.node.local_name) {
c.LXB_TAG_A => .{ .anchor = HTMLAnchorElement.init(base) },
c.LXB_TAG_AREA => .{ .area = HTMLAreaElement.init(base) },
c.LXB_TAG_AUDIO => .{ .audio = HTMLAudioElement.init(base) },
c.LXB_TAG_BR => .{ .br = HTMLBRElement.init(base) },
c.LXB_TAG_BASE => .{ .base = HTMLBaseElement.init(base) },
c.LXB_TAG_BODY => .{ .body = HTMLBodyElement.init(base) },
c.LXB_TAG_BUTTON => .{ .button = HTMLButtonElement.init(base) },
c.LXB_TAG_CANVAS => .{ .canvas = HTMLCanvasElement.init(base) },
c.LXB_TAG_DL => .{ .dlist = HTMLDListElement.init(base) },
c.LXB_TAG_DIALOG => .{ .dialog = HTMLDialogElement.init(base) },
c.LXB_TAG_DATA => .{ .data = HTMLDataElement.init(base) },
c.LXB_TAG_DIV => .{ .div = HTMLDivElement.init(base) },
c.LXB_TAG_EMBED => .{ .embed = HTMLEmbedElement.init(base) },
c.LXB_TAG_FIELDSET => .{ .fieldset = HTMLFieldSetElement.init(base) },
c.LXB_TAG_FORM => .{ .form = HTMLFormElement.init(base) },
c.LXB_TAG_FRAMESET => .{ .frameset = HTMLFrameSetElement.init(base) },
c.LXB_TAG_HR => .{ .hr = HTMLHRElement.init(base) },
c.LXB_TAG_HEAD => .{ .head = HTMLHeadElement.init(base) },
c.LXB_TAG_H1 => .{ .heading = HTMLHeadingElement.init(base) },
c.LXB_TAG_H2 => .{ .heading = HTMLHeadingElement.init(base) },
c.LXB_TAG_H3 => .{ .heading = HTMLHeadingElement.init(base) },
c.LXB_TAG_H4 => .{ .heading = HTMLHeadingElement.init(base) },
c.LXB_TAG_H5 => .{ .heading = HTMLHeadingElement.init(base) },
c.LXB_TAG_H6 => .{ .heading = HTMLHeadingElement.init(base) },
c.LXB_TAG_HTML => .{ .html = HTMLHtmlElement.init(base) },
c.LXB_TAG_IFRAME => .{ .iframe = HTMLIFrameElement.init(base) },
c.LXB_TAG_IMG => .{ .img = HTMLImageElement.init(base) },
c.LXB_TAG_INPUT => .{ .input = HTMLInputElement.init(base) },
c.LXB_TAG_LI => .{ .li = HTMLLIElement.init(base) },
c.LXB_TAG_LABEL => .{ .label = HTMLLabelElement.init(base) },
c.LXB_TAG_LEGEND => .{ .legend = HTMLLegendElement.init(base) },
c.LXB_TAG_LINK => .{ .link = HTMLLinkElement.init(base) },
c.LXB_TAG_MAP => .{ .map = HTMLMapElement.init(base) },
c.LXB_TAG_META => .{ .meta = HTMLMetaElement.init(base) },
c.LXB_TAG_METER => .{ .meter = HTMLMeterElement.init(base) },
c.LXB_TAG_INS => .{ .mod = HTMLModElement.init(base) },
c.LXB_TAG_DEL => .{ .mod = HTMLModElement.init(base) },
c.LXB_TAG_OL => .{ .olist = HTMLOListElement.init(base) },
c.LXB_TAG_OBJECT => .{ .object = HTMLObjectElement.init(base) },
c.LXB_TAG_OPTGROUP => .{ .optgroup = HTMLOptGroupElement.init(base) },
c.LXB_TAG_OPTION => .{ .option = HTMLOptionElement.init(base) },
c.LXB_TAG_OUTPUT => .{ .output = HTMLOutputElement.init(base) },
c.LXB_TAG_P => .{ .paragraph = HTMLParagraphElement.init(base) },
c.LXB_TAG_PICTURE => .{ .picture = HTMLPictureElement.init(base) },
c.LXB_TAG_PRE => .{ .pre = HTMLPreElement.init(base) },
c.LXB_TAG_PROGRESS => .{ .progress = HTMLProgressElement.init(base) },
c.LXB_TAG_BLOCKQUOTE => .{ .quote = HTMLQuoteElement.init(base) },
c.LXB_TAG_Q => .{ .quote = HTMLQuoteElement.init(base) },
c.LXB_TAG_SCRIPT => .{ .script = HTMLScriptElement.init(base) },
c.LXB_TAG_SELECT => .{ .select = HTMLSelectElement.init(base) },
c.LXB_TAG_SOURCE => .{ .source = HTMLSourceElement.init(base) },
c.LXB_TAG_SPAN => .{ .span = HTMLSpanElement.init(base) },
c.LXB_TAG_STYLE => .{ .style = HTMLStyleElement.init(base) },
c.LXB_TAG_TABLE => .{ .table = HTMLTableElement.init(base) },
c.LXB_TAG_CAPTION => .{ .tablecaption = HTMLTableCaptionElement.init(base) },
c.LXB_TAG_TH => .{ .tablecell = HTMLTableCellElement.init(base) },
c.LXB_TAG_TD => .{ .tablecell = HTMLTableCellElement.init(base) },
c.LXB_TAG_COL => .{ .tablecol = HTMLTableColElement.init(base) },
c.LXB_TAG_TR => .{ .tablerow = HTMLTableRowElement.init(base) },
c.LXB_TAG_THEAD => .{ .tablesection = HTMLTableSectionElement.init(base) },
c.LXB_TAG_TBODY => .{ .tablesection = HTMLTableSectionElement.init(base) },
c.LXB_TAG_TFOOT => .{ .tablesection = HTMLTableSectionElement.init(base) },
c.LXB_TAG_TEMPLATE => .{ .template = HTMLTemplateElement.init(base) },
c.LXB_TAG_TEXTAREA => .{ .textarea = HTMLTextAreaElement.init(base) },
c.LXB_TAG_TIME => .{ .time = HTMLTimeElement.init(base) },
c.LXB_TAG_TITLE => .{ .title = HTMLTitleElement.init(base) },
c.LXB_TAG_TRACK => .{ .track = HTMLTrackElement.init(base) },
c.LXB_TAG_UL => .{ .ulist = HTMLUListElement.init(base) },
c.LXB_TAG_VIDEO => .{ .video = HTMLVideoElement.init(base) },
c.LXB_TAG__UNDEF => .{ .unknown = HTMLUnknownElement.init(base) },
else => .{ .unknown = HTMLUnknownElement.init(base) },
};
}