Introduce GlobalScope::pipeline_id

This commit is contained in:
Anthony Ramine 2016-10-01 17:24:54 +02:00
parent c6ff767625
commit 27f100b1d4
21 changed files with 103 additions and 85 deletions

View file

@ -23,7 +23,6 @@ use js::jsapi::{HandleValue, JS_GetClass, JSAutoCompartment, JSContext};
use js::jsapi::{JSObject, MutableHandleValue};
use js::rust::CompileOptionsWrapper;
use libc;
use msg::constellation_msg::PipelineId;
use net_traits::{CoreResourceThread, IpcSend, ResourceThreads};
use profile_traits::time;
use script_runtime::{CommonScriptMsg, EnqueuedPromiseCallback, ScriptChan};
@ -80,14 +79,6 @@ impl<'a> GlobalRef<'a> {
}
}
/// Get the `PipelineId` for this global scope.
pub fn pipeline_id(&self) -> PipelineId {
match *self {
GlobalRef::Window(window) => window.pipeline_id(),
GlobalRef::Worker(worker) => worker.pipeline_id(),
}
}
/// Get the `ResourceThreads` for this global scope.
pub fn resource_threads(&self) -> ResourceThreads {
match *self {

View file

@ -4,6 +4,7 @@
use dom::bindings::cell::DOMRefCell;
use dom::bindings::conversions::{ToJSValConvertible, root_from_handleobject};
use dom::bindings::inheritance::Castable;
use dom::bindings::js::{JS, MutNullableHeap, Root, RootedReference};
use dom::bindings::proxyhandler::{fill_property_descriptor, get_property_descriptor};
use dom::bindings::reflector::{Reflectable, MutReflectable, Reflector};
@ -12,6 +13,7 @@ use dom::bindings::utils::WindowProxyHandler;
use dom::bindings::utils::get_array_index_from_id;
use dom::document::Document;
use dom::element::Element;
use dom::globalscope::GlobalScope;
use dom::window::Window;
use js::JSCLASS_IS_GLOBAL;
use js::glue::{CreateWrapperProxyHandler, ProxyTraps, NewWindowProxy};
@ -150,7 +152,7 @@ impl BrowsingContext {
pub fn find_child_by_id(&self, pipeline_id: PipelineId) -> Option<Root<Window>> {
self.children.borrow().iter().find(|context| {
let window = context.active_window();
window.pipeline_id() == pipeline_id
window.upcast::<GlobalScope>().pipeline_id() == pipeline_id
}).map(|context| context.active_window())
}

View file

@ -11,7 +11,8 @@ pub struct Console(());
impl Console {
fn send_to_devtools(global: GlobalRef, level: LogLevel, message: DOMString) {
if let Some(chan) = global.as_global_scope().devtools_chan() {
let global_scope = global.as_global_scope();
if let Some(chan) = global_scope.devtools_chan() {
let console_message = prepare_message(level, message);
let worker_id = if let GlobalRef::Worker(worker) = global {
Some(worker.get_worker_id())
@ -19,7 +20,7 @@ impl Console {
None
};
let devtools_message = ScriptToDevtoolsControlMsg::ConsoleAPI(
global.pipeline_id(),
global_scope.pipeline_id(),
console_message,
worker_id);
chan.send(devtools_message).unwrap();

View file

@ -651,8 +651,9 @@ impl Document {
// Update the focus state for all elements in the focus chain.
// https://html.spec.whatwg.org/multipage/#focus-chain
if focus_type == FocusType::Element {
let event = ConstellationMsg::Focus(self.window.pipeline_id());
self.window.upcast::<GlobalScope>().constellation_chan().send(event).unwrap();
let global_scope = self.window.upcast::<GlobalScope>();
let event = ConstellationMsg::Focus(global_scope.pipeline_id());
global_scope.constellation_chan().send(event).unwrap();
}
}
}
@ -670,9 +671,10 @@ impl Document {
/// Sends this document's title to the compositor.
pub fn send_title_to_compositor(&self) {
let window = self.window();
window.upcast::<GlobalScope>()
let global_scope = window.upcast::<GlobalScope>();
global_scope
.constellation_chan()
.send(ConstellationMsg::SetTitle(window.pipeline_id(),
.send(ConstellationMsg::SetTitle(global_scope.pipeline_id(),
Some(String::from(self.Title()))))
.unwrap();
}
@ -1358,10 +1360,11 @@ impl Document {
pub fn trigger_mozbrowser_event(&self, event: MozBrowserEvent) {
if PREFS.is_mozbrowser_enabled() {
if let Some((parent_pipeline_id, _)) = self.window.parent_info() {
let global_scope = self.window.upcast::<GlobalScope>();
let event = ConstellationMsg::MozBrowserEvent(parent_pipeline_id,
Some(self.window.pipeline_id()),
Some(global_scope.pipeline_id()),
event);
self.window.upcast::<GlobalScope>().constellation_chan().send(event).unwrap();
global_scope.constellation_chan().send(event).unwrap();
}
}
}
@ -1381,10 +1384,11 @@ impl Document {
//
// TODO: Should tick animation only when document is visible
if !self.running_animation_callbacks.get() {
let global_scope = self.window.upcast::<GlobalScope>();
let event = ConstellationMsg::ChangeRunningAnimationsState(
self.window.pipeline_id(),
global_scope.pipeline_id(),
AnimationState::AnimationCallbacksPresent);
self.window.upcast::<GlobalScope>().constellation_chan().send(event).unwrap();
global_scope.constellation_chan().send(event).unwrap();
}
ident
@ -1420,9 +1424,10 @@ impl Document {
if self.animation_frame_list.borrow().is_empty() {
mem::swap(&mut *self.animation_frame_list.borrow_mut(),
&mut animation_frame_list);
let event = ConstellationMsg::ChangeRunningAnimationsState(self.window.pipeline_id(),
let global_scope = self.window.upcast::<GlobalScope>();
let event = ConstellationMsg::ChangeRunningAnimationsState(global_scope.pipeline_id(),
AnimationState::NoAnimationCallbacksPresent);
self.window.upcast::<GlobalScope>().constellation_chan().send(event).unwrap();
global_scope.constellation_chan().send(event).unwrap();
}
self.running_animation_callbacks.set(false);
@ -1480,7 +1485,8 @@ impl Document {
let loader = self.loader.borrow();
if !loader.is_blocked() && !loader.events_inhibited() {
let win = self.window();
let msg = MainThreadScriptMsg::DocumentLoadsComplete(win.pipeline_id());
let msg = MainThreadScriptMsg::DocumentLoadsComplete(
win.upcast::<GlobalScope>().pipeline_id());
win.main_thread_script_chan().send(msg).unwrap();
}
}
@ -1578,9 +1584,10 @@ impl Document {
}
pub fn notify_constellation_load(&self) {
let pipeline_id = self.window.pipeline_id();
let global_scope = self.window.upcast::<GlobalScope>();
let pipeline_id = global_scope.pipeline_id();
let load_event = ConstellationMsg::LoadComplete(pipeline_id);
self.window.upcast::<GlobalScope>().constellation_chan().send(load_event).unwrap();
global_scope.constellation_chan().send(load_event).unwrap();
}
pub fn set_current_parser(&self, script: Option<ParserRef>) {

View file

@ -11,6 +11,7 @@ use dom::crypto::Crypto;
use dom::eventtarget::EventTarget;
use ipc_channel::ipc::IpcSender;
use js::jsapi::{JS_GetContext, JS_GetObjectRuntime, JSContext};
use msg::constellation_msg::PipelineId;
use profile_traits::{mem, time};
use script_traits::{ScriptMsg as ConstellationMsg, TimerEventRequest};
use std::cell::Cell;
@ -24,6 +25,9 @@ pub struct GlobalScope {
crypto: MutNullableHeap<JS<Crypto>>,
next_worker_id: Cell<WorkerId>,
/// Pipeline id associated with this global.
pipeline_id: PipelineId,
/// A flag to indicate whether the developer tools has requested
/// live updates from the worker.
devtools_wants_updates: Cell<bool>,
@ -53,6 +57,7 @@ pub struct GlobalScope {
impl GlobalScope {
pub fn new_inherited(
pipeline_id: PipelineId,
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
mem_profiler_chan: mem::ProfilerChan,
time_profiler_chan: time::ProfilerChan,
@ -63,6 +68,7 @@ impl GlobalScope {
eventtarget: EventTarget::new_inherited(),
crypto: Default::default(),
next_worker_id: Cell::new(WorkerId(0)),
pipeline_id: pipeline_id,
devtools_wants_updates: Default::default(),
console_timers: DOMRefCell::new(Default::default()),
devtools_chan: devtools_chan,
@ -149,6 +155,11 @@ impl GlobalScope {
pub fn scheduler_chan(&self) -> &IpcSender<TimerEventRequest> {
&self.scheduler_chan
}
/// Get the `PipelineId` for this global scope.
pub fn pipeline_id(&self) -> PipelineId {
self.pipeline_id
}
}
fn timestamp_in_ms(time: Timespec) -> u64 {

View file

@ -39,19 +39,21 @@ impl History {
impl History {
fn traverse_history(&self, direction: TraversalDirection) {
let pipeline = self.window.pipeline_id();
let global_scope = self.window.upcast::<GlobalScope>();
let pipeline = global_scope.pipeline_id();
let msg = ConstellationMsg::TraverseHistory(Some(pipeline), direction);
let _ = self.window.upcast::<GlobalScope>().constellation_chan().send(msg);
let _ = global_scope.constellation_chan().send(msg);
}
}
impl HistoryMethods for History {
// https://html.spec.whatwg.org/multipage/#dom-history-length
fn Length(&self) -> u32 {
let pipeline = self.window.pipeline_id();
let global_scope = self.window.upcast::<GlobalScope>();
let pipeline = global_scope.pipeline_id();
let (sender, recv) = ipc::channel().expect("Failed to create channel to send jsh length.");
let msg = ConstellationMsg::JointSessionHistoryLength(pipeline, sender);
let _ = self.window.upcast::<GlobalScope>().constellation_chan().send(msg);
let _ = global_scope.constellation_chan().send(msg);
recv.recv().unwrap()
}

View file

@ -24,6 +24,7 @@ use dom::element::Element;
use dom::event::{EventBubbles, EventCancelable};
use dom::eventtarget::EventTarget;
use dom::file::File;
use dom::globalscope::GlobalScope;
use dom::htmlbuttonelement::HTMLButtonElement;
use dom::htmlcollection::CollectionFilter;
use dom::htmldatalistelement::HTMLDataListElement;
@ -436,7 +437,7 @@ impl HTMLFormElement {
// Step 2
let nav = box PlannedNavigation {
load_data: load_data,
pipeline_id: window.pipeline_id(),
pipeline_id: window.upcast::<GlobalScope>().pipeline_id(),
script_chan: window.main_thread_script_chan().clone(),
generation_id: self.generation_id.get(),
form: Trusted::new(self)

View file

@ -126,9 +126,10 @@ impl HTMLIFrameElement {
let private_iframe = self.privatebrowsing();
let frame_type = if self.Mozbrowser() { FrameType::MozBrowserIFrame } else { FrameType::IFrame };
let global_scope = window.upcast::<GlobalScope>();
let load_info = IFrameLoadInfo {
load_data: load_data,
parent_pipeline_id: window.pipeline_id(),
parent_pipeline_id: global_scope.pipeline_id(),
old_pipeline_id: old_pipeline_id,
new_pipeline_id: new_pipeline_id,
sandbox: sandboxed,
@ -136,7 +137,7 @@ impl HTMLIFrameElement {
frame_type: frame_type,
replace: replace,
};
window.upcast::<GlobalScope>()
global_scope
.constellation_chan()
.send(ConstellationMsg::ScriptLoadedURLInIFrame(load_info))
.unwrap();

View file

@ -267,7 +267,7 @@ impl HTMLLinkElement {
credentials_mode: CredentialsMode::Include,
use_url_credentials: true,
origin: document.url().clone(),
pipeline_id: Some(self.global().r().pipeline_id()),
pipeline_id: Some(self.global().r().as_global_scope().pipeline_id()),
referrer_url: Some(document.url().clone()),
referrer_policy: referrer_policy,
.. RequestInit::default()

View file

@ -242,7 +242,7 @@ fn fetch_a_classic_script(script: &HTMLScriptElement,
_ => CredentialsMode::Include,
},
origin: doc.url().clone(),
pipeline_id: Some(script.global().r().pipeline_id()),
pipeline_id: Some(script.global().r().as_global_scope().pipeline_id()),
referrer_url: Some(doc.url().clone()),
referrer_policy: doc.get_referrer_policy(),
.. RequestInit::default()

View file

@ -451,7 +451,7 @@ fn net_request_from_global(global: GlobalRef,
url: Url,
is_service_worker_global_scope: bool) -> NetTraitsRequest {
let origin = Origin::Origin(global.get_url().origin());
let pipeline_id = global.pipeline_id();
let pipeline_id = global.as_global_scope().pipeline_id();
NetTraitsRequest::new(url,
Some(origin),
is_service_worker_global_scope,

View file

@ -95,11 +95,14 @@ impl ServiceWorkerContainerMethods for ServiceWorkerContainer {
return Err(Error::Type("Scope URL contains forbidden characters".to_owned()));
}
let worker_registration = ServiceWorkerRegistration::new(self.global().r().as_global_scope(),
let global = self.global();
let global = global.r();
let global_scope = global.as_global_scope();
let worker_registration = ServiceWorkerRegistration::new(global_scope,
script_url,
scope.clone(),
self);
ScriptThread::set_registration(scope, &*worker_registration, self.global().r().pipeline_id());
ScriptThread::set_registration(scope, &*worker_registration, global_scope.pipeline_id());
Ok(worker_registration)
}
}

View file

@ -51,13 +51,13 @@ impl ServiceWorkerRegistration {
}
pub fn create_scope_things(global: GlobalRef, script_url: Url) -> ScopeThings {
let global_scope = global.as_global_scope();
let worker_load_origin = WorkerScriptLoadOrigin {
referrer_url: None,
referrer_policy: None,
pipeline_id: Some(global.pipeline_id())
pipeline_id: Some(global_scope.pipeline_id())
};
let global_scope = global.as_global_scope();
let worker_id = global_scope.get_next_worker_id();
let devtools_chan = global_scope.devtools_chan().cloned();
let init = prepare_workerscope_init(global, None);

View file

@ -206,7 +206,7 @@ impl Runnable for StorageEventRunnable {
assert!(UrlHelper::SameOrigin(&ev_url, &it_window.get_url()));
// TODO: Such a Document object is not necessarily fully active, but events fired on such
// objects are ignored by the event loop until the Document becomes fully active again.
if ev_window.pipeline_id() != it_window.pipeline_id() {
if ev_window.upcast::<GlobalScope>().pipeline_id() != it_window.upcast::<GlobalScope>().pipeline_id() {
storage_event.upcast::<Event>().fire(it_window.upcast());
}
}

View file

@ -181,9 +181,6 @@ pub struct Window {
/// Pending resize event, if any.
resize_event: Cell<Option<(WindowSizeData, WindowSizeType)>>,
/// Pipeline id associated with this page.
id: PipelineId,
/// Parent id associated with this page, if any.
parent_info: Option<(PipelineId, FrameType)>,
@ -293,10 +290,6 @@ impl Window {
self.image_cache_chan.clone()
}
pub fn pipeline_id(&self) -> PipelineId {
self.id
}
pub fn parent_info(&self) -> Option<(PipelineId, FrameType)> {
self.parent_info
}
@ -430,9 +423,10 @@ impl WindowMethods for Window {
}
let (sender, receiver) = ipc::channel().unwrap();
self.upcast::<GlobalScope>()
let global_scope = self.upcast::<GlobalScope>();
global_scope
.constellation_chan()
.send(ConstellationMsg::Alert(self.pipeline_id(), s.to_string(), sender))
.send(ConstellationMsg::Alert(global_scope.pipeline_id(), s.to_string(), sender))
.unwrap();
let should_display_alert_dialog = receiver.recv().unwrap();
@ -443,7 +437,9 @@ impl WindowMethods for Window {
// https://html.spec.whatwg.org/multipage/#dom-window-close
fn Close(&self) {
self.main_thread_script_chan().send(MainThreadScriptMsg::ExitWindow(self.id.clone())).unwrap();
self.main_thread_script_chan()
.send(MainThreadScriptMsg::ExitWindow(self.upcast::<GlobalScope>().pipeline_id()))
.unwrap();
}
// https://html.spec.whatwg.org/multipage/#dom-document-2
@ -493,7 +489,7 @@ impl WindowMethods for Window {
args,
timeout,
IsInterval::NonInterval,
TimerSource::FromWindow(self.id.clone()))
TimerSource::FromWindow(self.upcast::<GlobalScope>().pipeline_id()))
}
// https://html.spec.whatwg.org/multipage/#dom-windowtimers-settimeout
@ -503,7 +499,7 @@ impl WindowMethods for Window {
args,
timeout,
IsInterval::NonInterval,
TimerSource::FromWindow(self.id.clone()))
TimerSource::FromWindow(self.upcast::<GlobalScope>().pipeline_id()))
}
// https://html.spec.whatwg.org/multipage/#dom-windowtimers-cleartimeout
@ -518,7 +514,7 @@ impl WindowMethods for Window {
args,
timeout,
IsInterval::Interval,
TimerSource::FromWindow(self.id.clone()))
TimerSource::FromWindow(self.upcast::<GlobalScope>().pipeline_id()))
}
// https://html.spec.whatwg.org/multipage/#dom-windowtimers-setinterval
@ -528,7 +524,7 @@ impl WindowMethods for Window {
args,
timeout,
IsInterval::Interval,
TimerSource::FromWindow(self.id.clone()))
TimerSource::FromWindow(self.upcast::<GlobalScope>().pipeline_id()))
}
// https://html.spec.whatwg.org/multipage/#dom-windowtimers-clearinterval
@ -976,8 +972,10 @@ impl Window {
// TODO (farodin91): Raise an event to stop the current_viewport
self.update_viewport_for_scroll(x, y);
let message = ConstellationMsg::ScrollFragmentPoint(self.pipeline_id(), layer_id, point, smooth);
self.upcast::<GlobalScope>().constellation_chan().send(message).unwrap();
let global_scope = self.upcast::<GlobalScope>();
let message = ConstellationMsg::ScrollFragmentPoint(
global_scope.pipeline_id(), layer_id, point, smooth);
global_scope.constellation_chan().send(message).unwrap();
}
pub fn update_viewport_for_scroll(&self, x: f32, y: f32) {
@ -1032,7 +1030,7 @@ impl Window {
let for_display = query_type == ReflowQueryType::NoQuery;
if for_display && self.suppress_reflow.get() {
debug!("Suppressing reflow pipeline {} for goal {:?} reason {:?} before FirstLoad or RefreshTick",
self.id, goal, reason);
self.upcast::<GlobalScope>().pipeline_id(), goal, reason);
return false;
}
@ -1049,7 +1047,7 @@ impl Window {
// On debug mode, print the reflow event information.
if opts::get().relayout_event {
debug_reflow_events(self.id, &goal, &query_type, &reason);
debug_reflow_events(self.upcast::<GlobalScope>().pipeline_id(), &goal, &query_type, &reason);
}
let document = self.Document();
@ -1154,8 +1152,9 @@ impl Window {
let ready_state = document.ReadyState();
if ready_state == DocumentReadyState::Complete && !reftest_wait {
let event = ConstellationMsg::SetDocumentState(self.id, DocumentState::Idle);
self.upcast::<GlobalScope>().constellation_chan().send(event).unwrap();
let global_scope = self.upcast::<GlobalScope>();
let event = ConstellationMsg::SetDocumentState(global_scope.pipeline_id(), DocumentState::Idle);
global_scope.constellation_chan().send(event).unwrap();
}
}
@ -1264,12 +1263,12 @@ impl Window {
}
let layer_id = self.layout_rpc.node_layer_id().layer_id;
let pipeline_id = self.id;
let (send, recv) = ipc::channel::<Point2D<f32>>().unwrap();
self.upcast::<GlobalScope>()
let global_scope = self.upcast::<GlobalScope>();
global_scope
.constellation_chan()
.send(ConstellationMsg::GetScrollOffset(pipeline_id, layer_id, send))
.send(ConstellationMsg::GetScrollOffset(global_scope.pipeline_id(), layer_id, send))
.unwrap();
recv.recv().unwrap_or(Point2D::zero())
}
@ -1345,7 +1344,7 @@ impl Window {
let referrer_policy = referrer_policy.or(doc.get_referrer_policy());
self.main_thread_script_chan().send(
MainThreadScriptMsg::Navigate(self.id,
MainThreadScriptMsg::Navigate(self.upcast::<GlobalScope>().pipeline_id(),
LoadData::new(url, referrer_policy, Some(doc.url().clone())),
replace)).unwrap();
}
@ -1388,7 +1387,7 @@ impl Window {
pub fn schedule_callback(&self, callback: OneshotTimerCallback, duration: MsDuration) -> OneshotTimerHandle {
self.timers.schedule_callback(callback,
duration,
TimerSource::FromWindow(self.id.clone()))
TimerSource::FromWindow(self.upcast::<GlobalScope>().pipeline_id()))
}
pub fn unschedule_callback(&self, handle: OneshotTimerHandle) {
@ -1588,6 +1587,7 @@ impl Window {
let win = box Window {
globalscope:
GlobalScope::new_inherited(
id,
devtools_chan,
mem_profiler_chan,
time_profiler_chan,
@ -1612,7 +1612,6 @@ impl Window {
local_storage: Default::default(),
status: DOMRefCell::new(DOMString::new()),
timers: OneshotTimers::new(timer_event_chan, scheduler_chan),
id: id,
parent_info: parent_info,
dom_static: GlobalStaticData::new(),
js_runtime: DOMRefCell::new(Some(runtime.clone())),

View file

@ -84,17 +84,17 @@ impl Worker {
let worker = Worker::new(global.as_global_scope(), sender.clone(), closing.clone());
let worker_ref = Trusted::new(worker.r());
let global_scope = global.as_global_scope();
let worker_load_origin = WorkerScriptLoadOrigin {
referrer_url: None,
referrer_policy: None,
pipeline_id: Some(global.pipeline_id()),
pipeline_id: Some(global_scope.pipeline_id()),
};
let (devtools_sender, devtools_receiver) = ipc::channel().unwrap();
let global_scope = global.as_global_scope();
let worker_id = global_scope.get_next_worker_id();
if let Some(ref chan) = global_scope.devtools_chan() {
let pipeline_id = global.pipeline_id();
let pipeline_id = global_scope.pipeline_id();
let title = format!("Worker for {}", worker_url);
let page_info = DevtoolsPageInfo {
title: title,

View file

@ -60,6 +60,7 @@ pub fn prepare_workerscope_init(global: GlobalRef,
let time_profiler_chan = global_scope.time_profiler_chan().clone();
let constellation_chan = global_scope.constellation_chan().clone();
let scheduler_chan = global_scope.scheduler_chan().clone();
let pipeline_id = global_scope.pipeline_id();
let init = WorkerGlobalScopeInit {
resource_threads: global.resource_threads(),
mem_profiler_chan: mem_profiler_chan,
@ -69,7 +70,7 @@ pub fn prepare_workerscope_init(global: GlobalRef,
constellation_chan: constellation_chan,
scheduler_chan: scheduler_chan,
worker_id: worker_id,
pipeline_id: global.pipeline_id(),
pipeline_id: pipeline_id,
};
init
@ -81,7 +82,6 @@ pub struct WorkerGlobalScope {
globalscope: GlobalScope,
worker_id: WorkerId,
pipeline_id: PipelineId,
worker_url: Url,
#[ignore_heap_size_of = "Arc"]
closing: Option<Arc<AtomicBool>>,
@ -120,13 +120,13 @@ impl WorkerGlobalScope {
WorkerGlobalScope {
globalscope:
GlobalScope::new_inherited(
init.pipeline_id,
init.to_devtools_sender,
init.mem_profiler_chan,
init.time_profiler_chan,
init.constellation_chan,
init.scheduler_chan.clone()),
worker_id: init.worker_id,
pipeline_id: init.pipeline_id,
worker_url: worker_url,
closing: closing,
runtime: runtime,
@ -207,7 +207,7 @@ impl WorkerGlobalScope {
fn do_flush_promise_jobs(&self) {
self.promise_job_queue.flush_promise_jobs(|id| {
assert_eq!(self.pipeline_id(), id);
assert_eq!(self.upcast::<GlobalScope>().pipeline_id(), id);
Some(GlobalRoot::Worker(Root::from_ref(self)))
});
}
@ -221,7 +221,7 @@ impl LoadOrigin for WorkerGlobalScope {
None
}
fn pipeline_id(&self) -> Option<PipelineId> {
Some(self.pipeline_id())
Some(self.upcast::<GlobalScope>().pipeline_id())
}
}
@ -401,10 +401,6 @@ impl WorkerGlobalScope {
FileReadingTaskSource(self.script_chan())
}
pub fn pipeline_id(&self) -> PipelineId {
self.pipeline_id
}
pub fn new_script_pair(&self) -> (Box<ScriptChan + Send>, Box<ScriptPort + Send>) {
let dedicated = self.downcast::<DedicatedWorkerGlobalScope>();
if let Some(dedicated) = dedicated {

View file

@ -284,7 +284,7 @@ impl LoadOrigin for XMLHttpRequest {
fn pipeline_id(&self) -> Option<PipelineId> {
let global = self.global();
Some(global.r().pipeline_id())
Some(global.r().as_global_scope().pipeline_id())
}
}
@ -1208,7 +1208,10 @@ impl XMLHttpRequest {
let decoded = charset.decode(&self.response.borrow(), DecoderTrap::Replace).unwrap();
let document = self.new_doc(IsHTMLDocument::HTMLDocument);
// TODO: Disable scripting while parsing
parse_html(document.r(), DOMString::from(decoded), wr.get_url(), ParseContext::Owner(Some(wr.pipeline_id())));
parse_html(document.r(),
DOMString::from(decoded),
wr.get_url(),
ParseContext::Owner(Some(wr.as_global_scope().pipeline_id())));
document
}
@ -1222,7 +1225,7 @@ impl XMLHttpRequest {
parse_xml(document.r(),
DOMString::from(decoded),
wr.get_url(),
xml::ParseContext::Owner(Some(wr.pipeline_id())));
xml::ParseContext::Owner(Some(wr.as_global_scope().pipeline_id())));
document
}

View file

@ -178,7 +178,7 @@ unsafe extern "C" fn enqueue_job(_cx: *mut JSContext,
_data: *mut c_void) -> bool {
let result = panic::catch_unwind(AssertUnwindSafe(|| {
let global = global_root_from_object(job.get());
let pipeline = global.r().pipeline_id();
let pipeline = global.r().as_global_scope().pipeline_id();
global.r().enqueue_promise_job(EnqueuedPromiseCallback {
callback: PromiseJobCallback::new(job.get()),
pipeline: pipeline,

View file

@ -650,7 +650,7 @@ impl ScriptThread {
let window = context.active_window();
let resize_event = window.steal_resize_event();
match resize_event {
Some(size) => resizes.push((window.pipeline_id(), size)),
Some(size) => resizes.push((window.upcast::<GlobalScope>().pipeline_id(), size)),
None => ()
}
}
@ -1501,7 +1501,7 @@ impl ScriptThread {
// If root is being exited, shut down all contexts
let context = self.root_browsing_context();
let window = context.active_window();
if window.pipeline_id() == id {
if window.upcast::<GlobalScope>().pipeline_id() == id {
debug!("shutting down layout for root context {:?}", id);
shut_down_layout(&context);
let _ = self.constellation_chan.send(ConstellationMsg::PipelineExited(id));

View file

@ -19,6 +19,7 @@ use dom::bindings::js::Root;
use dom::bindings::str::DOMString;
use dom::browsingcontext::BrowsingContext;
use dom::element::Element;
use dom::globalscope::GlobalScope;
use dom::htmlelement::HTMLElement;
use dom::htmliframeelement::HTMLIFrameElement;
use dom::htmlinputelement::HTMLInputElement;
@ -142,7 +143,7 @@ pub fn handle_get_frame_id(context: &BrowsingContext,
}
};
let frame_id = window.map(|x| x.map(|x| x.pipeline_id()));
let frame_id = window.map(|x| x.map(|x| x.upcast::<GlobalScope>().pipeline_id()));
reply.send(frame_id).unwrap()
}