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

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

Issue 2335203006: Add [CachedAccessor] attribute to cache (almost) constant accessors (window.document). (Closed)
Patch Set: Fix rebase dirt Created 4 years, 2 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 OnInstance = 1 << 0, 55 OnInstance = 1 << 0,
56 OnPrototype = 1 << 1, 56 OnPrototype = 1 << 1,
57 OnInterface = 1 << 2, 57 OnInterface = 1 << 2,
58 }; 58 };
59 59
60 enum HolderCheckConfiguration { 60 enum HolderCheckConfiguration {
61 CheckHolder, 61 CheckHolder,
62 DoNotCheckHolder, 62 DoNotCheckHolder,
63 }; 63 };
64 64
65 typedef v8::experimental::FastAccessorBuilder* (*FastAccessorBuilderCallback )(v8::Isolate*,
66 v8::FunctionCallback); // Default (slow) callback.
67
68 typedef v8::Local<v8::Private> (*CachedAccessorCallback)(v8::Isolate*);
69
65 // AttributeConfiguration translates into calls to SetNativeDataProperty() o n either 70 // AttributeConfiguration translates into calls to SetNativeDataProperty() o n either
66 // the instance or the prototype ObjectTemplate, based on |instanceOrPrototy peConfiguration|. 71 // the instance or the prototype ObjectTemplate, based on |instanceOrPrototy peConfiguration|.
67 struct AttributeConfiguration { 72 struct AttributeConfiguration {
68 AttributeConfiguration& operator=(const AttributeConfiguration&) = delet e; 73 AttributeConfiguration& operator=(const AttributeConfiguration&) = delet e;
69 DISALLOW_NEW(); 74 DISALLOW_NEW();
70 const char* const name; 75 const char* const name;
71 v8::AccessorNameGetterCallback getter; 76 v8::AccessorNameGetterCallback getter;
72 v8::AccessorNameSetterCallback setter; 77 v8::AccessorNameSetterCallback setter;
73 v8::AccessorNameGetterCallback getterForMainWorld; 78 v8::AccessorNameGetterCallback getterForMainWorld;
74 v8::AccessorNameSetterCallback setterForMainWorld; 79 v8::AccessorNameSetterCallback setterForMainWorld;
80 // TODO(peterssen|vogelheim): This has to be removed too since it's only used in accessors.
81 CachedAccessorCallback cachedAccessorCallback; // The accessor's 'result ' is stored in a private property.
75 const WrapperTypeInfo* data; 82 const WrapperTypeInfo* data;
76 unsigned settings : 8; // v8::AccessControl 83 unsigned settings : 8; // v8::AccessControl
77 unsigned attribute : 8; // v8::PropertyAttribute 84 unsigned attribute : 8; // v8::PropertyAttribute
78 unsigned exposeConfiguration : 1; // ExposeConfiguration 85 unsigned exposeConfiguration : 1; // ExposeConfiguration
79 unsigned propertyLocationConfiguration : 3; // PropertyLocationConfigura tion 86 unsigned propertyLocationConfiguration : 3; // PropertyLocationConfigura tion
80 unsigned holderCheckConfiguration : 1; // HolderCheckConfiguration 87 unsigned holderCheckConfiguration : 1; // HolderCheckConfiguration
81 }; 88 };
82 89
83 static void installAttributes(v8::Isolate*, const DOMWrapperWorld&, v8::Loca l<v8::ObjectTemplate> instanceTemplate, v8::Local<v8::ObjectTemplate> prototypeT emplate, const AttributeConfiguration*, size_t attributeCount); 90 static void installAttributes(v8::Isolate*, const DOMWrapperWorld&, v8::Loca l<v8::ObjectTemplate> instanceTemplate, v8::Local<v8::ObjectTemplate> prototypeT emplate, const AttributeConfiguration*, size_t attributeCount);
84 91
85 static void installAttribute(v8::Isolate*, const DOMWrapperWorld&, v8::Local <v8::ObjectTemplate> instanceTemplate, v8::Local<v8::ObjectTemplate> prototypeTe mplate, const AttributeConfiguration&); 92 static void installAttribute(v8::Isolate*, const DOMWrapperWorld&, v8::Local <v8::ObjectTemplate> instanceTemplate, v8::Local<v8::ObjectTemplate> prototypeTe mplate, const AttributeConfiguration&);
86 93
87 static void installAttribute(v8::Isolate*, const DOMWrapperWorld&, v8::Local <v8::Object> instance, v8::Local<v8::Object> prototype, const AttributeConfigura tion&); 94 static void installAttribute(v8::Isolate*, const DOMWrapperWorld&, v8::Local <v8::Object> instance, v8::Local<v8::Object> prototype, const AttributeConfigura tion&);
88 95
89 // AccessorConfiguration translates into calls to SetAccessorProperty() 96 // AccessorConfiguration translates into calls to SetAccessorProperty()
90 // on prototype ObjectTemplate. 97 // on prototype ObjectTemplate.
91 struct AccessorConfiguration { 98 struct AccessorConfiguration {
92 AccessorConfiguration& operator=(const AccessorConfiguration&) = delete; 99 AccessorConfiguration& operator=(const AccessorConfiguration&) = delete;
93 DISALLOW_NEW(); 100 DISALLOW_NEW();
94 const char* const name; 101 const char* const name;
95 v8::FunctionCallback getter; 102 v8::FunctionCallback getter;
96 v8::FunctionCallback setter; 103 v8::FunctionCallback setter;
97 v8::FunctionCallback getterForMainWorld; 104 v8::FunctionCallback getterForMainWorld;
98 v8::FunctionCallback setterForMainWorld; 105 v8::FunctionCallback setterForMainWorld;
106 CachedAccessorCallback cachedAccessorCallback; // The accessor's 'result ' is stored in a private property.
99 const WrapperTypeInfo* data; 107 const WrapperTypeInfo* data;
100 unsigned settings : 8; // v8::AccessControl 108 unsigned settings : 8; // v8::AccessControl
101 unsigned attribute : 8; // v8::PropertyAttribute 109 unsigned attribute : 8; // v8::PropertyAttribute
102 unsigned exposeConfiguration : 1; // ExposeConfiguration 110 unsigned exposeConfiguration : 1; // ExposeConfiguration
103 unsigned propertyLocationConfiguration : 3; // PropertyLocationConfigura tion 111 unsigned propertyLocationConfiguration : 3; // PropertyLocationConfigura tion
104 unsigned holderCheckConfiguration : 1; // HolderCheckConfiguration 112 unsigned holderCheckConfiguration : 1; // HolderCheckConfiguration
105 }; 113 };
106 114
107 static void installAccessors(v8::Isolate*, const DOMWrapperWorld&, v8::Local <v8::ObjectTemplate> instanceTemplate, v8::Local<v8::ObjectTemplate> prototypeTe mplate, v8::Local<v8::FunctionTemplate> interfaceTemplate, v8::Local<v8::Signatu re>, const AccessorConfiguration*, size_t accessorCount); 115 static void installAccessors(v8::Isolate*, const DOMWrapperWorld&, v8::Local <v8::ObjectTemplate> instanceTemplate, v8::Local<v8::ObjectTemplate> prototypeTe mplate, v8::Local<v8::FunctionTemplate> interfaceTemplate, v8::Local<v8::Signatu re>, const AccessorConfiguration*, size_t accessorCount);
108 116
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 static v8::Local<v8::FunctionTemplate> domClassTemplate(v8::Isolate*, const DOMWrapperWorld&, WrapperTypeInfo*, InstallTemplateFunction); 207 static v8::Local<v8::FunctionTemplate> domClassTemplate(v8::Isolate*, const DOMWrapperWorld&, WrapperTypeInfo*, InstallTemplateFunction);
200 208
201 // Sets the class string of platform objects, interface prototype objects, e tc. 209 // Sets the class string of platform objects, interface prototype objects, e tc.
202 // See also http://heycam.github.io/webidl/#dfn-class-string 210 // See also http://heycam.github.io/webidl/#dfn-class-string
203 static void setClassString(v8::Isolate*, v8::Local<v8::ObjectTemplate>, cons t char* classString); 211 static void setClassString(v8::Isolate*, v8::Local<v8::ObjectTemplate>, cons t char* classString);
204 }; 212 };
205 213
206 } // namespace blink 214 } // namespace blink
207 215
208 #endif // V8DOMConfiguration_h 216 #endif // V8DOMConfiguration_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698