mirror of
https://github.com/servo/servo.git
synced 2025-06-24 17:14:33 +01:00
Make use of From<String> for Atom
This commit is contained in:
parent
50af73d1a2
commit
cc030df36e
7 changed files with 14 additions and 14 deletions
|
@ -230,7 +230,7 @@ impl FontCache {
|
|||
let family_name = LowercaseString::new(family.name());
|
||||
|
||||
let templates = &mut self.web_families.get_mut(&family_name).unwrap();
|
||||
templates.add_template(Atom::from(&*url.to_string()), Some(bytes));
|
||||
templates.add_template(Atom::from(url.to_string()), Some(bytes));
|
||||
drop(result.send(()));
|
||||
}
|
||||
Command::Exit(result) => {
|
||||
|
|
|
@ -536,7 +536,7 @@ impl Document {
|
|||
// Step 3 & 4
|
||||
String::from_utf8(percent_decode(fragid.as_bytes())).ok()
|
||||
// Step 5
|
||||
.and_then(|decoded_fragid| self.get_element_by_id(&Atom::from(&*decoded_fragid)))
|
||||
.and_then(|decoded_fragid| self.get_element_by_id(&Atom::from(decoded_fragid)))
|
||||
// Step 6
|
||||
.or_else(|| self.get_anchor_by_name(fragid))
|
||||
// Step 7
|
||||
|
|
|
@ -925,7 +925,7 @@ impl Element {
|
|||
None => qname.local.clone(),
|
||||
Some(ref prefix) => {
|
||||
let name = format!("{}:{}", &**prefix, &*qname.local);
|
||||
Atom::from(&*name)
|
||||
Atom::from(name)
|
||||
},
|
||||
};
|
||||
let value = self.parse_attribute(&qname.ns, &qname.local, value);
|
||||
|
|
|
@ -59,7 +59,7 @@ impl FormDataMethods for FormData {
|
|||
// https://xhr.spec.whatwg.org/#dom-formdata-append
|
||||
fn Append(&self, name: USVString, value: USVString) {
|
||||
let mut data = self.data.borrow_mut();
|
||||
match data.entry(Atom::from(&*name.0)) {
|
||||
match data.entry(Atom::from(name.0)) {
|
||||
Occupied(entry) => entry.into_mut().push(FormDatum::StringData(value.0)),
|
||||
Vacant (entry) => { entry.insert(vec!(FormDatum::StringData(value.0))); }
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ impl FormDataMethods for FormData {
|
|||
fn Append_(&self, name: USVString, value: &Blob, filename: Option<USVString>) {
|
||||
let blob = FormDatum::BlobData(JS::from_rooted(&self.get_file_or_blob(value, filename)));
|
||||
let mut data = self.data.borrow_mut();
|
||||
match data.entry(Atom::from(&*name.0)) {
|
||||
match data.entry(Atom::from(name.0)) {
|
||||
Occupied(entry) => entry.into_mut().push(blob),
|
||||
Vacant(entry) => {
|
||||
entry.insert(vec!(blob));
|
||||
|
@ -80,13 +80,13 @@ impl FormDataMethods for FormData {
|
|||
|
||||
// https://xhr.spec.whatwg.org/#dom-formdata-delete
|
||||
fn Delete(&self, name: USVString) {
|
||||
self.data.borrow_mut().remove(&Atom::from(&*name.0));
|
||||
self.data.borrow_mut().remove(&Atom::from(name.0));
|
||||
}
|
||||
|
||||
// https://xhr.spec.whatwg.org/#dom-formdata-get
|
||||
fn Get(&self, name: USVString) -> Option<BlobOrUSVString> {
|
||||
self.data.borrow()
|
||||
.get(&Atom::from(&*name.0))
|
||||
.get(&Atom::from(name.0))
|
||||
.map(|entry| match entry[0] {
|
||||
FormDatum::StringData(ref s) => BlobOrUSVString::USVString(USVString(s.clone())),
|
||||
FormDatum::BlobData(ref b) => BlobOrUSVString::Blob(Root::from_ref(&*b)),
|
||||
|
@ -96,7 +96,7 @@ impl FormDataMethods for FormData {
|
|||
// https://xhr.spec.whatwg.org/#dom-formdata-getall
|
||||
fn GetAll(&self, name: USVString) -> Vec<BlobOrUSVString> {
|
||||
self.data.borrow()
|
||||
.get(&Atom::from(&*name.0))
|
||||
.get(&Atom::from(name.0))
|
||||
.map_or(vec![], |data|
|
||||
data.iter().map(|item| match *item {
|
||||
FormDatum::StringData(ref s) => BlobOrUSVString::USVString(USVString(s.clone())),
|
||||
|
@ -107,7 +107,7 @@ impl FormDataMethods for FormData {
|
|||
|
||||
// https://xhr.spec.whatwg.org/#dom-formdata-has
|
||||
fn Has(&self, name: USVString) -> bool {
|
||||
self.data.borrow().contains_key(&Atom::from(&*name.0))
|
||||
self.data.borrow().contains_key(&Atom::from(name.0))
|
||||
}
|
||||
|
||||
#[allow(unrooted_must_root)]
|
||||
|
@ -117,7 +117,7 @@ impl FormDataMethods for FormData {
|
|||
BlobOrUSVString::USVString(s) => FormDatum::StringData(s.0),
|
||||
BlobOrUSVString::Blob(b) => FormDatum::BlobData(JS::from_rooted(&b))
|
||||
};
|
||||
self.data.borrow_mut().insert(Atom::from(&*name.0), vec!(val));
|
||||
self.data.borrow_mut().insert(Atom::from(name.0), vec!(val));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1793,7 +1793,7 @@ pub mod longhands {
|
|||
value.push_str(" ");
|
||||
value.push_str(&ident);
|
||||
}
|
||||
Ok(FontFamily::FamilyName(Atom::from(&*value)))
|
||||
Ok(FontFamily::FamilyName(Atom::from(value)))
|
||||
}
|
||||
</%self:longhand>
|
||||
|
||||
|
|
|
@ -396,7 +396,7 @@ impl<'a, Impl: SelectorImpl> AtRuleParser for TopLevelRuleParser<'a, Impl> {
|
|||
self.state.set(State::Namespaces);
|
||||
|
||||
let prefix = input.try(|input| input.expect_ident()).ok().map(|p| p.into_owned());
|
||||
let url = Namespace(Atom::from(&*try!(input.expect_url_or_string())));
|
||||
let url = Namespace(Atom::from(try!(input.expect_url_or_string())));
|
||||
return Ok(AtRuleType::WithoutBlock(CSSRule::Namespace(prefix, url)))
|
||||
} else {
|
||||
return Err(()) // "@namespace must be before any rule but @charset and @import"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue