use crate::Tag;
use super::{Builder, Mode, Next, is_ws};
impl<'a> Builder<'a> {
pub(super) fn in_head_noscript(&self) -> bool {
!self.scripting && self.mode == Mode::InHead && self.current_is(Tag::Noscript)
}
pub(super) fn head_noscript_start(&mut self, tag: Tag, name: (usize, usize)) -> Option<Next> {
use Tag::*;
match tag {
Html => {
self.merge_attrs(self.html);
Some(Next::Data)
}
Basefont | Bgsound | Link | Meta | Noframes | Style => self.head_element(tag, name),
Head | Noscript => {
self.scratch.clear();
Some(Next::Data)
}
_ => {
self.pop();
None
}
}
}
pub(super) fn head_noscript_end(&mut self, tag: Tag) -> bool {
match tag {
Tag::Noscript => {
self.pop();
true
}
Tag::Br => {
self.pop();
false
}
_ => true,
}
}
pub(super) fn head_noscript_text(&mut self, s: usize, e: usize) -> usize {
let lead = self.src.as_bytes()[s..e]
.iter()
.take_while(|&&c| is_ws(c))
.count();
if lead > 0 {
self.add_text(crate::dom::Span::source(s, s + lead), false);
}
if s + lead < e {
self.pop();
}
s + lead
}
}