Use fn pipeline_id consistently, not fn pipeline

Consistently use the name 'pipeline_id' to refer to a function that
returns an (optional) PipelineId.

This was prompted by discovering both fn pipeline and fn pipeline_id
doing the same job in htmliframeelement.rs.

Note that there is fn pipeline in components/compositing/compositor.rs,
but that actually returns an Option<&CompositionPipeline>, not any kind
of PipelineId.
This commit is contained in:
Aneesh Agrawal 2016-06-09 07:01:24 -04:00
parent bb53da6957
commit 9d097e7d15
20 changed files with 50 additions and 51 deletions

View file

@ -69,10 +69,10 @@ impl<'a> GlobalRef<'a> {
} }
/// Get the `PipelineId` for this global scope. /// Get the `PipelineId` for this global scope.
pub fn pipeline(&self) -> PipelineId { pub fn pipeline_id(&self) -> PipelineId {
match *self { match *self {
GlobalRef::Window(window) => window.pipeline(), GlobalRef::Window(window) => window.pipeline_id(),
GlobalRef::Worker(worker) => worker.pipeline(), GlobalRef::Worker(worker) => worker.pipeline_id(),
} }
} }

View file

@ -152,7 +152,7 @@ impl BrowsingContext {
old old
} }
pub fn pipeline(&self) -> PipelineId { pub fn pipeline_id(&self) -> PipelineId {
self.id self.id
} }

View file

@ -18,7 +18,7 @@ impl Console {
if let Some(chan) = global.devtools_chan() { if let Some(chan) = global.devtools_chan() {
let console_message = prepare_message(level, message); let console_message = prepare_message(level, message);
let devtools_message = ScriptToDevtoolsControlMsg::ConsoleAPI( let devtools_message = ScriptToDevtoolsControlMsg::ConsoleAPI(
global.pipeline(), global.pipeline_id(),
console_message, console_message,
global.get_worker_id()); global.get_worker_id());
chan.send(devtools_message).unwrap(); chan.send(devtools_message).unwrap();

View file

@ -243,7 +243,7 @@ impl DedicatedWorkerGlobalScope {
} }
} }
pub fn pipeline(&self) -> PipelineId { pub fn pipeline_id(&self) -> PipelineId {
self.id self.id
} }

View file

@ -641,7 +641,7 @@ impl Document {
// Update the focus state for all elements in the focus chain. // Update the focus state for all elements in the focus chain.
// https://html.spec.whatwg.org/multipage/#focus-chain // https://html.spec.whatwg.org/multipage/#focus-chain
if focus_type == FocusType::Element { if focus_type == FocusType::Element {
let event = ConstellationMsg::Focus(self.window.pipeline()); let event = ConstellationMsg::Focus(self.window.pipeline_id());
self.window.constellation_chan().send(event).unwrap(); self.window.constellation_chan().send(event).unwrap();
} }
} }
@ -661,7 +661,7 @@ impl Document {
pub fn send_title_to_compositor(&self) { pub fn send_title_to_compositor(&self) {
let window = self.window(); let window = self.window();
window.constellation_chan() window.constellation_chan()
.send(ConstellationMsg::SetTitle(window.pipeline(), .send(ConstellationMsg::SetTitle(window.pipeline_id(),
Some(String::from(self.Title())))) Some(String::from(self.Title()))))
.unwrap(); .unwrap();
} }
@ -1367,7 +1367,7 @@ impl Document {
// TODO: Should tick animation only when document is visible // TODO: Should tick animation only when document is visible
if !self.running_animation_callbacks.get() { if !self.running_animation_callbacks.get() {
let event = ConstellationMsg::ChangeRunningAnimationsState( let event = ConstellationMsg::ChangeRunningAnimationsState(
self.window.pipeline(), self.window.pipeline_id(),
AnimationState::AnimationCallbacksPresent); AnimationState::AnimationCallbacksPresent);
self.window.constellation_chan().send(event).unwrap(); self.window.constellation_chan().send(event).unwrap();
} }
@ -1405,7 +1405,7 @@ impl Document {
if self.animation_frame_list.borrow().is_empty() { if self.animation_frame_list.borrow().is_empty() {
mem::swap(&mut *self.animation_frame_list.borrow_mut(), mem::swap(&mut *self.animation_frame_list.borrow_mut(),
&mut animation_frame_list); &mut animation_frame_list);
let event = ConstellationMsg::ChangeRunningAnimationsState(self.window.pipeline(), let event = ConstellationMsg::ChangeRunningAnimationsState(self.window.pipeline_id(),
AnimationState::NoAnimationCallbacksPresent); AnimationState::NoAnimationCallbacksPresent);
self.window.constellation_chan().send(event).unwrap(); self.window.constellation_chan().send(event).unwrap();
} }
@ -1469,7 +1469,7 @@ impl Document {
let loader = self.loader.borrow(); let loader = self.loader.borrow();
if !loader.is_blocked() && !loader.events_inhibited() { if !loader.is_blocked() && !loader.events_inhibited() {
let win = self.window(); let win = self.window();
let msg = MainThreadScriptMsg::DocumentLoadsComplete(win.pipeline()); let msg = MainThreadScriptMsg::DocumentLoadsComplete(win.pipeline_id());
win.main_thread_script_chan().send(msg).unwrap(); win.main_thread_script_chan().send(msg).unwrap();
} }
} }
@ -1567,7 +1567,7 @@ impl Document {
} }
pub fn notify_constellation_load(&self) { pub fn notify_constellation_load(&self) {
let pipeline_id = self.window.pipeline(); let pipeline_id = self.window.pipeline_id();
let load_event = ConstellationMsg::LoadComplete(pipeline_id); let load_event = ConstellationMsg::LoadComplete(pipeline_id);
self.window.constellation_chan().send(load_event).unwrap(); self.window.constellation_chan().send(load_event).unwrap();
} }
@ -1593,7 +1593,7 @@ impl Document {
self.upcast::<Node>() self.upcast::<Node>()
.traverse_preorder() .traverse_preorder()
.filter_map(Root::downcast::<HTMLIFrameElement>) .filter_map(Root::downcast::<HTMLIFrameElement>)
.find(|node| node.pipeline() == Some(pipeline)) .find(|node| node.pipeline_id() == Some(pipeline))
} }
pub fn get_dom_loading(&self) -> u64 { pub fn get_dom_loading(&self) -> u64 {

View file

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

View file

@ -435,7 +435,7 @@ impl HTMLFormElement {
// Step 2 // Step 2
let nav = box PlannedNavigation { let nav = box PlannedNavigation {
load_data: load_data, load_data: load_data,
pipeline_id: window.pipeline(), pipeline_id: window.pipeline_id(),
script_chan: window.main_thread_script_chan().clone(), script_chan: window.main_thread_script_chan().clone(),
generation_id: self.generation_id.get(), generation_id: self.generation_id.get(),
form: Trusted::new(self) form: Trusted::new(self)

View file

@ -133,7 +133,7 @@ impl HTMLIFrameElement {
let load_info = IFrameLoadInfo { let load_info = IFrameLoadInfo {
load_data: load_data, load_data: load_data,
containing_pipeline_id: window.pipeline(), containing_pipeline_id: window.pipeline_id(),
new_subpage_id: new_subpage_id, new_subpage_id: new_subpage_id,
old_subpage_id: old_subpage_id, old_subpage_id: old_subpage_id,
new_pipeline_id: new_pipeline_id, new_pipeline_id: new_pipeline_id,
@ -213,10 +213,6 @@ impl HTMLIFrameElement {
self.subpage_id.get() self.subpage_id.get()
} }
pub fn pipeline(&self) -> Option<PipelineId> {
self.pipeline_id.get()
}
pub fn change_visibility_status(&self, visibility: bool) { pub fn change_visibility_status(&self, visibility: bool) {
if self.visibility.get() != visibility { if self.visibility.get() != visibility {
self.visibility.set(visibility); self.visibility.set(visibility);
@ -241,7 +237,7 @@ impl HTMLIFrameElement {
pub fn iframe_load_event_steps(&self, loaded_pipeline: PipelineId) { pub fn iframe_load_event_steps(&self, loaded_pipeline: PipelineId) {
// TODO(#9592): assert that the load blocker is present at all times when we // TODO(#9592): assert that the load blocker is present at all times when we
// can guarantee that it's created for the case of iframe.reload(). // can guarantee that it's created for the case of iframe.reload().
assert_eq!(loaded_pipeline, self.pipeline().unwrap()); assert_eq!(loaded_pipeline, self.pipeline_id().unwrap());
// TODO A cross-origin child document would not be easily accessible // TODO A cross-origin child document would not be easily accessible
// from this script thread. It's unclear how to implement // from this script thread. It's unclear how to implement
@ -423,7 +419,7 @@ pub fn Navigate(iframe: &HTMLIFrameElement, direction: TraversalDirection) -> Er
if iframe.Mozbrowser() { if iframe.Mozbrowser() {
if iframe.upcast::<Node>().is_in_doc() { if iframe.upcast::<Node>().is_in_doc() {
let window = window_from_node(iframe); let window = window_from_node(iframe);
let msg = ConstellationMsg::TraverseHistory(iframe.pipeline(), direction); let msg = ConstellationMsg::TraverseHistory(iframe.pipeline_id(), direction);
window.constellation_chan().send(msg).unwrap(); window.constellation_chan().send(msg).unwrap();
} }

View file

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

View file

@ -100,7 +100,7 @@ impl ServiceWorkerContainerMethods for ServiceWorkerContainer {
script_url, script_url,
scope_str.clone(), scope_str.clone(),
self); self);
ScriptThread::set_registration(scope, &*worker_registration, self.global().r().pipeline()); ScriptThread::set_registration(scope, &*worker_registration, self.global().r().pipeline_id());
Ok(worker_registration) Ok(worker_registration)
} }
} }

View file

@ -285,7 +285,7 @@ impl ServiceWorkerGlobalScope {
} }
} }
pub fn pipeline(&self) -> PipelineId { pub fn pipeline_id(&self) -> PipelineId {
self.id self.id
} }

View file

@ -53,14 +53,14 @@ impl ServiceWorkerRegistration {
let worker_load_origin = WorkerScriptLoadOrigin { let worker_load_origin = WorkerScriptLoadOrigin {
referrer_url: None, referrer_url: None,
referrer_policy: None, referrer_policy: None,
pipeline_id: Some(global.pipeline()) pipeline_id: Some(global.pipeline_id())
}; };
let worker_id = global.get_next_worker_id(); let worker_id = global.get_next_worker_id();
let init = prepare_workerscope_init(global, None); let init = prepare_workerscope_init(global, None);
ScopeThings { ScopeThings {
script_url: script_url, script_url: script_url,
pipeline_id: global.pipeline(), pipeline_id: global.pipeline_id(),
init: init, init: init,
worker_load_origin: worker_load_origin, worker_load_origin: worker_load_origin,
devtools_chan: global.devtools_chan(), devtools_chan: global.devtools_chan(),

View file

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

View file

@ -331,7 +331,7 @@ impl Window {
worker_id worker_id
} }
pub fn pipeline(&self) -> PipelineId { pub fn pipeline_id(&self) -> PipelineId {
self.id self.id
} }
@ -472,7 +472,7 @@ impl WindowMethods for Window {
} }
let (sender, receiver) = ipc::channel().unwrap(); let (sender, receiver) = ipc::channel().unwrap();
self.constellation_chan().send(ConstellationMsg::Alert(self.pipeline(), s.to_string(), sender)).unwrap(); self.constellation_chan().send(ConstellationMsg::Alert(self.pipeline_id(), s.to_string(), sender)).unwrap();
let should_display_alert_dialog = receiver.recv().unwrap(); let should_display_alert_dialog = receiver.recv().unwrap();
if should_display_alert_dialog { if should_display_alert_dialog {
@ -1058,7 +1058,7 @@ impl Window {
// TODO (farodin91): Raise an event to stop the current_viewport // TODO (farodin91): Raise an event to stop the current_viewport
self.update_viewport_for_scroll(x, y); self.update_viewport_for_scroll(x, y);
let message = ConstellationMsg::ScrollFragmentPoint(self.pipeline(), layer_id, point, smooth); let message = ConstellationMsg::ScrollFragmentPoint(self.pipeline_id(), layer_id, point, smooth);
self.constellation_chan.send(message).unwrap(); self.constellation_chan.send(message).unwrap();
} }

View file

@ -85,13 +85,13 @@ impl Worker {
let worker_load_origin = WorkerScriptLoadOrigin { let worker_load_origin = WorkerScriptLoadOrigin {
referrer_url: None, referrer_url: None,
referrer_policy: None, referrer_policy: None,
pipeline_id: Some(global.pipeline()) pipeline_id: Some(global.pipeline_id()),
}; };
let (devtools_sender, devtools_receiver) = ipc::channel().unwrap(); let (devtools_sender, devtools_receiver) = ipc::channel().unwrap();
let worker_id = global.get_next_worker_id(); let worker_id = global.get_next_worker_id();
if let Some(ref chan) = global.devtools_chan() { if let Some(ref chan) = global.devtools_chan() {
let pipeline_id = global.pipeline(); let pipeline_id = global.pipeline_id();
let title = format!("Worker for {}", worker_url); let title = format!("Worker for {}", worker_url);
let page_info = DevtoolsPageInfo { let page_info = DevtoolsPageInfo {
title: title, title: title,
@ -105,7 +105,7 @@ impl Worker {
let init = prepare_workerscope_init(global, Some(devtools_sender)); let init = prepare_workerscope_init(global, Some(devtools_sender));
DedicatedWorkerGlobalScope::run_worker_scope( DedicatedWorkerGlobalScope::run_worker_scope(
init, worker_url, global.pipeline(), devtools_receiver, worker.runtime.clone(), worker_ref, init, worker_url, global.pipeline_id(), devtools_receiver, worker.runtime.clone(), worker_ref,
global.script_chan(), sender, receiver, worker_load_origin, closing); global.script_chan(), sender, receiver, worker_load_origin, closing);
Ok(worker) Ok(worker)

View file

@ -238,7 +238,7 @@ impl LoadOrigin for WorkerGlobalScope {
None None
} }
fn pipeline_id(&self) -> Option<PipelineId> { fn pipeline_id(&self) -> Option<PipelineId> {
Some(self.pipeline()) Some(self.pipeline_id())
} }
} }
@ -410,13 +410,13 @@ impl WorkerGlobalScope {
FileReadingTaskSource(self.script_chan()) FileReadingTaskSource(self.script_chan())
} }
pub fn pipeline(&self) -> PipelineId { pub fn pipeline_id(&self) -> PipelineId {
let dedicated = self.downcast::<DedicatedWorkerGlobalScope>(); let dedicated = self.downcast::<DedicatedWorkerGlobalScope>();
let service_worker = self.downcast::<ServiceWorkerGlobalScope>(); let service_worker = self.downcast::<ServiceWorkerGlobalScope>();
if let Some(dedicated) = dedicated { if let Some(dedicated) = dedicated {
return dedicated.pipeline(); return dedicated.pipeline_id();
} else if let Some(service_worker) = service_worker { } else if let Some(service_worker) = service_worker {
return service_worker.pipeline(); return service_worker.pipeline_id();
} else { } else {
panic!("need to implement a sender for SharedWorker") panic!("need to implement a sender for SharedWorker")
} }

View file

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

View file

@ -644,7 +644,7 @@ impl ScriptThread {
let window = context.active_window(); let window = context.active_window();
let resize_event = window.steal_resize_event(); let resize_event = window.steal_resize_event();
match resize_event { match resize_event {
Some(size) => resizes.push((window.pipeline(), size)), Some(size) => resizes.push((window.pipeline_id(), size)),
None => () None => ()
} }
} }
@ -1502,7 +1502,7 @@ impl ScriptThread {
// If root is being exited, shut down all contexts // If root is being exited, shut down all contexts
let context = self.root_browsing_context(); let context = self.root_browsing_context();
let window = context.active_window(); let window = context.active_window();
if window.pipeline() == id { if window.pipeline_id() == id {
debug!("shutting down layout for root context {:?}", id); debug!("shutting down layout for root context {:?}", id);
shut_down_layout(&context); shut_down_layout(&context);
let _ = self.constellation_chan.send(ConstellationMsg::PipelineExited(id)); let _ = self.constellation_chan.send(ConstellationMsg::PipelineExited(id));
@ -1698,7 +1698,7 @@ impl ScriptThread {
}); });
let loader = DocumentLoader::new_with_threads(self.resource_threads.clone(), let loader = DocumentLoader::new_with_threads(self.resource_threads.clone(),
Some(browsing_context.pipeline()), Some(browsing_context.pipeline_id()),
Some(incomplete.url.clone())); Some(incomplete.url.clone()));
let is_html_document = match metadata.content_type { let is_html_document = match metadata.content_type {
@ -1754,7 +1754,7 @@ impl ScriptThread {
.unwrap(); .unwrap();
// Notify devtools that a new script global exists. // Notify devtools that a new script global exists.
self.notify_devtools(document.Title(), final_url.clone(), (browsing_context.pipeline(), None)); self.notify_devtools(document.Title(), final_url.clone(), (browsing_context.pipeline_id(), None));
let is_javascript = incomplete.url.scheme() == "javascript"; let is_javascript = incomplete.url.scheme() == "javascript";
let parse_input = if is_javascript { let parse_input = if is_javascript {
@ -1818,7 +1818,7 @@ impl ScriptThread {
} }
if !incomplete.is_visible { if !incomplete.is_visible {
self.alter_resource_utilization(browsing_context.pipeline(), false); self.alter_resource_utilization(browsing_context.pipeline_id(), false);
} }
context_remover.neuter(); context_remover.neuter();

View file

@ -140,7 +140,7 @@ pub fn handle_get_frame_id(context: &BrowsingContext,
} }
}; };
let frame_id = window.map(|x| x.map(|x| x.pipeline())); let frame_id = window.map(|x| x.map(|x| x.pipeline_id()));
reply.send(frame_id).unwrap() reply.send(frame_id).unwrap()
} }

View file

@ -251,7 +251,7 @@ impl Handler {
} }
} }
fn pipeline(&self, frame_id: Option<FrameId>) -> WebDriverResult<PipelineId> { fn pipeline_id(&self, frame_id: Option<FrameId>) -> WebDriverResult<PipelineId> {
let interval = 20; let interval = 20;
let iterations = 30_000 / interval; let iterations = 30_000 / interval;
let (sender, receiver) = ipc::channel().unwrap(); let (sender, receiver) = ipc::channel().unwrap();
@ -271,11 +271,11 @@ impl Handler {
} }
fn root_pipeline(&self) -> WebDriverResult<PipelineId> { fn root_pipeline(&self) -> WebDriverResult<PipelineId> {
self.pipeline(None) self.pipeline_id(None)
} }
fn frame_pipeline(&self) -> WebDriverResult<PipelineId> { fn frame_pipeline(&self) -> WebDriverResult<PipelineId> {
self.pipeline(self.session.as_ref().and_then(|session| session.frame_id)) self.pipeline_id(self.session.as_ref().and_then(|session| session.frame_id))
} }
fn session(&self) -> WebDriverResult<&WebDriverSession> { fn session(&self) -> WebDriverResult<&WebDriverSession> {