mirror of
https://github.com/servo/servo.git
synced 2025-07-29 10:10:34 +01:00
changed to use globalscope origin
This commit is contained in:
parent
3577d1ff94
commit
aa7b4f6162
5 changed files with 19 additions and 21 deletions
|
@ -2597,6 +2597,7 @@ class CGWrapGlobalMethod(CGAbstractMethod):
|
||||||
values["members"] = "\n".join(members)
|
values["members"] = "\n".join(members)
|
||||||
|
|
||||||
return CGGeneric("""\
|
return CGGeneric("""\
|
||||||
|
let origin = object.origin().clone();
|
||||||
let raw = Box::into_raw(object);
|
let raw = Box::into_raw(object);
|
||||||
let _rt = RootedTraceable::new(&*raw);
|
let _rt = RootedTraceable::new(&*raw);
|
||||||
|
|
||||||
|
@ -2606,7 +2607,8 @@ create_global_object(
|
||||||
&Class.base,
|
&Class.base,
|
||||||
raw as *const libc::c_void,
|
raw as *const libc::c_void,
|
||||||
_trace,
|
_trace,
|
||||||
obj.handle_mut());
|
obj.handle_mut(),
|
||||||
|
&origin);
|
||||||
assert!(!obj.is_null());
|
assert!(!obj.is_null());
|
||||||
|
|
||||||
(*raw).init_reflector(obj.get());
|
(*raw).init_reflector(obj.get());
|
||||||
|
|
|
@ -12,7 +12,7 @@ use dom::bindings::guard::Guard;
|
||||||
use dom::bindings::utils::{DOM_PROTOTYPE_SLOT, ProtoOrIfaceArray, get_proto_or_iface_array};
|
use dom::bindings::utils::{DOM_PROTOTYPE_SLOT, ProtoOrIfaceArray, get_proto_or_iface_array};
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
use js::error::throw_type_error;
|
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::{Class, ClassOps, CompartmentOptions, GetGlobalForObjectCrossCompartment};
|
||||||
use js::jsapi::{GetWellKnownSymbol, HandleObject, HandleValue, JSAutoCompartment};
|
use js::jsapi::{GetWellKnownSymbol, HandleObject, HandleValue, JSAutoCompartment};
|
||||||
use js::jsapi::{JSClass, JSContext, JSFUN_CONSTRUCTOR, JSFunctionSpec, JSObject};
|
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::jsval::{JSVal, PrivateValue};
|
||||||
use js::rust::{define_methods, define_properties, get_object_class};
|
use js::rust::{define_methods, define_properties, get_object_class};
|
||||||
use libc;
|
use libc;
|
||||||
|
use servo_url::MutableOrigin;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
/// The class of a non-callback interface object.
|
/// The class of a non-callback interface object.
|
||||||
|
@ -131,7 +132,8 @@ pub unsafe fn create_global_object(
|
||||||
class: &'static JSClass,
|
class: &'static JSClass,
|
||||||
private: *const libc::c_void,
|
private: *const libc::c_void,
|
||||||
trace: TraceHook,
|
trace: TraceHook,
|
||||||
rval: MutableHandleObject) {
|
rval: MutableHandleObject,
|
||||||
|
origin: &MutableOrigin) {
|
||||||
assert!(rval.is_null());
|
assert!(rval.is_null());
|
||||||
|
|
||||||
let mut options = CompartmentOptions::default();
|
let mut options = CompartmentOptions::default();
|
||||||
|
@ -139,9 +141,8 @@ pub unsafe fn create_global_object(
|
||||||
options.creationOptions_.traceGlobal_ = Some(trace);
|
options.creationOptions_.traceGlobal_ = Some(trace);
|
||||||
options.creationOptions_.sharedMemoryAndAtomics_ = true;
|
options.creationOptions_.sharedMemoryAndAtomics_ = true;
|
||||||
|
|
||||||
let x = private.clone() as *const Window;
|
let origin = Box::new(origin.clone());
|
||||||
let obj = &*x;
|
let mut principal = CreateRustJSPrincipal(Box::into_raw(origin) as *const ::libc::c_void,
|
||||||
let mut principal = CreateServoJSPrincipal(Box::into_raw(obj.origin()) as *const ::libc::c_void,
|
|
||||||
None,
|
None,
|
||||||
None);
|
None);
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort, StackRootTLS, get_
|
||||||
use script_runtime::ScriptThreadEventCategory::WorkerEvent;
|
use script_runtime::ScriptThreadEventCategory::WorkerEvent;
|
||||||
use script_traits::{TimerEvent, TimerSource, WorkerGlobalScopeInit, WorkerScriptLoadOrigin};
|
use script_traits::{TimerEvent, TimerSource, WorkerGlobalScopeInit, WorkerScriptLoadOrigin};
|
||||||
use servo_rand::random;
|
use servo_rand::random;
|
||||||
use servo_url::ServoUrl;
|
use servo_url::{MutableOrigin, ServoUrl};
|
||||||
use std::mem::replace;
|
use std::mem::replace;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use std::sync::atomic::AtomicBool;
|
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)]
|
#[allow(unsafe_code)]
|
||||||
pub fn run_worker_scope(init: WorkerGlobalScopeInit,
|
pub fn run_worker_scope(init: WorkerGlobalScopeInit,
|
||||||
worker_url: ServoUrl,
|
worker_url: ServoUrl,
|
||||||
|
|
|
@ -30,7 +30,7 @@ use script_runtime::{CommonScriptMsg, StackRootTLS, get_reports, new_rt_and_cx,
|
||||||
use script_traits::{TimerEvent, WorkerGlobalScopeInit, ScopeThings, ServiceWorkerMsg, WorkerScriptLoadOrigin};
|
use script_traits::{TimerEvent, WorkerGlobalScopeInit, ScopeThings, ServiceWorkerMsg, WorkerScriptLoadOrigin};
|
||||||
use servo_config::prefs::PREFS;
|
use servo_config::prefs::PREFS;
|
||||||
use servo_rand::random;
|
use servo_rand::random;
|
||||||
use servo_url::ServoUrl;
|
use servo_url::{MutableOrigin, ServoUrl};
|
||||||
use std::sync::mpsc::{Receiver, RecvError, Select, Sender, channel};
|
use std::sync::mpsc::{Receiver, RecvError, Select, Sender, channel};
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
@ -138,6 +138,10 @@ impl ServiceWorkerGlobalScope {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn origin(&self) -> MutableOrigin {
|
||||||
|
MutableOrigin::new(self.scope_url.origin())
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(unsafe_code)]
|
#[allow(unsafe_code)]
|
||||||
pub fn run_serviceworker_scope(scope_things: ScopeThings,
|
pub fn run_serviceworker_scope(scope_things: ScopeThings,
|
||||||
own_sender: Sender<ServiceWorkerScriptMsg>,
|
own_sender: Sender<ServiceWorkerScriptMsg>,
|
||||||
|
|
|
@ -273,9 +273,6 @@ pub struct Window {
|
||||||
/// Directory to store unminified scripts for this window if unminify-js
|
/// Directory to store unminified scripts for this window if unminify-js
|
||||||
/// opt is enabled.
|
/// opt is enabled.
|
||||||
unminified_js_dir: DOMRefCell<Option<String>>,
|
unminified_js_dir: DOMRefCell<Option<String>>,
|
||||||
|
|
||||||
/// origin for cross origin wrappers
|
|
||||||
origin: Box<MutableOrigin>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Window {
|
impl Window {
|
||||||
|
@ -297,10 +294,6 @@ impl Window {
|
||||||
self.js_runtime.borrow().as_ref().unwrap().cx()
|
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 {
|
pub fn dom_manipulation_task_source(&self) -> DOMManipulationTaskSource {
|
||||||
self.dom_manipulation_task_source.clone()
|
self.dom_manipulation_task_source.clone()
|
||||||
}
|
}
|
||||||
|
@ -1818,7 +1811,6 @@ impl Window {
|
||||||
suppress_reflow: Cell::new(true),
|
suppress_reflow: Cell::new(true),
|
||||||
pending_reflow_count: Cell::new(0),
|
pending_reflow_count: Cell::new(0),
|
||||||
current_state: Cell::new(WindowState::Alive),
|
current_state: Cell::new(WindowState::Alive),
|
||||||
|
|
||||||
devtools_marker_sender: DOMRefCell::new(None),
|
devtools_marker_sender: DOMRefCell::new(None),
|
||||||
devtools_markers: DOMRefCell::new(HashSet::new()),
|
devtools_markers: DOMRefCell::new(HashSet::new()),
|
||||||
webdriver_script_chan: DOMRefCell::new(None),
|
webdriver_script_chan: DOMRefCell::new(None),
|
||||||
|
@ -1831,17 +1823,12 @@ impl Window {
|
||||||
permission_state_invocation_results: DOMRefCell::new(HashMap::new()),
|
permission_state_invocation_results: DOMRefCell::new(HashMap::new()),
|
||||||
pending_layout_images: DOMRefCell::new(HashMap::new()),
|
pending_layout_images: DOMRefCell::new(HashMap::new()),
|
||||||
unminified_js_dir: DOMRefCell::new(None),
|
unminified_js_dir: DOMRefCell::new(None),
|
||||||
origin: Box::new(origin),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
WindowBinding::Wrap(runtime.cx(), win)
|
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 {
|
fn should_move_clip_rect(clip_rect: Rect<Au>, new_viewport: Rect<f32>) -> bool {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue