mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
Remove some more unnecessary let bindings
This commit is contained in:
parent
2947d78e4e
commit
bc1eb97671
11 changed files with 29 additions and 84 deletions
|
@ -212,11 +212,9 @@ pub trait DedicatedWorkerGlobalScopeHelpers {
|
|||
|
||||
impl<'a> DedicatedWorkerGlobalScopeHelpers for &'a DedicatedWorkerGlobalScope {
|
||||
fn script_chan(self) -> Box<ScriptChan+Send> {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let worker = self.worker.borrow();
|
||||
box SendableWorkerScriptChan {
|
||||
sender: self.own_sender.clone(),
|
||||
worker: worker.as_ref().unwrap().clone(),
|
||||
worker: self.worker.borrow().as_ref().unwrap().clone(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -468,10 +468,7 @@ impl<'a> DocumentHelpers<'a> for &'a Document {
|
|||
let check_anchor = |&node: &&HTMLAnchorElement| {
|
||||
let elem = ElementCast::from_ref(node);
|
||||
elem.get_attribute(&ns!(""), &atom!("name")).map_or(false, |attr| {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let attr = attr.r();
|
||||
let value = attr.value();
|
||||
&**value == &*fragid
|
||||
&**attr.r().value() == &*fragid
|
||||
})
|
||||
};
|
||||
let doc_node = NodeCast::from_ref(self);
|
||||
|
@ -1562,10 +1559,7 @@ impl<'a> DocumentMethods for &'a Document {
|
|||
return false;
|
||||
}
|
||||
element.get_attribute(&ns!(""), &atom!("name")).map_or(false, |attr| {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let attr = attr.r();
|
||||
let value = attr.value();
|
||||
&**value == &*name
|
||||
&**attr.r().value() == &*name
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
@ -853,21 +853,15 @@ impl<'a> AttributeHandlers for &'a Element {
|
|||
// https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name
|
||||
fn get_attribute_by_name(self, name: DOMString) -> Option<Root<Attr>> {
|
||||
let name = &self.parsed_name(name);
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let attrs = self.attrs.borrow();
|
||||
attrs.iter().map(|attr| attr.root())
|
||||
self.attrs.borrow().iter().map(|attr| attr.root())
|
||||
.find(|a| a.r().name() == name)
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name
|
||||
fn get_attributes(self, local_name: &Atom, attributes: &mut RootedVec<JS<Attr>>) {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let attrs = self.attrs.borrow();
|
||||
for ref attr in attrs.iter() {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
for ref attr in self.attrs.borrow().iter() {
|
||||
let attr = attr.root();
|
||||
let attr_local_name = attr.r().local_name();
|
||||
if attr_local_name == local_name {
|
||||
if attr.r().local_name() == local_name {
|
||||
attributes.push(JS::from_rooted(&attr));
|
||||
}
|
||||
}
|
||||
|
@ -1010,10 +1004,7 @@ impl<'a> AttributeHandlers for &'a Element {
|
|||
Quirks => lhs.eq_ignore_ascii_case(&rhs)
|
||||
};
|
||||
self.get_attribute(&ns!(""), &atom!("class")).map(|attr| {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let attr = attr.r();
|
||||
let value = attr.value();
|
||||
value.tokens().map(|tokens| {
|
||||
attr.r().value().tokens().map(|tokens| {
|
||||
tokens.iter().any(|atom| is_equal(name, atom))
|
||||
}).unwrap_or(false)
|
||||
}).unwrap_or(false)
|
||||
|
@ -1027,12 +1018,8 @@ impl<'a> AttributeHandlers for &'a Element {
|
|||
|
||||
fn has_attribute(self, local_name: &Atom) -> bool {
|
||||
assert!(local_name.bytes().all(|b| b.to_ascii_lowercase() == b));
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let attrs = self.attrs.borrow();
|
||||
attrs.iter().map(|attr| attr.root()).any(|attr| {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let attr = attr.r();
|
||||
attr.local_name() == local_name && attr.namespace() == &ns!("")
|
||||
self.attrs.borrow().iter().map(|attr| attr.root()).any(|attr| {
|
||||
attr.r().local_name() == local_name && attr.r().namespace() == &ns!("")
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -1077,10 +1064,9 @@ impl<'a> AttributeHandlers for &'a Element {
|
|||
|
||||
fn get_tokenlist_attribute(self, local_name: &Atom) -> Vec<Atom> {
|
||||
self.get_attribute(&ns!(""), local_name).map(|attr| {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let attr = attr.r();
|
||||
let value = attr.value();
|
||||
value.tokens()
|
||||
attr.r()
|
||||
.value()
|
||||
.tokens()
|
||||
.expect("Expected a TokenListAttrValue")
|
||||
.to_vec()
|
||||
}).unwrap_or(vec!())
|
||||
|
@ -1663,10 +1649,7 @@ impl<'a> ::selectors::Element for &'a Element {
|
|||
}
|
||||
fn get_id(&self) -> Option<Atom> {
|
||||
self.get_attribute(&ns!(""), &atom!("id")).map(|attr| {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let attr = attr.r();
|
||||
let value = attr.value();
|
||||
match *value {
|
||||
match *attr.r().value() {
|
||||
AttrValue::Atom(ref val) => val.clone(),
|
||||
_ => panic!("`id` attribute should be AttrValue::Atom"),
|
||||
}
|
||||
|
@ -1735,10 +1718,7 @@ impl<'a> ::selectors::Element for &'a Element {
|
|||
NamespaceConstraint::Specific(ref ns) => {
|
||||
self.get_attribute(ns, local_name)
|
||||
.map_or(false, |attr| {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let attr = attr.r();
|
||||
let value = attr.value();
|
||||
test(&value)
|
||||
test(&attr.r().value())
|
||||
})
|
||||
},
|
||||
NamespaceConstraint::Any => {
|
||||
|
|
|
@ -65,10 +65,8 @@ impl ErrorEvent {
|
|||
colno: u32,
|
||||
error: HandleValue) -> Root<ErrorEvent> {
|
||||
let ev = ErrorEvent::new_uninitialized(global);
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
{
|
||||
let ev = ev.r();
|
||||
let event = EventCast::from_ref(ev);
|
||||
let event = EventCast::from_ref(ev.r());
|
||||
event.InitEvent(type_, bubbles == EventBubbles::Bubbles,
|
||||
cancelable == EventCancelable::Cancelable);
|
||||
*ev.message.borrow_mut() = message;
|
||||
|
@ -125,15 +123,11 @@ impl<'a> ErrorEventMethods for &'a ErrorEvent {
|
|||
}
|
||||
|
||||
fn Message(self) -> DOMString {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let message = self.message.borrow();
|
||||
message.clone()
|
||||
self.message.borrow().clone()
|
||||
}
|
||||
|
||||
fn Filename(self) -> DOMString {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let filename = self.filename.borrow();
|
||||
filename.clone()
|
||||
self.filename.borrow().clone()
|
||||
}
|
||||
|
||||
fn Error(self, _cx: *mut JSContext) -> JSVal {
|
||||
|
|
|
@ -180,9 +180,7 @@ impl<'a> EventMethods for &'a Event {
|
|||
|
||||
// https://dom.spec.whatwg.org/#dom-event-type
|
||||
fn Type(self) -> DOMString {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let type_ = self.type_.borrow();
|
||||
type_.clone()
|
||||
self.type_.borrow().clone()
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-event-target
|
||||
|
|
|
@ -282,9 +282,7 @@ impl<'a> EventTargetHelpers for &'a EventTarget {
|
|||
}
|
||||
|
||||
fn has_handlers(self) -> bool {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let handlers = self.handlers.borrow();
|
||||
!handlers.is_empty()
|
||||
!self.handlers.borrow().is_empty()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -250,10 +250,7 @@ impl<'a> HTMLElementCustomAttributeHelpers for &'a HTMLElement {
|
|||
let element = ElementCast::from_ref(self);
|
||||
let local_name = Atom::from_slice(&to_snake_case(local_name));
|
||||
element.get_attribute(&ns!(""), &local_name).map(|attr| {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let attr = attr.r();
|
||||
let value = attr.value();
|
||||
(**value).to_owned()
|
||||
(**attr.r().value()).to_owned()
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -189,9 +189,7 @@ impl<'a> HTMLTextAreaElementMethods for &'a HTMLTextAreaElement {
|
|||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-textarea-value
|
||||
fn Value(self) -> DOMString {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let textinput = self.textinput.borrow();
|
||||
textinput.get_content()
|
||||
self.textinput.borrow().get_content()
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-textarea-value
|
||||
|
|
|
@ -784,15 +784,11 @@ impl<'a> KeyboardEventMethods for &'a KeyboardEvent {
|
|||
}
|
||||
|
||||
fn Key(self) -> DOMString {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let key_string = self.key_string.borrow();
|
||||
key_string.clone()
|
||||
self.key_string.borrow().clone()
|
||||
}
|
||||
|
||||
fn Code(self) -> DOMString {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let code = self.code.borrow();
|
||||
code.clone()
|
||||
self.code.borrow().clone()
|
||||
}
|
||||
|
||||
fn Location(self) -> u32 {
|
||||
|
|
|
@ -45,15 +45,11 @@ impl URLSearchParams {
|
|||
match init {
|
||||
Some(eString(init)) => {
|
||||
// Step 2.
|
||||
let query = query.r();
|
||||
*query.list.borrow_mut() = parse(init.as_bytes());
|
||||
*query.r().list.borrow_mut() = parse(init.as_bytes());
|
||||
},
|
||||
Some(eURLSearchParams(init)) => {
|
||||
// Step 3.
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let query = query.r();
|
||||
let init = init.r();
|
||||
*query.list.borrow_mut() = init.list.borrow().clone();
|
||||
*query.r().list.borrow_mut() = init.r().list.borrow().clone();
|
||||
},
|
||||
None => {}
|
||||
}
|
||||
|
|
|
@ -623,9 +623,7 @@ impl<'a> XMLHttpRequestMethods for &'a XMLHttpRequest {
|
|||
|
||||
// https://xhr.spec.whatwg.org/#the-statustext-attribute
|
||||
fn StatusText(self) -> ByteString {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let status_text = self.status_text.borrow();
|
||||
status_text.clone()
|
||||
self.status_text.borrow().clone()
|
||||
}
|
||||
|
||||
// https://xhr.spec.whatwg.org/#the-getresponseheader()-method
|
||||
|
@ -1031,11 +1029,9 @@ impl<'a> PrivateXMLHttpRequestHelpers for &'a XMLHttpRequest {
|
|||
}
|
||||
|
||||
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let response = self.response.borrow();
|
||||
// According to Simon, decode() should never return an error, so unwrap()ing
|
||||
// the result should be fine. XXXManishearth have a closer look at this later
|
||||
encoding.decode(&response, DecoderTrap::Replace).unwrap().to_owned()
|
||||
encoding.decode(&self.response.borrow(), DecoderTrap::Replace).unwrap().to_owned()
|
||||
}
|
||||
fn filter_response_headers(self) -> Headers {
|
||||
// https://fetch.spec.whatwg.org/#concept-response-header-list
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue