Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: Source/bindings/v8/Dictionary.cpp

Issue 122783002: Add Dictionary get() method for AtomicString values and use it (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 ConversionContextScope scope(context); 192 ConversionContextScope scope(context);
193 193
194 bool hasValue = false; 194 bool hasValue = false;
195 if (!get(key, value, hasValue) && hasValue) { 195 if (!get(key, value, hasValue) && hasValue) {
196 context.throwTypeError(ExceptionMessages::incorrectPropertyType(key, "is not of type 'double'.")); 196 context.throwTypeError(ExceptionMessages::incorrectPropertyType(key, "is not of type 'double'."));
197 return false; 197 return false;
198 } 198 }
199 return true; 199 return true;
200 } 200 }
201 201
202 bool Dictionary::get(const String& key, String& value) const 202 template<typename StringType>
203 inline bool Dictionary::getStringType(const String& key, StringType& value) cons t
203 { 204 {
204 v8::Local<v8::Value> v8Value; 205 v8::Local<v8::Value> v8Value;
205 if (!getKey(key, v8Value)) 206 if (!getKey(key, v8Value))
206 return false; 207 return false;
207 208
208 V8TRYCATCH_FOR_V8STRINGRESOURCE_RETURN(V8StringResource<>, stringValue, v8Va lue, false); 209 V8TRYCATCH_FOR_V8STRINGRESOURCE_RETURN(V8StringResource<>, stringValue, v8Va lue, false);
209 value = stringValue; 210 value = stringValue;
210 return true; 211 return true;
211 } 212 }
212 213
214 bool Dictionary::get(const String& key, String& value) const
215 {
216 return getStringType(key, value);
217 }
218
219 bool Dictionary::get(const String& key, AtomicString& value) const
220 {
221 return getStringType(key, value);
222 }
223
213 bool Dictionary::convert(ConversionContext& context, const String& key, String& value) const 224 bool Dictionary::convert(ConversionContext& context, const String& key, String& value) const
214 { 225 {
215 ConversionContextScope scope(context); 226 ConversionContextScope scope(context);
216 227
217 v8::Local<v8::Value> v8Value; 228 v8::Local<v8::Value> v8Value;
218 if (!getKey(key, v8Value)) 229 if (!getKey(key, v8Value))
219 return true; 230 return true;
220 231
221 V8TRYCATCH_FOR_V8STRINGRESOURCE_RETURN(V8StringResource<>, stringValue, v8Va lue, false); 232 V8TRYCATCH_FOR_V8STRINGRESOURCE_RETURN(V8StringResource<>, stringValue, v8Va lue, false);
222 value = stringValue; 233 value = stringValue;
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 { 771 {
761 if (forConstructor()) { 772 if (forConstructor()) {
762 exceptionState().throwTypeError(detail); 773 exceptionState().throwTypeError(detail);
763 } else { 774 } else {
764 ASSERT(!methodName().isEmpty()); 775 ASSERT(!methodName().isEmpty());
765 exceptionState().throwTypeError(ExceptionMessages::failedToExecute(inter faceName(), methodName(), detail)); 776 exceptionState().throwTypeError(ExceptionMessages::failedToExecute(inter faceName(), methodName(), detail));
766 } 777 }
767 } 778 }
768 779
769 } // namespace WebCore 780 } // namespace WebCore
OLDNEW
« Source/bindings/v8/CustomElementConstructorBuilder.cpp ('K') | « Source/bindings/v8/Dictionary.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698