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

Side by Side Diff: Source/bindings/tests/results/V8TestExtendedEvent.cpp

Issue 106183010: Delete 2 redundant bindings tests: TestExtendedEvent.idl and TestEvent.idl (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 // This file has been auto-generated by code_generator_v8.pm. DO NOT MODIFY!
32
33 #include "config.h"
34 #if ENABLE(TEST)
35 #include "V8TestExtendedEvent.h"
36
37 #include "RuntimeEnabledFeatures.h"
38 #include "bindings/v8/Dictionary.h"
39 #include "bindings/v8/ExceptionMessages.h"
40 #include "bindings/v8/V8DOMConfiguration.h"
41 #include "bindings/v8/V8ObjectConstructor.h"
42 #include "core/dom/ContextFeatures.h"
43 #include "core/dom/Document.h"
44 #include "core/frame/UseCounter.h"
45 #include "platform/TraceEvent.h"
46
47 namespace WebCore {
48
49 static void initializeScriptWrappableForInterface(Event* object)
50 {
51 if (ScriptWrappable::wrapperCanBeStoredInObject(object))
52 ScriptWrappable::setTypeInfoInObject(object, &V8TestExtendedEvent::wrapp erTypeInfo);
53 else
54 ASSERT_NOT_REACHED();
55 }
56
57 } // namespace WebCore
58
59 // In ScriptWrappable::init, the use of a local function declaration has an issu e on Windows:
60 // the local declaration does not pick up the surrounding namespace. Therefore, we provide this function
61 // in the global namespace.
62 // (More info on the MSVC bug here: http://connect.microsoft.com/VisualStudio/fe edback/details/664619/the-namespace-of-local-function-declarations-in-c)
63 void webCoreInitializeScriptWrappableForInterface(WebCore::Event* object)
64 {
65 WebCore::initializeScriptWrappableForInterface(object);
66 }
67
68 namespace WebCore {
69 const WrapperTypeInfo V8TestExtendedEvent::wrapperTypeInfo = { gin::kEmbedderBli nk, V8TestExtendedEvent::domTemplate, V8TestExtendedEvent::derefObject, 0, 0, 0, V8TestExtendedEvent::installPerContextEnabledMethods, &V8TestEvent::wrapperType Info, WrapperTypeObjectPrototype };
70
71 namespace EventV8Internal {
72
73 template <typename T> void V8_USE(T) { }
74
75 static void locationAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& i nfo)
76 {
77 Event* imp = V8TestExtendedEvent::toNative(info.Holder());
78 v8SetReturnValueUnsigned(info, imp->location());
79 }
80
81 static void locationAttributeGetterCallback(v8::Local<v8::String>, const v8::Pro pertyCallbackInfo<v8::Value>& info)
82 {
83 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
84 EventV8Internal::locationAttributeGetter(info);
85 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
86 }
87
88 static void keyLocationAttributeGetter(const v8::PropertyCallbackInfo<v8::Value> & info)
89 {
90 Event* imp = V8TestExtendedEvent::toNative(info.Holder());
91 v8SetReturnValueUnsigned(info, imp->location());
92 }
93
94 static void keyLocationAttributeGetterCallback(v8::Local<v8::String>, const v8:: PropertyCallbackInfo<v8::Value>& info)
95 {
96 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
97 UseCounter::countDeprecation(activeExecutionContext(), UseCounter::KeyboardE ventKeyLocation);
98 EventV8Internal::keyLocationAttributeGetter(info);
99 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
100 }
101
102 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info)
103 {
104 ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestExte ndedEvent", info.Holder(), info.GetIsolate());
105 if (info.Length() < 1) {
106 exceptionState.throwTypeError("An event name must be provided.");
107 exceptionState.throwIfNeeded();
108 return;
109 }
110
111 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, type, info[0]);
112 EventInit eventInit;
113 if (info.Length() >= 2) {
114 V8TRYCATCH_VOID(Dictionary, options, Dictionary(info[1], info.GetIsolate ()));
115 if (!initializeEvent(eventInit, options, exceptionState)) {
116 exceptionState.throwIfNeeded();
117 return;
118 }
119 }
120 RefPtr<Event> event = Event::create(type, eventInit);
121 v8::Handle<v8::Object> wrapper = info.Holder();
122 V8DOMWrapper::associateObjectWithWrapper<V8TestExtendedEvent>(event.release( ), &V8TestExtendedEvent::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperCon figuration::Dependent);
123 v8SetReturnValue(info, wrapper);
124 }
125
126 } // namespace EventV8Internal
127
128 static const V8DOMConfiguration::AttributeConfiguration V8TestExtendedEventAttri butes[] = {
129 {"location", EventV8Internal::locationAttributeGetterCallback, 0, 0, 0, 0, s tatic_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v 8::None), 0 /* on instance */},
130 {"keyLocation", EventV8Internal::keyLocationAttributeGetterCallback, 0, 0, 0 , 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttrib ute>(v8::None), 0 /* on instance */},
131 };
132
133 bool initializeEvent(EventInit& eventInit, const Dictionary& options, ExceptionS tate& exceptionState, const String& forEventName)
134 {
135 Dictionary::ConversionContext conversionContext(forEventName.isEmpty() ? Str ing("TestExtendedEvent") : forEventName, "", exceptionState);
136 if (!initializeTestEvent(eventInit, options, exceptionState, forEventName.is Empty() ? String("TestExtendedEvent") : forEventName))
137 return false;
138
139 if (!options.convert(conversionContext.setConversionType("unsigned long", fa lse), "location", eventInit.location))
140 return false;
141 if (options.convert(conversionContext.setConversionType("unsigned long", fal se), "keyLocation", eventInit.location)) {
142 if (options.hasProperty("keyLocation"))
143 UseCounter::countDeprecation(activeExecutionContext(), UseCounter::K eyboardEventKeyLocation);
144 } else {
145 return false;
146 }
147 return true;
148 }
149
150 void V8TestExtendedEvent::constructorCallback(const v8::FunctionCallbackInfo<v8: :Value>& info)
151 {
152 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "DOMConstructor");
153 if (!info.IsConstructCall()) {
154 throwTypeError(ExceptionMessages::failedToConstruct("TestExtendedEvent", "Please use the 'new' operator, this DOM object constructor cannot be called as a function."), info.GetIsolate());
155 return;
156 }
157
158 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) {
159 v8SetReturnValue(info, info.Holder());
160 return;
161 }
162
163 EventV8Internal::constructor(info);
164 }
165
166 static v8::Handle<v8::FunctionTemplate> ConfigureV8TestExtendedEventTemplate(v8: :Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate, WrapperWor ldType currentWorldType)
167 {
168 functionTemplate->ReadOnlyPrototype();
169
170 v8::Local<v8::Signature> defaultSignature;
171 if (!RuntimeEnabledFeatures::testEnabled())
172 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionT emplate, "", V8TestEvent::domTemplate(isolate, currentWorldType), V8TestExtended Event::internalFieldCount, 0, 0, 0, 0, 0, 0, isolate, currentWorldType);
173 else
174 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionT emplate, "TestExtendedEvent", V8TestEvent::domTemplate(isolate, currentWorldType ), V8TestExtendedEvent::internalFieldCount,
175 V8TestExtendedEventAttributes, WTF_ARRAY_LENGTH(V8TestExtendedEventA ttributes),
176 0, 0,
177 0, 0,
178 isolate, currentWorldType);
179 functionTemplate->SetCallHandler(V8TestExtendedEvent::constructorCallback);
180 functionTemplate->SetLength(1);
181 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTempla te->InstanceTemplate();
182 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTempl ate->PrototypeTemplate();
183
184 // Custom toString template
185 functionTemplate->Set(v8::String::NewFromUtf8(isolate, "toString", v8::Strin g::kInternalizedString), V8PerIsolateData::current()->toStringTemplate());
186 return functionTemplate;
187 }
188
189 v8::Handle<v8::FunctionTemplate> V8TestExtendedEvent::domTemplate(v8::Isolate* i solate, WrapperWorldType currentWorldType)
190 {
191 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
192 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo rldType).find(&wrapperTypeInfo);
193 if (result != data->templateMap(currentWorldType).end())
194 return result->value.newLocal(isolate);
195
196 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate");
197 v8::EscapableHandleScope handleScope(isolate);
198 v8::Local<v8::FunctionTemplate> templ =
199 ConfigureV8TestExtendedEventTemplate(data->rawDOMTemplate(&wrapperTypeIn fo, currentWorldType), isolate, currentWorldType);
200 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v 8::FunctionTemplate>(isolate, templ));
201 return handleScope.Escape(templ);
202 }
203
204 bool V8TestExtendedEvent::hasInstance(v8::Handle<v8::Value> jsValue, v8::Isolate * isolate, WrapperWorldType currentWorldType)
205 {
206 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, currentWorldType);
207 }
208
209 bool V8TestExtendedEvent::hasInstanceInAnyWorld(v8::Handle<v8::Value> jsValue, v 8::Isolate* isolate)
210 {
211 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, MainWorld)
212 || V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, IsolatedWorld)
213 || V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValu e, WorkerWorld);
214 }
215
216 v8::Handle<v8::Object> V8TestExtendedEvent::createWrapper(PassRefPtr<Event> impl , v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
217 {
218 ASSERT(impl);
219 ASSERT(!DOMDataStore::containsWrapper<V8TestExtendedEvent>(impl.get(), isola te));
220 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) {
221 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObje ct(impl.get());
222 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapper TypeInfo. These will both have
223 // the same object de-ref functions, though, so use that as the basis of the check.
224 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction);
225 }
226
227 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext , &wrapperTypeInfo, toInternalPointer(impl.get()), isolate);
228 if (UNLIKELY(wrapper.IsEmpty()))
229 return wrapper;
230
231 installPerContextEnabledProperties(wrapper, impl.get(), isolate);
232 V8DOMWrapper::associateObjectWithWrapper<V8TestExtendedEvent>(impl, &wrapper TypeInfo, wrapper, isolate, WrapperConfiguration::Independent);
233 return wrapper;
234 }
235
236 void V8TestExtendedEvent::derefObject(void* object)
237 {
238 fromInternalPointer(object)->deref();
239 }
240
241 template<>
242 v8::Handle<v8::Value> toV8NoInline(Event* impl, v8::Handle<v8::Object> creationC ontext, v8::Isolate* isolate)
243 {
244 return toV8(impl, creationContext, isolate);
245 }
246
247 } // namespace WebCore
248 #endif // ENABLE(TEST)
OLDNEW
« no previous file with comments | « Source/bindings/tests/results/V8TestExtendedEvent.h ('k') | Tools/Scripts/webkitpy/bindings/main.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698