| 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 { | 104 { |
| 105 if (info.Length() < 1) { | 105 if (info.Length() < 1) { |
| 106 throwTypeError(ExceptionMessages::failedToConstruct("TestEventConstructo
r", "An event name must be provided."), info.GetIsolate()); | 106 throwTypeError(ExceptionMessages::failedToConstruct("TestEventConstructo
r", "An event name must be provided."), info.GetIsolate()); |
| 107 return; | 107 return; |
| 108 } | 108 } |
| 109 | 109 |
| 110 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, type, info[0]); | 110 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, type, info[0]); |
| 111 TestEventConstructorInit eventInit; | 111 TestEventConstructorInit eventInit; |
| 112 if (info.Length() >= 2) { | 112 if (info.Length() >= 2) { |
| 113 V8TRYCATCH_VOID(Dictionary, options, Dictionary(info[1], info.GetIsolate
())); | 113 V8TRYCATCH_VOID(Dictionary, options, Dictionary(info[1], info.GetIsolate
())); |
| 114 if (!fillTestEventConstructorInit(eventInit, options)) | 114 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); |
| 115 if (!fillTestEventConstructorInit(eventInit, options, exceptionState)) { |
| 116 exceptionState.throwIfNeeded(); |
| 115 return; | 117 return; |
| 118 } |
| 116 } | 119 } |
| 117 | |
| 118 RefPtr<TestEventConstructor> event = TestEventConstructor::create(type, even
tInit); | 120 RefPtr<TestEventConstructor> event = TestEventConstructor::create(type, even
tInit); |
| 119 v8::Handle<v8::Object> wrapper = info.Holder(); | 121 v8::Handle<v8::Object> wrapper = info.Holder(); |
| 120 V8DOMWrapper::associateObjectWithWrapper<V8TestEventConstructor>(event.relea
se(), &V8TestEventConstructor::wrapperTypeInfo, wrapper, info.GetIsolate(), Wrap
perConfiguration::Dependent); | 122 V8DOMWrapper::associateObjectWithWrapper<V8TestEventConstructor>(event.relea
se(), &V8TestEventConstructor::wrapperTypeInfo, wrapper, info.GetIsolate(), Wrap
perConfiguration::Dependent); |
| 121 v8SetReturnValue(info, wrapper); | 123 v8SetReturnValue(info, wrapper); |
| 122 } | 124 } |
| 123 } // namespace TestEventConstructorV8Internal | 125 } // namespace TestEventConstructorV8Internal |
| 124 | 126 |
| 125 static const V8DOMConfiguration::AttributeConfiguration V8TestEventConstructorAt
tributes[] = { | 127 static const V8DOMConfiguration::AttributeConfiguration V8TestEventConstructorAt
tributes[] = { |
| 126 {"attr1", TestEventConstructorV8Internal::attr1AttributeGetterCallback, 0, 0
, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAtt
ribute>(v8::None), 0 /* on instance */}, | 128 {"attr1", TestEventConstructorV8Internal::attr1AttributeGetterCallback, 0, 0
, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAtt
ribute>(v8::None), 0 /* on instance */}, |
| 127 {"attr2", TestEventConstructorV8Internal::attr2AttributeGetterCallback, 0, 0
, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAtt
ribute>(v8::None), 0 /* on instance */}, | 129 {"attr2", TestEventConstructorV8Internal::attr2AttributeGetterCallback, 0, 0
, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAtt
ribute>(v8::None), 0 /* on instance */}, |
| 128 }; | 130 }; |
| 129 | 131 |
| 130 bool fillTestEventConstructorInit(TestEventConstructorInit& eventInit, const Dic
tionary& options) | 132 bool fillTestEventConstructorInit(TestEventConstructorInit& eventInit, const Dic
tionary& options, ExceptionState& exceptionState) |
| 131 { | 133 { |
| 132 options.get("attr2", eventInit.attr2); | 134 if (!options.convert("attr2", eventInit.attr2, exceptionState)) |
| 135 return false; |
| 133 return true; | 136 return true; |
| 134 } | 137 } |
| 135 | 138 |
| 136 void V8TestEventConstructor::constructorCallback(const v8::FunctionCallbackInfo<
v8::Value>& info) | 139 void V8TestEventConstructor::constructorCallback(const v8::FunctionCallbackInfo<
v8::Value>& info) |
| 137 { | 140 { |
| 138 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "DOMConstructor"); | 141 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "DOMConstructor"); |
| 139 if (!info.IsConstructCall()) { | 142 if (!info.IsConstructCall()) { |
| 140 throwTypeError(ExceptionMessages::failedToConstruct("TestEventConstructo
r", "Please use the 'new' operator, this DOM object constructor cannot be called
as a function."), info.GetIsolate()); | 143 throwTypeError(ExceptionMessages::failedToConstruct("TestEventConstructo
r", "Please use the 'new' operator, this DOM object constructor cannot be called
as a function."), info.GetIsolate()); |
| 141 return; | 144 return; |
| 142 } | 145 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 V8DOMWrapper::associateObjectWithWrapper<V8TestEventConstructor>(impl, &wrap
perTypeInfo, wrapper, isolate, WrapperConfiguration::Independent); | 221 V8DOMWrapper::associateObjectWithWrapper<V8TestEventConstructor>(impl, &wrap
perTypeInfo, wrapper, isolate, WrapperConfiguration::Independent); |
| 219 return wrapper; | 222 return wrapper; |
| 220 } | 223 } |
| 221 | 224 |
| 222 void V8TestEventConstructor::derefObject(void* object) | 225 void V8TestEventConstructor::derefObject(void* object) |
| 223 { | 226 { |
| 224 fromInternalPointer(object)->deref(); | 227 fromInternalPointer(object)->deref(); |
| 225 } | 228 } |
| 226 | 229 |
| 227 } // namespace WebCore | 230 } // namespace WebCore |
| OLD | NEW |