Struct html5ever_ext::RcDom
[−]
pub struct RcDom { pub document: Rc<Node>, pub errors: Vec<Cow<'static, str>>, pub quirks_mode: QuirksMode, }
The DOM itself; the result of parsing.
Fields
document: Rc<Node>
The Document
itself.
errors: Vec<Cow<'static, str>>
Errors that occurred during parsing.
quirks_mode: QuirksMode
The document's quirks mode.
Trait Implementations
impl TreeSink for RcDom
type Output = RcDom
The overall result of parsing. Read more
fn finish(self) -> RcDom
Consume this sink and return the overall result of parsing. Read more
type Handle = Rc<Node>
Handle
is a reference to a DOM node. The tree builder requires that a Handle
implements Clone
to get another reference to the same node. Read more
fn parse_error(&mut self, msg: Cow<'static, str>)
Signal a parse error.
fn get_document(&mut self) -> Rc<Node>
Get a handle to the Document
node.
fn get_template_contents(&mut self, target: &Rc<Node>) -> Rc<Node>
Get a handle to a template's template contents. The tree builder promises this will never be called with something else than a template element. Read more
fn set_quirks_mode(&mut self, mode: QuirksMode)
Set the document's quirks mode.
fn same_node(&self, x: &Rc<Node>, y: &Rc<Node>) -> bool
Do two handles refer to the same node?
fn elem_name(&self, target: &'a Rc<Node>) -> ExpandedName<'a>
What is the name of this element? Read more
fn create_element(
&mut self,
name: QualName,
attrs: Vec<Attribute>,
flags: ElementFlags
) -> Rc<Node>
&mut self,
name: QualName,
attrs: Vec<Attribute>,
flags: ElementFlags
) -> Rc<Node>
Create an element. Read more
fn create_comment(&mut self, text: Tendril<UTF8, NonAtomic>) -> Rc<Node>
Create a comment node.
fn create_pi(
&mut self,
target: Tendril<UTF8, NonAtomic>,
data: Tendril<UTF8, NonAtomic>
) -> Rc<Node>
&mut self,
target: Tendril<UTF8, NonAtomic>,
data: Tendril<UTF8, NonAtomic>
) -> Rc<Node>
Create a Processing Instruction node.
fn append(&mut self, parent: &Rc<Node>, child: NodeOrText<Rc<Node>>)
Append a node as the last child of the given node. If this would produce adjacent sibling text nodes, it should concatenate the text instead. Read more
fn append_before_sibling(
&mut self,
sibling: &Rc<Node>,
child: NodeOrText<Rc<Node>>
)
&mut self,
sibling: &Rc<Node>,
child: NodeOrText<Rc<Node>>
)
Append a node as the sibling immediately before the given node. Read more
fn append_based_on_parent_node(
&mut self,
element: &<RcDom as TreeSink>::Handle,
prev_element: &<RcDom as TreeSink>::Handle,
child: NodeOrText<<RcDom as TreeSink>::Handle>
)
&mut self,
element: &<RcDom as TreeSink>::Handle,
prev_element: &<RcDom as TreeSink>::Handle,
child: NodeOrText<<RcDom as TreeSink>::Handle>
)
When the insertion point is decided by the existence of a parent node of the element, we consider both possibilities and send the element which will be used if a parent node exists, along with the element to be used if there isn't one. Read more
fn append_doctype_to_document(
&mut self,
name: Tendril<UTF8, NonAtomic>,
public_id: Tendril<UTF8, NonAtomic>,
system_id: Tendril<UTF8, NonAtomic>
)
&mut self,
name: Tendril<UTF8, NonAtomic>,
public_id: Tendril<UTF8, NonAtomic>,
system_id: Tendril<UTF8, NonAtomic>
)
Append a DOCTYPE
element to the Document
node.
fn add_attrs_if_missing(&mut self, target: &Rc<Node>, attrs: Vec<Attribute>)
Add each attribute to the given element, if no attribute with that name already exists. The tree builder promises this will never be called with something else than an element. Read more
fn remove_from_parent(&mut self, target: &Rc<Node>)
Detach the given node from its parent.
fn reparent_children(&mut self, node: &Rc<Node>, new_parent: &Rc<Node>)
Remove all the children from node and append them to new_parent.
fn is_mathml_annotation_xml_integration_point(&self, target: &Rc<Node>) -> bool
Returns true if the adjusted current node is an HTML integration point and the token is a start tag. Read more
fn mark_script_already_started(&mut self, _node: &Self::Handle)
Mark a HTML <script>
as "already started".
fn pop(&mut self, _node: &Self::Handle)
Indicate that a node was popped off the stack of open elements.
fn associate_with_form(
&mut self,
_target: &Self::Handle,
_form: &Self::Handle,
_nodes: (&Self::Handle, Option<&Self::Handle>)
)
&mut self,
_target: &Self::Handle,
_form: &Self::Handle,
_nodes: (&Self::Handle, Option<&Self::Handle>)
)
Associate the given form-associatable element with the form element
fn set_current_line(&mut self, _line_number: u64)
Called whenever the line number changes.
fn complete_script(&mut self, _node: &Self::Handle) -> NextParserState
Indicate that a script
element is complete.
impl Default for RcDom
impl Selectable for RcDom
[src]
fn find_all_matching_child_nodes_depth_first_including_this_one<MatchUser: FnMut(&Rc<Node>) -> bool>(
&self,
selector: &OurSelector,
match_user: &mut MatchUser
) -> bool
[src]
&self,
selector: &OurSelector,
match_user: &mut MatchUser
) -> bool
Recursively find element nodes that match this selector. Return true from MatchUser to abort early. The result of this function is true if MatchUser aborted early, or false otherwise. Read more
fn matches(&self, selector: &OurSelector) -> bool
[src]
Returns whether this element matches this selector. For the RcDom and &'a [RcDom], is currently always false. Read more
impl Minify for RcDom
[src]
fn debug_fmt<W: Write>(&self, f: &mut W) -> Result
[src]
Identical to impl Debug's fmt() method, except we can't impl Debug for a trait and struct we don't own in this crate.
fn minify_to_writer<W: Write>(
&self,
html_head_and_body_tags_are_optional: bool,
writer: W
) -> Result<()>
[src]
&self,
html_head_and_body_tags_are_optional: bool,
writer: W
) -> Result<()>
Minifies and serializes an instance of an HTML DOM to a writer. only_serialize_children
should be true only if you do not want to serialize '&self', eg <main><p>...</p>><p>...</p></main>
with only_serialize_children
set to true would serialize <p>...</p>><p>...</p>
. Note that this has no effect on a RcDom - it will still serialize an entire document, including a DOCTYPE, etc. If creating AMP pages, set html_head_and_body_tags_are_optional
to false. If you need to serialize multiple RcDom or Node objects to the same writer, or need more control, consider using UltraMinifyingHtmlSerializer
. Read more
fn debug_string(&self) -> String
[src]
A debug string representing this node and any children.
fn minify_to_file_path<P: AsRef<Path>>(
&self,
html_head_and_body_tags_are_optional: bool,
html_file_path: P
) -> Result<(), HtmlError>
[src]
&self,
html_head_and_body_tags_are_optional: bool,
html_file_path: P
) -> Result<(), HtmlError>
Minifies and serializes an instance of an HTML DOM to file. only_serialize_children
should be true only if you do not want to serialize '&self', eg <main><p>...</p>><p>...</p></main>
with only_serialize_children
set to true would serialize <p>...</p>><p>...</p>
. Note that this has no effect on a RcDom - it will still serialize an entire document, including a DOCTYPE, etc. If creating AMP pages, set html_head_and_body_tags_are_optional
to false. If you need to serialize multiple RcDom or Node objects to the same writer, or need more control, consider using UltraMinifyingHtmlSerializer
. Read more
fn minify_to_string(&self, html_head_and_body_tags_are_optional: bool) -> String
[src]
Minifies and serializes an instance of an HTML DOM to String. only_serialize_children
should be true only if you do not want to serialize '&self', eg <main><p>...</p>><p>...</p></main>
with only_serialize_children
set to true would serialize <p>...</p>><p>...</p>
. Note that this has no effect on a RcDom - it will still serialize an entire document, including a DOCTYPE, etc. If creating AMP pages, set html_head_and_body_tags_are_optional
to false. If you need to serialize multiple RcDom or Node objects to the same writer, or need more control, consider using UltraMinifyingHtmlSerializer
. Read more
fn minify_to_bytes(&self, html_head_and_body_tags_are_optional: bool) -> Vec<u8>
[src]
Minifies and serializes an instance of an HTML DOM to a vector of bytes. only_serialize_children
should be true only if you do not want to serialize '&self', eg <main><p>...</p>><p>...</p></main>
with only_serialize_children
set to true would serialize <p>...</p>><p>...</p>
. Note that this has no effect on a RcDom - it will still serialize an entire document, including a DOCTYPE, etc. If creating AMP pages, set html_head_and_body_tags_are_optional
to false. If you need to serialize multiple RcDom or Node objects to the same writer, or need more control, consider using UltraMinifyingHtmlSerializer
. Read more
impl QualNameExt for RcDom
[src]
fn is_unprefixed_and_html_namespace_or_none(&self) -> bool
[src]
Is this name effectively local?
fn is_only_local(&self, local_name: &LocalName) -> bool
[src]
Is this qualified name this local-only name (no prefix, no namespace)
fn is_only_local_of(&self, local_names: &[LocalName]) -> bool
[src]
Is this qualified name on these local-only names (no prefix, no namespace)
fn can_have_children(&self) -> bool
[src]
Can this element have children?
fn text_content_should_be_escaped(&self) -> bool
[src]
Should an immediate child text node have <
, >
and &
characters escaped? In modern HTML 5, the only common nodes which don't need this are <script>
and <style>
. In this case, the immediate child text node's content should not contain, say, </script>
as this will cause a parse error. Read more
fn can_collapse_whitespace(&self) -> bool
[src]
Can this element's descendant text nodes have leading, trailing and interstitial whitespace collapsed?
impl RcDomExt for RcDom
[src]
fn from_file_path_verified_and_stripped_of_comments_and_processing_instructions_and_with_a_sane_doc_type<P: AsRef<Path>>(
html_document_file_path: P
) -> Result<Self, HtmlError>
[src]
html_document_file_path: P
) -> Result<Self, HtmlError>
Creates an instance of an HTML DOM from a file path which is verified, stripped and with a sane DocType.
fn from_file_path<P: AsRef<Path>>(
html_document_file_path: P
) -> Result<Self, HtmlError>
[src]
html_document_file_path: P
) -> Result<Self, HtmlError>
Creates an instance of an HTML DOM from a file path
fn verify(&self, context: &Path) -> Result<(), HtmlError>
[src]
Verify that this HTML DOM is valid.
fn recursively_strip_nodes_of_comments_and_processing_instructions_and_create_sane_doc_type(
&self,
context: &Path
) -> Result<(), HtmlError>
[src]
&self,
context: &Path
) -> Result<(), HtmlError>
Remove all comments and processing instructions and make the DOCTYPE a simple 'html' (for HTML 5).
fn move_node_children_to_parent_node(
&mut self,
parent_node: &Rc<Node>,
node: &Rc<Node>
)
[src]
&mut self,
parent_node: &Rc<Node>,
node: &Rc<Node>
)
Moves a node's children to another parent node
fn move_node_to_parent_node(&mut self, parent_node: &Rc<Node>, node: &Rc<Node>)
[src]
Moves an existing element node to a parent node
fn move_node_before_sibling_node(
&mut self,
sibling_node: &Rc<Node>,
node: &Rc<Node>
)
[src]
&mut self,
sibling_node: &Rc<Node>,
node: &Rc<Node>
)
Moves an existing element before a sibling node
fn append_new_element_to_parent_node(
&mut self,
parent_node: &Rc<Node>,
qualified_name: QualName,
attributes: Vec<Attribute>
)
[src]
&mut self,
parent_node: &Rc<Node>,
qualified_name: QualName,
attributes: Vec<Attribute>
)
Appends a new element node to a parent node
fn append_new_element_before_sibling_node(
&mut self,
sibling_node: &Rc<Node>,
qualified_name: QualName,
attributes: Vec<Attribute>
)
[src]
&mut self,
sibling_node: &Rc<Node>,
qualified_name: QualName,
attributes: Vec<Attribute>
)
Appends a new element before a sibling node
fn append_new_comment_to_parent_node(
&mut self,
parent_node: &Rc<Node>,
comment: &str
)
[src]
&mut self,
parent_node: &Rc<Node>,
comment: &str
)
Appends a new comment node to a parent node
fn append_new_comment_before_sibling_node(
&mut self,
sibling_node: &Rc<Node>,
comment: &str
)
[src]
&mut self,
sibling_node: &Rc<Node>,
comment: &str
)
Appends a new comment before a sibling node
fn append_new_processing_instruction_to_parent_node(
&mut self,
parent_node: &Rc<Node>,
target: &str,
data: &str
)
[src]
&mut self,
parent_node: &Rc<Node>,
target: &str,
data: &str
)
Appends a new processing instruction node to a parent node
fn append_new_processing_instruction_before_sibling_node(
&mut self,
sibling_node: &Rc<Node>,
target: &str,
data: &str
)
[src]
&mut self,
sibling_node: &Rc<Node>,
target: &str,
data: &str
)
Appends a new processing instruction before a sibling node
fn append_text_to_parent_node(&mut self, parent_node: &Rc<Node>, text: &str)
[src]
Appends a text node to a parent node
fn append_text_before_sibling_node(
&mut self,
sibling_node: &Rc<Node>,
text: &str
)
[src]
&mut self,
sibling_node: &Rc<Node>,
text: &str
)
Appends a text node before a sibling node