mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Support HTML parser reentrancy (#32820)
* Update parser interface for reentrancy. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Remove assertions around invoking scripts with active parser. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Add regression test. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Run test with normal and async html parser. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
d44c0f7e5d
commit
4df7a1af25
13 changed files with 248 additions and 211 deletions
|
@ -4,6 +4,8 @@
|
|||
|
||||
#![allow(crown::unrooted_must_root)]
|
||||
|
||||
use std::cell::Cell;
|
||||
|
||||
use html5ever::tokenizer::TokenizerResult;
|
||||
use js::jsapi::JSTracer;
|
||||
use servo_url::ServoUrl;
|
||||
|
@ -30,7 +32,7 @@ impl Tokenizer {
|
|||
let sink = Sink {
|
||||
base_url: url,
|
||||
document: Dom::from_ref(document),
|
||||
current_line: 1,
|
||||
current_line: Cell::new(1),
|
||||
script: Default::default(),
|
||||
parsing_algorithm: ParsingAlgorithm::Normal,
|
||||
};
|
||||
|
@ -41,7 +43,7 @@ impl Tokenizer {
|
|||
Tokenizer { inner: tok }
|
||||
}
|
||||
|
||||
pub fn feed(&mut self, input: &mut BufferQueue) -> TokenizerResult<DomRoot<HTMLScriptElement>> {
|
||||
pub fn feed(&self, input: &BufferQueue) -> TokenizerResult<DomRoot<HTMLScriptElement>> {
|
||||
self.inner.run(input);
|
||||
match self.inner.sink.sink.script.take() {
|
||||
Some(script) => TokenizerResult::Script(script),
|
||||
|
@ -49,7 +51,7 @@ impl Tokenizer {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn end(&mut self) {
|
||||
pub fn end(&self) {
|
||||
self.inner.end()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue