| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009 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 15 matching lines...) Expand all Loading... |
| 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/core/v8/V8Binding.h" | 32 #include "bindings/core/v8/V8Binding.h" |
| 33 | 33 |
| 34 #include "bindings/core/v8/ScriptController.h" | 34 #include "bindings/core/v8/ScriptController.h" |
| 35 #include "bindings/core/v8/V8AbstractEventListener.h" | 35 #include "bindings/core/v8/V8AbstractEventListener.h" |
| 36 #include "bindings/core/v8/V8ArrayBufferView.h" |
| 36 #include "bindings/core/v8/V8BindingMacros.h" | 37 #include "bindings/core/v8/V8BindingMacros.h" |
| 37 #include "bindings/core/v8/V8Element.h" | 38 #include "bindings/core/v8/V8Element.h" |
| 38 #include "bindings/core/v8/V8EventTarget.h" | 39 #include "bindings/core/v8/V8EventTarget.h" |
| 39 #include "bindings/core/v8/V8NodeFilter.h" | 40 #include "bindings/core/v8/V8NodeFilter.h" |
| 40 #include "bindings/core/v8/V8NodeFilterCondition.h" | 41 #include "bindings/core/v8/V8NodeFilterCondition.h" |
| 41 #include "bindings/core/v8/V8ObjectConstructor.h" | 42 #include "bindings/core/v8/V8ObjectConstructor.h" |
| 42 #include "bindings/core/v8/V8Window.h" | 43 #include "bindings/core/v8/V8Window.h" |
| 43 #include "bindings/core/v8/V8WorkerGlobalScope.h" | 44 #include "bindings/core/v8/V8WorkerGlobalScope.h" |
| 44 #include "bindings/core/v8/V8XPathNSResolver.h" | 45 #include "bindings/core/v8/V8XPathNSResolver.h" |
| 45 #include "bindings/core/v8/WindowProxy.h" | 46 #include "bindings/core/v8/WindowProxy.h" |
| 46 #include "bindings/core/v8/WorkerScriptController.h" | 47 #include "bindings/core/v8/WorkerScriptController.h" |
| 47 #include "bindings/core/v8/custom/V8CustomXPathNSResolver.h" | 48 #include "bindings/core/v8/custom/V8CustomXPathNSResolver.h" |
| 48 #include "core/dom/Document.h" | 49 #include "core/dom/Document.h" |
| 49 #include "core/dom/Element.h" | 50 #include "core/dom/Element.h" |
| 51 #include "core/dom/FlexibleArrayBufferView.h" |
| 50 #include "core/dom/NodeFilter.h" | 52 #include "core/dom/NodeFilter.h" |
| 51 #include "core/dom/QualifiedName.h" | 53 #include "core/dom/QualifiedName.h" |
| 52 #include "core/frame/LocalDOMWindow.h" | 54 #include "core/frame/LocalDOMWindow.h" |
| 53 #include "core/frame/LocalFrame.h" | 55 #include "core/frame/LocalFrame.h" |
| 54 #include "core/frame/Settings.h" | 56 #include "core/frame/Settings.h" |
| 55 #include "core/inspector/BindingVisitors.h" | 57 #include "core/inspector/BindingVisitors.h" |
| 56 #include "core/inspector/InspectorTraceEvents.h" | 58 #include "core/inspector/InspectorTraceEvents.h" |
| 57 #include "core/loader/FrameLoader.h" | 59 #include "core/loader/FrameLoader.h" |
| 58 #include "core/loader/FrameLoaderClient.h" | 60 #include "core/loader/FrameLoaderClient.h" |
| 59 #include "core/workers/WorkerGlobalScope.h" | 61 #include "core/workers/WorkerGlobalScope.h" |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 // exists on a prototype chain of v8Value. | 750 // exists on a prototype chain of v8Value. |
| 749 if (DOMWindow* window = toDOMWindow(isolate, value)) | 751 if (DOMWindow* window = toDOMWindow(isolate, value)) |
| 750 return static_cast<EventTarget*>(window); | 752 return static_cast<EventTarget*>(window); |
| 751 if (V8EventTarget::hasInstance(value, isolate)) { | 753 if (V8EventTarget::hasInstance(value, isolate)) { |
| 752 v8::Local<v8::Object> object = v8::Handle<v8::Object>::Cast(value); | 754 v8::Local<v8::Object> object = v8::Handle<v8::Object>::Cast(value); |
| 753 return toWrapperTypeInfo(object)->toEventTarget(object); | 755 return toWrapperTypeInfo(object)->toEventTarget(object); |
| 754 } | 756 } |
| 755 return 0; | 757 return 0; |
| 756 } | 758 } |
| 757 | 759 |
| 760 void toFlexibleArrayBufferView(v8::Isolate* isolate, v8::Handle<v8::Value> value
, FlexibleArrayBufferView& result, void* storage) |
| 761 { |
| 762 if (!value->IsArrayBufferView()) |
| 763 return; |
| 764 v8::Local<v8::ArrayBufferView> buffer = value.As<v8::ArrayBufferView>(); |
| 765 if (!storage) { |
| 766 result.setFull(V8ArrayBufferView::toImpl(buffer)); |
| 767 return; |
| 768 } |
| 769 size_t length = buffer->ByteLength(); |
| 770 buffer->CopyContents(storage, length); |
| 771 result.setSmall(storage, length); |
| 772 } |
| 773 |
| 758 v8::Local<v8::Context> toV8Context(ExecutionContext* context, DOMWrapperWorld& w
orld) | 774 v8::Local<v8::Context> toV8Context(ExecutionContext* context, DOMWrapperWorld& w
orld) |
| 759 { | 775 { |
| 760 ASSERT(context); | 776 ASSERT(context); |
| 761 if (context->isDocument()) { | 777 if (context->isDocument()) { |
| 762 if (LocalFrame* frame = toDocument(context)->frame()) | 778 if (LocalFrame* frame = toDocument(context)->frame()) |
| 763 return frame->script().windowProxy(world)->context(); | 779 return frame->script().windowProxy(world)->context(); |
| 764 } else if (context->isWorkerGlobalScope()) { | 780 } else if (context->isWorkerGlobalScope()) { |
| 765 if (WorkerScriptController* script = toWorkerGlobalScope(context)->scrip
t()) | 781 if (WorkerScriptController* script = toWorkerGlobalScope(context)->scrip
t()) |
| 766 return script->context(); | 782 return script->context(); |
| 767 } | 783 } |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 983 v8::Local<v8::Value> data = info.Data(); | 999 v8::Local<v8::Value> data = info.Data(); |
| 984 ASSERT(data->IsExternal()); | 1000 ASSERT(data->IsExternal()); |
| 985 V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->Cre
ationContext()); | 1001 V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->Cre
ationContext()); |
| 986 if (!perContextData) | 1002 if (!perContextData) |
| 987 return; | 1003 return; |
| 988 v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::u
nwrap(data))); | 1004 v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::u
nwrap(data))); |
| 989 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); | 1005 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
| 990 } | 1006 } |
| 991 | 1007 |
| 992 } // namespace blink | 1008 } // namespace blink |
| OLD | NEW |