OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 29 matching lines...) Expand all Loading... |
40 #include "core/events/ErrorEvent.h" | 40 #include "core/events/ErrorEvent.h" |
41 #include "core/frame/LocalFrame.h" | 41 #include "core/frame/LocalFrame.h" |
42 | 42 |
43 namespace blink { | 43 namespace blink { |
44 | 44 |
45 V8ErrorHandler::V8ErrorHandler(v8::Local<v8::Object> listener, bool isInline, Sc
riptState* scriptState) | 45 V8ErrorHandler::V8ErrorHandler(v8::Local<v8::Object> listener, bool isInline, Sc
riptState* scriptState) |
46 : V8EventListener(listener, isInline, scriptState) | 46 : V8EventListener(listener, isInline, scriptState) |
47 { | 47 { |
48 } | 48 } |
49 | 49 |
50 v8::Local<v8::Value> V8ErrorHandler::callListenerFunction(v8::Handle<v8::Value>
jsEvent, Event* event) | 50 v8::Local<v8::Value> V8ErrorHandler::callListenerFunction(ScriptState* scriptSta
te, v8::Handle<v8::Value> jsEvent, Event* event) |
51 { | 51 { |
52 if (!event->hasInterface(EventNames::ErrorEvent)) | 52 if (!event->hasInterface(EventNames::ErrorEvent)) |
53 return V8EventListener::callListenerFunction(jsEvent, event); | 53 return V8EventListener::callListenerFunction(scriptState, jsEvent, event
); |
54 | 54 |
55 ErrorEvent* errorEvent = static_cast<ErrorEvent*>(event); | 55 ErrorEvent* errorEvent = static_cast<ErrorEvent*>(event); |
56 | |
57 if (errorEvent->world() && errorEvent->world() != &world()) | 56 if (errorEvent->world() && errorEvent->world() != &world()) |
58 return v8::Null(isolate()); | 57 return v8::Null(isolate()); |
59 | 58 |
60 v8::Local<v8::Object> listener = getListenerObject(scriptState()->executionC
ontext()); | 59 v8::Local<v8::Object> listener = getListenerObject(scriptState->executionCon
text()); |
61 v8::Local<v8::Value> returnValue; | 60 v8::Local<v8::Value> returnValue; |
62 if (!listener.IsEmpty() && listener->IsFunction()) { | 61 if (!listener.IsEmpty() && listener->IsFunction()) { |
63 v8::Local<v8::Function> callFunction = v8::Local<v8::Function>::Cast(lis
tener); | 62 v8::Local<v8::Function> callFunction = v8::Local<v8::Function>::Cast(lis
tener); |
64 v8::Local<v8::Object> thisValue = scriptState()->context()->Global(); | 63 v8::Local<v8::Object> thisValue = scriptState->context()->Global(); |
65 | 64 |
66 v8::Local<v8::Value> error = V8HiddenValue::getHiddenValue(isolate(), js
Event->ToObject(isolate()), V8HiddenValue::error(isolate())); | 65 v8::Local<v8::Value> error = V8HiddenValue::getHiddenValue(isolate(), js
Event->ToObject(isolate()), V8HiddenValue::error(isolate())); |
67 if (error.IsEmpty()) | 66 if (error.IsEmpty()) |
68 error = v8::Null(isolate()); | 67 error = v8::Null(isolate()); |
69 | 68 |
70 v8::Handle<v8::Value> parameters[5] = { v8String(isolate(), errorEvent->
message()), v8String(isolate(), errorEvent->filename()), v8::Integer::New(isolat
e(), errorEvent->lineno()), v8::Integer::New(isolate(), errorEvent->colno()), er
ror }; | 69 v8::Handle<v8::Value> parameters[5] = { v8String(isolate(), errorEvent->
message()), v8String(isolate(), errorEvent->filename()), v8::Integer::New(isolat
e(), errorEvent->lineno()), v8::Integer::New(isolate(), errorEvent->colno()), er
ror }; |
71 v8::TryCatch tryCatch; | 70 v8::TryCatch tryCatch; |
72 tryCatch.SetVerbose(true); | 71 tryCatch.SetVerbose(true); |
73 if (scriptState()->executionContext()->isWorkerGlobalScope()) | 72 if (scriptState->executionContext()->isWorkerGlobalScope()) |
74 returnValue = V8ScriptRunner::callFunction(callFunction, scriptState
()->executionContext(), thisValue, WTF_ARRAY_LENGTH(parameters), parameters, iso
late()); | 73 returnValue = V8ScriptRunner::callFunction(callFunction, scriptState
->executionContext(), thisValue, WTF_ARRAY_LENGTH(parameters), parameters, isola
te()); |
75 else | 74 else |
76 returnValue = ScriptController::callFunction(scriptState()->executio
nContext(), callFunction, thisValue, WTF_ARRAY_LENGTH(parameters), parameters, i
solate()); | 75 returnValue = ScriptController::callFunction(scriptState->executionC
ontext(), callFunction, thisValue, WTF_ARRAY_LENGTH(parameters), parameters, iso
late()); |
77 } | 76 } |
78 return returnValue; | 77 return returnValue; |
79 } | 78 } |
80 | 79 |
81 // static | 80 // static |
82 void V8ErrorHandler::storeExceptionOnErrorEventWrapper(v8::Isolate* isolate, Err
orEvent* event, v8::Handle<v8::Value> data, v8::Handle<v8::Object> creationConte
xt) | 81 void V8ErrorHandler::storeExceptionOnErrorEventWrapper(v8::Isolate* isolate, Err
orEvent* event, v8::Handle<v8::Value> data, v8::Handle<v8::Object> creationConte
xt) |
83 { | 82 { |
84 v8::Local<v8::Value> wrappedEvent = toV8(event, creationContext, isolate); | 83 v8::Local<v8::Value> wrappedEvent = toV8(event, creationContext, isolate); |
85 if (!wrappedEvent.IsEmpty()) { | 84 if (!wrappedEvent.IsEmpty()) { |
86 ASSERT(wrappedEvent->IsObject()); | 85 ASSERT(wrappedEvent->IsObject()); |
87 V8HiddenValue::setHiddenValue(isolate, v8::Local<v8::Object>::Cast(wrapp
edEvent), V8HiddenValue::error(isolate), data); | 86 V8HiddenValue::setHiddenValue(isolate, v8::Local<v8::Object>::Cast(wrapp
edEvent), V8HiddenValue::error(isolate), data); |
88 } | 87 } |
89 } | 88 } |
90 | 89 |
91 bool V8ErrorHandler::shouldPreventDefault(v8::Local<v8::Value> returnValue) | 90 bool V8ErrorHandler::shouldPreventDefault(v8::Local<v8::Value> returnValue) |
92 { | 91 { |
93 return returnValue->IsBoolean() && returnValue->BooleanValue(); | 92 return returnValue->IsBoolean() && returnValue->BooleanValue(); |
94 } | 93 } |
95 | 94 |
96 } // namespace blink | 95 } // namespace blink |
OLD | NEW |