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

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

Issue 2717183002: Slim V8DOMConfiguration::MethodConfiguration by refactoring per-world bindings. (Closed)
Patch Set: Merge branch 'master' into refactor-per-world-methods Created 3 years, 9 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 enum HolderCheckConfiguration : unsigned { 58 enum HolderCheckConfiguration : unsigned {
59 CheckHolder, 59 CheckHolder,
60 DoNotCheckHolder, 60 DoNotCheckHolder,
61 }; 61 };
62 62
63 enum AccessCheckConfiguration : unsigned { 63 enum AccessCheckConfiguration : unsigned {
64 CheckAccess, 64 CheckAccess,
65 DoNotCheckAccess, 65 DoNotCheckAccess,
66 }; 66 };
67 67
68 // Bit field to select which worlds the member will be defined in.
69 enum WorldConfiguration : unsigned {
70 MainWorld = 1 << 0,
71 OtherWorlds = 1 << 1,
haraken 2017/03/17 18:16:14 NonMainWorlds ?
jbroman 2017/03/17 18:32:43 Done. I'd named it for the hypothetical possibilit
72 AllWorlds = MainWorld | OtherWorlds,
73 };
74
68 typedef v8::Local<v8::Private> (*CachedAccessorCallback)(v8::Isolate*); 75 typedef v8::Local<v8::Private> (*CachedAccessorCallback)(v8::Isolate*);
69 76
70 // AttributeConfiguration translates into calls to SetNativeDataProperty() on 77 // AttributeConfiguration translates into calls to SetNativeDataProperty() on
71 // either the instance or the prototype ObjectTemplate, based on 78 // either the instance or the prototype ObjectTemplate, based on
72 // |propertyLocationConfiguration|. 79 // |propertyLocationConfiguration|.
73 struct AttributeConfiguration { 80 struct AttributeConfiguration {
74 AttributeConfiguration& operator=(const AttributeConfiguration&) = delete; 81 AttributeConfiguration& operator=(const AttributeConfiguration&) = delete;
75 DISALLOW_NEW(); 82 DISALLOW_NEW();
76 const char* const name; 83 const char* const name;
77 v8::AccessorNameGetterCallback getter; 84 v8::AccessorNameGetterCallback getter;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 233
227 // MethodConfiguration translates into calls to Set() for setting up an 234 // MethodConfiguration translates into calls to Set() for setting up an
228 // object's callbacks. It sets the method on both the FunctionTemplate or 235 // object's callbacks. It sets the method on both the FunctionTemplate or
229 // the ObjectTemplate. 236 // the ObjectTemplate.
230 struct MethodConfiguration { 237 struct MethodConfiguration {
231 MethodConfiguration& operator=(const MethodConfiguration&) = delete; 238 MethodConfiguration& operator=(const MethodConfiguration&) = delete;
232 DISALLOW_NEW(); 239 DISALLOW_NEW();
233 v8::Local<v8::Name> methodName(v8::Isolate* isolate) const { 240 v8::Local<v8::Name> methodName(v8::Isolate* isolate) const {
234 return v8AtomicString(isolate, name); 241 return v8AtomicString(isolate, name);
235 } 242 }
236 v8::FunctionCallback callbackForWorld(const DOMWrapperWorld& world) const {
237 return world.isMainWorld() && callbackForMainWorld ? callbackForMainWorld
238 : callback;
239 }
240 243
241 const char* const name; 244 const char* const name;
242 v8::FunctionCallback callback; 245 v8::FunctionCallback callback;
243 v8::FunctionCallback callbackForMainWorld;
244 int length; 246 int length;
245 // v8::PropertyAttribute 247 // v8::PropertyAttribute
246 unsigned attribute : 8; 248 unsigned attribute : 8;
247 // PropertyLocationConfiguration 249 // PropertyLocationConfiguration
248 unsigned propertyLocationConfiguration : 3; 250 unsigned propertyLocationConfiguration : 3;
249 // HolderCheckConfiguration 251 // HolderCheckConfiguration
250 unsigned holderCheckConfiguration : 1; 252 unsigned holderCheckConfiguration : 1;
251 // AccessCheckConfiguration 253 // AccessCheckConfiguration
252 unsigned accessCheckConfiguration : 1; 254 unsigned accessCheckConfiguration : 1;
255 // WorldConfiguration
256 unsigned worldConfiguration : 2;
253 }; 257 };
254 258
255 struct SymbolKeyedMethodConfiguration { 259 struct SymbolKeyedMethodConfiguration {
256 SymbolKeyedMethodConfiguration& operator=( 260 SymbolKeyedMethodConfiguration& operator=(
257 const SymbolKeyedMethodConfiguration&) = delete; 261 const SymbolKeyedMethodConfiguration&) = delete;
258 DISALLOW_NEW(); 262 DISALLOW_NEW();
259 v8::Local<v8::Name> methodName(v8::Isolate* isolate) const { 263 v8::Local<v8::Name> methodName(v8::Isolate* isolate) const {
260 return getSymbol(isolate); 264 return getSymbol(isolate);
261 } 265 }
262 v8::FunctionCallback callbackForWorld(const DOMWrapperWorld&) const { 266 v8::FunctionCallback callbackForWorld(const DOMWrapperWorld&) const {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 // Sets the class string of platform objects, interface prototype objects, 328 // Sets the class string of platform objects, interface prototype objects,
325 // etc. See also http://heycam.github.io/webidl/#dfn-class-string 329 // etc. See also http://heycam.github.io/webidl/#dfn-class-string
326 static void setClassString(v8::Isolate*, 330 static void setClassString(v8::Isolate*,
327 v8::Local<v8::ObjectTemplate>, 331 v8::Local<v8::ObjectTemplate>,
328 const char* classString); 332 const char* classString);
329 }; 333 };
330 334
331 } // namespace blink 335 } // namespace blink
332 336
333 #endif // V8DOMConfiguration_h 337 #endif // V8DOMConfiguration_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698