Skip to content

Commit 6e431bf

Browse files
committed
Cleanup
Signed-off-by: Nico Burns <[email protected]>
1 parent 845774c commit 6e431bf

File tree

1 file changed

+15
-96
lines changed

1 file changed

+15
-96
lines changed

html5ever/src/tree_builder/rules.rs

Lines changed: 15 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -36,112 +36,54 @@ fn current_node<Handle>(open_elems: &[Handle]) -> &Handle {
3636
open_elems.last().expect("no current element")
3737
}
3838

39+
#[rustfmt::skip]
3940
macro_rules! tag {
4041
// Any start tag
4142
(<>) => {
42-
crate::tokenizer::Tag {
43-
kind: crate::tokenizer::StartTag,
44-
..
45-
}
46-
};
47-
48-
// Any end tag
49-
(</>) => {
50-
crate::tokenizer::Tag {
51-
kind: crate::tokenizer::EndTag,
52-
..
53-
}
54-
};
55-
56-
// Named end tag
57-
(<$tag:tt>) => {
58-
crate::tokenizer::Tag {
59-
kind: crate::tokenizer::StartTag,
60-
name: local_name!($tag),
61-
..
62-
}
63-
};
64-
65-
// Named start tag
66-
(</$tag:tt>) => {
67-
crate::tokenizer::Tag {
68-
kind: crate::tokenizer::EndTag,
69-
name: local_name!($tag),
70-
..
71-
}
72-
};
73-
}
74-
75-
macro_rules! tags {
76-
// Any start tag
77-
(<>) => {
78-
tag!(<>)
43+
crate::tokenizer::Tag { kind: crate::tokenizer::StartTag, .. }
7944
};
8045
(<>|$($tail:tt)*) => {
81-
tag!(<>) | tags!($($tail)*)
46+
tag!(<>) | tag!($($tail)*)
8247
};
8348

8449
// Any end tag
8550
(</>) => {
86-
tag!(</>)
51+
crate::tokenizer::Tag { kind: crate::tokenizer::EndTag, .. }
8752
};
8853
(</>|$($tail:tt)*) => {
89-
tag!(</>) | tags!($($tail)*)
54+
tag!(</>) | tag!($($tail)*)
9055
};
9156

9257
// Named start tag
9358
(<$tag:tt>) => {
94-
tag!(<$tag>)
59+
crate::tokenizer::Tag { kind: crate::tokenizer::StartTag, name: local_name!($tag), .. }
9560
};
9661
(<$tag:tt>|$($tail:tt)*) => {
97-
tag!(<$tag>) | tags!($($tail)*)
62+
tag!(<$tag>) | tag!($($tail)*)
9863
};
9964

10065
// Named end tag
10166
(</$tag:tt>) => {
102-
tag!(</$tag>)
67+
crate::tokenizer::Tag { kind: crate::tokenizer::EndTag, name: local_name!($tag), .. }
10368
};
10469
(</$tag:tt>|$($tail:tt)*) => {
105-
tag!(</$tag>) | tags!($($tail)*)
70+
tag!(</$tag>) | tag!($($tail)*)
10671
};
10772
}
10873

10974
macro_rules! is_not_tag {
11075
($input:ident, $($tail:tt)*) => {
111-
!matches!($input, tags!($($tail)*))
76+
!matches!($input, tag!($($tail)*))
11277
};
11378
}
11479

80+
#[rustfmt::skip]
11581
macro_rules! tag_token {
11682
($id:ident @ $($tail:tt)*) => {
117-
crate::tree_builder::types::Token::Tag(
118-
$id @ ( tags!($($tail)*) )
119-
)
83+
crate::tree_builder::types::Token::Tag($id @ ( tag!($($tail)*) ) )
12084
};
12185
($($tail:tt)*) => {
122-
crate::tree_builder::types::Token::Tag(
123-
tags!($($tail)*)
124-
)
125-
};
126-
}
127-
128-
macro_rules! any_end_tag {
129-
() => {
130-
crate::tokenizer::Tag {
131-
kind: crate::tokenizer::EndTag,
132-
..
133-
}
134-
};
135-
}
136-
137-
macro_rules! any_end_tag_token {
138-
() => {
139-
any_end_tag_token!(_)
140-
};
141-
($tag:ident) => {
142-
crate::tree_builder::types::Token::Tag(
143-
$tag @ any_end_tag!()
144-
)
86+
crate::tree_builder::types::Token::Tag( tag!($($tail)*) )
14587
};
14688
}
14789

@@ -171,28 +113,6 @@ where
171113
},
172114
},
173115

174-
//§ the-before-html-insertion-mode
175-
// InsertionMode::BeforeHtml => match_token!(token {
176-
// Token::Characters(SplitStatus::NotSplit, text) => ProcessResult::SplitWhitespace(text),
177-
// Token::Characters(SplitStatus::Whitespace, _) => ProcessResult::Done,
178-
// Token::Comment(text) => self.append_comment_to_doc(text),
179-
180-
// tag @ <html> => {
181-
// self.create_root(tag.attrs);
182-
// self.mode.set(InsertionMode::BeforeHead);
183-
// ProcessResult::Done
184-
// }
185-
186-
// </head> </body> </html> </br> => else,
187-
188-
// tag @ </_> => self.unexpected(&tag),
189-
190-
// token => {
191-
// self.create_root(vec!());
192-
// ProcessResult::Reprocess(InsertionMode::BeforeHead, token)
193-
// }
194-
// }),
195-
196116
//§ the-before-html-insertion-mode
197117
InsertionMode::BeforeHtml => match token {
198118
Token::Characters(SplitStatus::NotSplit, text) => {
@@ -201,14 +121,13 @@ where
201121
Token::Characters(SplitStatus::Whitespace, _) => ProcessResult::Done,
202122
Token::Comment(text) => self.append_comment_to_doc(text),
203123

204-
// tag_token!(tag @ <"html"> | </"body">) => {
205-
Token::Tag(tag @ tags!(<html> | </body>)) => {
124+
Token::Tag(tag @ tag!(<html>)) => {
206125
self.create_root(tag.attrs);
207126
self.mode.set(InsertionMode::BeforeHead);
208127
ProcessResult::Done
209128
},
210129

211-
// any_end_tag_token!(tag) if !matches(tag, </"head"> | </"body"> | </"html"> | </"br">) => {
130+
// tag_token!(</>) if !matches(tag, </"head"> | </"body"> | </"html"> | </"br">) => {
212131
Token::Tag(tag @ tag!(</>)) if is_not_tag!(tag, </head> | </body> | </html> | </br>) => {
213132
self.unexpected(&tag)
214133
},

0 commit comments

Comments
 (0)