| OLD | NEW |
| 1 // Copyright 2011, Google Inc. | 1 // Copyright 2013, 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 |
| 11 // copyright notice, this list of conditions and the following disclaimer | 11 // copyright notice, this list of conditions and the following disclaimer |
| 12 // in the documentation and/or other materials provided with the | 12 // in the documentation and/or other materials provided with the |
| 13 // distribution. | 13 // distribution. |
| 14 // * Neither the name of Google Inc. nor the names of its | 14 // * Neither the name of Google Inc. nor the names of its |
| 15 // contributors may be used to endorse or promote products derived from | 15 // contributors may be used to endorse or promote products derived from |
| 16 // this software without specific prior written permission. | 16 // this software without specific prior written permission. |
| 17 // | 17 // |
| 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 19 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 20 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 | 29 |
| 30 #include "config.h" | 30 #include "config.h" |
| 31 #include "DartErrorEvent.h" | 31 #include "DartInjectedScriptHost.h" |
| 32 | 32 |
| 33 #include "DartBlob.h" | 33 #include "bindings/dart/DartController.h" |
| 34 #include "DartWindow.h" | 34 #include "bindings/dart/DartHandleProxy.h" |
| 35 #include "bindings/dart/DartScriptState.h" |
| 35 #include "bindings/dart/V8Converter.h" | 36 #include "bindings/dart/V8Converter.h" |
| 36 #include "bindings/v8/ScriptController.h" | 37 #include "bindings/v8/V8HiddenPropertyName.h" |
| 37 | 38 |
| 38 namespace WebCore { | 39 namespace WebCore { |
| 39 | 40 |
| 40 namespace DartErrorEventInternal { | 41 /** |
| 42 * Returns true if the expression passed in my args was evaluated as Dart code. |
| 43 */ |
| 44 v8::Handle<v8::Value> DartInjectedScriptHost::evaluateIfDartContext(v8::Handle<v
8::Object> v8InjectedScriptHost, v8::Handle<v8::String> expression) |
| 45 { |
| 46 ASSERT(!v8::Context::GetCurrent().IsEmpty()); |
| 41 | 47 |
| 42 void errorGetter(Dart_NativeArguments args) | 48 ScriptState* currentScriptState = 0; |
| 43 { | 49 v8::Local<v8::Value> scriptStateWrapper = v8InjectedScriptHost->GetHiddenVal
ue(V8HiddenPropertyName::scriptState()); |
| 44 // Tricky to implement because V8 appears to implement by setting a V8Hidden
Value | 50 if (!scriptStateWrapper.IsEmpty() && scriptStateWrapper->IsExternal()) |
| 45 /* | 51 currentScriptState = static_cast<ScriptState*>(v8::External::Cast(*scrip
tStateWrapper)->Value()); |
| 46 { | 52 else |
| 47 v8::Handle<v8::Value> error = info.Holder()->GetHiddenValue(V8HiddenProperty
Name::error()); | 53 currentScriptState = ScriptState::current(); |
| 48 | 54 |
| 49 if (!error.IsEmpty()) { | 55 ScriptExecutionContext* scriptExecutionContext = currentScriptState->scriptE
xecutionContext(); |
| 50 v8SetReturnValue(info, error); | 56 ASSERT(scriptExecutionContext); |
| 51 return; | 57 |
| 58 if (!currentScriptState->isJavaScript()) { |
| 59 DartScriptState* dartScriptState = static_cast<DartScriptState*>(current
ScriptState); |
| 60 DartIsolateScope scope(dartScriptState->isolate()); |
| 61 DartApiScope apiScope; |
| 62 |
| 63 Dart_Handle target = Dart_GetLibraryFromId(dartScriptState->libraryId())
; |
| 64 return DartHandleProxy::evaluate(target, V8Converter::stringToDart(expre
ssion), Dart_Null()); |
| 52 } | 65 } |
| 53 ErrorEvent* receiver = DartDOMWrapper::receiver< ErrorEvent >(args); | 66 return v8::Handle<v8::Value>(); |
| 54 | |
| 55 DartUtilities::setDartStringReturnValue(args, receiver->error()); | |
| 56 return; | |
| 57 } | |
| 58 */ | |
| 59 DART_UNIMPLEMENTED(); | |
| 60 } | 67 } |
| 61 | 68 |
| 62 } | 69 } // namespace WebCore |
| 63 | |
| 64 } | |
| OLD | NEW |