Merge pull request #1306 from lightpanda-io/generic-tags

add more generic tags
This commit is contained in:
Karl Seguin
2025-12-30 07:01:52 +08:00
committed by GitHub
2 changed files with 266 additions and 1 deletions

View File

@@ -1260,6 +1260,12 @@ pub fn createElement(self: *Page, ns_: ?[]const u8, name: []const u8, attribute_
attribute_iterator, attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "i", .{}) catch unreachable, ._tag = .i }, .{ ._proto = undefined, ._tag_name = String.init(undefined, "i", .{}) catch unreachable, ._tag = .i },
), ),
's' => return self.createHtmlElementT(
Element.Html.Generic,
namespace,
attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "s", .{}) catch unreachable, ._tag = .s },
),
else => {}, else => {},
}, },
2 => switch (@as(u16, @bitCast(name[0..2].*))) { 2 => switch (@as(u16, @bitCast(name[0..2].*))) {
@@ -1335,6 +1341,42 @@ pub fn createElement(self: *Page, ns_: ?[]const u8, name: []const u8, attribute_
attribute_iterator, attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "em", .{}) catch unreachable, ._tag = .em }, .{ ._proto = undefined, ._tag_name = String.init(undefined, "em", .{}) catch unreachable, ._tag = .em },
), ),
asUint("dd") => return self.createHtmlElementT(
Element.Html.Generic,
namespace,
attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "dd", .{}) catch unreachable, ._tag = .dd },
),
asUint("dl") => return self.createHtmlElementT(
Element.Html.Generic,
namespace,
attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "dl", .{}) catch unreachable, ._tag = .dl },
),
asUint("dt") => return self.createHtmlElementT(
Element.Html.Generic,
namespace,
attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "dt", .{}) catch unreachable, ._tag = .dt },
),
asUint("td") => return self.createHtmlElementT(
Element.Html.Generic,
namespace,
attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "td", .{}) catch unreachable, ._tag = .td },
),
asUint("th") => return self.createHtmlElementT(
Element.Html.Generic,
namespace,
attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "th", .{}) catch unreachable, ._tag = .th },
),
asUint("tr") => return self.createHtmlElementT(
Element.Html.Generic,
namespace,
attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "tr", .{}) catch unreachable, ._tag = .tr },
),
else => {}, else => {},
}, },
3 => switch (@as(u24, @bitCast(name[0..3].*))) { 3 => switch (@as(u24, @bitCast(name[0..3].*))) {
@@ -1356,6 +1398,36 @@ pub fn createElement(self: *Page, ns_: ?[]const u8, name: []const u8, attribute_
attribute_iterator, attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "nav", .{}) catch unreachable, ._tag = .nav }, .{ ._proto = undefined, ._tag_name = String.init(undefined, "nav", .{}) catch unreachable, ._tag = .nav },
), ),
asUint("del") => return self.createHtmlElementT(
Element.Html.Generic,
namespace,
attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "del", .{}) catch unreachable, ._tag = .del },
),
asUint("ins") => return self.createHtmlElementT(
Element.Html.Generic,
namespace,
attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "ins", .{}) catch unreachable, ._tag = .ins },
),
asUint("sub") => return self.createHtmlElementT(
Element.Html.Generic,
namespace,
attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "sub", .{}) catch unreachable, ._tag = .sub },
),
asUint("sup") => return self.createHtmlElementT(
Element.Html.Generic,
namespace,
attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "sup", .{}) catch unreachable, ._tag = .sup },
),
asUint("dfn") => return self.createHtmlElementT(
Element.Html.Generic,
namespace,
attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "dfn", .{}) catch unreachable, ._tag = .dfn },
),
else => {}, else => {},
}, },
4 => switch (@as(u32, @bitCast(name[0..4].*))) { 4 => switch (@as(u32, @bitCast(name[0..4].*))) {
@@ -1437,6 +1509,30 @@ pub fn createElement(self: *Page, ns_: ?[]const u8, name: []const u8, attribute_
return n; return n;
}, },
asUint("menu") => return self.createHtmlElementT(
Element.Html.Generic,
namespace,
attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "menu", .{}) catch unreachable, ._tag = .menu },
),
asUint("area") => return self.createHtmlElementT(
Element.Html.Generic,
namespace,
attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "area", .{}) catch unreachable, ._tag = .area },
),
asUint("code") => return self.createHtmlElementT(
Element.Html.Generic,
namespace,
attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "code", .{}) catch unreachable, ._tag = .code },
),
asUint("time") => return self.createHtmlElementT(
Element.Html.Generic,
namespace,
attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "time", .{}) catch unreachable, ._tag = .time },
),
else => {}, else => {},
}, },
5 => switch (@as(u40, @bitCast(name[0..5].*))) { 5 => switch (@as(u40, @bitCast(name[0..5].*))) {
@@ -1474,6 +1570,42 @@ pub fn createElement(self: *Page, ns_: ?[]const u8, name: []const u8, attribute_
namespace, namespace,
attribute_iterator, attribute_iterator,
), ),
asUint("aside") => return self.createHtmlElementT(
Element.Html.Generic,
namespace,
attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "aside", .{}) catch unreachable, ._tag = .aside },
),
asUint("meter") => return self.createHtmlElementT(
Element.Html.Generic,
namespace,
attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "meter", .{}) catch unreachable, ._tag = .meter },
),
asUint("table") => return self.createHtmlElementT(
Element.Html.Generic,
namespace,
attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "table", .{}) catch unreachable, ._tag = .table },
),
asUint("thead") => return self.createHtmlElementT(
Element.Html.Generic,
namespace,
attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "thead", .{}) catch unreachable, ._tag = .thead },
),
asUint("tbody") => return self.createHtmlElementT(
Element.Html.Generic,
namespace,
attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "tbody", .{}) catch unreachable, ._tag = .tbody },
),
asUint("tfoot") => return self.createHtmlElementT(
Element.Html.Generic,
namespace,
attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "tfoot", .{}) catch unreachable, ._tag = .tfoot },
),
else => {}, else => {},
}, },
6 => switch (@as(u48, @bitCast(name[0..6].*))) { 6 => switch (@as(u48, @bitCast(name[0..6].*))) {
@@ -1513,6 +1645,12 @@ pub fn createElement(self: *Page, ns_: ?[]const u8, name: []const u8, attribute_
attribute_iterator, attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "header", .{}) catch unreachable, ._tag = .header }, .{ ._proto = undefined, ._tag_name = String.init(undefined, "header", .{}) catch unreachable, ._tag = .header },
), ),
asUint("footer") => return self.createHtmlElementT(
Element.Html.Generic,
namespace,
attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "footer", .{}) catch unreachable, ._tag = .footer },
),
asUint("select") => return self.createHtmlElementT( asUint("select") => return self.createHtmlElementT(
Element.Html.Select, Element.Html.Select,
namespace, namespace,
@@ -1531,6 +1669,63 @@ pub fn createElement(self: *Page, ns_: ?[]const u8, name: []const u8, attribute_
attribute_iterator, attribute_iterator,
.{ ._proto = undefined }, .{ ._proto = undefined },
), ),
asUint("figure") => return self.createHtmlElementT(
Element.Html.Generic,
namespace,
attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "figure", .{}) catch unreachable, ._tag = .figure },
),
asUint("hgroup") => return self.createHtmlElementT(
Element.Html.Generic,
namespace,
attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "hgroup", .{}) catch unreachable, ._tag = .hgroup },
),
else => {},
},
7 => switch (@as(u56, @bitCast(name[0..7].*))) {
asUint("section") => return self.createHtmlElementT(
Element.Html.Generic,
namespace,
attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "section", .{}) catch unreachable, ._tag = .section },
),
asUint("article") => return self.createHtmlElementT(
Element.Html.Generic,
namespace,
attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "article", .{}) catch unreachable, ._tag = .article },
),
asUint("details") => return self.createHtmlElementT(
Element.Html.Generic,
namespace,
attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "details", .{}) catch unreachable, ._tag = .details },
),
asUint("summary") => return self.createHtmlElementT(
Element.Html.Generic,
namespace,
attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "summary", .{}) catch unreachable, ._tag = .summary },
),
asUint("caption") => return self.createHtmlElementT(
Element.Html.Generic,
namespace,
attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "caption", .{}) catch unreachable, ._tag = .caption },
),
asUint("marquee") => return self.createHtmlElementT(
Element.Html.Generic,
namespace,
attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "marquee", .{}) catch unreachable, ._tag = .marquee },
),
asUint("address") => return self.createHtmlElementT(
Element.Html.Generic,
namespace,
attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "address", .{}) catch unreachable, ._tag = .address },
),
else => {}, else => {},
}, },
8 => switch (@as(u64, @bitCast(name[0..8].*))) { 8 => switch (@as(u64, @bitCast(name[0..8].*))) {
@@ -1546,6 +1741,39 @@ pub fn createElement(self: *Page, ns_: ?[]const u8, name: []const u8, attribute_
attribute_iterator, attribute_iterator,
.{ ._proto = undefined, ._content = undefined }, .{ ._proto = undefined, ._content = undefined },
), ),
asUint("fieldset") => return self.createHtmlElementT(
Element.Html.Generic,
namespace,
attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "fieldset", .{}) catch unreachable, ._tag = .fieldset },
),
asUint("optgroup") => return self.createHtmlElementT(
Element.Html.Generic,
namespace,
attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "optgroup", .{}) catch unreachable, ._tag = .optgroup },
),
asUint("progress") => return self.createHtmlElementT(
Element.Html.Generic,
namespace,
attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "progress", .{}) catch unreachable, ._tag = .progress },
),
asUint("datalist") => return self.createHtmlElementT(
Element.Html.Generic,
namespace,
attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "datalist", .{}) catch unreachable, ._tag = .datalist },
),
else => {},
},
10 => switch (@as(u80, @bitCast(name[0..10].*))) {
asUint("blockquote") => return self.createHtmlElementT(
Element.Html.Generic,
namespace,
attribute_iterator,
.{ ._proto = undefined, ._tag_name = String.init(undefined, "blockquote", .{}) catch unreachable, ._tag = .blockquote },
),
else => {}, else => {},
}, },
else => {}, else => {},

