mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-12-17 00:38:59 +00:00
Work on HTMLTemplateElement
Implement Html5ever get_template_contents and add_attrs_if_missing callbacks
This commit is contained in:
@@ -45,6 +45,7 @@ pub extern "C" fn html5ever_parse_document(
|
||||
create_comment_callback: CreateCommentCallback,
|
||||
append_doctype_to_document: AppendDoctypeToDocumentCallback,
|
||||
add_attrs_if_missing_callback: AddAttrsIfMissingCallback,
|
||||
get_template_contents_callback: GetTemplateContentsCallback,
|
||||
) -> () {
|
||||
if html.is_null() || len == 0 {
|
||||
return ();
|
||||
@@ -65,6 +66,7 @@ pub extern "C" fn html5ever_parse_document(
|
||||
create_comment_callback: create_comment_callback,
|
||||
append_doctype_to_document: append_doctype_to_document,
|
||||
add_attrs_if_missing_callback: add_attrs_if_missing_callback,
|
||||
get_template_contents_callback: get_template_contents_callback,
|
||||
};
|
||||
|
||||
let bytes = unsafe { std::slice::from_raw_parts(html, len) };
|
||||
@@ -87,6 +89,7 @@ pub extern "C" fn html5ever_parse_fragment(
|
||||
create_comment_callback: CreateCommentCallback,
|
||||
append_doctype_to_document: AppendDoctypeToDocumentCallback,
|
||||
add_attrs_if_missing_callback: AddAttrsIfMissingCallback,
|
||||
get_template_contents_callback: GetTemplateContentsCallback,
|
||||
) -> () {
|
||||
if html.is_null() || len == 0 {
|
||||
return ();
|
||||
@@ -107,6 +110,7 @@ pub extern "C" fn html5ever_parse_fragment(
|
||||
create_comment_callback: create_comment_callback,
|
||||
append_doctype_to_document: append_doctype_to_document,
|
||||
add_attrs_if_missing_callback: add_attrs_if_missing_callback,
|
||||
get_template_contents_callback: get_template_contents_callback,
|
||||
};
|
||||
|
||||
let bytes = unsafe { std::slice::from_raw_parts(html, len) };
|
||||
@@ -188,6 +192,7 @@ pub extern "C" fn html5ever_streaming_parser_create(
|
||||
create_comment_callback: CreateCommentCallback,
|
||||
append_doctype_to_document: AppendDoctypeToDocumentCallback,
|
||||
add_attrs_if_missing_callback: AddAttrsIfMissingCallback,
|
||||
get_template_contents_callback: GetTemplateContentsCallback,
|
||||
) -> *mut c_void {
|
||||
let arena = Box::new(typed_arena::Arena::new());
|
||||
|
||||
@@ -211,6 +216,7 @@ pub extern "C" fn html5ever_streaming_parser_create(
|
||||
create_comment_callback: create_comment_callback,
|
||||
append_doctype_to_document: append_doctype_to_document,
|
||||
add_attrs_if_missing_callback: add_attrs_if_missing_callback,
|
||||
get_template_contents_callback: get_template_contents_callback,
|
||||
};
|
||||
|
||||
// Create a parser which implements TendrilSink for streaming parsing
|
||||
|
||||
@@ -56,6 +56,7 @@ pub struct Sink<'arena> {
|
||||
pub create_comment_callback: CreateCommentCallback,
|
||||
pub append_doctype_to_document: AppendDoctypeToDocumentCallback,
|
||||
pub add_attrs_if_missing_callback: AddAttrsIfMissingCallback,
|
||||
pub get_template_contents_callback: GetTemplateContentsCallback,
|
||||
}
|
||||
|
||||
impl<'arena> TreeSink for Sink<'arena> {
|
||||
@@ -101,8 +102,9 @@ impl<'arena> TreeSink for Sink<'arena> {
|
||||
}
|
||||
|
||||
fn get_template_contents(&self, target: &Ref) -> Ref {
|
||||
_ = target;
|
||||
panic!("get_template_contents")
|
||||
unsafe {
|
||||
return (self.get_template_contents_callback)(self.ctx, *target);
|
||||
}
|
||||
}
|
||||
|
||||
fn is_mathml_annotation_xml_integration_point(&self, target: &Ref) -> bool {
|
||||
|
||||
@@ -57,6 +57,8 @@ pub type AddAttrsIfMissingCallback = unsafe extern "C" fn(
|
||||
attributes: *mut c_void,
|
||||
) -> ();
|
||||
|
||||
pub type GetTemplateContentsCallback = unsafe extern "C" fn(ctx: Ref, target: Ref) -> Ref;
|
||||
|
||||
pub type Ref = *const c_void;
|
||||
|
||||
#[repr(C)]
|
||||
|
||||
Reference in New Issue
Block a user