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

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

Issue 2340883003: Treat null dictionary members as missing per WebIDL (Closed)
Patch Set: Created 4 years, 3 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/idls/core/TestDictionary.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 {% filter format_blink_cpp_source_code %} 1 {% filter format_blink_cpp_source_code %}
2 2
3 {% from 'utilities.cpp' import declare_enum_validation_variable %} 3 {% from 'utilities.cpp' import declare_enum_validation_variable %}
4 {% include 'copyright_block.txt' %} 4 {% include 'copyright_block.txt' %}
5 #include "{{v8_original_class}}.h" 5 #include "{{v8_original_class}}.h"
6 6
7 {% for filename in cpp_includes if filename != '%s.h' % v8_class %} 7 {% for filename in cpp_includes if filename != '%s.h' % v8_class %}
8 #include "{{filename}}" 8 #include "{{filename}}"
9 {% endfor %} 9 {% endfor %}
10 10
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 return; 44 return;
45 } 45 }
46 {% endif %} 46 {% endif %}
47 {% for member in members %} 47 {% for member in members %}
48 {% filter runtime_enabled(member.runtime_enabled_function) %} 48 {% filter runtime_enabled(member.runtime_enabled_function) %}
49 v8::Local<v8::Value> {{member.name}}Value; 49 v8::Local<v8::Value> {{member.name}}Value;
50 if (!v8Object->Get(isolate->GetCurrentContext(), v8String(isolate, "{{member .name}}")).ToLocal(&{{member.name}}Value)) { 50 if (!v8Object->Get(isolate->GetCurrentContext(), v8String(isolate, "{{member .name}}")).ToLocal(&{{member.name}}Value)) {
51 exceptionState.rethrowV8Exception(block.Exception()); 51 exceptionState.rethrowV8Exception(block.Exception());
52 return; 52 return;
53 } 53 }
54 if ({{member.name}}Value.IsEmpty() || {{member.name}}Value->IsUndefined()) { 54 if (isUndefinedOrNull({{member.name}}Value)) {
55 {% if member.is_required %} 55 {% if member.is_required %}
56 exceptionState.throwTypeError("required member {{member.name}} is undefi ned."); 56 exceptionState.throwTypeError("required member {{member.name}} is undefi ned.");
57 return; 57 return;
58 {% else %} 58 {% else %}
59 // Do nothing. 59 // Do nothing.
60 {% endif %} 60 {% endif %}
61 {% if member.is_nullable %}
62 } else if ({{member.name}}Value->IsNull()) {
63 impl.{{member.null_setter_name}}();
64 {% endif %}
65 } else { 61 } else {
66 {% if member.deprecate_as %} 62 {% if member.deprecate_as %}
67 Deprecation::countDeprecationIfNotPrivateScript(isolate, currentExecutio nContext(isolate), UseCounter::{{member.deprecate_as}}); 63 Deprecation::countDeprecationIfNotPrivateScript(isolate, currentExecutio nContext(isolate), UseCounter::{{member.deprecate_as}});
68 {% endif %} 64 {% endif %}
69 {{v8_value_to_local_cpp_value(member) | indent(8)}} 65 {{v8_value_to_local_cpp_value(member) | indent(8)}}
70 {% if member.is_interface_type %} 66 {% if member.is_interface_type %}
71 if (!{{member.name}} && !{{member.name}}Value->IsNull()) { 67 if (!{{member.name}}) {
72 exceptionState.throwTypeError("member {{member.name}} is not of type {{member.idl_type}}."); 68 exceptionState.throwTypeError("member {{member.name}} is not of type {{member.idl_type}}.");
73 return; 69 return;
74 } 70 }
75 {% endif %} 71 {% endif %}
76 {% if member.enum_values %} 72 {% if member.enum_values %}
77 {{declare_enum_validation_variable(member.enum_values) | indent(8)}} 73 {{declare_enum_validation_variable(member.enum_values) | indent(8)}}
78 if (!isValidEnum({{member.name}}, validValues, WTF_ARRAY_LENGTH(validVal ues), "{{member.enum_type}}", exceptionState)) 74 if (!isValidEnum({{member.name}}, validValues, WTF_ARRAY_LENGTH(validVal ues), "{{member.enum_type}}", exceptionState))
79 return; 75 return;
80 {% elif member.is_object %} 76 {% elif member.is_object %}
81 if (!{{member.name}}.isObject()) { 77 if (!{{member.name}}.isObject()) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 {{cpp_class}} NativeValueTraits<{{cpp_class}}>::nativeValue(v8::Isolate* isolate , v8::Local<v8::Value> value, ExceptionState& exceptionState) 129 {{cpp_class}} NativeValueTraits<{{cpp_class}}>::nativeValue(v8::Isolate* isolate , v8::Local<v8::Value> value, ExceptionState& exceptionState)
134 { 130 {
135 {{cpp_class}} impl; 131 {{cpp_class}} impl;
136 {{v8_class}}::toImpl(isolate, value, impl, exceptionState); 132 {{v8_class}}::toImpl(isolate, value, impl, exceptionState);
137 return impl; 133 return impl;
138 } 134 }
139 135
140 } // namespace blink 136 } // namespace blink
141 137
142 {% endfilter %}{# format_blink_cpp_source_code #} 138 {% endfilter %}{# format_blink_cpp_source_code #}
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/tests/idls/core/TestDictionary.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698