Skip to content

Commit

Permalink
Consistently use parent_pipeline_id
Browse files Browse the repository at this point in the history
Instead of containing_pipeline_id, use parent_pipeline_id because it is
more clear that it refers to the immediate parent.
  • Loading branch information
aneeshusa committed Sep 13, 2016
1 parent 9d097e7 commit b9b25b6
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 56 deletions.
38 changes: 19 additions & 19 deletions components/constellation/constellation.rs
Expand Up @@ -825,7 +825,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
}
FromScriptMsg::ScriptLoadedURLInIFrame(load_info) => {
debug!("constellation got iframe URL load message {:?} {:?} {:?}",
load_info.containing_pipeline_id,
load_info.parent_pipeline_id,
load_info.old_subpage_id,
load_info.new_subpage_id);
self.handle_script_loaded_url_in_iframe_msg(load_info);
Expand Down Expand Up @@ -1227,20 +1227,20 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>

// The script thread associated with pipeline_id has loaded a URL in an iframe via script. This
// will result in a new pipeline being spawned and a frame tree being added to
// containing_page_pipeline_id's frame tree's children. This message is never the result of a
// parent_pipeline_id's frame tree's children. This message is never the result of a
// page navigation.
fn handle_script_loaded_url_in_iframe_msg(&mut self, load_info: IFrameLoadInfo) {
let old_pipeline_id = load_info.old_subpage_id
.and_then(|old_subpage_id| self.subpage_map.get(&(load_info.containing_pipeline_id, old_subpage_id)))
.and_then(|old_subpage_id| self.subpage_map.get(&(load_info.parent_pipeline_id, old_subpage_id)))
.cloned();

let (load_data, script_chan, window_size, is_private) = {
let old_pipeline = old_pipeline_id
.and_then(|old_pipeline_id| self.pipelines.get(&old_pipeline_id));

let source_pipeline = match self.pipelines.get(&load_info.containing_pipeline_id) {
let source_pipeline = match self.pipelines.get(&load_info.parent_pipeline_id) {
Some(source_pipeline) => source_pipeline,
None => return warn!("Script loaded url in closed iframe {}.", load_info.containing_pipeline_id),
None => return warn!("Script loaded url in closed iframe {}.", load_info.parent_pipeline_id),
};

// If no url is specified, reload.
Expand Down Expand Up @@ -1290,13 +1290,13 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>

// Create the new pipeline, attached to the parent and push to pending frames
self.new_pipeline(load_info.new_pipeline_id,
Some((load_info.containing_pipeline_id, load_info.new_subpage_id, load_info.frame_type)),
Some((load_info.parent_pipeline_id, load_info.new_subpage_id, load_info.frame_type)),
window_size,
script_chan,
load_data,
is_private);

self.subpage_map.insert((load_info.containing_pipeline_id, load_info.new_subpage_id),
self.subpage_map.insert((load_info.parent_pipeline_id, load_info.new_subpage_id),
load_info.new_pipeline_id);

self.push_pending_frame(load_info.new_pipeline_id, old_pipeline_id);
Expand Down Expand Up @@ -1585,7 +1585,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
}

fn handle_mozbrowser_event_msg(&mut self,
containing_pipeline_id: PipelineId,
parent_pipeline_id: PipelineId,
subpage_id: Option<SubpageId>,
event: MozBrowserEvent) {
assert!(PREFS.is_mozbrowser_enabled());
Expand All @@ -1594,9 +1594,9 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
// and pass the event to that script thread.
// If the pipeline lookup fails, it is because we have torn down the pipeline,
// so it is reasonable to silently ignore the event.
match self.pipelines.get(&containing_pipeline_id) {
match self.pipelines.get(&parent_pipeline_id) {
Some(pipeline) => pipeline.trigger_mozbrowser_event(subpage_id, event),
None => warn!("Pipeline {:?} handling mozbrowser event after closure.", containing_pipeline_id),
None => warn!("Pipeline {:?} handling mozbrowser event after closure.", parent_pipeline_id),
}
}

Expand Down Expand Up @@ -1630,22 +1630,22 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
Some(pipeline) => pipeline.parent_info,
None => return warn!("Pipeline {:?} focus parent after closure.", pipeline_id),
};
let (containing_pipeline_id, subpage_id, _) = match parent_info {
let (parent_pipeline_id, subpage_id, _) = match parent_info {
Some(info) => info,
None => return debug!("Pipeline {:?} focus has no parent.", pipeline_id),
};

// Send a message to the parent of the provided pipeline (if it exists)
// telling it to mark the iframe element as focused.
let msg = ConstellationControlMsg::FocusIFrame(containing_pipeline_id, subpage_id);
let result = match self.pipelines.get(&containing_pipeline_id) {
let msg = ConstellationControlMsg::FocusIFrame(parent_pipeline_id, subpage_id);
let result = match self.pipelines.get(&parent_pipeline_id) {
Some(pipeline) => pipeline.script_chan.send(msg),
None => return warn!("Pipeline {:?} focus after closure.", containing_pipeline_id),
None => return warn!("Pipeline {:?} focus after closure.", parent_pipeline_id),
};
if let Err(e) = result {
self.handle_send_error(containing_pipeline_id, e);
self.handle_send_error(parent_pipeline_id, e);
}
self.focus_parent_pipeline(containing_pipeline_id);
self.focus_parent_pipeline(parent_pipeline_id);
}

fn handle_focus_msg(&mut self, pipeline_id: PipelineId) {
Expand Down Expand Up @@ -2415,9 +2415,9 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
};

// If this is a mozbrowser iframe, then send the event with new url
if let Some((containing_pipeline_id, subpage_id)) = self.get_mozbrowser_ancestor_info(pipeline_id) {
if let Some(parent_pipeline) = self.pipelines.get(&containing_pipeline_id) {
let pipeline_id = self.subpage_map.get(&(containing_pipeline_id, subpage_id));
if let Some((parent_pipeline_id, subpage_id)) = self.get_mozbrowser_ancestor_info(pipeline_id) {
if let Some(parent_pipeline) = self.pipelines.get(&parent_pipeline_id) {
let pipeline_id = self.subpage_map.get(&(parent_pipeline_id, subpage_id));
if let Some(pipeline) = pipeline_id.and_then(|pipeline_id| self.pipelines.get(pipeline_id)) {
if let Some(frame_id) = pipeline.frame {
let can_go_forward = !self.joint_session_future(frame_id).is_empty();
Expand Down
4 changes: 2 additions & 2 deletions components/constellation/pipeline.rs
Expand Up @@ -150,10 +150,10 @@ impl Pipeline {

let (script_chan, content_ports) = match state.script_chan {
Some(script_chan) => {
let (containing_pipeline_id, subpage_id, frame_type) =
let (parent_pipeline_id, subpage_id, frame_type) =
state.parent_info.expect("script_pipeline != None but subpage_id == None");
let new_layout_info = NewLayoutInfo {
containing_pipeline_id: containing_pipeline_id,
parent_pipeline_id: parent_pipeline_id,
new_pipeline_id: state.id,
subpage_id: subpage_id,
frame_type: frame_type,
Expand Down
4 changes: 2 additions & 2 deletions components/script/dom/document.rs
Expand Up @@ -1342,8 +1342,8 @@ impl Document {

pub fn trigger_mozbrowser_event(&self, event: MozBrowserEvent) {
if PREFS.is_mozbrowser_enabled() {
if let Some((containing_pipeline_id, subpage_id, _)) = self.window.parent_info() {
let event = ConstellationMsg::MozBrowserEvent(containing_pipeline_id,
if let Some((parent_pipeline_id, subpage_id, _)) = self.window.parent_info() {
let event = ConstellationMsg::MozBrowserEvent(parent_pipeline_id,
Some(subpage_id),
event);
self.window.constellation_chan().send(event).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/htmliframeelement.rs
Expand Up @@ -133,7 +133,7 @@ impl HTMLIFrameElement {

let load_info = IFrameLoadInfo {
load_data: load_data,
containing_pipeline_id: window.pipeline_id(),
parent_pipeline_id: window.pipeline_id(),
new_subpage_id: new_subpage_id,
old_subpage_id: old_subpage_id,
new_pipeline_id: new_pipeline_id,
Expand Down
60 changes: 30 additions & 30 deletions components/script/script_thread.rs
Expand Up @@ -877,8 +877,8 @@ impl ScriptThread {

fn handle_msg_from_constellation(&self, msg: ConstellationControlMsg) {
match msg {
ConstellationControlMsg::Navigate(pipeline_id, subpage_id, load_data) =>
self.handle_navigate(pipeline_id, Some(subpage_id), load_data),
ConstellationControlMsg::Navigate(parent_pipeline_id, subpage_id, load_data) =>
self.handle_navigate(parent_pipeline_id, Some(subpage_id), load_data),
ConstellationControlMsg::SendEvent(id, event) =>
self.handle_event(id, event),
ConstellationControlMsg::ResizeInactive(id, new_size) =>
Expand All @@ -891,35 +891,35 @@ impl ScriptThread {
self.handle_thaw_msg(pipeline_id),
ConstellationControlMsg::ChangeFrameVisibilityStatus(pipeline_id, visible) =>
self.handle_visibility_change_msg(pipeline_id, visible),
ConstellationControlMsg::NotifyVisibilityChange(containing_id, pipeline_id, visible) =>
self.handle_visibility_change_complete_msg(containing_id, pipeline_id, visible),
ConstellationControlMsg::NotifyVisibilityChange(parent_pipeline_id, pipeline_id, visible) =>
self.handle_visibility_change_complete_msg(parent_pipeline_id, pipeline_id, visible),
ConstellationControlMsg::MozBrowserEvent(parent_pipeline_id,
subpage_id,
event) =>
self.handle_mozbrowser_event_msg(parent_pipeline_id,
subpage_id,
event),
ConstellationControlMsg::UpdateSubpageId(containing_pipeline_id,
ConstellationControlMsg::UpdateSubpageId(parent_pipeline_id,
old_subpage_id,
new_subpage_id,
new_pipeline_id) =>
self.handle_update_subpage_id(containing_pipeline_id,
self.handle_update_subpage_id(parent_pipeline_id,
old_subpage_id,
new_subpage_id,
new_pipeline_id),
ConstellationControlMsg::FocusIFrame(containing_pipeline_id, subpage_id) =>
self.handle_focus_iframe_msg(containing_pipeline_id, subpage_id),
ConstellationControlMsg::FocusIFrame(parent_pipeline_id, subpage_id) =>
self.handle_focus_iframe_msg(parent_pipeline_id, subpage_id),
ConstellationControlMsg::WebDriverScriptCommand(pipeline_id, msg) =>
self.handle_webdriver_msg(pipeline_id, msg),
ConstellationControlMsg::TickAllAnimations(pipeline_id) =>
self.handle_tick_all_animations(pipeline_id),
ConstellationControlMsg::WebFontLoaded(pipeline_id) =>
self.handle_web_font_loaded(pipeline_id),
ConstellationControlMsg::DispatchFrameLoadEvent {
target: pipeline_id, parent: containing_id } =>
self.handle_frame_load_event(containing_id, pipeline_id),
ConstellationControlMsg::FramedContentChanged(containing_pipeline_id, subpage_id) =>
self.handle_framed_content_changed(containing_pipeline_id, subpage_id),
target: pipeline_id, parent: parent_pipeline_id } =>
self.handle_frame_load_event(parent_pipeline_id, pipeline_id),
ConstellationControlMsg::FramedContentChanged(parent_pipeline_id, pipeline_id) =>
self.handle_framed_content_changed(parent_pipeline_id, pipeline_id),
ConstellationControlMsg::ReportCSSError(pipeline_id, filename, line, column, msg) =>
self.handle_css_error_reporting(pipeline_id, filename, line, column, msg),
ConstellationControlMsg::Reload(pipeline_id) =>
Expand All @@ -935,8 +935,8 @@ impl ScriptThread {

fn handle_msg_from_script(&self, msg: MainThreadScriptMsg) {
match msg {
MainThreadScriptMsg::Navigate(id, load_data) =>
self.handle_navigate(id, None, load_data),
MainThreadScriptMsg::Navigate(parent_pipeline_id, load_data) =>
self.handle_navigate(parent_pipeline_id, None, load_data),
MainThreadScriptMsg::ExitWindow(id) =>
self.handle_exit_window_msg(id),
MainThreadScriptMsg::DocumentLoadsComplete(id) =>
Expand Down Expand Up @@ -1128,7 +1128,7 @@ impl ScriptThread {

fn handle_new_layout(&self, new_layout_info: NewLayoutInfo) {
let NewLayoutInfo {
containing_pipeline_id,
parent_pipeline_id,
new_pipeline_id,
subpage_id,
frame_type,
Expand Down Expand Up @@ -1158,7 +1158,7 @@ impl ScriptThread {
};

let context = self.root_browsing_context();
let parent_context = context.find(containing_pipeline_id).expect("ScriptThread: received a layout
let parent_context = context.find(parent_pipeline_id).expect("ScriptThread: received a layout
whose parent has a PipelineId which does not correspond to a pipeline in the script
thread's browsing context tree. This is a bug.");
let parent_window = parent_context.active_window();
Expand All @@ -1169,7 +1169,7 @@ impl ScriptThread {
.unwrap();

// Kick off the fetch for the new resource.
let new_load = InProgressLoad::new(new_pipeline_id, Some((containing_pipeline_id, subpage_id, frame_type)),
let new_load = InProgressLoad::new(new_pipeline_id, Some((parent_pipeline_id, subpage_id, frame_type)),
layout_chan, parent_window.window_size(),
load_data.url.clone());
self.start_page_load(new_load, load_data);
Expand Down Expand Up @@ -1254,9 +1254,9 @@ impl ScriptThread {
}

/// Updates iframe element after a change in visibility
fn handle_visibility_change_complete_msg(&self, containing_id: PipelineId, id: PipelineId, visible: bool) {
fn handle_visibility_change_complete_msg(&self, parent_pipeline_id: PipelineId, id: PipelineId, visible: bool) {
if let Some(root_context) = self.browsing_context.get() {
if let Some(ref inner_context) = root_context.find(containing_id) {
if let Some(ref inner_context) = root_context.find(parent_pipeline_id) {
if let Some(iframe) = inner_context.active_document().find_iframe_by_pipeline(id) {
iframe.change_visibility_status(visible);
}
Expand Down Expand Up @@ -1372,13 +1372,13 @@ impl ScriptThread {
}

fn handle_update_subpage_id(&self,
containing_pipeline_id: PipelineId,
parent_pipeline_id: PipelineId,
old_subpage_id: SubpageId,
new_subpage_id: SubpageId,
new_pipeline_id: PipelineId) {
let borrowed_context = self.root_browsing_context();

let frame_element = borrowed_context.find(containing_pipeline_id).and_then(|context| {
let frame_element = borrowed_context.find(parent_pipeline_id).and_then(|context| {
let doc = context.active_document();
doc.find_iframe(old_subpage_id)
});
Expand Down Expand Up @@ -1534,10 +1534,10 @@ impl ScriptThread {
}

/// Notify the containing document of a child frame that has completed loading.
fn handle_frame_load_event(&self, containing_pipeline: PipelineId, id: PipelineId) {
let document = match self.root_browsing_context().find(containing_pipeline) {
fn handle_frame_load_event(&self, parent_pipeline_id: PipelineId, id: PipelineId) {
let document = match self.root_browsing_context().find(parent_pipeline_id) {
Some(browsing_context) => browsing_context.active_document(),
None => return warn!("Message sent to closed pipeline {}.", containing_pipeline),
None => return warn!("Message sent to closed pipeline {}.", parent_pipeline_id),
};
if let Some(iframe) = document.find_iframe_by_pipeline(id) {
iframe.iframe_load_event_steps(id);
Expand Down Expand Up @@ -2006,19 +2006,19 @@ impl ScriptThread {
/// https://html.spec.whatwg.org/multipage/#navigating-across-documents
/// The entry point for content to notify that a new load has been requested
/// for the given pipeline (specifically the "navigate" algorithm).
fn handle_navigate(&self, pipeline_id: PipelineId, subpage_id: Option<SubpageId>, load_data: LoadData) {
fn handle_navigate(&self, parent_pipeline_id: PipelineId, subpage_id: Option<SubpageId>, load_data: LoadData) {
// Step 7.
{
let nurl = &load_data.url;
if let Some(fragment) = nurl.fragment() {
let document = match self.root_browsing_context().find(pipeline_id) {
let document = match self.root_browsing_context().find(parent_pipeline_id) {
Some(browsing_context) => browsing_context.active_document(),
None => return warn!("Message sent to closed pipeline {}.", pipeline_id),
None => return warn!("Message sent to closed pipeline {}.", parent_pipeline_id),
};
let url = document.url();
if &url[..Position::AfterQuery] == &nurl[..Position::AfterQuery] &&
load_data.method == Method::Get {
self.check_and_scroll_fragment(fragment, pipeline_id, document.r());
self.check_and_scroll_fragment(fragment, parent_pipeline_id, document.r());
return;
}
}
Expand All @@ -2027,7 +2027,7 @@ impl ScriptThread {
match subpage_id {
Some(subpage_id) => {
let root_context = self.root_browsing_context();
let iframe = root_context.find(pipeline_id).and_then(|context| {
let iframe = root_context.find(parent_pipeline_id).and_then(|context| {
let doc = context.active_document();
doc.find_iframe(subpage_id)
});
Expand All @@ -2037,7 +2037,7 @@ impl ScriptThread {
}
None => {
self.constellation_chan
.send(ConstellationMsg::LoadUrl(pipeline_id, load_data))
.send(ConstellationMsg::LoadUrl(parent_pipeline_id, load_data))
.unwrap();
}
}
Expand Down
4 changes: 2 additions & 2 deletions components/script_traits/lib.rs
Expand Up @@ -130,7 +130,7 @@ pub enum LayoutControlMsg {
#[derive(Deserialize, Serialize)]
pub struct NewLayoutInfo {
/// Id of the parent of this new pipeline.
pub containing_pipeline_id: PipelineId,
pub parent_pipeline_id: PipelineId,
/// Id of the newly-created pipeline.
pub new_pipeline_id: PipelineId,
/// Id of the new frame associated with this pipeline.
Expand Down Expand Up @@ -444,7 +444,7 @@ pub struct IFrameLoadInfo {
/// Load data containing the url to load
pub load_data: Option<LoadData>,
/// Pipeline ID of the parent of this iframe
pub containing_pipeline_id: PipelineId,
pub parent_pipeline_id: PipelineId,
/// The new subpage ID for this load
pub new_subpage_id: SubpageId,
/// The old subpage ID for this iframe, if a page was previously loaded.
Expand Down

0 comments on commit b9b25b6

Please sign in to comment.