Bug 35346 - Add a convenient center() method to IntRect
Summary: Add a convenient center() method to IntRect
Status: CLOSED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC All
: P2 Normal
Assignee: Antonio Gomes
URL:
Keywords:
Depends on:
Blocks: 18662
  Show dependency treegraph
 
Reported: 2010-02-24 08:26 PST by Antonio Gomes
Modified: 2010-04-06 02:58 PDT (History)
2 users (show)

See Also:


Attachments
patch 0.1 (1.89 KB, patch)
2010-02-24 08:39 PST, Antonio Gomes
simon.fraser: review+
tonikitoo: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Antonio Gomes 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.
Comment 1 Antonio Gomes 2010-02-24 08:39:24 PST
Created attachment 49399 [details]
patch 0.1
Comment 2 Simon Fraser (smfr) 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.
Comment 3 Antonio Gomes 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 ?
Comment 4 Simon Fraser (smfr) 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".
Comment 5 Antonio Gomes 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