aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py4
-rw-r--r--components/script/dom/bindings/interface.rs11
-rw-r--r--components/script/dom/dedicatedworkerglobalscope.rs6
-rw-r--r--components/script/dom/serviceworkerglobalscope.rs6
-rw-r--r--components/script/dom/window.rs13
5 files changed, 19 insertions, 21 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index e7a0541c4da..09dc19ce411 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -2597,6 +2597,7 @@ class CGWrapGlobalMethod(CGAbstractMethod):
values["members"] = "\n".join(members)
return CGGeneric("""\
+let origin = object.origin().clone();
let raw = Box::into_raw(object);
let _rt = RootedTraceable::new(&*raw);
@@ -2606,7 +2607,8 @@ create_global_object(
&Class.base,
raw as *const libc::c_void,
_trace,
- obj.handle_mut());
+ obj.handle_mut(),
+ &origin);
assert!(!obj.is_null());
(*raw).init_reflector(obj.get());
diff --git a/components/script/dom/bindings/interface.rs b/components/script/dom/bindings/interface.rs
index ef9651dcb62..3138c00cb89 100644
--- a/components/script/dom/bindings/interface.rs
+++ b/components/script/dom/bindings/interface.rs
@@ -12,7 +12,7 @@ use dom::bindings::guard::Guard;
use dom::bindings::utils::{DOM_PROTOTYPE_SLOT, ProtoOrIfaceArray, get_proto_or_iface_array};
use dom::window::Window;
use js::error::throw_type_error;
-use js::glue::{CreateServoJSPrincipal, RUST_SYMBOL_TO_JSID, UncheckedUnwrapObject};
+use js::glue::{CreateRustJSPrincipal, RUST_SYMBOL_TO_JSID, UncheckedUnwrapObject};
use js::jsapi::{Class, ClassOps, CompartmentOptions, GetGlobalForObjectCrossCompartment};
use js::jsapi::{GetWellKnownSymbol, HandleObject, HandleValue, JSAutoCompartment};
use js::jsapi::{JSClass, JSContext, JSFUN_CONSTRUCTOR, JSFunctionSpec, JSObject};
@@ -29,6 +29,7 @@ use js::jsapi::{TrueHandleValue, Value};
use js::jsval::{JSVal, PrivateValue};
use js::rust::{define_methods, define_properties, get_object_class};
use libc;
+use servo_url::MutableOrigin;
use std::ptr;
/// The class of a non-callback interface object.
@@ -131,7 +132,8 @@ pub unsafe fn create_global_object(
class: &'static JSClass,
private: *const libc::c_void,
trace: TraceHook,
- rval: MutableHandleObject) {
+ rval: MutableHandleObject,
+ origin: &MutableOrigin) {
assert!(rval.is_null());
let mut options = CompartmentOptions::default();
@@ -139,9 +141,8 @@ pub unsafe fn create_global_object(
options.creationOptions_.traceGlobal_ = Some(trace);
options.creationOptions_.sharedMemoryAndAtomics_ = true;
- let x = private.clone() as *const Window;
- let obj = &*x;
- let mut principal = CreateServoJSPrincipal(Box::into_raw(obj.origin()) as *const ::libc::c_void,
+ let origin = Box::new(origin.clone());
+ let mut principal = CreateRustJSPrincipal(Box::into_raw(origin) as *const ::libc::c_void,
None,
None);
diff --git a/components/script/dom/dedicatedworkerglobalscope.rs b/components/script/dom/dedicatedworkerglobalscope.rs
index 14dd070f44d..80b7982d35b 100644
--- a/components/script/dom/dedicatedworkerglobalscope.rs
+++ b/components/script/dom/dedicatedworkerglobalscope.rs
@@ -34,7 +34,7 @@ use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort, StackRootTLS, get_
use script_runtime::ScriptThreadEventCategory::WorkerEvent;
use script_traits::{TimerEvent, TimerSource, WorkerGlobalScopeInit, WorkerScriptLoadOrigin};
use servo_rand::random;
-use servo_url::ServoUrl;
+use servo_url::{MutableOrigin, ServoUrl};
use std::mem::replace;
use std::sync::{Arc, Mutex};
use std::sync::atomic::AtomicBool;
@@ -146,6 +146,10 @@ impl DedicatedWorkerGlobalScope {
}
}
+ pub fn origin(&self) -> MutableOrigin {
+ MutableOrigin::new(self.workerglobalscope.get_url().origin())
+ }
+
#[allow(unsafe_code)]
pub fn run_worker_scope(init: WorkerGlobalScopeInit,
worker_url: ServoUrl,
diff --git a/components/script/dom/serviceworkerglobalscope.rs b/components/script/dom/serviceworkerglobalscope.rs
index 953a6ae8328..ef69014c109 100644
--- a/components/script/dom/serviceworkerglobalscope.rs
+++ b/components/script/dom/serviceworkerglobalscope.rs
@@ -30,7 +30,7 @@ use script_runtime::{CommonScriptMsg, StackRootTLS, get_reports, new_rt_and_cx,
use script_traits::{TimerEvent, WorkerGlobalScopeInit, ScopeThings, ServiceWorkerMsg, WorkerScriptLoadOrigin};
use servo_config::prefs::PREFS;
use servo_rand::random;
-use servo_url::ServoUrl;
+use servo_url::{MutableOrigin, ServoUrl};
use std::sync::mpsc::{Receiver, RecvError, Select, Sender, channel};
use std::thread;
use std::time::Duration;
@@ -138,6 +138,10 @@ impl ServiceWorkerGlobalScope {
}
}
+ pub fn origin(&self) -> MutableOrigin {
+ MutableOrigin::new(self.scope_url.origin())
+ }
+
#[allow(unsafe_code)]
pub fn run_serviceworker_scope(scope_things: ScopeThings,
own_sender: Sender<ServiceWorkerScriptMsg>,
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index 7f1521b0029..7724f5b8d5f 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -273,9 +273,6 @@ pub struct Window {
/// Directory to store unminified scripts for this window if unminify-js
/// opt is enabled.
unminified_js_dir: DOMRefCell<Option<String>>,
-
- /// origin for cross origin wrappers
- origin: Box<MutableOrigin>
}
impl Window {
@@ -297,10 +294,6 @@ impl Window {
self.js_runtime.borrow().as_ref().unwrap().cx()
}
- pub fn get_origin(&self) -> Box<MutableOrigin> {
- self.origin.clone()
- }
-
pub fn dom_manipulation_task_source(&self) -> DOMManipulationTaskSource {
self.dom_manipulation_task_source.clone()
}
@@ -1818,7 +1811,6 @@ impl Window {
suppress_reflow: Cell::new(true),
pending_reflow_count: Cell::new(0),
current_state: Cell::new(WindowState::Alive),
-
devtools_marker_sender: DOMRefCell::new(None),
devtools_markers: DOMRefCell::new(HashSet::new()),
webdriver_script_chan: DOMRefCell::new(None),
@@ -1831,17 +1823,12 @@ impl Window {
permission_state_invocation_results: DOMRefCell::new(HashMap::new()),
pending_layout_images: DOMRefCell::new(HashMap::new()),
unminified_js_dir: DOMRefCell::new(None),
- origin: Box::new(origin),
};
unsafe {
WindowBinding::Wrap(runtime.cx(), win)
}
}
-
- pub fn origin(&self) -> Box<MutableOrigin> {
- self.origin.clone()
- }
}
fn should_move_clip_rect(clip_rect: Rect<Au>, new_viewport: Rect<f32>) -> bool {