View File

@@ -1088,23 +1088,40 @@ pub fn getTag(self: *const Element) Tag {
} }
pub const Tag = enum { pub const Tag = enum {
address,
anchor, anchor,
audio, audio,
area,
aside,
article,
b, b,
blockquote,
body, body,
br, br,
button, button,
base, base,
canvas, canvas,
caption,
circle, circle,
code,
custom, custom,
data, data,
datalist,
dd,
details,
del,
dfn,
dialog, dialog,
div, div,
dl,
dt,
embed, embed,
ellipse, ellipse,
em, em,
fieldset,
figure,
form, form,
footer,
g, g,
h1, h1,
h2, h2,
@@ -1115,37 +1132,57 @@ pub const Tag = enum {
head, head,
header, header,
heading, heading,
hgroup,
hr, hr,
html, html,
i, i,
iframe, iframe,
img, img,
input, input,
ins,
li, li,
line, line,
link, link,
main, main,
meta, marquee,
media, media,
menu,
meta,
meter,
nav, nav,
ol, ol,
optgroup,
option, option,
p, p,
path, path,
polygon, polygon,
polyline, polyline,
progress,
rect, rect,
s,
script, script,
section,
select, select,
slot, slot,
span, span,
strong, strong,
style, style,
sub,
summary,
sup,
svg, svg,
table,
time,
tbody,
td,
text, text,
template, template,
textarea, textarea,
tfoot,
th,
thead,
title, title,
tr,
ul, ul,
video, video,
unknown, unknown,