Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. 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 27 matching lines...) Expand all Loading... | |
| 38 #include "bindings/core/v8/V8ObjectConstructor.h" | 38 #include "bindings/core/v8/V8ObjectConstructor.h" |
| 39 #include "bindings/core/v8/V8ScriptRunner.h" | 39 #include "bindings/core/v8/V8ScriptRunner.h" |
| 40 | 40 |
| 41 #include <v8.h> | 41 #include <v8.h> |
| 42 | 42 |
| 43 namespace blink { | 43 namespace blink { |
| 44 | 44 |
| 45 void ScriptCallArgumentHandler::appendArgument(const ScriptValue& argument) | 45 void ScriptCallArgumentHandler::appendArgument(const ScriptValue& argument) |
| 46 { | 46 { |
| 47 if (argument.scriptState() != m_scriptState) { | 47 if (argument.scriptState() != m_scriptState) { |
| 48 ASSERT_NOT_REACHED(); | 48 appendArgument(); |
|
yurys
2014/07/21 12:45:32
Looks like it should be done in a separate patch.
aandrey
2014/07/22 11:08:43
Done. Extracted to http://crrev.com/412443002
| |
| 49 return; | 49 return; |
| 50 } | 50 } |
| 51 m_arguments.append(argument); | 51 m_arguments.append(argument); |
| 52 } | 52 } |
| 53 | 53 |
| 54 void ScriptCallArgumentHandler::appendArgument(const String& argument) | 54 void ScriptCallArgumentHandler::appendArgument(const String& argument) |
| 55 { | 55 { |
| 56 v8::Isolate* isolate = m_scriptState->isolate(); | 56 v8::Isolate* isolate = m_scriptState->isolate(); |
| 57 ScriptState::Scope scope(m_scriptState.get()); | 57 ScriptState::Scope scope(m_scriptState.get()); |
| 58 m_arguments.append(ScriptValue(m_scriptState.get(), v8String(isolate, argume nt))); | 58 m_arguments.append(ScriptValue(m_scriptState.get(), v8String(isolate, argume nt))); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 { | 104 { |
| 105 v8::Isolate* isolate = m_scriptState->isolate(); | 105 v8::Isolate* isolate = m_scriptState->isolate(); |
| 106 m_arguments.append(ScriptValue(m_scriptState.get(), v8Boolean(argument, isol ate))); | 106 m_arguments.append(ScriptValue(m_scriptState.get(), v8Boolean(argument, isol ate))); |
| 107 } | 107 } |
| 108 | 108 |
| 109 void ScriptCallArgumentHandler::appendArgument(const Vector<ScriptValue>& argume nt) | 109 void ScriptCallArgumentHandler::appendArgument(const Vector<ScriptValue>& argume nt) |
| 110 { | 110 { |
| 111 v8::Isolate* isolate = m_scriptState->isolate(); | 111 v8::Isolate* isolate = m_scriptState->isolate(); |
| 112 ScriptState::Scope scope(m_scriptState.get()); | 112 ScriptState::Scope scope(m_scriptState.get()); |
| 113 v8::Handle<v8::Array> result = v8::Array::New(isolate, argument.size()); | 113 v8::Handle<v8::Array> result = v8::Array::New(isolate, argument.size()); |
| 114 for (size_t i = 0; i < argument.size(); ++i) | 114 for (size_t i = 0; i < argument.size(); ++i) { |
| 115 result->Set(v8::Integer::New(isolate, i), argument[i].v8Value()); | 115 if (argument[i].scriptState() != m_scriptState) |
| 116 result->Set(v8::Integer::New(isolate, i), v8::Undefined(isolate)); | |
| 117 else | |
| 118 result->Set(v8::Integer::New(isolate, i), argument[i].v8Value()); | |
| 119 } | |
| 116 m_arguments.append(ScriptValue(m_scriptState.get(), result)); | 120 m_arguments.append(ScriptValue(m_scriptState.get(), result)); |
| 117 } | 121 } |
| 118 | 122 |
| 123 void ScriptCallArgumentHandler::appendArgument() | |
| 124 { | |
| 125 v8::Isolate* isolate = m_scriptState->isolate(); | |
| 126 m_arguments.append(ScriptValue(m_scriptState.get(), v8::Undefined(isolate))) ; | |
| 127 } | |
| 128 | |
| 119 ScriptFunctionCall::ScriptFunctionCall(const ScriptValue& thisObject, const Stri ng& name) | 129 ScriptFunctionCall::ScriptFunctionCall(const ScriptValue& thisObject, const Stri ng& name) |
| 120 : ScriptCallArgumentHandler(thisObject.scriptState()) | 130 : ScriptCallArgumentHandler(thisObject.scriptState()) |
| 121 , m_thisObject(thisObject) | 131 , m_thisObject(thisObject) |
| 122 , m_name(name) | 132 , m_name(name) |
| 123 { | 133 { |
| 124 } | 134 } |
| 125 | 135 |
| 126 ScriptValue ScriptFunctionCall::call(bool& hadException, bool reportExceptions) | 136 ScriptValue ScriptFunctionCall::call(bool& hadException, bool reportExceptions) |
| 127 { | 137 { |
| 128 ScriptState::Scope scope(m_scriptState.get()); | 138 ScriptState::Scope scope(m_scriptState.get()); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 183 v8::Local<v8::Object> result = V8ObjectConstructor::newInstance(m_scriptStat e->isolate(), constructor, m_arguments.size(), info.get()); | 193 v8::Local<v8::Object> result = V8ObjectConstructor::newInstance(m_scriptStat e->isolate(), constructor, m_arguments.size(), info.get()); |
| 184 if (tryCatch.HasCaught()) { | 194 if (tryCatch.HasCaught()) { |
| 185 hadException = true; | 195 hadException = true; |
| 186 return ScriptValue(); | 196 return ScriptValue(); |
| 187 } | 197 } |
| 188 | 198 |
| 189 return ScriptValue(m_scriptState.get(), result); | 199 return ScriptValue(m_scriptState.get(), result); |
| 190 } | 200 } |
| 191 | 201 |
| 192 } // namespace blink | 202 } // namespace blink |
| OLD | NEW |