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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "V8IDBKeyRange.h" | 31 #include "V8IDBKeyRange.h" |
32 #include "V8MIDIPort.h" | 32 #include "V8MIDIPort.h" |
33 #include "V8MediaKeyError.h" | 33 #include "V8MediaKeyError.h" |
34 #include "V8SpeechRecognitionError.h" | 34 #include "V8SpeechRecognitionError.h" |
35 #include "V8SpeechRecognitionResult.h" | 35 #include "V8SpeechRecognitionResult.h" |
36 #include "V8SpeechRecognitionResultList.h" | 36 #include "V8SpeechRecognitionResultList.h" |
37 #include "V8Storage.h" | 37 #include "V8Storage.h" |
38 #include "V8VoidCallback.h" | 38 #include "V8VoidCallback.h" |
39 #include "V8Window.h" | 39 #include "V8Window.h" |
40 #include "bindings/v8/ArrayValue.h" | 40 #include "bindings/v8/ArrayValue.h" |
| 41 #include "bindings/v8/ExceptionMessages.h" |
| 42 #include "bindings/v8/ExceptionState.h" |
41 #include "bindings/v8/V8Binding.h" | 43 #include "bindings/v8/V8Binding.h" |
42 #include "bindings/v8/V8Utilities.h" | 44 #include "bindings/v8/V8Utilities.h" |
43 #include "bindings/v8/custom/V8ArrayBufferViewCustom.h" | 45 #include "bindings/v8/custom/V8ArrayBufferViewCustom.h" |
44 #include "bindings/v8/custom/V8Uint8ArrayCustom.h" | 46 #include "bindings/v8/custom/V8Uint8ArrayCustom.h" |
45 #include "modules/indexeddb/IDBKeyRange.h" | 47 #include "modules/indexeddb/IDBKeyRange.h" |
46 #include "modules/speech/SpeechRecognitionError.h" | 48 #include "modules/speech/SpeechRecognitionError.h" |
47 #include "modules/speech/SpeechRecognitionResult.h" | 49 #include "modules/speech/SpeechRecognitionResult.h" |
48 #include "modules/speech/SpeechRecognitionResultList.h" | 50 #include "modules/speech/SpeechRecognitionResultList.h" |
49 #include "wtf/MathExtras.h" | 51 #include "wtf/MathExtras.h" |
50 | 52 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 return !isUndefinedOrNull() && m_options->IsObject(); | 86 return !isUndefinedOrNull() && m_options->IsObject(); |
85 } | 87 } |
86 | 88 |
87 bool Dictionary::isUndefinedOrNull() const | 89 bool Dictionary::isUndefinedOrNull() const |
88 { | 90 { |
89 if (m_options.IsEmpty()) | 91 if (m_options.IsEmpty()) |
90 return true; | 92 return true; |
91 return WebCore::isUndefinedOrNull(m_options); | 93 return WebCore::isUndefinedOrNull(m_options); |
92 } | 94 } |
93 | 95 |
| 96 bool Dictionary::hasProperty(const String& key) const |
| 97 { |
| 98 if (isUndefinedOrNull()) |
| 99 return false; |
| 100 v8::Local<v8::Object> options = m_options->ToObject(); |
| 101 ASSERT(!options.IsEmpty()); |
| 102 |
| 103 ASSERT(m_isolate); |
| 104 ASSERT(m_isolate == v8::Isolate::GetCurrent()); |
| 105 v8::Handle<v8::String> v8Key = v8String(key, m_isolate); |
| 106 if (!options->Has(v8Key)) |
| 107 return false; |
| 108 |
| 109 return true; |
| 110 } |
| 111 |
94 bool Dictionary::getKey(const String& key, v8::Local<v8::Value>& value) const | 112 bool Dictionary::getKey(const String& key, v8::Local<v8::Value>& value) const |
95 { | 113 { |
96 if (isUndefinedOrNull()) | 114 if (isUndefinedOrNull()) |
97 return false; | 115 return false; |
98 v8::Local<v8::Object> options = m_options->ToObject(); | 116 v8::Local<v8::Object> options = m_options->ToObject(); |
99 ASSERT(!options.IsEmpty()); | 117 ASSERT(!options.IsEmpty()); |
100 | 118 |
101 ASSERT(m_isolate); | 119 ASSERT(m_isolate); |
102 ASSERT(m_isolate == v8::Isolate::GetCurrent()); | 120 ASSERT(m_isolate == v8::Isolate::GetCurrent()); |
103 v8::Handle<v8::String> v8Key = v8String(key, m_isolate); | 121 v8::Handle<v8::String> v8Key = v8String(key, m_isolate); |
(...skipping 16 matching lines...) Expand all Loading... |
120 if (!getKey(key, v8Value)) | 138 if (!getKey(key, v8Value)) |
121 return false; | 139 return false; |
122 | 140 |
123 v8::Local<v8::Boolean> v8Bool = v8Value->ToBoolean(); | 141 v8::Local<v8::Boolean> v8Bool = v8Value->ToBoolean(); |
124 if (v8Bool.IsEmpty()) | 142 if (v8Bool.IsEmpty()) |
125 return false; | 143 return false; |
126 value = v8Bool->Value(); | 144 value = v8Bool->Value(); |
127 return true; | 145 return true; |
128 } | 146 } |
129 | 147 |
| 148 bool Dictionary::convert(ConversionContext& context, const String& key, bool& va
lue) const |
| 149 { |
| 150 ConversionContextScope scope(context); |
| 151 get(key, value); |
| 152 return true; |
| 153 } |
| 154 |
130 bool Dictionary::get(const String& key, int32_t& value) const | 155 bool Dictionary::get(const String& key, int32_t& value) const |
131 { | 156 { |
132 v8::Local<v8::Value> v8Value; | 157 v8::Local<v8::Value> v8Value; |
133 if (!getKey(key, v8Value)) | 158 if (!getKey(key, v8Value)) |
134 return false; | 159 return false; |
135 | 160 |
136 v8::Local<v8::Int32> v8Int32 = v8Value->ToInt32(); | 161 v8::Local<v8::Int32> v8Int32 = v8Value->ToInt32(); |
137 if (v8Int32.IsEmpty()) | 162 if (v8Int32.IsEmpty()) |
138 return false; | 163 return false; |
139 value = v8Int32->Value(); | 164 value = v8Int32->Value(); |
140 return true; | 165 return true; |
141 } | 166 } |
142 | 167 |
143 bool Dictionary::get(const String& key, double& value, bool& hasValue) const | 168 bool Dictionary::get(const String& key, double& value, bool& hasValue) const |
144 { | 169 { |
145 v8::Local<v8::Value> v8Value; | 170 v8::Local<v8::Value> v8Value; |
146 if (!getKey(key, v8Value)) { | 171 if (!getKey(key, v8Value)) { |
147 hasValue = false; | 172 hasValue = false; |
148 return false; | 173 return false; |
149 } | 174 } |
150 | 175 |
151 hasValue = true; | 176 hasValue = true; |
152 v8::Local<v8::Number> v8Number = v8Value->ToNumber(); | 177 V8TRYCATCH_RETURN(v8::Local<v8::Number>, v8Number, v8Value->ToNumber(), fals
e); |
153 if (v8Number.IsEmpty()) | 178 if (v8Number.IsEmpty()) |
154 return false; | 179 return false; |
155 value = v8Number->Value(); | 180 value = v8Number->Value(); |
156 return true; | 181 return true; |
157 } | 182 } |
158 | 183 |
159 bool Dictionary::get(const String& key, double& value) const | 184 bool Dictionary::get(const String& key, double& value) const |
160 { | 185 { |
161 bool unused; | 186 bool unused; |
162 return get(key, value, unused); | 187 return get(key, value, unused); |
163 } | 188 } |
164 | 189 |
| 190 bool Dictionary::convert(ConversionContext& context, const String& key, double&
value) const |
| 191 { |
| 192 ConversionContextScope scope(context); |
| 193 |
| 194 bool hasValue = false; |
| 195 if (!get(key, value, hasValue) && hasValue) { |
| 196 context.throwTypeError(ExceptionMessages::incorrectPropertyType(key, "is
not of type 'double'.")); |
| 197 return false; |
| 198 } |
| 199 return true; |
| 200 } |
| 201 |
165 bool Dictionary::get(const String& key, String& value) const | 202 bool Dictionary::get(const String& key, String& value) const |
166 { | 203 { |
167 v8::Local<v8::Value> v8Value; | 204 v8::Local<v8::Value> v8Value; |
168 if (!getKey(key, v8Value)) | 205 if (!getKey(key, v8Value)) |
169 return false; | 206 return false; |
170 | 207 |
171 V8TRYCATCH_FOR_V8STRINGRESOURCE_RETURN(V8StringResource<>, stringValue, v8Va
lue, false); | 208 V8TRYCATCH_FOR_V8STRINGRESOURCE_RETURN(V8StringResource<>, stringValue, v8Va
lue, false); |
172 value = stringValue; | 209 value = stringValue; |
173 return true; | 210 return true; |
174 } | 211 } |
175 | 212 |
| 213 bool Dictionary::convert(ConversionContext& context, const String& key, String&
value) const |
| 214 { |
| 215 ConversionContextScope scope(context); |
| 216 |
| 217 v8::Local<v8::Value> v8Value; |
| 218 if (!getKey(key, v8Value)) |
| 219 return true; |
| 220 |
| 221 V8TRYCATCH_FOR_V8STRINGRESOURCE_RETURN(V8StringResource<>, stringValue, v8Va
lue, false); |
| 222 value = stringValue; |
| 223 return true; |
| 224 } |
| 225 |
176 bool Dictionary::get(const String& key, ScriptValue& value) const | 226 bool Dictionary::get(const String& key, ScriptValue& value) const |
177 { | 227 { |
178 v8::Local<v8::Value> v8Value; | 228 v8::Local<v8::Value> v8Value; |
179 if (!getKey(key, v8Value)) | 229 if (!getKey(key, v8Value)) |
180 return false; | 230 return false; |
181 | 231 |
182 value = ScriptValue(v8Value, m_isolate); | 232 value = ScriptValue(v8Value, m_isolate); |
183 return true; | 233 return true; |
184 } | 234 } |
185 | 235 |
| 236 bool Dictionary::convert(ConversionContext& context, const String& key, ScriptVa
lue& value) const |
| 237 { |
| 238 ConversionContextScope scope(context); |
| 239 |
| 240 get(key, value); |
| 241 return true; |
| 242 } |
| 243 |
186 bool Dictionary::get(const String& key, unsigned short& value) const | 244 bool Dictionary::get(const String& key, unsigned short& value) const |
187 { | 245 { |
188 v8::Local<v8::Value> v8Value; | 246 v8::Local<v8::Value> v8Value; |
189 if (!getKey(key, v8Value)) | 247 if (!getKey(key, v8Value)) |
190 return false; | 248 return false; |
191 | 249 |
192 v8::Local<v8::Int32> v8Int32 = v8Value->ToInt32(); | 250 v8::Local<v8::Int32> v8Int32 = v8Value->ToInt32(); |
193 if (v8Int32.IsEmpty()) | 251 if (v8Int32.IsEmpty()) |
194 return false; | 252 return false; |
195 value = static_cast<unsigned short>(v8Int32->Value()); | 253 value = static_cast<unsigned short>(v8Int32->Value()); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 value = static_cast<unsigned long>(v8Integer->Value()); | 292 value = static_cast<unsigned long>(v8Integer->Value()); |
235 return true; | 293 return true; |
236 } | 294 } |
237 | 295 |
238 bool Dictionary::get(const String& key, unsigned long long& value) const | 296 bool Dictionary::get(const String& key, unsigned long long& value) const |
239 { | 297 { |
240 v8::Local<v8::Value> v8Value; | 298 v8::Local<v8::Value> v8Value; |
241 if (!getKey(key, v8Value)) | 299 if (!getKey(key, v8Value)) |
242 return false; | 300 return false; |
243 | 301 |
244 v8::Local<v8::Number> v8Number = v8Value->ToNumber(); | 302 V8TRYCATCH_RETURN(v8::Local<v8::Number>, v8Number, v8Value->ToNumber(), fals
e); |
245 if (v8Number.IsEmpty()) | 303 if (v8Number.IsEmpty()) |
246 return false; | 304 return false; |
247 double d = v8Number->Value(); | 305 double d = v8Number->Value(); |
248 doubleToInteger(d, value); | 306 doubleToInteger(d, value); |
249 return true; | 307 return true; |
250 } | 308 } |
251 | 309 |
252 bool Dictionary::get(const String& key, RefPtr<DOMWindow>& value) const | 310 bool Dictionary::get(const String& key, RefPtr<DOMWindow>& value) const |
253 { | 311 { |
254 v8::Local<v8::Value> v8Value; | 312 v8::Local<v8::Value> v8Value; |
(...skipping 28 matching lines...) Expand all Loading... |
283 { | 341 { |
284 v8::Local<v8::Value> v8Value; | 342 v8::Local<v8::Value> v8Value; |
285 if (!getKey(key, v8Value)) | 343 if (!getKey(key, v8Value)) |
286 return false; | 344 return false; |
287 | 345 |
288 ASSERT(m_isolate); | 346 ASSERT(m_isolate); |
289 ASSERT(m_isolate == v8::Isolate::GetCurrent()); | 347 ASSERT(m_isolate == v8::Isolate::GetCurrent()); |
290 return getMessagePortArray(v8Value, key, value, m_isolate); | 348 return getMessagePortArray(v8Value, key, value, m_isolate); |
291 } | 349 } |
292 | 350 |
| 351 bool Dictionary::convert(ConversionContext& context, const String& key, MessageP
ortArray& value) const |
| 352 { |
| 353 ConversionContextScope scope(context); |
| 354 |
| 355 v8::Local<v8::Value> v8Value; |
| 356 if (!getKey(key, v8Value)) |
| 357 return true; |
| 358 |
| 359 return get(key, value); |
| 360 } |
| 361 |
293 bool Dictionary::get(const String& key, HashSet<AtomicString>& value) const | 362 bool Dictionary::get(const String& key, HashSet<AtomicString>& value) const |
294 { | 363 { |
295 v8::Local<v8::Value> v8Value; | 364 v8::Local<v8::Value> v8Value; |
296 if (!getKey(key, v8Value)) | 365 if (!getKey(key, v8Value)) |
297 return false; | 366 return false; |
298 | 367 |
299 // FIXME: Support array-like objects | 368 // FIXME: Support array-like objects |
300 if (!v8Value->IsArray()) | 369 if (!v8Value->IsArray()) |
301 return false; | 370 return false; |
302 | 371 |
303 ASSERT(m_isolate); | 372 ASSERT(m_isolate); |
304 ASSERT(m_isolate == v8::Isolate::GetCurrent()); | 373 ASSERT(m_isolate == v8::Isolate::GetCurrent()); |
305 v8::Local<v8::Array> v8Array = v8::Local<v8::Array>::Cast(v8Value); | 374 v8::Local<v8::Array> v8Array = v8::Local<v8::Array>::Cast(v8Value); |
306 for (size_t i = 0; i < v8Array->Length(); ++i) { | 375 for (size_t i = 0; i < v8Array->Length(); ++i) { |
307 v8::Local<v8::Value> indexedValue = v8Array->Get(v8::Integer::New(i, m_i
solate)); | 376 v8::Local<v8::Value> indexedValue = v8Array->Get(v8::Integer::New(i, m_i
solate)); |
308 V8TRYCATCH_FOR_V8STRINGRESOURCE_RETURN(V8StringResource<>, stringValue,
indexedValue, false); | 377 V8TRYCATCH_FOR_V8STRINGRESOURCE_RETURN(V8StringResource<>, stringValue,
indexedValue, false); |
309 value.add(stringValue); | 378 value.add(stringValue); |
310 } | 379 } |
311 | 380 |
312 return true; | 381 return true; |
313 } | 382 } |
314 | 383 |
| 384 bool Dictionary::convert(ConversionContext& context, const String& key, HashSet<
AtomicString>& value) const |
| 385 { |
| 386 ConversionContextScope scope(context); |
| 387 |
| 388 v8::Local<v8::Value> v8Value; |
| 389 if (!getKey(key, v8Value)) |
| 390 return true; |
| 391 |
| 392 if (context.isNullable() && WebCore::isUndefinedOrNull(v8Value)) |
| 393 return true; |
| 394 |
| 395 if (!v8Value->IsArray()) { |
| 396 context.throwTypeError(ExceptionMessages::notASequenceTypeProperty(key))
; |
| 397 return false; |
| 398 } |
| 399 |
| 400 return get(key, value); |
| 401 } |
| 402 |
315 bool Dictionary::getWithUndefinedOrNullCheck(const String& key, String& value) c
onst | 403 bool Dictionary::getWithUndefinedOrNullCheck(const String& key, String& value) c
onst |
316 { | 404 { |
317 v8::Local<v8::Value> v8Value; | 405 v8::Local<v8::Value> v8Value; |
318 if (!getKey(key, v8Value) || v8Value->IsNull() || v8Value->IsUndefined()) | 406 if (!getKey(key, v8Value) || WebCore::isUndefinedOrNull(v8Value)) |
319 return false; | 407 return false; |
320 | 408 |
321 if (WebCore::isUndefinedOrNull(v8Value)) { | |
322 value = String(); | |
323 return true; | |
324 } | |
325 | |
326 V8TRYCATCH_FOR_V8STRINGRESOURCE_RETURN(V8StringResource<>, stringValue, v8Va
lue, false); | 409 V8TRYCATCH_FOR_V8STRINGRESOURCE_RETURN(V8StringResource<>, stringValue, v8Va
lue, false); |
327 value = stringValue; | 410 value = stringValue; |
328 return true; | 411 return true; |
329 } | 412 } |
330 | 413 |
331 bool Dictionary::get(const String& key, RefPtr<Uint8Array>& value) const | 414 bool Dictionary::get(const String& key, RefPtr<Uint8Array>& value) const |
332 { | 415 { |
333 v8::Local<v8::Value> v8Value; | 416 v8::Local<v8::Value> v8Value; |
334 if (!getKey(key, v8Value)) | 417 if (!getKey(key, v8Value)) |
335 return false; | 418 return false; |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
477 | 560 |
478 if (v8Value->IsObject()) { | 561 if (v8Value->IsObject()) { |
479 ASSERT(m_isolate); | 562 ASSERT(m_isolate); |
480 ASSERT(m_isolate == v8::Isolate::GetCurrent()); | 563 ASSERT(m_isolate == v8::Isolate::GetCurrent()); |
481 value = Dictionary(v8Value, m_isolate); | 564 value = Dictionary(v8Value, m_isolate); |
482 } | 565 } |
483 | 566 |
484 return true; | 567 return true; |
485 } | 568 } |
486 | 569 |
| 570 bool Dictionary::convert(ConversionContext& context, const String& key, Dictiona
ry& value) const |
| 571 { |
| 572 ConversionContextScope scope(context); |
| 573 |
| 574 v8::Local<v8::Value> v8Value; |
| 575 if (!getKey(key, v8Value)) |
| 576 return true; |
| 577 |
| 578 if (v8Value->IsObject()) |
| 579 return get(key, value); |
| 580 |
| 581 if (context.isNullable() && WebCore::isUndefinedOrNull(v8Value)) |
| 582 return true; |
| 583 |
| 584 context.throwTypeError(ExceptionMessages::incorrectPropertyType(key, "does n
ot have a Dictionary type.")); |
| 585 return false; |
| 586 } |
| 587 |
487 bool Dictionary::get(const String& key, Vector<String>& value) const | 588 bool Dictionary::get(const String& key, Vector<String>& value) const |
488 { | 589 { |
489 v8::Local<v8::Value> v8Value; | 590 v8::Local<v8::Value> v8Value; |
490 if (!getKey(key, v8Value)) | 591 if (!getKey(key, v8Value)) |
491 return false; | 592 return false; |
492 | 593 |
493 if (!v8Value->IsArray()) | 594 if (!v8Value->IsArray()) |
494 return false; | 595 return false; |
495 | 596 |
496 v8::Local<v8::Array> v8Array = v8::Local<v8::Array>::Cast(v8Value); | 597 v8::Local<v8::Array> v8Array = v8::Local<v8::Array>::Cast(v8Value); |
497 for (size_t i = 0; i < v8Array->Length(); ++i) { | 598 for (size_t i = 0; i < v8Array->Length(); ++i) { |
498 v8::Local<v8::Value> indexedValue = v8Array->Get(v8::Uint32::New(i, m_is
olate)); | 599 v8::Local<v8::Value> indexedValue = v8Array->Get(v8::Uint32::New(i, m_is
olate)); |
499 V8TRYCATCH_FOR_V8STRINGRESOURCE_RETURN(V8StringResource<>, stringValue,
indexedValue, false); | 600 V8TRYCATCH_FOR_V8STRINGRESOURCE_RETURN(V8StringResource<>, stringValue,
indexedValue, false); |
500 value.append(stringValue); | 601 value.append(stringValue); |
501 } | 602 } |
502 | 603 |
503 return true; | 604 return true; |
504 } | 605 } |
505 | 606 |
| 607 bool Dictionary::convert(ConversionContext& context, const String& key, Vector<S
tring>& value) const |
| 608 { |
| 609 ConversionContextScope scope(context); |
| 610 |
| 611 v8::Local<v8::Value> v8Value; |
| 612 if (!getKey(key, v8Value)) |
| 613 return true; |
| 614 |
| 615 if (context.isNullable() && WebCore::isUndefinedOrNull(v8Value)) |
| 616 return true; |
| 617 |
| 618 if (!v8Value->IsArray()) { |
| 619 context.throwTypeError(ExceptionMessages::notASequenceTypeProperty(key))
; |
| 620 return false; |
| 621 } |
| 622 |
| 623 return get(key, value); |
| 624 } |
| 625 |
506 bool Dictionary::get(const String& key, ArrayValue& value) const | 626 bool Dictionary::get(const String& key, ArrayValue& value) const |
507 { | 627 { |
508 v8::Local<v8::Value> v8Value; | 628 v8::Local<v8::Value> v8Value; |
509 if (!getKey(key, v8Value)) | 629 if (!getKey(key, v8Value)) |
510 return false; | 630 return false; |
511 | 631 |
512 if (!v8Value->IsArray()) | 632 if (!v8Value->IsArray()) |
513 return false; | 633 return false; |
514 | 634 |
515 ASSERT(m_isolate); | 635 ASSERT(m_isolate); |
516 ASSERT(m_isolate == v8::Isolate::GetCurrent()); | 636 ASSERT(m_isolate == v8::Isolate::GetCurrent()); |
517 value = ArrayValue(v8::Local<v8::Array>::Cast(v8Value), m_isolate); | 637 value = ArrayValue(v8::Local<v8::Array>::Cast(v8Value), m_isolate); |
518 return true; | 638 return true; |
519 } | 639 } |
520 | 640 |
| 641 bool Dictionary::convert(ConversionContext& context, const String& key, ArrayVal
ue& value) const |
| 642 { |
| 643 ConversionContextScope scope(context); |
| 644 |
| 645 v8::Local<v8::Value> v8Value; |
| 646 if (!getKey(key, v8Value)) |
| 647 return true; |
| 648 |
| 649 if (context.isNullable() && WebCore::isUndefinedOrNull(v8Value)) |
| 650 return true; |
| 651 |
| 652 if (!v8Value->IsArray()) { |
| 653 context.throwTypeError(ExceptionMessages::notASequenceTypeProperty(key))
; |
| 654 return false; |
| 655 } |
| 656 |
| 657 return get(key, value); |
| 658 } |
| 659 |
521 bool Dictionary::get(const String& key, RefPtr<DOMError>& value) const | 660 bool Dictionary::get(const String& key, RefPtr<DOMError>& value) const |
522 { | 661 { |
523 v8::Local<v8::Value> v8Value; | 662 v8::Local<v8::Value> v8Value; |
524 if (!getKey(key, v8Value)) | 663 if (!getKey(key, v8Value)) |
525 return false; | 664 return false; |
526 | 665 |
527 DOMError* error = 0; | 666 DOMError* error = 0; |
528 if (v8Value->IsObject()) { | 667 if (v8Value->IsObject()) { |
529 v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(v8Value); | 668 v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(v8Value); |
530 v8::Handle<v8::Object> domError = wrapper->FindInstanceInPrototypeChain(
V8DOMError::GetTemplate(m_isolate, worldType(m_isolate))); | 669 v8::Handle<v8::Object> domError = wrapper->FindInstanceInPrototypeChain(
V8DOMError::GetTemplate(m_isolate, worldType(m_isolate))); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 v8::Local<v8::String> key = properties->Get(i)->ToString(); | 730 v8::Local<v8::String> key = properties->Get(i)->ToString(); |
592 if (!options->Has(key)) | 731 if (!options->Has(key)) |
593 continue; | 732 continue; |
594 V8TRYCATCH_FOR_V8STRINGRESOURCE_RETURN(V8StringResource<>, stringKey, ke
y, false); | 733 V8TRYCATCH_FOR_V8STRINGRESOURCE_RETURN(V8StringResource<>, stringKey, ke
y, false); |
595 names.append(stringKey); | 734 names.append(stringKey); |
596 } | 735 } |
597 | 736 |
598 return true; | 737 return true; |
599 } | 738 } |
600 | 739 |
| 740 void Dictionary::ConversionContext::resetPerPropertyContext() |
| 741 { |
| 742 if (m_dirty) { |
| 743 m_dirty = false; |
| 744 m_isNullable = false; |
| 745 m_propertyTypeName = ""; |
| 746 m_numberConversion = NormalConversion; |
| 747 } |
| 748 } |
| 749 |
| 750 Dictionary::ConversionContext& Dictionary::ConversionContext::withAttributes(boo
l isNullable, IntegerConversionConfiguration conversion, const String& typeName) |
| 751 { |
| 752 ASSERT(!m_dirty); |
| 753 m_dirty = true; |
| 754 m_isNullable = isNullable; |
| 755 m_propertyTypeName = typeName; |
| 756 m_numberConversion = conversion; |
| 757 |
| 758 return *this; |
| 759 } |
| 760 |
| 761 Dictionary::ConversionContext& Dictionary::ConversionContext::withAttributes(boo
l isNullable, const String& typeName) |
| 762 { |
| 763 return withAttributes(isNullable, NormalConversion, typeName); |
| 764 } |
| 765 |
| 766 Dictionary::ConversionContext& Dictionary::ConversionContext::withAttributes(boo
l isNullable, IntegerConversionConfiguration conversion) |
| 767 { |
| 768 return withAttributes(isNullable, conversion, ""); |
| 769 } |
| 770 |
| 771 Dictionary::ConversionContext& Dictionary::ConversionContext::withAttributes(con
st String& typeName) |
| 772 { |
| 773 return withAttributes(false, NormalConversion, typeName); |
| 774 } |
| 775 |
| 776 Dictionary::ConversionContext& Dictionary::ConversionContext::withAttributes(boo
l isNullable) |
| 777 { |
| 778 return withAttributes(isNullable, NormalConversion, ""); |
| 779 } |
| 780 |
| 781 void Dictionary::ConversionContext::throwTypeError(const String& detail) |
| 782 { |
| 783 if (forConstructor()) { |
| 784 exceptionState().throwTypeError(ExceptionMessages::failedToConstruct(int
erfaceName(), detail)); |
| 785 } else { |
| 786 ASSERT(!methodName().isEmpty()); |
| 787 exceptionState().throwTypeError(ExceptionMessages::failedToExecute(inter
faceName(), methodName(), detail)); |
| 788 } |
| 789 } |
| 790 |
601 } // namespace WebCore | 791 } // namespace WebCore |
OLD | NEW |