| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "bindings/core/v8/PrivateScriptRunner.h" | 6 #include "bindings/core/v8/PrivateScriptRunner.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/DOMWrapperWorld.h" | 8 #include "bindings/core/v8/DOMWrapperWorld.h" |
| 9 #include "bindings/core/v8/ExceptionState.h" | 9 #include "bindings/core/v8/ExceptionState.h" |
| 10 #include "bindings/core/v8/V8Binding.h" | 10 #include "bindings/core/v8/V8Binding.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 } | 84 } |
| 85 | 85 |
| 86 static void initializeHolderIfNeeded(ScriptState* scriptState, v8::Handle<v8::Ob
ject> classObject, v8::Handle<v8::Value> holder) | 86 static void initializeHolderIfNeeded(ScriptState* scriptState, v8::Handle<v8::Ob
ject> classObject, v8::Handle<v8::Value> holder) |
| 87 { | 87 { |
| 88 RELEASE_ASSERT(!holder.IsEmpty()); | 88 RELEASE_ASSERT(!holder.IsEmpty()); |
| 89 RELEASE_ASSERT(holder->IsObject()); | 89 RELEASE_ASSERT(holder->IsObject()); |
| 90 v8::Handle<v8::Object> holderObject = v8::Handle<v8::Object>::Cast(holder); | 90 v8::Handle<v8::Object> holderObject = v8::Handle<v8::Object>::Cast(holder); |
| 91 v8::Isolate* isolate = scriptState->isolate(); | 91 v8::Isolate* isolate = scriptState->isolate(); |
| 92 v8::Handle<v8::Value> isInitialized = V8HiddenValue::getHiddenValue(isolate,
holderObject, V8HiddenValue::privateScriptObjectIsInitialized(isolate)); | 92 v8::Handle<v8::Value> isInitialized = V8HiddenValue::getHiddenValue(isolate,
holderObject, V8HiddenValue::privateScriptObjectIsInitialized(isolate)); |
| 93 if (isInitialized.IsEmpty()) { | 93 if (isInitialized.IsEmpty()) { |
| 94 v8::Handle<v8::Value> initializeFunction = classObject->Get(v8String(iso
late, "constructor")); | 94 v8::TryCatch block; |
| 95 v8::Handle<v8::Value> initializeFunction = classObject->Get(v8String(iso
late, "initialize")); |
| 95 if (!initializeFunction.IsEmpty() && initializeFunction->IsFunction()) { | 96 if (!initializeFunction.IsEmpty() && initializeFunction->IsFunction()) { |
| 96 V8ScriptRunner::callFunction(v8::Handle<v8::Function>::Cast(initiali
zeFunction), scriptState->executionContext(), holder, 0, 0, isolate); | 97 V8ScriptRunner::callFunction(v8::Handle<v8::Function>::Cast(initiali
zeFunction), scriptState->executionContext(), holder, 0, 0, isolate); |
| 97 } | 98 } |
| 98 isInitialized = v8Boolean(true, isolate); | 99 isInitialized = v8Boolean(true, isolate); |
| 99 V8HiddenValue::setHiddenValue(isolate, holderObject, V8HiddenValue::priv
ateScriptObjectIsInitialized(isolate), isInitialized); | 100 V8HiddenValue::setHiddenValue(isolate, holderObject, V8HiddenValue::priv
ateScriptObjectIsInitialized(isolate), isInitialized); |
| 100 } | 101 } |
| 101 } | 102 } |
| 102 | 103 |
| 103 v8::Handle<v8::Value> PrivateScriptRunner::installClass(LocalFrame* frame, Strin
g className) | 104 v8::Handle<v8::Value> PrivateScriptRunner::installClass(LocalFrame* frame, Strin
g className) |
| 104 { | 105 { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 RELEASE_ASSERT(!message.IsEmpty() && message->IsString()); | 165 RELEASE_ASSERT(!message.IsEmpty() && message->IsString()); |
| 165 v8::Handle<v8::Value> code = exceptionObject->Get(v8String(isolate, "code"))
; | 166 v8::Handle<v8::Value> code = exceptionObject->Get(v8String(isolate, "code"))
; |
| 166 RELEASE_ASSERT(!code.IsEmpty() && code->IsInt32()); | 167 RELEASE_ASSERT(!code.IsEmpty() && code->IsInt32()); |
| 167 // FIXME: Support JavaScript errors such as TypeError, RangeError and Securi
tyError. | 168 // FIXME: Support JavaScript errors such as TypeError, RangeError and Securi
tyError. |
| 168 exceptionState.throwDOMException(toInt32(code), toCoreString(v8::Handle<v8::
String>::Cast(message))); | 169 exceptionState.throwDOMException(toInt32(code), toCoreString(v8::Handle<v8::
String>::Cast(message))); |
| 169 exceptionState.throwIfNeeded(); | 170 exceptionState.throwIfNeeded(); |
| 170 return true; | 171 return true; |
| 171 } | 172 } |
| 172 | 173 |
| 173 } // namespace WebCore | 174 } // namespace WebCore |
| OLD | NEW |