OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 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 14 matching lines...) Expand all Loading... |
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/V8Utilities.h" | 32 #include "bindings/v8/V8Utilities.h" |
33 | 33 |
34 #include "V8MessagePort.h" | 34 #include "V8MessagePort.h" |
| 35 #include "bindings/v8/ExceptionMessages.h" |
35 #include "bindings/v8/ScriptState.h" | 36 #include "bindings/v8/ScriptState.h" |
36 #include "bindings/v8/V8AbstractEventListener.h" | 37 #include "bindings/v8/V8AbstractEventListener.h" |
37 #include "bindings/v8/V8Binding.h" | 38 #include "bindings/v8/V8Binding.h" |
38 #include "bindings/v8/custom/V8ArrayBufferCustom.h" | 39 #include "bindings/v8/custom/V8ArrayBufferCustom.h" |
39 #include "core/dom/Document.h" | 40 #include "core/dom/Document.h" |
40 #include "core/dom/ExceptionCode.h" | 41 #include "core/dom/ExceptionCode.h" |
41 #include "core/dom/ExecutionContext.h" | 42 #include "core/dom/ExecutionContext.h" |
42 #include "core/dom/MessagePort.h" | 43 #include "core/dom/MessagePort.h" |
43 #include "core/frame/Frame.h" | 44 #include "core/frame/Frame.h" |
44 #include "core/workers/WorkerGlobalScope.h" | 45 #include "core/workers/WorkerGlobalScope.h" |
(...skipping 24 matching lines...) Expand all Loading... |
69 ports.resize(0); | 70 ports.resize(0); |
70 arrayBuffers.resize(0); | 71 arrayBuffers.resize(0); |
71 return true; | 72 return true; |
72 } | 73 } |
73 | 74 |
74 uint32_t length = 0; | 75 uint32_t length = 0; |
75 if (value->IsArray()) { | 76 if (value->IsArray()) { |
76 v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(value); | 77 v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(value); |
77 length = array->Length(); | 78 length = array->Length(); |
78 } else { | 79 } else { |
79 if (toV8Sequence(value, length, ¬ASequence, isolate).IsEmpty()) | 80 if (toV8Sequence(value, length, notASequence, isolate).IsEmpty()) |
80 return false; | 81 return false; |
81 } | 82 } |
82 | 83 |
83 v8::Local<v8::Object> transferrables = v8::Local<v8::Object>::Cast(value); | 84 v8::Local<v8::Object> transferrables = v8::Local<v8::Object>::Cast(value); |
84 | 85 |
85 // Validate the passed array of transferrables. | 86 // Validate the passed array of transferrables. |
86 for (unsigned int i = 0; i < length; ++i) { | 87 for (unsigned int i = 0; i < length; ++i) { |
87 v8::Local<v8::Value> transferrable = transferrables->Get(i); | 88 v8::Local<v8::Value> transferrable = transferrables->Get(i); |
88 // Validation of non-null objects, per HTML5 spec 10.3.3. | 89 // Validation of non-null objects, per HTML5 spec 10.3.3. |
89 if (isUndefinedOrNull(transferrable)) { | 90 if (isUndefinedOrNull(transferrable)) { |
(...skipping 12 matching lines...) Expand all Loading... |
102 } else if (V8ArrayBuffer::HasInstance(transferrable, isolate, worldType(
isolate))) | 103 } else if (V8ArrayBuffer::HasInstance(transferrable, isolate, worldType(
isolate))) |
103 arrayBuffers.append(V8ArrayBuffer::toNative(v8::Handle<v8::Object>::
Cast(transferrable))); | 104 arrayBuffers.append(V8ArrayBuffer::toNative(v8::Handle<v8::Object>::
Cast(transferrable))); |
104 else { | 105 else { |
105 setDOMException(DataCloneError, isolate); | 106 setDOMException(DataCloneError, isolate); |
106 return false; | 107 return false; |
107 } | 108 } |
108 } | 109 } |
109 return true; | 110 return true; |
110 } | 111 } |
111 | 112 |
112 bool getMessagePortArray(v8::Local<v8::Value> value, MessagePortArray& ports, v8
::Isolate* isolate) | 113 bool getMessagePortArray(v8::Local<v8::Value> value, const String& propertyName,
MessagePortArray& ports, v8::Isolate* isolate) |
113 { | 114 { |
114 if (isUndefinedOrNull(value)) { | 115 if (isUndefinedOrNull(value)) { |
115 ports.resize(0); | 116 ports.resize(0); |
116 return true; | 117 return true; |
117 } | 118 } |
118 if (!value->IsArray()) { | 119 if (!value->IsArray()) { |
119 throwUninformativeAndGenericTypeError(isolate); | 120 throwTypeError(ExceptionMessages::notASequenceTypeProperty(propertyName)
, isolate); |
120 return false; | 121 return false; |
121 } | 122 } |
122 bool success = false; | 123 bool success = false; |
123 ports = toRefPtrNativeArray<MessagePort, V8MessagePort>(value, isolate, &suc
cess); | 124 ports = toRefPtrNativeArray<MessagePort, V8MessagePort>(value, propertyName,
isolate, &success); |
124 return success; | 125 return success; |
125 } | 126 } |
126 | 127 |
| 128 bool getMessagePortArray(v8::Local<v8::Value> value, int argumentIndex, MessageP
ortArray& ports, v8::Isolate* isolate) |
| 129 { |
| 130 if (isUndefinedOrNull(value)) { |
| 131 ports.resize(0); |
| 132 return true; |
| 133 } |
| 134 if (!value->IsArray()) { |
| 135 throwTypeError(ExceptionMessages::notASequenceTypeArgumentOrValue(argume
ntIndex), isolate); |
| 136 return false; |
| 137 } |
| 138 bool success = false; |
| 139 ports = toRefPtrNativeArray<MessagePort, V8MessagePort>(value, argumentIndex
, isolate, &success); |
| 140 return success; |
| 141 } |
| 142 |
127 void removeHiddenDependency(v8::Handle<v8::Object> object, v8::Local<v8::Value>
value, int cacheIndex, v8::Isolate* isolate) | 143 void removeHiddenDependency(v8::Handle<v8::Object> object, v8::Local<v8::Value>
value, int cacheIndex, v8::Isolate* isolate) |
128 { | 144 { |
129 v8::Local<v8::Value> cache = object->GetInternalField(cacheIndex); | 145 v8::Local<v8::Value> cache = object->GetInternalField(cacheIndex); |
130 if (!cache->IsArray()) | 146 if (!cache->IsArray()) |
131 return; | 147 return; |
132 v8::Local<v8::Array> cacheArray = v8::Local<v8::Array>::Cast(cache); | 148 v8::Local<v8::Array> cacheArray = v8::Local<v8::Array>::Cast(cache); |
133 for (int i = cacheArray->Length() - 1; i >= 0; --i) { | 149 for (int i = cacheArray->Length() - 1; i >= 0; --i) { |
134 v8::Local<v8::Value> cached = cacheArray->Get(v8::Integer::New(i, isolat
e)); | 150 v8::Local<v8::Value> cached = cacheArray->Get(v8::Integer::New(i, isolat
e)); |
135 if (cached->StrictEquals(value)) { | 151 if (cached->StrictEquals(value)) { |
136 cacheArray->Delete(i); | 152 cacheArray->Delete(i); |
(...skipping 19 matching lines...) Expand all Loading... |
156 | 172 |
157 ExecutionContext* getExecutionContext() | 173 ExecutionContext* getExecutionContext() |
158 { | 174 { |
159 if (WorkerScriptController* controller = WorkerScriptController::controllerF
orContext()) | 175 if (WorkerScriptController* controller = WorkerScriptController::controllerF
orContext()) |
160 return &controller->workerGlobalScope(); | 176 return &controller->workerGlobalScope(); |
161 | 177 |
162 return currentDocument(); | 178 return currentDocument(); |
163 } | 179 } |
164 | 180 |
165 } // namespace WebCore | 181 } // namespace WebCore |
OLD | NEW |