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

Side by Side Diff: Source/bindings/core/v8/V8DOMConfiguration.h

Issue 483163003: Introduce ES6 iterator for DOM objects. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 3 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 const char* const svalue; 127 const char* const svalue;
128 ConstantType type; 128 ConstantType type;
129 }; 129 };
130 130
131 static void installConstants(v8::Handle<v8::FunctionTemplate>, v8::Handle<v8 ::ObjectTemplate>, const ConstantConfiguration*, size_t constantCount, v8::Isola te*); 131 static void installConstants(v8::Handle<v8::FunctionTemplate>, v8::Handle<v8 ::ObjectTemplate>, const ConstantConfiguration*, size_t constantCount, v8::Isola te*);
132 132
133 // MethodConfiguration translates into calls to Set() for setting up an 133 // MethodConfiguration translates into calls to Set() for setting up an
134 // object's callbacks. It sets the method on both the FunctionTemplate or 134 // object's callbacks. It sets the method on both the FunctionTemplate or
135 // the ObjectTemplate. 135 // the ObjectTemplate.
136 struct MethodConfiguration { 136 struct MethodConfiguration {
137 v8::Local<v8::Name> methodName(v8::Isolate* isolate) const { return v8At omicString(isolate, name); }
138 v8::FunctionCallback callbackForWorld(const DOMWrapperWorld& world) cons t
139 {
140 return world.isMainWorld() && callbackForMainWorld ? callbackForMain World : callback;
141 }
142
137 const char* const name; 143 const char* const name;
138 v8::FunctionCallback callback; 144 v8::FunctionCallback callback;
139 v8::FunctionCallback callbackForMainWorld; 145 v8::FunctionCallback callbackForMainWorld;
140 int length; 146 int length;
141 ExposeConfiguration exposeConfiguration; 147 ExposeConfiguration exposeConfiguration;
142 }; 148 };
143 149
150 struct SymbolKeyedMethodConfiguration {
151 v8::Local<v8::Name> methodName(v8::Isolate* isolate) const { return getS ymbol(isolate); }
152 v8::FunctionCallback callbackForWorld(const DOMWrapperWorld&) const
153 {
154 return callback;
155 }
156
157 v8::Local<v8::Symbol> (*getSymbol)(v8::Isolate*);
158 v8::FunctionCallback callback;
159 // SymbolKeyedMethodConfiguration doesn't support per-world bindings.
160 int length;
161 ExposeConfiguration exposeConfiguration;
162 };
163
144 static void installMethods(v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::Si gnature>, v8::PropertyAttribute, const MethodConfiguration*, size_t callbackCoun t, v8::Isolate*); 164 static void installMethods(v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::Si gnature>, v8::PropertyAttribute, const MethodConfiguration*, size_t callbackCoun t, v8::Isolate*);
145 165
146 template <class Template> 166 template <class ObjectOrTemplate, class Configuration>
147 static void installMethod(v8::Handle<Template> prototype, v8::Handle<v8::Sig nature> signature, v8::PropertyAttribute attribute, const MethodConfiguration& c allback, v8::Isolate* isolate) 167 static void installMethod(v8::Handle<ObjectOrTemplate> objectOrTemplate, v8: :Handle<v8::Signature> signature, v8::PropertyAttribute attribute, const Configu ration& callback, v8::Isolate* isolate)
148 { 168 {
149 DOMWrapperWorld& world = DOMWrapperWorld::current(isolate); 169 DOMWrapperWorld& world = DOMWrapperWorld::current(isolate);
150 if (callback.exposeConfiguration == OnlyExposedToPrivateScript && !world .isPrivateScriptIsolatedWorld()) 170 if (callback.exposeConfiguration == OnlyExposedToPrivateScript && !world .isPrivateScriptIsolatedWorld())
151 return; 171 return;
152 172
153 v8::Local<v8::FunctionTemplate> functionTemplate = functionTemplateForMe thod(signature, callback, isolate); 173 v8::Local<v8::FunctionTemplate> functionTemplate = functionTemplateForCa llback(signature, callback.callbackForWorld(world), callback.length, isolate);
154 prototype->Set(v8AtomicString(isolate, callback.name), functionTemplate, attribute); 174 setMethod(objectOrTemplate, callback.methodName(isolate), functionTempla te, attribute);
155 }
156
157 static void installMethod(v8::Handle<v8::Object> object, v8::Handle<v8::Sign ature> signature, v8::PropertyAttribute, const MethodConfiguration& callback, v8 ::Isolate* isolate)
158 {
159 DOMWrapperWorld& world = DOMWrapperWorld::current(isolate);
160 if (callback.exposeConfiguration == OnlyExposedToPrivateScript && !world .isPrivateScriptIsolatedWorld())
161 return;
162
163 v8::Local<v8::FunctionTemplate> functionTemplate = functionTemplateForMe thod(signature, callback, isolate);
164 object->Set(v8AtomicString(isolate, callback.name), functionTemplate->Ge tFunction());
165 } 175 }
166 176
167 static void installAccessors(v8::Handle<v8::ObjectTemplate>, v8::Handle<v8:: Signature>, const AccessorConfiguration*, size_t accessorCount, v8::Isolate*); 177 static void installAccessors(v8::Handle<v8::ObjectTemplate>, v8::Handle<v8:: Signature>, const AccessorConfiguration*, size_t accessorCount, v8::Isolate*);
168 178
169 static v8::Local<v8::Signature> installDOMClassTemplate(v8::Handle<v8::Funct ionTemplate>, const char* interfaceName, v8::Handle<v8::FunctionTemplate> parent Class, size_t fieldCount, 179 static v8::Local<v8::Signature> installDOMClassTemplate(v8::Handle<v8::Funct ionTemplate>, const char* interfaceName, v8::Handle<v8::FunctionTemplate> parent Class, size_t fieldCount,
170 const AttributeConfiguration*, size_t attributeCount, 180 const AttributeConfiguration*, size_t attributeCount,
171 const AccessorConfiguration*, size_t accessorCount, 181 const AccessorConfiguration*, size_t accessorCount,
172 const MethodConfiguration*, size_t callbackCount, 182 const MethodConfiguration*, size_t callbackCount,
173 v8::Isolate*); 183 v8::Isolate*);
174 184
175 static v8::Handle<v8::FunctionTemplate> domClassTemplate(v8::Isolate*, Wrapp erTypeInfo*, void (*)(v8::Handle<v8::FunctionTemplate>, v8::Isolate*)); 185 static v8::Handle<v8::FunctionTemplate> domClassTemplate(v8::Isolate*, Wrapp erTypeInfo*, void (*)(v8::Handle<v8::FunctionTemplate>, v8::Isolate*));
176 186
177 private: 187 private:
178 static v8::Handle<v8::FunctionTemplate> functionTemplateForMethod(v8::Handle <v8::Signature>, const MethodConfiguration&, v8::Isolate*); 188 static void setMethod(v8::Handle<v8::Object> target, v8::Handle<v8::Name> na me, v8::Handle<v8::FunctionTemplate> functionTemplate, v8::PropertyAttribute att ribute)
189 {
190 target->Set(name, functionTemplate->GetFunction());
191 }
192 static void setMethod(v8::Handle<v8::FunctionTemplate> target, v8::Handle<v8 ::Name> name, v8::Handle<v8::FunctionTemplate> functionTemplate, v8::PropertyAtt ribute attribute)
193 {
194 target->Set(name, functionTemplate, attribute);
195 }
196 static void setMethod(v8::Handle<v8::ObjectTemplate> target, v8::Handle<v8:: Name> name, v8::Handle<v8::FunctionTemplate> functionTemplate, v8::PropertyAttri bute attribute)
197 {
198 target->Set(name, functionTemplate, attribute);
199 }
200
201 static v8::Handle<v8::FunctionTemplate> functionTemplateForCallback(v8::Hand le<v8::Signature>, v8::FunctionCallback, int length, v8::Isolate*);
179 }; 202 };
180 203
181 } // namespace blink 204 } // namespace blink
182 205
183 #endif // V8DOMConfiguration_h 206 #endif // V8DOMConfiguration_h
OLDNEW
« no previous file with comments | « Source/bindings/IDLExtendedAttributes.txt ('k') | Source/bindings/core/v8/V8DOMConfiguration.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698