1/* 2 * Copyright (C) 2013 Google Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google Inc. nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31// This file has been auto-generated by code_generator_v8.pm. DO NOT MODIFY! 32 33#include "config.h" 34#if ENABLE(Condition1) || ENABLE(Condition2) 35#include "V8TestInterface.h" 36 37#include "RuntimeEnabledFeatures.h" 38#include "V8Node.h" 39#include "V8NodeList.h" 40#include "V8ReferencedType.h" 41#include "V8TestObject.h" 42#include "bindings/tests/idls/TestImplements.h" 43#include "bindings/tests/idls/TestPartialInterface.h" 44#include "bindings/v8/ExceptionState.h" 45#include "bindings/v8/V8AbstractEventListener.h" 46#include "bindings/v8/V8DOMConfiguration.h" 47#include "bindings/v8/V8EventListenerList.h" 48#include "bindings/v8/V8ObjectConstructor.h" 49#include "core/dom/ContextFeatures.h" 50#include "core/dom/Document.h" 51#include "platform/TraceEvent.h" 52#include "wtf/GetPtr.h" 53#include "wtf/RefPtr.h" 54 55namespace WebCore { 56 57static void initializeScriptWrappableForInterface(TestInterface* object) 58{ 59 if (ScriptWrappable::wrapperCanBeStoredInObject(object)) 60 ScriptWrappable::setTypeInfoInObject(object, &V8TestInterface::wrapperTypeInfo); 61 else 62 ASSERT_NOT_REACHED(); 63} 64 65} // namespace WebCore 66 67// In ScriptWrappable::init, the use of a local function declaration has an issue on Windows: 68// the local declaration does not pick up the surrounding namespace. Therefore, we provide this function 69// in the global namespace. 70// (More info on the MSVC bug here: http://connect.microsoft.com/VisualStudio/feedback/details/664619/the-namespace-of-local-function-declarations-in-c) 71void webCoreInitializeScriptWrappableForInterface(WebCore::TestInterface* object) 72{ 73 WebCore::initializeScriptWrappableForInterface(object); 74} 75 76namespace WebCore { 77const WrapperTypeInfo V8TestInterface::wrapperTypeInfo = { gin::kEmbedderBlink, V8TestInterface::domTemplate, V8TestInterface::derefObject, V8TestInterface::toActiveDOMObject, 0, V8TestInterface::visitDOMWrapper, V8TestInterface::installPerContextEnabledMethods, 0, WrapperTypeObjectPrototype }; 78 79namespace TestInterfaceV8Internal { 80 81template <typename T> void V8_USE(T) { } 82 83static void implementsStaticReadOnlyAttrAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 84{ 85 v8SetReturnValueInt(info, TestImplements::implementsStaticReadOnlyAttr()); 86} 87 88static void implementsStaticReadOnlyAttrAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 89{ 90 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 91 TestInterfaceV8Internal::implementsStaticReadOnlyAttrAttributeGetter(info); 92 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 93} 94 95static void implementsStaticAttrAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 96{ 97 v8SetReturnValueString(info, TestImplements::implementsStaticAttr(), info.GetIsolate()); 98} 99 100static void implementsStaticAttrAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 101{ 102 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 103 TestInterfaceV8Internal::implementsStaticAttrAttributeGetter(info); 104 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 105} 106 107static void implementsStaticAttrAttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 108{ 109 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, cppValue, jsValue); 110 TestImplements::setImplementsStaticAttr(cppValue); 111} 112 113static void implementsStaticAttrAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 114{ 115 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 116 TestInterfaceV8Internal::implementsStaticAttrAttributeSetter(jsValue, info); 117 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 118} 119 120static void implementsStr1AttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 121{ 122 TestInterface* imp = V8TestInterface::toNative(info.Holder()); 123 v8SetReturnValueString(info, TestImplements::implementsStr1(imp), info.GetIsolate()); 124} 125 126static void implementsStr1AttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 127{ 128 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 129 TestInterfaceV8Internal::implementsStr1AttributeGetter(info); 130 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 131} 132 133static void implementsStr2AttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 134{ 135 TestInterface* imp = V8TestInterface::toNative(info.Holder()); 136 v8SetReturnValueString(info, TestImplements::implementsStr2(imp), info.GetIsolate()); 137} 138 139static void implementsStr2AttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 140{ 141 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 142 TestInterfaceV8Internal::implementsStr2AttributeGetter(info); 143 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 144} 145 146static void implementsStr2AttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 147{ 148 TestInterface* imp = V8TestInterface::toNative(info.Holder()); 149 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, cppValue, jsValue); 150 TestImplements::setImplementsStr2(imp, cppValue); 151} 152 153static void implementsStr2AttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 154{ 155 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 156 TestInterfaceV8Internal::implementsStr2AttributeSetter(jsValue, info); 157 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 158} 159 160static void implementsStr3AttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 161{ 162 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 163 V8TestInterface::implementsStr3AttributeGetterCustom(info); 164 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 165} 166 167static void implementsStr3AttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 168{ 169 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 170 V8TestInterface::implementsStr3AttributeSetterCustom(jsValue, info); 171 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 172} 173 174static void implementsNodeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 175{ 176 TestInterface* imp = V8TestInterface::toNative(info.Holder()); 177 v8SetReturnValueFast(info, TestImplements::implementsNode(imp), imp); 178} 179 180static void implementsNodeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 181{ 182 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 183 TestInterfaceV8Internal::implementsNodeAttributeGetter(info); 184 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 185} 186 187static void implementsNodeAttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 188{ 189 TestInterface* imp = V8TestInterface::toNative(info.Holder()); 190 V8TRYCATCH_VOID(Node*, cppValue, V8Node::hasInstance(jsValue, info.GetIsolate(), worldType(info.GetIsolate())) ? V8Node::toNative(v8::Handle<v8::Object>::Cast(jsValue)) : 0); 191 TestImplements::setImplementsNode(imp, WTF::getPtr(cppValue)); 192} 193 194static void implementsNodeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 195{ 196 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 197 TestInterfaceV8Internal::implementsNodeAttributeSetter(jsValue, info); 198 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 199} 200 201static void eventHandlerAttributeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 202{ 203 TestInterface* imp = V8TestInterface::toNative(info.Holder()); 204 EventListener* jsValue = TestImplements::eventHandlerAttribute(imp, isolatedWorldForIsolate(info.GetIsolate())); 205 v8SetReturnValue(info, jsValue ? v8::Handle<v8::Value>(V8AbstractEventListener::cast(jsValue)->getListenerObject(imp->executionContext())) : v8::Handle<v8::Value>(v8::Null(info.GetIsolate()))); 206} 207 208static void eventHandlerAttributeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 209{ 210 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 211 TestInterfaceV8Internal::eventHandlerAttributeAttributeGetter(info); 212 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 213} 214 215static void eventHandlerAttributeAttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 216{ 217 TestInterface* imp = V8TestInterface::toNative(info.Holder()); 218 transferHiddenDependency(info.Holder(), TestImplements::eventHandlerAttribute(imp, isolatedWorldForIsolate(info.GetIsolate())), jsValue, V8TestInterface::eventListenerCacheIndex, info.GetIsolate()); 219 TestImplements::setEventHandlerAttribute(imp, V8EventListenerList::getEventListener(jsValue, true, ListenerFindOrCreate), isolatedWorldForIsolate(info.GetIsolate())); 220} 221 222static void eventHandlerAttributeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 223{ 224 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 225 TestInterfaceV8Internal::eventHandlerAttributeAttributeSetter(jsValue, info); 226 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 227} 228 229static void Node23AttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 230{ 231 TestInterface* imp = V8TestInterface::toNative(info.Holder()); 232 v8SetReturnValueFast(info, TestImplements::node23(imp), imp); 233} 234 235static void Node23AttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 236{ 237 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 238 TestInterfaceV8Internal::Node23AttributeGetter(info); 239 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 240} 241 242static void Node23AttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 243{ 244 TestInterface* imp = V8TestInterface::toNative(info.Holder()); 245 V8TRYCATCH_VOID(Node*, cppValue, V8Node::hasInstance(jsValue, info.GetIsolate(), worldType(info.GetIsolate())) ? V8Node::toNative(v8::Handle<v8::Object>::Cast(jsValue)) : 0); 246 TestImplements::setNode23(imp, WTF::getPtr(cppValue)); 247} 248 249static void Node23AttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 250{ 251 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 252 TestInterfaceV8Internal::Node23AttributeSetter(jsValue, info); 253 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 254} 255 256static void Node24AttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 257{ 258 TestInterface* imp = V8TestInterface::toNative(info.Holder()); 259 v8SetReturnValueFast(info, TestImplements::node24(imp), imp); 260} 261 262static void Node24AttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 263{ 264 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 265 TestInterfaceV8Internal::Node24AttributeGetter(info); 266 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 267} 268 269static void Node24AttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 270{ 271 TestInterface* imp = V8TestInterface::toNative(info.Holder()); 272 V8TRYCATCH_VOID(Node*, cppValue, V8Node::hasInstance(jsValue, info.GetIsolate(), worldType(info.GetIsolate())) ? V8Node::toNative(v8::Handle<v8::Object>::Cast(jsValue)) : 0); 273 TestImplements::setNode24(imp, WTF::getPtr(cppValue)); 274} 275 276static void Node24AttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 277{ 278 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 279 TestInterfaceV8Internal::Node24AttributeSetter(jsValue, info); 280 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 281} 282 283#if ENABLE(Condition11) || ENABLE(Condition12) 284static void supplementalStaticReadOnlyAttrAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 285{ 286 v8SetReturnValueInt(info, TestPartialInterface::supplementalStaticReadOnlyAttr()); 287} 288#endif // ENABLE(Condition11) || ENABLE(Condition12) 289 290#if ENABLE(Condition11) || ENABLE(Condition12) 291static void supplementalStaticReadOnlyAttrAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 292{ 293 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 294 TestInterfaceV8Internal::supplementalStaticReadOnlyAttrAttributeGetter(info); 295 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 296} 297#endif // ENABLE(Condition11) || ENABLE(Condition12) 298 299#if ENABLE(Condition11) || ENABLE(Condition12) 300static void supplementalStaticAttrAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 301{ 302 v8SetReturnValueString(info, TestPartialInterface::supplementalStaticAttr(), info.GetIsolate()); 303} 304#endif // ENABLE(Condition11) || ENABLE(Condition12) 305 306#if ENABLE(Condition11) || ENABLE(Condition12) 307static void supplementalStaticAttrAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 308{ 309 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 310 TestInterfaceV8Internal::supplementalStaticAttrAttributeGetter(info); 311 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 312} 313#endif // ENABLE(Condition11) || ENABLE(Condition12) 314 315#if ENABLE(Condition11) || ENABLE(Condition12) 316static void supplementalStaticAttrAttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 317{ 318 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, cppValue, jsValue); 319 TestPartialInterface::setSupplementalStaticAttr(cppValue); 320} 321#endif // ENABLE(Condition11) || ENABLE(Condition12) 322 323#if ENABLE(Condition11) || ENABLE(Condition12) 324static void supplementalStaticAttrAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 325{ 326 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 327 TestInterfaceV8Internal::supplementalStaticAttrAttributeSetter(jsValue, info); 328 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 329} 330#endif // ENABLE(Condition11) || ENABLE(Condition12) 331 332#if ENABLE(Condition11) || ENABLE(Condition12) 333static void supplementalStr1AttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 334{ 335 TestInterface* imp = V8TestInterface::toNative(info.Holder()); 336 v8SetReturnValueString(info, TestPartialInterface::supplementalStr1(imp), info.GetIsolate()); 337} 338#endif // ENABLE(Condition11) || ENABLE(Condition12) 339 340#if ENABLE(Condition11) || ENABLE(Condition12) 341static void supplementalStr1AttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 342{ 343 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 344 TestInterfaceV8Internal::supplementalStr1AttributeGetter(info); 345 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 346} 347#endif // ENABLE(Condition11) || ENABLE(Condition12) 348 349#if ENABLE(Condition11) || ENABLE(Condition12) 350static void supplementalStr2AttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 351{ 352 TestInterface* imp = V8TestInterface::toNative(info.Holder()); 353 v8SetReturnValueString(info, TestPartialInterface::supplementalStr2(imp), info.GetIsolate()); 354} 355#endif // ENABLE(Condition11) || ENABLE(Condition12) 356 357#if ENABLE(Condition11) || ENABLE(Condition12) 358static void supplementalStr2AttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 359{ 360 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 361 TestInterfaceV8Internal::supplementalStr2AttributeGetter(info); 362 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 363} 364#endif // ENABLE(Condition11) || ENABLE(Condition12) 365 366#if ENABLE(Condition11) || ENABLE(Condition12) 367static void supplementalStr2AttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 368{ 369 TestInterface* imp = V8TestInterface::toNative(info.Holder()); 370 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, cppValue, jsValue); 371 TestPartialInterface::setSupplementalStr2(imp, cppValue); 372} 373#endif // ENABLE(Condition11) || ENABLE(Condition12) 374 375#if ENABLE(Condition11) || ENABLE(Condition12) 376static void supplementalStr2AttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 377{ 378 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 379 TestInterfaceV8Internal::supplementalStr2AttributeSetter(jsValue, info); 380 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 381} 382#endif // ENABLE(Condition11) || ENABLE(Condition12) 383 384#if ENABLE(Condition11) || ENABLE(Condition12) 385static void supplementalStr3AttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 386{ 387 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 388 V8TestInterface::supplementalStr3AttributeGetterCustom(info); 389 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 390} 391#endif // ENABLE(Condition11) || ENABLE(Condition12) 392 393#if ENABLE(Condition11) || ENABLE(Condition12) 394static void supplementalStr3AttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 395{ 396 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 397 V8TestInterface::supplementalStr3AttributeSetterCustom(jsValue, info); 398 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 399} 400#endif // ENABLE(Condition11) || ENABLE(Condition12) 401 402#if ENABLE(Condition11) || ENABLE(Condition12) 403static void supplementalNodeAttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 404{ 405 TestInterface* imp = V8TestInterface::toNative(info.Holder()); 406 v8SetReturnValueFast(info, TestPartialInterface::supplementalNode(imp), imp); 407} 408#endif // ENABLE(Condition11) || ENABLE(Condition12) 409 410#if ENABLE(Condition11) || ENABLE(Condition12) 411static void supplementalNodeAttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 412{ 413 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 414 TestInterfaceV8Internal::supplementalNodeAttributeGetter(info); 415 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 416} 417#endif // ENABLE(Condition11) || ENABLE(Condition12) 418 419#if ENABLE(Condition11) || ENABLE(Condition12) 420static void supplementalNodeAttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 421{ 422 TestInterface* imp = V8TestInterface::toNative(info.Holder()); 423 V8TRYCATCH_VOID(Node*, cppValue, V8Node::hasInstance(jsValue, info.GetIsolate(), worldType(info.GetIsolate())) ? V8Node::toNative(v8::Handle<v8::Object>::Cast(jsValue)) : 0); 424 TestPartialInterface::setSupplementalNode(imp, WTF::getPtr(cppValue)); 425} 426#endif // ENABLE(Condition11) || ENABLE(Condition12) 427 428#if ENABLE(Condition11) || ENABLE(Condition12) 429static void supplementalNodeAttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 430{ 431 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 432 TestInterfaceV8Internal::supplementalNodeAttributeSetter(jsValue, info); 433 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 434} 435#endif // ENABLE(Condition11) || ENABLE(Condition12) 436 437#if ENABLE(Condition11) || ENABLE(Condition12) 438static void Node13AttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 439{ 440 TestInterface* imp = V8TestInterface::toNative(info.Holder()); 441 v8SetReturnValueFast(info, TestPartialInterface::node13(imp), imp); 442} 443#endif // ENABLE(Condition11) || ENABLE(Condition12) 444 445#if ENABLE(Condition11) || ENABLE(Condition12) 446static void Node13AttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 447{ 448 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 449 TestInterfaceV8Internal::Node13AttributeGetter(info); 450 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 451} 452#endif // ENABLE(Condition11) || ENABLE(Condition12) 453 454#if ENABLE(Condition11) || ENABLE(Condition12) 455static void Node13AttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 456{ 457 TestInterface* imp = V8TestInterface::toNative(info.Holder()); 458 V8TRYCATCH_VOID(Node*, cppValue, V8Node::hasInstance(jsValue, info.GetIsolate(), worldType(info.GetIsolate())) ? V8Node::toNative(v8::Handle<v8::Object>::Cast(jsValue)) : 0); 459 TestPartialInterface::setNode13(imp, WTF::getPtr(cppValue)); 460} 461#endif // ENABLE(Condition11) || ENABLE(Condition12) 462 463#if ENABLE(Condition11) || ENABLE(Condition12) 464static void Node13AttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 465{ 466 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 467 TestInterfaceV8Internal::Node13AttributeSetter(jsValue, info); 468 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 469} 470#endif // ENABLE(Condition11) || ENABLE(Condition12) 471 472#if ENABLE(Condition11) || ENABLE(Condition12) 473static void Node14AttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 474{ 475 TestInterface* imp = V8TestInterface::toNative(info.Holder()); 476 v8SetReturnValueFast(info, TestPartialInterface::node14(imp), imp); 477} 478#endif // ENABLE(Condition11) || ENABLE(Condition12) 479 480#if ENABLE(Condition11) || ENABLE(Condition12) 481static void Node14AttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 482{ 483 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 484 TestInterfaceV8Internal::Node14AttributeGetter(info); 485 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 486} 487#endif // ENABLE(Condition11) || ENABLE(Condition12) 488 489#if ENABLE(Condition11) || ENABLE(Condition12) 490static void Node14AttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 491{ 492 TestInterface* imp = V8TestInterface::toNative(info.Holder()); 493 V8TRYCATCH_VOID(Node*, cppValue, V8Node::hasInstance(jsValue, info.GetIsolate(), worldType(info.GetIsolate())) ? V8Node::toNative(v8::Handle<v8::Object>::Cast(jsValue)) : 0); 494 TestPartialInterface::setNode14(imp, WTF::getPtr(cppValue)); 495} 496#endif // ENABLE(Condition11) || ENABLE(Condition12) 497 498#if ENABLE(Condition11) || ENABLE(Condition12) 499static void Node14AttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 500{ 501 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 502 TestInterfaceV8Internal::Node14AttributeSetter(jsValue, info); 503 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 504} 505#endif // ENABLE(Condition11) || ENABLE(Condition12) 506 507#if ENABLE(Condition11) || ENABLE(Condition12) 508static void Node15AttributeGetter(const v8::PropertyCallbackInfo<v8::Value>& info) 509{ 510 TestInterface* imp = V8TestInterface::toNative(info.Holder()); 511 v8SetReturnValueFast(info, TestPartialInterface::node15(imp), imp); 512} 513#endif // ENABLE(Condition11) || ENABLE(Condition12) 514 515#if ENABLE(Condition11) || ENABLE(Condition12) 516static void Node15AttributeGetterCallback(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info) 517{ 518 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMGetter"); 519 TestInterfaceV8Internal::Node15AttributeGetter(info); 520 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 521} 522#endif // ENABLE(Condition11) || ENABLE(Condition12) 523 524#if ENABLE(Condition11) || ENABLE(Condition12) 525static void Node15AttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 526{ 527 TestInterface* imp = V8TestInterface::toNative(info.Holder()); 528 V8TRYCATCH_VOID(Node*, cppValue, V8Node::hasInstance(jsValue, info.GetIsolate(), worldType(info.GetIsolate())) ? V8Node::toNative(v8::Handle<v8::Object>::Cast(jsValue)) : 0); 529 TestPartialInterface::setNode15(imp, WTF::getPtr(cppValue)); 530} 531#endif // ENABLE(Condition11) || ENABLE(Condition12) 532 533#if ENABLE(Condition11) || ENABLE(Condition12) 534static void Node15AttributeSetterCallback(v8::Local<v8::String>, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 535{ 536 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMSetter"); 537 TestInterfaceV8Internal::Node15AttributeSetter(jsValue, info); 538 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 539} 540#endif // ENABLE(Condition11) || ENABLE(Condition12) 541 542static void implementsMethod1Method(const v8::FunctionCallbackInfo<v8::Value>& info) 543{ 544 TestInterface* imp = V8TestInterface::toNative(info.Holder()); 545 TestImplements::implementsMethod1(imp); 546} 547 548static void implementsMethod1MethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 549{ 550 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 551 TestInterfaceV8Internal::implementsMethod1Method(info); 552 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 553} 554 555static void implementsMethod2Method(const v8::FunctionCallbackInfo<v8::Value>& info) 556{ 557 ExceptionState exceptionState(ExceptionState::ExecutionContext, "implementsMethod2", "TestInterface", info.Holder(), info.GetIsolate()); 558 if (UNLIKELY(info.Length() < 2)) { 559 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, info.Length())); 560 exceptionState.throwIfNeeded(); 561 return; 562 } 563 TestInterface* imp = V8TestInterface::toNative(info.Holder()); 564 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, strArg, info[0]); 565 if (info.Length() <= 1 || !info[1]->IsFunction()) { 566 throwTypeError(ExceptionMessages::failedToExecute("implementsMethod2", "TestInterface", "The callback provided as parameter 2 is not a function."), info.GetIsolate()); 567 return; 568 } 569 OwnPtr<TestObject> objArg = V8TestObject::create(v8::Handle<v8::Function>::Cast(info[1]), getExecutionContext()); 570 ExecutionContext* scriptContext = getExecutionContext(); 571 RefPtr<TestObj> result = TestImplements::implementsMethod2(scriptContext, imp, strArg, objArg.release(), exceptionState); 572 if (exceptionState.throwIfNeeded()) 573 return; 574 v8SetReturnValue(info, result.release()); 575} 576 577static void implementsMethod2MethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 578{ 579 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 580 TestInterfaceV8Internal::implementsMethod2Method(info); 581 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 582} 583 584static void implementsMethod3MethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 585{ 586 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 587 V8TestInterface::implementsMethod3MethodCustom(info); 588 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 589} 590 591static void implementsMethod4Method(const v8::FunctionCallbackInfo<v8::Value>& info) 592{ 593 TestImplements::implementsMethod4(); 594} 595 596static void implementsMethod4MethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 597{ 598 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 599 TestInterfaceV8Internal::implementsMethod4Method(info); 600 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 601} 602 603#if ENABLE(Condition11) || ENABLE(Condition12) 604static void supplementalMethod1Method(const v8::FunctionCallbackInfo<v8::Value>& info) 605{ 606 TestInterface* imp = V8TestInterface::toNative(info.Holder()); 607 TestPartialInterface::supplementalMethod1(imp); 608} 609#endif // ENABLE(Condition11) || ENABLE(Condition12) 610 611#if ENABLE(Condition11) || ENABLE(Condition12) 612static void supplementalMethod1MethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 613{ 614 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 615 TestInterfaceV8Internal::supplementalMethod1Method(info); 616 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 617} 618#endif // ENABLE(Condition11) || ENABLE(Condition12) 619 620#if ENABLE(Condition11) || ENABLE(Condition12) 621static void supplementalMethod2Method(const v8::FunctionCallbackInfo<v8::Value>& info) 622{ 623 ExceptionState exceptionState(ExceptionState::ExecutionContext, "supplementalMethod2", "TestInterface", info.Holder(), info.GetIsolate()); 624 if (UNLIKELY(info.Length() < 2)) { 625 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(2, info.Length())); 626 exceptionState.throwIfNeeded(); 627 return; 628 } 629 TestInterface* imp = V8TestInterface::toNative(info.Holder()); 630 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, strArg, info[0]); 631 if (info.Length() <= 1 || !info[1]->IsFunction()) { 632 throwTypeError(ExceptionMessages::failedToExecute("supplementalMethod2", "TestInterface", "The callback provided as parameter 2 is not a function."), info.GetIsolate()); 633 return; 634 } 635 OwnPtr<TestObject> objArg = V8TestObject::create(v8::Handle<v8::Function>::Cast(info[1]), getExecutionContext()); 636 ExecutionContext* scriptContext = getExecutionContext(); 637 RefPtr<TestObj> result = TestPartialInterface::supplementalMethod2(scriptContext, imp, strArg, objArg.release(), exceptionState); 638 if (exceptionState.throwIfNeeded()) 639 return; 640 v8SetReturnValue(info, result.release()); 641} 642#endif // ENABLE(Condition11) || ENABLE(Condition12) 643 644#if ENABLE(Condition11) || ENABLE(Condition12) 645static void supplementalMethod2MethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 646{ 647 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 648 TestInterfaceV8Internal::supplementalMethod2Method(info); 649 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 650} 651#endif // ENABLE(Condition11) || ENABLE(Condition12) 652 653#if ENABLE(Condition11) || ENABLE(Condition12) 654static void supplementalMethod3MethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 655{ 656 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 657 V8TestInterface::supplementalMethod3MethodCustom(info); 658 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 659} 660#endif // ENABLE(Condition11) || ENABLE(Condition12) 661 662#if ENABLE(Condition11) || ENABLE(Condition12) 663static void supplementalMethod4Method(const v8::FunctionCallbackInfo<v8::Value>& info) 664{ 665 TestPartialInterface::supplementalMethod4(); 666} 667#endif // ENABLE(Condition11) || ENABLE(Condition12) 668 669#if ENABLE(Condition11) || ENABLE(Condition12) 670static void supplementalMethod4MethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 671{ 672 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMMethod"); 673 TestInterfaceV8Internal::supplementalMethod4Method(info); 674 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 675} 676#endif // ENABLE(Condition11) || ENABLE(Condition12) 677 678static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) 679{ 680 if (UNLIKELY(info.Length() < 1)) { 681 throwTypeError(ExceptionMessages::failedToExecute("Constructor", "TestInterface", ExceptionMessages::notEnoughArguments(1, info.Length())), info.GetIsolate()); 682 return; 683 } 684 ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInterface", info.Holder(), info.GetIsolate()); 685 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, str1, info[0]); 686 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, str2, info[1]); 687 ExecutionContext* context = getExecutionContext(); 688 RefPtr<TestInterface> impl = TestInterface::create(context, str1, str2, exceptionState); 689 v8::Handle<v8::Object> wrapper = info.Holder(); 690 if (exceptionState.throwIfNeeded()) 691 return; 692 693 V8DOMWrapper::associateObjectWithWrapper<V8TestInterface>(impl.release(), &V8TestInterface::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration::Dependent); 694 v8SetReturnValue(info, wrapper); 695} 696 697static void namedPropertyGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info) 698{ 699 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty()) 700 return; 701 if (info.Holder()->HasRealNamedCallbackProperty(name)) 702 return; 703 if (info.Holder()->HasRealNamedProperty(name)) 704 return; 705 706 ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder())); 707 TestInterface* collection = V8TestInterface::toNative(info.Holder()); 708 AtomicString propertyName = toCoreAtomicString(name); 709 bool element0Enabled = false; 710 RefPtr<Node> element0; 711 bool element1Enabled = false; 712 RefPtr<NodeList> element1; 713 collection->getItem(propertyName, element0Enabled, element0, element1Enabled, element1); 714 if (element0Enabled) { 715 v8SetReturnValueFast(info, element0.release(), collection); 716 return; 717 } 718 719 if (element1Enabled) { 720 v8SetReturnValueFast(info, element1.release(), collection); 721 return; 722 } 723 724 return; 725} 726 727static void namedPropertyGetterCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info) 728{ 729 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); 730 TestInterfaceV8Internal::namedPropertyGetter(name, info); 731 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 732} 733 734static void namedPropertySetterCallback(v8::Local<v8::String> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<v8::Value>& info) 735{ 736 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); 737 V8TestInterface::namedPropertySetterCustom(name, jsValue, info); 738 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 739} 740 741static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& info) 742{ 743 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); 744 TestInterface* collection = V8TestInterface::toNative(info.Holder()); 745 Vector<String> names; 746 collection->namedPropertyEnumerator(names, exceptionState); 747 if (exceptionState.throwIfNeeded()) 748 return; 749 v8::Handle<v8::Array> v8names = v8::Array::New(info.GetIsolate(), names.size()); 750 for (size_t i = 0; i < names.size(); ++i) 751 v8names->Set(v8::Integer::New(info.GetIsolate(), i), v8String(info.GetIsolate(), names[i])); 752 v8SetReturnValue(info, v8names); 753} 754 755static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Integer>& info) 756{ 757 TestInterface* collection = V8TestInterface::toNative(info.Holder()); 758 AtomicString propertyName = toCoreAtomicString(name); 759 ExceptionState exceptionState(info.Holder(), info.GetIsolate()); 760 bool result = collection->namedPropertyQuery(propertyName, exceptionState); 761 if (exceptionState.throwIfNeeded()) 762 return; 763 if (!result) 764 return; 765 v8SetReturnValueInt(info, v8::None); 766} 767 768static void namedPropertyEnumeratorCallback(const v8::PropertyCallbackInfo<v8::Array>& info) 769{ 770 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); 771 TestInterfaceV8Internal::namedPropertyEnumerator(info); 772 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 773} 774 775static void namedPropertyQueryCallback(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Integer>& info) 776{ 777 TRACE_EVENT_SET_SAMPLING_STATE("Blink", "DOMNamedProperty"); 778 TestInterfaceV8Internal::namedPropertyQuery(name, info); 779 TRACE_EVENT_SET_SAMPLING_STATE("V8", "Execution"); 780} 781 782} // namespace TestInterfaceV8Internal 783 784void V8TestInterface::visitDOMWrapper(void* object, const v8::Persistent<v8::Object>& wrapper, v8::Isolate* isolate) 785{ 786 TestInterface* impl = fromInternalPointer(object); 787 v8::Local<v8::Object> creationContext = v8::Local<v8::Object>::New(isolate, wrapper); 788 V8WrapperInstantiationScope scope(creationContext, isolate); 789 ReferencedType* referencedName = impl->referencedName(); 790 if (referencedName) { 791 if (!DOMDataStore::containsWrapper<V8ReferencedType>(referencedName, isolate)) 792 wrap(referencedName, creationContext, isolate); 793 DOMDataStore::setWrapperReference<V8ReferencedType>(wrapper, referencedName, isolate); 794 } 795 setObjectGroup(object, wrapper, isolate); 796} 797 798static const V8DOMConfiguration::AttributeConfiguration V8TestInterfaceAttributes[] = { 799 {"implementsStr1", TestInterfaceV8Internal::implementsStr1AttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, 800 {"implementsStr2", TestInterfaceV8Internal::implementsStr2AttributeGetterCallback, TestInterfaceV8Internal::implementsStr2AttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, 801 {"implementsStr3", TestInterfaceV8Internal::implementsStr3AttributeGetterCallback, TestInterfaceV8Internal::implementsStr3AttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, 802 {"implementsNode", TestInterfaceV8Internal::implementsNodeAttributeGetterCallback, TestInterfaceV8Internal::implementsNodeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, 803 {"eventHandlerAttribute", TestInterfaceV8Internal::eventHandlerAttributeAttributeGetterCallback, TestInterfaceV8Internal::eventHandlerAttributeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, 804#if ENABLE(Condition11) || ENABLE(Condition12) 805 {"supplementalStr1", TestInterfaceV8Internal::supplementalStr1AttributeGetterCallback, 0, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, 806#endif // ENABLE(Condition11) || ENABLE(Condition12) 807#if ENABLE(Condition11) || ENABLE(Condition12) 808 {"supplementalStr2", TestInterfaceV8Internal::supplementalStr2AttributeGetterCallback, TestInterfaceV8Internal::supplementalStr2AttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, 809#endif // ENABLE(Condition11) || ENABLE(Condition12) 810#if ENABLE(Condition11) || ENABLE(Condition12) 811 {"supplementalStr3", TestInterfaceV8Internal::supplementalStr3AttributeGetterCallback, TestInterfaceV8Internal::supplementalStr3AttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, 812#endif // ENABLE(Condition11) || ENABLE(Condition12) 813#if ENABLE(Condition11) || ENABLE(Condition12) 814 {"supplementalNode", TestInterfaceV8Internal::supplementalNodeAttributeGetterCallback, TestInterfaceV8Internal::supplementalNodeAttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}, 815#endif // ENABLE(Condition11) || ENABLE(Condition12) 816}; 817 818static const V8DOMConfiguration::MethodConfiguration V8TestInterfaceMethods[] = { 819 {"implementsMethod1", TestInterfaceV8Internal::implementsMethod1MethodCallback, 0, 0}, 820 {"implementsMethod2", TestInterfaceV8Internal::implementsMethod2MethodCallback, 0, 2}, 821 {"implementsMethod3", TestInterfaceV8Internal::implementsMethod3MethodCallback, 0, 0}, 822#if ENABLE(Condition11) || ENABLE(Condition12) 823 {"supplementalMethod1", TestInterfaceV8Internal::supplementalMethod1MethodCallback, 0, 0}, 824#endif // ENABLE(Condition11) || ENABLE(Condition12) 825#if ENABLE(Condition11) || ENABLE(Condition12) 826 {"supplementalMethod2", TestInterfaceV8Internal::supplementalMethod2MethodCallback, 0, 2}, 827#endif // ENABLE(Condition11) || ENABLE(Condition12) 828#if ENABLE(Condition11) || ENABLE(Condition12) 829 {"supplementalMethod3", TestInterfaceV8Internal::supplementalMethod3MethodCallback, 0, 0}, 830#endif // ENABLE(Condition11) || ENABLE(Condition12) 831}; 832 833void V8TestInterface::constructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info) 834{ 835 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "DOMConstructor"); 836 if (!info.IsConstructCall()) { 837 throwTypeError(ExceptionMessages::failedToConstruct("TestInterface", "Please use the 'new' operator, this DOM object constructor cannot be called as a function."), info.GetIsolate()); 838 return; 839 } 840 841 if (ConstructorMode::current() == ConstructorMode::WrapExistingObject) { 842 v8SetReturnValue(info, info.Holder()); 843 return; 844 } 845 846 TestInterfaceV8Internal::constructor(info); 847} 848 849static v8::Handle<v8::FunctionTemplate> ConfigureV8TestInterfaceTemplate(v8::Handle<v8::FunctionTemplate> functionTemplate, v8::Isolate* isolate, WrapperWorldType currentWorldType) 850{ 851 functionTemplate->ReadOnlyPrototype(); 852 853 v8::Local<v8::Signature> defaultSignature; 854 defaultSignature = V8DOMConfiguration::installDOMClassTemplate(functionTemplate, "TestInterface", v8::Local<v8::FunctionTemplate>(), V8TestInterface::internalFieldCount, 855 V8TestInterfaceAttributes, WTF_ARRAY_LENGTH(V8TestInterfaceAttributes), 856 0, 0, 857 V8TestInterfaceMethods, WTF_ARRAY_LENGTH(V8TestInterfaceMethods), 858 isolate, currentWorldType); 859 functionTemplate->SetCallHandler(V8TestInterface::constructorCallback); 860 functionTemplate->SetLength(1); 861 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED instanceTemplate = functionTemplate->InstanceTemplate(); 862 v8::Local<v8::ObjectTemplate> ALLOW_UNUSED prototypeTemplate = functionTemplate->PrototypeTemplate(); 863 if (RuntimeEnabledFeatures::featureName23Enabled()) { 864 static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\ 865 {"Node23", TestInterfaceV8Internal::Node23AttributeGetterCallback, TestInterfaceV8Internal::Node23AttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}; 866 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate, attributeConfiguration, isolate, currentWorldType); 867 } 868#if ENABLE(Condition11) || ENABLE(Condition12) 869 if (RuntimeEnabledFeatures::condition13Enabled()) { 870 static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\ 871 {"Node13", TestInterfaceV8Internal::Node13AttributeGetterCallback, TestInterfaceV8Internal::Node13AttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}; 872 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate, attributeConfiguration, isolate, currentWorldType); 873 } 874#endif // ENABLE(Condition11) || ENABLE(Condition12) 875 static const V8DOMConfiguration::ConstantConfiguration V8TestInterfaceConstants[] = { 876 {"IMPLEMENTSCONSTANT1", 1}, 877 {"IMPLEMENTSCONSTANT2", 2}, 878 {"SUPPLEMENTALCONSTANT1", 1}, 879 {"SUPPLEMENTALCONSTANT2", 2}, 880 }; 881 V8DOMConfiguration::installConstants(functionTemplate, prototypeTemplate, V8TestInterfaceConstants, WTF_ARRAY_LENGTH(V8TestInterfaceConstants), isolate); 882 COMPILE_ASSERT(1 == TestImplements::IMPLEMENTSCONSTANT1, TheValueOfTestInterface_IMPLEMENTSCONSTANT1DoesntMatchWithImplementation); 883 COMPILE_ASSERT(2 == TestImplements::CONST_IMPL, TheValueOfTestInterface_CONST_IMPLDoesntMatchWithImplementation); 884 COMPILE_ASSERT(1 == TestPartialInterface::SUPPLEMENTALCONSTANT1, TheValueOfTestInterface_SUPPLEMENTALCONSTANT1DoesntMatchWithImplementation); 885 COMPILE_ASSERT(2 == TestPartialInterface::CONST_IMPL, TheValueOfTestInterface_CONST_IMPLDoesntMatchWithImplementation); 886 functionTemplate->InstanceTemplate()->SetNamedPropertyHandler(TestInterfaceV8Internal::namedPropertyGetterCallback, TestInterfaceV8Internal::namedPropertySetterCallback, TestInterfaceV8Internal::namedPropertyQueryCallback, 0, TestInterfaceV8Internal::namedPropertyEnumeratorCallback); 887 functionTemplate->Set(v8::String::NewFromUtf8(isolate, "implementsMethod4", v8::String::kInternalizedString), v8::FunctionTemplate::New(isolate, TestInterfaceV8Internal::implementsMethod4MethodCallback, v8Undefined(), v8::Local<v8::Signature>(), 0)); 888#if ENABLE(Condition11) || ENABLE(Condition12) 889 functionTemplate->Set(v8::String::NewFromUtf8(isolate, "supplementalMethod4", v8::String::kInternalizedString), v8::FunctionTemplate::New(isolate, TestInterfaceV8Internal::supplementalMethod4MethodCallback, v8Undefined(), v8::Local<v8::Signature>(), 0)); 890#endif // ENABLE(Condition11) || ENABLE(Condition12) 891 functionTemplate->SetNativeDataProperty(v8::String::NewFromUtf8(isolate, "implementsStaticReadOnlyAttr", v8::String::kInternalizedString), TestInterfaceV8Internal::implementsStaticReadOnlyAttrAttributeGetterCallback, 0, v8::External::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT)); 892 functionTemplate->SetNativeDataProperty(v8::String::NewFromUtf8(isolate, "implementsStaticAttr", v8::String::kInternalizedString), TestInterfaceV8Internal::implementsStaticAttrAttributeGetterCallback, TestInterfaceV8Internal::implementsStaticAttrAttributeSetterCallback, v8::External::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT)); 893#if ENABLE(Condition11) || ENABLE(Condition12) 894 functionTemplate->SetNativeDataProperty(v8::String::NewFromUtf8(isolate, "supplementalStaticReadOnlyAttr", v8::String::kInternalizedString), TestInterfaceV8Internal::supplementalStaticReadOnlyAttrAttributeGetterCallback, 0, v8::External::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT)); 895#endif // ENABLE(Condition11) || ENABLE(Condition12) 896#if ENABLE(Condition11) || ENABLE(Condition12) 897 functionTemplate->SetNativeDataProperty(v8::String::NewFromUtf8(isolate, "supplementalStaticAttr", v8::String::kInternalizedString), TestInterfaceV8Internal::supplementalStaticAttrAttributeGetterCallback, TestInterfaceV8Internal::supplementalStaticAttrAttributeSetterCallback, v8::External::New(isolate, 0), static_cast<v8::PropertyAttribute>(v8::None), v8::Handle<v8::AccessorSignature>(), static_cast<v8::AccessControl>(v8::DEFAULT)); 898#endif // ENABLE(Condition11) || ENABLE(Condition12) 899 900 // Custom toString template 901 functionTemplate->Set(v8::String::NewFromUtf8(isolate, "toString", v8::String::kInternalizedString), V8PerIsolateData::current()->toStringTemplate()); 902 return functionTemplate; 903} 904 905v8::Handle<v8::FunctionTemplate> V8TestInterface::domTemplate(v8::Isolate* isolate, WrapperWorldType currentWorldType) 906{ 907 V8PerIsolateData* data = V8PerIsolateData::from(isolate); 908 V8PerIsolateData::TemplateMap::iterator result = data->templateMap(currentWorldType).find(&wrapperTypeInfo); 909 if (result != data->templateMap(currentWorldType).end()) 910 return result->value.newLocal(isolate); 911 912 TRACE_EVENT_SCOPED_SAMPLING_STATE("Blink", "BuildDOMTemplate"); 913 v8::EscapableHandleScope handleScope(isolate); 914 v8::Local<v8::FunctionTemplate> templ = 915 ConfigureV8TestInterfaceTemplate(data->rawDOMTemplate(&wrapperTypeInfo, currentWorldType), isolate, currentWorldType); 916 data->templateMap(currentWorldType).add(&wrapperTypeInfo, UnsafePersistent<v8::FunctionTemplate>(isolate, templ)); 917 return handleScope.Escape(templ); 918} 919 920bool V8TestInterface::hasInstance(v8::Handle<v8::Value> jsValue, v8::Isolate* isolate, WrapperWorldType currentWorldType) 921{ 922 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValue, currentWorldType); 923} 924 925bool V8TestInterface::hasInstanceInAnyWorld(v8::Handle<v8::Value> jsValue, v8::Isolate* isolate) 926{ 927 return V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValue, MainWorld) 928 || V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValue, IsolatedWorld) 929 || V8PerIsolateData::from(isolate)->hasInstance(&wrapperTypeInfo, jsValue, WorkerWorld); 930} 931 932void V8TestInterface::installPerContextEnabledProperties(v8::Handle<v8::Object> instanceTemplate, TestInterface* impl, v8::Isolate* isolate) 933{ 934 v8::Local<v8::Object> prototypeTemplate = v8::Local<v8::Object>::Cast(instanceTemplate->GetPrototype()); 935 if (ContextFeatures::featureName24Enabled(impl->document())) { 936 static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\ 937 {"Node24", TestInterfaceV8Internal::Node24AttributeGetterCallback, TestInterfaceV8Internal::Node24AttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}; 938 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate, attributeConfiguration, isolate); 939 } 940 if (ContextFeatures::condition14Enabled(impl->document())) { 941 static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\ 942 {"Node14", TestInterfaceV8Internal::Node14AttributeGetterCallback, TestInterfaceV8Internal::Node14AttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}; 943 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate, attributeConfiguration, isolate); 944 } 945 if (ContextFeatures::condition16Enabled(impl->document())) { 946 static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\ 947 {"Node15", TestInterfaceV8Internal::Node15AttributeGetterCallback, TestInterfaceV8Internal::Node15AttributeSetterCallback, 0, 0, 0, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */}; 948 V8DOMConfiguration::installAttribute(instanceTemplate, prototypeTemplate, attributeConfiguration, isolate); 949 } 950} 951 952ActiveDOMObject* V8TestInterface::toActiveDOMObject(v8::Handle<v8::Object> wrapper) 953{ 954 return toNative(wrapper); 955} 956 957v8::Handle<v8::Object> V8TestInterface::createWrapper(PassRefPtr<TestInterface> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) 958{ 959 ASSERT(impl); 960 ASSERT(!DOMDataStore::containsWrapper<V8TestInterface>(impl.get(), isolate)); 961 if (ScriptWrappable::wrapperCanBeStoredInObject(impl.get())) { 962 const WrapperTypeInfo* actualInfo = ScriptWrappable::getTypeInfoFromObject(impl.get()); 963 // Might be a XXXConstructor::wrapperTypeInfo instead of an XXX::wrapperTypeInfo. These will both have 964 // the same object de-ref functions, though, so use that as the basis of the check. 965 RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == wrapperTypeInfo.derefObjectFunction); 966 } 967 968 v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &wrapperTypeInfo, toInternalPointer(impl.get()), isolate); 969 if (UNLIKELY(wrapper.IsEmpty())) 970 return wrapper; 971 972 installPerContextEnabledProperties(wrapper, impl.get(), isolate); 973 V8DOMWrapper::associateObjectWithWrapper<V8TestInterface>(impl, &wrapperTypeInfo, wrapper, isolate, WrapperConfiguration::Dependent); 974 return wrapper; 975} 976 977void V8TestInterface::derefObject(void* object) 978{ 979 fromInternalPointer(object)->deref(); 980} 981 982template<> 983v8::Handle<v8::Value> toV8NoInline(TestInterface* impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate) 984{ 985 return toV8(impl, creationContext, isolate); 986} 987 988} // namespace WebCore 989#endif // ENABLE(Condition1) || ENABLE(Condition2) 990