mirror of
https://github.com/servo/servo.git
synced 2025-06-08 08:33:26 +00:00
Rename GlobalRoot::root_ref() to GlobalRoot::r() for consistency.
This commit is contained in:
parent
d09d245ee1
commit
6077ed0ce8
9 changed files with 23 additions and 23 deletions
|
@ -147,7 +147,7 @@ impl CallSetup {
|
|||
pub fn new<T: CallbackContainer>(callback: T, handling: ExceptionHandling) -> CallSetup {
|
||||
let global = global_object_for_js_object(callback.callback());
|
||||
let global = global.root();
|
||||
let cx = global.root_ref().get_cx();
|
||||
let cx = global.r().get_cx();
|
||||
CallSetup {
|
||||
cx: cx,
|
||||
_handling: handling
|
||||
|
|
|
@ -2222,7 +2222,7 @@ class CGCallGenerator(CGThing):
|
|||
" Ok(result) => result,\n"
|
||||
" Err(e) => {\n"
|
||||
"%s"
|
||||
" throw_dom_exception(cx, global.root_ref(), e);\n"
|
||||
" throw_dom_exception(cx, global.r(), e);\n"
|
||||
" return%s;\n"
|
||||
" },\n"
|
||||
"};" % (glob, errorResult)))
|
||||
|
@ -4014,7 +4014,7 @@ let global = global_object_for_js_object(JS_CALLEE(cx, vp).to_object());
|
|||
let global = global.root();
|
||||
""")
|
||||
nativeName = MakeNativeName(self._ctor.identifier.name)
|
||||
callGenerator = CGMethodCall(["&global.root_ref()"], nativeName, True,
|
||||
callGenerator = CGMethodCall(["&global.r()"], nativeName, True,
|
||||
self.descriptor, self._ctor)
|
||||
return CGList([preamble, callGenerator])
|
||||
|
||||
|
|
|
@ -101,7 +101,7 @@ impl<'a> Reflectable for GlobalRef<'a> {
|
|||
impl GlobalRoot {
|
||||
/// Obtain a safe reference to the global object that cannot outlive the
|
||||
/// lifetime of this root.
|
||||
pub fn root_ref<'c>(&'c self) -> GlobalRef<'c> {
|
||||
pub fn r<'c>(&'c self) -> GlobalRef<'c> {
|
||||
match *self {
|
||||
GlobalRoot::Window(ref window) => GlobalRef::Window(window.r()),
|
||||
GlobalRoot::Worker(ref worker) => GlobalRef::Worker(worker.r()),
|
||||
|
|
|
@ -121,13 +121,13 @@ impl<'a> BlobMethods for JSRef<'a, Blob> {
|
|||
let span: i64 = max(relativeEnd - relativeStart, 0);
|
||||
let global = self.global.root();
|
||||
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) => {
|
||||
let start = relativeStart.to_uint().unwrap();
|
||||
let end = (relativeStart + span).to_uint().unwrap();
|
||||
let mut bytes: Vec<u8> = Vec::new();
|
||||
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())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -116,6 +116,6 @@ impl PrivateFormDataHelpers for FormData {
|
|||
let global = self.global.root();
|
||||
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()));
|
||||
File::new(&global.root_ref(), value, name)
|
||||
File::new(&global.r(), value, name)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,13 +38,13 @@ impl Storage {
|
|||
|
||||
fn get_url(&self) -> Url {
|
||||
let global_root = self.global.root();
|
||||
let global_ref = global_root.root_ref();
|
||||
let global_ref = global_root.r();
|
||||
global_ref.get_url()
|
||||
}
|
||||
|
||||
fn get_storage_task(&self) -> StorageTask {
|
||||
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()
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ impl<'a> TestBindingMethods for JSRef<'a, TestBinding> {
|
|||
fn SetEnumAttribute(self, _: TestEnum) {}
|
||||
fn InterfaceAttribute(self) -> Temporary<Blob> {
|
||||
let global = self.global.root();
|
||||
Blob::new(&global.root_ref(), None, "")
|
||||
Blob::new(&global.r(), None, "")
|
||||
}
|
||||
fn SetInterfaceAttribute(self, _: JSRef<Blob>) {}
|
||||
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 GetInterfaceAttributeNullable(self) -> Option<Temporary<Blob>> {
|
||||
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 GetUnionAttributeNullable(self) -> Option<HTMLElementOrLong> { Some(eLong(0)) }
|
||||
|
@ -123,7 +123,7 @@ impl<'a> TestBindingMethods for JSRef<'a, TestBinding> {
|
|||
fn ReceiveEnum(self) -> TestEnum { _empty }
|
||||
fn ReceiveInterface(self) -> Temporary<Blob> {
|
||||
let global = self.global.root();
|
||||
Blob::new(&global.root_ref(), None, "")
|
||||
Blob::new(&global.r(), None, "")
|
||||
}
|
||||
fn ReceiveAny(self, _: *mut JSContext) -> JSVal { NullValue() }
|
||||
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 ReceiveNullableInterface(self) -> Option<Temporary<Blob>> {
|
||||
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 ReceiveNullableUnion2(self) -> Option<EventOrString> { Some(eString("".into_string())) }
|
||||
|
|
|
@ -89,13 +89,13 @@ impl Worker {
|
|||
let mut message = UndefinedValue();
|
||||
unsafe {
|
||||
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,
|
||||
ptr::null(), ptr::null_mut()) != 0);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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)));
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -367,7 +367,7 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> {
|
|||
*self.request_method.borrow_mut() = maybe_method.unwrap();
|
||||
|
||||
// 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()) {
|
||||
Ok(parsed) => parsed,
|
||||
Err(_) => return Err(Syntax) // Step 7
|
||||
|
@ -535,7 +535,7 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> {
|
|||
}
|
||||
|
||||
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 mut load_data = LoadData::new(self.request_url.borrow().clone().unwrap(), start_chan);
|
||||
load_data.data = extracted;
|
||||
|
@ -579,7 +579,7 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> {
|
|||
*self.terminate_sender.borrow_mut() = Some(terminate_sender);
|
||||
|
||||
// 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() {
|
||||
RequestMode::ForcedPreflight
|
||||
} else {
|
||||
|
@ -613,11 +613,11 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> {
|
|||
terminate_receiver, cors_request, gen_id, start_port);
|
||||
} else {
|
||||
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
|
||||
// the object will stay alive as long as there are (possibly cancelled)
|
||||
// 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());
|
||||
spawn_named("XHRTask", proc() {
|
||||
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)
|
||||
self.ready_state.set(rs);
|
||||
let global = self.global.root();
|
||||
let event = Event::new(global.root_ref(),
|
||||
let event = Event::new(global.r(),
|
||||
"readystatechange".into_string(),
|
||||
EventBubbles::DoesNotBubble,
|
||||
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>) {
|
||||
let global = self.global.root();
|
||||
let upload_target = self.upload.root();
|
||||
let progressevent = ProgressEvent::new(global.root_ref(),
|
||||
let progressevent = ProgressEvent::new(global.r(),
|
||||
type_, false, false,
|
||||
total.is_some(), loaded,
|
||||
total.unwrap_or(0)).root();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue