mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +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 {
|
pub fn contains_point(&self, x: f64, y: f64, _path_transform: &Transform2D<f32>) -> bool {
|
||||||
for op in self.as_raqote().ops.iter() {
|
self.as_raqote().ops.iter().any(|op| match op {
|
||||||
match op {
|
PathOp::MoveTo(point) | PathOp::LineTo(point) => {
|
||||||
PathOp::MoveTo(point) | PathOp::LineTo(point) => {
|
point.x as f64 == x && point.y as f64 == y
|
||||||
if point.x as f64 == x && point.y as f64 == y {
|
},
|
||||||
return true;
|
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,
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn copy_to_builder(&self) -> Box<dyn GenericPathBuilder> {
|
pub fn copy_to_builder(&self) -> Box<dyn GenericPathBuilder> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue