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

Side by Side Diff: third_party/WebKit/Source/bindings/templates/union_container.cpp

Issue 1994823002: Add !IsArray() check for dictionary conversion in union types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/tests/results/core/LongOrTestDictionary.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 {% from 'utilities.cpp' import declare_enum_validation_variable %} 1 {% from 'utilities.cpp' import declare_enum_validation_variable %}
2 {% include 'copyright_block.txt' %} 2 {% include 'copyright_block.txt' %}
3 #include "{{this_include_header_name}}.h" 3 #include "{{this_include_header_name}}.h"
4 4
5 {% from 'utilities.cpp' import v8_value_to_local_cpp_value %} 5 {% from 'utilities.cpp' import v8_value_to_local_cpp_value %}
6 {% macro assign_and_return_if_hasinstance(member) %} 6 {% macro assign_and_return_if_hasinstance(member) %}
7 if (V8{{member.type_name}}::hasInstance(v8Value, isolate)) { 7 if (V8{{member.type_name}}::hasInstance(v8Value, isolate)) {
8 {{member.cpp_local_type}} cppValue = V8{{member.type_name}}::toImpl(v8::Loca l<v8::Object>::Cast(v8Value)); 8 {{member.cpp_local_type}} cppValue = V8{{member.type_name}}::toImpl(v8::Loca l<v8::Object>::Cast(v8Value));
9 impl.set{{member.type_name}}(cppValue); 9 impl.set{{member.type_name}}(cppValue);
10 return; 10 return;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 {# 9., 10. ArrayBufferView #} 86 {# 9., 10. ArrayBufferView #}
87 {# FIXME: Individual typed arrays (e.g. Uint8Array) aren't supported yet. #} 87 {# FIXME: Individual typed arrays (e.g. Uint8Array) aren't supported yet. #}
88 {% if array_buffer_view_type %} 88 {% if array_buffer_view_type %}
89 {{assign_and_return_if_hasinstance(array_buffer_view_type) | indent}} 89 {{assign_and_return_if_hasinstance(array_buffer_view_type) | indent}}
90 90
91 {% endif %} 91 {% endif %}
92 {% if dictionary_type %} 92 {% if dictionary_type %}
93 {# 12. Dictionaries #} 93 {# 12. Dictionaries #}
94 {# FIXME: This should also check "object but not Date or RegExp". Add checks 94 {# FIXME: This should also check "object but not Date or RegExp". Add checks
95 when we implement conversions for Date and RegExp. #} 95 when we implement conversions for Date and RegExp. #}
96 if (isUndefinedOrNull(v8Value) || v8Value->IsObject()) { 96 {# TODO(bashi): The spec doesn't say we should check !IsArray() but otherwis e
97 we can't distinguish a sequence<T> and a dictionary.
98 https://github.com/heycam/webidl/issues/123 #}
99 if (isUndefinedOrNull(v8Value) || (v8Value->IsObject() && !v8Value->IsArray( ))) {
97 {{v8_value_to_local_cpp_value(dictionary_type) | indent(8)}} 100 {{v8_value_to_local_cpp_value(dictionary_type) | indent(8)}}
98 impl.set{{dictionary_type.type_name}}(cppValue); 101 impl.set{{dictionary_type.type_name}}(cppValue);
99 return; 102 return;
100 } 103 }
101 104
102 {% endif %} 105 {% endif %}
103 {% if array_or_sequence_type %} 106 {% if array_or_sequence_type %}
104 {# 13.1, 13.2. Arrays and Sequences #} 107 {# 13.1, 13.2. Arrays and Sequences #}
105 {# FIXME: This should also check "object but not Date or RegExp". Add checks 108 {# FIXME: This should also check "object but not Date or RegExp". Add checks
106 when we implement conversions for Date and RegExp. #} 109 when we implement conversions for Date and RegExp. #}
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 } 195 }
193 196
194 {{cpp_class}} NativeValueTraits<{{cpp_class}}>::nativeValue(v8::Isolate* isolate , v8::Local<v8::Value> value, ExceptionState& exceptionState) 197 {{cpp_class}} NativeValueTraits<{{cpp_class}}>::nativeValue(v8::Isolate* isolate , v8::Local<v8::Value> value, ExceptionState& exceptionState)
195 { 198 {
196 {{cpp_class}} impl; 199 {{cpp_class}} impl;
197 {{v8_class}}::toImpl(isolate, value, impl, UnionTypeConversionMode::NotNulla ble, exceptionState); 200 {{v8_class}}::toImpl(isolate, value, impl, UnionTypeConversionMode::NotNulla ble, exceptionState);
198 return impl; 201 return impl;
199 } 202 }
200 203
201 } // namespace blink 204 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/tests/results/core/LongOrTestDictionary.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698