本文整理汇总了C++中V8IsolatedContext类的典型用法代码示例。如果您正苦于以下问题:C++ V8IsolatedContext类的具体用法?C++ V8IsolatedContext怎么用?C++ V8IsolatedContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了V8IsolatedContext类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1:
V8BindingPerContextData* V8Proxy::retrievePerContextData(Frame* frame)
{
V8IsolatedContext* isolatedContext;
if (UNLIKELY(!!(isolatedContext = V8IsolatedContext::getEntered())))
return isolatedContext->perContextData();
return frame->script()->windowShell()->perContextData();
}
开发者ID:,项目名称:,代码行数:7,代码来源:
示例2: adoptRef
PassRefPtr<HTMLOptionElement> HTMLOptionElement::createForJSConstructor(Document* document, const String& data, const String& value,
bool defaultSelected, bool selected, ExceptionCode& ec)
{
RefPtr<HTMLOptionElement> element = adoptRef(new HTMLOptionElement(optionTag, document));
int worldID = 0;
V8IsolatedContext* isolatedContext = V8IsolatedContext::getEntered();
if (isolatedContext!=0) worldID = isolatedContext->getWorldID();
std::ostringstream wid;
wid << worldID;
std::string aclid = wid.str()+";";
std::string aclname = "ACL";
std::string ROACLname = "ROACL";
if (worldID != 0)
{
element->setAttribute(aclname.c_str(),aclid.c_str(),ec,worldID,false);
element->setAttribute(ROACLname.c_str(),aclid.c_str(),ec,worldID,false);
}
RefPtr<Text> text = Text::create(document, data.isNull() ? "" : data);
ec = 0;
element->appendChild(text.release(), ec);
if (ec)
return 0;
if (!value.isNull())
element->setValue(value);
element->setDefaultSelected(defaultSelected);
element->setSelected(selected);
return element.release();
}
开发者ID:,项目名称:,代码行数:31,代码来源:
示例3: getDefaultStore
DOMDataStore& DOMData::getCurrentStore()
{
V8BindingPerIsolateData* data = V8BindingPerIsolateData::current();
if (UNLIKELY(data->domDataStore() != 0))
return *data->domDataStore();
V8IsolatedContext* context = V8IsolatedContext::getEntered();
if (UNLIKELY(context != 0))
return *context->world()->domDataStore();
return getDefaultStore();
}
开发者ID:KaoTD,项目名称:Nokia-RM-1013-2.0.0.11,代码行数:10,代码来源:DOMData.cpp
示例4: ASSERT
DOMDataStore& MainThreadDOMData::getMainThreadStore()
{
// This is broken out as a separate non-virtual method from getStore()
// so that it can be inlined by getCurrentMainThreadStore, which is
// a hot spot in Dromaeo DOM tests.
ASSERT(WTF::isMainThread());
V8IsolatedContext* context = V8IsolatedContext::getEntered();
if (UNLIKELY(context != 0))
return *context->world()->domDataStore();
return m_defaultStore;
}
开发者ID:sloanyang,项目名称:android_external_webkit,代码行数:11,代码来源:MainThreadDOMData.cpp
示例5:
v8::Handle<v8::Object> V8DOMWrapper::getWrapperSlow(Node* node)
{
V8IsolatedContext* context = V8IsolatedContext::getEntered();
if (LIKELY(!context)) {
v8::Persistent<v8::Object>* wrapper = node->wrapper();
if (!wrapper)
return v8::Handle<v8::Object>();
return *wrapper;
}
DOMNodeMapping& domNodeMap = context->world()->domDataStore()->domNodeMap();
return domNodeMap.get(node);
}
开发者ID:ACSOP,项目名称:android_external_webkit,代码行数:12,代码来源:V8DOMWrapper.cpp
示例6: ENABLE
v8::Local<v8::Object> V8DOMWrapper::instantiateV8Object(V8Proxy* proxy, WrapperTypeInfo* type, void* impl)
{
#if ENABLE(WORKERS)
WorkerContext* workerContext = 0;
#endif
V8BindingPerContextData* contextData = 0;
V8IsolatedContext* isolatedContext;
if (UNLIKELY(!!(isolatedContext = V8IsolatedContext::getEntered()))) {
contextData = isolatedContext->perContextData();
} else if (!proxy) {
v8::Handle<v8::Context> context = v8::Context::GetCurrent();
if (!context.IsEmpty()) {
v8::Handle<v8::Object> globalPrototype = v8::Handle<v8::Object>::Cast(context->Global()->GetPrototype());
if (isWrapperOfType(globalPrototype, &V8DOMWindow::info)) {
Frame* frame = V8DOMWindow::toNative(globalPrototype)->frame();
if (frame && frame->script()->canExecuteScripts(NotAboutToExecuteScript))
proxy = V8Proxy::retrieve(frame);
}
#if ENABLE(WORKERS)
else if (isWrapperOfType(globalPrototype, &V8WorkerContext::info))
workerContext = V8WorkerContext::toNative(lookupDOMWrapper(V8WorkerContext::GetTemplate(), context->Global()));
#endif
}
}
v8::Local<v8::Object> instance;
if (!contextData) {
if (proxy)
contextData = perContextData(proxy);
#if ENABLE(WORKERS)
else if (workerContext)
contextData = perContextData(workerContext);
#endif
}
if (contextData)
instance = contextData->createWrapperFromCache(type);
else {
v8::Local<v8::Function> function = type->getTemplate()->GetFunction();
instance = SafeAllocation::newInstance(function);
}
if (!instance.IsEmpty()) {
// Avoid setting the DOM wrapper for failed allocations.
setDOMWrapper(instance, type, impl);
if (type == &V8HTMLDocument::info)
instance = V8HTMLDocument::WrapInShadowObject(instance, static_cast<Node*>(impl));
}
return instance;
}
开发者ID:Spencerx,项目名称:webkit,代码行数:50,代码来源:V8DOMWrapper.cpp
示例7: getAttributeItem
PassRefPtr<Node> NamedNodeMap::setNamedItem(Node* arg, ExceptionCode& ec)
{
if (!m_element || !arg) {
ec = NOT_FOUND_ERR;
return 0;
}
// WRONG_DOCUMENT_ERR: Raised if arg was created from a different document than the one that created this map.
if (arg->document() != m_element->document()) {
ec = WRONG_DOCUMENT_ERR;
return 0;
}
// Not mentioned in spec: throw a HIERARCHY_REQUEST_ERROR if the user passes in a non-attribute node
if (!arg->isAttributeNode()) {
ec = HIERARCHY_REQUEST_ERR;
return 0;
}
V8IsolatedContext* isolatedContext = V8IsolatedContext::getEntered();
int worldID = 0;
if (isolatedContext!=0) worldID = isolatedContext->getWorldID();
Attr *attr = static_cast<Attr*>(arg);
Attribute* a = attr->attr();
if (worldID != 0) a->setWorldID(worldID);
Attribute* old = getAttributeItem(a->name());
if (old == a)
return RefPtr<Node>(arg); // we know about it already
// INUSE_ATTRIBUTE_ERR: Raised if arg is an Attr that is already an attribute of another Element object.
// The DOM user must explicitly clone Attr nodes to re-use them in other elements.
if (attr->ownerElement()) {
ec = INUSE_ATTRIBUTE_ERR;
return 0;
}
if (attr->isId())
m_element->updateId(old ? old->value() : nullAtom, a->value());
// ### slightly inefficient - resizes attribute array twice.
RefPtr<Node> r;
if (old) {
r = old->createAttrIfNeeded(m_element);
removeAttribute(a->name());
}
addAttribute(a);
return r.release();
}
开发者ID:,项目名称:,代码行数:48,代码来源:
示例8: V8IsolatedContext
v8::Local<v8::Array> V8Proxy::evaluateInIsolatedWorld(int worldID, const Vector<ScriptSourceCode>& sources, int extensionGroup)
{
// FIXME: This will need to get reorganized once we have a windowShell for the isolated world.
if (!windowShell()->initContextIfNeeded())
return v8::Local<v8::Array>();
v8::HandleScope handleScope;
V8IsolatedContext* isolatedContext = 0;
if (worldID > 0) {
IsolatedWorldMap::iterator iter = m_isolatedWorlds.find(worldID);
if (iter != m_isolatedWorlds.end()) {
isolatedContext = iter->second;
} else {
isolatedContext = new V8IsolatedContext(this, extensionGroup, worldID);
if (isolatedContext->context().IsEmpty()) {
delete isolatedContext;
return v8::Local<v8::Array>();
}
// FIXME: We should change this to using window shells to match JSC.
m_isolatedWorlds.set(worldID, isolatedContext);
}
IsolatedWorldSecurityOriginMap::iterator securityOriginIter = m_isolatedWorldSecurityOrigins.find(worldID);
if (securityOriginIter != m_isolatedWorldSecurityOrigins.end())
isolatedContext->setSecurityOrigin(securityOriginIter->second);
} else {
isolatedContext = new V8IsolatedContext(this, extensionGroup, worldID);
if (isolatedContext->context().IsEmpty()) {
delete isolatedContext;
return v8::Local<v8::Array>();
}
}
v8::Local<v8::Context> context = v8::Local<v8::Context>::New(isolatedContext->context());
v8::Context::Scope context_scope(context);
v8::Local<v8::Array> results = v8::Array::New(sources.size());
for (size_t i = 0; i < sources.size(); ++i) {
v8::Local<v8::Value> evaluationResult = evaluate(sources[i], 0);
if (evaluationResult.IsEmpty())
evaluationResult = v8::Local<v8::Value>::New(v8::Undefined());
results->Set(i, evaluationResult);
}
if (worldID == 0)
isolatedContext->destroy();
return handleScope.Close(results);
}
开发者ID:,项目名称:,代码行数:51,代码来源:
示例9: windowShell
void V8Proxy::evaluateInIsolatedWorld(int worldID, const Vector<ScriptSourceCode>& sources, int extensionGroup)
{
// FIXME: This will need to get reorganized once we have a windowShell for the isolated world.
windowShell()->initContextIfNeeded();
v8::HandleScope handleScope;
V8IsolatedContext* isolatedContext = 0;
if (worldID > 0) {
IsolatedWorldMap::iterator iter = m_isolatedWorlds.find(worldID);
if (iter != m_isolatedWorlds.end()) {
isolatedContext = iter->second;
} else {
isolatedContext = new V8IsolatedContext(this, extensionGroup);
if (isolatedContext->context().IsEmpty()) {
delete isolatedContext;
return;
}
// FIXME: We should change this to using window shells to match JSC.
m_isolatedWorlds.set(worldID, isolatedContext);
// Setup context id for JS debugger.
if (!setInjectedScriptContextDebugId(isolatedContext->context())) {
m_isolatedWorlds.take(worldID);
delete isolatedContext;
return;
}
}
} else {
isolatedContext = new V8IsolatedContext(this, extensionGroup);
if (isolatedContext->context().IsEmpty()) {
delete isolatedContext;
return;
}
}
v8::Local<v8::Context> context = v8::Local<v8::Context>::New(isolatedContext->context());
v8::Context::Scope context_scope(context);
for (size_t i = 0; i < sources.size(); ++i)
evaluate(sources[i], 0);
if (worldID == 0)
isolatedContext->destroy();
}
开发者ID:besk,项目名称:MT6589_kernel_source,代码行数:45,代码来源:V8Proxy.cpp
注:本文中的V8IsolatedContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论