OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 { | 108 { |
109 if (info.Length() < 1) { | 109 if (info.Length() < 1) { |
110 throwTypeError(ExceptionMessages::failedToConstruct("TestExtendedEvent",
"An event name must be provided."), info.GetIsolate()); | 110 throwTypeError(ExceptionMessages::failedToConstruct("TestExtendedEvent",
"An event name must be provided."), info.GetIsolate()); |
111 return; | 111 return; |
112 } | 112 } |
113 | 113 |
114 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, type, info[0]); | 114 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, type, info[0]); |
115 EventInit eventInit; | 115 EventInit eventInit; |
116 if (info.Length() >= 2) { | 116 if (info.Length() >= 2) { |
117 V8TRYCATCH_VOID(Dictionary, options, Dictionary(info[1], info.GetIsolate
())); | 117 V8TRYCATCH_VOID(Dictionary, options, Dictionary(info[1], info.GetIsolate
())); |
118 if (!fillEventInit(eventInit, options)) | 118 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); |
| 119 if (!fillEventInit(eventInit, options, exceptionState)) { |
| 120 exceptionState.throwIfNeeded(); |
119 return; | 121 return; |
| 122 } |
120 } | 123 } |
121 | |
122 RefPtr<Event> event = Event::create(type, eventInit); | 124 RefPtr<Event> event = Event::create(type, eventInit); |
123 v8::Handle<v8::Object> wrapper = info.Holder(); | 125 v8::Handle<v8::Object> wrapper = info.Holder(); |
124 V8DOMWrapper::associateObjectWithWrapper<V8TestExtendedEvent>(event.release(
), &V8TestExtendedEvent::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperCon
figuration::Dependent); | 126 V8DOMWrapper::associateObjectWithWrapper<V8TestExtendedEvent>(event.release(
), &V8TestExtendedEvent::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperCon
figuration::Dependent); |
125 v8SetReturnValue(info, wrapper); | 127 v8SetReturnValue(info, wrapper); |
126 } | 128 } |
127 } // namespace EventV8Internal | 129 } // namespace EventV8Internal |
128 | 130 |
129 static const V8DOMConfiguration::AttributeConfiguration V8TestExtendedEventAttri
butes[] = { | 131 static const V8DOMConfiguration::AttributeConfiguration V8TestExtendedEventAttri
butes[] = { |
130 {"location", EventV8Internal::locationAttributeGetterCallback, 0, 0, 0, 0, s
tatic_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v
8::None), 0 /* on instance */}, | 132 {"location", EventV8Internal::locationAttributeGetterCallback, 0, 0, 0, 0, s
tatic_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v
8::None), 0 /* on instance */}, |
131 {"keyLocation", EventV8Internal::keyLocationAttributeGetterCallback, 0, 0, 0
, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttrib
ute>(v8::None), 0 /* on instance */}, | 133 {"keyLocation", EventV8Internal::keyLocationAttributeGetterCallback, 0, 0, 0
, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttrib
ute>(v8::None), 0 /* on instance */}, |
132 }; | 134 }; |
133 | 135 |
134 bool fillEventInit(EventInit& eventInit, const Dictionary& options) | 136 bool fillEventInit(EventInit& eventInit, const Dictionary& options, ExceptionSta
te& exceptionState) |
135 { | 137 { |
136 if (!fillTestEventInit(eventInit, options)) | 138 if (!fillTestEventInit(eventInit, options, exceptionState)) |
137 return false; | 139 return false; |
138 | 140 |
139 options.get("location", eventInit.location); | 141 if (!options.convert("location", NormalConversion, eventInit.location, excep
tionState)) |
140 if (options.get("keyLocation", eventInit.location)) | 142 return false; |
141 UseCounter::countDeprecation(activeExecutionContext(), UseCounter::Keybo
ardEventKeyLocation); | 143 if (options.convert("keyLocation", NormalConversion, eventInit.location, exc
eptionState)) { |
| 144 if (options.hasProperty("keyLocation")) |
| 145 UseCounter::countDeprecation(activeExecutionContext(), UseCounter::K
eyboardEventKeyLocation); |
| 146 } else { |
| 147 return false; |
| 148 } |
142 return true; | 149 return true; |
143 } | 150 } |
144 | 151 |
145 void V8TestExtendedEvent::constructorCallback(const v8::FunctionCallbackInfo<v8:
:Value>& info) | 152 void V8TestExtendedEvent::constructorCallback(const v8::FunctionCallbackInfo<v8:
:Value>& info) |
146 { | 153 { |
147 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "DOMConstructor"); | 154 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "DOMConstructor"); |
148 if (!info.IsConstructCall()) { | 155 if (!info.IsConstructCall()) { |
149 throwTypeError(ExceptionMessages::failedToConstruct("TestExtendedEvent",
"Please use the 'new' operator, this DOM object constructor cannot be called as
a function."), info.GetIsolate()); | 156 throwTypeError(ExceptionMessages::failedToConstruct("TestExtendedEvent",
"Please use the 'new' operator, this DOM object constructor cannot be called as
a function."), info.GetIsolate()); |
150 return; | 157 return; |
151 } | 158 } |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 return wrapper; | 238 return wrapper; |
232 } | 239 } |
233 | 240 |
234 void V8TestExtendedEvent::derefObject(void* object) | 241 void V8TestExtendedEvent::derefObject(void* object) |
235 { | 242 { |
236 fromInternalPointer(object)->deref(); | 243 fromInternalPointer(object)->deref(); |
237 } | 244 } |
238 | 245 |
239 } // namespace WebCore | 246 } // namespace WebCore |
240 #endif // ENABLE(TEST) | 247 #endif // ENABLE(TEST) |
OLD | NEW |