diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs index c7a3d2e9d57..113986b8bfb 100644 --- a/components/script/dom/htmlformelement.rs +++ b/components/script/dom/htmlformelement.rs @@ -859,7 +859,7 @@ impl HTMLFormElement { load_data, enctype, encoding, - &target_window, + target_window, ); }, // https://html.spec.whatwg.org/multipage/#submit-get-action @@ -868,7 +868,7 @@ impl HTMLFormElement { ("data", FormMethod::FormPost) | ("ftp", _) | ("javascript", _) => { - self.plan_to_navigate(load_data, &target_window); + self.plan_to_navigate(load_data, target_window); }, ("mailto", FormMethod::FormPost) => { // TODO: Mail as body @@ -885,7 +885,7 @@ impl HTMLFormElement { // https://html.spec.whatwg.org/multipage/#submit-mutate-action fn mutate_action_url( &self, - form_data: &mut Vec, + form_data: &mut [FormDatum], mut load_data: LoadData, encoding: &'static Encoding, target: &Window, @@ -1510,7 +1510,7 @@ pub trait FormControl: DomObject { fn set_form_owner(&self, form: Option<&HTMLFormElement>); - fn to_element<'a>(&'a self) -> &'a Element; + fn to_element(&self) -> ∈ fn is_listed(&self) -> bool { true @@ -1721,11 +1721,11 @@ impl VirtualMethods for HTMLFormElement { } pub trait FormControlElementHelpers { - fn as_maybe_form_control<'a>(&'a self) -> Option<&'a dyn FormControl>; + fn as_maybe_form_control(&self) -> Option<&dyn FormControl>; } impl FormControlElementHelpers for Element { - fn as_maybe_form_control<'a>(&'a self) -> Option<&'a dyn FormControl> { + fn as_maybe_form_control(&self) -> Option<&dyn FormControl> { let node = self.upcast::(); match node.type_id() { @@ -1766,7 +1766,7 @@ impl FormControlElementHelpers for Element { // https://html.spec.whatwg.org/multipage/#multipart/form-data-encoding-algorithm pub fn encode_multipart_form_data( - form_data: &mut Vec, + form_data: &mut [FormDatum], boundary: String, encoding: &'static Encoding, ) -> Vec { diff --git a/components/script/dom/htmlheadelement.rs b/components/script/dom/htmlheadelement.rs index ad95bbd9224..9fd83041016 100644 --- a/components/script/dom/htmlheadelement.rs +++ b/components/script/dom/htmlheadelement.rs @@ -87,7 +87,7 @@ impl VirtualMethods for HTMLHeadElement { Some(self.upcast::() as &dyn VirtualMethods) } fn bind_to_tree(&self, context: &BindContext) { - if let Some(ref s) = self.super_type() { + if let Some(s) = self.super_type() { s.bind_to_tree(context); } load_script(self); diff --git a/components/script/dom/htmlhrelement.rs b/components/script/dom/htmlhrelement.rs index 1a63747aa57..96ba4733735 100644 --- a/components/script/dom/htmlhrelement.rs +++ b/components/script/dom/htmlhrelement.rs @@ -97,10 +97,10 @@ impl VirtualMethods for HTMLHRElement { } fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue { - match name { - &local_name!("align") => AttrValue::from_dimension(value.into()), - &local_name!("color") => AttrValue::from_legacy_color(value.into()), - &local_name!("width") => AttrValue::from_dimension(value.into()), + match *name { + local_name!("align") => AttrValue::from_dimension(value.into()), + local_name!("color") => AttrValue::from_legacy_color(value.into()), + local_name!("width") => AttrValue::from_dimension(value.into()), _ => self .super_type() .unwrap() diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index 3de9b5ef9c7..3db0b69e30f 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -168,7 +168,7 @@ impl HTMLIFrameElement { _ => { let mut load_blocker = self.load_blocker.borrow_mut(); *load_blocker = Some(LoadBlocker::new( - &*document, + &document, LoadType::Subframe(load_data.url.clone()), )); }, @@ -320,7 +320,7 @@ impl HTMLIFrameElement { return; } } - ancestor = a.parent().map(|p| DomRoot::from_ref(p)); + ancestor = a.parent().map(DomRoot::from_ref); } let creator_pipeline_id = if url.as_str() == "about:blank" { @@ -517,13 +517,13 @@ impl HTMLIFrameElementLayoutMethods for LayoutDom<'_, HTMLIFrameElement> { #[inline] #[allow(unsafe_code)] fn pipeline_id(self) -> Option { - unsafe { (*self.unsafe_get()).pipeline_id.get() } + unsafe { (self.unsafe_get()).pipeline_id.get() } } #[inline] #[allow(unsafe_code)] fn browsing_context_id(self) -> Option { - unsafe { (*self.unsafe_get()).browsing_context_id.get() } + unsafe { (self.unsafe_get()).browsing_context_id.get() } } fn get_width(self) -> LengthOrPercentageOrAuto { @@ -578,7 +578,7 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement { fn GetContentWindow(&self) -> Option> { self.browsing_context_id .get() - .and_then(|browsing_context_id| ScriptThread::find_window_proxy(browsing_context_id)) + .and_then(ScriptThread::find_window_proxy) } // https://html.spec.whatwg.org/multipage/#dom-iframe-contentdocument @@ -642,8 +642,8 @@ impl VirtualMethods for HTMLIFrameElement { fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) { self.super_type().unwrap().attribute_mutated(attr, mutation); - match attr.local_name() { - &local_name!("sandbox") => { + match *attr.local_name() { + local_name!("sandbox") => { self.sandbox_allowance .set(mutation.new_value(attr).map(|value| { let mut modes = SandboxAllowance::ALLOW_NOTHING; @@ -661,7 +661,7 @@ impl VirtualMethods for HTMLIFrameElement { modes })); }, - &local_name!("srcdoc") => { + local_name!("srcdoc") => { // https://html.spec.whatwg.org/multipage/#the-iframe-element:the-iframe-element-9 // "Whenever an iframe element with a non-null nested browsing context has its // srcdoc attribute set, changed, or removed, the user agent must process the @@ -677,7 +677,7 @@ impl VirtualMethods for HTMLIFrameElement { self.process_the_iframe_attributes(ProcessingMode::NotFirstTime); } }, - &local_name!("src") => { + local_name!("src") => { // https://html.spec.whatwg.org/multipage/#the-iframe-element // "Similarly, whenever an iframe element with a non-null nested browsing context // but with no srcdoc attribute specified has its src attribute set, changed, or removed, diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs index 02edcd924cd..e6e876e5f11 100644 --- a/components/script/dom/htmlimageelement.rs +++ b/components/script/dom/htmlimageelement.rs @@ -704,10 +704,10 @@ impl HTMLImageElement { /// fn normalise_source_densities(&self, source_set: &mut SourceSet, width: Option) { // Step 1 - let mut source_size = &mut source_set.source_size; + let source_size = &mut source_set.source_size; // Find source_size_length for Step 2.2 - let source_size_length = self.evaluate_source_size_list(&mut source_size, width); + let source_size_length = self.evaluate_source_size_list(source_size, width); // Step 2 for imgsource in &mut source_set.image_sources { @@ -721,7 +721,7 @@ impl HTMLImageElement { imgsource.descriptor.den = Some(wid as f64 / source_size_length.to_f64_px()); } else { //Step 2.3 - imgsource.descriptor.den = Some(1 as f64); + imgsource.descriptor.den = Some(1_f64); } } } @@ -947,7 +947,7 @@ impl HTMLImageElement { .map_or(false, |p| p.is::()); if src_set.is_empty() && !is_parent_picture && !src.is_empty() { selected_source = Some(src.clone()); - pixel_density = Some(1 as f64); + pixel_density = Some(1_f64); }; // Step 5 @@ -1579,7 +1579,7 @@ impl HTMLImageElementMethods for HTMLImageElement { match *url { Some(ref url) => USVString(url.clone().into_string()), None => { - let ref unparsed_url = current_request.source_url; + let unparsed_url = ¤t_request.source_url; match *unparsed_url { Some(ref url) => url.clone(), None => USVString("".to_owned()), @@ -1722,7 +1722,7 @@ impl VirtualMethods for HTMLImageElement { } fn bind_to_tree(&self, context: &BindContext) { - if let Some(ref s) = self.super_type() { + if let Some(s) = self.super_type() { s.bind_to_tree(context); } let document = document_from_node(self); @@ -1761,7 +1761,7 @@ impl FormControl for HTMLImageElement { self.form_owner.set(form); } - fn to_element<'a>(&'a self) -> &'a Element { + fn to_element(&self) -> &Element { self.upcast::() } diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index 1b8453c9497..899d36a5434 100755 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -120,24 +120,23 @@ impl InputType { // slightly differently, with placeholder characters shown rather // than the underlying value. fn is_textual(&self) -> bool { - match *self { + matches!( + *self, InputType::Color | - InputType::Date | - InputType::DatetimeLocal | - InputType::Email | - InputType::Hidden | - InputType::Month | - InputType::Number | - InputType::Range | - InputType::Search | - InputType::Tel | - InputType::Text | - InputType::Time | - InputType::Url | - InputType::Week => true, - - _ => false, - } + InputType::Date | + InputType::DatetimeLocal | + InputType::Email | + InputType::Hidden | + InputType::Month | + InputType::Number | + InputType::Range | + InputType::Search | + InputType::Tel | + InputType::Text | + InputType::Time | + InputType::Url | + InputType::Week + ) } fn is_textual_or_password(&self) -> bool { @@ -428,45 +427,45 @@ impl HTMLInputElement { } fn does_readonly_apply(&self) -> bool { - match self.input_type() { + matches!( + self.input_type(), InputType::Text | - InputType::Search | - InputType::Url | - InputType::Tel | - InputType::Email | - InputType::Password | - InputType::Date | - InputType::Month | - InputType::Week | - InputType::Time | - InputType::DatetimeLocal | - InputType::Number => true, - _ => false, - } + InputType::Search | + InputType::Url | + InputType::Tel | + InputType::Email | + InputType::Password | + InputType::Date | + InputType::Month | + InputType::Week | + InputType::Time | + InputType::DatetimeLocal | + InputType::Number + ) } fn does_minmaxlength_apply(&self) -> bool { - match self.input_type() { + matches!( + self.input_type(), InputType::Text | - InputType::Search | - InputType::Url | - InputType::Tel | - InputType::Email | - InputType::Password => true, - _ => false, - } + InputType::Search | + InputType::Url | + InputType::Tel | + InputType::Email | + InputType::Password + ) } fn does_pattern_apply(&self) -> bool { - match self.input_type() { + matches!( + self.input_type(), InputType::Text | - InputType::Search | - InputType::Url | - InputType::Tel | - InputType::Email | - InputType::Password => true, - _ => false, - } + InputType::Search | + InputType::Url | + InputType::Tel | + InputType::Email | + InputType::Password + ) } fn does_multiple_apply(&self) -> bool { @@ -476,24 +475,23 @@ impl HTMLInputElement { // valueAsNumber, step, min, and max all share the same set of // input types they apply to fn does_value_as_number_apply(&self) -> bool { - match self.input_type() { + matches!( + self.input_type(), InputType::Date | - InputType::Month | - InputType::Week | - InputType::Time | - InputType::DatetimeLocal | - InputType::Number | - InputType::Range => true, - _ => false, - } + InputType::Month | + InputType::Week | + InputType::Time | + InputType::DatetimeLocal | + InputType::Number | + InputType::Range + ) } fn does_value_as_date_apply(&self) -> bool { - match self.input_type() { - InputType::Date | InputType::Month | InputType::Week | InputType::Time => true, - // surprisingly, spec says false for DateTimeLocal! - _ => false, - } + matches!( + self.input_type(), + InputType::Date | InputType::Month | InputType::Week | InputType::Time + ) } // https://html.spec.whatwg.org/multipage#concept-input-step @@ -1102,15 +1100,14 @@ impl<'dom> LayoutHTMLInputElementHelpers<'dom> for LayoutDom<'dom, HTMLInputElem impl TextControlElement for HTMLInputElement { // https://html.spec.whatwg.org/multipage/#concept-input-apply fn selection_api_applies(&self) -> bool { - match self.input_type() { + matches!( + self.input_type(), InputType::Text | - InputType::Search | - InputType::Url | - InputType::Tel | - InputType::Password => true, - - _ => false, - } + InputType::Search | + InputType::Url | + InputType::Tel | + InputType::Password + ) } // https://html.spec.whatwg.org/multipage/#concept-input-apply @@ -2108,21 +2105,21 @@ impl HTMLInputElement { .filter_map(DomRoot::downcast::) .filter(|input| { input.form_owner() == owner && - match input.input_type() { + matches!( + input.input_type(), InputType::Text | - InputType::Search | - InputType::Url | - InputType::Tel | - InputType::Email | - InputType::Password | - InputType::Date | - InputType::Month | - InputType::Week | - InputType::Time | - InputType::DatetimeLocal | - InputType::Number => true, - _ => false, - } + InputType::Search | + InputType::Url | + InputType::Tel | + InputType::Email | + InputType::Password | + InputType::Date | + InputType::Month | + InputType::Week | + InputType::Time | + InputType::DatetimeLocal | + InputType::Number + ) }); if inputs.skip(1).next().is_some() {