mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #16876 - asajeffrey:constellation-rename-frames, r=cbrewster
Renamed constellation::Frame to constellation::BrowsingContext <!-- Please describe your changes on the following line: --> Now that script has `WindowProxy` rather than `BrowsingContext` objects, we can rename `Frame` in the constellation to `BrowsingContext`. In particular, this means that `FrameId`s are now `BrowsingContextid`s, which better captures their purpose (and they are used in a lot of places, not just the constellation). --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes do not require tests because renaming <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16876) <!-- Reviewable:end -->
This commit is contained in:
commit
8375319928
24 changed files with 778 additions and 721 deletions
|
@ -58,7 +58,7 @@ use js::glue::{CallObjectTracer, CallValueTracer};
|
|||
use js::jsapi::{GCTraceKindToAscii, Heap, JSObject, JSTracer, TraceKind};
|
||||
use js::jsval::JSVal;
|
||||
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::filemanager_thread::RelativePos;
|
||||
use net_traits::image::base::{Image, ImageMetadata};
|
||||
|
@ -336,7 +336,7 @@ unsafe_no_jsmanaged_fields!(TrustedPromise);
|
|||
unsafe_no_jsmanaged_fields!(PropertyDeclarationBlock);
|
||||
// These three are interdependent, if you plan to put jsmanaged data
|
||||
// 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!(TimelineMarkerType);
|
||||
unsafe_no_jsmanaged_fields!(WorkerId);
|
||||
|
|
|
@ -27,7 +27,7 @@ use js::jsapi::{HandleValue, JS_SetInterruptCallback};
|
|||
use js::jsapi::{JSAutoCompartment, JSContext};
|
||||
use js::jsval::UndefinedValue;
|
||||
use js::rust::Runtime;
|
||||
use msg::constellation_msg::FrameId;
|
||||
use msg::constellation_msg::BrowsingContextId;
|
||||
use net_traits::{IpcSend, load_whole_resource};
|
||||
use net_traits::request::{CredentialsMode, Destination, RequestInit, Type as RequestType};
|
||||
use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort, StackRootTLS, get_reports, new_rt_and_cx};
|
||||
|
@ -159,13 +159,13 @@ impl DedicatedWorkerGlobalScope {
|
|||
closing: Arc<AtomicBool>) {
|
||||
let serialized_worker_url = worker_url.to_string();
|
||||
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_state::initialize(thread_state::SCRIPT | thread_state::IN_WORKER);
|
||||
|
||||
if let Some(top_level_frame_id) = top_level_frame_id {
|
||||
FrameId::install(top_level_frame_id);
|
||||
if let Some(top_level_browsing_context_id) = top_level_browsing_context_id {
|
||||
BrowsingContextId::install(top_level_browsing_context_id);
|
||||
}
|
||||
|
||||
let roots = RootCollection::new();
|
||||
|
|
|
@ -184,7 +184,9 @@ impl DissimilarOriginWindowMethods for DissimilarOriginWindow {
|
|||
|
||||
impl DissimilarOriginWindow {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ use ipc_channel::ipc::{self, IpcSender};
|
|||
use js::jsapi::{JSContext, JSObject, JSRuntime};
|
||||
use js::jsapi::JS_GetRuntime;
|
||||
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::CookieSource::NonHTTP;
|
||||
use net_traits::CoreResourceMsg::{GetCookiesForUrl, SetCookiesForUrl};
|
||||
|
@ -1897,9 +1897,9 @@ impl 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()
|
||||
.find(|node| node.frame_id() == frame_id)
|
||||
.find(|node| node.browsing_context_id() == browsing_context_id)
|
||||
}
|
||||
|
||||
pub fn get_dom_loading(&self) -> u64 {
|
||||
|
|
|
@ -40,7 +40,7 @@ use html5ever::{LocalName, Prefix};
|
|||
use ipc_channel::ipc;
|
||||
use js::jsapi::{JSAutoCompartment, JSContext, MutableHandleValue};
|
||||
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 script_layout_interface::message::ReflowQueryType;
|
||||
use script_thread::{ScriptThread, Runnable};
|
||||
|
@ -84,7 +84,7 @@ enum ProcessingMode {
|
|||
#[dom_struct]
|
||||
pub struct HTMLIFrameElement {
|
||||
htmlelement: HTMLElement,
|
||||
frame_id: FrameId,
|
||||
browsing_context_id: BrowsingContextId,
|
||||
pipeline_id: Cell<Option<PipelineId>>,
|
||||
pending_pipeline_id: Cell<Option<PipelineId>>,
|
||||
sandbox: MutNullableJS<DOMTokenList>,
|
||||
|
@ -115,7 +115,7 @@ impl HTMLIFrameElement {
|
|||
pub fn generate_new_pipeline_id(&self) -> (Option<PipelineId>, PipelineId) {
|
||||
let old_pipeline_id = self.pipeline_id.get();
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -152,7 +152,7 @@ impl HTMLIFrameElement {
|
|||
let global_scope = window.upcast::<GlobalScope>();
|
||||
let load_info = IFrameLoadInfo {
|
||||
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,
|
||||
is_private: private_iframe,
|
||||
frame_type: frame_type,
|
||||
|
@ -171,7 +171,7 @@ impl HTMLIFrameElement {
|
|||
let new_layout_info = NewLayoutInfo {
|
||||
parent_info: Some((global_scope.pipeline_id(), frame_type)),
|
||||
new_pipeline_id: new_pipeline_id,
|
||||
frame_id: self.frame_id,
|
||||
browsing_context_id: self.browsing_context_id,
|
||||
load_data: load_data.unwrap(),
|
||||
pipeline_port: pipeline_receiver,
|
||||
content_process_shutdown_chan: None,
|
||||
|
@ -277,7 +277,7 @@ impl HTMLIFrameElement {
|
|||
document: &Document) -> HTMLIFrameElement {
|
||||
HTMLIFrameElement {
|
||||
htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
|
||||
frame_id: FrameId::new(),
|
||||
browsing_context_id: BrowsingContextId::new(),
|
||||
pipeline_id: Cell::new(None),
|
||||
pending_pipeline_id: Cell::new(None),
|
||||
sandbox: Default::default(),
|
||||
|
@ -302,8 +302,8 @@ impl HTMLIFrameElement {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn frame_id(&self) -> FrameId {
|
||||
self.frame_id
|
||||
pub fn browsing_context_id(&self) -> BrowsingContextId {
|
||||
self.browsing_context_id
|
||||
}
|
||||
|
||||
pub fn change_visibility_status(&self, visibility: bool) {
|
||||
|
@ -364,7 +364,7 @@ impl HTMLIFrameElement {
|
|||
|
||||
pub trait HTMLIFrameElementLayoutMethods {
|
||||
fn pipeline_id(&self) -> Option<PipelineId>;
|
||||
fn frame_id(&self) -> FrameId;
|
||||
fn browsing_context_id(&self) -> BrowsingContextId;
|
||||
fn get_width(&self) -> LengthOrPercentageOrAuto;
|
||||
fn get_height(&self) -> LengthOrPercentageOrAuto;
|
||||
}
|
||||
|
@ -380,9 +380,9 @@ impl HTMLIFrameElementLayoutMethods for LayoutJS<HTMLIFrameElement> {
|
|||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
fn frame_id(&self) -> FrameId {
|
||||
fn browsing_context_id(&self) -> BrowsingContextId {
|
||||
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
|
||||
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
|
||||
|
@ -711,7 +711,7 @@ impl VirtualMethods for HTMLIFrameElement {
|
|||
// is in a document tree and has a browsing context, which is what causes
|
||||
// the child browsing context to be created.
|
||||
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);
|
||||
}
|
||||
},
|
||||
|
@ -740,7 +740,7 @@ impl VirtualMethods for HTMLIFrameElement {
|
|||
// to the newly-created browsing context, and then process the
|
||||
// iframe attributes for the "first time"."
|
||||
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");
|
||||
self.create_nested_browsing_context();
|
||||
self.process_the_iframe_attributes(ProcessingMode::FirstTime);
|
||||
|
@ -754,13 +754,13 @@ impl VirtualMethods for HTMLIFrameElement {
|
|||
LoadBlocker::terminate(&mut blocker);
|
||||
|
||||
// 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 (sender, receiver) = ipc::channel().unwrap();
|
||||
|
||||
// Ask the constellation to remove the iframe, and tell us the
|
||||
// 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();
|
||||
let exited_pipeline_ids = receiver.recv().unwrap();
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ use heapsize::{HeapSizeOf, heap_size_of};
|
|||
use html5ever::{Prefix, Namespace, QualName};
|
||||
use js::jsapi::{JSContext, JSObject, JSRuntime};
|
||||
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 script_layout_interface::{HTMLCanvasData, OpaqueStyleAndLayoutData, SVGSVGData};
|
||||
use script_layout_interface::{LayoutElementType, LayoutNodeType, TrustedNodeAddress};
|
||||
|
@ -968,7 +968,7 @@ pub trait LayoutNodeHelpers {
|
|||
fn image_url(&self) -> Option<ServoUrl>;
|
||||
fn canvas_data(&self) -> Option<HTMLCanvasData>;
|
||||
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 opaque(&self) -> OpaqueNode;
|
||||
}
|
||||
|
@ -1119,10 +1119,10 @@ impl LayoutNodeHelpers for LayoutJS<Node> {
|
|||
.map(|svg| svg.data())
|
||||
}
|
||||
|
||||
fn iframe_frame_id(&self) -> FrameId {
|
||||
fn iframe_browsing_context_id(&self) -> BrowsingContextId {
|
||||
let iframe_element = self.downcast::<HTMLIFrameElement>()
|
||||
.expect("not an iframe element!");
|
||||
iframe_element.frame_id()
|
||||
iframe_element.browsing_context_id()
|
||||
}
|
||||
|
||||
fn iframe_pipeline_id(&self) -> PipelineId {
|
||||
|
|
|
@ -28,7 +28,7 @@ use js::jsapi::{MutableHandle, MutableHandleObject, MutableHandleValue};
|
|||
use js::jsapi::{ObjectOpResult, PropertyDescriptor};
|
||||
use js::jsval::{UndefinedValue, PrivateValue};
|
||||
use js::rust::get_object_class;
|
||||
use msg::constellation_msg::FrameId;
|
||||
use msg::constellation_msg::BrowsingContextId;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use std::cell::Cell;
|
||||
use std::ptr;
|
||||
|
@ -45,10 +45,10 @@ pub struct WindowProxy {
|
|||
/// changes Window.
|
||||
reflector: Reflector,
|
||||
|
||||
/// The frame id of the browsing context.
|
||||
/// In the case that this is a nested browsing context, this is the frame id
|
||||
/// The id of the browsing context.
|
||||
/// In the case that this is a nested browsing context, this is the id
|
||||
/// of the container.
|
||||
frame_id: FrameId,
|
||||
browsing_context_id: BrowsingContextId,
|
||||
|
||||
/// The pipeline id of the currently active document.
|
||||
/// May be None, when the currently active document is in another script thread.
|
||||
|
@ -68,7 +68,7 @@ pub struct WindowProxy {
|
|||
}
|
||||
|
||||
impl WindowProxy {
|
||||
pub fn new_inherited(frame_id: FrameId,
|
||||
pub fn new_inherited(browsing_context_id: BrowsingContextId,
|
||||
currently_active: Option<PipelineId>,
|
||||
frame_element: Option<&Element>,
|
||||
parent: Option<&WindowProxy>)
|
||||
|
@ -76,7 +76,7 @@ impl WindowProxy {
|
|||
{
|
||||
WindowProxy {
|
||||
reflector: Reflector::new(),
|
||||
frame_id: frame_id,
|
||||
browsing_context_id: browsing_context_id,
|
||||
currently_active: Cell::new(currently_active),
|
||||
discarded: Cell::new(false),
|
||||
frame_element: frame_element.map(JS::from_ref),
|
||||
|
@ -86,7 +86,7 @@ impl WindowProxy {
|
|||
|
||||
#[allow(unsafe_code)]
|
||||
pub fn new(window: &Window,
|
||||
frame_id: FrameId,
|
||||
browsing_context_id: BrowsingContextId,
|
||||
frame_element: Option<&Element>,
|
||||
parent: Option<&WindowProxy>)
|
||||
-> Root<WindowProxy>
|
||||
|
@ -107,7 +107,7 @@ impl WindowProxy {
|
|||
|
||||
// Create a new browsing context.
|
||||
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.
|
||||
// When we finalize the window proxy, it drops the browsing context it owns.
|
||||
|
@ -125,7 +125,7 @@ impl WindowProxy {
|
|||
|
||||
#[allow(unsafe_code)]
|
||||
pub fn new_dissimilar_origin(global_to_clone_from: &GlobalScope,
|
||||
frame_id: FrameId,
|
||||
browsing_context_id: BrowsingContextId,
|
||||
parent: Option<&WindowProxy>)
|
||||
-> Root<WindowProxy>
|
||||
{
|
||||
|
@ -136,7 +136,7 @@ impl WindowProxy {
|
|||
let cx = global_to_clone_from.get_cx();
|
||||
|
||||
// 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.
|
||||
let window = DissimilarOriginWindow::new(global_to_clone_from, &*window_proxy);
|
||||
|
@ -171,8 +171,8 @@ impl WindowProxy {
|
|||
self.discarded.get()
|
||||
}
|
||||
|
||||
pub fn frame_id(&self) -> FrameId {
|
||||
self.frame_id
|
||||
pub fn browsing_context_id(&self) -> BrowsingContextId {
|
||||
self.browsing_context_id
|
||||
}
|
||||
|
||||
pub fn frame_element(&self) -> Option<&Element> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue