mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
clippy: Fix collapsible_else_if warnings (#31853)
This commit is contained in:
parent
d814d05539
commit
f8a2eaea47
8 changed files with 37 additions and 52 deletions
|
@ -579,16 +579,14 @@ impl EventTarget {
|
||||||
Some(CommonEventHandler::ErrorEventHandler(unsafe {
|
Some(CommonEventHandler::ErrorEventHandler(unsafe {
|
||||||
OnErrorEventHandlerNonNull::new(cx, funobj)
|
OnErrorEventHandlerNonNull::new(cx, funobj)
|
||||||
}))
|
}))
|
||||||
|
} else if ty == &atom!("beforeunload") {
|
||||||
|
Some(CommonEventHandler::BeforeUnloadEventHandler(unsafe {
|
||||||
|
OnBeforeUnloadEventHandlerNonNull::new(cx, funobj)
|
||||||
|
}))
|
||||||
} else {
|
} else {
|
||||||
if ty == &atom!("beforeunload") {
|
Some(CommonEventHandler::EventHandler(unsafe {
|
||||||
Some(CommonEventHandler::BeforeUnloadEventHandler(unsafe {
|
EventHandlerNonNull::new(cx, funobj)
|
||||||
OnBeforeUnloadEventHandlerNonNull::new(cx, funobj)
|
}))
|
||||||
}))
|
|
||||||
} else {
|
|
||||||
Some(CommonEventHandler::EventHandler(unsafe {
|
|
||||||
EventHandlerNonNull::new(cx, funobj)
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -210,10 +210,8 @@ impl GPUDevice {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.try_remove_scope(s_id);
|
self.try_remove_scope(s_id);
|
||||||
} else {
|
} else if let Err((err, _)) = result {
|
||||||
if let Err((err, _)) = result {
|
self.fire_uncaptured_error(err);
|
||||||
self.fire_uncaptured_error(err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -578,17 +578,16 @@ impl HTMLFormElementMethods for HTMLFormElement {
|
||||||
} else {
|
} else {
|
||||||
a.source.cmp(&b.source)
|
a.source.cmp(&b.source)
|
||||||
}
|
}
|
||||||
|
} else if a
|
||||||
|
.element
|
||||||
|
.upcast::<Node>()
|
||||||
|
.CompareDocumentPosition(b.element.upcast::<Node>()) &
|
||||||
|
NodeConstants::DOCUMENT_POSITION_FOLLOWING ==
|
||||||
|
NodeConstants::DOCUMENT_POSITION_FOLLOWING
|
||||||
|
{
|
||||||
|
std::cmp::Ordering::Less
|
||||||
} else {
|
} else {
|
||||||
if a.element
|
std::cmp::Ordering::Greater
|
||||||
.upcast::<Node>()
|
|
||||||
.CompareDocumentPosition(b.element.upcast::<Node>()) &
|
|
||||||
NodeConstants::DOCUMENT_POSITION_FOLLOWING ==
|
|
||||||
NodeConstants::DOCUMENT_POSITION_FOLLOWING
|
|
||||||
{
|
|
||||||
std::cmp::Ordering::Less
|
|
||||||
} else {
|
|
||||||
std::cmp::Ordering::Greater
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -2868,11 +2868,9 @@ fn filter_from_accept(s: &DOMString) -> Vec<FilterPattern> {
|
||||||
for p in split_commas(s) {
|
for p in split_commas(s) {
|
||||||
if let Some('.') = p.chars().nth(0) {
|
if let Some('.') = p.chars().nth(0) {
|
||||||
filter.push(FilterPattern(p[1..].to_string()));
|
filter.push(FilterPattern(p[1..].to_string()));
|
||||||
} else {
|
} else if let Some(exts) = mime_guess::get_mime_extensions_str(p) {
|
||||||
if let Some(exts) = mime_guess::get_mime_extensions_str(p) {
|
for ext in exts {
|
||||||
for ext in exts {
|
filter.push(FilterPattern(ext.to_string()));
|
||||||
filter.push(FilterPattern(ext.to_string()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -167,11 +167,9 @@ impl HTMLSelectElement {
|
||||||
|
|
||||||
if let Some(last_selected) = last_selected {
|
if let Some(last_selected) = last_selected {
|
||||||
last_selected.set_selectedness(true);
|
last_selected.set_selectedness(true);
|
||||||
} else {
|
} else if self.display_size() == 1 {
|
||||||
if self.display_size() == 1 {
|
if let Some(first_enabled) = first_enabled {
|
||||||
if let Some(first_enabled) = first_enabled {
|
first_enabled.set_selectedness(true);
|
||||||
first_enabled.set_selectedness(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,12 +92,10 @@ impl StylePropertyMapReadOnlyMethods for StylePropertyMapReadOnly {
|
||||||
} else {
|
} else {
|
||||||
Ordering::Greater
|
Ordering::Greater
|
||||||
}
|
}
|
||||||
|
} else if let Ok(_) = custom_properties::parse_name(key2) {
|
||||||
|
Ordering::Less
|
||||||
} else {
|
} else {
|
||||||
if let Ok(_) = custom_properties::parse_name(key2) {
|
key1.cmp(key2)
|
||||||
Ordering::Less
|
|
||||||
} else {
|
|
||||||
key1.cmp(key2)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
result
|
result
|
||||||
|
|
|
@ -82,12 +82,10 @@ impl<'dom, LayoutDataType: LayoutDataTrait> fmt::Debug for ServoLayoutNode<'dom,
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
if let Some(el) = self.as_element() {
|
if let Some(el) = self.as_element() {
|
||||||
el.fmt(f)
|
el.fmt(f)
|
||||||
|
} else if self.is_text_node() {
|
||||||
|
write!(f, "<text node> ({:#x})", self.opaque().0)
|
||||||
} else {
|
} else {
|
||||||
if self.is_text_node() {
|
write!(f, "<non-text node> ({:#x})", self.opaque().0)
|
||||||
write!(f, "<text node> ({:#x})", self.opaque().0)
|
|
||||||
} else {
|
|
||||||
write!(f, "<non-text node> ({:#x})", self.opaque().0)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -627,15 +627,13 @@ impl<T: ClipboardProvider> TextInput<T> {
|
||||||
if self.selection_origin.is_none() {
|
if self.selection_origin.is_none() {
|
||||||
self.selection_origin = Some(self.edit_point);
|
self.selection_origin = Some(self.edit_point);
|
||||||
}
|
}
|
||||||
} else {
|
} else if self.has_selection() {
|
||||||
if self.has_selection() {
|
self.edit_point = match adjust {
|
||||||
self.edit_point = match adjust {
|
Direction::Backward => self.selection_start(),
|
||||||
Direction::Backward => self.selection_start(),
|
Direction::Forward => self.selection_end(),
|
||||||
Direction::Forward => self.selection_end(),
|
};
|
||||||
};
|
self.clear_selection();
|
||||||
self.clear_selection();
|
return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue