summaryrefslogtreecommitdiff
path: root/src/tokenizer
diff options
context:
space:
mode:
Diffstat (limited to 'src/tokenizer')
-rw-r--r--src/tokenizer/interface.rs5
-rw-r--r--src/tokenizer/mod.rs20
2 files changed, 9 insertions, 16 deletions
diff --git a/src/tokenizer/interface.rs b/src/tokenizer/interface.rs
index ebb8569..c331a0e 100644
--- a/src/tokenizer/interface.rs
+++ b/src/tokenizer/interface.rs
@@ -9,7 +9,6 @@
use tendril::StrTendril;
use crate::tokenizer::states;
-use markup5ever::{LocalName, QualName};
use std::borrow::Cow;
pub use self::TagKind::{EndTag, StartTag};
@@ -52,7 +51,7 @@ pub enum TagKind {
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Debug)]
pub struct Attribute {
/// The name of the attribute (e.g. the `class` in `<div class="test">`)
- pub name: QualName,
+ pub name: StrTendril,
/// The value of the attribute (e.g. the `"test"` in `<div class="test">`)
pub value: StrTendril,
}
@@ -61,7 +60,7 @@ pub struct Attribute {
#[derive(PartialEq, Eq, Clone, Debug)]
pub struct Tag {
pub kind: TagKind,
- pub name: LocalName,
+ pub name: StrTendril,
pub self_closing: bool,
pub attrs: Vec<Attribute>,
}
diff --git a/src/tokenizer/mod.rs b/src/tokenizer/mod.rs
index c6f7276..f45c917 100644
--- a/src/tokenizer/mod.rs
+++ b/src/tokenizer/mod.rs
@@ -25,7 +25,6 @@ use crate::util::{smallcharset::SmallCharSet, str::lower_ascii_letter};
use log::debug;
use mac::{_tt_as_expr_hack, format_if, matches};
-use markup5ever::{namespace_url, ns};
use std::borrow::Cow::{self, Borrowed};
use std::collections::BTreeMap;
use std::default::Default;
@@ -33,7 +32,6 @@ use std::mem::replace;
pub use crate::util::buffer_queue::{BufferQueue, FromSet, NotFromSet, SetResult};
use tendril::StrTendril;
-use markup5ever::{LocalName, QualName};
mod char_ref;
mod interface;
@@ -155,7 +153,7 @@ pub struct Tokenizer<Sink> {
current_doctype: Doctype,
/// Last start tag name, for use in checking "appropriate end tag".
- last_start_tag_name: Option<LocalName>,
+ last_start_tag_name: Option<StrTendril>,
/// The "temporary buffer" mentioned in the spec.
temp_buf: StrTendril,
@@ -176,7 +174,7 @@ impl<Sink: TokenSink> Tokenizer<Sink> {
let start_tag_name = opts
.last_start_tag_name
.take()
- .map(|s| LocalName::from(&*s));
+ .map(|s| StrTendril::from(s));
let state = opts.initial_state.unwrap_or(states::Data);
let discard_bom = opts.discard_bom;
Tokenizer {
@@ -412,7 +410,7 @@ impl<Sink: TokenSink> Tokenizer<Sink> {
fn emit_current_tag(&mut self) -> ProcessResult<Sink::Handle> {
self.finish_attribute();
- let name = LocalName::from(&*self.current_tag_name);
+ let name = self.current_tag_name.clone();
self.current_tag_name.clear();
match self.current_tag_kind {
@@ -506,7 +504,7 @@ impl<Sink: TokenSink> Tokenizer<Sink> {
let name = &*self.current_attr_name;
self.current_tag_attrs
.iter()
- .any(|a| &*a.name.local == name)
+ .any(|a| &*a.name == name)
};
if dup {
@@ -514,12 +512,10 @@ impl<Sink: TokenSink> Tokenizer<Sink> {
self.current_attr_name.clear();
self.current_attr_value.clear();
} else {
- let name = LocalName::from(&*self.current_attr_name);
+ let name = self.current_attr_name.clone();
self.current_attr_name.clear();
self.current_tag_attrs.push(Attribute {
- // The tree builder will adjust the namespace if necessary.
- // This only happens in foreign elements.
- name: QualName::new(None, ns!(), name),
+ name: name,
value: replace(&mut self.current_attr_value, StrTendril::new()),
});
}
@@ -1538,8 +1534,6 @@ mod test {
use crate::util::buffer_queue::BufferQueue;
use std::mem::replace;
- use markup5ever::LocalName;
-
// LinesMatch implements the TokenSink trait. It is used for testing to see
// if current_line is being updated when process_token is called. The lines
// vector is a collection of the line numbers that each token is on.
@@ -1630,7 +1624,7 @@ mod test {
// Create a tag token
fn create_tag(token: StrTendril, tagkind: TagKind) -> Token {
- let name = LocalName::from(&*token);
+ let name = token;
let token = TagToken(Tag {
kind: tagkind,
name,