| OLD | NEW |
| 1 // Copyright 2011, Google Inc. | 1 // Copyright 2011, Google Inc. |
| 2 // All rights reserved. | 2 // All rights reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
| 9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
| 10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 #include "DartBlob.h" | 33 #include "DartBlob.h" |
| 34 #include "DartHTMLElement.h" | 34 #include "DartHTMLElement.h" |
| 35 #include "DartIDBKeyRange.h" | 35 #include "DartIDBKeyRange.h" |
| 36 #include "DartImageData.h" | 36 #include "DartImageData.h" |
| 37 #include "DartMessagePort.h" | 37 #include "DartMessagePort.h" |
| 38 #include "bindings/dart/DartDOMData.h" | 38 #include "bindings/dart/DartDOMData.h" |
| 39 #include "bindings/dart/DartHandleProxy.h" | 39 #include "bindings/dart/DartHandleProxy.h" |
| 40 #include "bindings/dart/V8Converter.h" | 40 #include "bindings/dart/V8Converter.h" |
| 41 #include "bindings/v8/ScriptController.h" | 41 #include "bindings/v8/ScriptController.h" |
| 42 #include "bindings/v8/SerializedScriptValue.h" | 42 #include "bindings/v8/SerializedScriptValue.h" |
| 43 #include "bindings/v8/V8Binding.h" |
| 43 #include "bindings/v8/V8PerIsolateData.h" | 44 #include "bindings/v8/V8PerIsolateData.h" |
| 44 #include "core/dom/Document.h" | 45 #include "core/dom/Document.h" |
| 45 #include "core/html/canvas/DataView.h" | 46 #include "core/html/canvas/DataView.h" |
| 46 #include "core/inspector/ScriptArguments.h" | 47 #include "core/inspector/ScriptArguments.h" |
| 47 #include "core/inspector/ScriptCallStack.h" | 48 #include "core/inspector/ScriptCallStack.h" |
| 48 #include "core/loader/FrameLoader.h" | 49 #include "core/loader/FrameLoader.h" |
| 49 #include "core/page/DOMWindow.h" | 50 #include "core/page/DOMWindow.h" |
| 50 #include "core/page/Frame.h" | 51 #include "core/page/Frame.h" |
| 51 #include "core/platform/network/ResourceRequest.h" | 52 #include "core/platform/network/ResourceRequest.h" |
| 52 #include "core/platform/sql/SQLValue.h" | 53 #include "core/platform/sql/SQLValue.h" |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 return 0; | 290 return 0; |
| 290 if (value < 0) { | 291 if (value < 0) { |
| 291 exception = Dart_NewStringFromCString("value out of range"); | 292 exception = Dart_NewStringFromCString("value out of range"); |
| 292 return 0; | 293 return 0; |
| 293 } | 294 } |
| 294 return value; | 295 return value; |
| 295 } | 296 } |
| 296 | 297 |
| 297 Dart_Handle DartUtilities::numberToDart(double value) | 298 Dart_Handle DartUtilities::numberToDart(double value) |
| 298 { | 299 { |
| 299 int intValue = static_cast<int>(value); | 300 // JS can store integer values that are no greater than 2^53 - 1. |
| 300 if (value == intValue) | 301 if (-kJSMaxInteger <= value && value <= kJSMaxInteger) { |
| 301 return intToDart(intValue); | 302 int64_t intValue = static_cast<int64_t>(value); |
| 303 if (value == intValue) |
| 304 return intToDart(intValue); |
| 305 } |
| 302 return doubleToDart(value); | 306 return doubleToDart(value); |
| 303 } | 307 } |
| 304 | 308 |
| 305 ScriptValue DartUtilities::dartToScriptValue(Dart_Handle object, Dart_Handle& ex
ception) | 309 ScriptValue DartUtilities::dartToScriptValue(Dart_Handle object, Dart_Handle& ex
ception) |
| 306 { | 310 { |
| 307 return ScriptValue(V8Converter::toV8(object, exception)); | 311 return ScriptValue(V8Converter::toV8(object, exception)); |
| 308 } | 312 } |
| 309 | 313 |
| 310 Dart_Handle DartUtilities::scriptValueToDart(const ScriptValue& value) | 314 Dart_Handle DartUtilities::scriptValueToDart(const ScriptValue& value) |
| 311 { | 315 { |
| (...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1090 Dart_PersistentHandle library = domData->htmlLibrary(); | 1094 Dart_PersistentHandle library = domData->htmlLibrary(); |
| 1091 ASSERT(!Dart_IsError(library)); | 1095 ASSERT(!Dart_IsError(library)); |
| 1092 | 1096 |
| 1093 Dart_Handle utilsClass = Dart_GetType(library, Dart_NewStringFromCString("_U
tils"), 0, 0); | 1097 Dart_Handle utilsClass = Dart_GetType(library, Dart_NewStringFromCString("_U
tils"), 0, 0); |
| 1094 ASSERT(!Dart_IsError(utilsClass)); | 1098 ASSERT(!Dart_IsError(utilsClass)); |
| 1095 | 1099 |
| 1096 return Dart_Invoke(utilsClass, Dart_NewStringFromCString(methodName), argCou
nt, args); | 1100 return Dart_Invoke(utilsClass, Dart_NewStringFromCString(methodName), argCou
nt, args); |
| 1097 } | 1101 } |
| 1098 | 1102 |
| 1099 } | 1103 } |
| OLD | NEW |