OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 #include "bindings/v8/V8DOMActivityLogger.h" | 56 #include "bindings/v8/V8DOMActivityLogger.h" |
57 #include "bindings/v8/V8DOMConfiguration.h" | 57 #include "bindings/v8/V8DOMConfiguration.h" |
58 #include "bindings/v8/V8EventListenerList.h" | 58 #include "bindings/v8/V8EventListenerList.h" |
59 #include "bindings/v8/V8HiddenValue.h" | 59 #include "bindings/v8/V8HiddenValue.h" |
60 #include "bindings/v8/V8ObjectConstructor.h" | 60 #include "bindings/v8/V8ObjectConstructor.h" |
61 #include "bindings/v8/custom/V8Float32ArrayCustom.h" | 61 #include "bindings/v8/custom/V8Float32ArrayCustom.h" |
62 #include "core/css/MediaQueryListListener.h" | 62 #include "core/css/MediaQueryListListener.h" |
63 #include "core/dom/ContextFeatures.h" | 63 #include "core/dom/ContextFeatures.h" |
64 #include "core/dom/Document.h" | 64 #include "core/dom/Document.h" |
65 #include "core/dom/custom/CustomElementCallbackDispatcher.h" | 65 #include "core/dom/custom/CustomElementCallbackDispatcher.h" |
66 #include "core/frame/DOMWindow.h" | |
67 #include "core/frame/UseCounter.h" | 66 #include "core/frame/UseCounter.h" |
68 #include "platform/TraceEvent.h" | 67 #include "platform/TraceEvent.h" |
69 #include "wtf/GetPtr.h" | 68 #include "wtf/GetPtr.h" |
70 #include "wtf/RefPtr.h" | 69 #include "wtf/RefPtr.h" |
71 | 70 |
72 namespace WebCore { | 71 namespace WebCore { |
73 | 72 |
74 static void initializeScriptWrappableForInterface(TestObject* object) | 73 static void initializeScriptWrappableForInterface(TestObject* object) |
75 { | 74 { |
76 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) | 75 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) |
(...skipping 3424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3501 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | 3500 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
3502 } | 3501 } |
3503 | 3502 |
3504 static void customMethodWithArgsMethodCallback(const v8::FunctionCallbackInfo<v8
::Value>& info) | 3503 static void customMethodWithArgsMethodCallback(const v8::FunctionCallbackInfo<v8
::Value>& info) |
3505 { | 3504 { |
3506 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); | 3505 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); |
3507 V8TestObject::customMethodWithArgsMethodCustom(info); | 3506 V8TestObject::customMethodWithArgsMethodCustom(info); |
3508 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | 3507 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
3509 } | 3508 } |
3510 | 3509 |
3511 static void addEventListenerMethod(const v8::FunctionCallbackInfo<v8::Value>& in
fo) | |
3512 { | |
3513 ExceptionState exceptionState(ExceptionState::ExecutionContext, "addEventLis
tener", "TestObject", info.Holder(), info.GetIsolate()); | |
3514 EventTarget* impl = V8TestObject::toNative(info.Holder()); | |
3515 if (DOMWindow* window = impl->toDOMWindow()) { | |
3516 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), window
->frame(), exceptionState)) { | |
3517 exceptionState.throwIfNeeded(); | |
3518 return; | |
3519 } | |
3520 if (!window->document()) | |
3521 return; | |
3522 } | |
3523 RefPtr<EventListener> listener = V8EventListenerList::getEventListener(info[
1], false, ListenerFindOrCreate); | |
3524 if (listener) { | |
3525 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, ev
entName, info[0]); | |
3526 impl->addEventListener(eventName, listener, info[2]->BooleanValue()); | |
3527 if (!impl->toNode()) | |
3528 addHiddenValueToArray(info.Holder(), info[1], V8TestObject::eventLis
tenerCacheIndex, info.GetIsolate()); | |
3529 } | |
3530 } | |
3531 | |
3532 static void addEventListenerMethodCallback(const v8::FunctionCallbackInfo<v8::Va
lue>& info) | |
3533 { | |
3534 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); | |
3535 TestObjectV8Internal::addEventListenerMethod(info); | |
3536 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | |
3537 } | |
3538 | |
3539 static void removeEventListenerMethod(const v8::FunctionCallbackInfo<v8::Value>&
info) | |
3540 { | |
3541 ExceptionState exceptionState(ExceptionState::ExecutionContext, "removeEvent
Listener", "TestObject", info.Holder(), info.GetIsolate()); | |
3542 EventTarget* impl = V8TestObject::toNative(info.Holder()); | |
3543 if (DOMWindow* window = impl->toDOMWindow()) { | |
3544 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), window
->frame(), exceptionState)) { | |
3545 exceptionState.throwIfNeeded(); | |
3546 return; | |
3547 } | |
3548 if (!window->document()) | |
3549 return; | |
3550 } | |
3551 RefPtr<EventListener> listener = V8EventListenerList::getEventListener(info[
1], false, ListenerFindOnly); | |
3552 if (listener) { | |
3553 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, ev
entName, info[0]); | |
3554 impl->removeEventListener(eventName, listener.get(), info[2]->BooleanVal
ue()); | |
3555 if (!impl->toNode()) | |
3556 removeHiddenValueFromArray(info.Holder(), info[1], V8TestObject::eve
ntListenerCacheIndex, info.GetIsolate()); | |
3557 } | |
3558 } | |
3559 | |
3560 static void removeEventListenerMethodCallback(const v8::FunctionCallbackInfo<v8:
:Value>& info) | |
3561 { | |
3562 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); | |
3563 TestObjectV8Internal::removeEventListenerMethod(info); | |
3564 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | |
3565 } | |
3566 | |
3567 static void withScriptStateVoidMethod(const v8::FunctionCallbackInfo<v8::Value>&
info) | 3510 static void withScriptStateVoidMethod(const v8::FunctionCallbackInfo<v8::Value>&
info) |
3568 { | 3511 { |
3569 TestObject* imp = V8TestObject::toNative(info.Holder()); | 3512 TestObject* imp = V8TestObject::toNative(info.Holder()); |
3570 ScriptState* currentState = ScriptState::current(); | 3513 ScriptState* currentState = ScriptState::current(); |
3571 if (!currentState) | 3514 if (!currentState) |
3572 return; | 3515 return; |
3573 ScriptState& state = *currentState; | 3516 ScriptState& state = *currentState; |
3574 imp->withScriptStateVoid(&state); | 3517 imp->withScriptStateVoid(&state); |
3575 if (state.hadException()) { | 3518 if (state.hadException()) { |
3576 v8::Local<v8::Value> exception = state.exception(); | 3519 v8::Local<v8::Value> exception = state.exception(); |
(...skipping 1863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5440 {"methodReturningSequence", TestObjectV8Internal::methodReturningSequenceMet
hodCallback, 0, 1}, | 5383 {"methodReturningSequence", TestObjectV8Internal::methodReturningSequenceMet
hodCallback, 0, 1}, |
5441 {"methodWithEnumArg", TestObjectV8Internal::methodWithEnumArgMethodCallback,
0, 1}, | 5384 {"methodWithEnumArg", TestObjectV8Internal::methodWithEnumArgMethodCallback,
0, 1}, |
5442 {"methodThatRequiresAllArgsAndThrows", TestObjectV8Internal::methodThatRequi
resAllArgsAndThrowsMethodCallback, 0, 2}, | 5385 {"methodThatRequiresAllArgsAndThrows", TestObjectV8Internal::methodThatRequi
resAllArgsAndThrowsMethodCallback, 0, 2}, |
5443 {"methodQueryListListener", TestObjectV8Internal::methodQueryListListenerMet
hodCallback, 0, 1}, | 5386 {"methodQueryListListener", TestObjectV8Internal::methodQueryListListenerMet
hodCallback, 0, 1}, |
5444 {"serializedValue", TestObjectV8Internal::serializedValueMethodCallback, 0,
1}, | 5387 {"serializedValue", TestObjectV8Internal::serializedValueMethodCallback, 0,
1}, |
5445 {"optionsObject", TestObjectV8Internal::optionsObjectMethodCallback, 0, 1}, | 5388 {"optionsObject", TestObjectV8Internal::optionsObjectMethodCallback, 0, 1}, |
5446 {"optionsObjectList", TestObjectV8Internal::optionsObjectListMethodCallback,
0, 1}, | 5389 {"optionsObjectList", TestObjectV8Internal::optionsObjectListMethodCallback,
0, 1}, |
5447 {"methodWithException", TestObjectV8Internal::methodWithExceptionMethodCallb
ack, 0, 0}, | 5390 {"methodWithException", TestObjectV8Internal::methodWithExceptionMethodCallb
ack, 0, 0}, |
5448 {"customMethod", TestObjectV8Internal::customMethodMethodCallback, 0, 0}, | 5391 {"customMethod", TestObjectV8Internal::customMethodMethodCallback, 0, 0}, |
5449 {"customMethodWithArgs", TestObjectV8Internal::customMethodWithArgsMethodCal
lback, 0, 3}, | 5392 {"customMethodWithArgs", TestObjectV8Internal::customMethodWithArgsMethodCal
lback, 0, 3}, |
5450 {"addEventListener", TestObjectV8Internal::addEventListenerMethodCallback, 0
, 2}, | |
5451 {"removeEventListener", TestObjectV8Internal::removeEventListenerMethodCallb
ack, 0, 2}, | |
5452 {"withScriptStateVoid", TestObjectV8Internal::withScriptStateVoidMethodCallb
ack, 0, 0}, | 5393 {"withScriptStateVoid", TestObjectV8Internal::withScriptStateVoidMethodCallb
ack, 0, 0}, |
5453 {"withScriptStateObj", TestObjectV8Internal::withScriptStateObjMethodCallbac
k, 0, 0}, | 5394 {"withScriptStateObj", TestObjectV8Internal::withScriptStateObjMethodCallbac
k, 0, 0}, |
5454 {"withScriptStateVoidException", TestObjectV8Internal::withScriptStateVoidEx
ceptionMethodCallback, 0, 0}, | 5395 {"withScriptStateVoidException", TestObjectV8Internal::withScriptStateVoidEx
ceptionMethodCallback, 0, 0}, |
5455 {"withScriptStateObjException", TestObjectV8Internal::withScriptStateObjExce
ptionMethodCallback, 0, 0}, | 5396 {"withScriptStateObjException", TestObjectV8Internal::withScriptStateObjExce
ptionMethodCallback, 0, 0}, |
5456 {"withExecutionContext", TestObjectV8Internal::withExecutionContextMethodCal
lback, 0, 0}, | 5397 {"withExecutionContext", TestObjectV8Internal::withExecutionContextMethodCal
lback, 0, 0}, |
5457 {"withExecutionContextAndScriptState", TestObjectV8Internal::withExecutionCo
ntextAndScriptStateMethodCallback, 0, 0}, | 5398 {"withExecutionContextAndScriptState", TestObjectV8Internal::withExecutionCo
ntextAndScriptStateMethodCallback, 0, 0}, |
5458 {"withExecutionContextAndScriptStateObjException", TestObjectV8Internal::wit
hExecutionContextAndScriptStateObjExceptionMethodCallback, 0, 0}, | 5399 {"withExecutionContextAndScriptStateObjException", TestObjectV8Internal::wit
hExecutionContextAndScriptStateObjExceptionMethodCallback, 0, 0}, |
5459 {"withExecutionContextAndScriptStateWithSpaces", TestObjectV8Internal::withE
xecutionContextAndScriptStateWithSpacesMethodCallback, 0, 0}, | 5400 {"withExecutionContextAndScriptStateWithSpaces", TestObjectV8Internal::withE
xecutionContextAndScriptStateWithSpacesMethodCallback, 0, 0}, |
5460 {"withActiveWindowAndFirstWindow", TestObjectV8Internal::withActiveWindowAnd
FirstWindowMethodCallback, 0, 0}, | 5401 {"withActiveWindowAndFirstWindow", TestObjectV8Internal::withActiveWindowAnd
FirstWindowMethodCallback, 0, 0}, |
5461 {"methodWithOptionalArg", TestObjectV8Internal::methodWithOptionalArgMethodC
allback, 0, 0}, | 5402 {"methodWithOptionalArg", TestObjectV8Internal::methodWithOptionalArgMethodC
allback, 0, 0}, |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5630 fromInternalPointer(object)->deref(); | 5571 fromInternalPointer(object)->deref(); |
5631 } | 5572 } |
5632 | 5573 |
5633 template<> | 5574 template<> |
5634 v8::Handle<v8::Value> toV8NoInline(TestObject* impl, v8::Handle<v8::Object> crea
tionContext, v8::Isolate* isolate) | 5575 v8::Handle<v8::Value> toV8NoInline(TestObject* impl, v8::Handle<v8::Object> crea
tionContext, v8::Isolate* isolate) |
5635 { | 5576 { |
5636 return toV8(impl, creationContext, isolate); | 5577 return toV8(impl, creationContext, isolate); |
5637 } | 5578 } |
5638 | 5579 |
5639 } // namespace WebCore | 5580 } // namespace WebCore |
OLD | NEW |