Introduce abstraction over HTML and XML parsers for parser network listener.

This commit is contained in:
Josh Matthews 2015-12-02 02:45:52 -05:00
parent a840a23990
commit 9d3b915cac
5 changed files with 328 additions and 33 deletions

View file

@ -27,7 +27,7 @@ use dom::bindings::conversions::{FromJSValConvertible, StringificationBehavior};
use dom::bindings::global::GlobalRef;
use dom::bindings::inheritance::Castable;
use dom::bindings::js::{JS, RootCollection, trace_roots};
use dom::bindings::js::{Root, RootCollectionPtr, RootedReference};
use dom::bindings::js::{RootCollectionPtr, RootedReference};
use dom::bindings::refcounted::{LiveDOMReferences, Trusted, TrustedReference, trace_refcounted_objects};
use dom::bindings::trace::{JSTraceable, RootedVec, trace_traceables};
use dom::bindings::utils::{DOM_CALLBACKS, WRAP_CALLBACKS};
@ -36,7 +36,7 @@ use dom::element::Element;
use dom::event::{Event, EventBubbles, EventCancelable};
use dom::htmlanchorelement::HTMLAnchorElement;
use dom::node::{Node, NodeDamage, window_from_node};
use dom::servohtmlparser::{ParserContext, ServoHTMLParser};
use dom::servohtmlparser::{ParserContext, ParserRoot};
use dom::uievent::UIEvent;
use dom::window::{ReflowReason, ScriptHelpers, Window};
use dom::worker::TrustedWorkerAddress;
@ -595,7 +595,7 @@ pub unsafe extern "C" fn shadow_check_callback(_cx: *mut JSContext,
impl ScriptTask {
pub fn page_fetch_complete(id: PipelineId, subpage: Option<SubpageId>, metadata: Metadata)
-> Option<Root<ServoHTMLParser>> {
-> Option<ParserRoot> {
SCRIPT_TASK_ROOT.with(|root| {
let script_task = unsafe { &*root.borrow().unwrap() };
script_task.handle_page_fetch_complete(id, subpage, metadata)
@ -1451,7 +1451,7 @@ impl ScriptTask {
/// We have received notification that the response associated with a load has completed.
/// Kick off the document and frame tree creation process using the result.
fn handle_page_fetch_complete(&self, id: PipelineId, subpage: Option<SubpageId>,
metadata: Metadata) -> Option<Root<ServoHTMLParser>> {
metadata: Metadata) -> Option<ParserRoot> {
let idx = self.incomplete_loads.borrow().iter().position(|load| {
load.pipeline_id == id && load.parent_info.map(|info| info.1) == subpage
});
@ -1547,7 +1547,7 @@ impl ScriptTask {
/// The entry point to document loading. Defines bindings, sets up the window and document
/// objects, parses HTML and CSS, and kicks off initial layout.
fn load(&self, metadata: Metadata, incomplete: InProgressLoad) -> Root<ServoHTMLParser> {
fn load(&self, metadata: Metadata, incomplete: InProgressLoad) -> ParserRoot {
let final_url = metadata.final_url.clone();
debug!("ScriptTask: loading {} on page {:?}", incomplete.url.serialize(), incomplete.pipeline_id);