| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 #include "bindings/modules/v8/V8SpeechRecognitionResult.h" | 50 #include "bindings/modules/v8/V8SpeechRecognitionResult.h" |
| 51 #include "bindings/modules/v8/V8SpeechRecognitionResultList.h" | 51 #include "bindings/modules/v8/V8SpeechRecognitionResultList.h" |
| 52 #include "core/html/track/TrackBase.h" | 52 #include "core/html/track/TrackBase.h" |
| 53 #include "modules/gamepad/Gamepad.h" | 53 #include "modules/gamepad/Gamepad.h" |
| 54 #include "modules/indexeddb/IDBKeyRange.h" | 54 #include "modules/indexeddb/IDBKeyRange.h" |
| 55 #include "modules/mediastream/MediaStream.h" | 55 #include "modules/mediastream/MediaStream.h" |
| 56 #include "modules/speech/SpeechRecognitionResult.h" | 56 #include "modules/speech/SpeechRecognitionResult.h" |
| 57 #include "modules/speech/SpeechRecognitionResultList.h" | 57 #include "modules/speech/SpeechRecognitionResultList.h" |
| 58 #include "wtf/MathExtras.h" | 58 #include "wtf/MathExtras.h" |
| 59 | 59 |
| 60 namespace WebCore { | 60 namespace blink { |
| 61 | 61 |
| 62 Dictionary::Dictionary() | 62 Dictionary::Dictionary() |
| 63 : m_isolate(0) | 63 : m_isolate(0) |
| 64 { | 64 { |
| 65 } | 65 } |
| 66 | 66 |
| 67 Dictionary::Dictionary(const v8::Handle<v8::Value>& options, v8::Isolate* isolat
e) | 67 Dictionary::Dictionary(const v8::Handle<v8::Value>& options, v8::Isolate* isolat
e) |
| 68 : m_options(options) | 68 : m_options(options) |
| 69 , m_isolate(isolate) | 69 , m_isolate(isolate) |
| 70 { | 70 { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 89 | 89 |
| 90 bool Dictionary::isObject() const | 90 bool Dictionary::isObject() const |
| 91 { | 91 { |
| 92 return !isUndefinedOrNull() && m_options->IsObject(); | 92 return !isUndefinedOrNull() && m_options->IsObject(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 bool Dictionary::isUndefinedOrNull() const | 95 bool Dictionary::isUndefinedOrNull() const |
| 96 { | 96 { |
| 97 if (m_options.IsEmpty()) | 97 if (m_options.IsEmpty()) |
| 98 return true; | 98 return true; |
| 99 return WebCore::isUndefinedOrNull(m_options); | 99 return blink::isUndefinedOrNull(m_options); |
| 100 } | 100 } |
| 101 | 101 |
| 102 bool Dictionary::hasProperty(const String& key) const | 102 bool Dictionary::hasProperty(const String& key) const |
| 103 { | 103 { |
| 104 if (isUndefinedOrNull()) | 104 if (isUndefinedOrNull()) |
| 105 return false; | 105 return false; |
| 106 v8::Local<v8::Object> options = m_options->ToObject(); | 106 v8::Local<v8::Object> options = m_options->ToObject(); |
| 107 ASSERT(!options.IsEmpty()); | 107 ASSERT(!options.IsEmpty()); |
| 108 | 108 |
| 109 ASSERT(m_isolate); | 109 ASSERT(m_isolate); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 134 } | 134 } |
| 135 | 135 |
| 136 bool Dictionary::get(const String& key, v8::Local<v8::Value>& value) const | 136 bool Dictionary::get(const String& key, v8::Local<v8::Value>& value) const |
| 137 { | 137 { |
| 138 return getKey(key, value); | 138 return getKey(key, value); |
| 139 } | 139 } |
| 140 | 140 |
| 141 bool Dictionary::getWithUndefinedOrNullCheck(const String& key, String& value) c
onst | 141 bool Dictionary::getWithUndefinedOrNullCheck(const String& key, String& value) c
onst |
| 142 { | 142 { |
| 143 v8::Local<v8::Value> v8Value; | 143 v8::Local<v8::Value> v8Value; |
| 144 if (!getKey(key, v8Value) || WebCore::isUndefinedOrNull(v8Value)) | 144 if (!getKey(key, v8Value) || blink::isUndefinedOrNull(v8Value)) |
| 145 return false; | 145 return false; |
| 146 | 146 |
| 147 TOSTRING_DEFAULT(V8StringResource<>, stringValue, v8Value, false); | 147 TOSTRING_DEFAULT(V8StringResource<>, stringValue, v8Value, false); |
| 148 value = stringValue; | 148 value = stringValue; |
| 149 return true; | 149 return true; |
| 150 } | 150 } |
| 151 | 151 |
| 152 bool Dictionary::getWithUndefinedOrNullCheck(const String& key, RefPtrWillBeMemb
er<Element>& value) const | 152 bool Dictionary::getWithUndefinedOrNullCheck(const String& key, RefPtrWillBeMemb
er<Element>& value) const |
| 153 { | 153 { |
| 154 v8::Local<v8::Value> v8Value; | 154 v8::Local<v8::Value> v8Value; |
| 155 if (!getKey(key, v8Value) || WebCore::isUndefinedOrNull(v8Value)) | 155 if (!getKey(key, v8Value) || blink::isUndefinedOrNull(v8Value)) |
| 156 return false; | 156 return false; |
| 157 | 157 |
| 158 value = V8Element::toNativeWithTypeCheck(m_isolate, v8Value); | 158 value = V8Element::toNativeWithTypeCheck(m_isolate, v8Value); |
| 159 return true; | 159 return true; |
| 160 } | 160 } |
| 161 | 161 |
| 162 bool Dictionary::getWithUndefinedOrNullCheck(const String& key, RefPtr<Path2D>&
value) const | 162 bool Dictionary::getWithUndefinedOrNullCheck(const String& key, RefPtr<Path2D>&
value) const |
| 163 { | 163 { |
| 164 v8::Local<v8::Value> v8Value; | 164 v8::Local<v8::Value> v8Value; |
| 165 if (!getKey(key, v8Value) || WebCore::isUndefinedOrNull(v8Value)) | 165 if (!getKey(key, v8Value) || blink::isUndefinedOrNull(v8Value)) |
| 166 return false; | 166 return false; |
| 167 | 167 |
| 168 value = V8Path2D::toNativeWithTypeCheck(m_isolate, v8Value); | 168 value = V8Path2D::toNativeWithTypeCheck(m_isolate, v8Value); |
| 169 return true; | 169 return true; |
| 170 } | 170 } |
| 171 | 171 |
| 172 bool Dictionary::get(const String& key, Dictionary& value) const | 172 bool Dictionary::get(const String& key, Dictionary& value) const |
| 173 { | 173 { |
| 174 v8::Local<v8::Value> v8Value; | 174 v8::Local<v8::Value> v8Value; |
| 175 if (!getKey(key, v8Value)) | 175 if (!getKey(key, v8Value)) |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 { | 213 { |
| 214 ConversionContextScope scope(context); | 214 ConversionContextScope scope(context); |
| 215 | 215 |
| 216 v8::Local<v8::Value> v8Value; | 216 v8::Local<v8::Value> v8Value; |
| 217 if (!getKey(key, v8Value)) | 217 if (!getKey(key, v8Value)) |
| 218 return true; | 218 return true; |
| 219 | 219 |
| 220 if (v8Value->IsObject()) | 220 if (v8Value->IsObject()) |
| 221 return get(key, value); | 221 return get(key, value); |
| 222 | 222 |
| 223 if (context.isNullable() && WebCore::isUndefinedOrNull(v8Value)) | 223 if (context.isNullable() && blink::isUndefinedOrNull(v8Value)) |
| 224 return true; | 224 return true; |
| 225 | 225 |
| 226 context.throwTypeError(ExceptionMessages::incorrectPropertyType(key, "does n
ot have a Dictionary type.")); | 226 context.throwTypeError(ExceptionMessages::incorrectPropertyType(key, "does n
ot have a Dictionary type.")); |
| 227 return false; | 227 return false; |
| 228 } | 228 } |
| 229 | 229 |
| 230 bool Dictionary::getOwnPropertiesAsStringHashMap(HashMap<String, String>& hashMa
p) const | 230 bool Dictionary::getOwnPropertiesAsStringHashMap(HashMap<String, String>& hashMa
p) const |
| 231 { | 231 { |
| 232 if (!isObject()) | 232 if (!isObject()) |
| 233 return false; | 233 return false; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 m_propertyTypeName = typeName; | 294 m_propertyTypeName = typeName; |
| 295 | 295 |
| 296 return *this; | 296 return *this; |
| 297 } | 297 } |
| 298 | 298 |
| 299 void Dictionary::ConversionContext::throwTypeError(const String& detail) | 299 void Dictionary::ConversionContext::throwTypeError(const String& detail) |
| 300 { | 300 { |
| 301 exceptionState().throwTypeError(detail); | 301 exceptionState().throwTypeError(detail); |
| 302 } | 302 } |
| 303 | 303 |
| 304 } // namespace WebCore | 304 } // namespace blink |
| OLD | NEW |