geometry: Propagate NaN in min/max operations
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 [1], 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]: https://github.com/w3c/fxtf-drafts/pull/395 Fixed: 1066499 Change-Id: Id9a4282fa00dafcfe9c5616643efbe2eaace411e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2129889 Commit-Queue: Chris Harrelson <chrishtr@chromium.org> Reviewed-by:Chris Harrelson <chrishtr@chromium.org> Reviewed-by:
Jinho Bang <jinho.bang@samsung.com> Cr-Commit-Position: refs/heads/master@{#755373}
Showing
Please register or sign in to comment