mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Remove Reflectable::global
This commit is contained in:
parent
e7a1149984
commit
907781eb75
8 changed files with 15 additions and 22 deletions
|
@ -46,7 +46,7 @@ pub fn consume_body<T: BodyOperations + Reflectable>(object: &T, body_type: Body
|
|||
|
||||
// Step 1
|
||||
if object.get_body_used() || object.is_locked() {
|
||||
promise.reject_error(promise.global().r().get_cx(), Error::Type(
|
||||
promise.reject_error(promise.global_scope().get_cx(), Error::Type(
|
||||
"The response's stream is disturbed or locked".to_string()));
|
||||
return promise;
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ pub fn consume_body_with_promise<T: BodyOperations + Reflectable>(object: &T,
|
|||
body_type,
|
||||
object.get_mime_type());
|
||||
|
||||
let cx = promise.global().r().get_cx();
|
||||
let cx = promise.global_scope().get_cx();
|
||||
match pkg_data_results {
|
||||
Ok(results) => {
|
||||
match results {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
//! The `Reflector` struct.
|
||||
|
||||
use dom::bindings::conversions::DerivedFrom;
|
||||
use dom::bindings::global::{GlobalRoot, global_root_from_object, global_scope_from_reflector};
|
||||
use dom::bindings::global::global_scope_from_reflector;
|
||||
use dom::bindings::js::Root;
|
||||
use dom::globalscope::GlobalScope;
|
||||
use js::jsapi::{HandleObject, JSContext, JSObject};
|
||||
|
@ -84,11 +84,6 @@ pub trait Reflectable {
|
|||
fn global_scope(&self) -> Root<GlobalScope> where Self: Sized {
|
||||
global_scope_from_reflector(self)
|
||||
}
|
||||
|
||||
/// Returns the global object of the realm that the Reflectable was created in.
|
||||
fn global(&self) -> GlobalRoot where Self: Sized {
|
||||
unsafe { global_root_from_object(*self.reflector().get_jsobject()) }
|
||||
}
|
||||
}
|
||||
|
||||
/// A trait to initialize the `Reflector` for a DOM object.
|
||||
|
|
|
@ -275,8 +275,8 @@ pub fn result_to_promise<T: ToJSValConvertible>(global: &GlobalScope,
|
|||
-> Rc<Promise> {
|
||||
let p = Promise::new(global);
|
||||
match bluetooth_result {
|
||||
Ok(v) => p.resolve_native(p.global().r().get_cx(), &v),
|
||||
Err(e) => p.reject_error(p.global().r().get_cx(), e),
|
||||
Ok(v) => p.resolve_native(p.global_scope().get_cx(), &v),
|
||||
Err(e) => p.reject_error(p.global_scope().get_cx(), e),
|
||||
}
|
||||
p
|
||||
}
|
||||
|
|
|
@ -154,8 +154,7 @@ impl CompiledEventListener {
|
|||
match *handler {
|
||||
CommonEventHandler::ErrorEventHandler(ref handler) => {
|
||||
if let Some(event) = event.downcast::<ErrorEvent>() {
|
||||
let global = object.global();
|
||||
let cx = global.r().get_cx();
|
||||
let cx = object.global_scope().get_cx();
|
||||
rooted!(in(cx) let error = event.Error(cx));
|
||||
let return_value = handler.Call_(object,
|
||||
EventOrString::String(event.Message()),
|
||||
|
@ -201,8 +200,7 @@ impl CompiledEventListener {
|
|||
|
||||
CommonEventHandler::EventHandler(ref handler) => {
|
||||
if let Ok(value) = handler.Call_(object, event, exception_handle) {
|
||||
let global = object.global();
|
||||
let cx = global.r().get_cx();
|
||||
let cx = object.global_scope().get_cx();
|
||||
rooted!(in(cx) let value = value);
|
||||
let value = value.handle();
|
||||
|
||||
|
|
|
@ -355,6 +355,7 @@ impl FileReader {
|
|||
let fr = Trusted::new(self);
|
||||
let gen_id = self.generation_id.get();
|
||||
|
||||
let global = self.global_scope();
|
||||
let wrapper = global.get_runnable_wrapper();
|
||||
let task_source = global.file_reading_task_source();
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ impl PromiseHelper for Rc<Promise> {
|
|||
impl Drop for Promise {
|
||||
#[allow(unsafe_code)]
|
||||
fn drop(&mut self) {
|
||||
let cx = self.global().r().get_cx();
|
||||
let cx = self.global_scope().get_cx();
|
||||
unsafe {
|
||||
RemoveRawValueRoot(cx, self.permanent_js_root.get_unsafe());
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ impl Promise {
|
|||
|
||||
#[allow(unsafe_code, unrooted_must_root)]
|
||||
pub fn duplicate(&self) -> Rc<Promise> {
|
||||
let cx = self.global().r().get_cx();
|
||||
let cx = self.global_scope().get_cx();
|
||||
unsafe {
|
||||
Promise::new_with_js_promise(self.reflector().get_jsobject(), cx)
|
||||
}
|
||||
|
@ -210,8 +210,7 @@ impl Promise {
|
|||
|
||||
#[allow(unsafe_code)]
|
||||
pub fn append_native_handler(&self, handler: &PromiseNativeHandler) {
|
||||
let global = self.global();
|
||||
let cx = global.r().get_cx();
|
||||
let cx = self.global_scope().get_cx();
|
||||
rooted!(in(cx) let resolve_func =
|
||||
create_native_handler_function(cx,
|
||||
handler.reflector().get_jsobject(),
|
||||
|
|
|
@ -673,7 +673,7 @@ impl TestBindingMethods for TestBinding {
|
|||
}
|
||||
|
||||
fn PromiseRejectWithTypeError(&self, p: &Promise, s: USVString) {
|
||||
p.reject_error(self.global().r().get_cx(), Error::Type(s.0));
|
||||
p.reject_error(self.global_scope().get_cx(), Error::Type(s.0));
|
||||
}
|
||||
|
||||
#[allow(unrooted_must_root)]
|
||||
|
@ -789,7 +789,7 @@ impl TestBindingCallback {
|
|||
#[allow(unrooted_must_root)]
|
||||
pub fn invoke(self) {
|
||||
let p = self.promise.root();
|
||||
let cx = p.global().r().get_cx();
|
||||
let cx = p.global_scope().get_cx();
|
||||
let _ac = JSAutoCompartment::new(cx, p.reflector().get_jsobject().get());
|
||||
p.resolve_native(cx, &self.value);
|
||||
}
|
||||
|
|
|
@ -124,13 +124,13 @@ impl FetchResponseListener for FetchContext {
|
|||
|
||||
// JSAutoCompartment needs to be manually made.
|
||||
// Otherwise, Servo will crash.
|
||||
let promise_cx = promise.global().r().get_cx();
|
||||
let promise_cx = promise.global_scope().get_cx();
|
||||
let _ac = JSAutoCompartment::new(promise_cx, promise.reflector().get_jsobject().get());
|
||||
match fetch_metadata {
|
||||
// Step 4.1
|
||||
Err(_) => {
|
||||
promise.reject_error(
|
||||
promise.global().r().get_cx(),
|
||||
promise.global_scope().get_cx(),
|
||||
Error::Type("Network error occurred".to_string()));
|
||||
self.fetch_promise = Some(TrustedPromise::new(promise));
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue