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/InspectorTraceEvents.h" | 57 #include "core/inspector/InspectorTraceEvents.h" |
56 #include "core/loader/FrameLoader.h" | 58 #include "core/loader/FrameLoader.h" |
57 #include "core/loader/FrameLoaderClient.h" | 59 #include "core/loader/FrameLoaderClient.h" |
58 #include "core/workers/WorkerGlobalScope.h" | 60 #include "core/workers/WorkerGlobalScope.h" |
59 #include "core/xml/XPathNSResolver.h" | 61 #include "core/xml/XPathNSResolver.h" |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 // exists on a prototype chain of v8Value. | 751 // exists on a prototype chain of v8Value. |
750 if (DOMWindow* window = toDOMWindow(isolate, value)) | 752 if (DOMWindow* window = toDOMWindow(isolate, value)) |
751 return static_cast<EventTarget*>(window); | 753 return static_cast<EventTarget*>(window); |
752 if (V8EventTarget::hasInstance(value, isolate)) { | 754 if (V8EventTarget::hasInstance(value, isolate)) { |
753 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value); | 755 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value); |
754 return toWrapperTypeInfo(object)->toEventTarget(object); | 756 return toWrapperTypeInfo(object)->toEventTarget(object); |
755 } | 757 } |
756 return 0; | 758 return 0; |
757 } | 759 } |
758 | 760 |
| 761 void toFlexibleArrayBufferView(v8::Isolate* isolate, v8::Local<v8::Value> value,
FlexibleArrayBufferView& result, void* storage) |
| 762 { |
| 763 ASSERT(value->IsArrayBufferView()); |
| 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 |
759 v8::Local<v8::Context> toV8Context(ExecutionContext* context, DOMWrapperWorld& w
orld) | 774 v8::Local<v8::Context> toV8Context(ExecutionContext* context, DOMWrapperWorld& w
orld) |
760 { | 775 { |
761 ASSERT(context); | 776 ASSERT(context); |
762 if (context->isDocument()) { | 777 if (context->isDocument()) { |
763 if (LocalFrame* frame = toDocument(context)->frame()) | 778 if (LocalFrame* frame = toDocument(context)->frame()) |
764 return toV8Context(frame, world); | 779 return toV8Context(frame, world); |
765 } else if (context->isWorkerGlobalScope()) { | 780 } else if (context->isWorkerGlobalScope()) { |
766 if (WorkerScriptController* script = toWorkerGlobalScope(context)->scrip
t()) { | 781 if (WorkerScriptController* script = toWorkerGlobalScope(context)->scrip
t()) { |
767 if (script->scriptState()->contextIsValid()) | 782 if (script->scriptState()->contextIsValid()) |
768 return script->scriptState()->context(); | 783 return script->scriptState()->context(); |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 v8::Local<v8::Value> data = info.Data(); | 1019 v8::Local<v8::Value> data = info.Data(); |
1005 ASSERT(data->IsExternal()); | 1020 ASSERT(data->IsExternal()); |
1006 V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->Cre
ationContext()); | 1021 V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->Cre
ationContext()); |
1007 if (!perContextData) | 1022 if (!perContextData) |
1008 return; | 1023 return; |
1009 v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::u
nwrap(data))); | 1024 v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::u
nwrap(data))); |
1010 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); | 1025 TRACE_EVENT_SET_SAMPLING_STATE("v8", "V8Execution"); |
1011 } | 1026 } |
1012 | 1027 |
1013 } // namespace blink | 1028 } // namespace blink |
OLD | NEW |