mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
Remove some redundant let bindings
This commit is contained in:
parent
2e1c9785dc
commit
861ddedaef
8 changed files with 24 additions and 64 deletions
|
@ -50,9 +50,7 @@ impl CharacterData {
|
|||
impl<'a> CharacterDataMethods for &'a CharacterData {
|
||||
// https://dom.spec.whatwg.org/#dom-characterdata-data
|
||||
fn Data(self) -> DOMString {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let data = self.data.borrow();
|
||||
data.clone()
|
||||
self.data.borrow().clone()
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-characterdata-data
|
||||
|
@ -62,9 +60,7 @@ impl<'a> CharacterDataMethods for &'a CharacterData {
|
|||
|
||||
// https://dom.spec.whatwg.org/#dom-characterdata-length
|
||||
fn Length(self) -> u32 {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let data = self.data.borrow();
|
||||
data.chars().count() as u32
|
||||
self.data.borrow().chars().count() as u32
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-characterdata-substringdataoffset-count
|
||||
|
|
|
@ -1185,16 +1185,12 @@ impl<'a> DocumentMethods for &'a Document {
|
|||
|
||||
// https://dom.spec.whatwg.org/#dom-document-characterset
|
||||
fn CharacterSet(self) -> DOMString {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let encoding_name = self.encoding_name.borrow();
|
||||
encoding_name.clone()
|
||||
self.encoding_name.borrow().clone()
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-document-inputencoding
|
||||
fn InputEncoding(self) -> DOMString {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let encoding_name = self.encoding_name.borrow();
|
||||
encoding_name.clone()
|
||||
self.encoding_name.borrow().clone()
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-document-content_type
|
||||
|
@ -1239,9 +1235,7 @@ impl<'a> DocumentMethods for &'a Document {
|
|||
// https://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid
|
||||
fn GetElementById(self, id: DOMString) -> Option<Root<Element>> {
|
||||
let id = Atom::from_slice(&id);
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let idmap = self.idmap.borrow();
|
||||
idmap.get(&id).map(|ref elements| (*elements)[0].root())
|
||||
self.idmap.borrow().get(&id).map(|ref elements| (*elements)[0].root())
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-document-createelement
|
||||
|
|
|
@ -67,20 +67,16 @@ impl<'a> DOMTokenListMethods for &'a DOMTokenList {
|
|||
// https://dom.spec.whatwg.org/#dom-domtokenlist-length
|
||||
fn Length(self) -> u32 {
|
||||
self.attribute().map(|attr| {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let attr = attr.r();
|
||||
let value = attr.value();
|
||||
value.tokens().map(|tokens| tokens.len()).unwrap_or(0)
|
||||
attr.value().tokens().map(|tokens| tokens.len()).unwrap_or(0)
|
||||
}).unwrap_or(0) as u32
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-domtokenlist-item
|
||||
fn Item(self, index: u32) -> Option<DOMString> {
|
||||
self.attribute().and_then(|attr| {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let attr = attr.r();
|
||||
let value = attr.value();
|
||||
value.tokens().and_then(|tokens| {
|
||||
attr.value().tokens().and_then(|tokens| {
|
||||
tokens.get(index as usize).map(|token| (**token).to_owned())
|
||||
})
|
||||
})
|
||||
|
@ -96,10 +92,9 @@ impl<'a> DOMTokenListMethods for &'a DOMTokenList {
|
|||
fn Contains(self, token: DOMString) -> Fallible<bool> {
|
||||
self.check_token_exceptions(&token).map(|token| {
|
||||
self.attribute().map(|attr| {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let attr = attr.r();
|
||||
let value = attr.value();
|
||||
value.tokens()
|
||||
attr.value()
|
||||
.tokens()
|
||||
.expect("Should have parsed this attribute")
|
||||
.iter()
|
||||
.any(|atom| *atom == token)
|
||||
|
|
|
@ -98,9 +98,7 @@ impl<'a> FormDataMethods for &'a FormData {
|
|||
}
|
||||
|
||||
fn Has(self, name: DOMString) -> bool {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let data = self.data.borrow();
|
||||
data.contains_key(&name)
|
||||
self.data.borrow().contains_key(&name)
|
||||
}
|
||||
#[allow(unrooted_must_root)]
|
||||
fn Set(self, name: DOMString, value: &Blob, filename: Option<DOMString>) {
|
||||
|
|
|
@ -266,9 +266,7 @@ impl<'a> HTMLInputElementMethods for &'a HTMLInputElement {
|
|||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-input-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-input-value
|
||||
|
|
|
@ -983,13 +983,11 @@ impl<'a> NodeHelpers for &'a Node {
|
|||
}
|
||||
|
||||
fn get_unique_id(self) -> String {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
if self.unique_id.borrow().is_empty() {
|
||||
let mut unique_id = self.unique_id.borrow_mut();
|
||||
*unique_id = uuid::Uuid::new_v4().to_simple_string();
|
||||
}
|
||||
let id = self.unique_id.borrow();
|
||||
id.clone()
|
||||
self.unique_id.borrow().clone()
|
||||
}
|
||||
|
||||
fn summarize(self) -> NodeInfo {
|
||||
|
@ -2318,10 +2316,7 @@ impl<'a> NodeMethods for &'a Node {
|
|||
fn is_equal_characterdata(node: &Node, other: &Node) -> bool {
|
||||
let characterdata: &CharacterData = CharacterDataCast::to_ref(node).unwrap();
|
||||
let other_characterdata: &CharacterData = CharacterDataCast::to_ref(other).unwrap();
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let own_data = characterdata.data();
|
||||
let other_data = other_characterdata.data();
|
||||
*own_data == *other_data
|
||||
*characterdata.data() == *other_characterdata.data()
|
||||
}
|
||||
fn is_equal_element_attrs(node: &Node, other: &Node) -> bool {
|
||||
let element: &Element = ElementCast::to_ref(node).unwrap();
|
||||
|
|
|
@ -89,27 +89,19 @@ impl StorageEvent {
|
|||
|
||||
impl<'a> StorageEventMethods for &'a StorageEvent {
|
||||
fn GetKey(self) -> Option<DOMString> {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let key = self.key.borrow();
|
||||
key.clone()
|
||||
self.key.borrow().clone()
|
||||
}
|
||||
|
||||
fn GetOldValue(self) -> Option<DOMString> {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let oldValue = self.oldValue.borrow();
|
||||
oldValue.clone()
|
||||
self.oldValue.borrow().clone()
|
||||
}
|
||||
|
||||
fn GetNewValue(self) -> Option<DOMString> {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let newValue = self.newValue.borrow();
|
||||
newValue.clone()
|
||||
self.newValue.borrow().clone()
|
||||
}
|
||||
|
||||
fn Url(self) -> DOMString {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let url = self.url.borrow();
|
||||
url.clone()
|
||||
self.url.borrow().clone()
|
||||
}
|
||||
|
||||
fn GetStorageArea(self) -> Option<Root<Storage>> {
|
||||
|
|
|
@ -336,9 +336,7 @@ impl<'a> WindowMethods for &'a Window {
|
|||
}
|
||||
|
||||
fn Document(self) -> Root<Document> {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let context = self.browser_context();
|
||||
context.as_ref().unwrap().active_document()
|
||||
self.browser_context().as_ref().unwrap().active_document()
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/#dom-location
|
||||
|
@ -362,9 +360,7 @@ impl<'a> WindowMethods for &'a Window {
|
|||
|
||||
// https://html.spec.whatwg.org/#dom-frameelement
|
||||
fn GetFrameElement(self) -> Option<Root<Element>> {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let context = self.browser_context();
|
||||
context.as_ref().unwrap().frame_element()
|
||||
self.browser_context().as_ref().unwrap().frame_element()
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/#dom-navigator
|
||||
|
@ -792,9 +788,7 @@ impl<'a> WindowHelpers for &'a Window {
|
|||
}
|
||||
|
||||
fn steal_fragment_name(self) -> Option<String> {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let mut name = self.fragment_name.borrow_mut();
|
||||
name.take()
|
||||
self.fragment_name.borrow_mut().take()
|
||||
}
|
||||
|
||||
fn set_window_size(self, size: WindowSizeData) {
|
||||
|
@ -838,9 +832,7 @@ impl<'a> WindowHelpers for &'a Window {
|
|||
}
|
||||
|
||||
fn layout_is_idle(self) -> bool {
|
||||
// FIXME(https://github.com/rust-lang/rust/issues/23338)
|
||||
let port = self.layout_join_port.borrow();
|
||||
port.is_none()
|
||||
self.layout_join_port.borrow().is_none()
|
||||
}
|
||||
|
||||
fn get_pending_reflow_count(self) -> u32 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue