| 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 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 #include "config.h" | 30 #include "config.h" |
| 31 #include "bindings/core/dart/DartUtilities.h" | 31 #include "bindings/core/dart/DartUtilities.h" |
| 32 | 32 |
| 33 #if OS(ANDROID) | 33 #if OS(ANDROID) |
| 34 #include <sys/system_properties.h> | 34 #include <sys/system_properties.h> |
| 35 #endif | 35 #endif |
| 36 | 36 |
| 37 #include "bindings/core/dart/DartController.h" | 37 #include "bindings/core/dart/DartController.h" |
| 38 #include "bindings/core/dart/DartDOMData.h" | 38 #include "bindings/core/dart/DartDOMData.h" |
| 39 #include "bindings/core/dart/DartJsInterop.h" |
| 39 #include "bindings/core/dart/DartScriptDebugServer.h" | 40 #include "bindings/core/dart/DartScriptDebugServer.h" |
| 40 #include "bindings/core/dart/DartScriptState.h" | 41 #include "bindings/core/dart/DartScriptState.h" |
| 41 #include "bindings/core/dart/V8Converter.h" | 42 #include "bindings/core/dart/V8Converter.h" |
| 42 #include "bindings/core/v8/ExceptionState.h" | 43 #include "bindings/core/v8/ExceptionState.h" |
| 43 #include "bindings/core/v8/ScriptController.h" | 44 #include "bindings/core/v8/ScriptController.h" |
| 44 #include "bindings/core/v8/SerializedScriptValueFactory.h" | 45 #include "bindings/core/v8/SerializedScriptValueFactory.h" |
| 45 #include "bindings/core/v8/V8Binding.h" | 46 #include "bindings/core/v8/V8Binding.h" |
| 47 #include "bindings/core/v8/V8Node.h" |
| 46 #include "bindings/core/v8/V8PerIsolateData.h" | 48 #include "bindings/core/v8/V8PerIsolateData.h" |
| 47 #include "core/dom/DOMArrayBuffer.h" | 49 #include "core/dom/DOMArrayBuffer.h" |
| 48 #include "core/dom/DOMDataView.h" | 50 #include "core/dom/DOMDataView.h" |
| 49 #include "core/dom/Document.h" | 51 #include "core/dom/Document.h" |
| 50 #include "core/events/ErrorEvent.h" | 52 #include "core/events/ErrorEvent.h" |
| 51 #include "core/fetch/FetchInitiatorTypeNames.h" | 53 #include "core/fetch/FetchInitiatorTypeNames.h" |
| 52 #include "core/fetch/ResourceFetcher.h" | 54 #include "core/fetch/ResourceFetcher.h" |
| 53 #include "core/frame/LocalDOMWindow.h" | 55 #include "core/frame/LocalDOMWindow.h" |
| 54 #include "core/frame/LocalFrame.h" | 56 #include "core/frame/LocalFrame.h" |
| 55 #include "core/inspector/ScriptArguments.h" | 57 #include "core/inspector/ScriptArguments.h" |
| (...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 Dart_Handle dartType = Dart_GetType(DartDOMData::current()->htmlLibrary(), | 560 Dart_Handle dartType = Dart_GetType(DartDOMData::current()->htmlLibrary(), |
| 559 Dart_NewStringFromCString(typeName), 0, 0); | 561 Dart_NewStringFromCString(typeName), 0, 0); |
| 560 ASSERT(!Dart_IsError(dartType)); | 562 ASSERT(!Dart_IsError(dartType)); |
| 561 | 563 |
| 562 return dartType; | 564 return dartType; |
| 563 } | 565 } |
| 564 | 566 |
| 565 bool DartUtilities::isNode(Dart_Handle handle) | 567 bool DartUtilities::isNode(Dart_Handle handle) |
| 566 { | 568 { |
| 567 Dart_Handle dartType = DartUtilities::getDartHtmlType("Node"); | 569 Dart_Handle dartType = DartUtilities::getDartHtmlType("Node"); |
| 568 return objectIsType(handle, dartType); | 570 if (!objectIsType(handle, dartType)) { |
| 571 return false; |
| 572 } |
| 573 // Some dart:html Node instances may not really be Node objects. |
| 574 Dart_Handle exception = 0; |
| 575 v8::Handle<v8::Value> v8Node = JsInterop::fromDart(DartDOMData::current(), h
andle, exception); |
| 576 if (exception) { |
| 577 return false; |
| 578 } |
| 579 return V8Node::hasInstance(v8Node, v8::Isolate::GetCurrent()); |
| 569 } | 580 } |
| 570 | 581 |
| 571 Node* DartUtilities::dartNodeToNativeNode(void* value) | 582 Node* DartUtilities::dartNodeToNativeNode(Dart_Handle handle) |
| 572 { | 583 { |
| 573 return static_cast<Node*>(value); | 584 Dart_Handle exception = 0; |
| 585 v8::Handle<v8::Value> v8Node = JsInterop::fromDart(DartDOMData::current(), h
andle, exception); |
| 586 ASSERT(!exception); |
| 587 ASSERT(V8Node::hasInstance(v8Node, v8::Isolate::GetCurrent())); |
| 588 Node* node = V8Node::toImpl(v8Node.As<v8::Object>()); |
| 589 return node; |
| 574 } | 590 } |
| 575 | 591 |
| 576 bool DartUtilities::isMessagePort(Dart_Handle handle) | 592 bool DartUtilities::isMessagePort(Dart_Handle handle) |
| 577 { | 593 { |
| 578 Dart_Handle dartType = DartUtilities::getDartHtmlType("MessagePort"); | 594 Dart_Handle dartType = DartUtilities::getDartHtmlType("MessagePort"); |
| 579 return objectIsType(handle, dartType); | 595 return objectIsType(handle, dartType); |
| 580 } | 596 } |
| 581 | 597 |
| 582 MessagePort* DartUtilities::dartMessagePortToNativeMessagePort(void* value) | 598 MessagePort* DartUtilities::dartMessagePortToNativeMessagePort(void* value) |
| 583 { | 599 { |
| (...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1395 if (!v) { | 1411 if (!v) { |
| 1396 return 0; | 1412 return 0; |
| 1397 } | 1413 } |
| 1398 ASSERT(valueLen > 0 && static_cast<size_t>(valueLen) > strlen(v)); | 1414 ASSERT(valueLen > 0 && static_cast<size_t>(valueLen) > strlen(v)); |
| 1399 strncpy(value, v, valueLen); | 1415 strncpy(value, v, valueLen); |
| 1400 value[valueLen - 1] = '\0'; | 1416 value[valueLen - 1] = '\0'; |
| 1401 return strlen(value); | 1417 return strlen(value); |
| 1402 #endif | 1418 #endif |
| 1403 } | 1419 } |
| 1404 } | 1420 } |
| OLD | NEW |