@@ -26,6 +26,7 @@ const c = @cImport({
2626 @cInclude ("events/event.h" );
2727 @cInclude ("events/mouse_event.h" );
2828 @cInclude ("utils/validate.h" );
29+ @cInclude ("html/html_element.h" );
2930});
3031
3132const mimalloc = @import ("mimalloc.zig" );
@@ -550,7 +551,7 @@ pub fn mutationEventRelatedNode(evt: *MutationEvent) !?*Node {
550551 const err = c ._dom_mutation_event_get_related_node (evt , & n );
551552 try DOMErr (err );
552553 if (n == null ) return null ;
553- return @as (* Node , @ptrCast (n ));
554+ return @as (* Node , @alignCast ( @ ptrCast (n ) ));
554555}
555556
556557// EventListener
@@ -565,7 +566,7 @@ fn eventListenerGetData(lst: *EventListener) ?*anyopaque {
565566pub const EventTarget = c .dom_event_target ;
566567
567568pub fn eventTargetToNode (et : * EventTarget ) * Node {
568- return @as (* Node , @ptrCast (et ));
569+ return @as (* Node , @alignCast ( @ ptrCast (et ) ));
569570}
570571
571572fn eventTargetVtable (et : * EventTarget ) c.dom_event_target_vtable {
@@ -894,7 +895,7 @@ pub fn nodeListItem(nodeList: *NodeList, index: u32) !?*Node {
894895 const err = c ._dom_nodelist_item (nodeList , index , & n );
895896 try DOMErr (err );
896897 if (n == null ) return null ;
897- return @as (* Node , @ptrCast (n ));
898+ return @as (* Node , @alignCast ( @ ptrCast (n ) ));
898899}
899900
900901// NodeExternal is the libdom public representation of a Node.
@@ -1323,7 +1324,7 @@ fn characterDataVtable(data: *CharacterData) c.dom_characterdata_vtable {
13231324}
13241325
13251326pub inline fn characterDataToNode (cdata : * CharacterData ) * Node {
1326- return @as (* Node , @ptrCast (cdata ));
1327+ return @as (* Node , @alignCast ( @ ptrCast (cdata ) ));
13271328}
13281329
13291330pub fn characterDataData (cdata : * CharacterData ) ! []const u8 {
@@ -1408,7 +1409,7 @@ pub const ProcessingInstruction = c.dom_processing_instruction;
14081409
14091410// processingInstructionToNode is an helper to convert an ProcessingInstruction to a node.
14101411pub inline fn processingInstructionToNode (pi : * ProcessingInstruction ) * Node {
1411- return @as (* Node , @ptrCast (pi ));
1412+ return @as (* Node , @alignCast ( @ ptrCast (pi ) ));
14121413}
14131414
14141415pub fn processInstructionCopy (pi : * ProcessingInstruction ) ! * ProcessingInstruction {
@@ -1463,7 +1464,7 @@ pub fn attributeGetOwnerElement(a: *Attribute) !?*Element {
14631464
14641465// attributeToNode is an helper to convert an attribute to a node.
14651466pub inline fn attributeToNode (a : * Attribute ) * Node {
1466- return @as (* Node , @ptrCast (a ));
1467+ return @as (* Node , @alignCast ( @ ptrCast (a ) ));
14671468}
14681469
14691470// Element
@@ -1601,7 +1602,7 @@ pub fn elementHasClass(elem: *Element, class: []const u8) !bool {
16011602
16021603// elementToNode is an helper to convert an element to a node.
16031604pub inline fn elementToNode (e : * Element ) * Node {
1604- return @as (* Node , @ptrCast (e ));
1605+ return @as (* Node , @alignCast ( @ ptrCast (e ) ));
16051606}
16061607
16071608// TokenList
@@ -1685,14 +1686,14 @@ pub fn elementHTMLGetTagType(elem_html: *ElementHTML) !Tag {
16851686
16861687// scriptToElt is an helper to convert an script to an element.
16871688pub inline fn scriptToElt (s : * Script ) * Element {
1688- return @as (* Element , @ptrCast (s ));
1689+ return @as (* Element , @alignCast ( @ ptrCast (s ) ));
16891690}
16901691
16911692// HTMLAnchorElement
16921693
16931694// anchorToNode is an helper to convert an anchor to a node.
16941695pub inline fn anchorToNode (a : * Anchor ) * Node {
1695- return @as (* Node , @ptrCast (a ));
1696+ return @as (* Node , @alignCast ( @ ptrCast (a ) ));
16961697}
16971698
16981699pub fn anchorGetTarget (a : * Anchor ) ! []const u8 {
@@ -1837,7 +1838,7 @@ pub const OptionCollection = c.dom_html_options_collection;
18371838pub const DocumentFragment = c .dom_document_fragment ;
18381839
18391840pub inline fn documentFragmentToNode (doc : * DocumentFragment ) * Node {
1840- return @as (* Node , @ptrCast (doc ));
1841+ return @as (* Node , @alignCast ( @ ptrCast (doc ) ));
18411842}
18421843
18431844pub fn documentFragmentBodyChildren (doc : * DocumentFragment ) ! ? * NodeList {
@@ -1947,7 +1948,7 @@ pub inline fn domImplementationCreateHTMLDocument(title: ?[]const u8) !*Document
19471948 if (title ) | t | {
19481949 const htitle = try documentCreateElement (doc , "title" );
19491950 const txt = try documentCreateTextNode (doc , t );
1950- _ = try nodeAppendChild (elementToNode (htitle ), @as (* Node , @ptrCast (txt )));
1951+ _ = try nodeAppendChild (elementToNode (htitle ), @as (* Node , @alignCast ( @ ptrCast (txt ) )));
19511952 _ = try nodeAppendChild (elementToNode (head ), elementToNode (htitle ));
19521953 }
19531954
@@ -1965,7 +1966,7 @@ fn documentVtable(doc: *Document) c.dom_document_vtable {
19651966}
19661967
19671968pub inline fn documentToNode (doc : * Document ) * Node {
1968- return @as (* Node , @ptrCast (doc ));
1969+ return @as (* Node , @alignCast ( @ ptrCast (doc ) ));
19691970}
19701971
19711972pub inline fn documentGetElementById (doc : * Document , id : []const u8 ) ! ? * Element {
@@ -2103,15 +2104,15 @@ pub inline fn documentImportNode(doc: *Document, node: *Node, deep: bool) !*Node
21032104 const nodeext = toNodeExternal (Node , node );
21042105 const err = documentVtable (doc ).dom_document_import_node .? (doc , nodeext , deep , & res );
21052106 try DOMErr (err );
2106- return @as (* Node , @ptrCast (res ));
2107+ return @as (* Node , @alignCast ( @ ptrCast (res ) ));
21072108}
21082109
21092110pub inline fn documentAdoptNode (doc : * Document , node : * Node ) ! * Node {
21102111 var res : NodeExternal = undefined ;
21112112 const nodeext = toNodeExternal (Node , node );
21122113 const err = documentVtable (doc ).dom_document_adopt_node .? (doc , nodeext , & res );
21132114 try DOMErr (err );
2114- return @as (* Node , @ptrCast (res ));
2115+ return @as (* Node , @alignCast ( @ ptrCast (res ) ));
21152116}
21162117
21172118pub inline fn documentCreateAttribute (doc : * Document , name : []const u8 ) ! * Attribute {
@@ -2146,7 +2147,7 @@ pub const DocumentHTML = c.dom_html_document;
21462147
21472148// documentHTMLToNode is an helper to convert a documentHTML to an node.
21482149pub inline fn documentHTMLToNode (doc : * DocumentHTML ) * Node {
2149- return @as (* Node , @ptrCast (doc ));
2150+ return @as (* Node , @alignCast ( @ ptrCast (doc ) ));
21502151}
21512152
21522153fn documentHTMLVtable (doc_html : * DocumentHTML ) c.dom_html_document_vtable {
@@ -2291,7 +2292,7 @@ pub inline fn documentHTMLBody(doc_html: *DocumentHTML) !?*Body {
22912292}
22922293
22932294pub inline fn bodyToElement (body : * Body ) * Element {
2294- return @as (* Element , @ptrCast (body ));
2295+ return @as (* Element , @alignCast ( @ ptrCast (body ) ));
22952296}
22962297
22972298pub inline fn documentHTMLSetBody (doc_html : * DocumentHTML , elt : ? * ElementHTML ) ! void {
@@ -2330,7 +2331,7 @@ pub inline fn documentHTMLSetTitle(doc: *DocumentHTML, v: []const u8) !void {
23302331
23312332pub fn documentHTMLSetCurrentScript (doc : * DocumentHTML , script : ? * Script ) ! void {
23322333 var s : ? * ElementHTML = null ;
2333- if (script != null ) s = @ptrCast (script .? );
2334+ if (script != null ) s = @alignCast ( @ ptrCast (script .? ) );
23342335 const err = documentHTMLVtable (doc ).set_current_script .? (doc , s );
23352336 try DOMErr (err );
23362337}
@@ -2759,7 +2760,7 @@ pub fn inputSetType(input: *Input, type_: []const u8) !void {
27592760 }
27602761 }
27612762 const new_type = if (found ) type_ else "text" ;
2762- try elementSetAttribute (@ptrCast (input ), "type" , new_type );
2763+ try elementSetAttribute (@alignCast ( @ ptrCast (input ) ), "type" , new_type );
27632764}
27642765
27652766pub fn inputGetValue (input : * Input ) ! []const u8 {
0 commit comments