mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
added origin to globalscope
This commit is contained in:
parent
3af69cf9bf
commit
2c6bd51bef
8 changed files with 44 additions and 8 deletions
|
@ -12,6 +12,7 @@ use dom::bindings::str::DOMString;
|
|||
use dom::bindings::str::USVString;
|
||||
use dom::dissimilaroriginwindow::DissimilarOriginWindow;
|
||||
use dom_struct::dom_struct;
|
||||
use servo_url::MutableOrigin;
|
||||
|
||||
/// Represents a dissimilar-origin `Location` that exists in another script thread.
|
||||
///
|
||||
|
@ -43,6 +44,10 @@ impl DissimilarOriginLocation {
|
|||
window,
|
||||
DissimilarOriginLocationBinding::Wrap)
|
||||
}
|
||||
|
||||
pub fn origin(&self) -> &MutableOrigin {
|
||||
self.window.origin()
|
||||
}
|
||||
}
|
||||
|
||||
impl DissimilarOriginLocationMethods for DissimilarOriginLocation {
|
||||
|
|
|
@ -19,6 +19,7 @@ use js::jsval::{JSVal, UndefinedValue};
|
|||
use msg::constellation_msg::PipelineId;
|
||||
use script_traits::ScriptMsg as ConstellationMsg;
|
||||
use servo_url::ImmutableOrigin;
|
||||
use servo_url::MutableOrigin;
|
||||
use servo_url::ServoUrl;
|
||||
|
||||
/// Represents a dissimilar-origin `Window` that exists in another script thread.
|
||||
|
@ -56,12 +57,17 @@ impl DissimilarOriginWindow {
|
|||
global_to_clone_from.constellation_chan().clone(),
|
||||
global_to_clone_from.scheduler_chan().clone(),
|
||||
global_to_clone_from.resource_threads().clone(),
|
||||
timer_event_chan),
|
||||
timer_event_chan,
|
||||
global_to_clone_from.origin().clone()),
|
||||
browsing_context: JS::from_ref(browsing_context),
|
||||
location: MutNullableJS::new(None),
|
||||
};
|
||||
unsafe { DissimilarOriginWindowBinding::Wrap(cx, win) }
|
||||
}
|
||||
|
||||
pub fn origin(&self) -> &MutableOrigin {
|
||||
self.globalscope.origin()
|
||||
}
|
||||
}
|
||||
|
||||
impl DissimilarOriginWindowMethods for DissimilarOriginWindow {
|
||||
|
|
|
@ -38,7 +38,7 @@ use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort};
|
|||
use script_thread::{MainThreadScriptChan, RunnableWrapper, ScriptThread};
|
||||
use script_traits::{MsDuration, ScriptMsg as ConstellationMsg, TimerEvent};
|
||||
use script_traits::{TimerEventId, TimerSchedulerMsg, TimerSource};
|
||||
use servo_url::ServoUrl;
|
||||
use servo_url::{MutableOrigin, ServoUrl};
|
||||
use std::cell::Cell;
|
||||
use std::collections::HashMap;
|
||||
use std::collections::hash_map::Entry;
|
||||
|
@ -92,6 +92,9 @@ pub struct GlobalScope {
|
|||
resource_threads: ResourceThreads,
|
||||
|
||||
timers: OneshotTimers,
|
||||
|
||||
/// The origin of the globalscope
|
||||
origin: MutableOrigin,
|
||||
}
|
||||
|
||||
impl GlobalScope {
|
||||
|
@ -103,7 +106,8 @@ impl GlobalScope {
|
|||
constellation_chan: IpcSender<ConstellationMsg>,
|
||||
scheduler_chan: IpcSender<TimerSchedulerMsg>,
|
||||
resource_threads: ResourceThreads,
|
||||
timer_event_chan: IpcSender<TimerEvent>)
|
||||
timer_event_chan: IpcSender<TimerEvent>,
|
||||
origin: MutableOrigin)
|
||||
-> Self {
|
||||
GlobalScope {
|
||||
eventtarget: EventTarget::new_inherited(),
|
||||
|
@ -120,6 +124,7 @@ impl GlobalScope {
|
|||
in_error_reporting_mode: Default::default(),
|
||||
resource_threads: resource_threads,
|
||||
timers: OneshotTimers::new(timer_event_chan, scheduler_chan),
|
||||
origin: origin,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -238,6 +243,11 @@ impl GlobalScope {
|
|||
self.pipeline_id
|
||||
}
|
||||
|
||||
/// Get the origin for this global scope
|
||||
pub fn origin(&self) -> &MutableOrigin {
|
||||
&self.origin
|
||||
}
|
||||
|
||||
/// Get the [base url](https://html.spec.whatwg.org/multipage/#api-base-url)
|
||||
/// for this global scope.
|
||||
pub fn api_base_url(&self) -> ServoUrl {
|
||||
|
|
|
@ -13,7 +13,7 @@ use dom::globalscope::GlobalScope;
|
|||
use dom::urlhelper::UrlHelper;
|
||||
use dom::window::Window;
|
||||
use dom_struct::dom_struct;
|
||||
use servo_url::ServoUrl;
|
||||
use servo_url::{MutableOrigin, ServoUrl};
|
||||
|
||||
#[dom_struct]
|
||||
pub struct Location {
|
||||
|
@ -60,6 +60,10 @@ impl Location {
|
|||
pub fn reload_without_origin_check(&self) {
|
||||
self.window.load_url(self.get_url(), true, true, None);
|
||||
}
|
||||
|
||||
pub fn origin(&self) -> &MutableOrigin {
|
||||
self.window.origin()
|
||||
}
|
||||
}
|
||||
|
||||
impl LocationMethods for Location {
|
||||
|
|
|
@ -85,7 +85,7 @@ use servo_atoms::Atom;
|
|||
use servo_config::opts;
|
||||
use servo_config::prefs::PREFS;
|
||||
use servo_geometry::{f32_rect_to_au_rect, max_rect};
|
||||
use servo_url::{Host, ImmutableOrigin, ServoUrl};
|
||||
use servo_url::{Host, MutableOrigin, ImmutableOrigin, ServoUrl};
|
||||
use std::ascii::AsciiExt;
|
||||
use std::borrow::ToOwned;
|
||||
use std::cell::Cell;
|
||||
|
@ -286,6 +286,10 @@ impl Window {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn origin(&self) -> &MutableOrigin {
|
||||
self.globalscope.origin()
|
||||
}
|
||||
|
||||
pub fn get_cx(&self) -> *mut JSContext {
|
||||
self.js_runtime.borrow().as_ref().unwrap().cx()
|
||||
}
|
||||
|
@ -1749,6 +1753,7 @@ impl Window {
|
|||
id: PipelineId,
|
||||
parent_info: Option<(PipelineId, FrameType)>,
|
||||
window_size: Option<WindowSizeData>,
|
||||
origin: MutableOrigin,
|
||||
webvr_thread: Option<IpcSender<WebVRMsg>>)
|
||||
-> Root<Window> {
|
||||
let layout_rpc: Box<LayoutRPC + Send> = {
|
||||
|
@ -1771,7 +1776,8 @@ impl Window {
|
|||
constellation_chan,
|
||||
scheduler_chan,
|
||||
resource_threads,
|
||||
timer_event_chan),
|
||||
timer_event_chan,
|
||||
origin),
|
||||
script_chan: script_chan,
|
||||
dom_manipulation_task_source: dom_task_source,
|
||||
user_interaction_task_source: user_task_source,
|
||||
|
|
|
@ -37,7 +37,7 @@ use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort};
|
|||
use script_thread::RunnableWrapper;
|
||||
use script_traits::{TimerEvent, TimerEventId};
|
||||
use script_traits::WorkerGlobalScopeInit;
|
||||
use servo_url::ServoUrl;
|
||||
use servo_url::{MutableOrigin, ServoUrl};
|
||||
use std::default::Default;
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
|
@ -59,6 +59,7 @@ pub fn prepare_workerscope_init(global: &GlobalScope,
|
|||
scheduler_chan: global.scheduler_chan().clone(),
|
||||
worker_id: global.get_next_worker_id(),
|
||||
pipeline_id: global.pipeline_id(),
|
||||
origin: global.origin().immutable().clone(),
|
||||
};
|
||||
|
||||
init
|
||||
|
@ -109,7 +110,8 @@ impl WorkerGlobalScope {
|
|||
init.constellation_chan,
|
||||
init.scheduler_chan,
|
||||
init.resource_threads,
|
||||
timer_event_chan),
|
||||
timer_event_chan,
|
||||
MutableOrigin::new(init.origin)),
|
||||
worker_id: init.worker_id,
|
||||
worker_url: worker_url,
|
||||
closing: closing,
|
||||
|
|
|
@ -1784,6 +1784,7 @@ impl ScriptThread {
|
|||
incomplete.pipeline_id,
|
||||
incomplete.parent_info,
|
||||
incomplete.window_size,
|
||||
incomplete.origin.clone(),
|
||||
self.webvr_thread.clone());
|
||||
|
||||
// Initialize the browsing context for the window.
|
||||
|
|
|
@ -777,6 +777,8 @@ pub struct WorkerGlobalScopeInit {
|
|||
pub worker_id: WorkerId,
|
||||
/// The pipeline id
|
||||
pub pipeline_id: PipelineId,
|
||||
/// The origin
|
||||
pub origin: ImmutableOrigin,
|
||||
}
|
||||
|
||||
/// Common entities representing a network load origin
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue