mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Renamed constellation::Frame to constellation::BrowsingContext.
This commit is contained in:
parent
5403c2fff0
commit
607e011b05
24 changed files with 778 additions and 721 deletions
|
@ -3,7 +3,7 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use euclid::size::TypedSize2D;
|
use euclid::size::TypedSize2D;
|
||||||
use msg::constellation_msg::{FrameId, PipelineId};
|
use msg::constellation_msg::{BrowsingContextId, PipelineId};
|
||||||
use pipeline::Pipeline;
|
use pipeline::Pipeline;
|
||||||
use script_traits::LoadData;
|
use script_traits::LoadData;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
@ -12,17 +12,16 @@ use std::mem::replace;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
use style_traits::CSSPixel;
|
use style_traits::CSSPixel;
|
||||||
|
|
||||||
/// A frame in the frame tree.
|
/// The constellation's view of a browsing context.
|
||||||
/// Each frame is the constellation's view of a browsing context.
|
|
||||||
/// Each browsing context has a session history, caused by
|
/// Each browsing context has a session history, caused by
|
||||||
/// navigation and traversing the history. Each frame has its
|
/// navigation and traversing the history. Each browsing contest has its
|
||||||
/// current entry, plus past and future entries. The past is sorted
|
/// current entry, plus past and future entries. The past is sorted
|
||||||
/// chronologically, the future is sorted reverse chronologically:
|
/// chronologically, the future is sorted reverse chronologically:
|
||||||
/// in particular prev.pop() is the latest past entry, and
|
/// in particular prev.pop() is the latest past entry, and
|
||||||
/// next.pop() is the earliest future entry.
|
/// next.pop() is the earliest future entry.
|
||||||
pub struct Frame {
|
pub struct BrowsingContext {
|
||||||
/// The frame id.
|
/// The browsing context id.
|
||||||
pub id: FrameId,
|
pub id: BrowsingContextId,
|
||||||
|
|
||||||
/// The size of the frame.
|
/// The size of the frame.
|
||||||
pub size: Option<TypedSize2D<f32, CSSPixel>>,
|
pub size: Option<TypedSize2D<f32, CSSPixel>>,
|
||||||
|
@ -37,17 +36,17 @@ pub struct Frame {
|
||||||
pub load_data: LoadData,
|
pub load_data: LoadData,
|
||||||
|
|
||||||
/// The past session history, ordered chronologically.
|
/// The past session history, ordered chronologically.
|
||||||
pub prev: Vec<FrameState>,
|
pub prev: Vec<SessionHistoryEntry>,
|
||||||
|
|
||||||
/// The future session history, ordered reverse chronologically.
|
/// The future session history, ordered reverse chronologically.
|
||||||
pub next: Vec<FrameState>,
|
pub next: Vec<SessionHistoryEntry>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Frame {
|
impl BrowsingContext {
|
||||||
/// Create a new frame.
|
/// Create a new browsing context.
|
||||||
/// Note this just creates the frame, it doesn't add it to the frame tree.
|
/// Note this just creates the browsing context, it doesn't add it to the constellation's set of browsing contexts.
|
||||||
pub fn new(id: FrameId, pipeline_id: PipelineId, load_data: LoadData) -> Frame {
|
pub fn new(id: BrowsingContextId, pipeline_id: PipelineId, load_data: LoadData) -> BrowsingContext {
|
||||||
Frame {
|
BrowsingContext {
|
||||||
id: id,
|
id: id,
|
||||||
size: None,
|
size: None,
|
||||||
pipeline_id: pipeline_id,
|
pipeline_id: pipeline_id,
|
||||||
|
@ -58,17 +57,17 @@ impl Frame {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the current frame state.
|
/// Get the current session history entry.
|
||||||
pub fn current(&self) -> FrameState {
|
pub fn current(&self) -> SessionHistoryEntry {
|
||||||
FrameState {
|
SessionHistoryEntry {
|
||||||
instant: self.instant,
|
instant: self.instant,
|
||||||
frame_id: self.id,
|
browsing_context_id: self.id,
|
||||||
pipeline_id: Some(self.pipeline_id),
|
pipeline_id: Some(self.pipeline_id),
|
||||||
load_data: self.load_data.clone(),
|
load_data: self.load_data.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the current frame entry, and push the current frame entry into the past.
|
/// Set the current session history entry, and push the current frame entry into the past.
|
||||||
pub fn load(&mut self, pipeline_id: PipelineId, load_data: LoadData) {
|
pub fn load(&mut self, pipeline_id: PipelineId, load_data: LoadData) {
|
||||||
let current = self.current();
|
let current = self.current();
|
||||||
self.prev.push(current);
|
self.prev.push(current);
|
||||||
|
@ -78,25 +77,27 @@ impl Frame {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the future to be empty.
|
/// Set the future to be empty.
|
||||||
pub fn remove_forward_entries(&mut self) -> Vec<FrameState> {
|
pub fn remove_forward_entries(&mut self) -> Vec<SessionHistoryEntry> {
|
||||||
replace(&mut self.next, vec!())
|
replace(&mut self.next, vec!())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Update the current entry of the Frame from an entry that has been traversed to.
|
/// Update the current entry of the BrowsingContext from an entry that has been traversed to.
|
||||||
pub fn update_current(&mut self, pipeline_id: PipelineId, entry: FrameState) {
|
pub fn update_current(&mut self, pipeline_id: PipelineId, entry: SessionHistoryEntry) {
|
||||||
self.pipeline_id = pipeline_id;
|
self.pipeline_id = pipeline_id;
|
||||||
self.instant = entry.instant;
|
self.instant = entry.instant;
|
||||||
self.load_data = entry.load_data;
|
self.load_data = entry.load_data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An entry in a frame's session history.
|
/// An entry in a browsing context's session history.
|
||||||
/// Each entry stores the pipeline id for a document in the session history.
|
/// Each entry stores the pipeline id for a document in the session history.
|
||||||
///
|
///
|
||||||
/// When we operate on the joint session history, entries are sorted chronologically,
|
/// When we operate on the joint session history, entries are sorted chronologically,
|
||||||
/// so we timestamp the entries by when the entry was added to the session history.
|
/// so we timestamp the entries by when the entry was added to the session history.
|
||||||
|
///
|
||||||
|
/// https://html.spec.whatwg.org/multipage/#session-history-entry
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct FrameState {
|
pub struct SessionHistoryEntry {
|
||||||
/// The timestamp for when the session history entry was created
|
/// The timestamp for when the session history entry was created
|
||||||
pub instant: Instant,
|
pub instant: Instant,
|
||||||
|
|
||||||
|
@ -108,14 +109,14 @@ pub struct FrameState {
|
||||||
pub load_data: LoadData,
|
pub load_data: LoadData,
|
||||||
|
|
||||||
/// The frame that this session history entry is part of
|
/// The frame that this session history entry is part of
|
||||||
pub frame_id: FrameId,
|
pub browsing_context_id: BrowsingContextId,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents a pending change in the frame tree, that will be applied
|
/// Represents a pending change in a session history, that will be applied
|
||||||
/// once the new pipeline has loaded and completed initial layout / paint.
|
/// once the new pipeline has loaded and completed initial layout / paint.
|
||||||
pub struct FrameChange {
|
pub struct SessionHistoryChange {
|
||||||
/// The frame to change.
|
/// The browsing context to change.
|
||||||
pub frame_id: FrameId,
|
pub browsing_context_id: BrowsingContextId,
|
||||||
|
|
||||||
/// The pipeline for the document being loaded.
|
/// The pipeline for the document being loaded.
|
||||||
pub new_pipeline_id: PipelineId,
|
pub new_pipeline_id: PipelineId,
|
||||||
|
@ -129,16 +130,15 @@ pub struct FrameChange {
|
||||||
pub replace_instant: Option<Instant>,
|
pub replace_instant: Option<Instant>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An iterator over a frame tree, returning the fully active frames in
|
/// An iterator over browsing contexts, returning the descendant
|
||||||
/// depth-first order. Note that this iterator only returns the fully
|
/// contexts whose active documents are fully active, in depth-first
|
||||||
/// active frames, that is ones where every ancestor frame is
|
/// order.
|
||||||
/// in the currently active pipeline of its parent frame.
|
pub struct FullyActiveBrowsingContextsIterator<'a> {
|
||||||
pub struct FrameTreeIterator<'a> {
|
/// The browsing contexts still to iterate over.
|
||||||
/// The frames still to iterate over.
|
pub stack: Vec<BrowsingContextId>,
|
||||||
pub stack: Vec<FrameId>,
|
|
||||||
|
|
||||||
/// The set of all frames.
|
/// The set of all browsing contexts.
|
||||||
pub frames: &'a HashMap<FrameId, Frame>,
|
pub browsing_contexts: &'a HashMap<BrowsingContextId, BrowsingContext>,
|
||||||
|
|
||||||
/// The set of all pipelines. We use this to find the active
|
/// The set of all pipelines. We use this to find the active
|
||||||
/// children of a frame, which are the iframes in the currently
|
/// children of a frame, which are the iframes in the currently
|
||||||
|
@ -146,73 +146,73 @@ pub struct FrameTreeIterator<'a> {
|
||||||
pub pipelines: &'a HashMap<PipelineId, Pipeline>,
|
pub pipelines: &'a HashMap<PipelineId, Pipeline>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Iterator for FrameTreeIterator<'a> {
|
impl<'a> Iterator for FullyActiveBrowsingContextsIterator<'a> {
|
||||||
type Item = &'a Frame;
|
type Item = &'a BrowsingContext;
|
||||||
fn next(&mut self) -> Option<&'a Frame> {
|
fn next(&mut self) -> Option<&'a BrowsingContext> {
|
||||||
loop {
|
loop {
|
||||||
let frame_id = match self.stack.pop() {
|
let browsing_context_id = match self.stack.pop() {
|
||||||
Some(frame_id) => frame_id,
|
Some(browsing_context_id) => browsing_context_id,
|
||||||
None => return None,
|
None => return None,
|
||||||
};
|
};
|
||||||
let frame = match self.frames.get(&frame_id) {
|
let browsing_context = match self.browsing_contexts.get(&browsing_context_id) {
|
||||||
Some(frame) => frame,
|
Some(browsing_context) => browsing_context,
|
||||||
None => {
|
None => {
|
||||||
warn!("Frame {:?} iterated after closure.", frame_id);
|
warn!("BrowsingContext {:?} iterated after closure.", browsing_context_id);
|
||||||
continue;
|
continue;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
let pipeline = match self.pipelines.get(&frame.pipeline_id) {
|
let pipeline = match self.pipelines.get(&browsing_context.pipeline_id) {
|
||||||
Some(pipeline) => pipeline,
|
Some(pipeline) => pipeline,
|
||||||
None => {
|
None => {
|
||||||
warn!("Pipeline {:?} iterated after closure.", frame.pipeline_id);
|
warn!("Pipeline {:?} iterated after closure.", browsing_context.pipeline_id);
|
||||||
continue;
|
continue;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
self.stack.extend(pipeline.children.iter());
|
self.stack.extend(pipeline.children.iter());
|
||||||
return Some(frame)
|
return Some(browsing_context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An iterator over a frame tree, returning all frames in depth-first
|
/// An iterator over browsing contexts, returning all descendant
|
||||||
/// order. Note that this iterator returns all frames, not just the
|
/// contexts in depth-first order. Note that this iterator returns all
|
||||||
/// fully active ones.
|
/// contexts, not just the fully active ones.
|
||||||
pub struct FullFrameTreeIterator<'a> {
|
pub struct AllBrowsingContextsIterator<'a> {
|
||||||
/// The frames still to iterate over.
|
/// The browsing contexts still to iterate over.
|
||||||
pub stack: Vec<FrameId>,
|
pub stack: Vec<BrowsingContextId>,
|
||||||
|
|
||||||
/// The set of all frames.
|
/// The set of all browsing contexts.
|
||||||
pub frames: &'a HashMap<FrameId, Frame>,
|
pub browsing_contexts: &'a HashMap<BrowsingContextId, BrowsingContext>,
|
||||||
|
|
||||||
/// The set of all pipelines. We use this to find the
|
/// The set of all pipelines. We use this to find the
|
||||||
/// children of a frame, which are the iframes in all documents
|
/// children of a browsing context, which are the iframes in all documents
|
||||||
/// in the session history.
|
/// in the session history.
|
||||||
pub pipelines: &'a HashMap<PipelineId, Pipeline>,
|
pub pipelines: &'a HashMap<PipelineId, Pipeline>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Iterator for FullFrameTreeIterator<'a> {
|
impl<'a> Iterator for AllBrowsingContextsIterator<'a> {
|
||||||
type Item = &'a Frame;
|
type Item = &'a BrowsingContext;
|
||||||
fn next(&mut self) -> Option<&'a Frame> {
|
fn next(&mut self) -> Option<&'a BrowsingContext> {
|
||||||
let pipelines = self.pipelines;
|
let pipelines = self.pipelines;
|
||||||
loop {
|
loop {
|
||||||
let frame_id = match self.stack.pop() {
|
let browsing_context_id = match self.stack.pop() {
|
||||||
Some(frame_id) => frame_id,
|
Some(browsing_context_id) => browsing_context_id,
|
||||||
None => return None,
|
None => return None,
|
||||||
};
|
};
|
||||||
let frame = match self.frames.get(&frame_id) {
|
let browsing_context = match self.browsing_contexts.get(&browsing_context_id) {
|
||||||
Some(frame) => frame,
|
Some(browsing_context) => browsing_context,
|
||||||
None => {
|
None => {
|
||||||
warn!("Frame {:?} iterated after closure.", frame_id);
|
warn!("BrowsingContext {:?} iterated after closure.", browsing_context_id);
|
||||||
continue;
|
continue;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
let child_frame_ids = frame.prev.iter().chain(frame.next.iter())
|
let child_browsing_context_ids = browsing_context.prev.iter().chain(browsing_context.next.iter())
|
||||||
.filter_map(|entry| entry.pipeline_id)
|
.filter_map(|entry| entry.pipeline_id)
|
||||||
.chain(once(frame.pipeline_id))
|
.chain(once(browsing_context.pipeline_id))
|
||||||
.filter_map(|pipeline_id| pipelines.get(&pipeline_id))
|
.filter_map(|pipeline_id| pipelines.get(&pipeline_id))
|
||||||
.flat_map(|pipeline| pipeline.children.iter());
|
.flat_map(|pipeline| pipeline.children.iter());
|
||||||
self.stack.extend(child_frame_ids);
|
self.stack.extend(child_browsing_context_ids);
|
||||||
return Some(frame)
|
return Some(browsing_context)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
File diff suppressed because it is too large
Load diff
|
@ -41,9 +41,9 @@ extern crate style_traits;
|
||||||
extern crate webrender_traits;
|
extern crate webrender_traits;
|
||||||
extern crate webvr_traits;
|
extern crate webvr_traits;
|
||||||
|
|
||||||
|
mod browsingcontext;
|
||||||
mod constellation;
|
mod constellation;
|
||||||
mod event_loop;
|
mod event_loop;
|
||||||
mod frame;
|
|
||||||
mod pipeline;
|
mod pipeline;
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
mod sandboxing;
|
mod sandboxing;
|
||||||
|
|
|
@ -15,7 +15,7 @@ use ipc_channel::Error;
|
||||||
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
||||||
use ipc_channel::router::ROUTER;
|
use ipc_channel::router::ROUTER;
|
||||||
use layout_traits::LayoutThreadFactory;
|
use layout_traits::LayoutThreadFactory;
|
||||||
use msg::constellation_msg::{FrameId, FrameType, PipelineId, PipelineNamespaceId};
|
use msg::constellation_msg::{BrowsingContextId, FrameType, PipelineId, PipelineNamespaceId};
|
||||||
use net::image_cache::ImageCacheImpl;
|
use net::image_cache::ImageCacheImpl;
|
||||||
use net_traits::{IpcSend, ResourceThreads};
|
use net_traits::{IpcSend, ResourceThreads};
|
||||||
use net_traits::image_cache::ImageCache;
|
use net_traits::image_cache::ImageCache;
|
||||||
|
@ -49,14 +49,14 @@ pub struct Pipeline {
|
||||||
/// The ID of the pipeline.
|
/// The ID of the pipeline.
|
||||||
pub id: PipelineId,
|
pub id: PipelineId,
|
||||||
|
|
||||||
/// The ID of the frame that contains this Pipeline.
|
/// The ID of the browsing context that contains this Pipeline.
|
||||||
pub frame_id: FrameId,
|
pub browsing_context_id: BrowsingContextId,
|
||||||
|
|
||||||
/// The parent pipeline of this one. `None` if this is a root pipeline.
|
/// The parent pipeline of this one. `None` if this is a root pipeline.
|
||||||
/// Note that because of mozbrowser iframes, even top-level pipelines
|
/// Note that because of mozbrowser iframes, even top-level pipelines
|
||||||
/// may have a parent (in which case the frame type will be
|
/// may have a parent (in which case the frame type will be
|
||||||
/// `MozbrowserIFrame`).
|
/// `MozbrowserIFrame`).
|
||||||
/// TODO: move this field to `Frame`.
|
/// TODO: move this field to `BrowsingContext`.
|
||||||
pub parent_info: Option<(PipelineId, FrameType)>,
|
pub parent_info: Option<(PipelineId, FrameType)>,
|
||||||
|
|
||||||
/// The event loop handling this pipeline.
|
/// The event loop handling this pipeline.
|
||||||
|
@ -80,11 +80,11 @@ pub struct Pipeline {
|
||||||
/// animations cause composites to be continually scheduled.
|
/// animations cause composites to be continually scheduled.
|
||||||
pub running_animations: bool,
|
pub running_animations: bool,
|
||||||
|
|
||||||
/// The child frames of this pipeline (these are iframes in the document).
|
/// The child browsing contexts of this pipeline (these are iframes in the document).
|
||||||
pub children: Vec<FrameId>,
|
pub children: Vec<BrowsingContextId>,
|
||||||
|
|
||||||
/// Whether this pipeline is in private browsing mode.
|
/// Whether this pipeline is in private browsing mode.
|
||||||
/// TODO: move this field to `Frame`.
|
/// TODO: move this field to `BrowsingContext`.
|
||||||
pub is_private: bool,
|
pub is_private: bool,
|
||||||
|
|
||||||
/// Whether this pipeline should be treated as visible for the purposes of scheduling and
|
/// Whether this pipeline should be treated as visible for the purposes of scheduling and
|
||||||
|
@ -100,11 +100,11 @@ pub struct InitialPipelineState {
|
||||||
/// The ID of the pipeline to create.
|
/// The ID of the pipeline to create.
|
||||||
pub id: PipelineId,
|
pub id: PipelineId,
|
||||||
|
|
||||||
/// The ID of the frame that contains this Pipeline.
|
/// The ID of the browsing context that contains this Pipeline.
|
||||||
pub frame_id: FrameId,
|
pub browsing_context_id: BrowsingContextId,
|
||||||
|
|
||||||
/// The ID of the top-level frame that contains this Pipeline.
|
/// The ID of the top-level browsing context that contains this Pipeline.
|
||||||
pub top_level_frame_id: FrameId,
|
pub top_level_browsing_context_id: BrowsingContextId,
|
||||||
|
|
||||||
/// The ID of the parent pipeline and frame type, if any.
|
/// The ID of the parent pipeline and frame type, if any.
|
||||||
/// If `None`, this is the root.
|
/// If `None`, this is the root.
|
||||||
|
@ -200,7 +200,7 @@ impl Pipeline {
|
||||||
let new_layout_info = NewLayoutInfo {
|
let new_layout_info = NewLayoutInfo {
|
||||||
parent_info: state.parent_info,
|
parent_info: state.parent_info,
|
||||||
new_pipeline_id: state.id,
|
new_pipeline_id: state.id,
|
||||||
frame_id: state.frame_id,
|
browsing_context_id: state.browsing_context_id,
|
||||||
load_data: state.load_data,
|
load_data: state.load_data,
|
||||||
window_size: window_size,
|
window_size: window_size,
|
||||||
pipeline_port: pipeline_port,
|
pipeline_port: pipeline_port,
|
||||||
|
@ -237,8 +237,8 @@ impl Pipeline {
|
||||||
|
|
||||||
let unprivileged_pipeline_content = UnprivilegedPipelineContent {
|
let unprivileged_pipeline_content = UnprivilegedPipelineContent {
|
||||||
id: state.id,
|
id: state.id,
|
||||||
frame_id: state.frame_id,
|
browsing_context_id: state.browsing_context_id,
|
||||||
top_level_frame_id: state.top_level_frame_id,
|
top_level_browsing_context_id: state.top_level_browsing_context_id,
|
||||||
parent_info: state.parent_info,
|
parent_info: state.parent_info,
|
||||||
constellation_chan: state.constellation_chan,
|
constellation_chan: state.constellation_chan,
|
||||||
scheduler_chan: state.scheduler_chan,
|
scheduler_chan: state.scheduler_chan,
|
||||||
|
@ -280,7 +280,7 @@ impl Pipeline {
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(Pipeline::new(state.id,
|
Ok(Pipeline::new(state.id,
|
||||||
state.frame_id,
|
state.browsing_context_id,
|
||||||
state.parent_info,
|
state.parent_info,
|
||||||
script_chan,
|
script_chan,
|
||||||
pipeline_chan,
|
pipeline_chan,
|
||||||
|
@ -293,7 +293,7 @@ impl Pipeline {
|
||||||
/// Creates a new `Pipeline`, after the script and layout threads have been
|
/// Creates a new `Pipeline`, after the script and layout threads have been
|
||||||
/// spawned.
|
/// spawned.
|
||||||
pub fn new(id: PipelineId,
|
pub fn new(id: PipelineId,
|
||||||
frame_id: FrameId,
|
browsing_context_id: BrowsingContextId,
|
||||||
parent_info: Option<(PipelineId, FrameType)>,
|
parent_info: Option<(PipelineId, FrameType)>,
|
||||||
event_loop: Rc<EventLoop>,
|
event_loop: Rc<EventLoop>,
|
||||||
layout_chan: IpcSender<LayoutControlMsg>,
|
layout_chan: IpcSender<LayoutControlMsg>,
|
||||||
|
@ -304,7 +304,7 @@ impl Pipeline {
|
||||||
-> Pipeline {
|
-> Pipeline {
|
||||||
let pipeline = Pipeline {
|
let pipeline = Pipeline {
|
||||||
id: id,
|
id: id,
|
||||||
frame_id: frame_id,
|
browsing_context_id: browsing_context_id,
|
||||||
parent_info: parent_info,
|
parent_info: parent_info,
|
||||||
event_loop: event_loop,
|
event_loop: event_loop,
|
||||||
layout_chan: layout_chan,
|
layout_chan: layout_chan,
|
||||||
|
@ -376,15 +376,15 @@ impl Pipeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add a new child frame.
|
/// Add a new child browsing context.
|
||||||
pub fn add_child(&mut self, frame_id: FrameId) {
|
pub fn add_child(&mut self, browsing_context_id: BrowsingContextId) {
|
||||||
self.children.push(frame_id);
|
self.children.push(browsing_context_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Remove a child frame.
|
/// Remove a child browsing context.
|
||||||
pub fn remove_child(&mut self, frame_id: FrameId) {
|
pub fn remove_child(&mut self, browsing_context_id: BrowsingContextId) {
|
||||||
match self.children.iter().position(|id| *id == frame_id) {
|
match self.children.iter().position(|id| *id == browsing_context_id) {
|
||||||
None => return warn!("Pipeline remove child already removed ({:?}).", frame_id),
|
None => return warn!("Pipeline remove child already removed ({:?}).", browsing_context_id),
|
||||||
Some(index) => self.children.remove(index),
|
Some(index) => self.children.remove(index),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -393,7 +393,7 @@ impl Pipeline {
|
||||||
/// This will cause an event to be fired on an iframe in the document,
|
/// This will cause an event to be fired on an iframe in the document,
|
||||||
/// or on the `Window` if no frame is given.
|
/// or on the `Window` if no frame is given.
|
||||||
pub fn trigger_mozbrowser_event(&self,
|
pub fn trigger_mozbrowser_event(&self,
|
||||||
child_id: Option<FrameId>,
|
child_id: Option<BrowsingContextId>,
|
||||||
event: MozBrowserEvent) {
|
event: MozBrowserEvent) {
|
||||||
assert!(PREFS.is_mozbrowser_enabled());
|
assert!(PREFS.is_mozbrowser_enabled());
|
||||||
|
|
||||||
|
@ -433,8 +433,8 @@ impl Pipeline {
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
pub struct UnprivilegedPipelineContent {
|
pub struct UnprivilegedPipelineContent {
|
||||||
id: PipelineId,
|
id: PipelineId,
|
||||||
frame_id: FrameId,
|
browsing_context_id: BrowsingContextId,
|
||||||
top_level_frame_id: FrameId,
|
top_level_browsing_context_id: BrowsingContextId,
|
||||||
parent_info: Option<(PipelineId, FrameType)>,
|
parent_info: Option<(PipelineId, FrameType)>,
|
||||||
constellation_chan: IpcSender<ScriptMsg>,
|
constellation_chan: IpcSender<ScriptMsg>,
|
||||||
layout_to_constellation_chan: IpcSender<LayoutMsg>,
|
layout_to_constellation_chan: IpcSender<LayoutMsg>,
|
||||||
|
@ -470,8 +470,8 @@ impl UnprivilegedPipelineContent {
|
||||||
let image_cache = Arc::new(ImageCacheImpl::new(self.webrender_api_sender.create_api()));
|
let image_cache = Arc::new(ImageCacheImpl::new(self.webrender_api_sender.create_api()));
|
||||||
let layout_pair = STF::create(InitialScriptState {
|
let layout_pair = STF::create(InitialScriptState {
|
||||||
id: self.id,
|
id: self.id,
|
||||||
frame_id: self.frame_id,
|
browsing_context_id: self.browsing_context_id,
|
||||||
top_level_frame_id: self.top_level_frame_id,
|
top_level_browsing_context_id: self.top_level_browsing_context_id,
|
||||||
parent_info: self.parent_info,
|
parent_info: self.parent_info,
|
||||||
control_chan: self.script_chan.clone(),
|
control_chan: self.script_chan.clone(),
|
||||||
control_port: self.script_port,
|
control_port: self.script_port,
|
||||||
|
@ -491,7 +491,7 @@ impl UnprivilegedPipelineContent {
|
||||||
}, self.load_data.clone());
|
}, self.load_data.clone());
|
||||||
|
|
||||||
LTF::create(self.id,
|
LTF::create(self.id,
|
||||||
Some(self.top_level_frame_id),
|
Some(self.top_level_browsing_context_id),
|
||||||
self.load_data.url,
|
self.load_data.url,
|
||||||
self.parent_info.is_some(),
|
self.parent_info.is_some(),
|
||||||
layout_pair,
|
layout_pair,
|
||||||
|
|
|
@ -34,7 +34,7 @@ use inline::{FIRST_FRAGMENT_OF_ELEMENT, InlineFlow, LAST_FRAGMENT_OF_ELEMENT};
|
||||||
use ipc_channel::ipc;
|
use ipc_channel::ipc;
|
||||||
use list_item::ListItemFlow;
|
use list_item::ListItemFlow;
|
||||||
use model::{self, MaybeAuto, specified};
|
use model::{self, MaybeAuto, specified};
|
||||||
use msg::constellation_msg::FrameId;
|
use msg::constellation_msg::BrowsingContextId;
|
||||||
use net_traits::image::base::PixelFormat;
|
use net_traits::image::base::PixelFormat;
|
||||||
use net_traits::image_cache::UsePlaceholder;
|
use net_traits::image_cache::UsePlaceholder;
|
||||||
use range::Range;
|
use range::Range;
|
||||||
|
@ -175,7 +175,7 @@ pub struct DisplayListBuildState<'a> {
|
||||||
|
|
||||||
/// Vector containing iframe sizes, used to inform the constellation about
|
/// Vector containing iframe sizes, used to inform the constellation about
|
||||||
/// new iframe sizes
|
/// new iframe sizes
|
||||||
pub iframe_sizes: Vec<(FrameId, TypedSize2D<f32, CSSPixel>)>,
|
pub iframe_sizes: Vec<(BrowsingContextId, TypedSize2D<f32, CSSPixel>)>,
|
||||||
|
|
||||||
/// A stack of clips used to cull display list entries that are outside the
|
/// A stack of clips used to cull display list entries that are outside the
|
||||||
/// rendered region.
|
/// rendered region.
|
||||||
|
@ -1823,7 +1823,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
|
|
||||||
let size = Size2D::new(item.bounds().size.width.to_f32_px(),
|
let size = Size2D::new(item.bounds().size.width.to_f32_px(),
|
||||||
item.bounds().size.height.to_f32_px());
|
item.bounds().size.height.to_f32_px());
|
||||||
state.iframe_sizes.push((fragment_info.frame_id, TypedSize2D::from_untyped(&size)));
|
state.iframe_sizes.push((fragment_info.browsing_context_id, TypedSize2D::from_untyped(&size)));
|
||||||
|
|
||||||
state.add_display_item(item);
|
state.add_display_item(item);
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ use ipc_channel::ipc::IpcSender;
|
||||||
use layout_debug;
|
use layout_debug;
|
||||||
use model::{self, IntrinsicISizes, IntrinsicISizesContribution, MaybeAuto, SizeConstraint};
|
use model::{self, IntrinsicISizes, IntrinsicISizesContribution, MaybeAuto, SizeConstraint};
|
||||||
use model::{style_length, ToGfxMatrix};
|
use model::{style_length, ToGfxMatrix};
|
||||||
use msg::constellation_msg::{FrameId, PipelineId};
|
use msg::constellation_msg::{BrowsingContextId, PipelineId};
|
||||||
use net_traits::image::base::{Image, ImageMetadata};
|
use net_traits::image::base::{Image, ImageMetadata};
|
||||||
use net_traits::image_cache::{ImageOrMetadataAvailable, UsePlaceholder};
|
use net_traits::image_cache::{ImageOrMetadataAvailable, UsePlaceholder};
|
||||||
use range::*;
|
use range::*;
|
||||||
|
@ -472,7 +472,7 @@ impl ImageFragmentInfo {
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct IframeFragmentInfo {
|
pub struct IframeFragmentInfo {
|
||||||
/// The frame ID of this iframe.
|
/// The frame ID of this iframe.
|
||||||
pub frame_id: FrameId,
|
pub browsing_context_id: BrowsingContextId,
|
||||||
/// The pipelineID of this iframe.
|
/// The pipelineID of this iframe.
|
||||||
pub pipeline_id: PipelineId,
|
pub pipeline_id: PipelineId,
|
||||||
}
|
}
|
||||||
|
@ -480,10 +480,10 @@ pub struct IframeFragmentInfo {
|
||||||
impl IframeFragmentInfo {
|
impl IframeFragmentInfo {
|
||||||
/// Creates the information specific to an iframe fragment.
|
/// Creates the information specific to an iframe fragment.
|
||||||
pub fn new<N: ThreadSafeLayoutNode>(node: &N) -> IframeFragmentInfo {
|
pub fn new<N: ThreadSafeLayoutNode>(node: &N) -> IframeFragmentInfo {
|
||||||
let frame_id = node.iframe_frame_id();
|
let browsing_context_id = node.iframe_browsing_context_id();
|
||||||
let pipeline_id = node.iframe_pipeline_id();
|
let pipeline_id = node.iframe_pipeline_id();
|
||||||
IframeFragmentInfo {
|
IframeFragmentInfo {
|
||||||
frame_id: frame_id,
|
browsing_context_id: browsing_context_id,
|
||||||
pipeline_id: pipeline_id,
|
pipeline_id: pipeline_id,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ use layout::webrender_helpers::WebRenderDisplayListConverter;
|
||||||
use layout::wrapper::LayoutNodeLayoutData;
|
use layout::wrapper::LayoutNodeLayoutData;
|
||||||
use layout::wrapper::drop_style_and_layout_data;
|
use layout::wrapper::drop_style_and_layout_data;
|
||||||
use layout_traits::LayoutThreadFactory;
|
use layout_traits::LayoutThreadFactory;
|
||||||
use msg::constellation_msg::{FrameId, PipelineId};
|
use msg::constellation_msg::{BrowsingContextId, PipelineId};
|
||||||
use net_traits::image_cache::{ImageCache, UsePlaceholder};
|
use net_traits::image_cache::{ImageCache, UsePlaceholder};
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use profile_traits::mem::{self, Report, ReportKind, ReportsChan};
|
use profile_traits::mem::{self, Report, ReportKind, ReportsChan};
|
||||||
|
@ -244,7 +244,7 @@ impl LayoutThreadFactory for LayoutThread {
|
||||||
|
|
||||||
/// Spawns a new layout thread.
|
/// Spawns a new layout thread.
|
||||||
fn create(id: PipelineId,
|
fn create(id: PipelineId,
|
||||||
top_level_frame_id: Option<FrameId>,
|
top_level_browsing_context_id: Option<BrowsingContextId>,
|
||||||
url: ServoUrl,
|
url: ServoUrl,
|
||||||
is_iframe: bool,
|
is_iframe: bool,
|
||||||
chan: (Sender<Msg>, Receiver<Msg>),
|
chan: (Sender<Msg>, Receiver<Msg>),
|
||||||
|
@ -261,8 +261,8 @@ impl LayoutThreadFactory for LayoutThread {
|
||||||
thread::Builder::new().name(format!("LayoutThread {:?}", id)).spawn(move || {
|
thread::Builder::new().name(format!("LayoutThread {:?}", id)).spawn(move || {
|
||||||
thread_state::initialize(thread_state::LAYOUT);
|
thread_state::initialize(thread_state::LAYOUT);
|
||||||
|
|
||||||
if let Some(top_level_frame_id) = top_level_frame_id {
|
if let Some(top_level_browsing_context_id) = top_level_browsing_context_id {
|
||||||
FrameId::install(top_level_frame_id);
|
BrowsingContextId::install(top_level_browsing_context_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // Ensures layout thread is destroyed before we send shutdown message
|
{ // Ensures layout thread is destroyed before we send shutdown message
|
||||||
|
@ -730,7 +730,7 @@ impl LayoutThread {
|
||||||
|
|
||||||
fn create_layout_thread(&self, info: NewLayoutThreadInfo) {
|
fn create_layout_thread(&self, info: NewLayoutThreadInfo) {
|
||||||
LayoutThread::create(info.id,
|
LayoutThread::create(info.id,
|
||||||
FrameId::installed(),
|
BrowsingContextId::installed(),
|
||||||
info.url.clone(),
|
info.url.clone(),
|
||||||
info.is_parent,
|
info.is_parent,
|
||||||
info.layout_pair,
|
info.layout_pair,
|
||||||
|
@ -928,7 +928,7 @@ impl LayoutThread {
|
||||||
// build_state.iframe_sizes is only used here, so its okay to replace
|
// build_state.iframe_sizes is only used here, so its okay to replace
|
||||||
// it with an empty vector
|
// it with an empty vector
|
||||||
let iframe_sizes = std::mem::replace(&mut build_state.iframe_sizes, vec![]);
|
let iframe_sizes = std::mem::replace(&mut build_state.iframe_sizes, vec![]);
|
||||||
let msg = ConstellationMsg::FrameSizes(iframe_sizes);
|
let msg = ConstellationMsg::IFrameSizes(iframe_sizes);
|
||||||
if let Err(e) = self.constellation_chan.send(msg) {
|
if let Err(e) = self.constellation_chan.send(msg) {
|
||||||
warn!("Layout resize to constellation failed ({}).", e);
|
warn!("Layout resize to constellation failed ({}).", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ extern crate webrender_traits;
|
||||||
|
|
||||||
use gfx::font_cache_thread::FontCacheThread;
|
use gfx::font_cache_thread::FontCacheThread;
|
||||||
use ipc_channel::ipc::{IpcReceiver, IpcSender};
|
use ipc_channel::ipc::{IpcReceiver, IpcSender};
|
||||||
use msg::constellation_msg::{FrameId, PipelineId};
|
use msg::constellation_msg::{BrowsingContextId, PipelineId};
|
||||||
use net_traits::image_cache::ImageCache;
|
use net_traits::image_cache::ImageCache;
|
||||||
use profile_traits::{mem, time};
|
use profile_traits::{mem, time};
|
||||||
use script_traits::{ConstellationControlMsg, LayoutControlMsg};
|
use script_traits::{ConstellationControlMsg, LayoutControlMsg};
|
||||||
|
@ -34,7 +34,7 @@ use std::sync::mpsc::{Receiver, Sender};
|
||||||
pub trait LayoutThreadFactory {
|
pub trait LayoutThreadFactory {
|
||||||
type Message;
|
type Message;
|
||||||
fn create(id: PipelineId,
|
fn create(id: PipelineId,
|
||||||
top_level_frame_id: Option<FrameId>,
|
top_level_browsing_context_id: Option<BrowsingContextId>,
|
||||||
url: ServoUrl,
|
url: ServoUrl,
|
||||||
is_iframe: bool,
|
is_iframe: bool,
|
||||||
chan: (Sender<Self::Message>, Receiver<Self::Message>),
|
chan: (Sender<Self::Message>, Receiver<Self::Message>),
|
||||||
|
|
|
@ -207,10 +207,10 @@ impl PipelineNamespace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn next_frame_id(&mut self) -> FrameId {
|
fn next_browsing_context_id(&mut self) -> BrowsingContextId {
|
||||||
FrameId {
|
BrowsingContextId {
|
||||||
namespace_id: self.id,
|
namespace_id: self.id,
|
||||||
index: FrameIndex(self.next_index()),
|
index: BrowsingContextIndex(self.next_index()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -258,42 +258,41 @@ impl fmt::Display for PipelineId {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
thread_local!(pub static TOP_LEVEL_FRAME_ID: Cell<Option<FrameId>> = Cell::new(None));
|
thread_local!(pub static TOP_LEVEL_BROWSING_CONTEXT_ID: Cell<Option<BrowsingContextId>> = Cell::new(None));
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Copy, Hash, Debug, Deserialize, Serialize, HeapSizeOf)]
|
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Copy, Hash, Debug, Deserialize, Serialize, HeapSizeOf)]
|
||||||
pub struct FrameIndex(pub u32);
|
pub struct BrowsingContextIndex(pub u32);
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Copy, Hash, Debug, Deserialize, Serialize, HeapSizeOf)]
|
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Copy, Hash, Debug, Deserialize, Serialize, HeapSizeOf)]
|
||||||
pub struct FrameId {
|
pub struct BrowsingContextId {
|
||||||
pub namespace_id: PipelineNamespaceId,
|
pub namespace_id: PipelineNamespaceId,
|
||||||
pub index: FrameIndex
|
pub index: BrowsingContextIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FrameId {
|
impl BrowsingContextId {
|
||||||
pub fn new() -> FrameId {
|
pub fn new() -> BrowsingContextId {
|
||||||
PIPELINE_NAMESPACE.with(|tls| {
|
PIPELINE_NAMESPACE.with(|tls| {
|
||||||
let mut namespace = tls.get().expect("No namespace set for this thread!");
|
let mut namespace = tls.get().expect("No namespace set for this thread!");
|
||||||
let new_frame_id = namespace.next_frame_id();
|
let new_browsing_context_id = namespace.next_browsing_context_id();
|
||||||
tls.set(Some(namespace));
|
tls.set(Some(namespace));
|
||||||
new_frame_id
|
new_browsing_context_id
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
/// Each script and layout thread should have the top-level browsing context id installed,
|
||||||
/// Each script and layout thread should have the top-level frame id installed,
|
|
||||||
/// since it is used by crash reporting.
|
/// since it is used by crash reporting.
|
||||||
pub fn install(id: FrameId) {
|
pub fn install(id: BrowsingContextId) {
|
||||||
TOP_LEVEL_FRAME_ID.with(|tls| tls.set(Some(id)))
|
TOP_LEVEL_BROWSING_CONTEXT_ID.with(|tls| tls.set(Some(id)))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn installed() -> Option<FrameId> {
|
pub fn installed() -> Option<BrowsingContextId> {
|
||||||
TOP_LEVEL_FRAME_ID.with(|tls| tls.get())
|
TOP_LEVEL_BROWSING_CONTEXT_ID.with(|tls| tls.get())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for FrameId {
|
impl fmt::Display for BrowsingContextId {
|
||||||
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||||
let PipelineNamespaceId(namespace_id) = self.namespace_id;
|
let PipelineNamespaceId(namespace_id) = self.namespace_id;
|
||||||
let FrameIndex(index) = self.index;
|
let BrowsingContextIndex(index) = self.index;
|
||||||
write!(fmt, "({},{})", namespace_id, index)
|
write!(fmt, "({},{})", namespace_id, index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -302,8 +301,9 @@ impl fmt::Display for FrameId {
|
||||||
pub const TEST_NAMESPACE: PipelineNamespaceId = PipelineNamespaceId(1234);
|
pub const TEST_NAMESPACE: PipelineNamespaceId = PipelineNamespaceId(1234);
|
||||||
pub const TEST_PIPELINE_INDEX: PipelineIndex = PipelineIndex(5678);
|
pub const TEST_PIPELINE_INDEX: PipelineIndex = PipelineIndex(5678);
|
||||||
pub const TEST_PIPELINE_ID: PipelineId = PipelineId { namespace_id: TEST_NAMESPACE, index: TEST_PIPELINE_INDEX };
|
pub const TEST_PIPELINE_ID: PipelineId = PipelineId { namespace_id: TEST_NAMESPACE, index: TEST_PIPELINE_INDEX };
|
||||||
pub const TEST_FRAME_INDEX: FrameIndex = FrameIndex(8765);
|
pub const TEST_BROWSING_CONTEXT_INDEX: BrowsingContextIndex = BrowsingContextIndex(8765);
|
||||||
pub const TEST_FRAME_ID: FrameId = FrameId { namespace_id: TEST_NAMESPACE, index: TEST_FRAME_INDEX };
|
pub const TEST_BROWSING_CONTEXT_ID: BrowsingContextId =
|
||||||
|
BrowsingContextId { namespace_id: TEST_NAMESPACE, index: TEST_BROWSING_CONTEXT_INDEX };
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Eq, Copy, Hash, Debug, Deserialize, Serialize, HeapSizeOf)]
|
#[derive(Clone, PartialEq, Eq, Copy, Hash, Debug, Deserialize, Serialize, HeapSizeOf)]
|
||||||
pub enum FrameType {
|
pub enum FrameType {
|
||||||
|
|
|
@ -58,7 +58,7 @@ use js::glue::{CallObjectTracer, CallValueTracer};
|
||||||
use js::jsapi::{GCTraceKindToAscii, Heap, JSObject, JSTracer, TraceKind};
|
use js::jsapi::{GCTraceKindToAscii, Heap, JSObject, JSTracer, TraceKind};
|
||||||
use js::jsval::JSVal;
|
use js::jsval::JSVal;
|
||||||
use js::rust::Runtime;
|
use js::rust::Runtime;
|
||||||
use msg::constellation_msg::{FrameId, FrameType, PipelineId};
|
use msg::constellation_msg::{BrowsingContextId, FrameType, PipelineId};
|
||||||
use net_traits::{Metadata, NetworkError, ReferrerPolicy, ResourceThreads};
|
use net_traits::{Metadata, NetworkError, ReferrerPolicy, ResourceThreads};
|
||||||
use net_traits::filemanager_thread::RelativePos;
|
use net_traits::filemanager_thread::RelativePos;
|
||||||
use net_traits::image::base::{Image, ImageMetadata};
|
use net_traits::image::base::{Image, ImageMetadata};
|
||||||
|
@ -336,7 +336,7 @@ unsafe_no_jsmanaged_fields!(TrustedPromise);
|
||||||
unsafe_no_jsmanaged_fields!(PropertyDeclarationBlock);
|
unsafe_no_jsmanaged_fields!(PropertyDeclarationBlock);
|
||||||
// These three are interdependent, if you plan to put jsmanaged data
|
// These three are interdependent, if you plan to put jsmanaged data
|
||||||
// in one of these make sure it is propagated properly to containing structs
|
// in one of these make sure it is propagated properly to containing structs
|
||||||
unsafe_no_jsmanaged_fields!(DocumentActivity, FrameId, FrameType, WindowSizeData, WindowSizeType, PipelineId);
|
unsafe_no_jsmanaged_fields!(DocumentActivity, BrowsingContextId, FrameType, WindowSizeData, WindowSizeType, PipelineId);
|
||||||
unsafe_no_jsmanaged_fields!(TimerEventId, TimerSource);
|
unsafe_no_jsmanaged_fields!(TimerEventId, TimerSource);
|
||||||
unsafe_no_jsmanaged_fields!(TimelineMarkerType);
|
unsafe_no_jsmanaged_fields!(TimelineMarkerType);
|
||||||
unsafe_no_jsmanaged_fields!(WorkerId);
|
unsafe_no_jsmanaged_fields!(WorkerId);
|
||||||
|
|
|
@ -27,7 +27,7 @@ use js::jsapi::{HandleValue, JS_SetInterruptCallback};
|
||||||
use js::jsapi::{JSAutoCompartment, JSContext};
|
use js::jsapi::{JSAutoCompartment, JSContext};
|
||||||
use js::jsval::UndefinedValue;
|
use js::jsval::UndefinedValue;
|
||||||
use js::rust::Runtime;
|
use js::rust::Runtime;
|
||||||
use msg::constellation_msg::FrameId;
|
use msg::constellation_msg::BrowsingContextId;
|
||||||
use net_traits::{IpcSend, load_whole_resource};
|
use net_traits::{IpcSend, load_whole_resource};
|
||||||
use net_traits::request::{CredentialsMode, Destination, RequestInit, Type as RequestType};
|
use net_traits::request::{CredentialsMode, Destination, RequestInit, Type as RequestType};
|
||||||
use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort, StackRootTLS, get_reports, new_rt_and_cx};
|
use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort, StackRootTLS, get_reports, new_rt_and_cx};
|
||||||
|
@ -159,13 +159,13 @@ impl DedicatedWorkerGlobalScope {
|
||||||
closing: Arc<AtomicBool>) {
|
closing: Arc<AtomicBool>) {
|
||||||
let serialized_worker_url = worker_url.to_string();
|
let serialized_worker_url = worker_url.to_string();
|
||||||
let name = format!("WebWorker for {}", serialized_worker_url);
|
let name = format!("WebWorker for {}", serialized_worker_url);
|
||||||
let top_level_frame_id = FrameId::installed();
|
let top_level_browsing_context_id = BrowsingContextId::installed();
|
||||||
|
|
||||||
thread::Builder::new().name(name).spawn(move || {
|
thread::Builder::new().name(name).spawn(move || {
|
||||||
thread_state::initialize(thread_state::SCRIPT | thread_state::IN_WORKER);
|
thread_state::initialize(thread_state::SCRIPT | thread_state::IN_WORKER);
|
||||||
|
|
||||||
if let Some(top_level_frame_id) = top_level_frame_id {
|
if let Some(top_level_browsing_context_id) = top_level_browsing_context_id {
|
||||||
FrameId::install(top_level_frame_id);
|
BrowsingContextId::install(top_level_browsing_context_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
let roots = RootCollection::new();
|
let roots = RootCollection::new();
|
||||||
|
|
|
@ -184,7 +184,9 @@ impl DissimilarOriginWindowMethods for DissimilarOriginWindow {
|
||||||
|
|
||||||
impl DissimilarOriginWindow {
|
impl DissimilarOriginWindow {
|
||||||
pub fn post_message(&self, origin: Option<ImmutableOrigin>, data: StructuredCloneData) {
|
pub fn post_message(&self, origin: Option<ImmutableOrigin>, data: StructuredCloneData) {
|
||||||
let msg = ConstellationMsg::PostMessage(self.window_proxy.frame_id(), origin, data.move_to_arraybuffer());
|
let msg = ConstellationMsg::PostMessage(self.window_proxy.browsing_context_id(),
|
||||||
|
origin,
|
||||||
|
data.move_to_arraybuffer());
|
||||||
let _ = self.upcast::<GlobalScope>().constellation_chan().send(msg);
|
let _ = self.upcast::<GlobalScope>().constellation_chan().send(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ use ipc_channel::ipc::{self, IpcSender};
|
||||||
use js::jsapi::{JSContext, JSObject, JSRuntime};
|
use js::jsapi::{JSContext, JSObject, JSRuntime};
|
||||||
use js::jsapi::JS_GetRuntime;
|
use js::jsapi::JS_GetRuntime;
|
||||||
use msg::constellation_msg::{ALT, CONTROL, SHIFT, SUPER};
|
use msg::constellation_msg::{ALT, CONTROL, SHIFT, SUPER};
|
||||||
use msg::constellation_msg::{FrameId, Key, KeyModifiers, KeyState};
|
use msg::constellation_msg::{BrowsingContextId, Key, KeyModifiers, KeyState};
|
||||||
use net_traits::{FetchResponseMsg, IpcSend, ReferrerPolicy};
|
use net_traits::{FetchResponseMsg, IpcSend, ReferrerPolicy};
|
||||||
use net_traits::CookieSource::NonHTTP;
|
use net_traits::CookieSource::NonHTTP;
|
||||||
use net_traits::CoreResourceMsg::{GetCookiesForUrl, SetCookiesForUrl};
|
use net_traits::CoreResourceMsg::{GetCookiesForUrl, SetCookiesForUrl};
|
||||||
|
@ -1897,9 +1897,9 @@ impl Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Find an iframe element in the document.
|
/// Find an iframe element in the document.
|
||||||
pub fn find_iframe(&self, frame_id: FrameId) -> Option<Root<HTMLIFrameElement>> {
|
pub fn find_iframe(&self, browsing_context_id: BrowsingContextId) -> Option<Root<HTMLIFrameElement>> {
|
||||||
self.iter_iframes()
|
self.iter_iframes()
|
||||||
.find(|node| node.frame_id() == frame_id)
|
.find(|node| node.browsing_context_id() == browsing_context_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_dom_loading(&self) -> u64 {
|
pub fn get_dom_loading(&self) -> u64 {
|
||||||
|
|
|
@ -40,7 +40,7 @@ use html5ever::{LocalName, Prefix};
|
||||||
use ipc_channel::ipc;
|
use ipc_channel::ipc;
|
||||||
use js::jsapi::{JSAutoCompartment, JSContext, MutableHandleValue};
|
use js::jsapi::{JSAutoCompartment, JSContext, MutableHandleValue};
|
||||||
use js::jsval::{NullValue, UndefinedValue};
|
use js::jsval::{NullValue, UndefinedValue};
|
||||||
use msg::constellation_msg::{FrameType, FrameId, PipelineId, TraversalDirection};
|
use msg::constellation_msg::{FrameType, BrowsingContextId, PipelineId, TraversalDirection};
|
||||||
use net_traits::response::HttpsState;
|
use net_traits::response::HttpsState;
|
||||||
use script_layout_interface::message::ReflowQueryType;
|
use script_layout_interface::message::ReflowQueryType;
|
||||||
use script_thread::{ScriptThread, Runnable};
|
use script_thread::{ScriptThread, Runnable};
|
||||||
|
@ -84,7 +84,7 @@ enum ProcessingMode {
|
||||||
#[dom_struct]
|
#[dom_struct]
|
||||||
pub struct HTMLIFrameElement {
|
pub struct HTMLIFrameElement {
|
||||||
htmlelement: HTMLElement,
|
htmlelement: HTMLElement,
|
||||||
frame_id: FrameId,
|
browsing_context_id: BrowsingContextId,
|
||||||
pipeline_id: Cell<Option<PipelineId>>,
|
pipeline_id: Cell<Option<PipelineId>>,
|
||||||
pending_pipeline_id: Cell<Option<PipelineId>>,
|
pending_pipeline_id: Cell<Option<PipelineId>>,
|
||||||
sandbox: MutNullableJS<DOMTokenList>,
|
sandbox: MutNullableJS<DOMTokenList>,
|
||||||
|
@ -115,7 +115,7 @@ impl HTMLIFrameElement {
|
||||||
pub fn generate_new_pipeline_id(&self) -> (Option<PipelineId>, PipelineId) {
|
pub fn generate_new_pipeline_id(&self) -> (Option<PipelineId>, PipelineId) {
|
||||||
let old_pipeline_id = self.pipeline_id.get();
|
let old_pipeline_id = self.pipeline_id.get();
|
||||||
let new_pipeline_id = PipelineId::new();
|
let new_pipeline_id = PipelineId::new();
|
||||||
debug!("Frame {} created pipeline {}.", self.frame_id, new_pipeline_id);
|
debug!("Frame {} created pipeline {}.", self.browsing_context_id, new_pipeline_id);
|
||||||
(old_pipeline_id, new_pipeline_id)
|
(old_pipeline_id, new_pipeline_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ impl HTMLIFrameElement {
|
||||||
let global_scope = window.upcast::<GlobalScope>();
|
let global_scope = window.upcast::<GlobalScope>();
|
||||||
let load_info = IFrameLoadInfo {
|
let load_info = IFrameLoadInfo {
|
||||||
parent_pipeline_id: global_scope.pipeline_id(),
|
parent_pipeline_id: global_scope.pipeline_id(),
|
||||||
frame_id: self.frame_id,
|
browsing_context_id: self.browsing_context_id,
|
||||||
new_pipeline_id: new_pipeline_id,
|
new_pipeline_id: new_pipeline_id,
|
||||||
is_private: private_iframe,
|
is_private: private_iframe,
|
||||||
frame_type: frame_type,
|
frame_type: frame_type,
|
||||||
|
@ -171,7 +171,7 @@ impl HTMLIFrameElement {
|
||||||
let new_layout_info = NewLayoutInfo {
|
let new_layout_info = NewLayoutInfo {
|
||||||
parent_info: Some((global_scope.pipeline_id(), frame_type)),
|
parent_info: Some((global_scope.pipeline_id(), frame_type)),
|
||||||
new_pipeline_id: new_pipeline_id,
|
new_pipeline_id: new_pipeline_id,
|
||||||
frame_id: self.frame_id,
|
browsing_context_id: self.browsing_context_id,
|
||||||
load_data: load_data.unwrap(),
|
load_data: load_data.unwrap(),
|
||||||
pipeline_port: pipeline_receiver,
|
pipeline_port: pipeline_receiver,
|
||||||
content_process_shutdown_chan: None,
|
content_process_shutdown_chan: None,
|
||||||
|
@ -277,7 +277,7 @@ impl HTMLIFrameElement {
|
||||||
document: &Document) -> HTMLIFrameElement {
|
document: &Document) -> HTMLIFrameElement {
|
||||||
HTMLIFrameElement {
|
HTMLIFrameElement {
|
||||||
htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
|
htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
|
||||||
frame_id: FrameId::new(),
|
browsing_context_id: BrowsingContextId::new(),
|
||||||
pipeline_id: Cell::new(None),
|
pipeline_id: Cell::new(None),
|
||||||
pending_pipeline_id: Cell::new(None),
|
pending_pipeline_id: Cell::new(None),
|
||||||
sandbox: Default::default(),
|
sandbox: Default::default(),
|
||||||
|
@ -302,8 +302,8 @@ impl HTMLIFrameElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn frame_id(&self) -> FrameId {
|
pub fn browsing_context_id(&self) -> BrowsingContextId {
|
||||||
self.frame_id
|
self.browsing_context_id
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn change_visibility_status(&self, visibility: bool) {
|
pub fn change_visibility_status(&self, visibility: bool) {
|
||||||
|
@ -364,7 +364,7 @@ impl HTMLIFrameElement {
|
||||||
|
|
||||||
pub trait HTMLIFrameElementLayoutMethods {
|
pub trait HTMLIFrameElementLayoutMethods {
|
||||||
fn pipeline_id(&self) -> Option<PipelineId>;
|
fn pipeline_id(&self) -> Option<PipelineId>;
|
||||||
fn frame_id(&self) -> FrameId;
|
fn browsing_context_id(&self) -> BrowsingContextId;
|
||||||
fn get_width(&self) -> LengthOrPercentageOrAuto;
|
fn get_width(&self) -> LengthOrPercentageOrAuto;
|
||||||
fn get_height(&self) -> LengthOrPercentageOrAuto;
|
fn get_height(&self) -> LengthOrPercentageOrAuto;
|
||||||
}
|
}
|
||||||
|
@ -380,9 +380,9 @@ impl HTMLIFrameElementLayoutMethods for LayoutJS<HTMLIFrameElement> {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
fn frame_id(&self) -> FrameId {
|
fn browsing_context_id(&self) -> BrowsingContextId {
|
||||||
unsafe {
|
unsafe {
|
||||||
(*self.unsafe_get()).frame_id
|
(*self.unsafe_get()).browsing_context_id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -541,7 +541,7 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement {
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-iframe-contentwindow
|
// https://html.spec.whatwg.org/multipage/#dom-iframe-contentwindow
|
||||||
fn GetContentWindow(&self) -> Option<Root<WindowProxy>> {
|
fn GetContentWindow(&self) -> Option<Root<WindowProxy>> {
|
||||||
self.pipeline_id.get().and_then(|_| ScriptThread::find_window_proxy(self.frame_id))
|
self.pipeline_id.get().and_then(|_| ScriptThread::find_window_proxy(self.browsing_context_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#dom-iframe-contentdocument
|
// https://html.spec.whatwg.org/multipage/#dom-iframe-contentdocument
|
||||||
|
@ -711,7 +711,7 @@ impl VirtualMethods for HTMLIFrameElement {
|
||||||
// is in a document tree and has a browsing context, which is what causes
|
// is in a document tree and has a browsing context, which is what causes
|
||||||
// the child browsing context to be created.
|
// the child browsing context to be created.
|
||||||
if self.upcast::<Node>().is_in_doc_with_browsing_context() {
|
if self.upcast::<Node>().is_in_doc_with_browsing_context() {
|
||||||
debug!("iframe {} src set while in browsing context.", self.frame_id);
|
debug!("iframe {} src set while in browsing context.", self.browsing_context_id);
|
||||||
self.process_the_iframe_attributes(ProcessingMode::NotFirstTime);
|
self.process_the_iframe_attributes(ProcessingMode::NotFirstTime);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -740,7 +740,7 @@ impl VirtualMethods for HTMLIFrameElement {
|
||||||
// to the newly-created browsing context, and then process the
|
// to the newly-created browsing context, and then process the
|
||||||
// iframe attributes for the "first time"."
|
// iframe attributes for the "first time"."
|
||||||
if self.upcast::<Node>().is_in_doc_with_browsing_context() {
|
if self.upcast::<Node>().is_in_doc_with_browsing_context() {
|
||||||
debug!("iframe {} bound to browsing context.", self.frame_id);
|
debug!("iframe {} bound to browsing context.", self.browsing_context_id);
|
||||||
debug_assert!(tree_in_doc, "is_in_doc_with_bc, but not tree_in_doc");
|
debug_assert!(tree_in_doc, "is_in_doc_with_bc, but not tree_in_doc");
|
||||||
self.create_nested_browsing_context();
|
self.create_nested_browsing_context();
|
||||||
self.process_the_iframe_attributes(ProcessingMode::FirstTime);
|
self.process_the_iframe_attributes(ProcessingMode::FirstTime);
|
||||||
|
@ -754,13 +754,13 @@ impl VirtualMethods for HTMLIFrameElement {
|
||||||
LoadBlocker::terminate(&mut blocker);
|
LoadBlocker::terminate(&mut blocker);
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#a-browsing-context-is-discarded
|
// https://html.spec.whatwg.org/multipage/#a-browsing-context-is-discarded
|
||||||
debug!("Unbinding frame {}.", self.frame_id);
|
debug!("Unbinding frame {}.", self.browsing_context_id);
|
||||||
let window = window_from_node(self);
|
let window = window_from_node(self);
|
||||||
let (sender, receiver) = ipc::channel().unwrap();
|
let (sender, receiver) = ipc::channel().unwrap();
|
||||||
|
|
||||||
// Ask the constellation to remove the iframe, and tell us the
|
// Ask the constellation to remove the iframe, and tell us the
|
||||||
// pipeline ids of the closed pipelines.
|
// pipeline ids of the closed pipelines.
|
||||||
let msg = ConstellationMsg::RemoveIFrame(self.frame_id, sender);
|
let msg = ConstellationMsg::RemoveIFrame(self.browsing_context_id, sender);
|
||||||
window.upcast::<GlobalScope>().constellation_chan().send(msg).unwrap();
|
window.upcast::<GlobalScope>().constellation_chan().send(msg).unwrap();
|
||||||
let exited_pipeline_ids = receiver.recv().unwrap();
|
let exited_pipeline_ids = receiver.recv().unwrap();
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ use heapsize::{HeapSizeOf, heap_size_of};
|
||||||
use html5ever::{Prefix, Namespace, QualName};
|
use html5ever::{Prefix, Namespace, QualName};
|
||||||
use js::jsapi::{JSContext, JSObject, JSRuntime};
|
use js::jsapi::{JSContext, JSObject, JSRuntime};
|
||||||
use libc::{self, c_void, uintptr_t};
|
use libc::{self, c_void, uintptr_t};
|
||||||
use msg::constellation_msg::{FrameId, PipelineId};
|
use msg::constellation_msg::{BrowsingContextId, PipelineId};
|
||||||
use ref_slice::ref_slice;
|
use ref_slice::ref_slice;
|
||||||
use script_layout_interface::{HTMLCanvasData, OpaqueStyleAndLayoutData, SVGSVGData};
|
use script_layout_interface::{HTMLCanvasData, OpaqueStyleAndLayoutData, SVGSVGData};
|
||||||
use script_layout_interface::{LayoutElementType, LayoutNodeType, TrustedNodeAddress};
|
use script_layout_interface::{LayoutElementType, LayoutNodeType, TrustedNodeAddress};
|
||||||
|
@ -968,7 +968,7 @@ pub trait LayoutNodeHelpers {
|
||||||
fn image_url(&self) -> Option<ServoUrl>;
|
fn image_url(&self) -> Option<ServoUrl>;
|
||||||
fn canvas_data(&self) -> Option<HTMLCanvasData>;
|
fn canvas_data(&self) -> Option<HTMLCanvasData>;
|
||||||
fn svg_data(&self) -> Option<SVGSVGData>;
|
fn svg_data(&self) -> Option<SVGSVGData>;
|
||||||
fn iframe_frame_id(&self) -> FrameId;
|
fn iframe_browsing_context_id(&self) -> BrowsingContextId;
|
||||||
fn iframe_pipeline_id(&self) -> PipelineId;
|
fn iframe_pipeline_id(&self) -> PipelineId;
|
||||||
fn opaque(&self) -> OpaqueNode;
|
fn opaque(&self) -> OpaqueNode;
|
||||||
}
|
}
|
||||||
|
@ -1119,10 +1119,10 @@ impl LayoutNodeHelpers for LayoutJS<Node> {
|
||||||
.map(|svg| svg.data())
|
.map(|svg| svg.data())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn iframe_frame_id(&self) -> FrameId {
|
fn iframe_browsing_context_id(&self) -> BrowsingContextId {
|
||||||
let iframe_element = self.downcast::<HTMLIFrameElement>()
|
let iframe_element = self.downcast::<HTMLIFrameElement>()
|
||||||
.expect("not an iframe element!");
|
.expect("not an iframe element!");
|
||||||
iframe_element.frame_id()
|
iframe_element.browsing_context_id()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn iframe_pipeline_id(&self) -> PipelineId {
|
fn iframe_pipeline_id(&self) -> PipelineId {
|
||||||
|
|
|
@ -28,7 +28,7 @@ use js::jsapi::{MutableHandle, MutableHandleObject, MutableHandleValue};
|
||||||
use js::jsapi::{ObjectOpResult, PropertyDescriptor};
|
use js::jsapi::{ObjectOpResult, PropertyDescriptor};
|
||||||
use js::jsval::{UndefinedValue, PrivateValue};
|
use js::jsval::{UndefinedValue, PrivateValue};
|
||||||
use js::rust::get_object_class;
|
use js::rust::get_object_class;
|
||||||
use msg::constellation_msg::FrameId;
|
use msg::constellation_msg::BrowsingContextId;
|
||||||
use msg::constellation_msg::PipelineId;
|
use msg::constellation_msg::PipelineId;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
@ -45,10 +45,10 @@ pub struct WindowProxy {
|
||||||
/// changes Window.
|
/// changes Window.
|
||||||
reflector: Reflector,
|
reflector: Reflector,
|
||||||
|
|
||||||
/// The frame id of the browsing context.
|
/// The id of the browsing context.
|
||||||
/// In the case that this is a nested browsing context, this is the frame id
|
/// In the case that this is a nested browsing context, this is the id
|
||||||
/// of the container.
|
/// of the container.
|
||||||
frame_id: FrameId,
|
browsing_context_id: BrowsingContextId,
|
||||||
|
|
||||||
/// The pipeline id of the currently active document.
|
/// The pipeline id of the currently active document.
|
||||||
/// May be None, when the currently active document is in another script thread.
|
/// May be None, when the currently active document is in another script thread.
|
||||||
|
@ -68,7 +68,7 @@ pub struct WindowProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WindowProxy {
|
impl WindowProxy {
|
||||||
pub fn new_inherited(frame_id: FrameId,
|
pub fn new_inherited(browsing_context_id: BrowsingContextId,
|
||||||
currently_active: Option<PipelineId>,
|
currently_active: Option<PipelineId>,
|
||||||
frame_element: Option<&Element>,
|
frame_element: Option<&Element>,
|
||||||
parent: Option<&WindowProxy>)
|
parent: Option<&WindowProxy>)
|
||||||
|
@ -76,7 +76,7 @@ impl WindowProxy {
|
||||||
{
|
{
|
||||||
WindowProxy {
|
WindowProxy {
|
||||||
reflector: Reflector::new(),
|
reflector: Reflector::new(),
|
||||||
frame_id: frame_id,
|
browsing_context_id: browsing_context_id,
|
||||||
currently_active: Cell::new(currently_active),
|
currently_active: Cell::new(currently_active),
|
||||||
discarded: Cell::new(false),
|
discarded: Cell::new(false),
|
||||||
frame_element: frame_element.map(JS::from_ref),
|
frame_element: frame_element.map(JS::from_ref),
|
||||||
|
@ -86,7 +86,7 @@ impl WindowProxy {
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
pub fn new(window: &Window,
|
pub fn new(window: &Window,
|
||||||
frame_id: FrameId,
|
browsing_context_id: BrowsingContextId,
|
||||||
frame_element: Option<&Element>,
|
frame_element: Option<&Element>,
|
||||||
parent: Option<&WindowProxy>)
|
parent: Option<&WindowProxy>)
|
||||||
-> Root<WindowProxy>
|
-> Root<WindowProxy>
|
||||||
|
@ -107,7 +107,7 @@ impl WindowProxy {
|
||||||
|
|
||||||
// Create a new browsing context.
|
// Create a new browsing context.
|
||||||
let current = Some(window.global().pipeline_id());
|
let current = Some(window.global().pipeline_id());
|
||||||
let mut window_proxy = box WindowProxy::new_inherited(frame_id, current, frame_element, parent);
|
let mut window_proxy = box WindowProxy::new_inherited(browsing_context_id, current, frame_element, parent);
|
||||||
|
|
||||||
// The window proxy owns the browsing context.
|
// The window proxy owns the browsing context.
|
||||||
// When we finalize the window proxy, it drops the browsing context it owns.
|
// When we finalize the window proxy, it drops the browsing context it owns.
|
||||||
|
@ -125,7 +125,7 @@ impl WindowProxy {
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
pub fn new_dissimilar_origin(global_to_clone_from: &GlobalScope,
|
pub fn new_dissimilar_origin(global_to_clone_from: &GlobalScope,
|
||||||
frame_id: FrameId,
|
browsing_context_id: BrowsingContextId,
|
||||||
parent: Option<&WindowProxy>)
|
parent: Option<&WindowProxy>)
|
||||||
-> Root<WindowProxy>
|
-> Root<WindowProxy>
|
||||||
{
|
{
|
||||||
|
@ -136,7 +136,7 @@ impl WindowProxy {
|
||||||
let cx = global_to_clone_from.get_cx();
|
let cx = global_to_clone_from.get_cx();
|
||||||
|
|
||||||
// Create a new browsing context.
|
// Create a new browsing context.
|
||||||
let mut window_proxy = box WindowProxy::new_inherited(frame_id, None, None, parent);
|
let mut window_proxy = box WindowProxy::new_inherited(browsing_context_id, None, None, parent);
|
||||||
|
|
||||||
// Create a new dissimilar-origin window.
|
// Create a new dissimilar-origin window.
|
||||||
let window = DissimilarOriginWindow::new(global_to_clone_from, &*window_proxy);
|
let window = DissimilarOriginWindow::new(global_to_clone_from, &*window_proxy);
|
||||||
|
@ -171,8 +171,8 @@ impl WindowProxy {
|
||||||
self.discarded.get()
|
self.discarded.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn frame_id(&self) -> FrameId {
|
pub fn browsing_context_id(&self) -> BrowsingContextId {
|
||||||
self.frame_id
|
self.browsing_context_id
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn frame_element(&self) -> Option<&Element> {
|
pub fn frame_element(&self) -> Option<&Element> {
|
||||||
|
|
|
@ -44,7 +44,7 @@ use dom::node::{LayoutNodeHelpers, Node};
|
||||||
use dom::text::Text;
|
use dom::text::Text;
|
||||||
use gfx_traits::ByteIndex;
|
use gfx_traits::ByteIndex;
|
||||||
use html5ever::{LocalName, Namespace};
|
use html5ever::{LocalName, Namespace};
|
||||||
use msg::constellation_msg::{FrameId, PipelineId};
|
use msg::constellation_msg::{BrowsingContextId, PipelineId};
|
||||||
use range::Range;
|
use range::Range;
|
||||||
use script_layout_interface::{HTMLCanvasData, LayoutNodeType, SVGSVGData, TrustedNodeAddress};
|
use script_layout_interface::{HTMLCanvasData, LayoutNodeType, SVGSVGData, TrustedNodeAddress};
|
||||||
use script_layout_interface::{OpaqueStyleAndLayoutData, PartialPersistentLayoutData};
|
use script_layout_interface::{OpaqueStyleAndLayoutData, PartialPersistentLayoutData};
|
||||||
|
@ -908,9 +908,9 @@ impl<'ln> ThreadSafeLayoutNode for ServoThreadSafeLayoutNode<'ln> {
|
||||||
this.svg_data()
|
this.svg_data()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn iframe_frame_id(&self) -> FrameId {
|
fn iframe_browsing_context_id(&self) -> BrowsingContextId {
|
||||||
let this = unsafe { self.get_jsmanaged() };
|
let this = unsafe { self.get_jsmanaged() };
|
||||||
this.iframe_frame_id()
|
this.iframe_browsing_context_id()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn iframe_pipeline_id(&self) -> PipelineId {
|
fn iframe_pipeline_id(&self) -> PipelineId {
|
||||||
|
|
|
@ -71,7 +71,7 @@ use js::jsval::UndefinedValue;
|
||||||
use js::rust::Runtime;
|
use js::rust::Runtime;
|
||||||
use mem::heap_size_of_self_and_children;
|
use mem::heap_size_of_self_and_children;
|
||||||
use microtask::{MicrotaskQueue, Microtask};
|
use microtask::{MicrotaskQueue, Microtask};
|
||||||
use msg::constellation_msg::{FrameId, FrameType, PipelineId, PipelineNamespace};
|
use msg::constellation_msg::{BrowsingContextId, FrameType, PipelineId, PipelineNamespace};
|
||||||
use net_traits::{CoreResourceMsg, FetchMetadata, FetchResponseListener};
|
use net_traits::{CoreResourceMsg, FetchMetadata, FetchResponseListener};
|
||||||
use net_traits::{IpcSend, Metadata, ReferrerPolicy, ResourceThreads};
|
use net_traits::{IpcSend, Metadata, ReferrerPolicy, ResourceThreads};
|
||||||
use net_traits::image_cache::{ImageCache, PendingImageResponse};
|
use net_traits::image_cache::{ImageCache, PendingImageResponse};
|
||||||
|
@ -142,7 +142,7 @@ struct InProgressLoad {
|
||||||
/// The pipeline which requested this load.
|
/// The pipeline which requested this load.
|
||||||
pipeline_id: PipelineId,
|
pipeline_id: PipelineId,
|
||||||
/// The frame being loaded into.
|
/// The frame being loaded into.
|
||||||
frame_id: FrameId,
|
browsing_context_id: BrowsingContextId,
|
||||||
/// The parent pipeline and frame type associated with this load, if any.
|
/// The parent pipeline and frame type associated with this load, if any.
|
||||||
parent_info: Option<(PipelineId, FrameType)>,
|
parent_info: Option<(PipelineId, FrameType)>,
|
||||||
/// The current window size associated with this pipeline.
|
/// The current window size associated with this pipeline.
|
||||||
|
@ -162,7 +162,7 @@ struct InProgressLoad {
|
||||||
impl InProgressLoad {
|
impl InProgressLoad {
|
||||||
/// Create a new InProgressLoad object.
|
/// Create a new InProgressLoad object.
|
||||||
fn new(id: PipelineId,
|
fn new(id: PipelineId,
|
||||||
frame_id: FrameId,
|
browsing_context_id: BrowsingContextId,
|
||||||
parent_info: Option<(PipelineId, FrameType)>,
|
parent_info: Option<(PipelineId, FrameType)>,
|
||||||
layout_chan: Sender<message::Msg>,
|
layout_chan: Sender<message::Msg>,
|
||||||
window_size: Option<WindowSizeData>,
|
window_size: Option<WindowSizeData>,
|
||||||
|
@ -170,7 +170,7 @@ impl InProgressLoad {
|
||||||
origin: MutableOrigin) -> InProgressLoad {
|
origin: MutableOrigin) -> InProgressLoad {
|
||||||
InProgressLoad {
|
InProgressLoad {
|
||||||
pipeline_id: id,
|
pipeline_id: id,
|
||||||
frame_id: frame_id,
|
browsing_context_id: browsing_context_id,
|
||||||
parent_info: parent_info,
|
parent_info: parent_info,
|
||||||
layout_chan: layout_chan,
|
layout_chan: layout_chan,
|
||||||
window_size: window_size,
|
window_size: window_size,
|
||||||
|
@ -368,8 +368,10 @@ impl Documents {
|
||||||
self.find_window(pipeline_id).map(|window| Root::from_ref(window.upcast()))
|
self.find_window(pipeline_id).map(|window| Root::from_ref(window.upcast()))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn find_iframe(&self, pipeline_id: PipelineId, frame_id: FrameId) -> Option<Root<HTMLIFrameElement>> {
|
pub fn find_iframe(&self, pipeline_id: PipelineId, browsing_context_id: BrowsingContextId)
|
||||||
self.find_document(pipeline_id).and_then(|doc| doc.find_iframe(frame_id))
|
-> Option<Root<HTMLIFrameElement>>
|
||||||
|
{
|
||||||
|
self.find_document(pipeline_id).and_then(|doc| doc.find_iframe(browsing_context_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn iter<'a>(&'a self) -> DocumentsIter<'a> {
|
pub fn iter<'a>(&'a self) -> DocumentsIter<'a> {
|
||||||
|
@ -400,7 +402,7 @@ pub struct ScriptThread {
|
||||||
documents: DOMRefCell<Documents>,
|
documents: DOMRefCell<Documents>,
|
||||||
/// The window proxies known by this thread
|
/// The window proxies known by this thread
|
||||||
/// TODO: this map grows, but never shrinks. Issue #15258.
|
/// TODO: this map grows, but never shrinks. Issue #15258.
|
||||||
window_proxies: DOMRefCell<HashMap<FrameId, JS<WindowProxy>>>,
|
window_proxies: DOMRefCell<HashMap<BrowsingContextId, JS<WindowProxy>>>,
|
||||||
/// A list of data pertaining to loads that have not yet received a network response
|
/// A list of data pertaining to loads that have not yet received a network response
|
||||||
incomplete_loads: DOMRefCell<Vec<InProgressLoad>>,
|
incomplete_loads: DOMRefCell<Vec<InProgressLoad>>,
|
||||||
/// A map to store service worker registrations for a given origin
|
/// A map to store service worker registrations for a given origin
|
||||||
|
@ -538,11 +540,11 @@ impl ScriptThreadFactory for ScriptThread {
|
||||||
thread::Builder::new().name(format!("ScriptThread {:?}", state.id)).spawn(move || {
|
thread::Builder::new().name(format!("ScriptThread {:?}", state.id)).spawn(move || {
|
||||||
thread_state::initialize(thread_state::SCRIPT);
|
thread_state::initialize(thread_state::SCRIPT);
|
||||||
PipelineNamespace::install(state.pipeline_namespace_id);
|
PipelineNamespace::install(state.pipeline_namespace_id);
|
||||||
FrameId::install(state.top_level_frame_id);
|
BrowsingContextId::install(state.top_level_browsing_context_id);
|
||||||
let roots = RootCollection::new();
|
let roots = RootCollection::new();
|
||||||
let _stack_roots_tls = StackRootTLS::new(&roots);
|
let _stack_roots_tls = StackRootTLS::new(&roots);
|
||||||
let id = state.id;
|
let id = state.id;
|
||||||
let frame_id = state.frame_id;
|
let browsing_context_id = state.browsing_context_id;
|
||||||
let parent_info = state.parent_info;
|
let parent_info = state.parent_info;
|
||||||
let mem_profiler_chan = state.mem_profiler_chan.clone();
|
let mem_profiler_chan = state.mem_profiler_chan.clone();
|
||||||
let window_size = state.window_size;
|
let window_size = state.window_size;
|
||||||
|
@ -557,7 +559,7 @@ impl ScriptThreadFactory for ScriptThread {
|
||||||
let mut failsafe = ScriptMemoryFailsafe::new(&script_thread);
|
let mut failsafe = ScriptMemoryFailsafe::new(&script_thread);
|
||||||
|
|
||||||
let origin = MutableOrigin::new(load_data.url.origin());
|
let origin = MutableOrigin::new(load_data.url.origin());
|
||||||
let new_load = InProgressLoad::new(id, frame_id, parent_info,
|
let new_load = InProgressLoad::new(id, browsing_context_id, parent_info,
|
||||||
layout_chan, window_size, load_data.url.clone(), origin);
|
layout_chan, window_size, load_data.url.clone(), origin);
|
||||||
script_thread.start_page_load(new_load, load_data);
|
script_thread.start_page_load(new_load, load_data);
|
||||||
|
|
||||||
|
@ -669,7 +671,7 @@ impl ScriptThread {
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn find_window_proxy(id: FrameId) -> Option<Root<WindowProxy>> {
|
pub fn find_window_proxy(id: BrowsingContextId) -> Option<Root<WindowProxy>> {
|
||||||
SCRIPT_THREAD_ROOT.with(|root| root.get().and_then(|script_thread| {
|
SCRIPT_THREAD_ROOT.with(|root| root.get().and_then(|script_thread| {
|
||||||
let script_thread = unsafe { &*script_thread };
|
let script_thread = unsafe { &*script_thread };
|
||||||
script_thread.window_proxies.borrow().get(&id)
|
script_thread.window_proxies.borrow().get(&id)
|
||||||
|
@ -1049,8 +1051,8 @@ impl ScriptThread {
|
||||||
|
|
||||||
fn handle_msg_from_constellation(&self, msg: ConstellationControlMsg) {
|
fn handle_msg_from_constellation(&self, msg: ConstellationControlMsg) {
|
||||||
match msg {
|
match msg {
|
||||||
ConstellationControlMsg::Navigate(parent_pipeline_id, frame_id, load_data, replace) =>
|
ConstellationControlMsg::Navigate(parent_pipeline_id, browsing_context_id, load_data, replace) =>
|
||||||
self.handle_navigate(parent_pipeline_id, Some(frame_id), load_data, replace),
|
self.handle_navigate(parent_pipeline_id, Some(browsing_context_id), load_data, replace),
|
||||||
ConstellationControlMsg::SendEvent(id, event) =>
|
ConstellationControlMsg::SendEvent(id, event) =>
|
||||||
self.handle_event(id, event),
|
self.handle_event(id, event),
|
||||||
ConstellationControlMsg::ResizeInactive(id, new_size) =>
|
ConstellationControlMsg::ResizeInactive(id, new_size) =>
|
||||||
|
@ -1061,22 +1063,22 @@ impl ScriptThread {
|
||||||
self.handle_set_document_activity_msg(pipeline_id, activity),
|
self.handle_set_document_activity_msg(pipeline_id, activity),
|
||||||
ConstellationControlMsg::ChangeFrameVisibilityStatus(pipeline_id, visible) =>
|
ConstellationControlMsg::ChangeFrameVisibilityStatus(pipeline_id, visible) =>
|
||||||
self.handle_visibility_change_msg(pipeline_id, visible),
|
self.handle_visibility_change_msg(pipeline_id, visible),
|
||||||
ConstellationControlMsg::NotifyVisibilityChange(parent_pipeline_id, frame_id, visible) =>
|
ConstellationControlMsg::NotifyVisibilityChange(parent_pipeline_id, browsing_context_id, visible) =>
|
||||||
self.handle_visibility_change_complete_msg(parent_pipeline_id, frame_id, visible),
|
self.handle_visibility_change_complete_msg(parent_pipeline_id, browsing_context_id, visible),
|
||||||
ConstellationControlMsg::PostMessage(pipeline_id, origin, data) =>
|
ConstellationControlMsg::PostMessage(pipeline_id, origin, data) =>
|
||||||
self.handle_post_message_msg(pipeline_id, origin, data),
|
self.handle_post_message_msg(pipeline_id, origin, data),
|
||||||
ConstellationControlMsg::MozBrowserEvent(parent_pipeline_id,
|
ConstellationControlMsg::MozBrowserEvent(parent_pipeline_id,
|
||||||
frame_id,
|
browsing_context_id,
|
||||||
event) =>
|
event) =>
|
||||||
self.handle_mozbrowser_event_msg(parent_pipeline_id,
|
self.handle_mozbrowser_event_msg(parent_pipeline_id,
|
||||||
frame_id,
|
browsing_context_id,
|
||||||
event),
|
event),
|
||||||
ConstellationControlMsg::UpdatePipelineId(parent_pipeline_id,
|
ConstellationControlMsg::UpdatePipelineId(parent_pipeline_id,
|
||||||
frame_id,
|
browsing_context_id,
|
||||||
new_pipeline_id,
|
new_pipeline_id,
|
||||||
reason) =>
|
reason) =>
|
||||||
self.handle_update_pipeline_id(parent_pipeline_id,
|
self.handle_update_pipeline_id(parent_pipeline_id,
|
||||||
frame_id,
|
browsing_context_id,
|
||||||
new_pipeline_id,
|
new_pipeline_id,
|
||||||
reason),
|
reason),
|
||||||
ConstellationControlMsg::FocusIFrame(parent_pipeline_id, frame_id) =>
|
ConstellationControlMsg::FocusIFrame(parent_pipeline_id, frame_id) =>
|
||||||
|
@ -1089,9 +1091,9 @@ impl ScriptThread {
|
||||||
self.handle_transition_event(unsafe_node, name, duration),
|
self.handle_transition_event(unsafe_node, name, duration),
|
||||||
ConstellationControlMsg::WebFontLoaded(pipeline_id) =>
|
ConstellationControlMsg::WebFontLoaded(pipeline_id) =>
|
||||||
self.handle_web_font_loaded(pipeline_id),
|
self.handle_web_font_loaded(pipeline_id),
|
||||||
ConstellationControlMsg::DispatchFrameLoadEvent {
|
ConstellationControlMsg::DispatchIFrameLoadEvent {
|
||||||
target: frame_id, parent: parent_id, child: child_id } =>
|
target: browsing_context_id, parent: parent_id, child: child_id } =>
|
||||||
self.handle_frame_load_event(parent_id, frame_id, child_id),
|
self.handle_iframe_load_event(parent_id, browsing_context_id, child_id),
|
||||||
ConstellationControlMsg::DispatchStorageEvent(pipeline_id, storage, url, key, old_value, new_value) =>
|
ConstellationControlMsg::DispatchStorageEvent(pipeline_id, storage, url, key, old_value, new_value) =>
|
||||||
self.handle_storage_event(pipeline_id, storage, url, key, old_value, new_value),
|
self.handle_storage_event(pipeline_id, storage, url, key, old_value, new_value),
|
||||||
ConstellationControlMsg::ReportCSSError(pipeline_id, filename, line, column, msg) =>
|
ConstellationControlMsg::ReportCSSError(pipeline_id, filename, line, column, msg) =>
|
||||||
|
@ -1224,8 +1226,8 @@ impl ScriptThread {
|
||||||
webdriver_handlers::handle_get_rect(&*documents, pipeline_id, node_id, reply),
|
webdriver_handlers::handle_get_rect(&*documents, pipeline_id, node_id, reply),
|
||||||
WebDriverScriptCommand::GetElementText(node_id, reply) =>
|
WebDriverScriptCommand::GetElementText(node_id, reply) =>
|
||||||
webdriver_handlers::handle_get_text(&*documents, pipeline_id, node_id, reply),
|
webdriver_handlers::handle_get_text(&*documents, pipeline_id, node_id, reply),
|
||||||
WebDriverScriptCommand::GetFrameId(frame_id, reply) =>
|
WebDriverScriptCommand::GetPipelineId(browsing_context_id, reply) =>
|
||||||
webdriver_handlers::handle_get_frame_id(&*documents, pipeline_id, frame_id, reply),
|
webdriver_handlers::handle_get_pipeline_id(&*documents, pipeline_id, browsing_context_id, reply),
|
||||||
WebDriverScriptCommand::GetUrl(reply) =>
|
WebDriverScriptCommand::GetUrl(reply) =>
|
||||||
webdriver_handlers::handle_get_url(&*documents, pipeline_id, reply),
|
webdriver_handlers::handle_get_url(&*documents, pipeline_id, reply),
|
||||||
WebDriverScriptCommand::IsEnabled(element_id, reply) =>
|
WebDriverScriptCommand::IsEnabled(element_id, reply) =>
|
||||||
|
@ -1292,7 +1294,7 @@ impl ScriptThread {
|
||||||
let NewLayoutInfo {
|
let NewLayoutInfo {
|
||||||
parent_info,
|
parent_info,
|
||||||
new_pipeline_id,
|
new_pipeline_id,
|
||||||
frame_id,
|
browsing_context_id,
|
||||||
load_data,
|
load_data,
|
||||||
window_size,
|
window_size,
|
||||||
pipeline_port,
|
pipeline_port,
|
||||||
|
@ -1328,7 +1330,7 @@ impl ScriptThread {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Kick off the fetch for the new resource.
|
// Kick off the fetch for the new resource.
|
||||||
let new_load = InProgressLoad::new(new_pipeline_id, frame_id, parent_info,
|
let new_load = InProgressLoad::new(new_pipeline_id, browsing_context_id, parent_info,
|
||||||
layout_chan, window_size,
|
layout_chan, window_size,
|
||||||
load_data.url.clone(), origin);
|
load_data.url.clone(), origin);
|
||||||
if load_data.url.as_str() == "about:blank" {
|
if load_data.url.as_str() == "about:blank" {
|
||||||
|
@ -1369,8 +1371,12 @@ impl ScriptThread {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Updates iframe element after a change in visibility
|
/// Updates iframe element after a change in visibility
|
||||||
fn handle_visibility_change_complete_msg(&self, parent_pipeline_id: PipelineId, id: FrameId, visible: bool) {
|
fn handle_visibility_change_complete_msg(&self,
|
||||||
let iframe = self.documents.borrow().find_iframe(parent_pipeline_id, id);
|
parent_pipeline_id: PipelineId,
|
||||||
|
browsing_context_id: BrowsingContextId,
|
||||||
|
visible: bool)
|
||||||
|
{
|
||||||
|
let iframe = self.documents.borrow().find_iframe(parent_pipeline_id, browsing_context_id);
|
||||||
if let Some(iframe) = iframe {
|
if let Some(iframe) = iframe {
|
||||||
iframe.change_visibility_status(visible);
|
iframe.change_visibility_status(visible);
|
||||||
}
|
}
|
||||||
|
@ -1418,9 +1424,9 @@ impl ScriptThread {
|
||||||
|
|
||||||
fn handle_focus_iframe_msg(&self,
|
fn handle_focus_iframe_msg(&self,
|
||||||
parent_pipeline_id: PipelineId,
|
parent_pipeline_id: PipelineId,
|
||||||
frame_id: FrameId) {
|
browsing_context_id: BrowsingContextId) {
|
||||||
let doc = self.documents.borrow().find_document(parent_pipeline_id).unwrap();
|
let doc = self.documents.borrow().find_document(parent_pipeline_id).unwrap();
|
||||||
let frame_element = doc.find_iframe(frame_id);
|
let frame_element = doc.find_iframe(browsing_context_id);
|
||||||
|
|
||||||
if let Some(ref frame_element) = frame_element {
|
if let Some(ref frame_element) = frame_element {
|
||||||
doc.begin_focus_transaction();
|
doc.begin_focus_transaction();
|
||||||
|
@ -1440,17 +1446,17 @@ impl ScriptThread {
|
||||||
/// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowserloadstart
|
/// https://developer.mozilla.org/en-US/docs/Web/Events/mozbrowserloadstart
|
||||||
fn handle_mozbrowser_event_msg(&self,
|
fn handle_mozbrowser_event_msg(&self,
|
||||||
parent_pipeline_id: PipelineId,
|
parent_pipeline_id: PipelineId,
|
||||||
frame_id: Option<FrameId>,
|
browsing_context_id: Option<BrowsingContextId>,
|
||||||
event: MozBrowserEvent) {
|
event: MozBrowserEvent) {
|
||||||
let doc = match { self.documents.borrow().find_document(parent_pipeline_id) } {
|
let doc = match { self.documents.borrow().find_document(parent_pipeline_id) } {
|
||||||
None => return warn!("Mozbrowser event after pipeline {:?} closed.", parent_pipeline_id),
|
None => return warn!("Mozbrowser event after pipeline {} closed.", parent_pipeline_id),
|
||||||
Some(doc) => doc,
|
Some(doc) => doc,
|
||||||
};
|
};
|
||||||
|
|
||||||
match frame_id {
|
match browsing_context_id {
|
||||||
None => doc.window().dispatch_mozbrowser_event(event),
|
None => doc.window().dispatch_mozbrowser_event(event),
|
||||||
Some(frame_id) => match doc.find_iframe(frame_id) {
|
Some(browsing_context_id) => match doc.find_iframe(browsing_context_id) {
|
||||||
None => warn!("Mozbrowser event after iframe {:?}/{:?} closed.", parent_pipeline_id, frame_id),
|
None => warn!("Mozbrowser event after iframe {}/{} closed.", parent_pipeline_id, browsing_context_id),
|
||||||
Some(frame_element) => frame_element.dispatch_mozbrowser_event(event),
|
Some(frame_element) => frame_element.dispatch_mozbrowser_event(event),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -1458,10 +1464,10 @@ impl ScriptThread {
|
||||||
|
|
||||||
fn handle_update_pipeline_id(&self,
|
fn handle_update_pipeline_id(&self,
|
||||||
parent_pipeline_id: PipelineId,
|
parent_pipeline_id: PipelineId,
|
||||||
frame_id: FrameId,
|
browsing_context_id: BrowsingContextId,
|
||||||
new_pipeline_id: PipelineId,
|
new_pipeline_id: PipelineId,
|
||||||
reason: UpdatePipelineIdReason) {
|
reason: UpdatePipelineIdReason) {
|
||||||
let frame_element = self.documents.borrow().find_iframe(parent_pipeline_id, frame_id);
|
let frame_element = self.documents.borrow().find_iframe(parent_pipeline_id, browsing_context_id);
|
||||||
if let Some(frame_element) = frame_element {
|
if let Some(frame_element) = frame_element {
|
||||||
frame_element.update_pipeline_id(new_pipeline_id, reason);
|
frame_element.update_pipeline_id(new_pipeline_id, reason);
|
||||||
}
|
}
|
||||||
|
@ -1690,18 +1696,22 @@ impl ScriptThread {
|
||||||
storage.queue_storage_event(url, key, old_value, new_value);
|
storage.queue_storage_event(url, key, old_value, new_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Notify the containing document of a child frame that has completed loading.
|
/// Notify the containing document of a child iframe that has completed loading.
|
||||||
fn handle_frame_load_event(&self, parent_id: PipelineId, frame_id: FrameId, child_id: PipelineId) {
|
fn handle_iframe_load_event(&self,
|
||||||
let iframe = self.documents.borrow().find_iframe(parent_id, frame_id);
|
parent_id: PipelineId,
|
||||||
|
browsing_context_id: BrowsingContextId,
|
||||||
|
child_id: PipelineId)
|
||||||
|
{
|
||||||
|
let iframe = self.documents.borrow().find_iframe(parent_id, browsing_context_id);
|
||||||
match iframe {
|
match iframe {
|
||||||
Some(iframe) => iframe.iframe_load_event_steps(child_id),
|
Some(iframe) => iframe.iframe_load_event_steps(child_id),
|
||||||
None => warn!("Message sent to closed pipeline {}.", parent_id),
|
None => warn!("Message sent to closed pipeline {}.", parent_id),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ask_constellation_for_frame_id(&self, pipeline_id: PipelineId) -> Option<FrameId> {
|
fn ask_constellation_for_browsing_context_id(&self, pipeline_id: PipelineId) -> Option<BrowsingContextId> {
|
||||||
let (result_sender, result_receiver) = ipc::channel().unwrap();
|
let (result_sender, result_receiver) = ipc::channel().unwrap();
|
||||||
let msg = ConstellationMsg::GetFrameId(pipeline_id, result_sender);
|
let msg = ConstellationMsg::GetBrowsingContextId(pipeline_id, result_sender);
|
||||||
self.constellation_chan.send(msg).expect("Failed to send to constellation.");
|
self.constellation_chan.send(msg).expect("Failed to send to constellation.");
|
||||||
result_receiver.recv().expect("Failed to get frame id from constellation.")
|
result_receiver.recv().expect("Failed to get frame id from constellation.")
|
||||||
}
|
}
|
||||||
|
@ -1724,19 +1734,19 @@ impl ScriptThread {
|
||||||
pipeline_id: PipelineId)
|
pipeline_id: PipelineId)
|
||||||
-> Option<Root<WindowProxy>>
|
-> Option<Root<WindowProxy>>
|
||||||
{
|
{
|
||||||
let frame_id = match self.ask_constellation_for_frame_id(pipeline_id) {
|
let browsing_context_id = match self.ask_constellation_for_browsing_context_id(pipeline_id) {
|
||||||
Some(frame_id) => frame_id,
|
Some(browsing_context_id) => browsing_context_id,
|
||||||
None => return None,
|
None => return None,
|
||||||
};
|
};
|
||||||
if let Some(window_proxy) = self.window_proxies.borrow().get(&frame_id) {
|
if let Some(window_proxy) = self.window_proxies.borrow().get(&browsing_context_id) {
|
||||||
return Some(Root::from_ref(window_proxy));
|
return Some(Root::from_ref(window_proxy));
|
||||||
}
|
}
|
||||||
let parent = match self.ask_constellation_for_parent_info(pipeline_id) {
|
let parent = match self.ask_constellation_for_parent_info(pipeline_id) {
|
||||||
Some((parent_id, FrameType::IFrame)) => self.remote_window_proxy(global_to_clone, parent_id),
|
Some((parent_id, FrameType::IFrame)) => self.remote_window_proxy(global_to_clone, parent_id),
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
let window_proxy = WindowProxy::new_dissimilar_origin(global_to_clone, frame_id, parent.r());
|
let window_proxy = WindowProxy::new_dissimilar_origin(global_to_clone, browsing_context_id, parent.r());
|
||||||
self.window_proxies.borrow_mut().insert(frame_id, JS::from_ref(&*window_proxy));
|
self.window_proxies.borrow_mut().insert(browsing_context_id, JS::from_ref(&*window_proxy));
|
||||||
Some(window_proxy)
|
Some(window_proxy)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1748,16 +1758,16 @@ impl ScriptThread {
|
||||||
// to the `window_proxies` map, and return it.
|
// to the `window_proxies` map, and return it.
|
||||||
fn local_window_proxy(&self,
|
fn local_window_proxy(&self,
|
||||||
window: &Window,
|
window: &Window,
|
||||||
frame_id: FrameId,
|
browsing_context_id: BrowsingContextId,
|
||||||
parent_info: Option<(PipelineId, FrameType)>)
|
parent_info: Option<(PipelineId, FrameType)>)
|
||||||
-> Root<WindowProxy>
|
-> Root<WindowProxy>
|
||||||
{
|
{
|
||||||
if let Some(window_proxy) = self.window_proxies.borrow().get(&frame_id) {
|
if let Some(window_proxy) = self.window_proxies.borrow().get(&browsing_context_id) {
|
||||||
window_proxy.set_currently_active(&*window);
|
window_proxy.set_currently_active(&*window);
|
||||||
return Root::from_ref(window_proxy);
|
return Root::from_ref(window_proxy);
|
||||||
}
|
}
|
||||||
let iframe = match parent_info {
|
let iframe = match parent_info {
|
||||||
Some((parent_id, FrameType::IFrame)) => self.documents.borrow().find_iframe(parent_id, frame_id),
|
Some((parent_id, FrameType::IFrame)) => self.documents.borrow().find_iframe(parent_id, browsing_context_id),
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
let parent = match (parent_info, iframe.as_ref()) {
|
let parent = match (parent_info, iframe.as_ref()) {
|
||||||
|
@ -1765,8 +1775,8 @@ impl ScriptThread {
|
||||||
(Some((parent_id, FrameType::IFrame)), _) => self.remote_window_proxy(window.upcast(), parent_id),
|
(Some((parent_id, FrameType::IFrame)), _) => self.remote_window_proxy(window.upcast(), parent_id),
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
let window_proxy = WindowProxy::new(&window, frame_id, iframe.r().map(Castable::upcast), parent.r());
|
let window_proxy = WindowProxy::new(&window, browsing_context_id, iframe.r().map(Castable::upcast), parent.r());
|
||||||
self.window_proxies.borrow_mut().insert(frame_id, JS::from_ref(&*window_proxy));
|
self.window_proxies.borrow_mut().insert(browsing_context_id, JS::from_ref(&*window_proxy));
|
||||||
window_proxy
|
window_proxy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1823,7 +1833,7 @@ impl ScriptThread {
|
||||||
self.webvr_thread.clone());
|
self.webvr_thread.clone());
|
||||||
|
|
||||||
// Initialize the browsing context for the window.
|
// Initialize the browsing context for the window.
|
||||||
let window_proxy = self.local_window_proxy(&window, incomplete.frame_id, incomplete.parent_info);
|
let window_proxy = self.local_window_proxy(&window, incomplete.browsing_context_id, incomplete.parent_info);
|
||||||
window.init_window_proxy(&window_proxy);
|
window.init_window_proxy(&window_proxy);
|
||||||
|
|
||||||
let last_modified = metadata.headers.as_ref().and_then(|headers| {
|
let last_modified = metadata.headers.as_ref().and_then(|headers| {
|
||||||
|
@ -2093,12 +2103,12 @@ impl ScriptThread {
|
||||||
/// The entry point for content to notify that a new load has been requested
|
/// The entry point for content to notify that a new load has been requested
|
||||||
/// for the given pipeline (specifically the "navigate" algorithm).
|
/// for the given pipeline (specifically the "navigate" algorithm).
|
||||||
fn handle_navigate(&self, parent_pipeline_id: PipelineId,
|
fn handle_navigate(&self, parent_pipeline_id: PipelineId,
|
||||||
frame_id: Option<FrameId>,
|
browsing_context_id: Option<BrowsingContextId>,
|
||||||
load_data: LoadData,
|
load_data: LoadData,
|
||||||
replace: bool) {
|
replace: bool) {
|
||||||
match frame_id {
|
match browsing_context_id {
|
||||||
Some(frame_id) => {
|
Some(browsing_context_id) => {
|
||||||
let iframe = self.documents.borrow().find_iframe(parent_pipeline_id, frame_id);
|
let iframe = self.documents.borrow().find_iframe(parent_pipeline_id, browsing_context_id);
|
||||||
if let Some(iframe) = iframe {
|
if let Some(iframe) = iframe {
|
||||||
iframe.navigate_or_reload_child_browsing_context(Some(load_data), NavigationType::Regular, replace);
|
iframe.navigate_or_reload_child_browsing_context(Some(load_data), NavigationType::Regular, replace);
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,10 +109,10 @@ pub fn handle_execute_async_script(documents: &Documents,
|
||||||
window.upcast::<GlobalScope>().evaluate_js_on_global_with_result(&eval, rval.handle_mut());
|
window.upcast::<GlobalScope>().evaluate_js_on_global_with_result(&eval, rval.handle_mut());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_get_frame_id(documents: &Documents,
|
pub fn handle_get_pipeline_id(documents: &Documents,
|
||||||
pipeline: PipelineId,
|
pipeline: PipelineId,
|
||||||
webdriver_frame_id: WebDriverFrameId,
|
webdriver_frame_id: WebDriverFrameId,
|
||||||
reply: IpcSender<Result<Option<PipelineId>, ()>>) {
|
reply: IpcSender<Result<Option<PipelineId>, ()>>) {
|
||||||
let result = match webdriver_frame_id {
|
let result = match webdriver_frame_id {
|
||||||
WebDriverFrameId::Short(_) => {
|
WebDriverFrameId::Short(_) => {
|
||||||
// This isn't supported yet
|
// This isn't supported yet
|
||||||
|
|
|
@ -11,7 +11,7 @@ use SVGSVGData;
|
||||||
use atomic_refcell::AtomicRefCell;
|
use atomic_refcell::AtomicRefCell;
|
||||||
use gfx_traits::{ByteIndex, FragmentType, combine_id_with_fragment_type};
|
use gfx_traits::{ByteIndex, FragmentType, combine_id_with_fragment_type};
|
||||||
use html5ever::{Namespace, LocalName};
|
use html5ever::{Namespace, LocalName};
|
||||||
use msg::constellation_msg::{FrameId, PipelineId};
|
use msg::constellation_msg::{BrowsingContextId, PipelineId};
|
||||||
use range::Range;
|
use range::Range;
|
||||||
use servo_url::ServoUrl;
|
use servo_url::ServoUrl;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
|
@ -271,9 +271,9 @@ pub trait ThreadSafeLayoutNode: Clone + Copy + Debug + GetLayoutData + NodeInfo
|
||||||
|
|
||||||
fn svg_data(&self) -> Option<SVGSVGData>;
|
fn svg_data(&self) -> Option<SVGSVGData>;
|
||||||
|
|
||||||
/// If this node is an iframe element, returns its frame ID. If this node is
|
/// If this node is an iframe element, returns its browsing context ID. If this node is
|
||||||
/// not an iframe element, fails.
|
/// not an iframe element, fails.
|
||||||
fn iframe_frame_id(&self) -> FrameId;
|
fn iframe_browsing_context_id(&self) -> BrowsingContextId;
|
||||||
|
|
||||||
/// If this node is an iframe element, returns its pipeline ID. If this node is
|
/// If this node is an iframe element, returns its pipeline ID. If this node is
|
||||||
/// not an iframe element, fails.
|
/// not an iframe element, fails.
|
||||||
|
|
|
@ -53,7 +53,7 @@ use hyper::header::Headers;
|
||||||
use hyper::method::Method;
|
use hyper::method::Method;
|
||||||
use ipc_channel::ipc::{IpcReceiver, IpcSender};
|
use ipc_channel::ipc::{IpcReceiver, IpcSender};
|
||||||
use libc::c_void;
|
use libc::c_void;
|
||||||
use msg::constellation_msg::{FrameId, FrameType, Key, KeyModifiers, KeyState};
|
use msg::constellation_msg::{BrowsingContextId, FrameType, Key, KeyModifiers, KeyState};
|
||||||
use msg::constellation_msg::{PipelineId, PipelineNamespaceId, TraversalDirection};
|
use msg::constellation_msg::{PipelineId, PipelineNamespaceId, TraversalDirection};
|
||||||
use net_traits::{ReferrerPolicy, ResourceThreads};
|
use net_traits::{ReferrerPolicy, ResourceThreads};
|
||||||
use net_traits::image::base::Image;
|
use net_traits::image::base::Image;
|
||||||
|
@ -179,8 +179,8 @@ pub struct NewLayoutInfo {
|
||||||
pub parent_info: Option<(PipelineId, FrameType)>,
|
pub parent_info: Option<(PipelineId, FrameType)>,
|
||||||
/// Id of the newly-created pipeline.
|
/// Id of the newly-created pipeline.
|
||||||
pub new_pipeline_id: PipelineId,
|
pub new_pipeline_id: PipelineId,
|
||||||
/// Id of the frame associated with this pipeline.
|
/// Id of the browsing context associated with this pipeline.
|
||||||
pub frame_id: FrameId,
|
pub browsing_context_id: BrowsingContextId,
|
||||||
/// Network request data which will be initiated by the script thread.
|
/// Network request data which will be initiated by the script thread.
|
||||||
pub load_data: LoadData,
|
pub load_data: LoadData,
|
||||||
/// Information about the initial window size.
|
/// Information about the initial window size.
|
||||||
|
@ -253,22 +253,22 @@ pub enum ConstellationControlMsg {
|
||||||
/// Notifies script thread whether frame is visible
|
/// Notifies script thread whether frame is visible
|
||||||
ChangeFrameVisibilityStatus(PipelineId, bool),
|
ChangeFrameVisibilityStatus(PipelineId, bool),
|
||||||
/// Notifies script thread that frame visibility change is complete
|
/// Notifies script thread that frame visibility change is complete
|
||||||
/// PipelineId is for the parent, FrameId is for the actual frame.
|
/// PipelineId is for the parent, BrowsingContextId is for the nested browsing context
|
||||||
NotifyVisibilityChange(PipelineId, FrameId, bool),
|
NotifyVisibilityChange(PipelineId, BrowsingContextId, bool),
|
||||||
/// Notifies script thread that a url should be loaded in this iframe.
|
/// Notifies script thread that a url should be loaded in this iframe.
|
||||||
/// PipelineId is for the parent, FrameId is for the actual frame.
|
/// PipelineId is for the parent, BrowsingContextId is for the nested browsing context
|
||||||
Navigate(PipelineId, FrameId, LoadData, bool),
|
Navigate(PipelineId, BrowsingContextId, LoadData, bool),
|
||||||
/// Post a message to a given window.
|
/// Post a message to a given window.
|
||||||
PostMessage(PipelineId, Option<ImmutableOrigin>, Vec<u8>),
|
PostMessage(PipelineId, Option<ImmutableOrigin>, Vec<u8>),
|
||||||
/// Requests the script thread forward a mozbrowser event to an iframe it owns,
|
/// Requests the script thread forward a mozbrowser event to an iframe it owns,
|
||||||
/// or to the window if no child frame id is provided.
|
/// or to the window if no browsing context id is provided.
|
||||||
MozBrowserEvent(PipelineId, Option<FrameId>, MozBrowserEvent),
|
MozBrowserEvent(PipelineId, Option<BrowsingContextId>, MozBrowserEvent),
|
||||||
/// Updates the current pipeline ID of a given iframe.
|
/// Updates the current pipeline ID of a given iframe.
|
||||||
/// First PipelineId is for the parent, second is the new PipelineId for the frame.
|
/// First PipelineId is for the parent, second is the new PipelineId for the frame.
|
||||||
UpdatePipelineId(PipelineId, FrameId, PipelineId, UpdatePipelineIdReason),
|
UpdatePipelineId(PipelineId, BrowsingContextId, PipelineId, UpdatePipelineIdReason),
|
||||||
/// Set an iframe to be focused. Used when an element in an iframe gains focus.
|
/// Set an iframe to be focused. Used when an element in an iframe gains focus.
|
||||||
/// PipelineId is for the parent, FrameId is for the actual frame.
|
/// PipelineId is for the parent, BrowsingContextId is for the nested browsing context
|
||||||
FocusIFrame(PipelineId, FrameId),
|
FocusIFrame(PipelineId, BrowsingContextId),
|
||||||
/// Passes a webdriver command to the script thread for execution
|
/// Passes a webdriver command to the script thread for execution
|
||||||
WebDriverScriptCommand(PipelineId, WebDriverScriptCommand),
|
WebDriverScriptCommand(PipelineId, WebDriverScriptCommand),
|
||||||
/// Notifies script thread that all animations are done
|
/// Notifies script thread that all animations are done
|
||||||
|
@ -278,10 +278,10 @@ pub enum ConstellationControlMsg {
|
||||||
/// Notifies the script thread that a new Web font has been loaded, and thus the page should be
|
/// Notifies the script thread that a new Web font has been loaded, and thus the page should be
|
||||||
/// reflowed.
|
/// reflowed.
|
||||||
WebFontLoaded(PipelineId),
|
WebFontLoaded(PipelineId),
|
||||||
/// Cause a `load` event to be dispatched at the appropriate frame element.
|
/// Cause a `load` event to be dispatched at the appropriate iframe element.
|
||||||
DispatchFrameLoadEvent {
|
DispatchIFrameLoadEvent {
|
||||||
/// The frame that has been marked as loaded.
|
/// The frame that has been marked as loaded.
|
||||||
target: FrameId,
|
target: BrowsingContextId,
|
||||||
/// The pipeline that contains a frame loading the target pipeline.
|
/// The pipeline that contains a frame loading the target pipeline.
|
||||||
parent: PipelineId,
|
parent: PipelineId,
|
||||||
/// The pipeline that has completed loading.
|
/// The pipeline that has completed loading.
|
||||||
|
@ -323,7 +323,7 @@ impl fmt::Debug for ConstellationControlMsg {
|
||||||
TickAllAnimations(..) => "TickAllAnimations",
|
TickAllAnimations(..) => "TickAllAnimations",
|
||||||
TransitionEnd(..) => "TransitionEnd",
|
TransitionEnd(..) => "TransitionEnd",
|
||||||
WebFontLoaded(..) => "WebFontLoaded",
|
WebFontLoaded(..) => "WebFontLoaded",
|
||||||
DispatchFrameLoadEvent { .. } => "DispatchFrameLoadEvent",
|
DispatchIFrameLoadEvent { .. } => "DispatchIFrameLoadEvent",
|
||||||
DispatchStorageEvent(..) => "DispatchStorageEvent",
|
DispatchStorageEvent(..) => "DispatchStorageEvent",
|
||||||
ReportCSSError(..) => "ReportCSSError",
|
ReportCSSError(..) => "ReportCSSError",
|
||||||
Reload(..) => "Reload",
|
Reload(..) => "Reload",
|
||||||
|
@ -489,9 +489,9 @@ pub struct InitialScriptState {
|
||||||
/// If `None`, this is the root.
|
/// If `None`, this is the root.
|
||||||
pub parent_info: Option<(PipelineId, FrameType)>,
|
pub parent_info: Option<(PipelineId, FrameType)>,
|
||||||
/// The ID of the frame this script is part of.
|
/// The ID of the frame this script is part of.
|
||||||
pub frame_id: FrameId,
|
pub browsing_context_id: BrowsingContextId,
|
||||||
/// The ID of the top-level frame this script is part of.
|
/// The ID of the top-level frame this script is part of.
|
||||||
pub top_level_frame_id: FrameId,
|
pub top_level_browsing_context_id: BrowsingContextId,
|
||||||
/// A channel with which messages can be sent to us (the script thread).
|
/// A channel with which messages can be sent to us (the script thread).
|
||||||
pub control_chan: IpcSender<ConstellationControlMsg>,
|
pub control_chan: IpcSender<ConstellationControlMsg>,
|
||||||
/// A port on which messages sent by the constellation to script can be received.
|
/// A port on which messages sent by the constellation to script can be received.
|
||||||
|
@ -549,7 +549,7 @@ pub struct IFrameLoadInfo {
|
||||||
/// Pipeline ID of the parent of this iframe
|
/// Pipeline ID of the parent of this iframe
|
||||||
pub parent_pipeline_id: PipelineId,
|
pub parent_pipeline_id: PipelineId,
|
||||||
/// The ID for this iframe.
|
/// The ID for this iframe.
|
||||||
pub frame_id: FrameId,
|
pub browsing_context_id: BrowsingContextId,
|
||||||
/// The new pipeline ID that the iframe has generated.
|
/// The new pipeline ID that the iframe has generated.
|
||||||
pub new_pipeline_id: PipelineId,
|
pub new_pipeline_id: PipelineId,
|
||||||
/// Whether this iframe should be considered private
|
/// Whether this iframe should be considered private
|
||||||
|
@ -732,13 +732,13 @@ pub enum WebDriverCommandMsg {
|
||||||
pub enum ConstellationMsg {
|
pub enum ConstellationMsg {
|
||||||
/// Exit the constellation.
|
/// Exit the constellation.
|
||||||
Exit,
|
Exit,
|
||||||
/// Request that the constellation send the FrameId corresponding to the document
|
/// Request that the constellation send the BrowsingContextId corresponding to the document
|
||||||
/// with the provided pipeline id
|
/// with the provided pipeline id
|
||||||
GetFrame(PipelineId, IpcSender<Option<FrameId>>),
|
GetBrowsingContext(PipelineId, IpcSender<Option<BrowsingContextId>>),
|
||||||
/// Request that the constellation send the current pipeline id for the provided frame
|
/// Request that the constellation send the current pipeline id for the provided frame
|
||||||
/// id, or for the root frame if this is None, over a provided channel.
|
/// id, or for the root frame if this is None, over a provided channel.
|
||||||
/// Also returns a boolean saying whether the document has finished loading or not.
|
/// Also returns a boolean saying whether the document has finished loading or not.
|
||||||
GetPipeline(Option<FrameId>, IpcSender<Option<PipelineId>>),
|
GetPipeline(Option<BrowsingContextId>, IpcSender<Option<PipelineId>>),
|
||||||
/// Requests that the constellation inform the compositor of the title of the pipeline
|
/// Requests that the constellation inform the compositor of the title of the pipeline
|
||||||
/// immediately.
|
/// immediately.
|
||||||
GetPipelineTitle(PipelineId),
|
GetPipelineTitle(PipelineId),
|
||||||
|
@ -760,8 +760,8 @@ pub enum ConstellationMsg {
|
||||||
WebDriverCommand(WebDriverCommandMsg),
|
WebDriverCommand(WebDriverCommandMsg),
|
||||||
/// Reload the current page.
|
/// Reload the current page.
|
||||||
Reload,
|
Reload,
|
||||||
/// A log entry, with the top-level frame id and thread name
|
/// A log entry, with the top-level browsing context id and thread name
|
||||||
LogEntry(Option<FrameId>, Option<String>, LogEntry),
|
LogEntry(Option<BrowsingContextId>, Option<String>, LogEntry),
|
||||||
/// Set the WebVR thread channel.
|
/// Set the WebVR thread channel.
|
||||||
SetWebVRThread(IpcSender<WebVRMsg>),
|
SetWebVRThread(IpcSender<WebVRMsg>),
|
||||||
/// Dispatch WebVR events to the subscribed script threads.
|
/// Dispatch WebVR events to the subscribed script threads.
|
||||||
|
|
|
@ -17,7 +17,7 @@ use devtools_traits::{ScriptToDevtoolsControlMsg, WorkerId};
|
||||||
use euclid::point::Point2D;
|
use euclid::point::Point2D;
|
||||||
use euclid::size::{Size2D, TypedSize2D};
|
use euclid::size::{Size2D, TypedSize2D};
|
||||||
use ipc_channel::ipc::IpcSender;
|
use ipc_channel::ipc::IpcSender;
|
||||||
use msg::constellation_msg::{FrameId, FrameType, PipelineId, TraversalDirection};
|
use msg::constellation_msg::{BrowsingContextId, FrameType, PipelineId, TraversalDirection};
|
||||||
use msg::constellation_msg::{Key, KeyModifiers, KeyState};
|
use msg::constellation_msg::{Key, KeyModifiers, KeyState};
|
||||||
use net_traits::CoreResourceMsg;
|
use net_traits::CoreResourceMsg;
|
||||||
use net_traits::storage_thread::StorageType;
|
use net_traits::storage_thread::StorageType;
|
||||||
|
@ -34,8 +34,8 @@ use webrender_traits::ClipId;
|
||||||
pub enum LayoutMsg {
|
pub enum LayoutMsg {
|
||||||
/// Indicates whether this pipeline is currently running animations.
|
/// Indicates whether this pipeline is currently running animations.
|
||||||
ChangeRunningAnimationsState(PipelineId, AnimationState),
|
ChangeRunningAnimationsState(PipelineId, AnimationState),
|
||||||
/// Inform the constellation of the size of the frame's viewport.
|
/// Inform the constellation of the size of the iframe's viewport.
|
||||||
FrameSizes(Vec<(FrameId, TypedSize2D<f32, CSSPixel>)>),
|
IFrameSizes(Vec<(BrowsingContextId, TypedSize2D<f32, CSSPixel>)>),
|
||||||
/// Requests that the constellation inform the compositor of the a cursor change.
|
/// Requests that the constellation inform the compositor of the a cursor change.
|
||||||
SetCursor(Cursor),
|
SetCursor(Cursor),
|
||||||
/// Notifies the constellation that the viewport has been constrained in some manner
|
/// Notifies the constellation that the viewport has been constrained in some manner
|
||||||
|
@ -87,7 +87,7 @@ pub enum ScriptMsg {
|
||||||
/// Requests that the constellation retrieve the current contents of the clipboard
|
/// Requests that the constellation retrieve the current contents of the clipboard
|
||||||
GetClipboardContents(IpcSender<String>),
|
GetClipboardContents(IpcSender<String>),
|
||||||
/// Get the frame id for a given pipeline.
|
/// Get the frame id for a given pipeline.
|
||||||
GetFrameId(PipelineId, IpcSender<Option<FrameId>>),
|
GetBrowsingContextId(PipelineId, IpcSender<Option<BrowsingContextId>>),
|
||||||
/// Get the parent info for a given pipeline.
|
/// Get the parent info for a given pipeline.
|
||||||
GetParentInfo(PipelineId, IpcSender<Option<(PipelineId, FrameType)>>),
|
GetParentInfo(PipelineId, IpcSender<Option<(PipelineId, FrameType)>>),
|
||||||
/// <head> tag finished parsing
|
/// <head> tag finished parsing
|
||||||
|
@ -99,7 +99,7 @@ pub enum ScriptMsg {
|
||||||
/// instead of adding a new entry.
|
/// instead of adding a new entry.
|
||||||
LoadUrl(PipelineId, LoadData, bool),
|
LoadUrl(PipelineId, LoadData, bool),
|
||||||
/// Post a message to the currently active window of a given browsing context.
|
/// Post a message to the currently active window of a given browsing context.
|
||||||
PostMessage(FrameId, Option<ImmutableOrigin>, Vec<u8>),
|
PostMessage(BrowsingContextId, Option<ImmutableOrigin>, Vec<u8>),
|
||||||
/// Dispatch a mozbrowser event to the parent of this pipeline.
|
/// Dispatch a mozbrowser event to the parent of this pipeline.
|
||||||
/// The first PipelineId is for the parent, the second is for the originating pipeline.
|
/// The first PipelineId is for the parent, the second is for the originating pipeline.
|
||||||
MozBrowserEvent(PipelineId, PipelineId, MozBrowserEvent),
|
MozBrowserEvent(PipelineId, PipelineId, MozBrowserEvent),
|
||||||
|
@ -113,7 +113,7 @@ pub enum ScriptMsg {
|
||||||
NodeStatus(Option<String>),
|
NodeStatus(Option<String>),
|
||||||
/// Notification that this iframe should be removed.
|
/// Notification that this iframe should be removed.
|
||||||
/// Returns a list of pipelines which were closed.
|
/// Returns a list of pipelines which were closed.
|
||||||
RemoveIFrame(FrameId, IpcSender<Vec<PipelineId>>),
|
RemoveIFrame(BrowsingContextId, IpcSender<Vec<PipelineId>>),
|
||||||
/// Change pipeline visibility
|
/// Change pipeline visibility
|
||||||
SetVisible(PipelineId, bool),
|
SetVisible(PipelineId, bool),
|
||||||
/// Notifies constellation that an iframe's visibility has been changed.
|
/// Notifies constellation that an iframe's visibility has been changed.
|
||||||
|
@ -147,8 +147,8 @@ pub enum ScriptMsg {
|
||||||
ResizeTo(Size2D<u32>),
|
ResizeTo(Size2D<u32>),
|
||||||
/// Script has handled a touch event, and either prevented or allowed default actions.
|
/// Script has handled a touch event, and either prevented or allowed default actions.
|
||||||
TouchEventProcessed(EventResult),
|
TouchEventProcessed(EventResult),
|
||||||
/// A log entry, with the top-level frame id and thread name
|
/// A log entry, with the top-level browsing context id and thread name
|
||||||
LogEntry(Option<FrameId>, Option<String>, LogEntry),
|
LogEntry(Option<BrowsingContextId>, Option<String>, LogEntry),
|
||||||
/// Notifies the constellation that this pipeline has exited.
|
/// Notifies the constellation that this pipeline has exited.
|
||||||
PipelineExited(PipelineId),
|
PipelineExited(PipelineId),
|
||||||
/// Send messages from postMessage calls from serviceworker
|
/// Send messages from postMessage calls from serviceworker
|
||||||
|
|
|
@ -31,7 +31,7 @@ pub enum WebDriverScriptCommand {
|
||||||
GetElementRect(String, IpcSender<Result<Rect<f64>, ()>>),
|
GetElementRect(String, IpcSender<Result<Rect<f64>, ()>>),
|
||||||
GetElementTagName(String, IpcSender<Result<String, ()>>),
|
GetElementTagName(String, IpcSender<Result<String, ()>>),
|
||||||
GetElementText(String, IpcSender<Result<String, ()>>),
|
GetElementText(String, IpcSender<Result<String, ()>>),
|
||||||
GetFrameId(WebDriverFrameId, IpcSender<Result<Option<PipelineId>, ()>>),
|
GetPipelineId(WebDriverFrameId, IpcSender<Result<Option<PipelineId>, ()>>),
|
||||||
GetUrl(IpcSender<ServoUrl>),
|
GetUrl(IpcSender<ServoUrl>),
|
||||||
IsEnabled(String, IpcSender<Result<bool, ()>>),
|
IsEnabled(String, IpcSender<Result<bool, ()>>),
|
||||||
IsSelected(String, IpcSender<Result<bool, ()>>),
|
IsSelected(String, IpcSender<Result<bool, ()>>),
|
||||||
|
|
|
@ -32,7 +32,7 @@ use hyper::method::Method::{self, Post};
|
||||||
use image::{DynamicImage, ImageFormat, RgbImage};
|
use image::{DynamicImage, ImageFormat, RgbImage};
|
||||||
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
use ipc_channel::ipc::{self, IpcReceiver, IpcSender};
|
||||||
use keys::keycodes_to_keys;
|
use keys::keycodes_to_keys;
|
||||||
use msg::constellation_msg::{FrameId, PipelineId, TraversalDirection};
|
use msg::constellation_msg::{BrowsingContextId, PipelineId, TraversalDirection};
|
||||||
use net_traits::image::base::PixelFormat;
|
use net_traits::image::base::PixelFormat;
|
||||||
use regex::Captures;
|
use regex::Captures;
|
||||||
use rustc_serialize::json::{Json, ToJson};
|
use rustc_serialize::json::{Json, ToJson};
|
||||||
|
@ -102,7 +102,7 @@ pub fn start_server(port: u16, constellation_chan: Sender<ConstellationMsg>) {
|
||||||
/// Represents the current WebDriver session and holds relevant session state.
|
/// Represents the current WebDriver session and holds relevant session state.
|
||||||
struct WebDriverSession {
|
struct WebDriverSession {
|
||||||
id: Uuid,
|
id: Uuid,
|
||||||
frame_id: Option<FrameId>,
|
browsing_context_id: Option<BrowsingContextId>,
|
||||||
|
|
||||||
/// Time to wait for injected scripts to run before interrupting them. A [`None`] value
|
/// Time to wait for injected scripts to run before interrupting them. A [`None`] value
|
||||||
/// specifies that the script should run indefinitely.
|
/// specifies that the script should run indefinitely.
|
||||||
|
@ -120,7 +120,7 @@ impl WebDriverSession {
|
||||||
pub fn new() -> WebDriverSession {
|
pub fn new() -> WebDriverSession {
|
||||||
WebDriverSession {
|
WebDriverSession {
|
||||||
id: Uuid::new_v4(),
|
id: Uuid::new_v4(),
|
||||||
frame_id: None,
|
browsing_context_id: None,
|
||||||
|
|
||||||
script_timeout: Some(30_000),
|
script_timeout: Some(30_000),
|
||||||
load_timeout: Some(300_000),
|
load_timeout: Some(300_000),
|
||||||
|
@ -264,7 +264,7 @@ impl Handler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pipeline_id(&self, frame_id: Option<FrameId>) -> WebDriverResult<PipelineId> {
|
fn pipeline_id(&self, frame_id: Option<BrowsingContextId>) -> 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();
|
||||||
|
@ -288,7 +288,7 @@ impl Handler {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn frame_pipeline(&self) -> WebDriverResult<PipelineId> {
|
fn frame_pipeline(&self) -> WebDriverResult<PipelineId> {
|
||||||
self.pipeline_id(self.session.as_ref().and_then(|session| session.frame_id))
|
self.pipeline_id(self.session.as_ref().and_then(|session| session.browsing_context_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn session(&self) -> WebDriverResult<&WebDriverSession> {
|
fn session(&self) -> WebDriverResult<&WebDriverSession> {
|
||||||
|
@ -299,10 +299,10 @@ impl Handler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_frame_id(&mut self, frame_id: Option<FrameId>) -> WebDriverResult<()> {
|
fn set_browsing_context_id(&mut self, browsing_context_id: Option<BrowsingContextId>) -> WebDriverResult<()> {
|
||||||
match self.session {
|
match self.session {
|
||||||
Some(ref mut x) => {
|
Some(ref mut x) => {
|
||||||
x.frame_id = frame_id;
|
x.browsing_context_id = browsing_context_id;
|
||||||
Ok(())
|
Ok(())
|
||||||
},
|
},
|
||||||
None => Err(WebDriverError::new(ErrorStatus::SessionNotCreated,
|
None => Err(WebDriverError::new(ErrorStatus::SessionNotCreated,
|
||||||
|
@ -525,7 +525,7 @@ impl Handler {
|
||||||
use webdriver::common::FrameId;
|
use webdriver::common::FrameId;
|
||||||
let frame_id = match parameters.id {
|
let frame_id = match parameters.id {
|
||||||
FrameId::Null => {
|
FrameId::Null => {
|
||||||
self.set_frame_id(None).unwrap();
|
self.set_browsing_context_id(None).unwrap();
|
||||||
return Ok(WebDriverResponse::Void)
|
return Ok(WebDriverResponse::Void)
|
||||||
},
|
},
|
||||||
FrameId::Short(ref x) => WebDriverFrameId::Short(*x),
|
FrameId::Short(ref x) => WebDriverFrameId::Short(*x),
|
||||||
|
@ -547,16 +547,16 @@ impl Handler {
|
||||||
}
|
}
|
||||||
let pipeline_id = try!(self.frame_pipeline());
|
let pipeline_id = try!(self.frame_pipeline());
|
||||||
let (sender, receiver) = ipc::channel().unwrap();
|
let (sender, receiver) = ipc::channel().unwrap();
|
||||||
let cmd = WebDriverScriptCommand::GetFrameId(frame_id, sender);
|
let cmd = WebDriverScriptCommand::GetPipelineId(frame_id, sender);
|
||||||
{
|
{
|
||||||
self.constellation_chan.send(ConstellationMsg::WebDriverCommand(
|
self.constellation_chan.send(ConstellationMsg::WebDriverCommand(
|
||||||
WebDriverCommandMsg::ScriptCommand(pipeline_id, cmd))).unwrap();
|
WebDriverCommandMsg::ScriptCommand(pipeline_id, cmd))).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
let frame = match receiver.recv().unwrap() {
|
let context_id = match receiver.recv().unwrap() {
|
||||||
Ok(Some(pipeline_id)) => {
|
Ok(Some(pipeline_id)) => {
|
||||||
let (sender, receiver) = ipc::channel().unwrap();
|
let (sender, receiver) = ipc::channel().unwrap();
|
||||||
self.constellation_chan.send(ConstellationMsg::GetFrame(pipeline_id, sender)).unwrap();
|
self.constellation_chan.send(ConstellationMsg::GetBrowsingContext(pipeline_id, sender)).unwrap();
|
||||||
receiver.recv().unwrap()
|
receiver.recv().unwrap()
|
||||||
},
|
},
|
||||||
Ok(None) => None,
|
Ok(None) => None,
|
||||||
|
@ -566,7 +566,7 @@ impl Handler {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
self.set_frame_id(frame).unwrap();
|
self.set_browsing_context_id(context_id).unwrap();
|
||||||
Ok(WebDriverResponse::Void)
|
Ok(WebDriverResponse::Void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue