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 18 matching lines...) Expand all Loading... | |
29 #include "bindings/core/v8/ExceptionMessages.h" | 29 #include "bindings/core/v8/ExceptionMessages.h" |
30 #include "bindings/core/v8/ExceptionState.h" | 30 #include "bindings/core/v8/ExceptionState.h" |
31 #include "bindings/core/v8/V8Binding.h" | 31 #include "bindings/core/v8/V8Binding.h" |
32 #include "bindings/modules/v8/V8Gamepad.h" | 32 #include "bindings/modules/v8/V8Gamepad.h" |
33 #include "bindings/modules/v8/V8Headers.h" | 33 #include "bindings/modules/v8/V8Headers.h" |
34 #include "bindings/modules/v8/V8MIDIPort.h" | 34 #include "bindings/modules/v8/V8MIDIPort.h" |
35 #include "bindings/modules/v8/V8MediaStream.h" | 35 #include "bindings/modules/v8/V8MediaStream.h" |
36 #include "bindings/modules/v8/V8SpeechRecognitionResult.h" | 36 #include "bindings/modules/v8/V8SpeechRecognitionResult.h" |
37 #include "bindings/modules/v8/V8SpeechRecognitionResultList.h" | 37 #include "bindings/modules/v8/V8SpeechRecognitionResultList.h" |
38 #include "modules/gamepad/Gamepad.h" | 38 #include "modules/gamepad/Gamepad.h" |
39 #include "modules/indexeddb/IDBVersionChangeEvent.h" | |
39 #include "modules/mediastream/MediaStream.h" | 40 #include "modules/mediastream/MediaStream.h" |
40 #include "modules/speech/SpeechRecognitionResult.h" | 41 #include "modules/speech/SpeechRecognitionResult.h" |
41 #include "modules/speech/SpeechRecognitionResultList.h" | 42 #include "modules/speech/SpeechRecognitionResultList.h" |
43 #include "public/platform/WebIDBTypes.h" | |
jsbell
2014/07/11 18:42:48
It'd be nice to drop this dependency...
cmumford
2014/07/11 20:53:05
Yes, this is obviously so that we can get at the W
| |
42 | 44 |
43 namespace WebCore { | 45 namespace WebCore { |
44 | 46 |
45 template <> | 47 template <> |
46 struct DictionaryHelperTraits<MIDIPort> { | 48 struct DictionaryHelperTraits<MIDIPort> { |
47 typedef V8MIDIPort type; | 49 typedef V8MIDIPort type; |
48 }; | 50 }; |
49 | 51 |
50 template <> | 52 template <> |
51 struct DictionaryHelperTraits<SpeechRecognitionResult> { | 53 struct DictionaryHelperTraits<SpeechRecognitionResult> { |
(...skipping 13 matching lines...) Expand all Loading... | |
65 template <> | 67 template <> |
66 struct DictionaryHelperTraits<MediaStream> { | 68 struct DictionaryHelperTraits<MediaStream> { |
67 typedef V8MediaStream type; | 69 typedef V8MediaStream type; |
68 }; | 70 }; |
69 | 71 |
70 template <> | 72 template <> |
71 struct DictionaryHelperTraits<Headers> { | 73 struct DictionaryHelperTraits<Headers> { |
72 typedef V8Headers type; | 74 typedef V8Headers type; |
73 }; | 75 }; |
74 | 76 |
77 template <typename T> | |
jsbell
2014/07/11 18:42:48
This is basically doing two things:
* Dig the IDL
cmumford
2014/07/11 20:53:05
Well the string conversion is in IDBVersionChangeE
jsbell
2014/07/11 23:08:30
Right... I'm assuming that the DictionaryHelper.co
bashi
2014/07/13 04:53:32
I agree with jsbell here. Some classes are doing t
| |
78 struct IntegralTypeTraits { | |
79 }; | |
80 | |
81 template <> | |
82 struct IntegralTypeTraits<blink::WebIDBDataLoss> { | |
83 static inline blink::WebIDBDataLoss toIntegral(v8::Handle<v8::Value> value, IntegerConversionConfiguration configuration, ExceptionState& exceptionState) | |
84 { | |
85 blink::WebIDBDataLoss dataLoss = blink::WebIDBDataLossNone; | |
86 if (!IDBVersionChangeEvent::toNativeDataLoss(value, &dataLoss)) | |
87 exceptionState.throwTypeError("Invalid IDBDataLossAmount value"); | |
88 return dataLoss; | |
89 } | |
90 static const String typeName() { return "IDBDataLossAmount"; } | |
91 }; | |
92 | |
93 template<typename T> | |
94 bool DictionaryHelper::convert(const Dictionary& dictionary, Dictionary::Convers ionContext& context, const String& key, T& value) | |
95 { | |
96 Dictionary::ConversionContextScope scope(context); | |
97 | |
98 v8::Local<v8::Value> v8Value; | |
99 if (!dictionary.get(key, v8Value)) | |
100 return true; | |
101 | |
102 value = IntegralTypeTraits<T>::toIntegral(v8Value, NormalConversion, context .exceptionState()); | |
103 if (context.exceptionState().throwIfNeeded()) | |
104 return false; | |
105 | |
106 return true; | |
107 } | |
bashi
2014/07/13 04:53:32
This looks exactly the same as DictionaryHelper::c
cmumford
2014/07/14 22:09:37
Done.
| |
108 | |
75 template bool DictionaryHelper::get(const Dictionary&, const String& key, Member <MIDIPort>& value); | 109 template bool DictionaryHelper::get(const Dictionary&, const String& key, Member <MIDIPort>& value); |
76 template bool DictionaryHelper::get(const Dictionary&, const String& key, Member <SpeechRecognitionResult>& value); | 110 template bool DictionaryHelper::get(const Dictionary&, const String& key, Member <SpeechRecognitionResult>& value); |
77 template bool DictionaryHelper::get(const Dictionary&, const String& key, Member <SpeechRecognitionResultList>& value); | 111 template bool DictionaryHelper::get(const Dictionary&, const String& key, Member <SpeechRecognitionResultList>& value); |
78 template bool DictionaryHelper::get(const Dictionary&, const String& key, Member <Gamepad>& value); | 112 template bool DictionaryHelper::get(const Dictionary&, const String& key, Member <Gamepad>& value); |
79 template bool DictionaryHelper::get(const Dictionary&, const String& key, Member <MediaStream>& value); | 113 template bool DictionaryHelper::get(const Dictionary&, const String& key, Member <MediaStream>& value); |
80 template bool DictionaryHelper::get(const Dictionary&, const String& key, RefPtr WillBeMember<Headers>& value); | 114 template bool DictionaryHelper::get(const Dictionary&, const String& key, RefPtr WillBeMember<Headers>& value); |
81 | 115 |
82 template bool DictionaryHelper::convert(const Dictionary&, Dictionary::Conversio nContext&, const String& key, Member<MIDIPort>& value); | 116 template bool DictionaryHelper::convert(const Dictionary&, Dictionary::Conversio nContext&, const String& key, Member<MIDIPort>& value); |
83 template bool DictionaryHelper::convert(const Dictionary&, Dictionary::Conversio nContext&, const String& key, Member<SpeechRecognitionResult>& value); | 117 template bool DictionaryHelper::convert(const Dictionary&, Dictionary::Conversio nContext&, const String& key, Member<SpeechRecognitionResult>& value); |
84 template bool DictionaryHelper::convert(const Dictionary&, Dictionary::Conversio nContext&, const String& key, Member<SpeechRecognitionResultList>& value); | 118 template bool DictionaryHelper::convert(const Dictionary&, Dictionary::Conversio nContext&, const String& key, Member<SpeechRecognitionResultList>& value); |
85 template bool DictionaryHelper::convert(const Dictionary&, Dictionary::Conversio nContext&, const String& key, Member<Gamepad>& value); | 119 template bool DictionaryHelper::convert(const Dictionary&, Dictionary::Conversio nContext&, const String& key, Member<Gamepad>& value); |
86 template bool DictionaryHelper::convert(const Dictionary&, Dictionary::Conversio nContext&, const String& key, Member<MediaStream>& value); | 120 template bool DictionaryHelper::convert(const Dictionary&, Dictionary::Conversio nContext&, const String& key, Member<MediaStream>& value); |
87 template bool DictionaryHelper::convert(const Dictionary&, Dictionary::Conversio nContext&, const String& key, RefPtrWillBeMember<Headers>& value); | 121 template bool DictionaryHelper::convert(const Dictionary&, Dictionary::Conversio nContext&, const String& key, RefPtrWillBeMember<Headers>& value); |
122 template bool DictionaryHelper::convert(const Dictionary&, Dictionary::Conversio nContext&, const String& key, blink::WebIDBDataLoss& value); | |
88 | 123 |
89 } // namespace WebCore | 124 } // namespace WebCore |
OLD | NEW |