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 13 matching lines...) Expand all Loading... | |
| 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 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "bindings/v8/V8ErrorHandler.h" | 32 #include "bindings/v8/V8ErrorHandler.h" |
| 33 | 33 |
| 34 #include "V8ErrorEvent.h" | |
| 34 #include "bindings/v8/ScriptController.h" | 35 #include "bindings/v8/ScriptController.h" |
| 35 #include "bindings/v8/V8Binding.h" | 36 #include "bindings/v8/V8Binding.h" |
| 36 #include "bindings/v8/V8HiddenPropertyName.h" | 37 #include "bindings/v8/V8HiddenPropertyName.h" |
| 37 #include "bindings/v8/V8ScriptRunner.h" | 38 #include "bindings/v8/V8ScriptRunner.h" |
| 39 #include "core/dom/Document.h" | |
| 38 #include "core/dom/ErrorEvent.h" | 40 #include "core/dom/ErrorEvent.h" |
| 39 #include "core/dom/EventNames.h" | 41 #include "core/dom/EventNames.h" |
| 42 #include "core/dom/ScriptExecutionContext.h" | |
| 43 #include "core/page/Frame.h" | |
| 40 | 44 |
| 41 namespace WebCore { | 45 namespace WebCore { |
| 42 | 46 |
| 43 V8ErrorHandler::V8ErrorHandler(v8::Local<v8::Object> listener, bool isInline) | 47 V8ErrorHandler::V8ErrorHandler(v8::Local<v8::Object> listener, bool isInline) |
| 44 : V8EventListener(listener, isInline) | 48 : V8EventListener(listener, isInline) |
| 45 { | 49 { |
| 46 } | 50 } |
| 47 | 51 |
| 48 v8::Local<v8::Value> V8ErrorHandler::callListenerFunction(ScriptExecutionContext * context, v8::Handle<v8::Value> jsEvent, Event* event) | 52 v8::Local<v8::Value> V8ErrorHandler::callListenerFunction(ScriptExecutionContext * context, v8::Handle<v8::Value> jsEvent, Event* event) |
| 49 { | 53 { |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 66 v8::TryCatch tryCatch; | 70 v8::TryCatch tryCatch; |
| 67 tryCatch.SetVerbose(true); | 71 tryCatch.SetVerbose(true); |
| 68 if (worldType(isolate) == WorkerWorld) | 72 if (worldType(isolate) == WorkerWorld) |
| 69 returnValue = V8ScriptRunner::callFunction(callFunction, context, th isValue, WTF_ARRAY_LENGTH(parameters), parameters); | 73 returnValue = V8ScriptRunner::callFunction(callFunction, context, th isValue, WTF_ARRAY_LENGTH(parameters), parameters); |
| 70 else | 74 else |
| 71 returnValue = ScriptController::callFunctionWithInstrumentation(0, c allFunction, thisValue, WTF_ARRAY_LENGTH(parameters), parameters); | 75 returnValue = ScriptController::callFunctionWithInstrumentation(0, c allFunction, thisValue, WTF_ARRAY_LENGTH(parameters), parameters); |
| 72 } | 76 } |
| 73 return returnValue; | 77 return returnValue; |
| 74 } | 78 } |
| 75 | 79 |
| 80 // static | |
| 81 void V8ErrorHandler::storeExceptionOnErrorEventWrapper(ScriptExecutionContext* c ontext, ErrorEvent* event, v8::Handle<v8::Value> data, v8::Isolate* isolate) | |
| 82 { | |
| 83 if (context->isDocument()) { | |
| 84 // This method might be called while we're creating a new context. Since we | |
|
adamk
2013/08/09 17:11:32
Why move this code? It seems like it would work fi
Mike West
2013/08/09 20:34:51
It seemed better to have one spot where the wrappi
adamk
2013/08/09 21:29:25
I'm confused: I'm suggesting sharing the wrapping/
Mike West
2013/08/09 21:38:45
Ah, sorry. I thought you were asking "Why move all
| |
| 85 // cannot create a wrapper during context creation, we bail out early. | |
| 86 DOMWrapperWorld* world = DOMWrapperWorld::current(); | |
| 87 Frame* frame = toDocument(context)->frame(); | |
| 88 if (!world || !frame || !frame->script()->existingWindowShell(world)) | |
| 89 return; | |
| 90 } | |
| 91 | |
| 92 v8::Local<v8::Value> wrappedEvent = toV8(event, v8::Handle<v8::Object>(), is olate); | |
| 93 if (!wrappedEvent.IsEmpty()) { | |
| 94 ASSERT(wrappedEvent->IsObject()); | |
| 95 v8::Local<v8::Object>::Cast(wrappedEvent)->SetHiddenValue(V8HiddenProper tyName::error(), data); | |
| 96 } | |
| 97 } | |
| 98 | |
| 76 bool V8ErrorHandler::shouldPreventDefault(v8::Local<v8::Value> returnValue) | 99 bool V8ErrorHandler::shouldPreventDefault(v8::Local<v8::Value> returnValue) |
| 77 { | 100 { |
| 78 return returnValue->IsBoolean() && returnValue->BooleanValue(); | 101 return returnValue->IsBoolean() && returnValue->BooleanValue(); |
| 79 } | 102 } |
| 80 | 103 |
| 81 } // namespace WebCore | 104 } // namespace WebCore |
| OLD | NEW |