diff --git a/components/script/dom/bindings/conversions.rs b/components/script/dom/bindings/conversions.rs index 7bd6a3c8b90..9078fe77ed4 100644 --- a/components/script/dom/bindings/conversions.rs +++ b/components/script/dom/bindings/conversions.rs @@ -56,7 +56,6 @@ use js::rust::{ToInt64, ToUint64}; use libc; use num::Float; use num::traits::{Bounded, Zero}; -use std::borrow::ToOwned; use std::rc::Rc; use std::{char, ptr, slice}; use util::str::DOMString; @@ -517,7 +516,7 @@ impl FromJSValConvertible for DOMString { -> Result { if null_behavior == StringificationBehavior::Empty && value.get().is_null() { - Ok("".to_owned()) + Ok(DOMString::new()) } else { let jsstr = unsafe { ToString(cx, value) }; if jsstr.is_null() { diff --git a/components/script/dom/blob.rs b/components/script/dom/blob.rs index 0645a146c0f..b42bcce573e 100644 --- a/components/script/dom/blob.rs +++ b/components/script/dom/blob.rs @@ -113,13 +113,13 @@ impl BlobMethods for Blob { } }; let relativeContentType = match contentType { - None => "".to_owned(), + None => DOMString::new(), Some(mut str) => { if is_ascii_printable(&str) { str.make_ascii_lowercase(); str } else { - "".to_owned() + DOMString::new() } } }; diff --git a/components/script/dom/characterdata.rs b/components/script/dom/characterdata.rs index b012122c2ec..5c1558086ea 100644 --- a/components/script/dom/characterdata.rs +++ b/components/script/dom/characterdata.rs @@ -80,7 +80,7 @@ impl CharacterDataMethods for CharacterData { // https://dom.spec.whatwg.org/#dom-characterdata-deletedataoffset-count 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 diff --git a/components/script/dom/cssstyledeclaration.rs b/components/script/dom/cssstyledeclaration.rs index 5eff390ff69..a3f2f048b22 100644 --- a/components/script/dom/cssstyledeclaration.rs +++ b/components/script/dom/cssstyledeclaration.rs @@ -126,7 +126,7 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration { if self.readonly { // 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 @@ -143,7 +143,7 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration { // Step 2.2.2 & 2.2.3 match 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 let result = match owner.get_inline_style_declaration(&property) { Some(declaration) => declaration.value(), - None => "".to_owned(), + None => DOMString::new(), }; result } @@ -183,7 +183,7 @@ impl CSSStyleDeclarationMethods for CSSStyleDeclaration { } // Step 4 - "".to_owned() + DOMString::new() } // 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 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 diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index eb018092a24..7a6b569897e 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -942,7 +942,7 @@ impl Document { Some(ref body) => { body.upcast::().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); // repetition used because string_cache::atom::Atom is non-copyable 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)) } @@ -1553,7 +1553,7 @@ impl DocumentMethods for Document { -> Fallible> { let (namespace, prefix, local_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); Ok(Attr::new(&self.window, local_name, value, qualified_name, namespace, prefix, None)) diff --git a/components/script/dom/documenttype.rs b/components/script/dom/documenttype.rs index 1754ad84f66..ed5a64307cc 100644 --- a/components/script/dom/documenttype.rs +++ b/components/script/dom/documenttype.rs @@ -10,7 +10,6 @@ use dom::bindings::inheritance::Castable; use dom::bindings::js::Root; use dom::document::Document; use dom::node::Node; -use std::borrow::ToOwned; use util::str::DOMString; // https://dom.spec.whatwg.org/#documenttype @@ -32,8 +31,8 @@ impl DocumentType { DocumentType { node: Node::new_inherited(document), name: name, - public_id: public_id.unwrap_or("".to_owned()), - system_id: system_id.unwrap_or("".to_owned()) + public_id: public_id.unwrap_or(DOMString::new()), + system_id: system_id.unwrap_or(DOMString::new()) } } #[allow(unrooted_must_root)] diff --git a/components/script/dom/domstringmap.rs b/components/script/dom/domstringmap.rs index b27f0eca4e0..5486af84a8b 100644 --- a/components/script/dom/domstringmap.rs +++ b/components/script/dom/domstringmap.rs @@ -54,7 +54,7 @@ impl DOMStringMapMethods for DOMStringMap { }, None => { *found = false; - String::new() + DOMString::new() } } } diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 9f860d1f2bb..447658e4660 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -1014,7 +1014,7 @@ impl Element { pub fn set_bool_attribute(&self, local_name: &Atom, value: bool) { if self.has_attribute(local_name) == value { return; } if value { - self.set_string_attribute(local_name, String::new()); + self.set_string_attribute(local_name, DOMString::new()); } else { self.remove_attribute(&ns!(""), local_name); } @@ -1023,7 +1023,7 @@ impl Element { pub fn get_url_attribute(&self, local_name: &Atom) -> DOMString { assert!(&**local_name == local_name.to_ascii_lowercase()); if !self.has_attribute(local_name) { - return "".to_owned(); + return DOMString::new(); } let url = self.get_string_attribute(local_name); let doc = document_from_node(self); @@ -1042,7 +1042,7 @@ impl Element { pub fn get_string_attribute(&self, local_name: &Atom) -> DOMString { match self.get_attribute(&ns!(""), local_name) { Some(x) => x.Value(), - None => "".to_owned() + None => DOMString::new() } } pub fn set_string_attribute(&self, local_name: &Atom, value: DOMString) { diff --git a/components/script/dom/errorevent.rs b/components/script/dom/errorevent.rs index 21e70ab8436..75c782becf9 100644 --- a/components/script/dom/errorevent.rs +++ b/components/script/dom/errorevent.rs @@ -15,7 +15,6 @@ use dom::bindings::trace::JSTraceable; use dom::event::{Event, EventBubbles, EventCancelable}; use js::jsapi::{RootedValue, HandleValue, JSContext}; use js::jsval::JSVal; -use std::borrow::ToOwned; use std::cell::Cell; use util::str::DOMString; @@ -34,8 +33,8 @@ impl ErrorEvent { fn new_inherited() -> ErrorEvent { ErrorEvent { event: Event::new_inherited(), - message: DOMRefCell::new("".to_owned()), - filename: DOMRefCell::new("".to_owned()), + message: DOMRefCell::new(DOMString::new()), + filename: DOMRefCell::new(DOMString::new()), lineno: Cell::new(0), colno: Cell::new(0), error: MutHeapJSVal::new() @@ -76,12 +75,12 @@ impl ErrorEvent { init: &ErrorEventBinding::ErrorEventInit) -> Fallible>{ let msg = match init.message.as_ref() { Some(message) => message.clone(), - None => "".to_owned(), + None => DOMString::new(), }; let file_name = match init.filename.as_ref() { - None => "".to_owned(), Some(filename) => filename.clone(), + None => DOMString::new(), }; let line_num = init.lineno.unwrap_or(0); diff --git a/components/script/dom/htmldialogelement.rs b/components/script/dom/htmldialogelement.rs index 0d9e534f85c..d52d564d74b 100644 --- a/components/script/dom/htmldialogelement.rs +++ b/components/script/dom/htmldialogelement.rs @@ -9,7 +9,6 @@ use dom::bindings::js::Root; use dom::document::Document; use dom::htmlelement::HTMLElement; use dom::node::Node; -use std::borrow::ToOwned; use util::str::DOMString; #[dom_struct] @@ -25,7 +24,7 @@ impl HTMLDialogElement { HTMLDialogElement { htmlelement: HTMLElement::new_inherited(localName, prefix, document), - return_value: DOMRefCell::new("".to_owned()), + return_value: DOMRefCell::new(DOMString::new()), } } diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs index 66a03f1557d..0f28260d970 100644 --- a/components/script/dom/htmlformelement.rs +++ b/components/script/dom/htmlformelement.rs @@ -491,7 +491,7 @@ pub trait FormControl: DerivedFrom + Reflectable { if self.to_element().has_attribute(attr) { input(self) } else { - self.form_owner().map_or("".to_owned(), |t| owner(t.r())) + self.form_owner().map_or(DOMString::new(), |t| owner(t.r())) } } diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index 04ff8e0d670..daa7fbde84b 100644 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -111,11 +111,11 @@ impl HTMLInputElement { HTMLElement::new_inherited_with_state(IN_ENABLED_STATE, localName, prefix, document), input_type: Cell::new(InputType::InputText), - placeholder: DOMRefCell::new("".to_owned()), + placeholder: DOMRefCell::new(DOMString::new()), checked_changed: Cell::new(false), value_changed: Cell::new(false), 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()) } } diff --git a/components/script/dom/htmloptionelement.rs b/components/script/dom/htmloptionelement.rs index 873745dd6a7..9db05875b91 100644 --- a/components/script/dom/htmloptionelement.rs +++ b/components/script/dom/htmloptionelement.rs @@ -96,7 +96,7 @@ impl HTMLOptionElementMethods for HTMLOptionElement { // https://html.spec.whatwg.org/multipage/#dom-option-text fn Text(&self) -> DOMString { - let mut content = String::new(); + let mut content = DOMString::new(); collect_text(self.upcast(), &mut content); str_join(split_html_space_chars(&content), " ") } diff --git a/components/script/dom/htmltextareaelement.rs b/components/script/dom/htmltextareaelement.rs index 0b31e628743..fbb71031125 100644 --- a/components/script/dom/htmltextareaelement.rs +++ b/components/script/dom/htmltextareaelement.rs @@ -99,7 +99,7 @@ impl HTMLTextAreaElement { htmlelement: HTMLElement::new_inherited_with_state(IN_ENABLED_STATE, 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), rows: Cell::new(DEFAULT_ROWS), value_changed: Cell::new(false), diff --git a/components/script/dom/keyboardevent.rs b/components/script/dom/keyboardevent.rs index 86c536f69e4..c7f91cccee8 100644 --- a/components/script/dom/keyboardevent.rs +++ b/components/script/dom/keyboardevent.rs @@ -17,7 +17,6 @@ use dom::window::Window; use msg::constellation_msg; use msg::constellation_msg::{ALT, CONTROL, SHIFT, SUPER}; use msg::constellation_msg::{Key, KeyModifiers}; -use std::borrow::ToOwned; use std::cell::Cell; use util::str::DOMString; @@ -45,8 +44,8 @@ impl KeyboardEvent { KeyboardEvent { uievent: UIEvent::new_inherited(), key: Cell::new(None), - key_string: DOMRefCell::new("".to_owned()), - code: DOMRefCell::new("".to_owned()), + key_string: DOMRefCell::new(DOMString::new()), + code: DOMRefCell::new(DOMString::new()), location: Cell::new(0), ctrl: Cell::new(false), alt: Cell::new(false), @@ -85,7 +84,7 @@ impl KeyboardEvent { key_code: u32) -> Root { let ev = KeyboardEvent::new_uninitialized(window); 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) { let ev = ev.r(); diff --git a/components/script/dom/messageevent.rs b/components/script/dom/messageevent.rs index 2509031abdc..c418df4de3c 100644 --- a/components/script/dom/messageevent.rs +++ b/components/script/dom/messageevent.rs @@ -28,7 +28,10 @@ pub struct MessageEvent { impl MessageEvent { pub fn new_uninitialized(global: GlobalRef) -> Root { - 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, @@ -77,7 +80,7 @@ impl MessageEvent { message: HandleValue) { let messageevent = MessageEvent::new( scope, "message".to_owned(), false, false, message, - "".to_owned(), "".to_owned()); + DOMString::new(), DOMString::new()); messageevent.upcast::().fire(target); } } diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index ad1c4a4af81..6b5cf8be2f2 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -784,14 +784,14 @@ impl Node { baseURI: self.BaseURI(), parent: self.GetParentNode().map(|node| node.get_unique_id()).unwrap_or("".to_owned()), nodeType: self.NodeType(), - namespaceURI: "".to_owned(), //FIXME + namespaceURI: DOMString::new(), //FIXME nodeName: self.NodeName(), numChildren: self.ChildNodes().Length() as usize, //FIXME doctype nodes only - name: "".to_owned(), - publicId: "".to_owned(), - systemId: "".to_owned(), + name: DOMString::new(), + publicId: DOMString::new(), + systemId: DOMString::new(), attrs: self.downcast().map(Element::summarize).unwrap_or(vec![]), isDocumentElement: @@ -800,7 +800,7 @@ impl Node { .map(|elem| elem.upcast::() == self) .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 } } @@ -1903,7 +1903,7 @@ impl NodeMethods for Node { // https://dom.spec.whatwg.org/#dom-node-textcontent fn SetTextContent(&self, value: Option) { - let value = value.unwrap_or(String::new()); + let value = value.unwrap_or(DOMString::new()); match self.type_id() { NodeTypeId::DocumentFragment | NodeTypeId::Element(..) => { diff --git a/components/script/dom/range.rs b/components/script/dom/range.rs index 1675036e80b..6175ba4383e 100644 --- a/components/script/dom/range.rs +++ b/components/script/dom/range.rs @@ -23,6 +23,7 @@ use dom::node::Node; use dom::text::Text; use std::cell::Cell; use std::cmp::{Ord, Ordering, PartialEq, PartialOrd}; +use util::str::DOMString; #[dom_struct] pub struct Range { @@ -524,7 +525,7 @@ impl RangeMethods for Range { // Step 4.4. try!(end_data.ReplaceData(start_offset, end_offset - start_offset, - "".to_owned())); + DOMString::new())); // Step 4.5. return Ok(fragment); } @@ -560,7 +561,7 @@ impl RangeMethods for Range { // Step 15.4. try!(start_data.ReplaceData(start_offset, start_node.len() - start_offset, - "".to_owned())); + DOMString::new())); } else { // Step 16.1. let clone = child.CloneNode(false); @@ -595,7 +596,7 @@ impl RangeMethods for Range { // Step 18.3. try!(fragment.upcast::().AppendChild(&clone)); // Step 18.4. - try!(end_data.ReplaceData(0, end_offset, "".to_owned())); + try!(end_data.ReplaceData(0, end_offset, DOMString::new())); } else { // Step 19.1. let clone = child.CloneNode(false); diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs index 9e6d98dc3dd..6e78e4e3316 100644 --- a/components/script/dom/testbinding.rs +++ b/components/script/dom/testbinding.rs @@ -62,7 +62,7 @@ impl TestBindingMethods for TestBinding { fn SetUnrestrictedDoubleAttribute(&self, _: f64) {} fn DoubleAttribute(&self) -> Finite { Finite::wrap(0.) } fn SetDoubleAttribute(&self, _: Finite) {} - fn StringAttribute(&self) -> DOMString { "".to_owned() } + fn StringAttribute(&self) -> DOMString { DOMString::new() } fn SetStringAttribute(&self, _: DOMString) {} fn UsvstringAttribute(&self) -> USVString { USVString("".to_owned()) } fn SetUsvstringAttribute(&self, _: USVString) {} @@ -77,7 +77,7 @@ impl TestBindingMethods for TestBinding { fn SetInterfaceAttribute(&self, _: &Blob) {} fn UnionAttribute(&self) -> HTMLElementOrLong { eLong(0) } fn SetUnionAttribute(&self, _: HTMLElementOrLong) {} - fn Union2Attribute(&self) -> EventOrString { eString("".to_owned()) } + fn Union2Attribute(&self) -> EventOrString { eString(DOMString::new()) } fn SetUnion2Attribute(&self, _: EventOrString) {} fn Union3Attribute(&self) -> EventOrUSVString { eUSVString(USVString("".to_owned())) } fn SetUnion3Attribute(&self, _: EventOrUSVString) {} @@ -115,16 +115,16 @@ impl TestBindingMethods for TestBinding { fn SetDoubleAttributeNullable(&self, _: Option>) {} fn GetByteStringAttributeNullable(&self) -> Option { Some(ByteString::new(vec!())) } fn SetByteStringAttributeNullable(&self, _: Option) {} - fn GetStringAttributeNullable(&self) -> Option { Some("".to_owned()) } + fn GetStringAttributeNullable(&self) -> Option { Some(DOMString::new()) } fn SetStringAttributeNullable(&self, _: Option) {} fn GetUsvstringAttributeNullable(&self) -> Option { Some(USVString("".to_owned())) } fn SetUsvstringAttributeNullable(&self, _: Option) {} fn SetBinaryRenamedAttribute(&self, _: DOMString) {} fn ForwardedAttribute(&self) -> Root { Root::from_ref(self) } - fn BinaryRenamedAttribute(&self) -> DOMString { "".to_owned() } + fn BinaryRenamedAttribute(&self) -> DOMString { DOMString::new() } fn SetBinaryRenamedAttribute2(&self, _: DOMString) {} - fn BinaryRenamedAttribute2(&self) -> DOMString { "".to_owned() } - fn Attr_to_automatically_rename(&self) -> DOMString { "".to_owned() } + fn BinaryRenamedAttribute2(&self) -> DOMString { DOMString::new() } + fn Attr_to_automatically_rename(&self) -> DOMString { DOMString::new() } fn SetAttr_to_automatically_rename(&self, _: DOMString) {} fn GetEnumAttributeNullable(&self) -> Option { Some(_empty) } fn GetInterfaceAttributeNullable(&self) -> Option> { @@ -136,7 +136,7 @@ impl TestBindingMethods for TestBinding { fn SetObjectAttributeNullable(&self, _: *mut JSContext, _: *mut JSObject) {} fn GetUnionAttributeNullable(&self) -> Option { Some(eLong(0)) } fn SetUnionAttributeNullable(&self, _: Option) {} - fn GetUnion2AttributeNullable(&self) -> Option { Some(eString("".to_owned())) } + fn GetUnion2AttributeNullable(&self) -> Option { Some(eString(DOMString::new())) } fn SetUnion2AttributeNullable(&self, _: Option) {} fn BinaryRenamedMethod(&self) -> () {} fn ReceiveVoid(&self) -> () {} @@ -153,7 +153,7 @@ impl TestBindingMethods for TestBinding { fn ReceiveFloat(&self) -> Finite { Finite::wrap(0.) } fn ReceiveUnrestrictedDouble(&self) -> f64 { 0. } fn ReceiveDouble(&self) -> Finite { Finite::wrap(0.) } - fn ReceiveString(&self) -> DOMString { "".to_owned() } + fn ReceiveString(&self) -> DOMString { DOMString::new() } fn ReceiveUsvstring(&self) -> USVString { USVString("".to_owned()) } fn ReceiveByteString(&self) -> ByteString { ByteString::new(vec!()) } fn ReceiveEnum(&self) -> TestEnum { _empty } @@ -164,7 +164,7 @@ impl TestBindingMethods for TestBinding { fn ReceiveAny(&self, _: *mut JSContext) -> JSVal { NullValue() } fn ReceiveObject(&self, _: *mut JSContext) -> *mut JSObject { panic!() } fn ReceiveUnion(&self) -> HTMLElementOrLong { eLong(0) } - fn ReceiveUnion2(&self) -> EventOrString { eString("".to_owned()) } + fn ReceiveUnion2(&self) -> EventOrString { eString(DOMString::new()) } fn ReceiveNullableBoolean(&self) -> Option { Some(false) } fn ReceiveNullableByte(&self) -> Option { Some(0) } @@ -179,7 +179,7 @@ impl TestBindingMethods for TestBinding { fn ReceiveNullableFloat(&self) -> Option> { Some(Finite::wrap(0.)) } fn ReceiveNullableUnrestrictedDouble(&self) -> Option { Some(0.) } fn ReceiveNullableDouble(&self) -> Option> { Some(Finite::wrap(0.)) } - fn ReceiveNullableString(&self) -> Option { Some("".to_owned()) } + fn ReceiveNullableString(&self) -> Option { Some(DOMString::new()) } fn ReceiveNullableUsvstring(&self) -> Option { Some(USVString("".to_owned())) } fn ReceiveNullableByteString(&self) -> Option { Some(ByteString::new(vec!())) } fn ReceiveNullableEnum(&self) -> Option { Some(_empty) } @@ -189,7 +189,7 @@ impl TestBindingMethods for TestBinding { } fn ReceiveNullableObject(&self, _: *mut JSContext) -> *mut JSObject { ptr::null_mut() } fn ReceiveNullableUnion(&self) -> Option { Some(eLong(0)) } - fn ReceiveNullableUnion2(&self) -> Option { Some(eString("".to_owned())) } + fn ReceiveNullableUnion2(&self) -> Option { Some(eString(DOMString::new())) } fn PassBoolean(&self, _: bool) {} fn PassByte(&self, _: i8) {} diff --git a/components/script/dom/testbindingproxy.rs b/components/script/dom/testbindingproxy.rs index 0c323a3f4c3..120d125de72 100644 --- a/components/script/dom/testbindingproxy.rs +++ b/components/script/dom/testbindingproxy.rs @@ -17,16 +17,16 @@ pub struct TestBindingProxy { impl TestBindingProxyMethods for TestBindingProxy { fn Length(&self) -> u32 { 0 } fn SupportedPropertyNames(&self) -> Vec { vec![] } - fn GetNamedItem(&self, _: DOMString) -> DOMString { "".to_owned() } + fn GetNamedItem(&self, _: DOMString) -> DOMString { DOMString::new() } 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 RemoveItem(&self, _: DOMString) -> () {} - fn Stringifier(&self) -> DOMString { "".to_owned() } - fn IndexedGetter(&self, _: u32, _: &mut bool) -> DOMString { "".to_owned() } + fn Stringifier(&self) -> DOMString { DOMString::new() } + fn IndexedGetter(&self, _: u32, _: &mut bool) -> DOMString { DOMString::new() } fn NamedDeleter(&self, _: DOMString) -> () {} fn IndexedSetter(&self, _: u32, _: DOMString) -> () {} fn NamedSetter(&self, _: DOMString, _: DOMString) -> () {} - fn NamedGetter(&self, _: DOMString, _: &mut bool) -> DOMString { "".to_owned() } + fn NamedGetter(&self, _: DOMString, _: &mut bool) -> DOMString { DOMString::new() } } diff --git a/components/script/dom/webglcontextevent.rs b/components/script/dom/webglcontextevent.rs index ce42026b5d2..0e236ad634f 100644 --- a/components/script/dom/webglcontextevent.rs +++ b/components/script/dom/webglcontextevent.rs @@ -58,7 +58,7 @@ impl WebGLContextEvent { init: &WebGLContextEventInit) -> Fallible> { let status_message = match init.statusMessage.as_ref() { Some(message) => message.clone(), - None => "".to_owned(), + None => DOMString::new(), }; let bubbles = if init.parent.bubbles { diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs index 3d24eb956cf..aa617abcb0c 100644 --- a/components/script/dom/xmlhttprequest.rs +++ b/components/script/dom/xmlhttprequest.rs @@ -151,7 +151,7 @@ impl XMLHttpRequest { timeout: Cell::new(0u32), with_credentials: Cell::new(false), upload: JS::from_rooted(&XMLHttpRequestUpload::new(global)), - response_url: "".to_owned(), + response_url: DOMString::new(), status: Cell::new(0), status_text: DOMRefCell::new(ByteString::new(vec!())), response: DOMRefCell::new(ByteString::new(vec!())), diff --git a/components/script/script_task.rs b/components/script/script_task.rs index ff74192bab4..5455c5868fa 100644 --- a/components/script/script_task.rs +++ b/components/script/script_task.rs @@ -1642,9 +1642,9 @@ impl ScriptTask { window.evaluate_js_on_global_with_result(evalstr, jsval.handle_mut()); let strval = FromJSValConvertible::from_jsval(self.get_cx(), jsval.handle(), StringificationBehavior::Empty); - strval.unwrap_or("".to_owned()) + strval.unwrap_or(DOMString::new()) } else { - "".to_owned() + DOMString::new() }; parse_html(document.r(), parse_input, final_url, diff --git a/components/script/textinput.rs b/components/script/textinput.rs index c75d246d3ba..ce69139d5ab 100644 --- a/components/script/textinput.rs +++ b/components/script/textinput.rs @@ -124,7 +124,7 @@ impl TextInput { if self.selection_begin.is_none() { 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