mirror of
https://github.com/servo/servo.git
synced 2025-06-15 20:04:28 +00:00
Remove some Cells for immutable members.
This commit is contained in:
parent
e8d013794b
commit
a14bb68c3f
2 changed files with 10 additions and 12 deletions
|
@ -17,12 +17,10 @@ use servo_util::str::DOMString;
|
||||||
use js::jsapi::JSContext;
|
use js::jsapi::JSContext;
|
||||||
use js::jsval::{JSVal, NullValue};
|
use js::jsval::{JSVal, NullValue};
|
||||||
|
|
||||||
use std::cell::Cell;
|
|
||||||
|
|
||||||
#[deriving(Encodable)]
|
#[deriving(Encodable)]
|
||||||
pub struct TestBinding {
|
pub struct TestBinding {
|
||||||
reflector: Reflector,
|
reflector: Reflector,
|
||||||
global: Cell<JS<Window>>,
|
global: JS<Window>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait TestBindingMethods {
|
pub trait TestBindingMethods {
|
||||||
|
@ -279,19 +277,19 @@ pub trait TestBindingMethods {
|
||||||
|
|
||||||
impl<'a> TestBindingMethods for JSRef<'a, TestBinding> {
|
impl<'a> TestBindingMethods for JSRef<'a, TestBinding> {
|
||||||
fn InterfaceAttribute(&self) -> Temporary<Blob> {
|
fn InterfaceAttribute(&self) -> Temporary<Blob> {
|
||||||
let global = self.global.get().root();
|
let global = self.global.root();
|
||||||
Blob::new(&*global)
|
Blob::new(&*global)
|
||||||
}
|
}
|
||||||
fn GetInterfaceAttributeNullable(&self) -> Option<Temporary<Blob>> {
|
fn GetInterfaceAttributeNullable(&self) -> Option<Temporary<Blob>> {
|
||||||
let global = self.global.get().root();
|
let global = self.global.root();
|
||||||
Some(Blob::new(&*global))
|
Some(Blob::new(&*global))
|
||||||
}
|
}
|
||||||
fn ReceiveInterface(&self) -> Temporary<Blob> {
|
fn ReceiveInterface(&self) -> Temporary<Blob> {
|
||||||
let global = self.global.get().root();
|
let global = self.global.root();
|
||||||
Blob::new(&*global)
|
Blob::new(&*global)
|
||||||
}
|
}
|
||||||
fn ReceiveNullableInterface(&self) -> Option<Temporary<Blob>> {
|
fn ReceiveNullableInterface(&self) -> Option<Temporary<Blob>> {
|
||||||
let global = self.global.get().root();
|
let global = self.global.root();
|
||||||
Some(Blob::new(&*global))
|
Some(Blob::new(&*global))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,7 @@ pub struct XMLHttpRequest {
|
||||||
ready_state: Traceable<Cell<XMLHttpRequestState>>,
|
ready_state: Traceable<Cell<XMLHttpRequestState>>,
|
||||||
timeout: Traceable<Cell<u32>>,
|
timeout: Traceable<Cell<u32>>,
|
||||||
with_credentials: Traceable<Cell<bool>>,
|
with_credentials: Traceable<Cell<bool>>,
|
||||||
upload: Cell<JS<XMLHttpRequestUpload>>,
|
upload: JS<XMLHttpRequestUpload>,
|
||||||
response_url: DOMString,
|
response_url: DOMString,
|
||||||
status: Traceable<Cell<u16>>,
|
status: Traceable<Cell<u16>>,
|
||||||
status_text: Traceable<RefCell<ByteString>>,
|
status_text: Traceable<RefCell<ByteString>>,
|
||||||
|
@ -136,7 +136,7 @@ impl XMLHttpRequest {
|
||||||
ready_state: Traceable::new(Cell::new(Unsent)),
|
ready_state: Traceable::new(Cell::new(Unsent)),
|
||||||
timeout: Traceable::new(Cell::new(0u32)),
|
timeout: Traceable::new(Cell::new(0u32)),
|
||||||
with_credentials: Traceable::new(Cell::new(false)),
|
with_credentials: Traceable::new(Cell::new(false)),
|
||||||
upload: Cell::new(JS::from_rooted(&XMLHttpRequestUpload::new(global))),
|
upload: JS::from_rooted(&XMLHttpRequestUpload::new(global)),
|
||||||
response_url: "".to_string(),
|
response_url: "".to_string(),
|
||||||
status: Traceable::new(Cell::new(0)),
|
status: Traceable::new(Cell::new(0)),
|
||||||
status_text: Traceable::new(RefCell::new(ByteString::new(vec!()))),
|
status_text: Traceable::new(RefCell::new(ByteString::new(vec!()))),
|
||||||
|
@ -434,7 +434,7 @@ impl<'a> XMLHttpRequestMethods<'a> for JSRef<'a, XMLHttpRequest> {
|
||||||
self.with_credentials.deref().set(with_credentials);
|
self.with_credentials.deref().set(with_credentials);
|
||||||
}
|
}
|
||||||
fn Upload(&self) -> Temporary<XMLHttpRequestUpload> {
|
fn Upload(&self) -> Temporary<XMLHttpRequestUpload> {
|
||||||
Temporary::new(self.upload.get())
|
Temporary::new(self.upload)
|
||||||
}
|
}
|
||||||
fn Send(&self, data: Option<SendParam>) -> ErrorResult {
|
fn Send(&self, data: Option<SendParam>) -> ErrorResult {
|
||||||
if self.ready_state.deref().get() != Opened || self.send_flag.deref().get() {
|
if self.ready_state.deref().get() != Opened || self.send_flag.deref().get() {
|
||||||
|
@ -466,7 +466,7 @@ impl<'a> XMLHttpRequestMethods<'a> for JSRef<'a, XMLHttpRequest> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 8
|
// Step 8
|
||||||
let upload_target = &*self.upload.get().root();
|
let upload_target = &*self.upload.root();
|
||||||
let event_target: &JSRef<EventTarget> = EventTargetCast::from_ref(upload_target);
|
let event_target: &JSRef<EventTarget> = EventTargetCast::from_ref(upload_target);
|
||||||
if event_target.has_handlers() {
|
if event_target.has_handlers() {
|
||||||
self.upload_events.deref().set(true);
|
self.upload_events.deref().set(true);
|
||||||
|
@ -841,7 +841,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.get().root();
|
let upload_target = &*self.upload.root();
|
||||||
let progressevent = ProgressEvent::new(&*global,
|
let progressevent = ProgressEvent::new(&*global,
|
||||||
type_, false, false,
|
type_, false, false,
|
||||||
total.is_some(), loaded,
|
total.is_some(), loaded,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue