mirror of
https://github.com/servo/servo.git
synced 2025-06-25 09:34:32 +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 family_name = LowercaseString::new(family.name());
|
||||||
|
|
||||||
let templates = &mut self.web_families.get_mut(&family_name).unwrap();
|
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(()));
|
drop(result.send(()));
|
||||||
}
|
}
|
||||||
Command::Exit(result) => {
|
Command::Exit(result) => {
|
||||||
|
|
|
@ -536,7 +536,7 @@ impl Document {
|
||||||
// Step 3 & 4
|
// Step 3 & 4
|
||||||
String::from_utf8(percent_decode(fragid.as_bytes())).ok()
|
String::from_utf8(percent_decode(fragid.as_bytes())).ok()
|
||||||
// Step 5
|
// 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
|
// Step 6
|
||||||
.or_else(|| self.get_anchor_by_name(fragid))
|
.or_else(|| self.get_anchor_by_name(fragid))
|
||||||
// Step 7
|
// Step 7
|
||||||
|
|
|
@ -925,7 +925,7 @@ impl Element {
|
||||||
None => qname.local.clone(),
|
None => qname.local.clone(),
|
||||||
Some(ref prefix) => {
|
Some(ref prefix) => {
|
||||||
let name = format!("{}:{}", &**prefix, &*qname.local);
|
let name = format!("{}:{}", &**prefix, &*qname.local);
|
||||||
Atom::from(&*name)
|
Atom::from(name)
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
let value = self.parse_attribute(&qname.ns, &qname.local, value);
|
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
|
// https://xhr.spec.whatwg.org/#dom-formdata-append
|
||||||
fn Append(&self, name: USVString, value: USVString) {
|
fn Append(&self, name: USVString, value: USVString) {
|
||||||
let mut data = self.data.borrow_mut();
|
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)),
|
Occupied(entry) => entry.into_mut().push(FormDatum::StringData(value.0)),
|
||||||
Vacant (entry) => { entry.insert(vec!(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>) {
|
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 blob = FormDatum::BlobData(JS::from_rooted(&self.get_file_or_blob(value, filename)));
|
||||||
let mut data = self.data.borrow_mut();
|
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),
|
Occupied(entry) => entry.into_mut().push(blob),
|
||||||
Vacant(entry) => {
|
Vacant(entry) => {
|
||||||
entry.insert(vec!(blob));
|
entry.insert(vec!(blob));
|
||||||
|
@ -80,13 +80,13 @@ impl FormDataMethods for FormData {
|
||||||
|
|
||||||
// https://xhr.spec.whatwg.org/#dom-formdata-delete
|
// https://xhr.spec.whatwg.org/#dom-formdata-delete
|
||||||
fn Delete(&self, name: USVString) {
|
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
|
// https://xhr.spec.whatwg.org/#dom-formdata-get
|
||||||
fn Get(&self, name: USVString) -> Option<BlobOrUSVString> {
|
fn Get(&self, name: USVString) -> Option<BlobOrUSVString> {
|
||||||
self.data.borrow()
|
self.data.borrow()
|
||||||
.get(&Atom::from(&*name.0))
|
.get(&Atom::from(name.0))
|
||||||
.map(|entry| match entry[0] {
|
.map(|entry| match entry[0] {
|
||||||
FormDatum::StringData(ref s) => BlobOrUSVString::USVString(USVString(s.clone())),
|
FormDatum::StringData(ref s) => BlobOrUSVString::USVString(USVString(s.clone())),
|
||||||
FormDatum::BlobData(ref b) => BlobOrUSVString::Blob(Root::from_ref(&*b)),
|
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
|
// https://xhr.spec.whatwg.org/#dom-formdata-getall
|
||||||
fn GetAll(&self, name: USVString) -> Vec<BlobOrUSVString> {
|
fn GetAll(&self, name: USVString) -> Vec<BlobOrUSVString> {
|
||||||
self.data.borrow()
|
self.data.borrow()
|
||||||
.get(&Atom::from(&*name.0))
|
.get(&Atom::from(name.0))
|
||||||
.map_or(vec![], |data|
|
.map_or(vec![], |data|
|
||||||
data.iter().map(|item| match *item {
|
data.iter().map(|item| match *item {
|
||||||
FormDatum::StringData(ref s) => BlobOrUSVString::USVString(USVString(s.clone())),
|
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
|
// https://xhr.spec.whatwg.org/#dom-formdata-has
|
||||||
fn Has(&self, name: USVString) -> bool {
|
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)]
|
#[allow(unrooted_must_root)]
|
||||||
|
@ -117,7 +117,7 @@ impl FormDataMethods for FormData {
|
||||||
BlobOrUSVString::USVString(s) => FormDatum::StringData(s.0),
|
BlobOrUSVString::USVString(s) => FormDatum::StringData(s.0),
|
||||||
BlobOrUSVString::Blob(b) => FormDatum::BlobData(JS::from_rooted(&b))
|
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(" ");
|
||||||
value.push_str(&ident);
|
value.push_str(&ident);
|
||||||
}
|
}
|
||||||
Ok(FontFamily::FamilyName(Atom::from(&*value)))
|
Ok(FontFamily::FamilyName(Atom::from(value)))
|
||||||
}
|
}
|
||||||
</%self:longhand>
|
</%self:longhand>
|
||||||
|
|
||||||
|
|
|
@ -396,7 +396,7 @@ impl<'a, Impl: SelectorImpl> AtRuleParser for TopLevelRuleParser<'a, Impl> {
|
||||||
self.state.set(State::Namespaces);
|
self.state.set(State::Namespaces);
|
||||||
|
|
||||||
let prefix = input.try(|input| input.expect_ident()).ok().map(|p| p.into_owned());
|
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)))
|
return Ok(AtRuleType::WithoutBlock(CSSRule::Namespace(prefix, url)))
|
||||||
} else {
|
} else {
|
||||||
return Err(()) // "@namespace must be before any rule but @charset and @import"
|
return Err(()) // "@namespace must be before any rule but @charset and @import"
|
||||||
|
|
|
@ -406,7 +406,7 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut length: u32 = 0;
|
let mut length: u32 = 0;
|
||||||
let p = Gecko_LocalName(self.element, &mut length);
|
let p = Gecko_LocalName(self.element, &mut length);
|
||||||
Atom::from(&*String::from_utf16(slice::from_raw_parts(p, length as usize)).unwrap())
|
Atom::from(String::from_utf16(slice::from_raw_parts(p, length as usize)).unwrap())
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
@ -417,7 +417,7 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut length: u32 = 0;
|
let mut length: u32 = 0;
|
||||||
let p = Gecko_Namespace(self.element, &mut length);
|
let p = Gecko_Namespace(self.element, &mut length);
|
||||||
Namespace(Atom::from(&*String::from_utf16(slice::from_raw_parts(p, length as usize)).unwrap()))
|
Namespace(Atom::from(String::from_utf16(slice::from_raw_parts(p, length as usize)).unwrap()))
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue