mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
clippy: Fix collapsible_if warnings (#31852)
This commit is contained in:
parent
3d10dbae32
commit
a53632c0e5
11 changed files with 85 additions and 95 deletions
|
@ -231,11 +231,8 @@ impl BluetoothDevice {
|
|||
let context = self.get_context();
|
||||
for (id, device) in context.get_device_map().borrow().iter() {
|
||||
// Step 2.1 - 2.2.
|
||||
if id == &self.Id().to_string() {
|
||||
if device.get_gatt().Connected() {
|
||||
return Ok(());
|
||||
}
|
||||
// TODO: Step 2.3: Implement activeAlgorithms internal slot for BluetoothRemoteGATTServer.
|
||||
if id == &self.Id().to_string() && device.get_gatt().Connected() {
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2393,10 +2393,8 @@ impl Document {
|
|||
// TODO: should this only happen on the first document loaded?
|
||||
// https://immersive-web.github.io/webxr/#user-intention
|
||||
// https://github.com/immersive-web/navigation/issues/10
|
||||
if pref!(dom.webxr.sessionavailable) {
|
||||
if self.window.is_top_level() {
|
||||
self.window.Navigator().Xr().dispatch_sessionavailable();
|
||||
}
|
||||
if pref!(dom.webxr.sessionavailable) && self.window.is_top_level() {
|
||||
self.window.Navigator().Xr().dispatch_sessionavailable();
|
||||
}
|
||||
|
||||
// Step 12: completely loaded.
|
||||
|
|
|
@ -143,18 +143,16 @@ impl HTMLFormElement {
|
|||
RadioListMode::ControlsExceptImageInputs => {
|
||||
if child
|
||||
.downcast::<HTMLElement>()
|
||||
.map_or(false, |c| c.is_listed_element())
|
||||
.map_or(false, |c| c.is_listed_element()) &&
|
||||
(child.get_id().map_or(false, |i| i == *name) ||
|
||||
child.get_name().map_or(false, |n| n == *name))
|
||||
{
|
||||
if child.get_id().map_or(false, |i| i == *name) ||
|
||||
child.get_name().map_or(false, |n| n == *name)
|
||||
{
|
||||
if let Some(inp) = child.downcast::<HTMLInputElement>() {
|
||||
// input, only return it if it's not image-button state
|
||||
return inp.input_type() != InputType::Image;
|
||||
} else {
|
||||
// control, but not an input
|
||||
return true;
|
||||
}
|
||||
if let Some(inp) = child.downcast::<HTMLInputElement>() {
|
||||
// input, only return it if it's not image-button state
|
||||
return inp.input_type() != InputType::Image;
|
||||
} else {
|
||||
// control, but not an input
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -719,11 +717,9 @@ impl HTMLFormElement {
|
|||
// Step 6.2
|
||||
self.firing_submission_events.set(true);
|
||||
// Step 6.3
|
||||
if !submitter.no_validate(self) {
|
||||
if self.interactive_validation().is_err() {
|
||||
self.firing_submission_events.set(false);
|
||||
return;
|
||||
}
|
||||
if !submitter.no_validate(self) && self.interactive_validation().is_err() {
|
||||
self.firing_submission_events.set(false);
|
||||
return;
|
||||
}
|
||||
// Step 6.4
|
||||
// spec calls this "submitterButton" but it doesn't have to be a button,
|
||||
|
@ -1537,10 +1533,11 @@ pub trait FormControl: DomObject {
|
|||
.next();
|
||||
|
||||
// Step 1
|
||||
if old_owner.is_some() && !(self.is_listed() && has_form_id) {
|
||||
if nearest_form_ancestor == old_owner {
|
||||
return;
|
||||
}
|
||||
if old_owner.is_some() &&
|
||||
!(self.is_listed() && has_form_id) &&
|
||||
nearest_form_ancestor == old_owner
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
let new_owner = if self.is_listed() && has_form_id && elem.is_connected() {
|
||||
|
|
|
@ -2684,28 +2684,28 @@ impl Validatable for HTMLInputElement {
|
|||
let mut failed_flags = ValidationFlags::empty();
|
||||
let value = self.Value();
|
||||
|
||||
if validate_flags.contains(ValidationFlags::VALUE_MISSING) {
|
||||
if self.suffers_from_being_missing(&value) {
|
||||
failed_flags.insert(ValidationFlags::VALUE_MISSING);
|
||||
}
|
||||
if validate_flags.contains(ValidationFlags::VALUE_MISSING) &&
|
||||
self.suffers_from_being_missing(&value)
|
||||
{
|
||||
failed_flags.insert(ValidationFlags::VALUE_MISSING);
|
||||
}
|
||||
|
||||
if validate_flags.contains(ValidationFlags::TYPE_MISMATCH) {
|
||||
if self.suffers_from_type_mismatch(&value) {
|
||||
failed_flags.insert(ValidationFlags::TYPE_MISMATCH);
|
||||
}
|
||||
if validate_flags.contains(ValidationFlags::TYPE_MISMATCH) &&
|
||||
self.suffers_from_type_mismatch(&value)
|
||||
{
|
||||
failed_flags.insert(ValidationFlags::TYPE_MISMATCH);
|
||||
}
|
||||
|
||||
if validate_flags.contains(ValidationFlags::PATTERN_MISMATCH) {
|
||||
if self.suffers_from_pattern_mismatch(&value) {
|
||||
failed_flags.insert(ValidationFlags::PATTERN_MISMATCH);
|
||||
}
|
||||
if validate_flags.contains(ValidationFlags::PATTERN_MISMATCH) &&
|
||||
self.suffers_from_pattern_mismatch(&value)
|
||||
{
|
||||
failed_flags.insert(ValidationFlags::PATTERN_MISMATCH);
|
||||
}
|
||||
|
||||
if validate_flags.contains(ValidationFlags::BAD_INPUT) {
|
||||
if self.suffers_from_bad_input(&value) {
|
||||
failed_flags.insert(ValidationFlags::BAD_INPUT);
|
||||
}
|
||||
if validate_flags.contains(ValidationFlags::BAD_INPUT) &&
|
||||
self.suffers_from_bad_input(&value)
|
||||
{
|
||||
failed_flags.insert(ValidationFlags::BAD_INPUT);
|
||||
}
|
||||
|
||||
if validate_flags.intersects(ValidationFlags::TOO_LONG | ValidationFlags::TOO_SHORT) {
|
||||
|
|
|
@ -736,10 +736,12 @@ impl Validatable for HTMLTextAreaElement {
|
|||
|
||||
// https://html.spec.whatwg.org/multipage/#suffering-from-being-missing
|
||||
// https://html.spec.whatwg.org/multipage/#the-textarea-element%3Asuffering-from-being-missing
|
||||
if validate_flags.contains(ValidationFlags::VALUE_MISSING) {
|
||||
if self.Required() && self.is_mutable() && value_len == 0 {
|
||||
failed_flags.insert(ValidationFlags::VALUE_MISSING);
|
||||
}
|
||||
if validate_flags.contains(ValidationFlags::VALUE_MISSING) &&
|
||||
self.Required() &&
|
||||
self.is_mutable() &&
|
||||
value_len == 0
|
||||
{
|
||||
failed_flags.insert(ValidationFlags::VALUE_MISSING);
|
||||
}
|
||||
|
||||
if value_dirty && last_edit_by_user && value_len > 0 {
|
||||
|
|
|
@ -117,13 +117,11 @@ impl NavigationPreloadManagerMethods for NavigationPreloadManager {
|
|||
let mut state = NavigationPreloadState::empty();
|
||||
|
||||
// 3.
|
||||
if self.serviceworker_registration.is_active() {
|
||||
if self
|
||||
.serviceworker_registration
|
||||
if self.serviceworker_registration.is_active() &&
|
||||
self.serviceworker_registration
|
||||
.get_navigation_preload_enabled()
|
||||
{
|
||||
state.enabled = true;
|
||||
}
|
||||
{
|
||||
state.enabled = true;
|
||||
}
|
||||
|
||||
// 4.
|
||||
|
|
|
@ -238,12 +238,12 @@ impl Request {
|
|||
}
|
||||
|
||||
// Step 21
|
||||
if request.cache_mode == NetTraitsRequestCache::OnlyIfCached {
|
||||
if request.mode != NetTraitsRequestMode::SameOrigin {
|
||||
return Err(Error::Type(
|
||||
"Cache is 'only-if-cached' and mode is not 'same-origin'".to_string(),
|
||||
));
|
||||
}
|
||||
if request.cache_mode == NetTraitsRequestCache::OnlyIfCached &&
|
||||
request.mode != NetTraitsRequestMode::SameOrigin
|
||||
{
|
||||
return Err(Error::Type(
|
||||
"Cache is 'only-if-cached' and mode is not 'same-origin'".to_string(),
|
||||
));
|
||||
}
|
||||
|
||||
// Step 22
|
||||
|
|
|
@ -458,10 +458,10 @@ impl WebGLExtensions {
|
|||
}
|
||||
|
||||
pub fn effective_type(&self, type_: u32) -> u32 {
|
||||
if type_ == OESTextureHalfFloatConstants::HALF_FLOAT_OES {
|
||||
if !self.supports_gl_extension("GL_OES_texture_half_float") {
|
||||
return gl::HALF_FLOAT;
|
||||
}
|
||||
if type_ == OESTextureHalfFloatConstants::HALF_FLOAT_OES &&
|
||||
!self.supports_gl_extension("GL_OES_texture_half_float")
|
||||
{
|
||||
return gl::HALF_FLOAT;
|
||||
}
|
||||
type_
|
||||
}
|
||||
|
|
|
@ -871,10 +871,10 @@ impl WebGLRenderingContext {
|
|||
}
|
||||
|
||||
// See https://www.khronos.org/registry/webgl/specs/latest/2.0/#4.1.6
|
||||
if self.webgl_version() == WebGLVersion::WebGL1 {
|
||||
if data_type != image_info.data_type().unwrap() {
|
||||
return self.webgl_error(InvalidOperation);
|
||||
}
|
||||
if self.webgl_version() == WebGLVersion::WebGL1 &&
|
||||
data_type != image_info.data_type().unwrap()
|
||||
{
|
||||
return self.webgl_error(InvalidOperation);
|
||||
}
|
||||
|
||||
let settings = self.texture_unpacking_settings.get();
|
||||
|
|
|
@ -2257,10 +2257,8 @@ impl Window {
|
|||
// Step 4 and 5
|
||||
let window_proxy = self.window_proxy();
|
||||
if let Some(active) = window_proxy.currently_active() {
|
||||
if pipeline_id == active {
|
||||
if doc.is_prompting_or_unloading() {
|
||||
return;
|
||||
}
|
||||
if pipeline_id == active && doc.is_prompting_or_unloading() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -753,29 +753,29 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
|
|||
if let Some(encoding) = encoding {
|
||||
let mime: Mime = ct.into();
|
||||
for param in mime.params() {
|
||||
if param.0 == mime::CHARSET {
|
||||
if !param.1.as_ref().eq_ignore_ascii_case(encoding) {
|
||||
let new_params: Vec<(Name, Name)> = mime
|
||||
.params()
|
||||
.filter(|p| p.0 != mime::CHARSET)
|
||||
.map(|p| (p.0, p.1))
|
||||
.collect();
|
||||
if param.0 == mime::CHARSET &&
|
||||
!param.1.as_ref().eq_ignore_ascii_case(encoding)
|
||||
{
|
||||
let new_params: Vec<(Name, Name)> = mime
|
||||
.params()
|
||||
.filter(|p| p.0 != mime::CHARSET)
|
||||
.map(|p| (p.0, p.1))
|
||||
.collect();
|
||||
|
||||
let new_mime = format!(
|
||||
"{}/{}; charset={}{}{}",
|
||||
mime.type_().as_ref(),
|
||||
mime.subtype().as_ref(),
|
||||
encoding,
|
||||
if new_params.is_empty() { "" } else { "; " },
|
||||
new_params
|
||||
.iter()
|
||||
.map(|p| format!("{}={}", p.0, p.1))
|
||||
.collect::<Vec<String>>()
|
||||
.join("; ")
|
||||
);
|
||||
let new_mime: Mime = new_mime.parse().unwrap();
|
||||
request.headers.typed_insert(ContentType::from(new_mime))
|
||||
}
|
||||
let new_mime = format!(
|
||||
"{}/{}; charset={}{}{}",
|
||||
mime.type_().as_ref(),
|
||||
mime.subtype().as_ref(),
|
||||
encoding,
|
||||
if new_params.is_empty() { "" } else { "; " },
|
||||
new_params
|
||||
.iter()
|
||||
.map(|p| format!("{}={}", p.0, p.1))
|
||||
.collect::<Vec<String>>()
|
||||
.join("; ")
|
||||
);
|
||||
let new_mime: Mime = new_mime.parse().unwrap();
|
||||
request.headers.typed_insert(ContentType::from(new_mime))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue