mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Replace most ~"string"s with "string".to_owned().
This commit is contained in:
parent
660f7a016e
commit
25542e3f7e
35 changed files with 206 additions and 206 deletions
|
@ -82,7 +82,7 @@ pub fn _obj_toString(cx: *JSContext, className: *libc::c_char) -> *JSString {
|
|||
return ptr::null();
|
||||
}
|
||||
|
||||
let result = ~"[object " + name + "]";
|
||||
let result = "[object ".to_owned() + name + "]";
|
||||
for (i, c) in result.chars().enumerate() {
|
||||
*chars.offset(i as int) = c as jschar;
|
||||
}
|
||||
|
|
|
@ -212,16 +212,16 @@ impl Document {
|
|||
Some(string) => string.clone(),
|
||||
None => match is_html_document {
|
||||
// http://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
|
||||
HTMLDocument => ~"text/html",
|
||||
HTMLDocument => "text/html".to_owned(),
|
||||
// http://dom.spec.whatwg.org/#concept-document-content-type
|
||||
NonHTMLDocument => ~"application/xml"
|
||||
NonHTMLDocument => "application/xml".to_owned()
|
||||
}
|
||||
},
|
||||
url: Untraceable::new(url),
|
||||
// http://dom.spec.whatwg.org/#concept-document-quirks
|
||||
quirks_mode: Untraceable::new(NoQuirks),
|
||||
// http://dom.spec.whatwg.org/#concept-document-encoding
|
||||
encoding_name: ~"utf-8",
|
||||
encoding_name: "utf-8".to_owned(),
|
||||
is_html_document: is_html_document == HTMLDocument,
|
||||
}
|
||||
}
|
||||
|
@ -346,8 +346,8 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
|||
// http://dom.spec.whatwg.org/#dom-document-compatmode
|
||||
fn CompatMode(&self) -> DOMString {
|
||||
match *self.quirks_mode {
|
||||
NoQuirks => ~"CSS1Compat",
|
||||
LimitedQuirks | FullQuirks => ~"BackCompat"
|
||||
NoQuirks => "CSS1Compat".to_owned(),
|
||||
LimitedQuirks | FullQuirks => "BackCompat".to_owned()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -585,7 +585,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
|||
assert!(title_node.AppendChild(NodeCast::from_mut_ref(&mut *new_text)).is_ok());
|
||||
},
|
||||
None => {
|
||||
let mut new_title = HTMLTitleElement::new(~"title", self).root();
|
||||
let mut new_title = HTMLTitleElement::new("title".to_owned(), self).root();
|
||||
let new_title: &mut JSRef<Node> = NodeCast::from_mut_ref(&mut *new_title);
|
||||
|
||||
let mut new_text = self.CreateTextNode(title.clone()).root();
|
||||
|
|
|
@ -88,27 +88,27 @@ impl<'a> DOMExceptionMethods for JSRef<'a, DOMException> {
|
|||
// http://dom.spec.whatwg.org/#error-names-0
|
||||
fn Message(&self) -> DOMString {
|
||||
match self.code {
|
||||
IndexSizeError => ~"The index is not in the allowed range.",
|
||||
HierarchyRequestError => ~"The operation would yield an incorrect node tree.",
|
||||
WrongDocumentError => ~"The object is in the wrong document.",
|
||||
InvalidCharacterError => ~"The string contains invalid characters.",
|
||||
NoModificationAllowedError => ~"The object can not be modified.",
|
||||
NotFoundError => ~"The object can not be found here.",
|
||||
NotSupportedError => ~"The operation is not supported.",
|
||||
InvalidStateError => ~"The object is in an invalid state.",
|
||||
SyntaxError => ~"The string did not match the expected pattern.",
|
||||
InvalidModificationError => ~"The object can not be modified in this way.",
|
||||
NamespaceError => ~"The operation is not allowed by Namespaces in XML.",
|
||||
InvalidAccessError => ~"The object does not support the operation or argument.",
|
||||
SecurityError => ~"The operation is insecure.",
|
||||
NetworkError => ~"A network error occurred.",
|
||||
AbortError => ~"The operation was aborted.",
|
||||
URLMismatchError => ~"The given URL does not match another URL.",
|
||||
QuotaExceededError => ~"The quota has been exceeded.",
|
||||
TimeoutError => ~"The operation timed out.",
|
||||
InvalidNodeTypeError => ~"The supplied node is incorrect or has an incorrect ancestor for this operation.",
|
||||
DataCloneError => ~"The object can not be cloned.",
|
||||
EncodingError => ~"The encoding operation (either encoded or decoding) failed."
|
||||
IndexSizeError => "The index is not in the allowed range.".to_owned(),
|
||||
HierarchyRequestError => "The operation would yield an incorrect node tree.".to_owned(),
|
||||
WrongDocumentError => "The object is in the wrong document.".to_owned(),
|
||||
InvalidCharacterError => "The string contains invalid characters.".to_owned(),
|
||||
NoModificationAllowedError => "The object can not be modified.".to_owned(),
|
||||
NotFoundError => "The object can not be found here.".to_owned(),
|
||||
NotSupportedError => "The operation is not supported.".to_owned(),
|
||||
InvalidStateError => "The object is in an invalid state.".to_owned(),
|
||||
SyntaxError => "The string did not match the expected pattern.".to_owned(),
|
||||
InvalidModificationError => "The object can not be modified in this way.".to_owned(),
|
||||
NamespaceError => "The operation is not allowed by Namespaces in XML.".to_owned(),
|
||||
InvalidAccessError => "The object does not support the operation or argument.".to_owned(),
|
||||
SecurityError => "The operation is insecure.".to_owned(),
|
||||
NetworkError => "A network error occurred.".to_owned(),
|
||||
AbortError => "The operation was aborted.".to_owned(),
|
||||
URLMismatchError => "The given URL does not match another URL.".to_owned(),
|
||||
QuotaExceededError => "The quota has been exceeded.".to_owned(),
|
||||
TimeoutError => "The operation timed out.".to_owned(),
|
||||
InvalidNodeTypeError => "The supplied node is incorrect or has an incorrect ancestor for this operation.".to_owned(),
|
||||
DataCloneError => "The object can not be cloned.".to_owned(),
|
||||
EncodingError => "The encoding operation (either encoded or decoding) failed.".to_owned()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,18 +129,18 @@ impl<'a> DOMImplementationMethods for JSRef<'a, DOMImplementation> {
|
|||
|
||||
{
|
||||
// Step 3.
|
||||
let mut doc_type = DocumentType::new(~"html", None, None, &*doc).root();
|
||||
let mut doc_type = DocumentType::new("html".to_owned(), None, None, &*doc).root();
|
||||
assert!(doc_node.AppendChild(NodeCast::from_mut_ref(&mut *doc_type)).is_ok());
|
||||
}
|
||||
|
||||
{
|
||||
// Step 4.
|
||||
let mut doc_html = NodeCast::from_unrooted(HTMLHtmlElement::new(~"html", &*doc)).root();
|
||||
let mut doc_html = NodeCast::from_unrooted(HTMLHtmlElement::new("html".to_owned(), &*doc)).root();
|
||||
assert!(doc_node.AppendChild(&mut *doc_html).is_ok());
|
||||
|
||||
{
|
||||
// Step 5.
|
||||
let mut doc_head = NodeCast::from_unrooted(HTMLHeadElement::new(~"head", &*doc)).root();
|
||||
let mut doc_head = NodeCast::from_unrooted(HTMLHeadElement::new("head".to_owned(), &*doc)).root();
|
||||
assert!(doc_html.AppendChild(&mut *doc_head).is_ok());
|
||||
|
||||
// Step 6.
|
||||
|
@ -148,7 +148,7 @@ impl<'a> DOMImplementationMethods for JSRef<'a, DOMImplementation> {
|
|||
None => (),
|
||||
Some(title_str) => {
|
||||
// Step 6.1.
|
||||
let mut doc_title = NodeCast::from_unrooted(HTMLTitleElement::new(~"title", &*doc)).root();
|
||||
let mut doc_title = NodeCast::from_unrooted(HTMLTitleElement::new("title".to_owned(), &*doc)).root();
|
||||
assert!(doc_head.AppendChild(&mut *doc_title).is_ok());
|
||||
|
||||
// Step 6.2.
|
||||
|
@ -159,7 +159,7 @@ impl<'a> DOMImplementationMethods for JSRef<'a, DOMImplementation> {
|
|||
}
|
||||
|
||||
// Step 7.
|
||||
let mut doc_body = HTMLBodyElement::new(~"body", &*doc).root();
|
||||
let mut doc_body = HTMLBodyElement::new("body".to_owned(), &*doc).root();
|
||||
assert!(doc_html.AppendChild(NodeCast::from_mut_ref(&mut *doc_body)).is_ok());
|
||||
}
|
||||
|
||||
|
|
|
@ -48,10 +48,10 @@ impl<'a> DOMParserMethods for JSRef<'a, DOMParser> {
|
|||
let owner = self.owner.root();
|
||||
match ty {
|
||||
Text_html => {
|
||||
Ok(Document::new(&owner.root_ref(), None, HTMLDocument, Some(~"text/html")))
|
||||
Ok(Document::new(&owner.root_ref(), None, HTMLDocument, Some("text/html".to_owned())))
|
||||
}
|
||||
Text_xml => {
|
||||
Ok(Document::new(&owner.root_ref(), None, NonHTMLDocument, Some(~"text/xml")))
|
||||
Ok(Document::new(&owner.root_ref(), None, NonHTMLDocument, Some("text/xml".to_owned())))
|
||||
}
|
||||
_ => {
|
||||
Err(FailureUnknown)
|
||||
|
|
|
@ -571,7 +571,7 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
|
|||
}
|
||||
|
||||
// Step 8.
|
||||
if namespace == namespace::XMLNS && "xmlns" != name && Some(~"xmlns") != prefix {
|
||||
if namespace == namespace::XMLNS && "xmlns" != name && Some("xmlns".to_owned()) != prefix {
|
||||
return Err(NamespaceError);
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ impl<'a> FormDataMethods for JSRef<'a, FormData> {
|
|||
fn Append(&mut self, name: DOMString, value: &JSRef<Blob>, filename: Option<DOMString>) {
|
||||
let blob = BlobData {
|
||||
blob: value.unrooted(),
|
||||
name: filename.unwrap_or(~"default")
|
||||
name: filename.unwrap_or("default".to_owned())
|
||||
};
|
||||
self.data.insert(name.clone(), blob);
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ pub fn serialize(iterator: &mut NodeIterator) -> ~str {
|
|||
|
||||
for node in *iterator {
|
||||
while open_elements.len() > iterator.depth {
|
||||
html.push_str(~"</" + open_elements.pop().unwrap().as_slice() + ">");
|
||||
html.push_str("</".to_owned() + open_elements.pop().unwrap().as_slice() + ">");
|
||||
}
|
||||
html.push_str(
|
||||
match node.type_id() {
|
||||
|
@ -60,13 +60,13 @@ pub fn serialize(iterator: &mut NodeIterator) -> ~str {
|
|||
);
|
||||
}
|
||||
while open_elements.len() > 0 {
|
||||
html.push_str(~"</" + open_elements.pop().unwrap().as_slice() + ">");
|
||||
html.push_str("</".to_owned() + open_elements.pop().unwrap().as_slice() + ">");
|
||||
}
|
||||
html
|
||||
}
|
||||
|
||||
fn serialize_comment(comment: &JSRef<Comment>) -> ~str {
|
||||
~"<!--" + comment.deref().characterdata.data + "-->"
|
||||
"<!--".to_owned() + comment.deref().characterdata.data + "-->"
|
||||
}
|
||||
|
||||
fn serialize_text(text: &JSRef<Text>) -> ~str {
|
||||
|
@ -88,15 +88,15 @@ fn serialize_text(text: &JSRef<Text>) -> ~str {
|
|||
}
|
||||
|
||||
fn serialize_processing_instruction(processing_instruction: &JSRef<ProcessingInstruction>) -> ~str {
|
||||
~"<?" + processing_instruction.deref().target + " " + processing_instruction.deref().characterdata.data + "?>"
|
||||
"<?".to_owned() + processing_instruction.deref().target + " " + processing_instruction.deref().characterdata.data + "?>"
|
||||
}
|
||||
|
||||
fn serialize_doctype(doctype: &JSRef<DocumentType>) -> ~str {
|
||||
~"<!DOCTYPE" + doctype.deref().name + ">"
|
||||
"<!DOCTYPE".to_owned() + doctype.deref().name + ">"
|
||||
}
|
||||
|
||||
fn serialize_elem(elem: &JSRef<Element>, open_elements: &mut Vec<~str>) -> ~str {
|
||||
let mut rv = ~"<" + elem.deref().local_name;
|
||||
let mut rv = "<".to_owned() + elem.deref().local_name;
|
||||
for attr in elem.deref().attrs.iter() {
|
||||
let attr = attr.root();
|
||||
rv.push_str(serialize_attr(&*attr));
|
||||
|
@ -125,18 +125,18 @@ fn serialize_elem(elem: &JSRef<Element>, open_elements: &mut Vec<~str>) -> ~str
|
|||
|
||||
fn serialize_attr(attr: &JSRef<Attr>) -> ~str {
|
||||
let attr_name = if attr.deref().namespace == namespace::XML {
|
||||
~"xml:" + attr.deref().local_name.clone()
|
||||
"xml:".to_owned() + attr.deref().local_name.clone()
|
||||
} else if attr.deref().namespace == namespace::XMLNS &&
|
||||
attr.deref().local_name.as_slice() == "xmlns" {
|
||||
~"xmlns"
|
||||
"xmlns".to_owned()
|
||||
} else if attr.deref().namespace == namespace::XMLNS {
|
||||
~"xmlns:" + attr.deref().local_name.clone()
|
||||
"xmlns:".to_owned() + attr.deref().local_name.clone()
|
||||
} else if attr.deref().namespace == namespace::XLink {
|
||||
~"xlink:" + attr.deref().local_name.clone()
|
||||
"xlink:".to_owned() + attr.deref().local_name.clone()
|
||||
} else {
|
||||
attr.deref().name.clone()
|
||||
};
|
||||
~" " + attr_name + "=\"" + escape(attr.deref().value, true) + "\""
|
||||
" ".to_owned() + attr_name + "=\"" + escape(attr.deref().value, true) + "\""
|
||||
}
|
||||
|
||||
fn escape(string: &str, attr_mode: bool) -> ~str {
|
||||
|
|
|
@ -49,7 +49,7 @@ pub trait NavigatorMethods {
|
|||
|
||||
impl<'a> NavigatorMethods for JSRef<'a, Navigator> {
|
||||
fn DoNotTrack(&self) -> DOMString {
|
||||
~"unspecified"
|
||||
"unspecified".to_owned()
|
||||
}
|
||||
|
||||
fn Vendor(&self) -> DOMString {
|
||||
|
@ -61,7 +61,7 @@ impl<'a> NavigatorMethods for JSRef<'a, Navigator> {
|
|||
}
|
||||
|
||||
fn Product(&self) -> DOMString {
|
||||
~"Gecko"
|
||||
"Gecko".to_owned()
|
||||
}
|
||||
|
||||
fn ProductSub(&self) -> DOMString {
|
||||
|
@ -85,11 +85,11 @@ impl<'a> NavigatorMethods for JSRef<'a, Navigator> {
|
|||
}
|
||||
|
||||
fn AppName(&self) -> DOMString {
|
||||
~"Netscape" // Like Gecko/Webkit
|
||||
"Netscape".to_owned() // Like Gecko/Webkit
|
||||
}
|
||||
|
||||
fn GetAppCodeName(&self) -> Fallible<DOMString> {
|
||||
Ok(~"Mozilla") // Like Gecko/Webkit
|
||||
Ok("Mozilla".to_owned()) // Like Gecko/Webkit
|
||||
}
|
||||
|
||||
fn GetAppVersion(&self) -> Fallible<DOMString> {
|
||||
|
|
|
@ -1387,19 +1387,19 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
|||
let elem: &JSRef<Element> = ElementCast::to_ref(self).unwrap();
|
||||
elem.TagName()
|
||||
}
|
||||
TextNodeTypeId => ~"#text",
|
||||
TextNodeTypeId => "#text".to_owned(),
|
||||
ProcessingInstructionNodeTypeId => {
|
||||
let processing_instruction: &JSRef<ProcessingInstruction> =
|
||||
ProcessingInstructionCast::to_ref(self).unwrap();
|
||||
processing_instruction.Target()
|
||||
}
|
||||
CommentNodeTypeId => ~"#comment",
|
||||
CommentNodeTypeId => "#comment".to_owned(),
|
||||
DoctypeNodeTypeId => {
|
||||
let doctype: &JSRef<DocumentType> = DocumentTypeCast::to_ref(self).unwrap();
|
||||
doctype.deref().name.clone()
|
||||
},
|
||||
DocumentFragmentNodeTypeId => ~"#document-fragment",
|
||||
DocumentNodeTypeId => ~"#document"
|
||||
DocumentFragmentNodeTypeId => "#document-fragment".to_owned(),
|
||||
DocumentNodeTypeId => "#document".to_owned()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue