| 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, const String& forEventName) |
| 135 { | 137 { |
| 136 if (!fillTestEventInit(eventInit, options)) | 138 Dictionary::ConversionContext conversionContext(forEventName.isEmpty() ? Str
ing("TestExtendedEvent") : forEventName, "", exceptionState); |
| 139 if (!fillTestEventInit(eventInit, options, exceptionState, forEventName.isEm
pty() ? String("TestExtendedEvent") : forEventName)) |
| 137 return false; | 140 return false; |
| 138 | 141 |
| 139 options.get("location", eventInit.location); | 142 if (!options.convert(conversionContext.withAttributes(false, NormalConversio
n), "location", eventInit.location)) |
| 140 if (options.get("keyLocation", eventInit.location)) | 143 return false; |
| 141 UseCounter::countDeprecation(activeExecutionContext(), UseCounter::Keybo
ardEventKeyLocation); | 144 if (options.convert(conversionContext.withAttributes(false, NormalConversion
), "keyLocation", eventInit.location)) { |
| 145 if (options.hasProperty("keyLocation")) |
| 146 UseCounter::countDeprecation(activeExecutionContext(), UseCounter::K
eyboardEventKeyLocation); |
| 147 } else { |
| 148 return false; |
| 149 } |
| 142 return true; | 150 return true; |
| 143 } | 151 } |
| 144 | 152 |
| 145 void V8TestExtendedEvent::constructorCallback(const v8::FunctionCallbackInfo<v8:
:Value>& info) | 153 void V8TestExtendedEvent::constructorCallback(const v8::FunctionCallbackInfo<v8:
:Value>& info) |
| 146 { | 154 { |
| 147 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "DOMConstructor"); | 155 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "DOMConstructor"); |
| 148 if (!info.IsConstructCall()) { | 156 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()); | 157 throwTypeError(ExceptionMessages::failedToConstruct("TestExtendedEvent",
"Please use the 'new' operator, this DOM object constructor cannot be called as
a function."), info.GetIsolate()); |
| 150 return; | 158 return; |
| 151 } | 159 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 return wrapper; | 239 return wrapper; |
| 232 } | 240 } |
| 233 | 241 |
| 234 void V8TestExtendedEvent::derefObject(void* object) | 242 void V8TestExtendedEvent::derefObject(void* object) |
| 235 { | 243 { |
| 236 fromInternalPointer(object)->deref(); | 244 fromInternalPointer(object)->deref(); |
| 237 } | 245 } |
| 238 | 246 |
| 239 } // namespace WebCore | 247 } // namespace WebCore |
| 240 #endif // ENABLE(TEST) | 248 #endif // ENABLE(TEST) |
| OLD | NEW |