Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign up(breaking change) Some Rect and Box adjustments #459
Conversation
|
Let me know if the For WebRender I want to eventually replace most uses of Rect with Box2D anyway because it has less precision loss and is faster for the majority of what we do in WebRender (anything except translating boxes). |
| @@ -215,13 +215,13 @@ where | |||
| T: Copy + PartialOrd + Add<T, Output = T> + Sub<T, Output = T>, | |||
| { | |||
| #[inline] | |||
| pub fn intersection(&self, other: &Self) -> Option<Self> { | |||
| pub fn try_intersection(&self, other: &Self) -> Option<NonEmpty<Self>> { | |||
This comment has been minimized.
This comment has been minimized.
kvark
Jul 23, 2020
Member
I don't think try_ returning Option is idiomatic. Perhaps, we could call it just intersect?
…into intersection.
|
As discussed, changed the PR so that we have
I don't feel like rebasing the other two commits over the last change, but if having the back-and-forth in the commit log bothers you I can squash it into one. With this Rect::intersection keeps the same name so it won't cause as much breakage downstream. |
|
@bors-servo r+ |
|
|
|
Oh noes I meant r=kvark. It's one of these days. |
|
|
nical commentedJul 23, 2020
A few rect/box related adjustments:
Rect::intersection -> Option<Self>intoRect::try_intersection -> Option<NonEmpty<Self>to match Box2D's API and get the extra typeness ofNonEmpty. That's main ly for consistency but I would understand if we feel like it's too annoying a change becase webrender (and perhaps servo layout?) code is riddled with intersection checks. Let me know.Box2D::try_intersectioncheck that the box is empty instead of just negative. That was an oversight, we'd previously getSome(intersection)with intersection being an empty rect (or a bad rect with NaNs) which I believe isn't what we want.