Use DOMString::new() somewhat consistently.

This commit is contained in:
Ms2ger 2015-11-03 14:11:07 +01:00
parent dab3926622
commit e6aa976462
24 changed files with 67 additions and 68 deletions

View file

@ -56,7 +56,6 @@ use js::rust::{ToInt64, ToUint64};
use libc; use libc;
use num::Float; use num::Float;
use num::traits::{Bounded, Zero}; use num::traits::{Bounded, Zero};
use std::borrow::ToOwned;
use std::rc::Rc; use std::rc::Rc;
use std::{char, ptr, slice}; use std::{char, ptr, slice};
use util::str::DOMString; use util::str::DOMString;
@ -517,7 +516,7 @@ impl FromJSValConvertible for DOMString {
-> Result<DOMString, ()> { -> Result<DOMString, ()> {
if null_behavior == StringificationBehavior::Empty && if null_behavior == StringificationBehavior::Empty &&
value.get().is_null() { value.get().is_null() {
Ok("".to_owned()) Ok(DOMString::new())
} else { } else {
let jsstr = unsafe { ToString(cx, value) }; let jsstr = unsafe { ToString(cx, value) };
if jsstr.is_null() { if jsstr.is_null() {

View file

@ -113,13 +113,13 @@ impl BlobMethods for Blob {
} }
}; };
let relativeContentType = match contentType { let relativeContentType = match contentType {
None => "".to_owned(), None => DOMString::new(),
Some(mut str) => { Some(mut str) => {
if is_ascii_printable(&str) { if is_ascii_printable(&str) {
str.make_ascii_lowercase(); str.make_ascii_lowercase();
str str
} else { } else {
"".to_owned() DOMString::new()
} }
} }
}; };

View file

@ -80,7 +80,7 @@ impl CharacterDataMethods for CharacterData {
// https://dom.spec.whatwg.org/#dom-characterdata-deletedataoffset-count // https://dom.spec.whatwg.org/#dom-characterdata-deletedataoffset-count
fn DeleteData(&self, offset: u32, count: u32) -> ErrorResult { fn DeleteData(&self, offset: u32, count: u32) -> ErrorResult {
self.ReplaceData(offset, count, "".to_owned()) self.ReplaceData(offset, count, DOMString::new())
} }
// https://dom.spec.whatwg.org/#dom-characterdata-replacedata // https://dom.spec.whatwg.org/#dom-characterdata-replacedata

View file

@ -126,7 +126,7 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
if self.readonly { if self.readonly {
// Readonly style declarations are used for getComputedStyle. // Readonly style declarations are used for getComputedStyle.
return self.get_computed_style(&property).unwrap_or("".to_owned()); return self.get_computed_style(&property).unwrap_or(DOMString::new());
} }
// Step 2 // Step 2
@ -143,7 +143,7 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
// Step 2.2.2 & 2.2.3 // Step 2.2.2 & 2.2.3
match declaration { match declaration {
Some(declaration) => list.push(declaration), Some(declaration) => list.push(declaration),
None => return "".to_owned(), None => return DOMString::new(),
} }
} }
@ -154,7 +154,7 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
// Step 3 & 4 // Step 3 & 4
let result = match owner.get_inline_style_declaration(&property) { let result = match owner.get_inline_style_declaration(&property) {
Some(declaration) => declaration.value(), Some(declaration) => declaration.value(),
None => "".to_owned(), None => DOMString::new(),
}; };
result result
} }
@ -183,7 +183,7 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
} }
// Step 4 // Step 4
"".to_owned() DOMString::new()
} }
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-setproperty // https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-setproperty
@ -274,7 +274,7 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration {
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-setpropertyvalue // https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-setpropertyvalue
fn SetPropertyValue(&self, property: DOMString, value: DOMString) -> ErrorResult { fn SetPropertyValue(&self, property: DOMString, value: DOMString) -> ErrorResult {
self.SetProperty(property, value, "".to_owned()) self.SetProperty(property, value, DOMString::new())
} }
// https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-removeproperty // https://dev.w3.org/csswg/cssom/#dom-cssstyledeclaration-removeproperty

View file

@ -942,7 +942,7 @@ impl Document {
Some(ref body) => { Some(ref body) => {
body.upcast::<Element>().get_string_attribute(local_name) body.upcast::<Element>().get_string_attribute(local_name)
}, },
None => "".to_owned() None => DOMString::new()
} }
} }
@ -1543,7 +1543,7 @@ impl DocumentMethods for Document {
let name = Atom::from_slice(&local_name); let name = Atom::from_slice(&local_name);
// repetition used because string_cache::atom::Atom is non-copyable // repetition used because string_cache::atom::Atom is non-copyable
let l_name = Atom::from_slice(&local_name); let l_name = Atom::from_slice(&local_name);
let value = AttrValue::String("".to_owned()); let value = AttrValue::String(DOMString::new());
Ok(Attr::new(&self.window, name, value, l_name, ns!(""), None, None)) Ok(Attr::new(&self.window, name, value, l_name, ns!(""), None, None))
} }
@ -1553,7 +1553,7 @@ impl DocumentMethods for Document {
-> Fallible<Root<Attr>> { -> Fallible<Root<Attr>> {
let (namespace, prefix, local_name) = let (namespace, prefix, local_name) =
try!(validate_and_extract(namespace, &qualified_name)); try!(validate_and_extract(namespace, &qualified_name));
let value = AttrValue::String("".to_owned()); let value = AttrValue::String(DOMString::new());
let qualified_name = Atom::from_slice(&qualified_name); let qualified_name = Atom::from_slice(&qualified_name);
Ok(Attr::new(&self.window, local_name, value, qualified_name, Ok(Attr::new(&self.window, local_name, value, qualified_name,
namespace, prefix, None)) namespace, prefix, None))

View file

@ -10,7 +10,6 @@ use dom::bindings::inheritance::Castable;
use dom::bindings::js::Root; use dom::bindings::js::Root;
use dom::document::Document; use dom::document::Document;
use dom::node::Node; use dom::node::Node;
use std::borrow::ToOwned;
use util::str::DOMString; use util::str::DOMString;
// https://dom.spec.whatwg.org/#documenttype // https://dom.spec.whatwg.org/#documenttype
@ -32,8 +31,8 @@ impl DocumentType {
DocumentType { DocumentType {
node: Node::new_inherited(document), node: Node::new_inherited(document),
name: name, name: name,
public_id: public_id.unwrap_or("".to_owned()), public_id: public_id.unwrap_or(DOMString::new()),
system_id: system_id.unwrap_or("".to_owned()) system_id: system_id.unwrap_or(DOMString::new())
} }
} }
#[allow(unrooted_must_root)] #[allow(unrooted_must_root)]

View file

@ -54,7 +54,7 @@ impl DOMStringMapMethods for DOMStringMap {
}, },
None => { None => {
*found = false; *found = false;
String::new() DOMString::new()
} }
} }
} }

View file

@ -1014,7 +1014,7 @@ impl Element {
pub fn set_bool_attribute(&self, local_name: &Atom, value: bool) { pub fn set_bool_attribute(&self, local_name: &Atom, value: bool) {
if self.has_attribute(local_name) == value { return; } if self.has_attribute(local_name) == value { return; }
if value { if value {
self.set_string_attribute(local_name, String::new()); self.set_string_attribute(local_name, DOMString::new());
} else { } else {
self.remove_attribute(&ns!(""), local_name); self.remove_attribute(&ns!(""), local_name);
} }
@ -1023,7 +1023,7 @@ impl Element {
pub fn get_url_attribute(&self, local_name: &Atom) -> DOMString { pub fn get_url_attribute(&self, local_name: &Atom) -> DOMString {
assert!(&**local_name == local_name.to_ascii_lowercase()); assert!(&**local_name == local_name.to_ascii_lowercase());
if !self.has_attribute(local_name) { if !self.has_attribute(local_name) {
return "".to_owned(); return DOMString::new();
} }
let url = self.get_string_attribute(local_name); let url = self.get_string_attribute(local_name);
let doc = document_from_node(self); let doc = document_from_node(self);
@ -1042,7 +1042,7 @@ impl Element {
pub fn get_string_attribute(&self, local_name: &Atom) -> DOMString { pub fn get_string_attribute(&self, local_name: &Atom) -> DOMString {
match self.get_attribute(&ns!(""), local_name) { match self.get_attribute(&ns!(""), local_name) {
Some(x) => x.Value(), Some(x) => x.Value(),
None => "".to_owned() None => DOMString::new()
} }
} }
pub fn set_string_attribute(&self, local_name: &Atom, value: DOMString) { pub fn set_string_attribute(&self, local_name: &Atom, value: DOMString) {

View file

@ -15,7 +15,6 @@ use dom::bindings::trace::JSTraceable;
use dom::event::{Event, EventBubbles, EventCancelable}; use dom::event::{Event, EventBubbles, EventCancelable};
use js::jsapi::{RootedValue, HandleValue, JSContext}; use js::jsapi::{RootedValue, HandleValue, JSContext};
use js::jsval::JSVal; use js::jsval::JSVal;
use std::borrow::ToOwned;
use std::cell::Cell; use std::cell::Cell;
use util::str::DOMString; use util::str::DOMString;
@ -34,8 +33,8 @@ impl ErrorEvent {
fn new_inherited() -> ErrorEvent { fn new_inherited() -> ErrorEvent {
ErrorEvent { ErrorEvent {
event: Event::new_inherited(), event: Event::new_inherited(),
message: DOMRefCell::new("".to_owned()), message: DOMRefCell::new(DOMString::new()),
filename: DOMRefCell::new("".to_owned()), filename: DOMRefCell::new(DOMString::new()),
lineno: Cell::new(0), lineno: Cell::new(0),
colno: Cell::new(0), colno: Cell::new(0),
error: MutHeapJSVal::new() error: MutHeapJSVal::new()
@ -76,12 +75,12 @@ impl ErrorEvent {
init: &ErrorEventBinding::ErrorEventInit) -> Fallible<Root<ErrorEvent>>{ init: &ErrorEventBinding::ErrorEventInit) -> Fallible<Root<ErrorEvent>>{
let msg = match init.message.as_ref() { let msg = match init.message.as_ref() {
Some(message) => message.clone(), Some(message) => message.clone(),
None => "".to_owned(), None => DOMString::new(),
}; };
let file_name = match init.filename.as_ref() { let file_name = match init.filename.as_ref() {
None => "".to_owned(),
Some(filename) => filename.clone(), Some(filename) => filename.clone(),
None => DOMString::new(),
}; };
let line_num = init.lineno.unwrap_or(0); let line_num = init.lineno.unwrap_or(0);

View file

@ -9,7 +9,6 @@ use dom::bindings::js::Root;
use dom::document::Document; use dom::document::Document;
use dom::htmlelement::HTMLElement; use dom::htmlelement::HTMLElement;
use dom::node::Node; use dom::node::Node;
use std::borrow::ToOwned;
use util::str::DOMString; use util::str::DOMString;
#[dom_struct] #[dom_struct]
@ -25,7 +24,7 @@ impl HTMLDialogElement {
HTMLDialogElement { HTMLDialogElement {
htmlelement: htmlelement:
HTMLElement::new_inherited(localName, prefix, document), HTMLElement::new_inherited(localName, prefix, document),
return_value: DOMRefCell::new("".to_owned()), return_value: DOMRefCell::new(DOMString::new()),
} }
} }

View file

@ -491,7 +491,7 @@ pub trait FormControl: DerivedFrom<Element> + Reflectable {
if self.to_element().has_attribute(attr) { if self.to_element().has_attribute(attr) {
input(self) input(self)
} else { } else {
self.form_owner().map_or("".to_owned(), |t| owner(t.r())) self.form_owner().map_or(DOMString::new(), |t| owner(t.r()))
} }
} }

View file

@ -111,11 +111,11 @@ impl HTMLInputElement {
HTMLElement::new_inherited_with_state(IN_ENABLED_STATE, HTMLElement::new_inherited_with_state(IN_ENABLED_STATE,
localName, prefix, document), localName, prefix, document),
input_type: Cell::new(InputType::InputText), input_type: Cell::new(InputType::InputText),
placeholder: DOMRefCell::new("".to_owned()), placeholder: DOMRefCell::new(DOMString::new()),
checked_changed: Cell::new(false), checked_changed: Cell::new(false),
value_changed: Cell::new(false), value_changed: Cell::new(false),
size: Cell::new(DEFAULT_INPUT_SIZE), size: Cell::new(DEFAULT_INPUT_SIZE),
textinput: DOMRefCell::new(TextInput::new(Single, "".to_owned(), chan)), textinput: DOMRefCell::new(TextInput::new(Single, DOMString::new(), chan)),
activation_state: DOMRefCell::new(InputActivationState::new()) activation_state: DOMRefCell::new(InputActivationState::new())
} }
} }

View file

@ -96,7 +96,7 @@ impl HTMLOptionElementMethods for HTMLOptionElement {
// https://html.spec.whatwg.org/multipage/#dom-option-text // https://html.spec.whatwg.org/multipage/#dom-option-text
fn Text(&self) -> DOMString { fn Text(&self) -> DOMString {
let mut content = String::new(); let mut content = DOMString::new();
collect_text(self.upcast(), &mut content); collect_text(self.upcast(), &mut content);
str_join(split_html_space_chars(&content), " ") str_join(split_html_space_chars(&content), " ")
} }

View file

@ -99,7 +99,7 @@ impl HTMLTextAreaElement {
htmlelement: htmlelement:
HTMLElement::new_inherited_with_state(IN_ENABLED_STATE, HTMLElement::new_inherited_with_state(IN_ENABLED_STATE,
localName, prefix, document), localName, prefix, document),
textinput: DOMRefCell::new(TextInput::new(Lines::Multiple, "".to_owned(), chan)), textinput: DOMRefCell::new(TextInput::new(Lines::Multiple, DOMString::new(), chan)),
cols: Cell::new(DEFAULT_COLS), cols: Cell::new(DEFAULT_COLS),
rows: Cell::new(DEFAULT_ROWS), rows: Cell::new(DEFAULT_ROWS),
value_changed: Cell::new(false), value_changed: Cell::new(false),

View file

@ -17,7 +17,6 @@ use dom::window::Window;
use msg::constellation_msg; use msg::constellation_msg;
use msg::constellation_msg::{ALT, CONTROL, SHIFT, SUPER}; use msg::constellation_msg::{ALT, CONTROL, SHIFT, SUPER};
use msg::constellation_msg::{Key, KeyModifiers}; use msg::constellation_msg::{Key, KeyModifiers};
use std::borrow::ToOwned;
use std::cell::Cell; use std::cell::Cell;
use util::str::DOMString; use util::str::DOMString;
@ -45,8 +44,8 @@ impl KeyboardEvent {
KeyboardEvent { KeyboardEvent {
uievent: UIEvent::new_inherited(), uievent: UIEvent::new_inherited(),
key: Cell::new(None), key: Cell::new(None),
key_string: DOMRefCell::new("".to_owned()), key_string: DOMRefCell::new(DOMString::new()),
code: DOMRefCell::new("".to_owned()), code: DOMRefCell::new(DOMString::new()),
location: Cell::new(0), location: Cell::new(0),
ctrl: Cell::new(false), ctrl: Cell::new(false),
alt: Cell::new(false), alt: Cell::new(false),
@ -85,7 +84,7 @@ impl KeyboardEvent {
key_code: u32) -> Root<KeyboardEvent> { key_code: u32) -> Root<KeyboardEvent> {
let ev = KeyboardEvent::new_uninitialized(window); let ev = KeyboardEvent::new_uninitialized(window);
ev.InitKeyboardEvent(type_, canBubble, cancelable, view, key_string, location, ev.InitKeyboardEvent(type_, canBubble, cancelable, view, key_string, location,
"".to_owned(), repeat, "".to_owned()); DOMString::new(), repeat, DOMString::new());
// FIXME(https://github.com/rust-lang/rust/issues/23338) // FIXME(https://github.com/rust-lang/rust/issues/23338)
{ {
let ev = ev.r(); let ev = ev.r();

View file

@ -28,7 +28,10 @@ pub struct MessageEvent {
impl MessageEvent { impl MessageEvent {
pub fn new_uninitialized(global: GlobalRef) -> Root<MessageEvent> { pub fn new_uninitialized(global: GlobalRef) -> Root<MessageEvent> {
MessageEvent::new_initialized(global, HandleValue::undefined(), "".to_owned(), "".to_owned()) MessageEvent::new_initialized(global,
HandleValue::undefined(),
DOMString::new(),
DOMString::new())
} }
pub fn new_initialized(global: GlobalRef, pub fn new_initialized(global: GlobalRef,
@ -77,7 +80,7 @@ impl MessageEvent {
message: HandleValue) { message: HandleValue) {
let messageevent = MessageEvent::new( let messageevent = MessageEvent::new(
scope, "message".to_owned(), false, false, message, scope, "message".to_owned(), false, false, message,
"".to_owned(), "".to_owned()); DOMString::new(), DOMString::new());
messageevent.upcast::<Event>().fire(target); messageevent.upcast::<Event>().fire(target);
} }
} }

View file

@ -784,14 +784,14 @@ impl Node {
baseURI: self.BaseURI(), baseURI: self.BaseURI(),
parent: self.GetParentNode().map(|node| node.get_unique_id()).unwrap_or("".to_owned()), parent: self.GetParentNode().map(|node| node.get_unique_id()).unwrap_or("".to_owned()),
nodeType: self.NodeType(), nodeType: self.NodeType(),
namespaceURI: "".to_owned(), //FIXME namespaceURI: DOMString::new(), //FIXME
nodeName: self.NodeName(), nodeName: self.NodeName(),
numChildren: self.ChildNodes().Length() as usize, numChildren: self.ChildNodes().Length() as usize,
//FIXME doctype nodes only //FIXME doctype nodes only
name: "".to_owned(), name: DOMString::new(),
publicId: "".to_owned(), publicId: DOMString::new(),
systemId: "".to_owned(), systemId: DOMString::new(),
attrs: self.downcast().map(Element::summarize).unwrap_or(vec![]), attrs: self.downcast().map(Element::summarize).unwrap_or(vec![]),
isDocumentElement: isDocumentElement:
@ -800,7 +800,7 @@ impl Node {
.map(|elem| elem.upcast::<Node>() == self) .map(|elem| elem.upcast::<Node>() == self)
.unwrap_or(false), .unwrap_or(false),
shortValue: self.GetNodeValue().unwrap_or("".to_owned()), //FIXME: truncate shortValue: self.GetNodeValue().unwrap_or(DOMString::new()), //FIXME: truncate
incompleteValue: false, //FIXME: reflect truncation incompleteValue: false, //FIXME: reflect truncation
} }
} }
@ -1903,7 +1903,7 @@ impl NodeMethods for Node {
// https://dom.spec.whatwg.org/#dom-node-textcontent // https://dom.spec.whatwg.org/#dom-node-textcontent
fn SetTextContent(&self, value: Option<DOMString>) { fn SetTextContent(&self, value: Option<DOMString>) {
let value = value.unwrap_or(String::new()); let value = value.unwrap_or(DOMString::new());
match self.type_id() { match self.type_id() {
NodeTypeId::DocumentFragment | NodeTypeId::DocumentFragment |
NodeTypeId::Element(..) => { NodeTypeId::Element(..) => {

View file

@ -23,6 +23,7 @@ use dom::node::Node;
use dom::text::Text; use dom::text::Text;
use std::cell::Cell; use std::cell::Cell;
use std::cmp::{Ord, Ordering, PartialEq, PartialOrd}; use std::cmp::{Ord, Ordering, PartialEq, PartialOrd};
use util::str::DOMString;
#[dom_struct] #[dom_struct]
pub struct Range { pub struct Range {
@ -524,7 +525,7 @@ impl RangeMethods for Range {
// Step 4.4. // Step 4.4.
try!(end_data.ReplaceData(start_offset, try!(end_data.ReplaceData(start_offset,
end_offset - start_offset, end_offset - start_offset,
"".to_owned())); DOMString::new()));
// Step 4.5. // Step 4.5.
return Ok(fragment); return Ok(fragment);
} }
@ -560,7 +561,7 @@ impl RangeMethods for Range {
// Step 15.4. // Step 15.4.
try!(start_data.ReplaceData(start_offset, try!(start_data.ReplaceData(start_offset,
start_node.len() - start_offset, start_node.len() - start_offset,
"".to_owned())); DOMString::new()));
} else { } else {
// Step 16.1. // Step 16.1.
let clone = child.CloneNode(false); let clone = child.CloneNode(false);
@ -595,7 +596,7 @@ impl RangeMethods for Range {
// Step 18.3. // Step 18.3.
try!(fragment.upcast::<Node>().AppendChild(&clone)); try!(fragment.upcast::<Node>().AppendChild(&clone));
// Step 18.4. // Step 18.4.
try!(end_data.ReplaceData(0, end_offset, "".to_owned())); try!(end_data.ReplaceData(0, end_offset, DOMString::new()));
} else { } else {
// Step 19.1. // Step 19.1.
let clone = child.CloneNode(false); let clone = child.CloneNode(false);

View file

@ -62,7 +62,7 @@ impl TestBindingMethods for TestBinding {
fn SetUnrestrictedDoubleAttribute(&self, _: f64) {} fn SetUnrestrictedDoubleAttribute(&self, _: f64) {}
fn DoubleAttribute(&self) -> Finite<f64> { Finite::wrap(0.) } fn DoubleAttribute(&self) -> Finite<f64> { Finite::wrap(0.) }
fn SetDoubleAttribute(&self, _: Finite<f64>) {} fn SetDoubleAttribute(&self, _: Finite<f64>) {}
fn StringAttribute(&self) -> DOMString { "".to_owned() } fn StringAttribute(&self) -> DOMString { DOMString::new() }
fn SetStringAttribute(&self, _: DOMString) {} fn SetStringAttribute(&self, _: DOMString) {}
fn UsvstringAttribute(&self) -> USVString { USVString("".to_owned()) } fn UsvstringAttribute(&self) -> USVString { USVString("".to_owned()) }
fn SetUsvstringAttribute(&self, _: USVString) {} fn SetUsvstringAttribute(&self, _: USVString) {}
@ -77,7 +77,7 @@ impl TestBindingMethods for TestBinding {
fn SetInterfaceAttribute(&self, _: &Blob) {} fn SetInterfaceAttribute(&self, _: &Blob) {}
fn UnionAttribute(&self) -> HTMLElementOrLong { eLong(0) } fn UnionAttribute(&self) -> HTMLElementOrLong { eLong(0) }
fn SetUnionAttribute(&self, _: HTMLElementOrLong) {} fn SetUnionAttribute(&self, _: HTMLElementOrLong) {}
fn Union2Attribute(&self) -> EventOrString { eString("".to_owned()) } fn Union2Attribute(&self) -> EventOrString { eString(DOMString::new()) }
fn SetUnion2Attribute(&self, _: EventOrString) {} fn SetUnion2Attribute(&self, _: EventOrString) {}
fn Union3Attribute(&self) -> EventOrUSVString { eUSVString(USVString("".to_owned())) } fn Union3Attribute(&self) -> EventOrUSVString { eUSVString(USVString("".to_owned())) }
fn SetUnion3Attribute(&self, _: EventOrUSVString) {} fn SetUnion3Attribute(&self, _: EventOrUSVString) {}
@ -115,16 +115,16 @@ impl TestBindingMethods for TestBinding {
fn SetDoubleAttributeNullable(&self, _: Option<Finite<f64>>) {} fn SetDoubleAttributeNullable(&self, _: Option<Finite<f64>>) {}
fn GetByteStringAttributeNullable(&self) -> Option<ByteString> { Some(ByteString::new(vec!())) } fn GetByteStringAttributeNullable(&self) -> Option<ByteString> { Some(ByteString::new(vec!())) }
fn SetByteStringAttributeNullable(&self, _: Option<ByteString>) {} fn SetByteStringAttributeNullable(&self, _: Option<ByteString>) {}
fn GetStringAttributeNullable(&self) -> Option<DOMString> { Some("".to_owned()) } fn GetStringAttributeNullable(&self) -> Option<DOMString> { Some(DOMString::new()) }
fn SetStringAttributeNullable(&self, _: Option<DOMString>) {} fn SetStringAttributeNullable(&self, _: Option<DOMString>) {}
fn GetUsvstringAttributeNullable(&self) -> Option<USVString> { Some(USVString("".to_owned())) } fn GetUsvstringAttributeNullable(&self) -> Option<USVString> { Some(USVString("".to_owned())) }
fn SetUsvstringAttributeNullable(&self, _: Option<USVString>) {} fn SetUsvstringAttributeNullable(&self, _: Option<USVString>) {}
fn SetBinaryRenamedAttribute(&self, _: DOMString) {} fn SetBinaryRenamedAttribute(&self, _: DOMString) {}
fn ForwardedAttribute(&self) -> Root<TestBinding> { Root::from_ref(self) } fn ForwardedAttribute(&self) -> Root<TestBinding> { Root::from_ref(self) }
fn BinaryRenamedAttribute(&self) -> DOMString { "".to_owned() } fn BinaryRenamedAttribute(&self) -> DOMString { DOMString::new() }
fn SetBinaryRenamedAttribute2(&self, _: DOMString) {} fn SetBinaryRenamedAttribute2(&self, _: DOMString) {}
fn BinaryRenamedAttribute2(&self) -> DOMString { "".to_owned() } fn BinaryRenamedAttribute2(&self) -> DOMString { DOMString::new() }
fn Attr_to_automatically_rename(&self) -> DOMString { "".to_owned() } fn Attr_to_automatically_rename(&self) -> DOMString { DOMString::new() }
fn SetAttr_to_automatically_rename(&self, _: DOMString) {} fn SetAttr_to_automatically_rename(&self, _: DOMString) {}
fn GetEnumAttributeNullable(&self) -> Option<TestEnum> { Some(_empty) } fn GetEnumAttributeNullable(&self) -> Option<TestEnum> { Some(_empty) }
fn GetInterfaceAttributeNullable(&self) -> Option<Root<Blob>> { fn GetInterfaceAttributeNullable(&self) -> Option<Root<Blob>> {
@ -136,7 +136,7 @@ impl TestBindingMethods for TestBinding {
fn SetObjectAttributeNullable(&self, _: *mut JSContext, _: *mut JSObject) {} fn SetObjectAttributeNullable(&self, _: *mut JSContext, _: *mut JSObject) {}
fn GetUnionAttributeNullable(&self) -> Option<HTMLElementOrLong> { Some(eLong(0)) } fn GetUnionAttributeNullable(&self) -> Option<HTMLElementOrLong> { Some(eLong(0)) }
fn SetUnionAttributeNullable(&self, _: Option<HTMLElementOrLong>) {} fn SetUnionAttributeNullable(&self, _: Option<HTMLElementOrLong>) {}
fn GetUnion2AttributeNullable(&self) -> Option<EventOrString> { Some(eString("".to_owned())) } fn GetUnion2AttributeNullable(&self) -> Option<EventOrString> { Some(eString(DOMString::new())) }
fn SetUnion2AttributeNullable(&self, _: Option<EventOrString>) {} fn SetUnion2AttributeNullable(&self, _: Option<EventOrString>) {}
fn BinaryRenamedMethod(&self) -> () {} fn BinaryRenamedMethod(&self) -> () {}
fn ReceiveVoid(&self) -> () {} fn ReceiveVoid(&self) -> () {}
@ -153,7 +153,7 @@ impl TestBindingMethods for TestBinding {
fn ReceiveFloat(&self) -> Finite<f32> { Finite::wrap(0.) } fn ReceiveFloat(&self) -> Finite<f32> { Finite::wrap(0.) }
fn ReceiveUnrestrictedDouble(&self) -> f64 { 0. } fn ReceiveUnrestrictedDouble(&self) -> f64 { 0. }
fn ReceiveDouble(&self) -> Finite<f64> { Finite::wrap(0.) } fn ReceiveDouble(&self) -> Finite<f64> { Finite::wrap(0.) }
fn ReceiveString(&self) -> DOMString { "".to_owned() } fn ReceiveString(&self) -> DOMString { DOMString::new() }
fn ReceiveUsvstring(&self) -> USVString { USVString("".to_owned()) } fn ReceiveUsvstring(&self) -> USVString { USVString("".to_owned()) }
fn ReceiveByteString(&self) -> ByteString { ByteString::new(vec!()) } fn ReceiveByteString(&self) -> ByteString { ByteString::new(vec!()) }
fn ReceiveEnum(&self) -> TestEnum { _empty } fn ReceiveEnum(&self) -> TestEnum { _empty }
@ -164,7 +164,7 @@ impl TestBindingMethods for TestBinding {
fn ReceiveAny(&self, _: *mut JSContext) -> JSVal { NullValue() } fn ReceiveAny(&self, _: *mut JSContext) -> JSVal { NullValue() }
fn ReceiveObject(&self, _: *mut JSContext) -> *mut JSObject { panic!() } fn ReceiveObject(&self, _: *mut JSContext) -> *mut JSObject { panic!() }
fn ReceiveUnion(&self) -> HTMLElementOrLong { eLong(0) } fn ReceiveUnion(&self) -> HTMLElementOrLong { eLong(0) }
fn ReceiveUnion2(&self) -> EventOrString { eString("".to_owned()) } fn ReceiveUnion2(&self) -> EventOrString { eString(DOMString::new()) }
fn ReceiveNullableBoolean(&self) -> Option<bool> { Some(false) } fn ReceiveNullableBoolean(&self) -> Option<bool> { Some(false) }
fn ReceiveNullableByte(&self) -> Option<i8> { Some(0) } fn ReceiveNullableByte(&self) -> Option<i8> { Some(0) }
@ -179,7 +179,7 @@ impl TestBindingMethods for TestBinding {
fn ReceiveNullableFloat(&self) -> Option<Finite<f32>> { Some(Finite::wrap(0.)) } fn ReceiveNullableFloat(&self) -> Option<Finite<f32>> { Some(Finite::wrap(0.)) }
fn ReceiveNullableUnrestrictedDouble(&self) -> Option<f64> { Some(0.) } fn ReceiveNullableUnrestrictedDouble(&self) -> Option<f64> { Some(0.) }
fn ReceiveNullableDouble(&self) -> Option<Finite<f64>> { Some(Finite::wrap(0.)) } fn ReceiveNullableDouble(&self) -> Option<Finite<f64>> { Some(Finite::wrap(0.)) }
fn ReceiveNullableString(&self) -> Option<DOMString> { Some("".to_owned()) } fn ReceiveNullableString(&self) -> Option<DOMString> { Some(DOMString::new()) }
fn ReceiveNullableUsvstring(&self) -> Option<USVString> { Some(USVString("".to_owned())) } fn ReceiveNullableUsvstring(&self) -> Option<USVString> { Some(USVString("".to_owned())) }
fn ReceiveNullableByteString(&self) -> Option<ByteString> { Some(ByteString::new(vec!())) } fn ReceiveNullableByteString(&self) -> Option<ByteString> { Some(ByteString::new(vec!())) }
fn ReceiveNullableEnum(&self) -> Option<TestEnum> { Some(_empty) } fn ReceiveNullableEnum(&self) -> Option<TestEnum> { Some(_empty) }
@ -189,7 +189,7 @@ impl TestBindingMethods for TestBinding {
} }
fn ReceiveNullableObject(&self, _: *mut JSContext) -> *mut JSObject { ptr::null_mut() } fn ReceiveNullableObject(&self, _: *mut JSContext) -> *mut JSObject { ptr::null_mut() }
fn ReceiveNullableUnion(&self) -> Option<HTMLElementOrLong> { Some(eLong(0)) } fn ReceiveNullableUnion(&self) -> Option<HTMLElementOrLong> { Some(eLong(0)) }
fn ReceiveNullableUnion2(&self) -> Option<EventOrString> { Some(eString("".to_owned())) } fn ReceiveNullableUnion2(&self) -> Option<EventOrString> { Some(eString(DOMString::new())) }
fn PassBoolean(&self, _: bool) {} fn PassBoolean(&self, _: bool) {}
fn PassByte(&self, _: i8) {} fn PassByte(&self, _: i8) {}

View file

@ -17,16 +17,16 @@ pub struct TestBindingProxy {
impl TestBindingProxyMethods for TestBindingProxy { impl TestBindingProxyMethods for TestBindingProxy {
fn Length(&self) -> u32 { 0 } fn Length(&self) -> u32 { 0 }
fn SupportedPropertyNames(&self) -> Vec<DOMString> { vec![] } fn SupportedPropertyNames(&self) -> Vec<DOMString> { vec![] }
fn GetNamedItem(&self, _: DOMString) -> DOMString { "".to_owned() } fn GetNamedItem(&self, _: DOMString) -> DOMString { DOMString::new() }
fn SetNamedItem(&self, _: DOMString, _: DOMString) -> () {} fn SetNamedItem(&self, _: DOMString, _: DOMString) -> () {}
fn GetItem(&self, _: u32) -> DOMString { "".to_owned() } fn GetItem(&self, _: u32) -> DOMString { DOMString::new() }
fn SetItem(&self, _: u32, _: DOMString) -> () {} fn SetItem(&self, _: u32, _: DOMString) -> () {}
fn RemoveItem(&self, _: DOMString) -> () {} fn RemoveItem(&self, _: DOMString) -> () {}
fn Stringifier(&self) -> DOMString { "".to_owned() } fn Stringifier(&self) -> DOMString { DOMString::new() }
fn IndexedGetter(&self, _: u32, _: &mut bool) -> DOMString { "".to_owned() } fn IndexedGetter(&self, _: u32, _: &mut bool) -> DOMString { DOMString::new() }
fn NamedDeleter(&self, _: DOMString) -> () {} fn NamedDeleter(&self, _: DOMString) -> () {}
fn IndexedSetter(&self, _: u32, _: DOMString) -> () {} fn IndexedSetter(&self, _: u32, _: DOMString) -> () {}
fn NamedSetter(&self, _: DOMString, _: DOMString) -> () {} fn NamedSetter(&self, _: DOMString, _: DOMString) -> () {}
fn NamedGetter(&self, _: DOMString, _: &mut bool) -> DOMString { "".to_owned() } fn NamedGetter(&self, _: DOMString, _: &mut bool) -> DOMString { DOMString::new() }
} }

View file

@ -58,7 +58,7 @@ impl WebGLContextEvent {
init: &WebGLContextEventInit) -> Fallible<Root<WebGLContextEvent>> { init: &WebGLContextEventInit) -> Fallible<Root<WebGLContextEvent>> {
let status_message = match init.statusMessage.as_ref() { let status_message = match init.statusMessage.as_ref() {
Some(message) => message.clone(), Some(message) => message.clone(),
None => "".to_owned(), None => DOMString::new(),
}; };
let bubbles = if init.parent.bubbles { let bubbles = if init.parent.bubbles {

View file

@ -151,7 +151,7 @@ impl XMLHttpRequest {
timeout: Cell::new(0u32), timeout: Cell::new(0u32),
with_credentials: Cell::new(false), with_credentials: Cell::new(false),
upload: JS::from_rooted(&XMLHttpRequestUpload::new(global)), upload: JS::from_rooted(&XMLHttpRequestUpload::new(global)),
response_url: "".to_owned(), response_url: DOMString::new(),
status: Cell::new(0), status: Cell::new(0),
status_text: DOMRefCell::new(ByteString::new(vec!())), status_text: DOMRefCell::new(ByteString::new(vec!())),
response: DOMRefCell::new(ByteString::new(vec!())), response: DOMRefCell::new(ByteString::new(vec!())),

View file

@ -1642,9 +1642,9 @@ impl ScriptTask {
window.evaluate_js_on_global_with_result(evalstr, jsval.handle_mut()); window.evaluate_js_on_global_with_result(evalstr, jsval.handle_mut());
let strval = FromJSValConvertible::from_jsval(self.get_cx(), jsval.handle(), let strval = FromJSValConvertible::from_jsval(self.get_cx(), jsval.handle(),
StringificationBehavior::Empty); StringificationBehavior::Empty);
strval.unwrap_or("".to_owned()) strval.unwrap_or(DOMString::new())
} else { } else {
"".to_owned() DOMString::new()
}; };
parse_html(document.r(), parse_input, final_url, parse_html(document.r(), parse_input, final_url,

View file

@ -124,7 +124,7 @@ impl<T: ClipboardProvider> TextInput<T> {
if self.selection_begin.is_none() { if self.selection_begin.is_none() {
self.adjust_horizontal_by_one(dir, Selection::Selected); self.adjust_horizontal_by_one(dir, Selection::Selected);
} }
self.replace_selection("".to_owned()); self.replace_selection(DOMString::new());
} }
/// Insert a character at the current editing point /// Insert a character at the current editing point