mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Auto merge of #8797 - cheba:rect-contains, r=Manishearth
Replaced rect_contains_point with Rect.contains() This is a proposed in servo/servo#8791 clean up. Fixes #8791. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8797) <!-- Reviewable:end -->
This commit is contained in:
commit
68922e0ac2
2 changed files with 4 additions and 14 deletions
|
@ -397,7 +397,7 @@ impl DisplayList {
|
||||||
// Clipped out.
|
// Clipped out.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if !geometry::rect_contains_point(item.bounds(), point) {
|
if !item.bounds().contains(&point) {
|
||||||
// Can't possibly hit.
|
// Can't possibly hit.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -420,7 +420,7 @@ impl DisplayList {
|
||||||
border.base.bounds.size.height -
|
border.base.bounds.size.height -
|
||||||
(border.border_widths.top +
|
(border.border_widths.top +
|
||||||
border.border_widths.bottom)));
|
border.border_widths.bottom)));
|
||||||
if geometry::rect_contains_point(interior_rect, point) {
|
if interior_rect.contains(&point) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1089,8 +1089,8 @@ impl ClippingRegion {
|
||||||
/// This is a quick, not a precise, test; it can yield false positives.
|
/// This is a quick, not a precise, test; it can yield false positives.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn might_intersect_point(&self, point: &Point2D<Au>) -> bool {
|
pub fn might_intersect_point(&self, point: &Point2D<Au>) -> bool {
|
||||||
geometry::rect_contains_point(self.main, *point) &&
|
self.main.contains(point) &&
|
||||||
self.complex.iter().all(|complex| geometry::rect_contains_point(complex.rect, *point))
|
self.complex.iter().all(|complex| complex.rect.contains(point))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true if this clipping region might intersect the given rectangle and false
|
/// Returns true if this clipping region might intersect the given rectangle and false
|
||||||
|
|
|
@ -75,16 +75,6 @@ pub static MAX_RECT: Rect<Au> = Rect {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Returns true if the rect contains the given point. Points on the top or left sides of the rect
|
|
||||||
/// are considered inside the rectangle, while points on the right or bottom sides of the rect are
|
|
||||||
/// not considered inside the rectangle.
|
|
||||||
pub fn rect_contains_point<T>(rect: Rect<T>, point: Point2D<T>) -> bool
|
|
||||||
where T: PartialOrd + Add<T, Output=T>
|
|
||||||
{
|
|
||||||
point.x >= rect.origin.x && point.x < rect.origin.x + rect.size.width &&
|
|
||||||
point.y >= rect.origin.y && point.y < rect.origin.y + rect.size.height
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A helper function to convert a rect of `f32` pixels to a rect of app units.
|
/// A helper function to convert a rect of `f32` pixels to a rect of app units.
|
||||||
pub fn f32_rect_to_au_rect(rect: Rect<f32>) -> Rect<Au> {
|
pub fn f32_rect_to_au_rect(rect: Rect<f32>) -> Rect<Au> {
|
||||||
Rect::new(Point2D::new(Au::from_f32_px(rect.origin.x), Au::from_f32_px(rect.origin.y)),
|
Rect::new(Point2D::new(Au::from_f32_px(rect.origin.x), Au::from_f32_px(rect.origin.y)),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue