Create implicit constructors on floating-point types taking integer types

RESOLVED FIXED in mozilla11

Status

()

Core
Graphics
RESOLVED FIXED
6 years ago
5 years ago

People

(Reporter: Joe Drew (not getting mail), Assigned: Joe Drew (not getting mail))

Tracking

Trunk
mozilla11
x86
Mac OS X
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment, 1 obsolete attachment)

(Assignee)

Description

6 years ago
Created attachment 558971 [details] [diff] [review]
Implicitly convert

This patch lets us implicitly convert from an Int{Point,Size,Rect} to a {Point,Size,Rect}, which is non-lossy and therefore should be supported!

It also corrects a typo in the template parameters for IntPoint:

-struct IntPoint :
-  public BasePoint<int32_t, Point> {
-  typedef BasePoint<int32_t, Point> Super;
Attachment #558971 - Flags: review?(roc)
Attachment #558971 - Flags: review?(roc) → review+
(Assignee)

Comment 1

6 years ago
Created attachment 565709 [details] [diff] [review]
Explicitly convert

Bas rightfully points out that int -> float is lossy, since float can only represent 23 bits of fraction. (int->double would be non-lossy, though.) Therefore, I'm going to commit an explicit version of this patch. Carrying over r+ since this is strictly safer.
Assignee: nobody → joe
Attachment #558971 - Attachment is obsolete: true
Attachment #565709 - Flags: review+
https://hg.mozilla.org/mozilla-central/rev/677fe017e6a0
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla11

Updated

6 years ago
Blocks: 703028
You need to log in before you can comment on or make changes to this bug.