mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Upgrade to SM 39
This commit is contained in:
parent
a256f39796
commit
675267b782
205 changed files with 6546 additions and 5340 deletions
|
@ -10,7 +10,7 @@ use dom::bindings::cell::DOMRefCell;
|
|||
use dom::bindings::codegen::Bindings::ServoHTMLParserBinding;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::trace::JSTraceable;
|
||||
use dom::bindings::js::{JS, JSRef, Rootable, Temporary};
|
||||
use dom::bindings::js::{JS, Root};
|
||||
use dom::bindings::refcounted::Trusted;
|
||||
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
|
||||
use dom::document::{Document, DocumentHelpers};
|
||||
|
@ -28,7 +28,7 @@ use encoding::types::{Encoding, DecoderTrap};
|
|||
use std::cell::{Cell, RefCell};
|
||||
use std::default::Default;
|
||||
use url::Url;
|
||||
use js::jsapi::JSTracer;
|
||||
use js::jsapi::{JSTracer, JSObject};
|
||||
use html5ever::tokenizer;
|
||||
use html5ever::tree_builder;
|
||||
use html5ever::tree_builder::{TreeBuilder, TreeBuilderOpts};
|
||||
|
@ -46,8 +46,8 @@ pub struct Sink {
|
|||
/// into functions.
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct FragmentContext<'a> {
|
||||
pub context_elem: JSRef<'a, Node>,
|
||||
pub form_elem: Option<JSRef<'a, Node>>,
|
||||
pub context_elem: &'a Node,
|
||||
pub form_elem: Option<&'a Node>,
|
||||
}
|
||||
|
||||
pub type Tokenizer = tokenizer::Tokenizer<TreeBuilder<JS<Node>, Sink>>;
|
||||
|
@ -91,10 +91,10 @@ impl AsyncResponseListener for ParserContext {
|
|||
let parser = match parser {
|
||||
Some(parser) => parser,
|
||||
None => return,
|
||||
}.root();
|
||||
};
|
||||
|
||||
let parser = parser.r();
|
||||
let win = parser.window().root();
|
||||
let win = parser.window();
|
||||
*self.parser.borrow_mut() = Some(Trusted::new(win.r().get_cx(), parser,
|
||||
self.script_chan.clone()));
|
||||
|
||||
|
@ -128,18 +128,18 @@ impl AsyncResponseListener for ParserContext {
|
|||
// FIXME: use Vec<u8> (html5ever #34)
|
||||
let data = UTF_8.decode(&payload, DecoderTrap::Replace).unwrap();
|
||||
let parser = match self.parser.borrow().as_ref() {
|
||||
Some(parser) => parser.to_temporary(),
|
||||
Some(parser) => parser.root(),
|
||||
None => return,
|
||||
}.root();
|
||||
};
|
||||
parser.r().parse_chunk(data);
|
||||
}
|
||||
}
|
||||
|
||||
fn response_complete(&self, status: Result<(), String>) {
|
||||
let parser = match self.parser.borrow().as_ref() {
|
||||
Some(parser) => parser.to_temporary(),
|
||||
Some(parser) => parser.root(),
|
||||
None => return,
|
||||
}.root();
|
||||
};
|
||||
let doc = parser.r().document.root();
|
||||
doc.r().finish_load(LoadType::PageSource(self.url.clone()));
|
||||
|
||||
|
@ -176,7 +176,7 @@ pub struct ServoHTMLParser {
|
|||
pipeline: Option<PipelineId>,
|
||||
}
|
||||
|
||||
impl<'a> Parser for JSRef<'a, ServoHTMLParser> {
|
||||
impl<'a> Parser for &'a ServoHTMLParser {
|
||||
fn parse_chunk(self, input: String) {
|
||||
self.document.root().r().set_current_parser(Some(self));
|
||||
self.pending_input.borrow_mut().push(input);
|
||||
|
@ -201,12 +201,12 @@ impl<'a> Parser for JSRef<'a, ServoHTMLParser> {
|
|||
|
||||
impl ServoHTMLParser {
|
||||
#[allow(unrooted_must_root)]
|
||||
pub fn new(base_url: Option<Url>, document: JSRef<Document>, pipeline: Option<PipelineId>)
|
||||
-> Temporary<ServoHTMLParser> {
|
||||
let window = document.window().root();
|
||||
pub fn new(base_url: Option<Url>, document: &Document, pipeline: Option<PipelineId>)
|
||||
-> Root<ServoHTMLParser> {
|
||||
let window = document.window();
|
||||
let sink = Sink {
|
||||
base_url: base_url,
|
||||
document: JS::from_rooted(document),
|
||||
document: JS::from_ref(document),
|
||||
};
|
||||
|
||||
let tb = TreeBuilder::new(sink, TreeBuilderOpts {
|
||||
|
@ -220,7 +220,7 @@ impl ServoHTMLParser {
|
|||
reflector_: Reflector::new(),
|
||||
tokenizer: DOMRefCell::new(tok),
|
||||
pending_input: DOMRefCell::new(vec!()),
|
||||
document: JS::from_rooted(document),
|
||||
document: JS::from_ref(document),
|
||||
suspended: Cell::new(false),
|
||||
last_chunk_received: Cell::new(false),
|
||||
pipeline: pipeline,
|
||||
|
@ -231,12 +231,12 @@ impl ServoHTMLParser {
|
|||
}
|
||||
|
||||
#[allow(unrooted_must_root)]
|
||||
pub fn new_for_fragment(base_url: Option<Url>, document: JSRef<Document>,
|
||||
fragment_context: FragmentContext) -> Temporary<ServoHTMLParser> {
|
||||
let window = document.window().root();
|
||||
pub fn new_for_fragment(base_url: Option<Url>, document: &Document,
|
||||
fragment_context: FragmentContext) -> Root<ServoHTMLParser> {
|
||||
let window = document.window();
|
||||
let sink = Sink {
|
||||
base_url: base_url,
|
||||
document: JS::from_rooted(document),
|
||||
document: JS::from_ref(document),
|
||||
};
|
||||
|
||||
let tb_opts = TreeBuilderOpts {
|
||||
|
@ -244,8 +244,8 @@ impl ServoHTMLParser {
|
|||
.. Default::default()
|
||||
};
|
||||
let tb = TreeBuilder::new_for_fragment(sink,
|
||||
JS::from_rooted(fragment_context.context_elem),
|
||||
fragment_context.form_elem.map(|n| JS::from_rooted(n)),
|
||||
JS::from_ref(fragment_context.context_elem),
|
||||
fragment_context.form_elem.map(|n| JS::from_ref(n)),
|
||||
tb_opts);
|
||||
|
||||
let tok_opts = tokenizer::TokenizerOpts {
|
||||
|
@ -258,7 +258,7 @@ impl ServoHTMLParser {
|
|||
reflector_: Reflector::new(),
|
||||
tokenizer: DOMRefCell::new(tok),
|
||||
pending_input: DOMRefCell::new(vec!()),
|
||||
document: JS::from_rooted(document),
|
||||
document: JS::from_ref(document),
|
||||
suspended: Cell::new(false),
|
||||
last_chunk_received: Cell::new(true),
|
||||
pipeline: None,
|
||||
|
@ -278,6 +278,9 @@ impl Reflectable for ServoHTMLParser {
|
|||
fn reflector<'a>(&'a self) -> &'a Reflector {
|
||||
&self.reflector_
|
||||
}
|
||||
fn init_reflector(&mut self, obj: *mut JSObject) {
|
||||
self.reflector_.set_jsobject(obj);
|
||||
}
|
||||
}
|
||||
|
||||
trait PrivateServoHTMLParserHelpers {
|
||||
|
@ -285,10 +288,10 @@ trait PrivateServoHTMLParserHelpers {
|
|||
/// the tokenizer runs out of input.
|
||||
fn parse_sync(self);
|
||||
/// Retrieve the window object associated with this parser.
|
||||
fn window(self) -> Temporary<Window>;
|
||||
fn window(self) -> Root<Window>;
|
||||
}
|
||||
|
||||
impl<'a> PrivateServoHTMLParserHelpers for JSRef<'a, ServoHTMLParser> {
|
||||
impl<'a> PrivateServoHTMLParserHelpers for &'a ServoHTMLParser {
|
||||
fn parse_sync(self) {
|
||||
let mut first = true;
|
||||
|
||||
|
@ -322,7 +325,7 @@ impl<'a> PrivateServoHTMLParserHelpers for JSRef<'a, ServoHTMLParser> {
|
|||
}
|
||||
}
|
||||
|
||||
fn window(self) -> Temporary<Window> {
|
||||
fn window(self) -> Root<Window> {
|
||||
let doc = self.document.root();
|
||||
window_from_node(doc.r())
|
||||
}
|
||||
|
@ -337,7 +340,7 @@ pub trait ServoHTMLParserHelpers {
|
|||
fn resume(self);
|
||||
}
|
||||
|
||||
impl<'a> ServoHTMLParserHelpers for JSRef<'a, ServoHTMLParser> {
|
||||
impl<'a> ServoHTMLParserHelpers for &'a ServoHTMLParser {
|
||||
fn suspend(self) {
|
||||
assert!(!self.suspended.get());
|
||||
self.suspended.set(true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue