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