mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Refactor Path::contains_point() using any()
This commit is contained in:
parent
ee7f3dbc46
commit
89b8bd516f
1 changed files with 8 additions and 21 deletions
|
@ -185,27 +185,14 @@ impl Path {
|
|||
}
|
||||
|
||||
pub fn contains_point(&self, x: f64, y: f64, _path_transform: &Transform2D<f32>) -> bool {
|
||||
for op in self.as_raqote().ops.iter() {
|
||||
match op {
|
||||
PathOp::MoveTo(point) | PathOp::LineTo(point) => {
|
||||
if point.x as f64 == x && point.y as f64 == y {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
PathOp::QuadTo(_, point) => {
|
||||
if point.x as f64 == x && point.y as f64 == y {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
PathOp::CubicTo(_, _, point) => {
|
||||
if point.x as f64 == x && point.y as f64 == y {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
false
|
||||
self.as_raqote().ops.iter().any(|op| match op {
|
||||
PathOp::MoveTo(point) | PathOp::LineTo(point) => {
|
||||
point.x as f64 == x && point.y as f64 == y
|
||||
},
|
||||
PathOp::QuadTo(_, point) => point.x as f64 == x && point.y as f64 == y,
|
||||
PathOp::CubicTo(_, _, point) => point.x as f64 == x && point.y as f64 == y,
|
||||
_ => false,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn copy_to_builder(&self) -> Box<dyn GenericPathBuilder> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue