mirror of
https://github.com/servo/servo.git
synced 2025-07-24 07:40:27 +01:00
Fixed some clippy warnings in components (#32107)
* Fixed some clippy warnings in components * Updated handling of NaN values in comparison * Updated formatting using ./mach fmt
This commit is contained in:
parent
f70413baba
commit
007a72fe4d
9 changed files with 20 additions and 29 deletions
|
@ -1043,7 +1043,7 @@ impl FormControl for HTMLElement {
|
||||||
.set_form_owner(form);
|
.set_form_owner(form);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_element<'a>(&'a self) -> &'a Element {
|
fn to_element(&self) -> &Element {
|
||||||
debug_assert!(self.is_form_associated_custom_element());
|
debug_assert!(self.is_form_associated_custom_element());
|
||||||
self.as_element()
|
self.as_element()
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,10 +98,7 @@ impl LayoutHTMLTextAreaElementHelpers for LayoutDom<'_, HTMLTextAreaElement> {
|
||||||
if text.is_empty() {
|
if text.is_empty() {
|
||||||
// FIXME(nox): Would be cool to not allocate a new string if the
|
// FIXME(nox): Would be cool to not allocate a new string if the
|
||||||
// placeholder is single line, but that's an unimportant detail.
|
// placeholder is single line, but that's an unimportant detail.
|
||||||
self.placeholder()
|
self.placeholder().replace("\r\n", "\n").replace('\r', "\n")
|
||||||
.replace("\r\n", "\n")
|
|
||||||
.replace('\r', "\n")
|
|
||||||
.into()
|
|
||||||
} else {
|
} else {
|
||||||
text.into()
|
text.into()
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,14 +128,11 @@ impl MediaFragmentParser {
|
||||||
fn parse_utc_timestamp(&self, input: &str) -> Result<(Option<f64>, Option<f64>), ()> {
|
fn parse_utc_timestamp(&self, input: &str) -> Result<(Option<f64>, Option<f64>), ()> {
|
||||||
if input.ends_with('-') || input.starts_with(',') || !input.contains('-') {
|
if input.ends_with('-') || input.starts_with(',') || !input.contains('-') {
|
||||||
let sec = parse_hms(
|
let sec = parse_hms(
|
||||||
NaiveDateTime::parse_from_str(
|
NaiveDateTime::parse_from_str(&input.replace(['-', ','], ""), "%Y%m%dT%H%M%S%.fZ")
|
||||||
&input.replace('-', "").replace(',', ""),
|
.map_err(|_| ())?
|
||||||
"%Y%m%dT%H%M%S%.fZ",
|
.time()
|
||||||
)
|
.to_string()
|
||||||
.map_err(|_| ())?
|
.as_ref(),
|
||||||
.time()
|
|
||||||
.to_string()
|
|
||||||
.as_ref(),
|
|
||||||
)?;
|
)?;
|
||||||
if input.starts_with(',') {
|
if input.starts_with(',') {
|
||||||
Ok((Some(0.), Some(sec)))
|
Ok((Some(0.), Some(sec)))
|
||||||
|
|
|
@ -719,15 +719,11 @@ impl Node {
|
||||||
other: &Node,
|
other: &Node,
|
||||||
shadow_including: ShadowIncluding,
|
shadow_including: ShadowIncluding,
|
||||||
) -> Option<DomRoot<Node>> {
|
) -> Option<DomRoot<Node>> {
|
||||||
for ancestor in self.inclusive_ancestors(shadow_including) {
|
self.inclusive_ancestors(shadow_including).find(|ancestor| {
|
||||||
if other
|
other
|
||||||
.inclusive_ancestors(shadow_including)
|
.inclusive_ancestors(shadow_including)
|
||||||
.any(|node| node == ancestor)
|
.any(|node| node == *ancestor)
|
||||||
{
|
})
|
||||||
return Some(ancestor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
None
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_inclusive_ancestor_of(&self, parent: &Node) -> bool {
|
pub fn is_inclusive_ancestor_of(&self, parent: &Node) -> bool {
|
||||||
|
|
|
@ -438,6 +438,6 @@ impl ElementsByNameList {
|
||||||
pub fn item(&self, index: u32) -> Option<DomRoot<Node>> {
|
pub fn item(&self, index: u32) -> Option<DomRoot<Node>> {
|
||||||
self.document
|
self.document
|
||||||
.nth_element_by_name(index, &self.name)
|
.nth_element_by_name(index, &self.name)
|
||||||
.and_then(|n| Some(DomRoot::from_ref(&*n)))
|
.map(|n| DomRoot::from_ref(&*n))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -557,9 +557,9 @@ impl RTCPeerConnectionMethods for RTCPeerConnection {
|
||||||
fn AddIceCandidate(&self, candidate: &RTCIceCandidateInit, comp: InRealm) -> Rc<Promise> {
|
fn AddIceCandidate(&self, candidate: &RTCIceCandidateInit, comp: InRealm) -> Rc<Promise> {
|
||||||
let p = Promise::new_in_current_realm(comp);
|
let p = Promise::new_in_current_realm(comp);
|
||||||
if candidate.sdpMid.is_none() && candidate.sdpMLineIndex.is_none() {
|
if candidate.sdpMid.is_none() && candidate.sdpMLineIndex.is_none() {
|
||||||
p.reject_error(Error::Type(format!(
|
p.reject_error(Error::Type(
|
||||||
"one of sdpMid and sdpMLineIndex must be set"
|
"one of sdpMid and sdpMLineIndex must be set".to_string(),
|
||||||
)));
|
));
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2953,7 +2953,8 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
if pbo_offset < 0 || pbo_offset as usize > pixel_unpack_buffer.capacity() {
|
if pbo_offset < 0 || pbo_offset as usize > pixel_unpack_buffer.capacity() {
|
||||||
return Ok(self.base.webgl_error(InvalidValue));
|
self.base.webgl_error(InvalidValue);
|
||||||
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let unpacking_alignment = self.base.texture_unpacking_alignment();
|
let unpacking_alignment = self.base.texture_unpacking_alignment();
|
||||||
|
@ -4119,7 +4120,7 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
|
||||||
handle_potential_webgl_error!(
|
handle_potential_webgl_error!(
|
||||||
self.base,
|
self.base,
|
||||||
program.get_uniform_block_index(block_name),
|
program.get_uniform_block_index(block_name),
|
||||||
return constants::INVALID_INDEX
|
constants::INVALID_INDEX
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -406,7 +406,7 @@ impl WebGLExtensions {
|
||||||
.borrow()
|
.borrow()
|
||||||
.tex_compression_formats
|
.tex_compression_formats
|
||||||
.keys()
|
.keys()
|
||||||
.map(|&k| k)
|
.copied()
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -326,7 +326,7 @@ impl WebGLTexture {
|
||||||
},
|
},
|
||||||
EXTTextureFilterAnisotropicConstants::TEXTURE_MAX_ANISOTROPY_EXT => {
|
EXTTextureFilterAnisotropicConstants::TEXTURE_MAX_ANISOTROPY_EXT => {
|
||||||
// NaN is not less than 1., what a time to be alive.
|
// NaN is not less than 1., what a time to be alive.
|
||||||
if !(float_value >= 1.) {
|
if float_value < 1. || !float_value.is_normal() {
|
||||||
return Err(WebGLError::InvalidValue);
|
return Err(WebGLError::InvalidValue);
|
||||||
}
|
}
|
||||||
self.upcast::<WebGLObject>()
|
self.upcast::<WebGLObject>()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue