本文整理汇总了C++中v8::Handle::CreationContext方法的典型用法代码示例。如果您正苦于以下问题:C++ Handle::CreationContext方法的具体用法?C++ Handle::CreationContext怎么用?C++ Handle::CreationContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类v8::Handle
的用法示例。
在下文中一共展示了Handle::CreationContext方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ASSERT
v8::Handle<v8::Object> V8TestNamedConstructor::wrapSlow(PassRefPtr<TestNamedConstructor> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
{
v8::Handle<v8::Object> wrapper;
Document* document = 0;
UNUSED_PARAM(document);
v8::Handle<v8::Context> context;
if (!creationContext.IsEmpty() && creationContext->CreationContext() != v8::Context::GetCurrent()) {
// For performance, we enter the context only if the currently running context
// is different from the context that we are about to enter.
context = v8::Local<v8::Context>::New(creationContext->CreationContext());
ASSERT(!context.IsEmpty());
context->Enter();
}
wrapper = V8DOMWrapper::instantiateV8Object(document, &info, impl.get());
if (!context.IsEmpty())
context->Exit();
if (UNLIKELY(wrapper.IsEmpty()))
return wrapper;
v8::Persistent<v8::Object> wrapperHandle = V8DOMWrapper::setJSWrapperForActiveDOMObject(impl, wrapper, isolate);
if (!hasDependentLifetime)
wrapperHandle.MarkIndependent();
return wrapper;
}
示例2: resolveOrRejectInternal
void ScriptPromisePropertyBase::resolveOrRejectInternal(v8::Handle<v8::Promise::Resolver> resolver)
{
switch (m_state) {
case Pending:
ASSERT_NOT_REACHED();
break;
case Resolved:
resolver->Resolve(resolvedValue(m_isolate, resolver->CreationContext()->Global()));
break;
case Rejected:
resolver->Reject(rejectedValue(m_isolate, resolver->CreationContext()->Global()));
break;
}
}
示例3:
explicit V8WrapperInstantiationScope(v8::Handle<v8::Object> creationContext)
: m_didEnterContext(false)
, m_context(v8::Context::GetCurrent())
{
if (creationContext.IsEmpty())
return;
v8::Handle<v8::Context> contextForWrapper = creationContext->CreationContext();
// For performance, we enter the context only if the currently running context
// is different from the context that we are about to enter.
if (contextForWrapper == m_context)
return;
m_context = v8::Local<v8::Context>::New(contextForWrapper);
m_didEnterContext = true;
m_context->Enter();
}
示例4: ASSERT
v8::Handle<v8::Object> V8CustomElement::createWrapper(PassRefPtr<Element> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate)
{
ASSERT(impl);
RefPtr<CustomElementConstructor> constructor = CustomElementRegistry::constructorOf(impl.get());
if (!constructor) {
v8::Handle<v8::Value> wrapperValue = WebCore::toV8(toHTMLUnknownElement(toHTMLElement(impl.get())), creationContext, isolate);
if (!wrapperValue.IsEmpty() && wrapperValue->IsObject())
return v8::Handle<v8::Object>::Cast(wrapperValue);
return v8::Handle<v8::Object>();
}
// The constructor and registered lifecycle callbacks should be visible only from main world.
// FIXME: This shouldn't be needed once each custom element has its own FunctionTemplate
// https://bugs.webkit.org/show_bug.cgi?id=108138
if (!CustomElementHelpers::isFeatureAllowed(creationContext->CreationContext())) {
v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &V8HTMLElement::info, impl.get(), isolate);
if (!wrapper.IsEmpty())
V8DOMWrapper::associateObjectWithWrapper(impl, &V8HTMLElement::info, wrapper, isolate, WrapperConfiguration::Dependent);
return wrapper;
}
v8::Handle<v8::Value> constructorValue = WebCore::toV8(constructor.get(), creationContext, isolate);
if (constructorValue.IsEmpty() || !constructorValue->IsObject())
return v8::Handle<v8::Object>();
v8::Handle<v8::Object> constructorWapper = v8::Handle<v8::Object>::Cast(constructorValue);
v8::Handle<v8::Object> prototype = v8::Handle<v8::Object>::Cast(constructorWapper->Get(v8::String::NewSymbol("prototype")));
WrapperTypeInfo* typeInfo = findWrapperTypeOf(prototype);
if (!typeInfo)
return v8::Handle<v8::Object>();
v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, typeInfo, impl.get(), isolate);
if (wrapper.IsEmpty())
return v8::Handle<v8::Object>();
wrapper->SetPrototype(prototype);
V8DOMWrapper::associateObjectWithWrapper(impl, typeInfo, wrapper, isolate, WrapperConfiguration::Dependent);
return wrapper;
}
示例5: createUpgradeCandidateWrapper
v8::Handle<v8::Object> CustomElementWrapper<ElementType, WrapperType>::wrap(PassRefPtrWillBeRawPtr<ElementType> element, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate, v8::Handle<v8::Object> (*createSpecificWrapper)(ElementType* element, v8::Handle<v8::Object> creationContext, v8::Isolate*))
{
ASSERT(DOMDataStore::getWrapper<V8Element>(element.get(), isolate).IsEmpty());
// FIXME: creationContext.IsEmpty() should never happen. Remove
// this when callers (like InspectorController::inspect) are fixed
// to never pass an empty creation context.
v8::Handle<v8::Context> context = creationContext.IsEmpty() ? isolate->GetCurrentContext() : creationContext->CreationContext();
if (!element->isUpgradedCustomElement() || DOMWrapperWorld::world(context).isIsolatedWorld())
return createUpgradeCandidateWrapper(element.get(), creationContext, isolate, createSpecificWrapper);
V8PerContextData* perContextData = V8PerContextData::from(context);
if (!perContextData)
return v8::Handle<v8::Object>();
CustomElementBinding* binding = perContextData->customElementBinding(element->customElementDefinition());
v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, binding->wrapperType(), element.get(), isolate);
if (wrapper.IsEmpty())
return v8::Handle<v8::Object>();
wrapper->SetPrototype(binding->prototype());
V8DOMWrapper::associateObjectWithWrapper<WrapperType>(element, binding->wrapperType(), wrapper, isolate, WrapperConfiguration::Dependent);
return wrapper;
}
示例6: createUpgradeCandidateWrapper
v8::Handle<v8::Object> CustomElementHelpers::createWrapper(PassRefPtr<Element> impl, v8::Handle<v8::Object> creationContext, v8::Isolate* isolate, const CreateWrapperFunction& createTypeExtensionUpgradeCandidateWrapper)
{
ASSERT(impl);
// FIXME: creationContext.IsEmpty() should never happen. Remove
// this when callers (like InspectorController::inspect) are fixed
// to never pass an empty creation context.
v8::Handle<v8::Context> context = creationContext.IsEmpty() ? isolate->GetCurrentContext() : creationContext->CreationContext();
// The constructor and registered lifecycle callbacks should be visible only from main world.
// FIXME: This shouldn't be needed once each custom element has its own FunctionTemplate
// https://bugs.webkit.org/show_bug.cgi?id=108138
if (!CustomElementHelpers::isFeatureAllowed(context)) {
v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, &V8HTMLElement::info, impl.get(), isolate);
if (!wrapper.IsEmpty())
V8DOMWrapper::associateObjectWithWrapper(impl, &V8HTMLElement::info, wrapper, isolate, WrapperConfiguration::Dependent);
return wrapper;
}
CustomElementRegistry* registry = impl->document()->registry();
RefPtr<CustomElementDefinition> definition = registry->findFor(impl.get());
if (!definition)
return createUpgradeCandidateWrapper(impl, creationContext, isolate, createTypeExtensionUpgradeCandidateWrapper);
v8::Handle<v8::Object> prototype = V8PerContextData::from(context)->customElementPrototypes()->get(definition->type()).newLocal(isolate);
WrapperTypeInfo* typeInfo = CustomElementHelpers::findWrapperType(prototype);
if (!typeInfo) {
// FIXME: When can this happen?
return v8::Handle<v8::Object>();
}
v8::Handle<v8::Object> wrapper = V8DOMWrapper::createWrapper(creationContext, typeInfo, impl.get(), isolate);
if (wrapper.IsEmpty())
return v8::Handle<v8::Object>();
wrapper->SetPrototype(prototype);
V8DOMWrapper::associateObjectWithWrapper(impl, typeInfo, wrapper, isolate, WrapperConfiguration::Dependent);
return wrapper;
}