|
21 | 21 |
|
22 | 22 | using namespace v8;
|
23 | 23 |
|
24 |
| -// Windows doesn't support the C99 names for these |
25 |
| -#ifdef _MSC_VER |
26 |
| -#define isnan(x) _isnan(x) |
27 |
| -#define isinf(x) (!_finite(x)) |
28 |
| -#endif |
29 |
| - |
30 |
| -#ifndef isnan |
31 |
| -#define isnan(x) std::isnan(x) |
32 |
| -#define isinf(x) std::isinf(x) |
33 |
| -#endif |
34 |
| - |
35 | 24 | Nan::Persistent<FunctionTemplate> Context2d::constructor;
|
36 | 25 |
|
37 | 26 | /*
|
@@ -77,9 +66,7 @@ inline static bool checkArgs(const Nan::FunctionCallbackInfo<Value> &info, doubl
|
77 | 66 | double val = Nan::To<double>(info[i]).FromMaybe(0);
|
78 | 67 |
|
79 | 68 | if (areArgsValid) {
|
80 |
| - if (val != val || |
81 |
| - val == std::numeric_limits<double>::infinity() || |
82 |
| - val == -std::numeric_limits<double>::infinity()) { |
| 69 | + if (!std::isfinite(val)) { |
83 | 70 | // We should continue the loop instead of returning immediately
|
84 | 71 | // See https://html.spec.whatwg.org/multipage/canvas.html
|
85 | 72 |
|
@@ -2787,7 +2774,7 @@ NAN_METHOD(Context2d::SetLineDash) {
|
2787 | 2774 | if (!d->IsNumber()) return;
|
2788 | 2775 | a[i] = Nan::To<double>(d).FromMaybe(0);
|
2789 | 2776 | if (a[i] == 0) zero_dashes++;
|
2790 |
| - if (a[i] < 0 || isnan(a[i]) || isinf(a[i])) return; |
| 2777 | + if (a[i] < 0 || !std::isfinite(a[i])) return; |
2791 | 2778 | }
|
2792 | 2779 |
|
2793 | 2780 | Context2d *context = Nan::ObjectWrap::Unwrap<Context2d>(info.This());
|
@@ -2827,7 +2814,7 @@ NAN_METHOD(Context2d::GetLineDash) {
|
2827 | 2814 | */
|
2828 | 2815 | NAN_SETTER(Context2d::SetLineDashOffset) {
|
2829 | 2816 | double offset = Nan::To<double>(value).FromMaybe(0);
|
2830 |
| - if (isnan(offset) || isinf(offset)) return; |
| 2817 | + if (!std::isfinite(offset)) return; |
2831 | 2818 |
|
2832 | 2819 | Context2d *context = Nan::ObjectWrap::Unwrap<Context2d>(info.This());
|
2833 | 2820 | cairo_t *ctx = context->context();
|
|
0 commit comments