use tokenizer::Attribute;
use std::borrow::Cow;
use string_cache::QualName;
use tendril::StrTendril;
pub use self::QuirksMode::{Quirks, LimitedQuirks, NoQuirks};
pub use self::NodeOrText::{AppendNode, AppendText};
#[derive(PartialEq, Eq, Copy, Clone, Hash, Debug)]
pub enum QuirksMode {
Quirks,
LimitedQuirks,
NoQuirks,
}
pub enum NodeOrText<Handle> {
AppendNode(Handle),
AppendText(StrTendril),
}
#[derive(PartialEq, Eq, Copy, Clone, Hash, Debug)]
pub enum NextParserState {
Suspend,
Continue,
}
pub trait TreeSink {
type Handle: Clone;
fn parse_error(&mut self, msg: Cow<'static, str>);
fn get_document(&mut self) -> Self::Handle;
fn same_node(&self, x: Self::Handle, y: Self::Handle) -> bool;
fn elem_name(&self, target: Self::Handle) -> QualName;
fn set_quirks_mode(&mut self, mode: QuirksMode);
fn create_element(&mut self, name: QualName, attrs: Vec<Attribute>) -> Self::Handle;
fn create_comment(&mut self, text: StrTendril) -> Self::Handle;
fn append(&mut self, parent: Self::Handle, child: NodeOrText<Self::Handle>);
fn append_before_sibling(&mut self,
sibling: Self::Handle,
new_node: NodeOrText<Self::Handle>) -> Result<(), NodeOrText<Self::Handle>>;
fn append_doctype_to_document(&mut self,
name: StrTendril,
public_id: StrTendril,
system_id: StrTendril);
fn add_attrs_if_missing(&mut self, target: Self::Handle, attrs: Vec<Attribute>);
fn remove_from_parent(&mut self, target: Self::Handle);
fn reparent_children(&mut self, node: Self::Handle, new_parent: Self::Handle);
fn mark_script_already_started(&mut self, node: Self::Handle);
fn complete_script(&mut self, _node: Self::Handle) -> NextParserState {
NextParserState::Continue
}
}
pub trait Tracer {
type Handle;
fn trace_handle(&self, node: Self::Handle);
}