mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Updated fixes to some clippy warnings in components/script
This commit is contained in:
parent
e74a03724f
commit
2a37c3dec8
58 changed files with 156 additions and 265 deletions
|
@ -543,9 +543,9 @@ pub enum ProtoOrIfaceIndex {
|
|||
Constructor(PrototypeList::Constructor),
|
||||
}
|
||||
|
||||
impl Into<usize> for ProtoOrIfaceIndex {
|
||||
fn into(self) -> usize {
|
||||
match self {
|
||||
impl From<ProtoOrIfaceIndex> for usize {
|
||||
fn from(index: ProtoOrIfaceIndex) -> usize {
|
||||
match index {
|
||||
ProtoOrIfaceIndex::ID(id) => id as usize,
|
||||
ProtoOrIfaceIndex::Constructor(constructor) => constructor as usize,
|
||||
}
|
||||
|
|
|
@ -51,9 +51,9 @@ impl ByteString {
|
|||
}
|
||||
}
|
||||
|
||||
impl Into<Vec<u8>> for ByteString {
|
||||
fn into(self) -> Vec<u8> {
|
||||
self.0
|
||||
impl From<ByteString> for Vec<u8> {
|
||||
fn from(byte_string: ByteString) -> Vec<u8> {
|
||||
byte_string.0
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -640,21 +640,21 @@ impl From<DOMString> for String {
|
|||
}
|
||||
}
|
||||
|
||||
impl Into<Vec<u8>> for DOMString {
|
||||
fn into(self) -> Vec<u8> {
|
||||
self.0.into()
|
||||
impl From<DOMString> for Vec<u8> {
|
||||
fn from(contents: DOMString) -> Vec<u8> {
|
||||
contents.0.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Into<Cow<'a, str>> for DOMString {
|
||||
fn into(self) -> Cow<'a, str> {
|
||||
self.0.into()
|
||||
impl<'a> From<DOMString> for Cow<'a, str> {
|
||||
fn from(contents: DOMString) -> Cow<'a, str> {
|
||||
contents.0.into()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Into<CowRcStr<'a>> for DOMString {
|
||||
fn into(self) -> CowRcStr<'a> {
|
||||
self.0.into()
|
||||
impl<'a> From<DOMString> for CowRcStr<'a> {
|
||||
fn from(contents: DOMString) -> CowRcStr<'a> {
|
||||
contents.0.into()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -110,15 +110,13 @@ pub fn xml_name_type(name: &str) -> XMLName {
|
|||
|
||||
fn is_valid_continuation(c: char) -> bool {
|
||||
is_valid_start(c) ||
|
||||
match c {
|
||||
matches!(c,
|
||||
'-' |
|
||||
'.' |
|
||||
'0'..='9' |
|
||||
'\u{B7}' |
|
||||
'\u{300}'..='\u{36F}' |
|
||||
'\u{203F}'..='\u{2040}' => true,
|
||||
_ => false,
|
||||
}
|
||||
'\u{203F}'..='\u{2040}')
|
||||
}
|
||||
|
||||
let mut iter = name.chars();
|
||||
|
|
|
@ -64,14 +64,14 @@ impl CryptoMethods for Crypto {
|
|||
}
|
||||
|
||||
fn is_integer_buffer(array_type: Type) -> bool {
|
||||
match array_type {
|
||||
matches!(
|
||||
array_type,
|
||||
Type::Uint8 |
|
||||
Type::Uint8Clamped |
|
||||
Type::Int8 |
|
||||
Type::Uint16 |
|
||||
Type::Int16 |
|
||||
Type::Uint32 |
|
||||
Type::Int32 => true,
|
||||
_ => false,
|
||||
}
|
||||
Type::Uint8Clamped |
|
||||
Type::Int8 |
|
||||
Type::Uint16 |
|
||||
Type::Int16 |
|
||||
Type::Uint32 |
|
||||
Type::Int32
|
||||
)
|
||||
}
|
||||
|
|
|
@ -345,16 +345,17 @@ impl Element {
|
|||
self.is.borrow().clone()
|
||||
}
|
||||
|
||||
/// <https://dom.spec.whatwg.org/#concept-element-custom-element-state>
|
||||
pub fn set_custom_element_state(&self, state: CustomElementState) {
|
||||
// no need to inflate rare data for uncustomized
|
||||
if state != CustomElementState::Uncustomized || self.rare_data().is_some() {
|
||||
self.ensure_rare_data().custom_element_state = state;
|
||||
}
|
||||
// https://dom.spec.whatwg.org/#concept-element-defined
|
||||
let in_defined_state = match state {
|
||||
CustomElementState::Uncustomized | CustomElementState::Custom => true,
|
||||
_ => false,
|
||||
};
|
||||
|
||||
let in_defined_state = matches!(
|
||||
state,
|
||||
CustomElementState::Uncustomized | CustomElementState::Custom
|
||||
);
|
||||
self.set_state(ElementState::DEFINED, in_defined_state)
|
||||
}
|
||||
|
||||
|
@ -627,7 +628,7 @@ pub trait LayoutElementHelpers<'dom> {
|
|||
fn get_lang_for_layout(self) -> String;
|
||||
fn get_state_for_layout(self) -> ElementState;
|
||||
fn insert_selector_flags(self, flags: ElementSelectorFlags);
|
||||
fn has_selector_flags(self, flags: ElementSelectorFlags) -> bool;
|
||||
fn get_selector_flags(self) -> ElementSelectorFlags;
|
||||
/// The shadow root this element is a host of.
|
||||
fn get_shadow_root_for_layout(self) -> Option<LayoutDom<'dom, ShadowRoot>>;
|
||||
fn get_attr_for_layout(
|
||||
|
@ -707,7 +708,7 @@ impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> {
|
|||
};
|
||||
|
||||
if let Some(color) = bgcolor {
|
||||
use cssparser::FromParsedColor;
|
||||
use style::color::parsing::FromParsedColor;
|
||||
hints.push(from_declaration(
|
||||
shared_lock,
|
||||
PropertyDeclaration::BackgroundColor(specified::Color::from_rgba(
|
||||
|
@ -747,7 +748,7 @@ impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> {
|
|||
};
|
||||
|
||||
if let Some(color) = color {
|
||||
use cssparser::FromParsedColor;
|
||||
use style::color::parsing::FromParsedColor;
|
||||
hints.push(from_declaration(
|
||||
shared_lock,
|
||||
PropertyDeclaration::Color(longhands::color::SpecifiedValue(
|
||||
|
@ -1107,8 +1108,8 @@ impl<'dom> LayoutElementHelpers<'dom> for LayoutDom<'dom, Element> {
|
|||
|
||||
#[inline]
|
||||
#[allow(unsafe_code)]
|
||||
fn has_selector_flags(self, flags: ElementSelectorFlags) -> bool {
|
||||
unsafe { (self.unsafe_get()).selector_flags.get().contains(flags) }
|
||||
fn get_selector_flags(self) -> ElementSelectorFlags {
|
||||
unsafe { self.unsafe_get().selector_flags.get() }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -1393,21 +1394,18 @@ impl Element {
|
|||
}
|
||||
|
||||
// <a>, <input>, <select>, and <textrea> are inherently focusable.
|
||||
match node.type_id() {
|
||||
matches!(
|
||||
node.type_id(),
|
||||
NodeTypeId::Element(ElementTypeId::HTMLElement(
|
||||
HTMLElementTypeId::HTMLAnchorElement,
|
||||
)) |
|
||||
NodeTypeId::Element(ElementTypeId::HTMLElement(
|
||||
)) | NodeTypeId::Element(ElementTypeId::HTMLElement(
|
||||
HTMLElementTypeId::HTMLInputElement,
|
||||
)) |
|
||||
NodeTypeId::Element(ElementTypeId::HTMLElement(
|
||||
)) | NodeTypeId::Element(ElementTypeId::HTMLElement(
|
||||
HTMLElementTypeId::HTMLSelectElement,
|
||||
)) |
|
||||
NodeTypeId::Element(ElementTypeId::HTMLElement(
|
||||
)) | NodeTypeId::Element(ElementTypeId::HTMLElement(
|
||||
HTMLElementTypeId::HTMLTextAreaElement,
|
||||
)) => true,
|
||||
_ => false,
|
||||
}
|
||||
))
|
||||
)
|
||||
}
|
||||
|
||||
pub fn is_actually_disabled(&self) -> bool {
|
||||
|
@ -1493,7 +1491,7 @@ impl Element {
|
|||
.map(|js| DomRoot::from_ref(&**js))
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name
|
||||
/// <https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name>
|
||||
pub fn get_attribute_by_name(&self, name: DOMString) -> Option<DomRoot<Attr>> {
|
||||
let name = &self.parsed_name(name);
|
||||
let maybe_attribute = self
|
||||
|
@ -1506,10 +1504,7 @@ impl Element {
|
|||
if *name == local_name!("id") || *name == local_name!("name") {
|
||||
match maybe_attr {
|
||||
None => true,
|
||||
Some(ref attr) => match *attr.value() {
|
||||
AttrValue::Atom(_) => true,
|
||||
_ => false,
|
||||
},
|
||||
Some(ref attr) => matches!(*attr.value(), AttrValue::Atom(_)),
|
||||
}
|
||||
} else {
|
||||
true
|
||||
|
@ -2932,10 +2927,7 @@ impl VirtualMethods for Element {
|
|||
//
|
||||
// Juggle a bit to keep the borrow checker happy
|
||||
// while avoiding the extra clone.
|
||||
let is_declaration = match *attr.value() {
|
||||
AttrValue::Declaration(..) => true,
|
||||
_ => false,
|
||||
};
|
||||
let is_declaration = matches!(*attr.value(), AttrValue::Declaration(..));
|
||||
|
||||
let block = if is_declaration {
|
||||
let mut value = AttrValue::String(String::new());
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use cssparser::RgbaLegacy;
|
||||
use dom_struct::dom_struct;
|
||||
use embedder_traits::EmbedderMsg;
|
||||
use html5ever::{local_name, namespace_url, ns, LocalName, Prefix};
|
||||
use js::rust::HandleObject;
|
||||
use servo_url::ServoUrl;
|
||||
use style::attr::AttrValue;
|
||||
use style::color::parsing::RgbaLegacy;
|
||||
|
||||
use crate::dom::attr::Attr;
|
||||
use crate::dom::bindings::codegen::Bindings::HTMLBodyElementBinding::HTMLBodyElementMethods;
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use cssparser::RgbaLegacy;
|
||||
use dom_struct::dom_struct;
|
||||
use html5ever::{local_name, namespace_url, ns, LocalName, Prefix};
|
||||
use js::rust::HandleObject;
|
||||
use servo_atoms::Atom;
|
||||
use style::attr::AttrValue;
|
||||
use style::color::parsing::RgbaLegacy;
|
||||
use style::str::{read_numbers, HTML_SPACE_CHARACTERS};
|
||||
|
||||
use crate::dom::attr::Attr;
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use cssparser::RgbaLegacy;
|
||||
use dom_struct::dom_struct;
|
||||
use html5ever::{local_name, namespace_url, ns, LocalName, Prefix};
|
||||
use js::rust::HandleObject;
|
||||
use style::attr::{AttrValue, LengthOrPercentageOrAuto};
|
||||
use style::color::parsing::RgbaLegacy;
|
||||
|
||||
use crate::dom::bindings::codegen::Bindings::HTMLHRElementBinding::HTMLHRElementMethods;
|
||||
use crate::dom::bindings::inheritance::Castable;
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use cssparser::RgbaLegacy;
|
||||
use dom_struct::dom_struct;
|
||||
use html5ever::{local_name, namespace_url, ns, LocalName, Prefix};
|
||||
use js::rust::HandleObject;
|
||||
use style::attr::{AttrValue, LengthOrPercentageOrAuto};
|
||||
use style::color::parsing::RgbaLegacy;
|
||||
use style::context::QuirksMode;
|
||||
|
||||
use crate::dom::bindings::codegen::Bindings::HTMLTableCellElementBinding::HTMLTableCellElementMethods;
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
|
||||
use std::cell::Cell;
|
||||
|
||||
use cssparser::RgbaLegacy;
|
||||
use dom_struct::dom_struct;
|
||||
use html5ever::{local_name, namespace_url, ns, LocalName, Prefix};
|
||||
use js::rust::HandleObject;
|
||||
use style::attr::{parse_unsigned_integer, AttrValue, LengthOrPercentageOrAuto};
|
||||
use style::color::parsing::RgbaLegacy;
|
||||
|
||||
use crate::dom::attr::Attr;
|
||||
use crate::dom::bindings::codegen::Bindings::HTMLCollectionBinding::HTMLCollectionMethods;
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use cssparser::RgbaLegacy;
|
||||
use dom_struct::dom_struct;
|
||||
use html5ever::{local_name, namespace_url, ns, LocalName, Prefix};
|
||||
use js::rust::HandleObject;
|
||||
use style::attr::AttrValue;
|
||||
use style::color::parsing::RgbaLegacy;
|
||||
|
||||
use crate::dom::bindings::codegen::Bindings::HTMLTableElementBinding::HTMLTableElementMethods;
|
||||
use crate::dom::bindings::codegen::Bindings::HTMLTableRowElementBinding::HTMLTableRowElementMethods;
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use cssparser::RgbaLegacy;
|
||||
use dom_struct::dom_struct;
|
||||
use html5ever::{local_name, namespace_url, ns, LocalName, Prefix};
|
||||
use js::rust::HandleObject;
|
||||
use style::attr::AttrValue;
|
||||
use style::color::parsing::RgbaLegacy;
|
||||
|
||||
use crate::dom::bindings::codegen::Bindings::HTMLTableSectionElementBinding::HTMLTableSectionElementMethods;
|
||||
use crate::dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
||||
|
|
|
@ -3454,10 +3454,10 @@ impl UniqueId {
|
|||
}
|
||||
}
|
||||
|
||||
impl Into<LayoutNodeType> for NodeTypeId {
|
||||
impl From<NodeTypeId> for LayoutNodeType {
|
||||
#[inline(always)]
|
||||
fn into(self) -> LayoutNodeType {
|
||||
match self {
|
||||
fn from(node_type: NodeTypeId) -> LayoutNodeType {
|
||||
match node_type {
|
||||
NodeTypeId::Element(e) => LayoutNodeType::Element(e.into()),
|
||||
NodeTypeId::CharacterData(CharacterDataTypeId::Text(_)) => LayoutNodeType::Text,
|
||||
x => unreachable!("Layout should not traverse nodes of type {:?}", x),
|
||||
|
@ -3465,10 +3465,10 @@ impl Into<LayoutNodeType> for NodeTypeId {
|
|||
}
|
||||
}
|
||||
|
||||
impl Into<LayoutElementType> for ElementTypeId {
|
||||
impl From<ElementTypeId> for LayoutElementType {
|
||||
#[inline(always)]
|
||||
fn into(self) -> LayoutElementType {
|
||||
match self {
|
||||
fn from(element_type: ElementTypeId) -> LayoutElementType {
|
||||
match element_type {
|
||||
ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLBodyElement) => {
|
||||
LayoutElementType::HTMLBodyElement
|
||||
},
|
||||
|
|
|
@ -24,10 +24,7 @@ gl_enums! {
|
|||
|
||||
impl TexImageTarget {
|
||||
pub fn is_cubic(&self) -> bool {
|
||||
match *self {
|
||||
TexImageTarget::Texture2D => false,
|
||||
_ => true,
|
||||
}
|
||||
!matches!(*self, TexImageTarget::Texture2D)
|
||||
}
|
||||
|
||||
pub fn dimensions(self) -> u8 {
|
||||
|
|
|
@ -2520,6 +2520,7 @@ impl Window {
|
|||
|
||||
impl Window {
|
||||
#[allow(unsafe_code)]
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
runtime: Rc<Runtime>,
|
||||
script_chan: MainThreadScriptChan,
|
||||
|
|
|
@ -99,9 +99,9 @@ impl XRSystem {
|
|||
}
|
||||
}
|
||||
|
||||
impl Into<SessionMode> for XRSessionMode {
|
||||
fn into(self) -> SessionMode {
|
||||
match self {
|
||||
impl From<XRSessionMode> for SessionMode {
|
||||
fn from(mode: XRSessionMode) -> SessionMode {
|
||||
match mode {
|
||||
XRSessionMode::Immersive_vr => SessionMode::ImmersiveVR,
|
||||
XRSessionMode::Immersive_ar => SessionMode::ImmersiveAR,
|
||||
XRSessionMode::Inline => SessionMode::Inline,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue