当前位置: 首页>>代码示例>>C++>>正文


C++ V8PerContextData类代码示例

本文整理汇总了C++中V8PerContextData的典型用法代码示例。如果您正苦于以下问题:C++ V8PerContextData类的具体用法?C++ V8PerContextData怎么用?C++ V8PerContextData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了V8PerContextData类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ASSERT

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;
}
开发者ID:ericwilligers,项目名称:blink,代码行数:26,代码来源:CustomElementWrapper.cpp

示例2: ASSERT

v8::Local<v8::Object> V8DOMWrapper::createWrapper(v8::Isolate* isolate, v8::Local<v8::Object> creationContext, const WrapperTypeInfo* type, ScriptWrappable* scriptWrappable)
{
    ASSERT(!type->equals(&V8Window::wrapperTypeInfo));
    // According to https://html.spec.whatwg.org/multipage/browsers.html#security-location,
    // cross-origin script access to a few properties of Location is allowed.
    // Location already implements the necessary security checks.
    bool withSecurityCheck = !type->equals(&V8Location::wrapperTypeInfo);
    V8WrapperInstantiationScope scope(creationContext, isolate, withSecurityCheck);

    V8PerContextData* perContextData = V8PerContextData::from(scope.context());
    v8::Local<v8::Object> wrapper;
    if (perContextData) {
        wrapper = perContextData->createWrapperFromCache(type);
    } else {
        v8::Local<v8::Function> function;
        if (!type->domTemplate(isolate)->GetFunction(isolate->GetCurrentContext()).ToLocal(&function))
            return v8::Local<v8::Object>();
        if (!V8ObjectConstructor::newInstance(isolate, function).ToLocal(&wrapper))
            return v8::Local<v8::Object>();
    }

    if (type == &V8HTMLDocument::wrapperTypeInfo && !wrapper.IsEmpty())
        wrapper = wrapInShadowTemplate(wrapper, scriptWrappable, isolate);

    return wrapper;
}
开发者ID:howardroark2018,项目名称:chromium,代码行数:26,代码来源:V8DOMWrapper.cpp

示例3: TestInterfaceNamedConstructorConstructorGetter

static void TestInterfaceNamedConstructorConstructorGetter(v8::Local<v8::String>, const v8::PropertyCallbackInfo<v8::Value>& info)
{
    v8::Handle<v8::Value> data = info.Data();
    ASSERT(data->IsExternal());
    V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->CreationContext());
    if (!perContextData)
        return;
    v8SetReturnValue(info, perContextData->constructorForType(WrapperTypeInfo::unwrap(data)));
}
开发者ID:junmin-zhu,项目名称:blink,代码行数:9,代码来源:V8TestInterfaceNamedConstructor.cpp

示例4: scope

v8::Local<v8::Object> V8DOMWrapper::createWrapper(v8::Handle<v8::Object> creationContext, WrapperTypeInfo* type, void* impl, v8::Isolate* isolate)
{
    V8WrapperInstantiationScope scope(creationContext);

    V8PerContextData* perContextData = V8PerContextData::from(scope.context());
    v8::Local<v8::Object> wrapper = perContextData ? perContextData->createWrapperFromCache(type) : V8ObjectConstructor::newInstance(type->getTemplate(isolate, worldTypeInMainThread(isolate))->GetFunction());

    if (type == &V8HTMLDocument::info && !wrapper.IsEmpty())
        wrapper = wrapInShadowTemplate(wrapper, static_cast<Node*>(impl), isolate);

    return wrapper;
}
开发者ID:windyuuy,项目名称:opera,代码行数:12,代码来源:V8DOMWrapper.cpp

示例5:

V8DOMActivityLogger* V8DOMActivityLogger::currentActivityLogger()
{
    v8::Isolate* isolate = v8::Isolate::GetCurrent();
    if (!isolate->InContext())
        return 0;

    V8PerContextData* contextData = ScriptState::current(isolate)->perContextData();
    if (!contextData)
        return 0;

    return contextData->activityLogger();
}
开发者ID:ewilligers,项目名称:blink,代码行数:12,代码来源:V8DOMActivityLogger.cpp

示例6: creationContextData

bool V8CustomElementLifecycleCallbacks::setBinding(CustomElementDefinition* owner, PassOwnPtr<CustomElementBinding> binding)
{
    V8PerContextData* perContextData = creationContextData();
    if (!perContextData)
        return false;

    // The context is responsible for keeping the prototype
    // alive. This in turn keeps callbacks alive through hidden
    // references; see CALLBACK_LIST(SET_HIDDEN_VALUE).
    perContextData->addCustomElementBinding(owner, binding);
    return true;
}
开发者ID:azureplus,项目名称:chromium,代码行数:12,代码来源:V8CustomElementLifecycleCallbacks.cpp

示例7: scope

v8::Local<v8::Object> V8DOMWrapper::instantiateV8Object(v8::Handle<v8::Object> creationContext, WrapperTypeInfo* type, void* impl)
{
    V8WrapperInstantiationScope scope(creationContext);

    V8PerContextData* perContextData = V8PerContextData::from(scope.context());
    v8::Local<v8::Object> instance = perContextData ? perContextData->createWrapperFromCache(type) : V8ObjectConstructor::newInstance(type->getTemplate()->GetFunction());

    // Avoid setting the DOM wrapper for failed allocations.
    if (instance.IsEmpty())
        return instance;

    if (type == &V8HTMLDocument::info)
        instance = V8HTMLDocument::wrapInShadowObject(instance, static_cast<Node*>(impl));
    return instance;
}
开发者ID:twnin,项目名称:webkit,代码行数:15,代码来源:V8DOMWrapper.cpp

示例8: ASSERT

bool V8CustomElementLifecycleCallbacks::setBinding(CustomElementDefinition* owner, PassOwnPtr<CustomElementBinding> binding)
{
    ASSERT(!m_owner);

    V8PerContextData* perContextData = creationContextData();
    if (!perContextData)
        return false;

    m_owner = owner;

    // Bindings retrieve the prototype when needed from per-context data.
    perContextData->addCustomElementBinding(owner, binding);

    return true;
}
开发者ID:halton,项目名称:blink-crosswalk,代码行数:15,代码来源:V8CustomElementLifecycleCallbacks.cpp

示例9: handleScope

V8DOMActivityLogger* V8DOMActivityLogger::currentActivityLogger() {
  v8::Isolate* isolate = v8::Isolate::GetCurrent();
  if (!isolate->InContext())
    return 0;

  v8::HandleScope handleScope(isolate);
  v8::Local<v8::Context> context = isolate->GetCurrentContext();
  if (context.IsEmpty() || !toDOMWindow(context))
    return 0;

  V8PerContextData* contextData = ScriptState::from(context)->perContextData();
  if (!contextData)
    return 0;

  return contextData->activityLogger();
}
开发者ID:mirror,项目名称:chromium,代码行数:16,代码来源:V8DOMActivityLogger.cpp

示例10: scope

v8::Local<v8::Object> V8DOMWrapper::createWrapper(v8::Isolate* isolate, v8::Local<v8::Object> creationContext, const WrapperTypeInfo* type, ScriptWrappable* scriptWrappable)
{
    V8WrapperInstantiationScope scope(creationContext, isolate);

    V8PerContextData* perContextData = V8PerContextData::from(scope.context());
    v8::Local<v8::Object> wrapper;
    if (perContextData) {
        wrapper = perContextData->createWrapperFromCache(type);
    } else {
        v8::Local<v8::Function> function;
        if (!type->domTemplate(isolate)->GetFunction(isolate->GetCurrentContext()).ToLocal(&function))
            return v8::Local<v8::Object>();
        if (!V8ObjectConstructor::newInstance(isolate, function).ToLocal(&wrapper))
            return v8::Local<v8::Object>();
    }

    if (type == &V8HTMLDocument::wrapperTypeInfo && !wrapper.IsEmpty())
        wrapper = wrapInShadowTemplate(wrapper, scriptWrappable, isolate);

    return wrapper;
}
开发者ID:alexanderbill,项目名称:blink-crosswalk,代码行数:21,代码来源:V8DOMWrapper.cpp


注:本文中的V8PerContextData类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。