Chromium Code Reviews| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 50 v8::Local<v8::Value> V8ErrorHandler::callListenerFunction(ScriptState* scriptSta te, v8::Local<v8::Value> jsEvent, Event* event) | 50 v8::Local<v8::Value> V8ErrorHandler::callListenerFunction(ScriptState* scriptSta te, v8::Local<v8::Value> jsEvent, Event* event) |
| 51 { | 51 { |
| 52 if (!event->hasInterface(EventNames::ErrorEvent)) | 52 if (!event->hasInterface(EventNames::ErrorEvent)) |
| 53 return V8EventListener::callListenerFunction(scriptState, 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 if (errorEvent->world() && errorEvent->world() != &world()) | 56 if (errorEvent->world() && errorEvent->world() != &world()) |
| 57 return v8::Null(isolate()); | 57 return v8::Null(isolate()); |
| 58 | 58 |
| 59 v8::Local<v8::Object> listener = getListenerObject(scriptState->executionCon text()); | 59 v8::Local<v8::Object> listener = getListenerObject(scriptState->executionCon text()); |
| 60 v8::Local<v8::Value> returnValue; | 60 v8::Local<v8::Value> returnValue; |
|
Yuki
2015/04/17 09:59:23
Move this line just before you really need returnV
bashi
2015/04/21 00:15:40
Done.
| |
| 61 if (!listener.IsEmpty() && listener->IsFunction()) { | 61 if (listener.IsEmpty() || !listener->IsFunction()) |
| 62 v8::Local<v8::Function> callFunction = v8::Local<v8::Function>::Cast(lis tener); | 62 return v8::Null(isolate()); |
| 63 v8::Local<v8::Object> thisValue = scriptState->context()->Global(); | |
| 64 | 63 |
| 65 v8::Local<v8::Object> eventObject; | 64 v8::Local<v8::Function> callFunction = v8::Local<v8::Function>::Cast(listene r); |
| 66 if (!jsEvent->ToObject(scriptState->context()).ToLocal(&eventObject)) | 65 v8::Local<v8::Object> thisValue = scriptState->context()->Global(); |
| 67 return v8::Null(isolate()); | |
| 68 v8::Local<v8::Value> error = V8HiddenValue::getHiddenValue(isolate(), ev entObject, V8HiddenValue::error(isolate())); | |
| 69 if (error.IsEmpty()) | |
| 70 error = v8::Null(isolate()); | |
| 71 | 66 |
| 72 v8::Local<v8::Value> parameters[5] = { v8String(isolate(), errorEvent->m essage()), v8String(isolate(), errorEvent->filename()), v8::Integer::New(isolate (), errorEvent->lineno()), v8::Integer::New(isolate(), errorEvent->colno()), err or }; | 67 v8::Local<v8::Object> eventObject; |
| 73 v8::TryCatch tryCatch; | 68 if (!jsEvent->ToObject(scriptState->context()).ToLocal(&eventObject)) |
| 74 tryCatch.SetVerbose(true); | 69 return v8::Null(isolate()); |
| 75 if (scriptState->executionContext()->isWorkerGlobalScope()) | 70 v8::Local<v8::Value> error = V8HiddenValue::getHiddenValue(isolate(), eventO bject, V8HiddenValue::error(isolate())); |
| 76 returnValue = V8ScriptRunner::callFunction(callFunction, scriptState ->executionContext(), thisValue, WTF_ARRAY_LENGTH(parameters), parameters, isola te()); | 71 if (error.IsEmpty()) |
| 77 else | 72 error = v8::Null(isolate()); |
| 78 returnValue = ScriptController::callFunction(scriptState->executionC ontext(), callFunction, thisValue, WTF_ARRAY_LENGTH(parameters), parameters, iso late()); | 73 |
| 79 } | 74 v8::Local<v8::Value> parameters[5] = { v8String(isolate(), errorEvent->messa ge()), v8String(isolate(), errorEvent->filename()), v8::Integer::New(isolate(), errorEvent->lineno()), v8::Integer::New(isolate(), errorEvent->colno()), error } ; |
| 75 v8::TryCatch tryCatch; | |
| 76 tryCatch.SetVerbose(true); | |
| 77 v8::MaybeLocal<v8::Value> result; | |
| 78 if (scriptState->executionContext()->isWorkerGlobalScope()) | |
|
haraken
2015/04/18 23:10:47
Nit: I'd add { } since the clause is long.
bashi
2015/04/21 00:15:40
Done.
| |
| 79 result = V8ScriptRunner::callFunction(callFunction, scriptState->executi onContext(), thisValue, WTF_ARRAY_LENGTH(parameters), parameters, isolate()); | |
| 80 else | |
| 81 result = ScriptController::callFunction(scriptState->executionContext(), callFunction, thisValue, WTF_ARRAY_LENGTH(parameters), parameters, isolate()); | |
| 82 if (!result.ToLocal(&returnValue)) | |
| 83 return v8::Null(isolate()); | |
| 84 | |
| 80 return returnValue; | 85 return returnValue; |
| 81 } | 86 } |
| 82 | 87 |
| 83 // static | 88 // static |
| 84 void V8ErrorHandler::storeExceptionOnErrorEventWrapper(v8::Isolate* isolate, Err orEvent* event, v8::Local<v8::Value> data, v8::Local<v8::Object> creationContext ) | 89 void V8ErrorHandler::storeExceptionOnErrorEventWrapper(v8::Isolate* isolate, Err orEvent* event, v8::Local<v8::Value> data, v8::Local<v8::Object> creationContext ) |
| 85 { | 90 { |
| 86 v8::Local<v8::Value> wrappedEvent = toV8(event, creationContext, isolate); | 91 v8::Local<v8::Value> wrappedEvent = toV8(event, creationContext, isolate); |
| 87 if (!wrappedEvent.IsEmpty()) { | 92 if (!wrappedEvent.IsEmpty()) { |
| 88 ASSERT(wrappedEvent->IsObject()); | 93 ASSERT(wrappedEvent->IsObject()); |
| 89 V8HiddenValue::setHiddenValue(isolate, v8::Local<v8::Object>::Cast(wrapp edEvent), V8HiddenValue::error(isolate), data); | 94 V8HiddenValue::setHiddenValue(isolate, v8::Local<v8::Object>::Cast(wrapp edEvent), V8HiddenValue::error(isolate), data); |
| 90 } | 95 } |
| 91 } | 96 } |
| 92 | 97 |
| 93 bool V8ErrorHandler::shouldPreventDefault(v8::Local<v8::Value> returnValue) | 98 bool V8ErrorHandler::shouldPreventDefault(v8::Local<v8::Value> returnValue) |
| 94 { | 99 { |
| 95 return returnValue->IsBoolean() && returnValue.As<v8::Boolean>()->Value(); | 100 return returnValue->IsBoolean() && returnValue.As<v8::Boolean>()->Value(); |
| 96 } | 101 } |
| 97 | 102 |
| 98 } // namespace blink | 103 } // namespace blink |
| OLD | NEW |