-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[geometry] DOMRect: use of unrestricted doubles - min(x, NaN) #222
Comments
The email was about DOMRect but it looks like it applies for DOMQuad also.
|
The entire conversation:
@smfr what did you end up implementing? The |
The Demo: http://software.hixie.ch/utilities/js/live-dom-viewer/saved/5914
logs |
(Filed https://bugzilla.mozilla.org/show_bug.cgi?id=1454622 about |
So I think the relevant testcase here is sort of like this:
here Firefox nightly and Chrome dev alert It does seem to me that reliably returning |
Currently in some geometry classes we are using std::min() and std::max() over numbers specified in IDL as "unrestricted double", meaning they could take the special value NaN. These STL helpers internally use the < operator, as in std::min(a, b) = a < b ? a : b. However, the IEEE 794 < operator always returns false when _either_ operand is NaN, so the result of min(0, NaN) and min(NaN, 0) could, confusingly, be different. This is difference is in fact visible through JavaScript. For instance, new DOMQuad({ x: NaN }, { x: 0 }, { x: 0 }, { x: 0 }).getBounds().x gives NaN, but new DOMQuad({ x: 0 }, { x: 0 }, { x: 0 }, { x: NaN }).getBounds().x gives 0. A similar problem is present for DOMRect/DOMRectReadOnly as well. This CL implements the rough consensus in [1][2], which is to adopt semantics similar to JavaScript's Math.min() and Math.max(), which propagates NaN from either operand. This also aligns our behavior with WebKit. [1]: w3c/fxtf-drafts#222 [2]: w3c/fxtf-drafts#395 Fixed: 1066499 Change-Id: Id9a4282fa00dafcfe9c5616643efbe2eaace411e
https://drafts.fxtf.org/geometry/#DOMQuad
See http://www.w3.org/mid/CAGN7qDCS4U=aa2bVec1OCUVSMECAgUDwZT5fSj8HS1Ue6AJozw@mail.gmail.com from @smfr
cc @cabanier
The text was updated successfully, but these errors were encountered: