Rename GlobalRoot::root_ref() to GlobalRoot::r() for consistency.

This commit is contained in:
Ms2ger 2015-01-01 12:21:47 +01:00
parent d09d245ee1
commit 6077ed0ce8
9 changed files with 23 additions and 23 deletions

View file

@ -147,7 +147,7 @@ impl CallSetup {
pub fn new<T: CallbackContainer>(callback: T, handling: ExceptionHandling) -> CallSetup { pub fn new<T: CallbackContainer>(callback: T, handling: ExceptionHandling) -> CallSetup {
let global = global_object_for_js_object(callback.callback()); let global = global_object_for_js_object(callback.callback());
let global = global.root(); let global = global.root();
let cx = global.root_ref().get_cx(); let cx = global.r().get_cx();
CallSetup { CallSetup {
cx: cx, cx: cx,
_handling: handling _handling: handling

View file

@ -2222,7 +2222,7 @@ class CGCallGenerator(CGThing):
" Ok(result) => result,\n" " Ok(result) => result,\n"
" Err(e) => {\n" " Err(e) => {\n"
"%s" "%s"
" throw_dom_exception(cx, global.root_ref(), e);\n" " throw_dom_exception(cx, global.r(), e);\n"
" return%s;\n" " return%s;\n"
" },\n" " },\n"
"};" % (glob, errorResult))) "};" % (glob, errorResult)))
@ -4014,7 +4014,7 @@ let global = global_object_for_js_object(JS_CALLEE(cx, vp).to_object());
let global = global.root(); let global = global.root();
""") """)
nativeName = MakeNativeName(self._ctor.identifier.name) nativeName = MakeNativeName(self._ctor.identifier.name)
callGenerator = CGMethodCall(["&global.root_ref()"], nativeName, True, callGenerator = CGMethodCall(["&global.r()"], nativeName, True,
self.descriptor, self._ctor) self.descriptor, self._ctor)
return CGList([preamble, callGenerator]) return CGList([preamble, callGenerator])

View file

