Bug 35346

Summary: Add a convenient center() method to IntRect
Product: WebKit Reporter: Antonio Gomes <tonikitoo>
Component: WebCore Misc.Assignee: Antonio Gomes <tonikitoo>
Status: CLOSED FIXED    
Severity: Normal CC: hausmann, simon.fraser
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: All   
Bug Depends on:    
Bug Blocks: 18662    
Attachments:
Description Flags
patch 0.1 simon.fraser: review+, tonikitoo: commit-queue-

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