mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-12-17 00:38:59 +00:00
add remove_from_parent html5ever callback
This commit is contained in:
@@ -46,6 +46,7 @@ pub extern "C" fn html5ever_parse_document(
|
||||
append_doctype_to_document: AppendDoctypeToDocumentCallback,
|
||||
add_attrs_if_missing_callback: AddAttrsIfMissingCallback,
|
||||
get_template_contents_callback: GetTemplateContentsCallback,
|
||||
remove_from_parent_callback: RemoveFromParentCallback,
|
||||
) -> () {
|
||||
if html.is_null() || len == 0 {
|
||||
return ();
|
||||
@@ -67,6 +68,7 @@ pub extern "C" fn html5ever_parse_document(
|
||||
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,
|
||||
remove_from_parent_callback: remove_from_parent_callback,
|
||||
};
|
||||
|
||||
let bytes = unsafe { std::slice::from_raw_parts(html, len) };
|
||||
@@ -90,6 +92,7 @@ pub extern "C" fn html5ever_parse_fragment(
|
||||
append_doctype_to_document: AppendDoctypeToDocumentCallback,
|
||||
add_attrs_if_missing_callback: AddAttrsIfMissingCallback,
|
||||
get_template_contents_callback: GetTemplateContentsCallback,
|
||||
remove_from_parent_callback: RemoveFromParentCallback,
|
||||
) -> () {
|
||||
if html.is_null() || len == 0 {
|
||||
return ();
|
||||
@@ -111,6 +114,7 @@ pub extern "C" fn html5ever_parse_fragment(
|
||||
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,
|
||||
remove_from_parent_callback: remove_from_parent_callback,
|
||||
};
|
||||
|
||||
let bytes = unsafe { std::slice::from_raw_parts(html, len) };
|
||||
@@ -193,6 +197,7 @@ pub extern "C" fn html5ever_streaming_parser_create(
|
||||
append_doctype_to_document: AppendDoctypeToDocumentCallback,
|
||||
add_attrs_if_missing_callback: AddAttrsIfMissingCallback,
|
||||
get_template_contents_callback: GetTemplateContentsCallback,
|
||||
remove_from_parent_callback: RemoveFromParentCallback,
|
||||
) -> *mut c_void {
|
||||
let arena = Box::new(typed_arena::Arena::new());
|
||||
|
||||
@@ -217,6 +222,7 @@ pub extern "C" fn html5ever_streaming_parser_create(
|
||||
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,
|
||||
remove_from_parent_callback: remove_from_parent_callback,
|
||||
};
|
||||
|
||||
// Create a parser which implements TendrilSink for streaming parsing
|
||||
|
||||
@@ -57,6 +57,7 @@ pub struct Sink<'arena> {
|
||||
pub append_doctype_to_document: AppendDoctypeToDocumentCallback,
|
||||
pub add_attrs_if_missing_callback: AddAttrsIfMissingCallback,
|
||||
pub get_template_contents_callback: GetTemplateContentsCallback,
|
||||
pub remove_from_parent_callback: RemoveFromParentCallback,
|
||||
}
|
||||
|
||||
impl<'arena> TreeSink for Sink<'arena> {
|
||||
@@ -228,8 +229,9 @@ impl<'arena> TreeSink for Sink<'arena> {
|
||||
}
|
||||
|
||||
fn remove_from_parent(&self, target: &Ref) {
|
||||
_ = target;
|
||||
panic!("remove_from_parent");
|
||||
unsafe {
|
||||
(self.remove_from_parent_callback)(self.ctx, *target);
|
||||
}
|
||||
}
|
||||
|
||||
fn reparent_children(&self, node: &Ref, new_parent: &Ref) {
|
||||
|
||||
@@ -59,6 +59,8 @@ pub type AddAttrsIfMissingCallback = unsafe extern "C" fn(
|
||||
|
||||
pub type GetTemplateContentsCallback = unsafe extern "C" fn(ctx: Ref, target: Ref) -> Ref;
|
||||
|
||||
pub type RemoveFromParentCallback = unsafe extern "C" fn(ctx: Ref, target: Ref) -> ();
|
||||
|
||||
pub type Ref = *const c_void;
|
||||
|
||||
#[repr(C)]
|
||||
|
||||
Reference in New Issue
Block a user