@ -101,7 +101,7 @@ impl<'a> Reflectable for GlobalRef<'a> {
impl GlobalRoot { impl GlobalRoot {
/// Obtain a safe reference to the global object that cannot outlive the /// Obtain a safe reference to the global object that cannot outlive the
/// lifetime of this root. /// lifetime of this root.
pub fn root_ref<'c>(&'c self) -> GlobalRef<'c> { pub fn r<'c>(&'c self) -> GlobalRef<'c> {
match *self { match *self {
GlobalRoot::Window(ref window) => GlobalRef::Window(window.r()), GlobalRoot::Window(ref window) => GlobalRef::Window(window.r()),
GlobalRoot::Worker(ref worker) => GlobalRef::Worker(worker.r()), GlobalRoot::Worker(ref worker) => GlobalRef::Worker(worker.r()),

View file

@ -121,13 +121,13 @@ impl<'a> BlobMethods for JSRef<'a, Blob> {
let span: i64 = max(relativeEnd - relativeStart, 0); let span: i64 = max(relativeEnd - relativeStart, 0);
let global = self.global.root(); let global = self.global.root();
match self.bytes { match self.bytes {
None => Blob::new(&global.root_ref(), None, relativeContentType.as_slice()), None => Blob::new(&global.r(), None, relativeContentType.as_slice()),
Some(ref vec) => { Some(ref vec) => {
let start = relativeStart.to_uint().unwrap(); let start = relativeStart.to_uint().unwrap();
let end = (relativeStart + span).to_uint().unwrap(); let end = (relativeStart + span).to_uint().unwrap();
let mut bytes: Vec<u8> = Vec::new(); let mut bytes: Vec<u8> = Vec::new();
bytes.push_all(vec.slice(start, end)); bytes.push_all(vec.slice(start, end));
Blob::new(&global.root_ref(), Some(bytes), relativeContentType.as_slice()) Blob::new(&global.r(), Some(bytes), relativeContentType.as_slice())
} }
} }
} }

View file

@ -116,6 +116,6 @@ impl PrivateFormDataHelpers for FormData {
let global = self.global.root(); let global = self.global.root();
let f: Option<JSRef<File>> = FileCast::to_ref(value); let f: Option<JSRef<File>> = FileCast::to_ref(value);
let name = filename.unwrap_or(f.map(|inner| inner.name().clone()).unwrap_or("blob".into_string())); let name = filename.unwrap_or(f.map(|inner| inner.name().clone()).unwrap_or("blob".into_string()));
File::new(&global.root_ref(), value, name) File::new(&global.r(), value, name)
} }
} }

View file

@ -38,13 +38,13 @@ impl Storage {
fn get_url(&self) -> Url { fn get_url(&self) -> Url {
let global_root = self.global.root(); let global_root = self.global.root();
let global_ref = global_root.root_ref(); let global_ref = global_root.r();
global_ref.get_url() global_ref.get_url()
} }
fn get_storage_task(&self) -> StorageTask { fn get_storage_task(&self) -> StorageTask {
let global_root = self.global.root(); let global_root = self.global.root();
let global_ref = global_root.root_ref(); let global_ref = global_root.r();
global_ref.as_window().storage_task() global_ref.as_window().storage_task()
} }

View file

@ -59,7 +59,7 @@ impl<'a> TestBindingMethods for JSRef<'a, TestBinding> {
fn SetEnumAttribute(self, _: TestEnum) {} fn SetEnumAttribute(self, _: TestEnum) {}
fn InterfaceAttribute(self) -> Temporary<Blob> { fn InterfaceAttribute(self) -> Temporary<Blob> {
let global = self.global.root(); let global = self.global.root();
Blob::new(&global.root_ref(), None, "") Blob::new(&global.r(), None, "")
} }
fn SetInterfaceAttribute(self, _: JSRef<Blob>) {} fn SetInterfaceAttribute(self, _: JSRef<Blob>) {}
fn UnionAttribute(self) -> HTMLElementOrLong { eLong(0) } fn UnionAttribute(self) -> HTMLElementOrLong { eLong(0) }
@ -99,7 +99,7 @@ impl<'a> TestBindingMethods for JSRef<'a, TestBinding> {
fn GetEnumAttributeNullable(self) -> Option<TestEnum> { Some(_empty) } fn GetEnumAttributeNullable(self) -> Option<TestEnum> { Some(_empty) }
fn GetInterfaceAttributeNullable(self) -> Option<Temporary<Blob>> { fn GetInterfaceAttributeNullable(self) -> Option<Temporary<Blob>> {
let global = self.global.root(); let global = self.global.root();
Some(Blob::new(&global.root_ref(), None, "")) Some(Blob::new(&global.r(), None, ""))
} }
fn SetInterfaceAttributeNullable(self, _: Option<JSRef<Blob>>) {} fn SetInterfaceAttributeNullable(self, _: Option<JSRef<Blob>>) {}
fn GetUnionAttributeNullable(self) -> Option<HTMLElementOrLong> { Some(eLong(0)) } fn GetUnionAttributeNullable(self) -> Option<HTMLElementOrLong> { Some(eLong(0)) }
@ -123,7 +123,7 @@ impl<'a> TestBindingMethods for JSRef<'a, TestBinding> {
fn ReceiveEnum(self) -> TestEnum { _empty } fn ReceiveEnum(self) -> TestEnum { _empty }
fn ReceiveInterface(self) -> Temporary<Blob> { fn ReceiveInterface(self) -> Temporary<Blob> {
let global = self.global.root(); let global = self.global.root();
Blob::new(&global.root_ref(), None, "") Blob::new(&global.r(), None, "")
} }
fn ReceiveAny(self, _: *mut JSContext) -> JSVal { NullValue() } fn ReceiveAny(self, _: *mut JSContext) -> JSVal { NullValue() }
fn ReceiveUnion(self) -> HTMLElementOrLong { eLong(0) } fn ReceiveUnion(self) -> HTMLElementOrLong { eLong(0) }
@ -145,7 +145,7 @@ impl<'a> TestBindingMethods for JSRef<'a, TestBinding> {
fn ReceiveNullableEnum(self) -> Option<TestEnum> { Some(_empty) } fn ReceiveNullableEnum(self) -> Option<TestEnum> { Some(_empty) }
fn ReceiveNullableInterface(self) -> Option<Temporary<Blob>> { fn ReceiveNullableInterface(self) -> Option<Temporary<Blob>> {
let global = self.global.root(); let global = self.global.root();
Some(Blob::new(&global.root_ref(), None, "")) Some(Blob::new(&global.r(), None, ""))
} }
fn ReceiveNullableUnion(self) -> Option<HTMLElementOrLong> { Some(eLong(0)) } fn ReceiveNullableUnion(self) -> Option<HTMLElementOrLong> { Some(eLong(0)) }
fn ReceiveNullableUnion2(self) -> Option<EventOrString> { Some(eString("".into_string())) } fn ReceiveNullableUnion2(self) -> Option<EventOrString> { Some(eString("".into_string())) }

View file

@ -89,13 +89,13 @@ impl Worker {
let mut message = UndefinedValue(); let mut message = UndefinedValue();
unsafe { unsafe {
assert!(JS_ReadStructuredClone( assert!(JS_ReadStructuredClone(
global.root_ref().get_cx(), data as *const u64, nbytes, global.r().get_cx(), data as *const u64, nbytes,
JS_STRUCTURED_CLONE_VERSION, &mut message, JS_STRUCTURED_CLONE_VERSION, &mut message,
ptr::null(), ptr::null_mut()) != 0); ptr::null(), ptr::null_mut()) != 0);
} }
let target: JSRef<EventTarget> = EventTargetCast::from_ref(worker.r()); let target: JSRef<EventTarget> = EventTargetCast::from_ref(worker.r());
MessageEvent::dispatch_jsval(target, global.root_ref(), message); MessageEvent::dispatch_jsval(target, global.r(), message);
} }
} }
@ -112,7 +112,7 @@ impl<'a> WorkerMethods for JSRef<'a, Worker> {
return Err(DataClone); return Err(DataClone);
} }
let address = Trusted::new(cx, self, self.global.root().root_ref().script_chan().clone()); let address = Trusted::new(cx, self, self.global.root().r().script_chan().clone());
self.sender.send((address, ScriptMsg::DOMMessage(data, nbytes))); self.sender.send((address, ScriptMsg::DOMMessage(data, nbytes)));
Ok(()) Ok(())
} }

View file

@ -367,7 +367,7 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> {
*self.request_method.borrow_mut() = maybe_method.unwrap(); *self.request_method.borrow_mut() = maybe_method.unwrap();
// Step 6 // Step 6
let base = self.global.root().root_ref().get_url(); let base = self.global.root().r().get_url();
let parsed_url = match UrlParser::new().base_url(&base).parse(url.as_slice()) { let parsed_url = match UrlParser::new().base_url(&base).parse(url.as_slice()) {
Ok(parsed) => parsed, Ok(parsed) => parsed,
Err(_) => return Err(Syntax) // Step 7 Err(_) => return Err(Syntax) // Step 7
@ -535,7 +535,7 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> {
} }
let global = self.global.root(); let global = self.global.root();
let resource_task = global.root_ref().resource_task(); let resource_task = global.r().resource_task();
let (start_chan, start_port) = channel(); let (start_chan, start_port) = channel();
let mut load_data = LoadData::new(self.request_url.borrow().clone().unwrap(), start_chan); let mut load_data = LoadData::new(self.request_url.borrow().clone().unwrap(), start_chan);
load_data.data = extracted; load_data.data = extracted;
@ -579,7 +579,7 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> {
*self.terminate_sender.borrow_mut() = Some(terminate_sender); *self.terminate_sender.borrow_mut() = Some(terminate_sender);
// CORS stuff // CORS stuff
let referer_url = self.global.root().root_ref().get_url(); let referer_url = self.global.root().r().get_url();
let mode = if self.upload_events.get() { let mode = if self.upload_events.get() {
RequestMode::ForcedPreflight RequestMode::ForcedPreflight
} else { } else {
@ -613,11 +613,11 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> {
terminate_receiver, cors_request, gen_id, start_port); terminate_receiver, cors_request, gen_id, start_port);
} else { } else {
self.fetch_time.set(time::now().to_timespec().sec); self.fetch_time.set(time::now().to_timespec().sec);
let script_chan = global.root_ref().script_chan(); let script_chan = global.r().script_chan();
// Pin the object before launching the fetch task. This is to ensure that // Pin the object before launching the fetch task. This is to ensure that
// the object will stay alive as long as there are (possibly cancelled) // the object will stay alive as long as there are (possibly cancelled)
// inflight events queued up in the script task's port. // inflight events queued up in the script task's port.
let addr = Trusted::new(self.global.root().root_ref().get_cx(), self, let addr = Trusted::new(self.global.root().r().get_cx(), self,
script_chan.clone()); script_chan.clone());
spawn_named("XHRTask", proc() { spawn_named("XHRTask", proc() {
let _ = XMLHttpRequest::fetch(&mut SyncOrAsync::Async(addr, script_chan), let _ = XMLHttpRequest::fetch(&mut SyncOrAsync::Async(addr, script_chan),
@ -764,7 +764,7 @@ impl<'a> PrivateXMLHttpRequestHelpers for JSRef<'a, XMLHttpRequest> {
assert!(self.ready_state.get() != rs) assert!(self.ready_state.get() != rs)
self.ready_state.set(rs); self.ready_state.set(rs);
let global = self.global.root(); let global = self.global.root();
let event = Event::new(global.root_ref(), let event = Event::new(global.r(),
"readystatechange".into_string(), "readystatechange".into_string(),
EventBubbles::DoesNotBubble, EventBubbles::DoesNotBubble,
EventCancelable::Cancelable).root(); EventCancelable::Cancelable).root();
@ -899,7 +899,7 @@ impl<'a> PrivateXMLHttpRequestHelpers for JSRef<'a, XMLHttpRequest> {
fn dispatch_progress_event(self, upload: bool, type_: DOMString, loaded: u64, total: Option<u64>) { fn dispatch_progress_event(self, upload: bool, type_: DOMString, loaded: u64, total: Option<u64>) {
let global = self.global.root(); let global = self.global.root();
let upload_target = self.upload.root(); let upload_target = self.upload.root();
let progressevent = ProgressEvent::new(global.root_ref(), let progressevent = ProgressEvent::new(global.r(),
type_, false, false, type_, false, false,
total.is_some(), loaded, total.is_some(), loaded,
total.unwrap_or(0)).root(); total.unwrap_or(0)).root();