aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2014-10-22 07:54:36 -0600
committerbors-servo <metajack+bors@gmail.com>2014-10-22 07:54:36 -0600
commitf5e8df9dac9330f2818906c471ed05f5975828c6 (patch)
treec606085bb5266ae0dadfa8a4356bb63649fcbef4 /components/script/dom
parent4b508195ace7490fda08f6d40fe64165feb91edd (diff)
parentf1c840de64885371b563e1dcda1ec9208d0f40c8 (diff)
downloadservo-f5e8df9dac9330f2818906c471ed05f5975828c6.tar.gz
servo-f5e8df9dac9330f2818906c471ed05f5975828c6.zip
auto merge of #3737 : saneyuki/servo/cell, r=jdm
#3050 Altough LayoutDataRef is touched from layout, we don't use DOMRefCell in it becasuse it's expected to manipulate in layout task.
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/document.rs15
-rw-r--r--components/script/dom/event.rs7
-rw-r--r--components/script/dom/eventtarget.rs6
-rw-r--r--components/script/dom/formdata.rs6
-rw-r--r--components/script/dom/htmlimageelement.rs7
-rw-r--r--components/script/dom/htmlinputelement.rs6
-rw-r--r--components/script/dom/node.rs5
-rw-r--r--components/script/dom/servohtmlparser.rs8
-rw-r--r--components/script/dom/urlsearchparams.rs6
-rw-r--r--components/script/dom/window.rs6
-rw-r--r--components/script/dom/xmlhttprequest.rs35
11 files changed, 55 insertions, 52 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index 8d767be9016..340e46db95e 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -3,6 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::attr::AttrHelpers;
+use dom::bindings::cell::{DOMRefCell, Ref};
use dom::bindings::codegen::Bindings::DocumentBinding;
use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
@@ -62,7 +63,7 @@ use url::Url;
use std::collections::hashmap::HashMap;
use std::ascii::StrAsciiExt;
-use std::cell::{Cell, Ref, RefCell};
+use std::cell::Cell;
use std::default::Default;
use time;
@@ -77,11 +78,11 @@ pub enum IsHTMLDocument {
pub struct Document {
node: Node,
window: JS<Window>,
- idmap: RefCell<HashMap<Atom, Vec<JS<Element>>>>,
+ idmap: DOMRefCell<HashMap<Atom, Vec<JS<Element>>>>,
implementation: MutNullableJS<DOMImplementation>,
content_type: DOMString,
- last_modified: RefCell<Option<DOMString>>,
- encoding_name: RefCell<DOMString>,
+ last_modified: DOMRefCell<Option<DOMString>>,
+ encoding_name: DOMRefCell<DOMString>,
is_html_document: bool,
url: Url,
quirks_mode: Cell<QuirksMode>,
@@ -299,7 +300,7 @@ impl Document {
Document {
node: Node::new_without_doc(DocumentNodeTypeId),
window: JS::from_rooted(window),
- idmap: RefCell::new(HashMap::new()),
+ idmap: DOMRefCell::new(HashMap::new()),
implementation: Default::default(),
content_type: match content_type {
Some(string) => string.clone(),
@@ -310,12 +311,12 @@ impl Document {
NonHTMLDocument => "application/xml".to_string()
}
},
- last_modified: RefCell::new(None),
+ last_modified: DOMRefCell::new(None),
url: url,
// http://dom.spec.whatwg.org/#concept-document-quirks
quirks_mode: Cell::new(NoQuirks),
// http://dom.spec.whatwg.org/#concept-document-encoding
- encoding_name: RefCell::new("utf-8".to_string()),
+ encoding_name: DOMRefCell::new("utf-8".to_string()),
is_html_document: is_html_document == HTMLDocument,
images: Default::default(),
embeds: Default::default(),
diff --git a/components/script/dom/event.rs b/components/script/dom/event.rs
index e61bd15a3b0..bb87993a3e7 100644
--- a/components/script/dom/event.rs
+++ b/components/script/dom/event.rs
@@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::EventBinding;
use dom::bindings::codegen::Bindings::EventBinding::{EventConstants, EventMethods};
use dom::bindings::error::Fallible;
@@ -10,7 +11,7 @@ use dom::bindings::js::{MutNullableJS, JSRef, Temporary};
use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
use dom::eventtarget::EventTarget;
use servo_util::str::DOMString;
-use std::cell::{Cell, RefCell};
+use std::cell::Cell;
use std::default::Default;
use time;
@@ -53,7 +54,7 @@ pub struct Event {
reflector_: Reflector,
current_target: MutNullableJS<EventTarget>,
target: MutNullableJS<EventTarget>,
- type_: RefCell<DOMString>,
+ type_: DOMRefCell<DOMString>,
phase: Cell<EventPhase>,
canceled: Cell<bool>,
stop_propagation: Cell<bool>,
@@ -74,7 +75,7 @@ impl Event {
current_target: Default::default(),
target: Default::default(),
phase: Cell::new(PhaseNone),
- type_: RefCell::new("".to_string()),
+ type_: DOMRefCell::new("".to_string()),
canceled: Cell::new(false),
cancelable: Cell::new(true),
bubbles: Cell::new(false),
diff --git a/components/script/dom/eventtarget.rs b/components/script/dom/eventtarget.rs
index 3a764c66a9d..233047691ea 100644
--- a/components/script/dom/eventtarget.rs
+++ b/components/script/dom/eventtarget.rs
@@ -3,6 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::callback::CallbackContainer;
+use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
use dom::bindings::codegen::Bindings::EventListenerBinding::EventListener;
use dom::bindings::codegen::Bindings::EventTargetBinding::EventTargetMethods;
@@ -19,7 +20,6 @@ use js::jsapi::{JS_CompileUCFunction, JS_GetFunctionObject, JS_CloneFunctionObje
use js::jsapi::{JSContext, JSObject};
use servo_util::str::DOMString;
use libc::{c_char, size_t};
-use std::cell::RefCell;
use std::ptr;
use url::Url;
@@ -69,7 +69,7 @@ pub struct EventListenerEntry {
pub struct EventTarget {
type_id: EventTargetTypeId,
reflector_: Reflector,
- handlers: RefCell<HashMap<DOMString, Vec<EventListenerEntry>>>,
+ handlers: DOMRefCell<HashMap<DOMString, Vec<EventListenerEntry>>>,
}
impl EventTarget {
@@ -77,7 +77,7 @@ impl EventTarget {
EventTarget {
type_id: type_id,
reflector_: Reflector::new(),
- handlers: RefCell::new(HashMap::new()),
+ handlers: DOMRefCell::new(HashMap::new()),
}
}
diff --git a/components/script/dom/formdata.rs b/components/script/dom/formdata.rs
index cd6dbf65143..7642ebab0d4 100644
--- a/components/script/dom/formdata.rs
+++ b/components/script/dom/formdata.rs
@@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::FormDataBinding;
use dom::bindings::codegen::Bindings::FormDataBinding::FormDataMethods;
use dom::bindings::codegen::InheritTypes::FileCast;
@@ -14,7 +15,6 @@ use dom::blob::Blob;
use dom::file::File;
use dom::htmlformelement::HTMLFormElement;
use servo_util::str::DOMString;
-use std::cell::RefCell;
use std::collections::hashmap::HashMap;
#[deriving(Clone)]
@@ -27,7 +27,7 @@ pub enum FormDatum {
#[dom_struct]
pub struct FormData {
- data: RefCell<HashMap<DOMString, Vec<FormDatum>>>,
+ data: DOMRefCell<HashMap<DOMString, Vec<FormDatum>>>,
reflector_: Reflector,
global: GlobalField,
form: Option<JS<HTMLFormElement>>
@@ -36,7 +36,7 @@ pub struct FormData {
impl FormData {
fn new_inherited(form: Option<JSRef<HTMLFormElement>>, global: &GlobalRef) -> FormData {
FormData {
- data: RefCell::new(HashMap::new()),
+ data: DOMRefCell::new(HashMap::new()),
reflector_: Reflector::new(),
global: GlobalField::from_rooted(global),
form: form.map(|f| JS::from_rooted(f)),
diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs
index 0128ebe0a3e..bc18a217d53 100644
--- a/components/script/dom/htmlimageelement.rs
+++ b/components/script/dom/htmlimageelement.rs
@@ -3,6 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::attr::AttrValue;
+use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::HTMLImageElementBinding;
use dom::bindings::codegen::Bindings::HTMLImageElementBinding::HTMLImageElementMethods;
use dom::bindings::codegen::InheritTypes::{NodeCast, ElementCast, HTMLElementCast, HTMLImageElementDerived};
@@ -22,12 +23,10 @@ use string_cache::Atom;
use url::{Url, UrlParser};
-use std::cell::RefCell;
-
#[dom_struct]
pub struct HTMLImageElement {
htmlelement: HTMLElement,
- image: RefCell<Option<Url>>,
+ image: DOMRefCell<Option<Url>>,
}
impl HTMLImageElementDerived for EventTarget {
@@ -73,7 +72,7 @@ impl HTMLImageElement {
fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> HTMLImageElement {
HTMLImageElement {
htmlelement: HTMLElement::new_inherited(HTMLImageElementTypeId, localName, prefix, document),
- image: RefCell::new(None),
+ image: DOMRefCell::new(None),
}
}
diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs
index 9b933c34dcc..39fd25e4de7 100644
--- a/components/script/dom/htmlinputelement.rs
+++ b/components/script/dom/htmlinputelement.rs
@@ -27,7 +27,7 @@ use servo_util::str::{DOMString, parse_unsigned_integer};
use string_cache::Atom;
use std::ascii::OwnedStrAsciiExt;
-use std::cell::{Cell, RefCell};
+use std::cell::Cell;
static DEFAULT_SUBMIT_VALUE: &'static str = "Submit";
static DEFAULT_RESET_VALUE: &'static str = "Reset";
@@ -49,7 +49,7 @@ pub struct HTMLInputElement {
htmlelement: HTMLElement,
input_type: Cell<InputType>,
checked: Cell<bool>,
- uncommitted_value: RefCell<Option<String>>,
+ uncommitted_value: DOMRefCell<Option<String>>,
value: DOMRefCell<Option<String>>,
size: Cell<u32>,
}
@@ -68,7 +68,7 @@ impl HTMLInputElement {
htmlelement: HTMLElement::new_inherited(HTMLInputElementTypeId, localName, prefix, document),
input_type: Cell::new(InputText),
checked: Cell::new(false),
- uncommitted_value: RefCell::new(None),
+ uncommitted_value: DOMRefCell::new(None),
value: DOMRefCell::new(None),
size: Cell::new(DEFAULT_INPUT_SIZE),
}
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs
index 2743cf4b268..e1ff126f431 100644
--- a/components/script/dom/node.rs
+++ b/components/script/dom/node.rs
@@ -5,6 +5,7 @@
//! The core DOM types. Defines the basic DOM hierarchy as well as all the HTML elements.
use dom::attr::{Attr, AttrHelpers};
+use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterDataMethods;
use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
use dom::bindings::codegen::Bindings::ElementBinding::ElementMethods;
@@ -110,7 +111,7 @@ pub struct Node {
/// node is finalized.
layout_data: LayoutDataRef,
- unique_id: RefCell<String>,
+ unique_id: DOMRefCell<String>,
}
impl NodeDerived for EventTarget {
@@ -1155,7 +1156,7 @@ impl Node {
layout_data: LayoutDataRef::new(),
- unique_id: RefCell::new("".to_string()),
+ unique_id: DOMRefCell::new("".to_string()),
}
}
diff --git a/components/script/dom/servohtmlparser.rs b/components/script/dom/servohtmlparser.rs
index c4d594186c8..8bd33ae1efa 100644
--- a/components/script/dom/servohtmlparser.rs
+++ b/components/script/dom/servohtmlparser.rs
@@ -5,6 +5,7 @@
//! The bulk of the HTML parser integration is in `script::parse::html`.
//! This module is mostly about its interaction with DOM memory management.
+use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::ServoHTMLParserBinding;
use dom::bindings::global;
use dom::bindings::trace::JSTraceable;
@@ -15,7 +16,6 @@ use dom::document::Document;
use parse::html::JSMessage;
use std::default::Default;
-use std::cell::RefCell;
use url::Url;
use js::jsapi::JSTracer;
use html5ever::tokenizer;
@@ -38,7 +38,7 @@ pub type Tokenizer = tokenizer::Tokenizer<TreeBuilder<TrustedNodeAddress, Sink>>
#[privatize]
pub struct ServoHTMLParser {
reflector_: Reflector,
- tokenizer: RefCell<Tokenizer>,
+ tokenizer: DOMRefCell<Tokenizer>,
}
impl ServoHTMLParser {
@@ -61,14 +61,14 @@ impl ServoHTMLParser {
let parser = ServoHTMLParser {
reflector_: Reflector::new(),
- tokenizer: RefCell::new(tok),
+ tokenizer: DOMRefCell::new(tok),
};
reflect_dom_object(box parser, &global::Window(*window), ServoHTMLParserBinding::Wrap)
}
#[inline]
- pub fn tokenizer<'a>(&'a self) -> &'a RefCell<Tokenizer> {
+ pub fn tokenizer<'a>(&'a self) -> &'a DOMRefCell<Tokenizer> {
&self.tokenizer
}
}
diff --git a/components/script/dom/urlsearchparams.rs b/components/script/dom/urlsearchparams.rs
index 98cfc2a5792..bd885dbf4b9 100644
--- a/components/script/dom/urlsearchparams.rs
+++ b/components/script/dom/urlsearchparams.rs
@@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::URLSearchParamsBinding;
use dom::bindings::codegen::Bindings::URLSearchParamsBinding::URLSearchParamsMethods;
use dom::bindings::codegen::UnionTypes::StringOrURLSearchParams::{StringOrURLSearchParams, eURLSearchParams, eString};
@@ -15,21 +16,20 @@ use servo_util::str::DOMString;
use encoding::all::UTF_8;
use encoding::types::{EncodingRef, EncodeReplace};
-use std::cell::RefCell;
use std::collections::hashmap::HashMap;
use std::fmt::radix;
use std::ascii::OwnedStrAsciiExt;
#[dom_struct]
pub struct URLSearchParams {
- data: RefCell<HashMap<DOMString, Vec<DOMString>>>,
+ data: DOMRefCell<HashMap<DOMString, Vec<DOMString>>>,
reflector_: Reflector,
}
impl URLSearchParams {
fn new_inherited() -> URLSearchParams {
URLSearchParams {
- data: RefCell::new(HashMap::new()),
+ data: DOMRefCell::new(HashMap::new()),
reflector_: Reflector::new(),
}
}
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index 044a6f6fabe..d2b6cf8b75d 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+use dom::bindings::cell::{DOMRefCell, Ref};
use dom::bindings::codegen::Bindings::EventHandlerBinding::{OnErrorEventHandlerNonNull, EventHandlerNonNull};
use dom::bindings::codegen::Bindings::WindowBinding;
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
@@ -39,7 +40,6 @@ use url::{Url, UrlParser};
use libc;
use serialize::base64::{FromBase64, ToBase64, STANDARD};
-use std::cell::{Ref, RefCell};
use std::default::Default;
use std::rc::Rc;
use time;
@@ -54,7 +54,7 @@ pub struct Window {
navigator: MutNullableJS<Navigator>,
image_cache_task: ImageCacheTask,
compositor: Box<ScriptListener+'static>,
- browser_context: RefCell<Option<BrowserContext>>,
+ browser_context: DOMRefCell<Option<BrowserContext>>,
page: Rc<Page>,
performance: MutNullableJS<Performance>,
navigation_start: u64,
@@ -437,7 +437,7 @@ impl Window {
location: Default::default(),
navigator: Default::default(),
image_cache_task: image_cache_task,
- browser_context: RefCell::new(None),
+ browser_context: DOMRefCell::new(None),
performance: Default::default(),
navigation_start: time::get_time().sec as u64,
navigation_start_precise: time::precise_time_s(),
diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs
index 02f7070ad3c..628eeb2e074 100644
--- a/components/script/dom/xmlhttprequest.rs
+++ b/components/script/dom/xmlhttprequest.rs
@@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
use dom::bindings::codegen::Bindings::XMLHttpRequestBinding;
use dom::bindings::codegen::Bindings::XMLHttpRequestBinding::XMLHttpRequestMethods;
@@ -50,7 +51,7 @@ use servo_util::str::DOMString;
use servo_util::task::spawn_named;
use std::ascii::StrAsciiExt;
-use std::cell::{Cell, RefCell};
+use std::cell::Cell;
use std::comm::{Sender, Receiver, channel};
use std::default::Default;
use std::io::{BufReader, MemWriter, Timer};
@@ -111,16 +112,16 @@ pub struct XMLHttpRequest {
upload: JS<XMLHttpRequestUpload>,
response_url: DOMString,
status: Cell<u16>,
- status_text: RefCell<ByteString>,
- response: RefCell<ByteString>,
+ status_text: DOMRefCell<ByteString>,
+ response: DOMRefCell<ByteString>,
response_type: Cell<XMLHttpRequestResponseType>,
response_xml: MutNullableJS<Document>,
- response_headers: RefCell<ResponseHeaderCollection>,
+ response_headers: DOMRefCell<ResponseHeaderCollection>,
// Associated concepts
- request_method: RefCell<Method>,
- request_url: RefCell<Option<Url>>,
- request_headers: RefCell<RequestHeaderCollection>,
+ request_method: DOMRefCell<Method>,
+ request_url: DOMRefCell<Option<Url>>,
+ request_headers: DOMRefCell<RequestHeaderCollection>,
request_body_len: Cell<uint>,
sync: Cell<bool>,
upload_complete: Cell<bool>,
@@ -129,10 +130,10 @@ pub struct XMLHttpRequest {
global: GlobalField,
pinned_count: Cell<uint>,
- timer: RefCell<Timer>,
+ timer: DOMRefCell<Timer>,
fetch_time: Cell<i64>,
timeout_pinned: Cell<bool>,
- terminate_sender: RefCell<Option<Sender<Error>>>,
+ terminate_sender: DOMRefCell<Option<Sender<Error>>>,
}
impl XMLHttpRequest {
@@ -145,15 +146,15 @@ impl XMLHttpRequest {
upload: JS::from_rooted(XMLHttpRequestUpload::new(global)),
response_url: "".to_string(),
status: Cell::new(0),
- status_text: RefCell::new(ByteString::new(vec!())),
- response: RefCell::new(ByteString::new(vec!())),
+ status_text: DOMRefCell::new(ByteString::new(vec!())),
+ response: DOMRefCell::new(ByteString::new(vec!())),
response_type: Cell::new(_empty),
response_xml: Default::default(),
- response_headers: RefCell::new(ResponseHeaderCollection::new()),
+ response_headers: DOMRefCell::new(ResponseHeaderCollection::new()),
- request_method: RefCell::new(Get),
- request_url: RefCell::new(None),
- request_headers: RefCell::new(RequestHeaderCollection::new()),
+ request_method: DOMRefCell::new(Get),
+ request_url: DOMRefCell::new(None),
+ request_headers: DOMRefCell::new(RequestHeaderCollection::new()),
request_body_len: Cell::new(0),
sync: Cell::new(false),
send_flag: Cell::new(false),
@@ -163,10 +164,10 @@ impl XMLHttpRequest {
global: GlobalField::from_rooted(global),
pinned_count: Cell::new(0),
- timer: RefCell::new(Timer::new().unwrap()),
+ timer: DOMRefCell::new(Timer::new().unwrap()),
fetch_time: Cell::new(0),
timeout_pinned: Cell::new(false),
- terminate_sender: RefCell::new(None),
+ terminate_sender: DOMRefCell::new(None),
}
}
pub fn new(global: &GlobalRef) -> Temporary<XMLHttpRequest> {