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

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

Issue 20034002: Add support for KeyboardEvent.location attribute (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « Source/bindings/tests/results/V8TestExtendedEvent.h ('k') | Source/core/dom/KeyboardEvent.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 This file is part of the Blink open source project. 2 This file is part of the Blink open source project.
3 This file has been auto-generated by CodeGeneratorV8.pm. DO NOT MODIFY! 3 This file has been auto-generated by CodeGeneratorV8.pm. DO NOT MODIFY!
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19 */ 19 */
20 20
21 #include "config.h" 21 #include "config.h"
22 #if ENABLE(TEST) 22 #if ENABLE(TEST)
23 #include "V8TestExtendedEvent.h" 23 #include "V8TestExtendedEvent.h"
24 24
25 #include "RuntimeEnabledFeatures.h" 25 #include "RuntimeEnabledFeatures.h"
26 #include "V8TestEvent.h" 26 #include "V8TestEvent.h"
27 #include "bindings/v8/Dictionary.h"
27 #include "bindings/v8/ScriptController.h" 28 #include "bindings/v8/ScriptController.h"
28 #include "bindings/v8/V8Binding.h" 29 #include "bindings/v8/V8Binding.h"
29 #include "bindings/v8/V8DOMConfiguration.h" 30 #include "bindings/v8/V8DOMConfiguration.h"
30 #include "bindings/v8/V8DOMWrapper.h" 31 #include "bindings/v8/V8DOMWrapper.h"
32 #include "bindings/v8/V8ObjectConstructor.h"
31 #include "core/dom/ContextFeatures.h" 33 #include "core/dom/ContextFeatures.h"
32 #include "core/dom/Document.h" 34 #include "core/dom/Document.h"
33 #include "core/page/Frame.h" 35 #include "core/page/Frame.h"
36 #include "core/page/PageConsole.h"
37 #include "core/page/UseCounter.h"
34 #include "core/platform/chromium/TraceEvent.h" 38 #include "core/platform/chromium/TraceEvent.h"
35 #include "wtf/UnusedParam.h" 39 #include "wtf/UnusedParam.h"
36 40
37 namespace WebCore { 41 namespace WebCore {
38 42
39 static void initializeScriptWrappableForInterface(Event* object) 43 static void initializeScriptWrappableForInterface(Event* object)
40 { 44 {
41 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) 45 if (ScriptWrappable::wrapperCanBeStoredInObject(object))
42 ScriptWrappable::setTypeInfoInObject(object, &V8TestExtendedEvent::info) ; 46 ScriptWrappable::setTypeInfoInObject(object, &V8TestExtendedEvent::info) ;
43 else 47 else
(...skipping 11 matching lines...) Expand all
55 WebCore::initializeScriptWrappableForInterface(object); 59 WebCore::initializeScriptWrappableForInterface(object);
56 } 60 }
57 61
58 namespace WebCore { 62 namespace WebCore {
59 WrapperTypeInfo V8TestExtendedEvent::info = { V8TestExtendedEvent::GetTemplate, V8TestExtendedEvent::derefObject, 0, 0, 0, V8TestExtendedEvent::installPerContex tPrototypeProperties, &V8TestEvent::info, WrapperTypeObjectPrototype }; 63 WrapperTypeInfo V8TestExtendedEvent::info = { V8TestExtendedEvent::GetTemplate, V8TestExtendedEvent::derefObject, 0, 0, 0, V8TestExtendedEvent::installPerContex tPrototypeProperties, &V8TestEvent::info, WrapperTypeObjectPrototype };
60 64
61 namespace EventV8Internal { 65 namespace EventV8Internal {
62 66
63 template <typename T> void V8_USE(T) { } 67 template <typename T> void V8_USE(T) { }
64 68
69 static void locationAttrGetter(v8::Local<v8::String> name, const v8::PropertyCal lbackInfo<v8::Value>& info)
70 {
71 Event* imp = V8TestExtendedEvent::toNative(info.Holder());
72 v8SetReturnValueUnsigned(info, imp->location());
73 return;
74 }
75
76 static void locationAttrGetterCallback(v8::Local<v8::String> name, const v8::Pro pertyCallbackInfo<v8::Value>& info)
77 {
78 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
79 EventV8Internal::locationAttrGetter(name, info);
80 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
81 }
82
83 static void keyLocationAttrGetter(v8::Local<v8::String> name, const v8::Property CallbackInfo<v8::Value>& info)
84 {
85 Event* imp = V8TestExtendedEvent::toNative(info.Holder());
86 v8SetReturnValueUnsigned(info, imp->location());
87 return;
88 }
89
90 static void keyLocationAttrGetterCallback(v8::Local<v8::String> name, const v8:: PropertyCallbackInfo<v8::Value>& info)
91 {
92 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter");
93 UseCounter::countDeprecation(activeDOMWindow(), UseCounter::KeyboardEventKey Location);
94 EventV8Internal::keyLocationAttrGetter(name, info);
95 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution");
96 }
97
98 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& args)
99 {
100 if (args.Length() < 1) {
101 throwNotEnoughArgumentsError(args.GetIsolate());
102 return;
103 }
104
105 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, type, args[0]);
106 EventInit eventInit;
107 if (args.Length() >= 2) {
108 V8TRYCATCH_VOID(Dictionary, options, Dictionary(args[1], args.GetIsolate ()));
109 if (!fillEventInit(eventInit, options))
110 return;
111 }
112
113 RefPtr<Event> event = Event::create(type, eventInit);
114 v8::Handle<v8::Object> wrapper = args.Holder();
115 V8DOMWrapper::associateObjectWithWrapper<V8TestExtendedEvent>(event.release( ), &V8TestExtendedEvent::info, wrapper, args.GetIsolate(), WrapperConfiguration: :Dependent);
116 v8SetReturnValue(args, wrapper);
117 }
65 } // namespace EventV8Internal 118 } // namespace EventV8Internal
66 119
120 static const V8DOMConfiguration::BatchedAttribute V8TestExtendedEventAttrs[] = {
121 // Attribute 'location'
122 {"location", EventV8Internal::locationAttrGetterCallback, 0, 0, 0, 0 /* no d ata */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAtt ribute>(v8::None), 0 /* on instance */},
123 // Attribute 'keyLocation'
124 {"keyLocation", EventV8Internal::keyLocationAttrGetterCallback, 0, 0, 0, 0 / * no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::Prope rtyAttribute>(v8::None), 0 /* on instance */},
125 };
126
127 bool fillEventInit(EventInit& eventInit, const Dictionary& options)
128 {
129 if (!fillTestEventInit(eventInit, options))
130 return false;
131
132 options.get("location", eventInit.location);
133 if (options.get("keyLocation", eventInit.location))
134 UseCounter::countDeprecation(activeDOMWindow(), UseCounter::KeyboardEven tKeyLocation);
135 return true;
136 }
137
138 void V8TestExtendedEvent::constructorCallback(const v8::FunctionCallbackInfo<v8: :Value>& args)
139 {
140 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "DOMConstructor");
141 if (!args.IsConstructCall()) {
142 throwTypeError("DOM object constructor cannot be called as a function.", args.GetIsolate());
143 return;
144 }
145
146 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) {
147 args.GetReturnValue().Set(args.Holder());
148 return;
149 }
150
151 EventV8Internal::constructor(args);
152 }
153
67 static v8::Handle<v8::FunctionTemplate> ConfigureV8TestExtendedEventTemplate(v8: :Handle<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldType curre ntWorldType) 154 static v8::Handle<v8::FunctionTemplate> ConfigureV8TestExtendedEventTemplate(v8: :Handle<v8::FunctionTemplate> desc, v8::Isolate* isolate, WrapperWorldType curre ntWorldType)
68 { 155 {
69 desc->ReadOnlyPrototype(); 156 desc->ReadOnlyPrototype();
70 157
71 v8::Local<v8::Signature> defaultSignature; 158 v8::Local<v8::Signature> defaultSignature;
72 if (!RuntimeEnabledFeatures::testEnabled()) 159 if (!RuntimeEnabledFeatures::testEnabled())
73 defaultSignature = V8DOMConfiguration::configureTemplate(desc, "", V8Tes tEvent::GetTemplate(isolate, currentWorldType), V8TestExtendedEvent::internalFie ldCount, 0, 0, 0, 0, isolate, currentWorldType); 160 defaultSignature = V8DOMConfiguration::configureTemplate(desc, "", V8Tes tEvent::GetTemplate(isolate, currentWorldType), V8TestExtendedEvent::internalFie ldCount, 0, 0, 0, 0, isolate, currentWorldType);
74 else 161 else
75 defaultSignature = V8DOMConfiguration::configureTemplate(desc, "TestExtended Event", V8TestEvent::GetTemplate(isolate, currentWorldType), V8TestExtendedEvent ::internalFieldCount, 162 defaultSignature = V8DOMConfiguration::configureTemplate(desc, "TestExtended Event", V8TestEvent::GetTemplate(isolate, currentWorldType), V8TestExtendedEvent ::internalFieldCount,
76 0, 0, 163 V8TestExtendedEventAttrs, WTF_ARRAY_LENGTH(V8TestExtendedEventAttrs),
77 0, 0, isolate, currentWorldType); 164 0, 0, isolate, currentWorldType);
78 UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. 165 UNUSED_PARAM(defaultSignature); // In some cases, it will not be used.
166 desc->SetCallHandler(V8TestExtendedEvent::constructorCallback);
167 desc->SetLength(1);
79 168
80 // Custom toString template 169 // Custom toString template
81 desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->to StringTemplate()); 170 desc->Set(v8::String::NewSymbol("toString"), V8PerIsolateData::current()->to StringTemplate());
82 return desc; 171 return desc;
83 } 172 }
84 173
85 v8::Handle<v8::FunctionTemplate> V8TestExtendedEvent::GetTemplate(v8::Isolate* i solate, WrapperWorldType currentWorldType) 174 v8::Handle<v8::FunctionTemplate> V8TestExtendedEvent::GetTemplate(v8::Isolate* i solate, WrapperWorldType currentWorldType)
86 { 175 {
87 V8PerIsolateData* data = V8PerIsolateData::from(isolate); 176 V8PerIsolateData* data = V8PerIsolateData::from(isolate);
88 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo rldType).find(&info); 177 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWo rldType).find(&info);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 return wrapper; 219 return wrapper;
131 } 220 }
132 void V8TestExtendedEvent::derefObject(void* object) 221 void V8TestExtendedEvent::derefObject(void* object)
133 { 222 {
134 fromInternalPointer(object)->deref(); 223 fromInternalPointer(object)->deref();
135 } 224 }
136 225
137 } // namespace WebCore 226 } // namespace WebCore
138 227
139 #endif // ENABLE(TEST) 228 #endif // ENABLE(TEST)
OLDNEW
« no previous file with comments | « Source/bindings/tests/results/V8TestExtendedEvent.h ('k') | Source/core/dom/KeyboardEvent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698