1197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch/* 2197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch * Copyright (C) 2010 Google Inc. All rights reserved. 3197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch * 4197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch * Redistribution and use in source and binary forms, with or without 5197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch * modification, are permitted provided that the following conditions 6197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch * are met: 7197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch * 8197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch * 1. Redistributions of source code must retain the above copyright 9197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch * notice, this list of conditions and the following disclaimer. 10197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch * 2. Redistributions in binary form must reproduce the above copyright 11197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch * notice, this list of conditions and the following disclaimer in the 12197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch * documentation and/or other materials provided with the distribution. 13197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch * 14197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 15197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 18197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 19197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 20197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 21197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch */ 25197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 26197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "config.h" 27197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 28197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "bindings/core/v8/ArrayValue.h" 29197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "bindings/core/v8/DictionaryHelperForBindings.h" 30197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "bindings/core/v8/ExceptionMessages.h" 31197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "bindings/core/v8/ExceptionState.h" 32197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "bindings/core/v8/V8Binding.h" 33197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "bindings/core/v8/V8DOMError.h" 34197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "bindings/core/v8/V8Element.h" 35197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "bindings/core/v8/V8EventTarget.h" 36197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "bindings/core/v8/V8MediaKeyError.h" 37197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "bindings/core/v8/V8MessagePort.h" 38197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "bindings/core/v8/V8Path2D.h" 39197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "bindings/core/v8/V8Storage.h" 40197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "bindings/core/v8/V8TextTrack.h" 41197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "bindings/core/v8/V8VoidCallback.h" 42197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "bindings/core/v8/V8Window.h" 43197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "bindings/core/v8/custom/V8ArrayBufferViewCustom.h" 44197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "bindings/core/v8/custom/V8Uint8ArrayCustom.h" 45197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "core/html/track/TrackBase.h" 46197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch#include "wtf/MathExtras.h" 47197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 48c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)namespace blink { 49197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 50197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 51197021e6b966cfb06891637935ef33fff06433d1Ben Murdochbool DictionaryHelper::get(const Dictionary& dictionary, const String& key, v8::Local<v8::Value>& value) 52197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{ 53197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return dictionary.get(key, value); 54197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch} 55197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 56197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 57197021e6b966cfb06891637935ef33fff06433d1Ben Murdochbool DictionaryHelper::get(const Dictionary& dictionary, const String& key, Dictionary& value) 58197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{ 59197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return dictionary.get(key, value); 60197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch} 61197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 62197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 63197021e6b966cfb06891637935ef33fff06433d1Ben Murdochbool DictionaryHelper::get(const Dictionary& dictionary, const String& key, bool& value) 64197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{ 65197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Local<v8::Value> v8Value; 66197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (!dictionary.get(key, v8Value)) 67197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return false; 68197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 69197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Local<v8::Boolean> v8Bool = v8Value->ToBoolean(); 70197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (v8Bool.IsEmpty()) 71197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return false; 72197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch value = v8Bool->Value(); 73197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return true; 74197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch} 75197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 76197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 77197021e6b966cfb06891637935ef33fff06433d1Ben Murdochbool DictionaryHelper::convert(const Dictionary& dictionary, Dictionary::ConversionContext& context, const String& key, bool& value) 78197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{ 79197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch Dictionary::ConversionContextScope scope(context); 80197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch DictionaryHelper::get(dictionary, key, value); 81197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return true; 82197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch} 83197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 84197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 85197021e6b966cfb06891637935ef33fff06433d1Ben Murdochbool DictionaryHelper::get(const Dictionary& dictionary, const String& key, int32_t& value) 86197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{ 87197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Local<v8::Value> v8Value; 88197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (!dictionary.get(key, v8Value)) 89197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return false; 90197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 91197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Local<v8::Int32> v8Int32 = v8Value->ToInt32(); 92197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (v8Int32.IsEmpty()) 93197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return false; 94197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch value = v8Int32->Value(); 95197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return true; 96197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch} 97197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 98197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 99197021e6b966cfb06891637935ef33fff06433d1Ben Murdochbool DictionaryHelper::get(const Dictionary& dictionary, const String& key, double& value, bool& hasValue) 100197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{ 101197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Local<v8::Value> v8Value; 102197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (!dictionary.get(key, v8Value)) { 103197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch hasValue = false; 104197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return false; 105197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch } 106197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 107197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch hasValue = true; 108197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TONATIVE_DEFAULT(v8::Local<v8::Number>, v8Number, v8Value->ToNumber(), false); 109197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (v8Number.IsEmpty()) 110197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return false; 111197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch value = v8Number->Value(); 112197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return true; 113197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch} 114197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 115197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 116197021e6b966cfb06891637935ef33fff06433d1Ben Murdochbool DictionaryHelper::get(const Dictionary& dictionary, const String& key, double& value) 117197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{ 118197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch bool unused; 119197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return DictionaryHelper::get(dictionary, key, value, unused); 120197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch} 121197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 122197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 123197021e6b966cfb06891637935ef33fff06433d1Ben Murdochbool DictionaryHelper::convert(const Dictionary& dictionary, Dictionary::ConversionContext& context, const String& key, double& value) 124197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{ 125197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch Dictionary::ConversionContextScope scope(context); 126197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 127197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch bool hasValue = false; 128197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (!DictionaryHelper::get(dictionary, key, value, hasValue) && hasValue) { 129197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch context.throwTypeError(ExceptionMessages::incorrectPropertyType(key, "is not of type 'double'.")); 130197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return false; 131197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch } 132197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return true; 133197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch} 134197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 135197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate<typename StringType> 136197021e6b966cfb06891637935ef33fff06433d1Ben Murdochbool getStringType(const Dictionary& dictionary, const String& key, StringType& value) 137197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{ 138197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Local<v8::Value> v8Value; 139197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (!dictionary.get(key, v8Value)) 140197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return false; 141197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 142197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TOSTRING_DEFAULT(V8StringResource<>, stringValue, v8Value, false); 143197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch value = stringValue; 144197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return true; 145197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch} 146197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 147197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 148197021e6b966cfb06891637935ef33fff06433d1Ben Murdochbool DictionaryHelper::get(const Dictionary& dictionary, const String& key, String& value) 149197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{ 150197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return getStringType(dictionary, key, value); 151197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch} 152197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 153197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 154197021e6b966cfb06891637935ef33fff06433d1Ben Murdochbool DictionaryHelper::get(const Dictionary& dictionary, const String& key, AtomicString& value) 155197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{ 156197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return getStringType(dictionary, key, value); 157197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch} 158197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 159197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 160197021e6b966cfb06891637935ef33fff06433d1Ben Murdochbool DictionaryHelper::convert(const Dictionary& dictionary, Dictionary::ConversionContext& context, const String& key, String& value) 161197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{ 162197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch Dictionary::ConversionContextScope scope(context); 163197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 164197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Local<v8::Value> v8Value; 165197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (!dictionary.get(key, v8Value)) 166197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return true; 167197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 168197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TOSTRING_DEFAULT(V8StringResource<>, stringValue, v8Value, false); 169197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch value = stringValue; 170197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return true; 171197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch} 172197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 173197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 174197021e6b966cfb06891637935ef33fff06433d1Ben Murdochbool DictionaryHelper::get(const Dictionary& dictionary, const String& key, ScriptValue& value) 175197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{ 176197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Local<v8::Value> v8Value; 177197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (!dictionary.get(key, v8Value)) 178197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return false; 179197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 180197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch value = ScriptValue(ScriptState::current(dictionary.isolate()), v8Value); 181197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return true; 182197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch} 183197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 184197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 185197021e6b966cfb06891637935ef33fff06433d1Ben Murdochbool DictionaryHelper::convert(const Dictionary& dictionary, Dictionary::ConversionContext& context, const String& key, ScriptValue& value) 186197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{ 187197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch Dictionary::ConversionContextScope scope(context); 188197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 189197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch DictionaryHelper::get(dictionary, key, value); 190197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return true; 191197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch} 192197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 193197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate<typename NumericType> 194197021e6b966cfb06891637935ef33fff06433d1Ben Murdochbool getNumericType(const Dictionary& dictionary, const String& key, NumericType& value) 195197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{ 196197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Local<v8::Value> v8Value; 197197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (!dictionary.get(key, v8Value)) 198197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return false; 199197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 200197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Local<v8::Int32> v8Int32 = v8Value->ToInt32(); 201197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (v8Int32.IsEmpty()) 202197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return false; 203197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch value = static_cast<NumericType>(v8Int32->Value()); 204197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return true; 205197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch} 206197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 207197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 208197021e6b966cfb06891637935ef33fff06433d1Ben Murdochbool DictionaryHelper::get(const Dictionary& dictionary, const String& key, short& value) 209197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{ 210197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return getNumericType<short>(dictionary, key, value); 211197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch} 212197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 213197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 214197021e6b966cfb06891637935ef33fff06433d1Ben Murdochbool DictionaryHelper::get(const Dictionary& dictionary, const String& key, unsigned short& value) 215197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{ 216197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return getNumericType<unsigned short>(dictionary, key, value); 217197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch} 218197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 219197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 220197021e6b966cfb06891637935ef33fff06433d1Ben Murdochbool DictionaryHelper::get(const Dictionary& dictionary, const String& key, unsigned& value) 221197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{ 222197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return getNumericType<unsigned>(dictionary, key, value); 223197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch} 224197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 225197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 226197021e6b966cfb06891637935ef33fff06433d1Ben Murdochbool DictionaryHelper::get(const Dictionary& dictionary, const String& key, unsigned long& value) 227197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{ 228197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Local<v8::Value> v8Value; 229197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (!dictionary.get(key, v8Value)) 230197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return false; 231197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 232197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Local<v8::Integer> v8Integer = v8Value->ToInteger(); 233197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (v8Integer.IsEmpty()) 234197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return false; 235197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch value = static_cast<unsigned long>(v8Integer->Value()); 236197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return true; 237197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch} 238197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 239197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 240197021e6b966cfb06891637935ef33fff06433d1Ben Murdochbool DictionaryHelper::get(const Dictionary& dictionary, const String& key, unsigned long long& value) 241197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{ 242197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Local<v8::Value> v8Value; 243197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (!dictionary.get(key, v8Value)) 244197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return false; 245197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 246197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TONATIVE_DEFAULT(v8::Local<v8::Number>, v8Number, v8Value->ToNumber(), false); 247197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (v8Number.IsEmpty()) 248197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return false; 249197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch double d = v8Number->Value(); 250197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch doubleToInteger(d, value); 251197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return true; 252197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch} 253197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 254197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 255197021e6b966cfb06891637935ef33fff06433d1Ben Murdochbool DictionaryHelper::get(const Dictionary& dictionary, const String& key, RefPtrWillBeMember<LocalDOMWindow>& value) 256197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{ 257197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Local<v8::Value> v8Value; 258197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (!dictionary.get(key, v8Value)) 259197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return false; 260197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 261197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch // We need to handle a DOMWindow specially, because a DOMWindow wrapper 262197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch // exists on a prototype chain of v8Value. 263197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch value = toDOMWindow(v8Value, dictionary.isolate()); 264197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return true; 265197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch} 266197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 267197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 268197021e6b966cfb06891637935ef33fff06433d1Ben Murdochbool DictionaryHelper::get(const Dictionary& dictionary, const String& key, HashSet<AtomicString>& value) 269197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{ 270197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Local<v8::Value> v8Value; 271197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (!dictionary.get(key, v8Value)) 272197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return false; 273197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 274197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch // FIXME: Support array-like objects 275197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (!v8Value->IsArray()) 276197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return false; 277197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 278197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch ASSERT(dictionary.isolate()); 279197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch ASSERT(dictionary.isolate() == v8::Isolate::GetCurrent()); 280197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Local<v8::Array> v8Array = v8::Local<v8::Array>::Cast(v8Value); 281197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch for (size_t i = 0; i < v8Array->Length(); ++i) { 282197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Local<v8::Value> indexedValue = v8Array->Get(v8::Integer::New(dictionary.isolate(), i)); 283197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TOSTRING_DEFAULT(V8StringResource<>, stringValue, indexedValue, false); 284197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch value.add(stringValue); 285197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch } 286197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 287197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return true; 288197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch} 289197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 290197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 291197021e6b966cfb06891637935ef33fff06433d1Ben Murdochbool DictionaryHelper::convert(const Dictionary& dictionary, Dictionary::ConversionContext& context, const String& key, HashSet<AtomicString>& value) 292197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{ 293197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch Dictionary::ConversionContextScope scope(context); 294197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 295197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Local<v8::Value> v8Value; 296197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (!dictionary.get(key, v8Value)) 297197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return true; 298197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 299c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) if (context.isNullable() && blink::isUndefinedOrNull(v8Value)) 300197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return true; 301197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 302197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (!v8Value->IsArray()) { 303197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch context.throwTypeError(ExceptionMessages::notASequenceTypeProperty(key)); 304197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return false; 305197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch } 306197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 307197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return DictionaryHelper::get(dictionary, key, value); 308197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch} 309197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 310197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 311197021e6b966cfb06891637935ef33fff06433d1Ben Murdochbool DictionaryHelper::get(const Dictionary& dictionary, const String& key, RefPtrWillBeMember<TrackBase>& value) 312197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{ 313197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Local<v8::Value> v8Value; 314197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (!dictionary.get(key, v8Value)) 315197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return false; 316197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 317197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TrackBase* source = 0; 318197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (v8Value->IsObject()) { 319197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(v8Value); 320197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 321197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch // FIXME: this will need to be changed so it can also return an AudioTrack or a VideoTrack once 322197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch // we add them. 323197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Handle<v8::Object> track = V8TextTrack::findInstanceInPrototypeChain(wrapper, dictionary.isolate()); 324197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (!track.IsEmpty()) 3257242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci source = V8TextTrack::toImpl(track); 326197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch } 327197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch value = source; 328197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return true; 329197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch} 330197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 331197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 332197021e6b966cfb06891637935ef33fff06433d1Ben Murdochbool DictionaryHelper::get(const Dictionary& dictionary, const String& key, RefPtrWillBeMember<EventTarget>& value) 333197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{ 334197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Local<v8::Value> v8Value; 335197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (!dictionary.get(key, v8Value)) 336197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return false; 337197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 338197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch value = nullptr; 339197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch // We need to handle a LocalDOMWindow specially, because a LocalDOMWindow wrapper 340197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch // exists on a prototype chain of v8Value. 341197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (v8Value->IsObject()) { 342197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(v8Value); 343197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Handle<v8::Object> window = V8Window::findInstanceInPrototypeChain(wrapper, dictionary.isolate()); 344197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (!window.IsEmpty()) { 345197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch value = toWrapperTypeInfo(window)->toEventTarget(window); 346197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return true; 347197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch } 348197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch } 349197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 350197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (V8DOMWrapper::isDOMWrapper(v8Value)) { 351197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Handle<v8::Object> wrapper = v8::Handle<v8::Object>::Cast(v8Value); 352197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch value = toWrapperTypeInfo(wrapper)->toEventTarget(wrapper); 353197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch } 354197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return true; 355197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch} 356197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 357197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 358197021e6b966cfb06891637935ef33fff06433d1Ben Murdochbool DictionaryHelper::get(const Dictionary& dictionary, const String& key, Vector<String>& value) 359197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{ 360197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Local<v8::Value> v8Value; 361197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (!dictionary.get(key, v8Value)) 362197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return false; 363197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 364197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (!v8Value->IsArray()) 365197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return false; 366197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 367197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Local<v8::Array> v8Array = v8::Local<v8::Array>::Cast(v8Value); 368197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch for (size_t i = 0; i < v8Array->Length(); ++i) { 369197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Local<v8::Value> indexedValue = v8Array->Get(v8::Uint32::New(dictionary.isolate(), i)); 370197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch TOSTRING_DEFAULT(V8StringResource<>, stringValue, indexedValue, false); 371197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch value.append(stringValue); 372197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch } 373197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 374197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return true; 375197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch} 376197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 377197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 378197021e6b966cfb06891637935ef33fff06433d1Ben Murdochbool DictionaryHelper::convert(const Dictionary& dictionary, Dictionary::ConversionContext& context, const String& key, Vector<String>& value) 379197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{ 380197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch Dictionary::ConversionContextScope scope(context); 381197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 382197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Local<v8::Value> v8Value; 383197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (!dictionary.get(key, v8Value)) 384197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return true; 385197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 386c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) if (context.isNullable() && blink::isUndefinedOrNull(v8Value)) 387197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return true; 388197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 389197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (!v8Value->IsArray()) { 390197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch context.throwTypeError(ExceptionMessages::notASequenceTypeProperty(key)); 391197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return false; 392197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch } 393197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 394197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return DictionaryHelper::get(dictionary, key, value); 395197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch} 396197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 397197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 398197021e6b966cfb06891637935ef33fff06433d1Ben Murdochbool DictionaryHelper::get(const Dictionary& dictionary, const String& key, ArrayValue& value) 399197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{ 400197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Local<v8::Value> v8Value; 401197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (!dictionary.get(key, v8Value)) 402197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return false; 403197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 404197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (!v8Value->IsArray()) 405197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return false; 406197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 407197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch ASSERT(dictionary.isolate()); 408197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch ASSERT(dictionary.isolate() == v8::Isolate::GetCurrent()); 409197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch value = ArrayValue(v8::Local<v8::Array>::Cast(v8Value), dictionary.isolate()); 410197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return true; 411197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch} 412197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 413197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 414197021e6b966cfb06891637935ef33fff06433d1Ben Murdochbool DictionaryHelper::convert(const Dictionary& dictionary, Dictionary::ConversionContext& context, const String& key, ArrayValue& value) 415197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{ 416197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch Dictionary::ConversionContextScope scope(context); 417197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 418197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Local<v8::Value> v8Value; 419197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (!dictionary.get(key, v8Value)) 420197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return true; 421197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 422c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) if (context.isNullable() && blink::isUndefinedOrNull(v8Value)) 423197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return true; 424197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 425197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (!v8Value->IsArray()) { 426197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch context.throwTypeError(ExceptionMessages::notASequenceTypeProperty(key)); 427197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return false; 428197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch } 429197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 430197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return DictionaryHelper::get(dictionary, key, value); 431197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch} 432197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 433197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 434197021e6b966cfb06891637935ef33fff06433d1Ben Murdochstruct DictionaryHelperTraits<Uint8Array> { 435197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch typedef V8Uint8Array type; 436197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch}; 437197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 438197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 439197021e6b966cfb06891637935ef33fff06433d1Ben Murdochstruct DictionaryHelperTraits<ArrayBufferView> { 440197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch typedef V8ArrayBufferView type; 441197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch}; 442197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 443197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 444197021e6b966cfb06891637935ef33fff06433d1Ben Murdochstruct DictionaryHelperTraits<MediaKeyError> { 445197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch typedef V8MediaKeyError type; 446197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch}; 447197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 448197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 449197021e6b966cfb06891637935ef33fff06433d1Ben Murdochstruct DictionaryHelperTraits<DOMError> { 450197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch typedef V8DOMError type; 451197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch}; 452197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 453197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 454197021e6b966cfb06891637935ef33fff06433d1Ben Murdochstruct DictionaryHelperTraits<Storage> { 455197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch typedef V8Storage type; 456197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch}; 457197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 4587242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tuccitemplate <> 4597242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tuccistruct DictionaryHelperTraits<Element> { 4607242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci typedef V8Element type; 4617242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci}; 4627242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci 4637242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tuccitemplate <> 4647242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tuccistruct DictionaryHelperTraits<Path2D> { 4657242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci typedef V8Path2D type; 4667242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci}; 4677242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci 468197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate bool DictionaryHelper::get(const Dictionary&, const String& key, RefPtr<Uint8Array>& value); 469197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate bool DictionaryHelper::get(const Dictionary&, const String& key, RefPtr<ArrayBufferView>& value); 470197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate bool DictionaryHelper::get(const Dictionary&, const String& key, RefPtrWillBeMember<MediaKeyError>& value); 471197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate bool DictionaryHelper::get(const Dictionary&, const String& key, RefPtrWillBeMember<DOMError>& value); 472197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate bool DictionaryHelper::get(const Dictionary&, const String& key, RefPtrWillBeMember<Storage>& value); 4737242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tuccitemplate bool DictionaryHelper::get(const Dictionary&, const String& key, RefPtrWillBeMember<Element>& value); 4747242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tuccitemplate bool DictionaryHelper::get(const Dictionary&, const String& key, RawPtr<Element>& value); 4757242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tuccitemplate bool DictionaryHelper::get(const Dictionary&, const String& key, RefPtrWillBeMember<Path2D>& value); 4767242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tuccitemplate bool DictionaryHelper::get(const Dictionary&, const String& key, RawPtr<Path2D>& value); 477197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 478197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <typename T> 479197021e6b966cfb06891637935ef33fff06433d1Ben Murdochstruct IntegralTypeTraits { 480197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch}; 481197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 482197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 483197021e6b966cfb06891637935ef33fff06433d1Ben Murdochstruct IntegralTypeTraits<uint8_t> { 484197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch static inline uint8_t toIntegral(v8::Handle<v8::Value> value, IntegerConversionConfiguration configuration, ExceptionState& exceptionState) 485197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch { 486197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return toUInt8(value, configuration, exceptionState); 487197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch } 488197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch static const String typeName() { return "UInt8"; } 489197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch}; 490197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 491197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 492197021e6b966cfb06891637935ef33fff06433d1Ben Murdochstruct IntegralTypeTraits<int8_t> { 493197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch static inline int8_t toIntegral(v8::Handle<v8::Value> value, IntegerConversionConfiguration configuration, ExceptionState& exceptionState) 494197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch { 495197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return toInt8(value, configuration, exceptionState); 496197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch } 497197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch static const String typeName() { return "Int8"; } 498197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch}; 499197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 500197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 501197021e6b966cfb06891637935ef33fff06433d1Ben Murdochstruct IntegralTypeTraits<unsigned short> { 502197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch static inline uint16_t toIntegral(v8::Handle<v8::Value> value, IntegerConversionConfiguration configuration, ExceptionState& exceptionState) 503197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch { 504197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return toUInt16(value, configuration, exceptionState); 505197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch } 506197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch static const String typeName() { return "UInt16"; } 507197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch}; 508197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 509197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 510197021e6b966cfb06891637935ef33fff06433d1Ben Murdochstruct IntegralTypeTraits<short> { 511197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch static inline int16_t toIntegral(v8::Handle<v8::Value> value, IntegerConversionConfiguration configuration, ExceptionState& exceptionState) 512197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch { 513197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return toInt16(value, configuration, exceptionState); 514197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch } 515197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch static const String typeName() { return "Int16"; } 516197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch}; 517197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 518197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 519197021e6b966cfb06891637935ef33fff06433d1Ben Murdochstruct IntegralTypeTraits<unsigned> { 520197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch static inline uint32_t toIntegral(v8::Handle<v8::Value> value, IntegerConversionConfiguration configuration, ExceptionState& exceptionState) 521197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch { 522197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return toUInt32(value, configuration, exceptionState); 523197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch } 524197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch static const String typeName() { return "UInt32"; } 525197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch}; 526197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 527197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 528197021e6b966cfb06891637935ef33fff06433d1Ben Murdochstruct IntegralTypeTraits<unsigned long> { 529197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch static inline uint32_t toIntegral(v8::Handle<v8::Value> value, IntegerConversionConfiguration configuration, ExceptionState& exceptionState) 530197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch { 531197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return toUInt32(value, configuration, exceptionState); 532197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch } 533197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch static const String typeName() { return "UInt32"; } 534197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch}; 535197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 536197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 537197021e6b966cfb06891637935ef33fff06433d1Ben Murdochstruct IntegralTypeTraits<int> { 538197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch static inline int32_t toIntegral(v8::Handle<v8::Value> value, IntegerConversionConfiguration configuration, ExceptionState& exceptionState) 539197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch { 540197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return toInt32(value, configuration, exceptionState); 541197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch } 542197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch static const String typeName() { return "Int32"; } 543197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch}; 544197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 545197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 546197021e6b966cfb06891637935ef33fff06433d1Ben Murdochstruct IntegralTypeTraits<long> { 547197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch static inline int32_t toIntegral(v8::Handle<v8::Value> value, IntegerConversionConfiguration configuration, ExceptionState& exceptionState) 548197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch { 549197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return toInt32(value, configuration, exceptionState); 550197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch } 551197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch static const String typeName() { return "Int32"; } 552197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch}; 553197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 554197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 555197021e6b966cfb06891637935ef33fff06433d1Ben Murdochstruct IntegralTypeTraits<unsigned long long> { 556197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch static inline unsigned long long toIntegral(v8::Handle<v8::Value> value, IntegerConversionConfiguration configuration, ExceptionState& exceptionState) 557197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch { 558197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return toUInt64(value, configuration, exceptionState); 559197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch } 560197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch static const String typeName() { return "UInt64"; } 561197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch}; 562197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 563197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 564197021e6b966cfb06891637935ef33fff06433d1Ben Murdochstruct IntegralTypeTraits<long long> { 565197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch static inline long long toIntegral(v8::Handle<v8::Value> value, IntegerConversionConfiguration configuration, ExceptionState& exceptionState) 566197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch { 567197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return toInt64(value, configuration, exceptionState); 568197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch } 569197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch static const String typeName() { return "Int64"; } 570197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch}; 571197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 572197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate<typename T> 573197021e6b966cfb06891637935ef33fff06433d1Ben Murdochbool DictionaryHelper::convert(const Dictionary& dictionary, Dictionary::ConversionContext& context, const String& key, T& value) 574197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{ 575197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch Dictionary::ConversionContextScope scope(context); 576197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 577197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Local<v8::Value> v8Value; 578197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (!dictionary.get(key, v8Value)) 579197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return true; 580197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 581197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch value = IntegralTypeTraits<T>::toIntegral(v8Value, NormalConversion, context.exceptionState()); 582197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (context.exceptionState().throwIfNeeded()) 583197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return false; 584197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 585197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return true; 586197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch} 587197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 588197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate bool DictionaryHelper::convert(const Dictionary&, Dictionary::ConversionContext&, const String& key, uint8_t& value); 589197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate bool DictionaryHelper::convert(const Dictionary&, Dictionary::ConversionContext&, const String& key, int8_t& value); 590197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate bool DictionaryHelper::convert(const Dictionary&, Dictionary::ConversionContext&, const String& key, unsigned short& value); 591197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate bool DictionaryHelper::convert(const Dictionary&, Dictionary::ConversionContext&, const String& key, short& value); 592197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate bool DictionaryHelper::convert(const Dictionary&, Dictionary::ConversionContext&, const String& key, unsigned& value); 593197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate bool DictionaryHelper::convert(const Dictionary&, Dictionary::ConversionContext&, const String& key, unsigned long& value); 594197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate bool DictionaryHelper::convert(const Dictionary&, Dictionary::ConversionContext&, const String& key, int& value); 595197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate bool DictionaryHelper::convert(const Dictionary&, Dictionary::ConversionContext&, const String& key, long& value); 596197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate bool DictionaryHelper::convert(const Dictionary&, Dictionary::ConversionContext&, const String& key, long long& value); 597197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate bool DictionaryHelper::convert(const Dictionary&, Dictionary::ConversionContext&, const String& key, unsigned long long& value); 598197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 599197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate<typename T> 600197021e6b966cfb06891637935ef33fff06433d1Ben Murdochbool DictionaryHelper::convert(const Dictionary& dictionary, Dictionary::ConversionContext& context, const String& key, Nullable<T>& value) 601197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{ 602197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch Dictionary::ConversionContextScope scope(context); 603197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 604197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Local<v8::Value> v8Value; 605197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (!dictionary.get(key, v8Value)) 606197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return true; 607197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 608c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) if (context.isNullable() && blink::isUndefinedOrNull(v8Value)) { 609197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch value = Nullable<T>(); 610197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return true; 611197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch } 612197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 613197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch T converted = IntegralTypeTraits<T>::toIntegral(v8Value, NormalConversion, context.exceptionState()); 614197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 615197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (context.exceptionState().throwIfNeeded()) 616197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return false; 617197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 618197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch value = Nullable<T>(converted); 619197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return true; 620197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch} 621197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 622197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate bool DictionaryHelper::convert(const Dictionary&, Dictionary::ConversionContext&, const String& key, Nullable<uint8_t>& value); 623197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate bool DictionaryHelper::convert(const Dictionary&, Dictionary::ConversionContext&, const String& key, Nullable<int8_t>& value); 624197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate bool DictionaryHelper::convert(const Dictionary&, Dictionary::ConversionContext&, const String& key, Nullable<unsigned short>& value); 625197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate bool DictionaryHelper::convert(const Dictionary&, Dictionary::ConversionContext&, const String& key, Nullable<short>& value); 626197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate bool DictionaryHelper::convert(const Dictionary&, Dictionary::ConversionContext&, const String& key, Nullable<unsigned>& value); 627197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate bool DictionaryHelper::convert(const Dictionary&, Dictionary::ConversionContext&, const String& key, Nullable<unsigned long>& value); 628197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate bool DictionaryHelper::convert(const Dictionary&, Dictionary::ConversionContext&, const String& key, Nullable<int>& value); 629197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate bool DictionaryHelper::convert(const Dictionary&, Dictionary::ConversionContext&, const String& key, Nullable<long>& value); 630197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate bool DictionaryHelper::convert(const Dictionary&, Dictionary::ConversionContext&, const String& key, Nullable<long long>& value); 631197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate bool DictionaryHelper::convert(const Dictionary&, Dictionary::ConversionContext&, const String& key, Nullable<unsigned long long>& value); 632197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 633197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate bool DictionaryHelper::convert(const Dictionary&, Dictionary::ConversionContext&, const String& key, RefPtrWillBeMember<LocalDOMWindow>& value); 634197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate bool DictionaryHelper::convert(const Dictionary&, Dictionary::ConversionContext&, const String& key, RefPtrWillBeMember<Storage>& value); 635197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate bool DictionaryHelper::convert(const Dictionary&, Dictionary::ConversionContext&, const String& key, RefPtr<Uint8Array>& value); 636197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate bool DictionaryHelper::convert(const Dictionary&, Dictionary::ConversionContext&, const String& key, RefPtr<ArrayBufferView>& value); 637197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate bool DictionaryHelper::convert(const Dictionary&, Dictionary::ConversionContext&, const String& key, RefPtrWillBeMember<MediaKeyError>& value); 638197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate bool DictionaryHelper::convert(const Dictionary&, Dictionary::ConversionContext&, const String& key, RefPtrWillBeMember<TrackBase>& value); 639197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate bool DictionaryHelper::convert(const Dictionary&, Dictionary::ConversionContext&, const String& key, RefPtrWillBeMember<EventTarget>& value); 640197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 641197021e6b966cfb06891637935ef33fff06433d1Ben Murdochtemplate <> 642197021e6b966cfb06891637935ef33fff06433d1Ben Murdochbool DictionaryHelper::convert(const Dictionary& dictionary, Dictionary::ConversionContext& context, const String& key, MessagePortArray& value) 643197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch{ 644197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch Dictionary::ConversionContextScope scope(context); 645197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 646197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch v8::Local<v8::Value> v8Value; 647197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch if (!dictionary.get(key, v8Value)) 648197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch return true; 649197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 6507242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci ASSERT(dictionary.isolate()); 6517242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci ASSERT(dictionary.isolate() == v8::Isolate::GetCurrent()); 6527242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci 6537242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci if (isUndefinedOrNull(v8Value)) 6547242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci return true; 6557242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci 6567242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci value = toRefPtrWillBeMemberNativeArray<MessagePort, V8MessagePort>(v8Value, key, dictionary.isolate(), context.exceptionState()); 6577242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci 6587242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci if (context.exceptionState().throwIfNeeded()) 6597242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci return false; 6607242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci 6617242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci return true; 662197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch} 663197021e6b966cfb06891637935ef33fff06433d1Ben Murdoch 664c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)} // namespace blink 665