mirror of
https://github.com/servo/servo.git
synced 2025-08-14 09:55:35 +01:00
lint
Signed-off-by: Ville Lindholm <ville@lindholm.dev>
This commit is contained in:
parent
58293acd23
commit
e31e448fda
3 changed files with 44 additions and 50 deletions
|
@ -48,7 +48,7 @@ use style::properties::ComputedValues;
|
||||||
use style::selector_parser::{SelectorImpl, SelectorParser};
|
use style::selector_parser::{SelectorImpl, SelectorParser};
|
||||||
use style::stylesheets::{Stylesheet, UrlExtraData};
|
use style::stylesheets::{Stylesheet, UrlExtraData};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
use xml5ever::serialize as xml_serialize;
|
use xml5ever::{local_name, serialize as xml_serialize};
|
||||||
|
|
||||||
use super::globalscope::GlobalScope;
|
use super::globalscope::GlobalScope;
|
||||||
use crate::conversions::Convert;
|
use crate::conversions::Convert;
|
||||||
|
@ -1415,7 +1415,6 @@ impl Node {
|
||||||
// TODO: Check HTTP Content-Language header
|
// TODO: Check HTTP Content-Language header
|
||||||
})
|
})
|
||||||
.next()
|
.next()
|
||||||
.unwrap_or(String::new())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://dom.spec.whatwg.org/#assign-slotables-for-a-tree>
|
/// <https://dom.spec.whatwg.org/#assign-slotables-for-a-tree>
|
||||||
|
|
|
@ -442,8 +442,8 @@ impl Evaluatable for StepExpr {
|
||||||
|
|
||||||
if axis_step
|
if axis_step
|
||||||
.predicates
|
.predicates
|
||||||
.as_ref()
|
.predicates
|
||||||
.map_or(true, |plist| plist.predicates.is_empty())
|
.is_empty()
|
||||||
{
|
{
|
||||||
trace!(
|
trace!(
|
||||||
"[StepExpr] No predicates, returning nodes {:?}",
|
"[StepExpr] No predicates, returning nodes {:?}",
|
||||||
|
@ -461,10 +461,10 @@ impl Evaluatable for StepExpr {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_primitive(&self) -> bool {
|
fn is_primitive(&self) -> bool {
|
||||||
match self {
|
self.predicates
|
||||||
StepExpr::Filter(filter_expr) => filter_expr.is_primitive(),
|
.predicates
|
||||||
StepExpr::Axis(_) => false,
|
.is_empty() &&
|
||||||
}
|
self.primary.is_primitive()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -540,10 +540,7 @@ impl Evaluatable for PredicateExpr {
|
||||||
impl Evaluatable for FilterExpr {
|
impl Evaluatable for FilterExpr {
|
||||||
fn evaluate(&self, context: &EvaluationCtx) -> Result<Value, Error> {
|
fn evaluate(&self, context: &EvaluationCtx) -> Result<Value, Error> {
|
||||||
let primary_result = self.primary.evaluate(context)?;
|
let primary_result = self.primary.evaluate(context)?;
|
||||||
let have_predicates = self
|
let have_predicates = !self.predicates.predicates.is_empty();
|
||||||
.predicates
|
|
||||||
.as_ref()
|
|
||||||
.map_or(false, |plist| !plist.predicates.is_empty());
|
|
||||||
|
|
||||||
match (have_predicates, &primary_result) {
|
match (have_predicates, &primary_result) {
|
||||||
(false, _) => {
|
(false, _) => {
|
||||||
|
@ -571,8 +568,8 @@ impl Evaluatable for FilterExpr {
|
||||||
|
|
||||||
fn is_primitive(&self) -> bool {
|
fn is_primitive(&self) -> bool {
|
||||||
self.predicates
|
self.predicates
|
||||||
.as_ref()
|
.predicates
|
||||||
.map_or(true, |plist| plist.predicates.is_empty()) &&
|
.is_empty() &&
|
||||||
self.primary.is_primitive()
|
self.primary.is_primitive()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -553,7 +553,7 @@ fn relative_path_expr(input: &str) -> IResult<&str, Expr> {
|
||||||
all_steps.push(StepExpr::Axis(AxisStep {
|
all_steps.push(StepExpr::Axis(AxisStep {
|
||||||
axis: Axis::DescendantOrSelf,
|
axis: Axis::DescendantOrSelf,
|
||||||
node_test: NodeTest::Kind(KindTest::Node),
|
node_test: NodeTest::Kind(KindTest::Node),
|
||||||
predicates: None,
|
predicates: PredicateListExpr { predicates: vec![] },
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
all_steps.push(step);
|
all_steps.push(step);
|
||||||
|
@ -697,16 +697,12 @@ fn filter_expr(input: &str) -> IResult<&str, FilterExpr> {
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn predicate_list(input: &str) -> IResult<&str, Option<PredicateListExpr>> {
|
fn predicate_list(input: &str) -> IResult<&str, PredicateListExpr> {
|
||||||
let (input, predicates) = many0(predicate)(input)?;
|
let (input, predicates) = many0(predicate)(input)?;
|
||||||
|
|
||||||
Ok((
|
Ok((
|
||||||
input,
|
input,
|
||||||
if predicates.is_empty() {
|
PredicateListExpr { predicates },
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(PredicateListExpr { predicates })
|
|
||||||
},
|
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1013,7 +1009,7 @@ mod tests {
|
||||||
steps: vec![StepExpr::Axis(AxisStep {
|
steps: vec![StepExpr::Axis(AxisStep {
|
||||||
axis: Axis::Child,
|
axis: Axis::Child,
|
||||||
node_test: NodeTest::Kind(KindTest::PI(Some("test".to_string()))),
|
node_test: NodeTest::Kind(KindTest::PI(Some("test".to_string()))),
|
||||||
predicates: Some(PredicateListExpr {
|
predicates: PredicateListExpr {
|
||||||
predicates: vec![PredicateExpr {
|
predicates: vec![PredicateExpr {
|
||||||
expr: Expr::Path(PathExpr {
|
expr: Expr::Path(PathExpr {
|
||||||
is_absolute: false,
|
is_absolute: false,
|
||||||
|
@ -1022,11 +1018,11 @@ mod tests {
|
||||||
primary: PrimaryExpr::Literal(Literal::Numeric(
|
primary: PrimaryExpr::Literal(Literal::Numeric(
|
||||||
NumericLiteral::Integer(2),
|
NumericLiteral::Integer(2),
|
||||||
)),
|
)),
|
||||||
predicates: None,
|
predicates: PredicateListExpr { predicates: vec![] },
|
||||||
})],
|
})],
|
||||||
}),
|
}),
|
||||||
}],
|
}],
|
||||||
}),
|
},
|
||||||
})],
|
})],
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
|
@ -1044,7 +1040,7 @@ mod tests {
|
||||||
primary: PrimaryExpr::Literal(Literal::String(
|
primary: PrimaryExpr::Literal(Literal::String(
|
||||||
"hello".to_string(),
|
"hello".to_string(),
|
||||||
)),
|
)),
|
||||||
predicates: None,
|
predicates: PredicateListExpr { predicates: vec![] },
|
||||||
})],
|
})],
|
||||||
}),
|
}),
|
||||||
Expr::Path(PathExpr {
|
Expr::Path(PathExpr {
|
||||||
|
@ -1052,7 +1048,7 @@ mod tests {
|
||||||
is_descendant: false,
|
is_descendant: false,
|
||||||
steps: vec![StepExpr::Filter(FilterExpr {
|
steps: vec![StepExpr::Filter(FilterExpr {
|
||||||
primary: PrimaryExpr::Literal(Literal::String(" ".to_string())),
|
primary: PrimaryExpr::Literal(Literal::String(" ".to_string())),
|
||||||
predicates: None,
|
predicates: PredicateListExpr { predicates: vec![] },
|
||||||
})],
|
})],
|
||||||
}),
|
}),
|
||||||
Expr::Path(PathExpr {
|
Expr::Path(PathExpr {
|
||||||
|
@ -1062,11 +1058,11 @@ mod tests {
|
||||||
primary: PrimaryExpr::Literal(Literal::String(
|
primary: PrimaryExpr::Literal(Literal::String(
|
||||||
"world".to_string(),
|
"world".to_string(),
|
||||||
)),
|
)),
|
||||||
predicates: None,
|
predicates: PredicateListExpr { predicates: vec![] },
|
||||||
})],
|
})],
|
||||||
}),
|
}),
|
||||||
])),
|
])),
|
||||||
predicates: None,
|
predicates: PredicateListExpr { predicates: vec![] },
|
||||||
})],
|
})],
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
|
@ -1093,7 +1089,7 @@ mod tests {
|
||||||
steps: vec![StepExpr::Axis(AxisStep {
|
steps: vec![StepExpr::Axis(AxisStep {
|
||||||
axis: Axis::Child,
|
axis: Axis::Child,
|
||||||
node_test: NodeTest::Wildcard,
|
node_test: NodeTest::Wildcard,
|
||||||
predicates: Some(PredicateListExpr {
|
predicates: PredicateListExpr {
|
||||||
predicates: vec![PredicateExpr {
|
predicates: vec![PredicateExpr {
|
||||||
expr: Expr::Path(PathExpr {
|
expr: Expr::Path(PathExpr {
|
||||||
is_absolute: false,
|
is_absolute: false,
|
||||||
|
@ -1109,7 +1105,9 @@ mod tests {
|
||||||
prefix: None,
|
prefix: None,
|
||||||
local_part: "class".to_string(),
|
local_part: "class".to_string(),
|
||||||
}),
|
}),
|
||||||
predicates: None,
|
predicates: PredicateListExpr {
|
||||||
|
predicates: vec![]
|
||||||
|
},
|
||||||
})],
|
})],
|
||||||
})),
|
})),
|
||||||
Box::new(Expr::Path(PathExpr {
|
Box::new(Expr::Path(PathExpr {
|
||||||
|
@ -1119,15 +1117,15 @@ mod tests {
|
||||||
primary: PrimaryExpr::Literal(Literal::String(
|
primary: PrimaryExpr::Literal(Literal::String(
|
||||||
"test".to_string(),
|
"test".to_string(),
|
||||||
)),
|
)),
|
||||||
predicates: None,
|
predicates: PredicateListExpr { predicates: vec![] },
|
||||||
})],
|
})],
|
||||||
})),
|
})),
|
||||||
)),
|
)),
|
||||||
predicates: None,
|
predicates: PredicateListExpr { predicates: vec![] },
|
||||||
})],
|
})],
|
||||||
}),
|
}),
|
||||||
}],
|
}],
|
||||||
}),
|
},
|
||||||
})],
|
})],
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
|
@ -1143,7 +1141,7 @@ mod tests {
|
||||||
prefix: None,
|
prefix: None,
|
||||||
local_part: "div".to_string(),
|
local_part: "div".to_string(),
|
||||||
}),
|
}),
|
||||||
predicates: Some(PredicateListExpr {
|
predicates: PredicateListExpr {
|
||||||
predicates: vec![PredicateExpr {
|
predicates: vec![PredicateExpr {
|
||||||
expr: Expr::Relational(
|
expr: Expr::Relational(
|
||||||
Box::new(Expr::Path(PathExpr {
|
Box::new(Expr::Path(PathExpr {
|
||||||
|
@ -1153,7 +1151,7 @@ mod tests {
|
||||||
primary: PrimaryExpr::Function(
|
primary: PrimaryExpr::Function(
|
||||||
CoreFunction::Position,
|
CoreFunction::Position,
|
||||||
),
|
),
|
||||||
predicates: None,
|
predicates: PredicateListExpr { predicates: vec![] },
|
||||||
})],
|
})],
|
||||||
})),
|
})),
|
||||||
RelationalOp::Gt,
|
RelationalOp::Gt,
|
||||||
|
@ -1164,28 +1162,28 @@ mod tests {
|
||||||
primary: PrimaryExpr::Literal(Literal::Numeric(
|
primary: PrimaryExpr::Literal(Literal::Numeric(
|
||||||
NumericLiteral::Integer(1),
|
NumericLiteral::Integer(1),
|
||||||
)),
|
)),
|
||||||
predicates: None,
|
predicates: PredicateListExpr { predicates: vec![] },
|
||||||
})],
|
})],
|
||||||
})),
|
})),
|
||||||
),
|
),
|
||||||
}],
|
}],
|
||||||
}),
|
},
|
||||||
}),
|
}),
|
||||||
StepExpr::Axis(AxisStep {
|
StepExpr::Axis(AxisStep {
|
||||||
axis: Axis::Child,
|
axis: Axis::Child,
|
||||||
node_test: NodeTest::Wildcard,
|
node_test: NodeTest::Wildcard,
|
||||||
predicates: Some(PredicateListExpr {
|
predicates: PredicateListExpr {
|
||||||
predicates: vec![PredicateExpr {
|
predicates: vec![PredicateExpr {
|
||||||
expr: Expr::Path(PathExpr {
|
expr: Expr::Path(PathExpr {
|
||||||
is_absolute: false,
|
is_absolute: false,
|
||||||
is_descendant: false,
|
is_descendant: false,
|
||||||
steps: vec![StepExpr::Filter(FilterExpr {
|
steps: vec![StepExpr::Filter(FilterExpr {
|
||||||
primary: PrimaryExpr::Function(CoreFunction::Last),
|
primary: PrimaryExpr::Function(CoreFunction::Last),
|
||||||
predicates: None,
|
predicates: PredicateListExpr { predicates: vec![] },
|
||||||
})],
|
})],
|
||||||
}),
|
}),
|
||||||
}],
|
}],
|
||||||
}),
|
},
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
|
@ -1202,7 +1200,7 @@ mod tests {
|
||||||
prefix: None,
|
prefix: None,
|
||||||
local_part: "mu".to_string(),
|
local_part: "mu".to_string(),
|
||||||
}),
|
}),
|
||||||
predicates: Some(PredicateListExpr {
|
predicates: PredicateListExpr {
|
||||||
predicates: vec![PredicateExpr {
|
predicates: vec![PredicateExpr {
|
||||||
expr: Expr::Equality(
|
expr: Expr::Equality(
|
||||||
Box::new(Expr::Path(PathExpr {
|
Box::new(Expr::Path(PathExpr {
|
||||||
|
@ -1214,7 +1212,7 @@ mod tests {
|
||||||
prefix: Some("xml".to_string()),
|
prefix: Some("xml".to_string()),
|
||||||
local_part: "id".to_string(),
|
local_part: "id".to_string(),
|
||||||
}),
|
}),
|
||||||
predicates: None,
|
predicates: PredicateListExpr { predicates: vec![] },
|
||||||
})],
|
})],
|
||||||
})),
|
})),
|
||||||
EqualityOp::Eq,
|
EqualityOp::Eq,
|
||||||
|
@ -1225,17 +1223,17 @@ mod tests {
|
||||||
primary: PrimaryExpr::Literal(Literal::String(
|
primary: PrimaryExpr::Literal(Literal::String(
|
||||||
"id1".to_string(),
|
"id1".to_string(),
|
||||||
)),
|
)),
|
||||||
predicates: None,
|
predicates: PredicateListExpr { predicates: vec![] },
|
||||||
})],
|
})],
|
||||||
})),
|
})),
|
||||||
),
|
),
|
||||||
}],
|
}],
|
||||||
}),
|
},
|
||||||
}),
|
}),
|
||||||
StepExpr::Axis(AxisStep {
|
StepExpr::Axis(AxisStep {
|
||||||
axis: Axis::DescendantOrSelf, // Represents the second '//'
|
axis: Axis::DescendantOrSelf, // Represents the second '//'
|
||||||
node_test: NodeTest::Kind(KindTest::Node),
|
node_test: NodeTest::Kind(KindTest::Node),
|
||||||
predicates: None,
|
predicates: PredicateListExpr { predicates: vec![] },
|
||||||
}),
|
}),
|
||||||
StepExpr::Axis(AxisStep {
|
StepExpr::Axis(AxisStep {
|
||||||
axis: Axis::Child,
|
axis: Axis::Child,
|
||||||
|
@ -1243,7 +1241,7 @@ mod tests {
|
||||||
prefix: None,
|
prefix: None,
|
||||||
local_part: "rho".to_string(),
|
local_part: "rho".to_string(),
|
||||||
}),
|
}),
|
||||||
predicates: Some(PredicateListExpr {
|
predicates: PredicateListExpr {
|
||||||
predicates: vec![
|
predicates: vec![
|
||||||
PredicateExpr {
|
PredicateExpr {
|
||||||
expr: Expr::Path(PathExpr {
|
expr: Expr::Path(PathExpr {
|
||||||
|
@ -1255,7 +1253,7 @@ mod tests {
|
||||||
prefix: None,
|
prefix: None,
|
||||||
local_part: "title".to_string(),
|
local_part: "title".to_string(),
|
||||||
}),
|
}),
|
||||||
predicates: None,
|
predicates: PredicateListExpr { predicates: vec![] },
|
||||||
})],
|
})],
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
@ -1270,7 +1268,7 @@ mod tests {
|
||||||
prefix: Some("xml".to_string()),
|
prefix: Some("xml".to_string()),
|
||||||
local_part: "lang".to_string(),
|
local_part: "lang".to_string(),
|
||||||
}),
|
}),
|
||||||
predicates: None,
|
predicates: PredicateListExpr { predicates: vec![] },
|
||||||
})],
|
})],
|
||||||
})),
|
})),
|
||||||
EqualityOp::Eq,
|
EqualityOp::Eq,
|
||||||
|
@ -1281,13 +1279,13 @@ mod tests {
|
||||||
primary: PrimaryExpr::Literal(Literal::String(
|
primary: PrimaryExpr::Literal(Literal::String(
|
||||||
"en-GB".to_string(),
|
"en-GB".to_string(),
|
||||||
)),
|
)),
|
||||||
predicates: None,
|
predicates: PredicateListExpr { predicates: vec![] },
|
||||||
})],
|
})],
|
||||||
})),
|
})),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}),
|
},
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue