CLOSED FIXED Bug 35346
Add a convenient center() method to IntRect
https://bugs.webkit.org/show_bug.cgi?id=35346
Summary Add a convenient center() method to IntRect
Antonio Gomes
Reported 2010-02-24 08:26:52 PST
FloatRect has the same and according to https://bugs.webkit.org/show_bug.cgi?id=18662#c63 that is something acceptable. "to make this code more readable. You could also add IntPoint IntRect::center() const if you like (FloatRect has one)." patch coming.
Attachments
patch 0.1 (1.89 KB, patch)
2010-02-24 08:39 PST, Antonio Gomes
simon.fraser: review+
tonikitoo: commit-queue-
Antonio Gomes
Comment 1 2010-02-24 08:39:24 PST
Created attachment 49399 [details] patch 0.1
Simon Fraser (smfr)
Comment 2 2010-02-24 09:23:38 PST
Comment on attachment 49399 [details] patch 0.1 r=me, but perhaps note in a comment that the center point suffers from rounding.
Antonio Gomes
Comment 3 2010-02-24 12:23:41 PST
simon, would + // NOTE: The result is rounded to integer values, and thus can be not the exact + // center point. + IntPoint center() const { return IntPoint(x() + width() / 2, y() + height() / 2); } be ok ?
Simon Fraser (smfr)
Comment 4 2010-02-24 12:39:03 PST
I'd change: "can be not the exact center point" to "may not be the exact center point".
Antonio Gomes
Comment 5 2010-02-25 03:49:44 PST
(In reply to comment #4) > I'd change: "can be not the exact center point" to "may not be the exact center > point". landed in r55228 thx simon and kenneth
Note You need to log in before you can comment on or make changes to this bug.