| OLD | NEW |
| 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 23 matching lines...) Expand all Loading... |
| 34 namespace WebCore { | 34 namespace WebCore { |
| 35 | 35 |
| 36 void V8DOMConfiguration::installAttributes(v8::Handle<v8::ObjectTemplate> instan
ceTemplate, v8::Handle<v8::ObjectTemplate> prototype, const AttributeConfigurati
on* attributes, size_t attributeCount, v8::Isolate* isolate) | 36 void V8DOMConfiguration::installAttributes(v8::Handle<v8::ObjectTemplate> instan
ceTemplate, v8::Handle<v8::ObjectTemplate> prototype, const AttributeConfigurati
on* attributes, size_t attributeCount, v8::Isolate* isolate) |
| 37 { | 37 { |
| 38 for (size_t i = 0; i < attributeCount; ++i) | 38 for (size_t i = 0; i < attributeCount; ++i) |
| 39 installAttribute(instanceTemplate, prototype, attributes[i], isolate); | 39 installAttribute(instanceTemplate, prototype, attributes[i], isolate); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void V8DOMConfiguration::installAccessors(v8::Handle<v8::ObjectTemplate> prototy
pe, v8::Handle<v8::Signature> signature, const AccessorConfiguration* accessors,
size_t accessorCount, v8::Isolate* isolate) | 42 void V8DOMConfiguration::installAccessors(v8::Handle<v8::ObjectTemplate> prototy
pe, v8::Handle<v8::Signature> signature, const AccessorConfiguration* accessors,
size_t accessorCount, v8::Isolate* isolate) |
| 43 { | 43 { |
| 44 bool isMainWorld = DOMWrapperWorld::current(isolate)->isMainWorld(); | 44 bool isMainWorld = DOMWrapperWorld::current(isolate).isMainWorld(); |
| 45 for (size_t i = 0; i < accessorCount; ++i) { | 45 for (size_t i = 0; i < accessorCount; ++i) { |
| 46 v8::FunctionCallback getterCallback = accessors[i].getter; | 46 v8::FunctionCallback getterCallback = accessors[i].getter; |
| 47 v8::FunctionCallback setterCallback = accessors[i].setter; | 47 v8::FunctionCallback setterCallback = accessors[i].setter; |
| 48 if (isMainWorld) { | 48 if (isMainWorld) { |
| 49 if (accessors[i].getterForMainWorld) | 49 if (accessors[i].getterForMainWorld) |
| 50 getterCallback = accessors[i].getterForMainWorld; | 50 getterCallback = accessors[i].getterForMainWorld; |
| 51 if (accessors[i].setterForMainWorld) | 51 if (accessors[i].setterForMainWorld) |
| 52 setterCallback = accessors[i].setterForMainWorld; | 52 setterCallback = accessors[i].setterForMainWorld; |
| 53 } | 53 } |
| 54 | 54 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 71 for (size_t i = 0; i < constantCount; ++i) { | 71 for (size_t i = 0; i < constantCount; ++i) { |
| 72 const ConstantConfiguration* constant = &constants[i]; | 72 const ConstantConfiguration* constant = &constants[i]; |
| 73 v8::Handle<v8::String> constantName = v8AtomicString(isolate, constant->
name); | 73 v8::Handle<v8::String> constantName = v8AtomicString(isolate, constant->
name); |
| 74 functionDescriptor->Set(constantName, v8::Integer::New(isolate, constant
->value), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete)); | 74 functionDescriptor->Set(constantName, v8::Integer::New(isolate, constant
->value), static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete)); |
| 75 prototype->Set(constantName, v8::Integer::New(isolate, constant->value),
static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete)); | 75 prototype->Set(constantName, v8::Integer::New(isolate, constant->value),
static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete)); |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 | 78 |
| 79 void V8DOMConfiguration::installCallbacks(v8::Handle<v8::ObjectTemplate> prototy
pe, v8::Handle<v8::Signature> signature, v8::PropertyAttribute attributes, const
MethodConfiguration* callbacks, size_t callbackCount, v8::Isolate* isolate) | 79 void V8DOMConfiguration::installCallbacks(v8::Handle<v8::ObjectTemplate> prototy
pe, v8::Handle<v8::Signature> signature, v8::PropertyAttribute attributes, const
MethodConfiguration* callbacks, size_t callbackCount, v8::Isolate* isolate) |
| 80 { | 80 { |
| 81 bool isMainWorld = DOMWrapperWorld::current(isolate)->isMainWorld(); | 81 bool isMainWorld = DOMWrapperWorld::current(isolate).isMainWorld(); |
| 82 for (size_t i = 0; i < callbackCount; ++i) { | 82 for (size_t i = 0; i < callbackCount; ++i) { |
| 83 v8::FunctionCallback callback = callbacks[i].callback; | 83 v8::FunctionCallback callback = callbacks[i].callback; |
| 84 if (isMainWorld && callbacks[i].callbackForMainWorld) | 84 if (isMainWorld && callbacks[i].callbackForMainWorld) |
| 85 callback = callbacks[i].callbackForMainWorld; | 85 callback = callbacks[i].callbackForMainWorld; |
| 86 v8::Local<v8::FunctionTemplate> functionTemplate = v8::FunctionTemplate:
:New(isolate, callback, v8Undefined(), signature, callbacks[i].length); | 86 v8::Local<v8::FunctionTemplate> functionTemplate = v8::FunctionTemplate:
:New(isolate, callback, v8Undefined(), signature, callbacks[i].length); |
| 87 functionTemplate->RemovePrototype(); | 87 functionTemplate->RemovePrototype(); |
| 88 prototype->Set(v8AtomicString(isolate, callbacks[i].name), functionTempl
ate, attributes); | 88 prototype->Set(v8AtomicString(isolate, callbacks[i].name), functionTempl
ate, attributes); |
| 89 } | 89 } |
| 90 } | 90 } |
| 91 | 91 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 111 if (attributeCount) | 111 if (attributeCount) |
| 112 installAttributes(instanceTemplate, functionDescriptor->PrototypeTemplat
e(), attributes, attributeCount, isolate); | 112 installAttributes(instanceTemplate, functionDescriptor->PrototypeTemplat
e(), attributes, attributeCount, isolate); |
| 113 if (accessorCount) | 113 if (accessorCount) |
| 114 installAccessors(functionDescriptor->PrototypeTemplate(), defaultSignatu
re, accessors, accessorCount, isolate); | 114 installAccessors(functionDescriptor->PrototypeTemplate(), defaultSignatu
re, accessors, accessorCount, isolate); |
| 115 if (callbackCount) | 115 if (callbackCount) |
| 116 installCallbacks(functionDescriptor->PrototypeTemplate(), defaultSignatu
re, static_cast<v8::PropertyAttribute>(v8::DontDelete), callbacks, callbackCount
, isolate); | 116 installCallbacks(functionDescriptor->PrototypeTemplate(), defaultSignatu
re, static_cast<v8::PropertyAttribute>(v8::DontDelete), callbacks, callbackCount
, isolate); |
| 117 return defaultSignature; | 117 return defaultSignature; |
| 118 } | 118 } |
| 119 | 119 |
| 120 } // namespace WebCore | 120 } // namespace WebCore |
| OLD | NEW |