mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Fix some rust-clippy violations
This commit is contained in:
parent
1dfc0481ef
commit
16fa9cabc9
11 changed files with 37 additions and 42 deletions
|
@ -1024,17 +1024,12 @@ impl BlockFlow {
|
||||||
let mut candidate_block_size_iterator = CandidateBSizeIterator::new(
|
let mut candidate_block_size_iterator = CandidateBSizeIterator::new(
|
||||||
&self.fragment,
|
&self.fragment,
|
||||||
self.base.block_container_explicit_block_size);
|
self.base.block_container_explicit_block_size);
|
||||||
loop {
|
while let Some(candidate_block_size) = candidate_block_size_iterator.next() {
|
||||||
match candidate_block_size_iterator.next() {
|
candidate_block_size_iterator.candidate_value =
|
||||||
Some(candidate_block_size) => {
|
match candidate_block_size {
|
||||||
candidate_block_size_iterator.candidate_value =
|
MaybeAuto::Auto => block_size,
|
||||||
match candidate_block_size {
|
MaybeAuto::Specified(value) => value
|
||||||
MaybeAuto::Auto => block_size,
|
|
||||||
MaybeAuto::Specified(value) => value
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
None => break,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adjust `cur_b` as necessary to account for the explicitly-specified block-size.
|
// Adjust `cur_b` as necessary to account for the explicitly-specified block-size.
|
||||||
|
|
|
@ -562,8 +562,8 @@ impl VirtualMethods for HTMLScriptElement {
|
||||||
|
|
||||||
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
|
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
|
||||||
self.super_type().unwrap().attribute_mutated(attr, mutation);
|
self.super_type().unwrap().attribute_mutated(attr, mutation);
|
||||||
match attr.local_name() {
|
match *attr.local_name() {
|
||||||
&atom!("src") => {
|
atom!("src") => {
|
||||||
if let AttributeMutation::Set(_) = mutation {
|
if let AttributeMutation::Set(_) = mutation {
|
||||||
if !self.parser_inserted.get() && self.upcast::<Node>().is_in_doc() {
|
if !self.parser_inserted.get() && self.upcast::<Node>().is_in_doc() {
|
||||||
self.prepare();
|
self.prepare();
|
||||||
|
|
|
@ -205,8 +205,8 @@ impl VirtualMethods for HTMLSelectElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_plain_attribute(&self, local_name: &Atom, value: DOMString) -> AttrValue {
|
fn parse_plain_attribute(&self, local_name: &Atom, value: DOMString) -> AttrValue {
|
||||||
match local_name {
|
match *local_name {
|
||||||
&atom!("size") => AttrValue::from_u32(value, DEFAULT_SELECT_SIZE),
|
atom!("size") => AttrValue::from_u32(value, DEFAULT_SELECT_SIZE),
|
||||||
_ => self.super_type().unwrap().parse_plain_attribute(local_name, value),
|
_ => self.super_type().unwrap().parse_plain_attribute(local_name, value),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,18 +107,18 @@ impl VirtualMethods for HTMLTableCellElement {
|
||||||
|
|
||||||
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
|
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
|
||||||
self.super_type().unwrap().attribute_mutated(attr, mutation);
|
self.super_type().unwrap().attribute_mutated(attr, mutation);
|
||||||
match attr.local_name() {
|
match *attr.local_name() {
|
||||||
&atom!(bgcolor) => {
|
atom!(bgcolor) => {
|
||||||
self.background_color.set(mutation.new_value(attr).and_then(|value| {
|
self.background_color.set(mutation.new_value(attr).and_then(|value| {
|
||||||
str::parse_legacy_color(&value).ok()
|
str::parse_legacy_color(&value).ok()
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
&atom!(colspan) => {
|
atom!(colspan) => {
|
||||||
self.colspan.set(mutation.new_value(attr).map(|value| {
|
self.colspan.set(mutation.new_value(attr).map(|value| {
|
||||||
max(DEFAULT_COLSPAN, value.as_uint())
|
max(DEFAULT_COLSPAN, value.as_uint())
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
&atom!(width) => {
|
atom!(width) => {
|
||||||
let width = mutation.new_value(attr).map(|value| {
|
let width = mutation.new_value(attr).map(|value| {
|
||||||
str::parse_length(&value)
|
str::parse_length(&value)
|
||||||
});
|
});
|
||||||
|
@ -129,8 +129,8 @@ impl VirtualMethods for HTMLTableCellElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_plain_attribute(&self, local_name: &Atom, value: DOMString) -> AttrValue {
|
fn parse_plain_attribute(&self, local_name: &Atom, value: DOMString) -> AttrValue {
|
||||||
match local_name {
|
match *local_name {
|
||||||
&atom!("colspan") => AttrValue::from_u32(value, DEFAULT_COLSPAN),
|
atom!("colspan") => AttrValue::from_u32(value, DEFAULT_COLSPAN),
|
||||||
_ => self.super_type().unwrap().parse_plain_attribute(local_name, value),
|
_ => self.super_type().unwrap().parse_plain_attribute(local_name, value),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,24 +141,24 @@ impl VirtualMethods for HTMLTableElement {
|
||||||
|
|
||||||
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
|
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
|
||||||
self.super_type().unwrap().attribute_mutated(attr, mutation);
|
self.super_type().unwrap().attribute_mutated(attr, mutation);
|
||||||
match attr.local_name() {
|
match *attr.local_name() {
|
||||||
&atom!(bgcolor) => {
|
atom!(bgcolor) => {
|
||||||
self.background_color.set(mutation.new_value(attr).and_then(|value| {
|
self.background_color.set(mutation.new_value(attr).and_then(|value| {
|
||||||
str::parse_legacy_color(&value).ok()
|
str::parse_legacy_color(&value).ok()
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
&atom!(border) => {
|
atom!(border) => {
|
||||||
// According to HTML5 § 14.3.9, invalid values map to 1px.
|
// According to HTML5 § 14.3.9, invalid values map to 1px.
|
||||||
self.border.set(mutation.new_value(attr).map(|value| {
|
self.border.set(mutation.new_value(attr).map(|value| {
|
||||||
str::parse_unsigned_integer(value.chars()).unwrap_or(1)
|
str::parse_unsigned_integer(value.chars()).unwrap_or(1)
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
&atom!(cellspacing) => {
|
atom!(cellspacing) => {
|
||||||
self.cellspacing.set(mutation.new_value(attr).and_then(|value| {
|
self.cellspacing.set(mutation.new_value(attr).and_then(|value| {
|
||||||
str::parse_unsigned_integer(value.chars())
|
str::parse_unsigned_integer(value.chars())
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
&atom!(width) => {
|
atom!(width) => {
|
||||||
let width = mutation.new_value(attr).map(|value| {
|
let width = mutation.new_value(attr).map(|value| {
|
||||||
str::parse_length(&value)
|
str::parse_length(&value)
|
||||||
});
|
});
|
||||||
|
@ -169,8 +169,8 @@ impl VirtualMethods for HTMLTableElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_plain_attribute(&self, local_name: &Atom, value: DOMString) -> AttrValue {
|
fn parse_plain_attribute(&self, local_name: &Atom, value: DOMString) -> AttrValue {
|
||||||
match local_name {
|
match *local_name {
|
||||||
&atom!("border") => AttrValue::from_u32(value, 1),
|
atom!("border") => AttrValue::from_u32(value, 1),
|
||||||
_ => self.super_type().unwrap().parse_plain_attribute(local_name, value),
|
_ => self.super_type().unwrap().parse_plain_attribute(local_name, value),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,8 +102,8 @@ impl VirtualMethods for HTMLTableRowElement {
|
||||||
|
|
||||||
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
|
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
|
||||||
self.super_type().unwrap().attribute_mutated(attr, mutation);
|
self.super_type().unwrap().attribute_mutated(attr, mutation);
|
||||||
match attr.local_name() {
|
match *attr.local_name() {
|
||||||
&atom!(bgcolor) => {
|
atom!(bgcolor) => {
|
||||||
self.background_color.set(mutation.new_value(attr).and_then(|value| {
|
self.background_color.set(mutation.new_value(attr).and_then(|value| {
|
||||||
str::parse_legacy_color(&value).ok()
|
str::parse_legacy_color(&value).ok()
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -87,8 +87,8 @@ impl VirtualMethods for HTMLTableSectionElement {
|
||||||
|
|
||||||
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
|
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
|
||||||
self.super_type().unwrap().attribute_mutated(attr, mutation);
|
self.super_type().unwrap().attribute_mutated(attr, mutation);
|
||||||
match attr.local_name() {
|
match *attr.local_name() {
|
||||||
&atom!(bgcolor) => {
|
atom!(bgcolor) => {
|
||||||
self.background_color.set(mutation.new_value(attr).and_then(|value| {
|
self.background_color.set(mutation.new_value(attr).and_then(|value| {
|
||||||
str::parse_legacy_color(&value).ok()
|
str::parse_legacy_color(&value).ok()
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -246,8 +246,8 @@ impl VirtualMethods for HTMLTextAreaElement {
|
||||||
|
|
||||||
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
|
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
|
||||||
self.super_type().unwrap().attribute_mutated(attr, mutation);
|
self.super_type().unwrap().attribute_mutated(attr, mutation);
|
||||||
match attr.local_name() {
|
match *attr.local_name() {
|
||||||
&atom!(disabled) => {
|
atom!(disabled) => {
|
||||||
let el = self.upcast::<Element>();
|
let el = self.upcast::<Element>();
|
||||||
match mutation {
|
match mutation {
|
||||||
AttributeMutation::Set(_) => {
|
AttributeMutation::Set(_) => {
|
||||||
|
@ -261,13 +261,13 @@ impl VirtualMethods for HTMLTextAreaElement {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
&atom!(cols) => {
|
atom!(cols) => {
|
||||||
let cols = mutation.new_value(attr).map(|value| {
|
let cols = mutation.new_value(attr).map(|value| {
|
||||||
value.as_uint()
|
value.as_uint()
|
||||||
});
|
});
|
||||||
self.cols.set(cols.unwrap_or(DEFAULT_COLS));
|
self.cols.set(cols.unwrap_or(DEFAULT_COLS));
|
||||||
},
|
},
|
||||||
&atom!(rows) => {
|
atom!(rows) => {
|
||||||
let rows = mutation.new_value(attr).map(|value| {
|
let rows = mutation.new_value(attr).map(|value| {
|
||||||
value.as_uint()
|
value.as_uint()
|
||||||
});
|
});
|
||||||
|
@ -286,9 +286,9 @@ impl VirtualMethods for HTMLTextAreaElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue {
|
fn parse_plain_attribute(&self, name: &Atom, value: DOMString) -> AttrValue {
|
||||||
match name {
|
match *name {
|
||||||
&atom!("cols") => AttrValue::from_limited_u32(value, DEFAULT_COLS),
|
atom!("cols") => AttrValue::from_limited_u32(value, DEFAULT_COLS),
|
||||||
&atom!("rows") => AttrValue::from_limited_u32(value, DEFAULT_ROWS),
|
atom!("rows") => AttrValue::from_limited_u32(value, DEFAULT_ROWS),
|
||||||
_ => self.super_type().unwrap().parse_plain_attribute(name, value),
|
_ => self.super_type().unwrap().parse_plain_attribute(name, value),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -885,8 +885,8 @@ fn first_node_not_in<I>(mut nodes: I, not_in: &[NodeOrString]) -> Option<Root<No
|
||||||
{
|
{
|
||||||
nodes.find(|node| {
|
nodes.find(|node| {
|
||||||
not_in.iter().all(|n| {
|
not_in.iter().all(|n| {
|
||||||
match n {
|
match *n {
|
||||||
&NodeOrString::eNode(ref n) => n != node,
|
NodeOrString::eNode(ref n) => n != node,
|
||||||
_ => true,
|
_ => true,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -809,7 +809,7 @@ fn bp_position(a_node: &Node, a_offset: u32,
|
||||||
} else if position & NodeConstants::DOCUMENT_POSITION_CONTAINS != 0 {
|
} else if position & NodeConstants::DOCUMENT_POSITION_CONTAINS != 0 {
|
||||||
// Step 3-1, 3-2.
|
// Step 3-1, 3-2.
|
||||||
let mut b_ancestors = b_node.inclusive_ancestors();
|
let mut b_ancestors = b_node.inclusive_ancestors();
|
||||||
let ref child = b_ancestors.find(|child| {
|
let child = b_ancestors.find(|child| {
|
||||||
child.r().GetParentNode().unwrap().r() == a_node
|
child.r().GetParentNode().unwrap().r() == a_node
|
||||||
}).unwrap();
|
}).unwrap();
|
||||||
// Step 3-3.
|
// Step 3-3.
|
||||||
|
|
|
@ -78,7 +78,7 @@ impl Ord for Timer {
|
||||||
fn cmp(&self, other: &Timer) -> Ordering {
|
fn cmp(&self, other: &Timer) -> Ordering {
|
||||||
match self.next_call.cmp(&other.next_call).reverse() {
|
match self.next_call.cmp(&other.next_call).reverse() {
|
||||||
Ordering::Equal => self.handle.cmp(&other.handle).reverse(),
|
Ordering::Equal => self.handle.cmp(&other.handle).reverse(),
|
||||||
res @ _ => res
|
res => res
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue