OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 | 66 |
67 namespace WebCore { | 67 namespace WebCore { |
68 const WrapperTypeInfo V8TestSpecialOperationsAnonymous::wrapperTypeInfo = { gin:
:kEmbedderBlink, V8TestSpecialOperationsAnonymous::domTemplate, V8TestSpecialOpe
rationsAnonymous::derefObject, 0, 0, 0, V8TestSpecialOperationsAnonymous::instal
lPerContextEnabledMethods, 0, WrapperTypeObjectPrototype, false }; | 68 const WrapperTypeInfo V8TestSpecialOperationsAnonymous::wrapperTypeInfo = { gin:
:kEmbedderBlink, V8TestSpecialOperationsAnonymous::domTemplate, V8TestSpecialOpe
rationsAnonymous::derefObject, 0, 0, 0, V8TestSpecialOperationsAnonymous::instal
lPerContextEnabledMethods, 0, WrapperTypeObjectPrototype, false }; |
69 | 69 |
70 namespace TestSpecialOperationsAnonymousV8Internal { | 70 namespace TestSpecialOperationsAnonymousV8Internal { |
71 | 71 |
72 template <typename T> void V8_USE(T) { } | 72 template <typename T> void V8_USE(T) { } |
73 | 73 |
74 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo
<v8::Value>& info) | 74 static void indexedPropertyGetter(uint32_t index, const v8::PropertyCallbackInfo
<v8::Value>& info) |
75 { | 75 { |
76 TestSpecialOperationsAnonymous* collection = V8TestSpecialOperationsAnonymou
s::toNative(info.Holder()); | 76 TestSpecialOperationsAnonymous* imp = V8TestSpecialOperationsAnonymous::toNa
tive(info.Holder()); |
77 String element = collection->anonymousIndexedGetter(index); | 77 String result = imp->anonymousIndexedGetter(index); |
78 if (element.isNull()) | 78 if (result.isNull()) |
79 return; | 79 return; |
80 v8SetReturnValueString(info, element, info.GetIsolate()); | 80 v8SetReturnValueString(info, result, info.GetIsolate()); |
81 } | 81 } |
82 | 82 |
83 static void indexedPropertyGetterCallback(uint32_t index, const v8::PropertyCall
backInfo<v8::Value>& info) | 83 static void indexedPropertyGetterCallback(uint32_t index, const v8::PropertyCall
backInfo<v8::Value>& info) |
84 { | 84 { |
85 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty"); | 85 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty"); |
86 TestSpecialOperationsAnonymousV8Internal::indexedPropertyGetter(index, info)
; | 86 TestSpecialOperationsAnonymousV8Internal::indexedPropertyGetter(index, info)
; |
87 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | 87 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
88 } | 88 } |
89 | 89 |
90 static void indexedPropertySetter(uint32_t index, v8::Local<v8::Value> jsValue,
const v8::PropertyCallbackInfo<v8::Value>& info) | 90 static void indexedPropertySetter(uint32_t index, v8::Local<v8::Value> jsValue,
const v8::PropertyCallbackInfo<v8::Value>& info) |
91 { | 91 { |
92 TestSpecialOperationsAnonymous* collection = V8TestSpecialOperationsAnonymou
s::toNative(info.Holder()); | 92 TestSpecialOperationsAnonymous* imp = V8TestSpecialOperationsAnonymous::toNa
tive(info.Holder()); |
93 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, propertyValue, jsVa
lue); | 93 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, propertyValue, jsVa
lue); |
94 bool result = collection->anonymousIndexedSetter(index, propertyValue); | 94 bool result = imp->anonymousIndexedSetter(index, propertyValue); |
95 if (!result) | 95 if (!result) |
96 return; | 96 return; |
97 v8SetReturnValue(info, jsValue); | 97 v8SetReturnValue(info, jsValue); |
98 } | 98 } |
99 | 99 |
100 static void indexedPropertySetterCallback(uint32_t index, v8::Local<v8::Value> j
sValue, const v8::PropertyCallbackInfo<v8::Value>& info) | 100 static void indexedPropertySetterCallback(uint32_t index, v8::Local<v8::Value> j
sValue, const v8::PropertyCallbackInfo<v8::Value>& info) |
101 { | 101 { |
102 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty"); | 102 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty"); |
103 TestSpecialOperationsAnonymousV8Internal::indexedPropertySetter(index, jsVal
ue, info); | 103 TestSpecialOperationsAnonymousV8Internal::indexedPropertySetter(index, jsVal
ue, info); |
104 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | 104 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
105 } | 105 } |
106 | 106 |
107 static void indexedPropertyDeleter(uint32_t index, const v8::PropertyCallbackInf
o<v8::Boolean>& info) | 107 static void indexedPropertyDeleter(uint32_t index, const v8::PropertyCallbackInf
o<v8::Boolean>& info) |
108 { | 108 { |
109 TestSpecialOperationsAnonymous* collection = V8TestSpecialOperationsAnonymou
s::toNative(info.Holder()); | 109 TestSpecialOperationsAnonymous* imp = V8TestSpecialOperationsAnonymous::toNa
tive(info.Holder()); |
110 DeleteResult result = collection->anonymousIndexedDeleter(index); | 110 DeleteResult result = imp->anonymousIndexedDeleter(index); |
111 if (result != DeleteUnknownProperty) | 111 if (result != DeleteUnknownProperty) |
112 return v8SetReturnValueBool(info, result == DeleteSuccess); | 112 return v8SetReturnValueBool(info, result == DeleteSuccess); |
113 } | 113 } |
114 | 114 |
115 static void indexedPropertyDeleterCallback(uint32_t index, const v8::PropertyCal
lbackInfo<v8::Boolean>& info) | 115 static void indexedPropertyDeleterCallback(uint32_t index, const v8::PropertyCal
lbackInfo<v8::Boolean>& info) |
116 { | 116 { |
117 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty"); | 117 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMIndexedProperty"); |
118 TestSpecialOperationsAnonymousV8Internal::indexedPropertyDeleter(index, info
); | 118 TestSpecialOperationsAnonymousV8Internal::indexedPropertyDeleter(index, info
); |
119 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | 119 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
120 } | 120 } |
121 | 121 |
122 static void namedPropertyGetter(v8::Local<v8::String> name, const v8::PropertyCa
llbackInfo<v8::Value>& info) | 122 static void namedPropertyGetter(v8::Local<v8::String> name, const v8::PropertyCa
llbackInfo<v8::Value>& info) |
123 { | 123 { |
124 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty()) | 124 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty()) |
125 return; | 125 return; |
126 if (info.Holder()->HasRealNamedCallbackProperty(name)) | 126 if (info.Holder()->HasRealNamedCallbackProperty(name)) |
127 return; | 127 return; |
128 if (info.Holder()->HasRealNamedProperty(name)) | 128 if (info.Holder()->HasRealNamedProperty(name)) |
129 return; | 129 return; |
130 | 130 |
131 TestSpecialOperationsAnonymous* collection = V8TestSpecialOperationsAnonymou
s::toNative(info.Holder()); | 131 TestSpecialOperationsAnonymous* imp = V8TestSpecialOperationsAnonymous::toNa
tive(info.Holder()); |
132 AtomicString propertyName = toCoreAtomicString(name); | 132 AtomicString propertyName = toCoreAtomicString(name); |
133 String element = collection->anonymousNamedGetter(propertyName); | 133 String result = imp->anonymousNamedGetter(propertyName); |
134 if (element.isNull()) | 134 if (result.isNull()) |
135 return; | 135 return; |
136 v8SetReturnValueString(info, element, info.GetIsolate()); | 136 v8SetReturnValueString(info, result, info.GetIsolate()); |
137 } | 137 } |
138 | 138 |
139 static void namedPropertyGetterCallback(v8::Local<v8::String> name, const v8::Pr
opertyCallbackInfo<v8::Value>& info) | 139 static void namedPropertyGetterCallback(v8::Local<v8::String> name, const v8::Pr
opertyCallbackInfo<v8::Value>& info) |
140 { | 140 { |
141 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); | 141 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); |
142 TestSpecialOperationsAnonymousV8Internal::namedPropertyGetter(name, info); | 142 TestSpecialOperationsAnonymousV8Internal::namedPropertyGetter(name, info); |
143 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | 143 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
144 } | 144 } |
145 | 145 |
146 static void namedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value>
jsValue, const v8::PropertyCallbackInfo<v8::Value>& info) | 146 static void namedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value>
jsValue, const v8::PropertyCallbackInfo<v8::Value>& info) |
147 { | 147 { |
148 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty()) | 148 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty()) |
149 return; | 149 return; |
150 if (info.Holder()->HasRealNamedCallbackProperty(name)) | 150 if (info.Holder()->HasRealNamedCallbackProperty(name)) |
151 return; | 151 return; |
152 if (info.Holder()->HasRealNamedProperty(name)) | 152 if (info.Holder()->HasRealNamedProperty(name)) |
153 return; | 153 return; |
154 | 154 |
155 TestSpecialOperationsAnonymous* collection = V8TestSpecialOperationsAnonymou
s::toNative(info.Holder()); | 155 TestSpecialOperationsAnonymous* imp = V8TestSpecialOperationsAnonymous::toNa
tive(info.Holder()); |
156 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, propertyName, name)
; | 156 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, propertyName, name)
; |
157 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, propertyValue, jsVa
lue); | 157 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, propertyValue, jsVa
lue); |
158 bool result = collection->anonymousNamedSetter(propertyName, propertyValue); | 158 bool result = imp->anonymousNamedSetter(propertyName, propertyValue); |
159 if (!result) | 159 if (!result) |
160 return; | 160 return; |
161 v8SetReturnValue(info, jsValue); | 161 v8SetReturnValue(info, jsValue); |
162 } | 162 } |
163 | 163 |
164 static void namedPropertySetterCallback(v8::Local<v8::String> name, v8::Local<v8
::Value> jsValue, const v8::PropertyCallbackInfo<v8::Value>& info) | 164 static void namedPropertySetterCallback(v8::Local<v8::String> name, v8::Local<v8
::Value> jsValue, const v8::PropertyCallbackInfo<v8::Value>& info) |
165 { | 165 { |
166 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); | 166 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); |
167 TestSpecialOperationsAnonymousV8Internal::namedPropertySetter(name, jsValue,
info); | 167 TestSpecialOperationsAnonymousV8Internal::namedPropertySetter(name, jsValue,
info); |
168 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | 168 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
169 } | 169 } |
170 | 170 |
171 static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCal
lbackInfo<v8::Integer>& info) | 171 static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCal
lbackInfo<v8::Integer>& info) |
172 { | 172 { |
173 TestSpecialOperationsAnonymous* collection = V8TestSpecialOperationsAnonymou
s::toNative(info.Holder()); | 173 TestSpecialOperationsAnonymous* imp = V8TestSpecialOperationsAnonymous::toNa
tive(info.Holder()); |
174 AtomicString propertyName = toCoreAtomicString(name); | 174 AtomicString propertyName = toCoreAtomicString(name); |
175 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); | 175 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); |
176 bool result = collection->namedPropertyQuery(propertyName, exceptionState); | 176 bool result = imp->namedPropertyQuery(propertyName, exceptionState); |
177 if (exceptionState.throwIfNeeded()) | 177 if (exceptionState.throwIfNeeded()) |
178 return; | 178 return; |
179 if (!result) | 179 if (!result) |
180 return; | 180 return; |
181 v8SetReturnValueInt(info, v8::None); | 181 v8SetReturnValueInt(info, v8::None); |
182 } | 182 } |
183 | 183 |
184 static void namedPropertyQueryCallback(v8::Local<v8::String> name, const v8::Pro
pertyCallbackInfo<v8::Integer>& info) | 184 static void namedPropertyQueryCallback(v8::Local<v8::String> name, const v8::Pro
pertyCallbackInfo<v8::Integer>& info) |
185 { | 185 { |
186 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); | 186 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); |
187 TestSpecialOperationsAnonymousV8Internal::namedPropertyQuery(name, info); | 187 TestSpecialOperationsAnonymousV8Internal::namedPropertyQuery(name, info); |
188 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | 188 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
189 } | 189 } |
190 | 190 |
191 static void namedPropertyDeleter(v8::Local<v8::String> name, const v8::PropertyC
allbackInfo<v8::Boolean>& info) | 191 static void namedPropertyDeleter(v8::Local<v8::String> name, const v8::PropertyC
allbackInfo<v8::Boolean>& info) |
192 { | 192 { |
193 TestSpecialOperationsAnonymous* collection = V8TestSpecialOperationsAnonymou
s::toNative(info.Holder()); | 193 TestSpecialOperationsAnonymous* imp = V8TestSpecialOperationsAnonymous::toNa
tive(info.Holder()); |
194 AtomicString propertyName = toCoreAtomicString(name); | 194 AtomicString propertyName = toCoreAtomicString(name); |
195 DeleteResult result = collection->anonymousNamedDeleter(propertyName); | 195 DeleteResult result = imp->anonymousNamedDeleter(propertyName); |
196 if (result != DeleteUnknownProperty) | 196 if (result != DeleteUnknownProperty) |
197 return v8SetReturnValueBool(info, result == DeleteSuccess); | 197 return v8SetReturnValueBool(info, result == DeleteSuccess); |
198 } | 198 } |
199 | 199 |
200 static void namedPropertyDeleterCallback(v8::Local<v8::String> name, const v8::P
ropertyCallbackInfo<v8::Boolean>& info) | 200 static void namedPropertyDeleterCallback(v8::Local<v8::String> name, const v8::P
ropertyCallbackInfo<v8::Boolean>& info) |
201 { | 201 { |
202 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); | 202 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); |
203 TestSpecialOperationsAnonymousV8Internal::namedPropertyDeleter(name, info); | 203 TestSpecialOperationsAnonymousV8Internal::namedPropertyDeleter(name, info); |
204 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); | 204 TRACE_EVENT_SET_SAMPLING_STATE("V8", "V8Execution"); |
205 } | 205 } |
206 | 206 |
207 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& i
nfo) | 207 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& i
nfo) |
208 { | 208 { |
209 TestSpecialOperationsAnonymous* collection = V8TestSpecialOperationsAnonymou
s::toNative(info.Holder()); | 209 TestSpecialOperationsAnonymous* imp = V8TestSpecialOperationsAnonymous::toNa
tive(info.Holder()); |
210 Vector<String> names; | 210 Vector<String> names; |
211 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); | 211 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); |
212 collection->namedPropertyEnumerator(names, exceptionState); | 212 imp->namedPropertyEnumerator(names, exceptionState); |
213 if (exceptionState.throwIfNeeded()) | 213 if (exceptionState.throwIfNeeded()) |
214 return; | 214 return; |
215 v8::Handle<v8::Array> v8names = v8::Array::New(info.GetIsolate(), names.size
()); | 215 v8::Handle<v8::Array> v8names = v8::Array::New(info.GetIsolate(), names.size
()); |
216 for (size_t i = 0; i < names.size(); ++i) | 216 for (size_t i = 0; i < names.size(); ++i) |
217 v8names->Set(v8::Integer::New(info.GetIsolate(), i), v8String(info.GetIs
olate(), names[i])); | 217 v8names->Set(v8::Integer::New(info.GetIsolate(), i), v8String(info.GetIs
olate(), names[i])); |
218 v8SetReturnValue(info, v8names); | 218 v8SetReturnValue(info, v8names); |
219 } | 219 } |
220 | 220 |
221 static void namedPropertyEnumeratorCallback(const v8::PropertyCallbackInfo<v8::A
rray>& info) | 221 static void namedPropertyEnumeratorCallback(const v8::PropertyCallbackInfo<v8::A
rray>& info) |
222 { | 222 { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 fromInternalPointer(object)->deref(); | 292 fromInternalPointer(object)->deref(); |
293 } | 293 } |
294 | 294 |
295 template<> | 295 template<> |
296 v8::Handle<v8::Value> toV8NoInline(TestSpecialOperationsAnonymous* impl, v8::Han
dle<v8::Object> creationContext, v8::Isolate* isolate) | 296 v8::Handle<v8::Value> toV8NoInline(TestSpecialOperationsAnonymous* impl, v8::Han
dle<v8::Object> creationContext, v8::Isolate* isolate) |
297 { | 297 { |
298 return toV8(impl, creationContext, isolate); | 298 return toV8(impl, creationContext, isolate); |
299 } | 299 } |
300 | 300 |
301 } // namespace WebCore | 301 } // namespace WebCore |
OLD | NEW |