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


C++ JSDOMWindow::globalExec方法代码示例

本文整理汇总了C++中JSDOMWindow::globalExec方法的典型用法代码示例。如果您正苦于以下问题:C++ JSDOMWindow::globalExec方法的具体用法?C++ JSDOMWindow::globalExec怎么用?C++ JSDOMWindow::globalExec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JSDOMWindow的用法示例。


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

示例1: computedStyleIncludingVisitedInfo

JSValueRef WebFrame::computedStyleIncludingVisitedInfo(JSObjectRef element)
{
    if (!m_coreFrame)
        return 0;

#if USE(JSC)
    JSDOMWindow* globalObject = m_coreFrame->script()->globalObject(mainThreadNormalWorld());
    ExecState* exec = globalObject->globalExec();

    if (!toJS(element)->inherits(&JSElement::s_info))
        return JSValueMakeUndefined(toRef(exec));

    RefPtr<CSSComputedStyleDeclaration> style = CSSComputedStyleDeclaration::create(static_cast<JSElement*>(toJS(element))->impl(), true);

    JSLock lock(SilenceAssertionsOnly);
    return toRef(exec, toJS(exec, globalObject, style.get()));
#elif USE(V8)
    v8::HandleScope handleScope;
    Element* webElement = V8Element::toNative(toV8(element));
    if (!webElement)
        return 0;
    v8::Handle<v8::Value> wrapper = V8CSSStyleDeclaration::wrap(CSSComputedStyleDeclaration::create(webElement, true).leakRef(), 0);
    if (wrapper.IsEmpty())
        return 0;
    return toRef(wrapper);
#endif
}
开发者ID:,项目名称:,代码行数:27,代码来源:

示例2: addToJavaScriptWindowObject

void QWebFrameAdapter::addToJavaScriptWindowObject(const QString& name, QObject* object, ValueOwnership ownership)
{
    if (!pageAdapter->settings->testAttribute(QWebSettings::JavascriptEnabled))
        return;
    JSC::Bindings::QtInstance::ValueOwnership valueOwnership = static_cast<JSC::Bindings::QtInstance::ValueOwnership>(ownership);
    JSDOMWindow* window = toJSDOMWindow(frame, mainThreadNormalWorld());
    JSC::Bindings::RootObject* root;
    if (valueOwnership == JSC::Bindings::QtInstance::QtOwnership)
        root = frame->script()->cacheableBindingRootObject();
    else
        root = frame->script()->bindingRootObject();

    if (!window) {
        qDebug() << "Warning: couldn't get window object";
        return;
    }
    if (!root) {
        qDebug() << "Warning: couldn't get root object";
        return;
    }

    JSC::ExecState* exec = window->globalExec();
    JSC::JSLockHolder lock(exec);

    JSC::JSObject* runtimeObject = JSC::Bindings::QtInstance::getQtInstance(object, root, valueOwnership)->createRuntimeObject(exec);

    JSC::PutPropertySlot slot;
    window->methodTable()->put(window, exec, JSC::Identifier(&exec->globalData(), reinterpret_cast_ptr<const UChar*>(name.constData()), name.length()), runtimeObject, slot);
}
开发者ID:,项目名称:,代码行数:29,代码来源:

示例3: jsObjectForPluginElement

JSObject* ScriptController::jsObjectForPluginElement(HTMLPlugInElement* plugin)
{
    // Can't create JSObjects when JavaScript is disabled
    if (!canExecuteScripts(NotAboutToExecuteScript))
        return 0;

    // Create a JSObject bound to this element
    JSDOMWindow* globalObj = globalObject(pluginWorld());
    JSLockHolder lock(globalObj->globalExec());
    // FIXME: is normal okay? - used for NP plugins?
    JSValue jsElementValue = toJS(globalObj->globalExec(), globalObj, plugin);
    if (!jsElementValue || !jsElementValue.isObject())
        return 0;
    
    return jsElementValue.getObject();
}
开发者ID:,项目名称:,代码行数:16,代码来源:

示例4: lock

PassRefPtr<JSLazyEventListener> createAttributeEventListener(Node* node, Attribute* attr)
{
    ASSERT(node);

    Frame* frame = node->document()->frame();
    if (!frame)
        return 0;

    ScriptController* scriptController = frame->script();
    if (!scriptController->isEnabled())
        return 0;

    if (!scriptController->xssAuditor()->canCreateInlineEventListener(attr->localName().string(), attr->value())) {
        // This script is not safe to execute.
        return 0;
    }
    
    JSDOMWindow* globalObject = scriptController->globalObject();

    // Ensure that 'node' has a JavaScript wrapper to mark the event listener we're creating.
    {
        JSLock lock(SilenceAssertionsOnly);
        // FIXME: Should pass the global object associated with the node
        toJS(globalObject->globalExec(), globalObject, node);
    }

    return JSLazyEventListener::create(attr->localName().string(), eventParameterName(node->isSVGElement()), attr->value(), globalObject, node, scriptController->eventHandlerLineNumber());
}
开发者ID:boyliang,项目名称:ComponentSuperAccessor,代码行数:28,代码来源:ScriptEventListener.cpp

示例5: registerNativeJSObjectsToContext

int MDNativeBindingManager::registerNativeJSObjectsToContext(ScriptController *script, DOMWrapperWorld* world)
{
    DOMWrapperWorld* nativeWorld = (world)? world : mainThreadNormalWorld();
    JSDOMWindow*    window =  (script->globalObject(nativeWorld));
    //toJSDOMWindow
    JSContextRef context = reinterpret_cast<JSContextRef>(window->globalExec()); 
    JSObjectRef globalObject = JSContextGetGlobalObject(context);

    IMDNativeBindingObject *object = NULL;
    size_t size = m_jsTable.size();
    
    for (size_t i=0; i<size; i++) {
        object = m_jsTable.at(i);
        JSStringRef propertyName = object->propertyName(); //entry->m_propertyName;
        JSObjectSetProperty(
                context,
                globalObject,
                propertyName,
                object->propertyValue(context),
                kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete, NULL);

        JSStringRelease(propertyName);
    }

    return 0;
}
开发者ID:bytewang,项目名称:vitas,代码行数:26,代码来源:MDNativeBindingManager.cpp

示例6: attachExtensionObjectToFrame

// FIXME: Revisit the creation of this class and make sure this is the best way to approach it.
void attachExtensionObjectToFrame(Frame* frame, WebPageClient* client)
{
    JSC::JSLock lock(JSC::SilenceAssertionsOnly);

    JSDOMWindow* window = frame->script()->windowShell(mainThreadNormalWorld())->window();

    JSC::ExecState* exec = window->globalExec();
    JSContextRef scriptCtx = toRef(exec);

    JSClassDefinition definition = kJSClassDefinitionEmpty;
    definition.staticValues = clientExtensionStaticValues;
    definition.staticFunctions = clientExtensionStaticFunctions;
    definition.initialize = clientExtensionInitialize;
    definition.finalize = clientExtensionFinalize;
    JSClassRef clientClass = JSClassCreate(&definition);

    JSObjectRef clientClassObject = JSObjectMake(scriptCtx, clientClass, 0);
    JSObjectSetPrivate(clientClassObject, reinterpret_cast<void*>(client));

    JSC::UString name("qnx");

    JSC::PutPropertySlot slot;
    window->put(window, exec, JSC::Identifier(exec, name), toJS(clientClassObject), slot);

    JSClassRelease(clientClass);
}
开发者ID:Moondee,项目名称:Artemis,代码行数:27,代码来源:ClientExtension.cpp

示例7: jsWrapperForWorld

JSValueRef WebFrame::jsWrapperForWorld(InjectedBundleRangeHandle* rangeHandle, InjectedBundleScriptWorld* world)
{
    JSDOMWindow* globalObject = m_coreFrame->script()->globalObject(world->coreWorld());
    ExecState* exec = globalObject->globalExec();

    JSLock lock(SilenceAssertionsOnly);
    return toRef(exec, toJS(exec, globalObject, rangeHandle->coreRange()));
}
开发者ID:dankurka,项目名称:webkit_titanium,代码行数:8,代码来源:WebFrame.cpp

示例8: jsWrapperForWorld

JSValueRef WebFrame::jsWrapperForWorld(InjectedBundleRangeHandle* rangeHandle, InjectedBundleScriptWorld* world)
{
    if (!m_coreFrame)
        return 0;

    JSDOMWindow* globalObject = m_coreFrame->script().globalObject(world->coreWorld());
    ExecState* exec = globalObject->globalExec();

    JSLockHolder lock(exec);
    return toRef(exec, toJS(exec, globalObject, rangeHandle->coreRange()));
}
开发者ID:Happy-Ferret,项目名称:webkit.js,代码行数:11,代码来源:WebFrame.cpp

示例9: addToJSWindowObject

void WebFrame::addToJSWindowObject(const char* name, void *object)
{
    KJS::JSLock lock(false);
    JSDOMWindow *window = toJSDOMWindow(core(this));
    if (!window)
        return;
    KJS::Bindings::RootObject *root = core(this)->bindingRootObject();

    KJS::ExecState* exec = window->globalExec();
    KJS::JSObject *runtimeObject = KJS::Bindings::Instance::createRuntimeObject(exec, KJS::Bindings::BalInstance::create(static_cast<BalObject*>(object), root));

    window->put(exec, KJS::Identifier(exec, name), runtimeObject);
}
开发者ID:acss,项目名称:owb-mirror,代码行数:13,代码来源:WebFrame.cpp

示例10: resetInternalsObject

void DumpRenderTreeSupportQt::resetInternalsObject(QWebFrameAdapter* adapter)
{
    WebCore::Frame* coreFrame = adapter->frame;
    JSDOMWindow* window = toJSDOMWindow(coreFrame, mainThreadNormalWorld());
    Q_ASSERT(window);

    JSC::ExecState* exec = window->globalExec();
    Q_ASSERT(exec);
    JSC::JSLockHolder lock(exec);

    JSContextRef context = toRef(exec);
    WebCoreTestSupport::resetInternalsObject(context);
}
开发者ID:jbat100,项目名称:webkit,代码行数:13,代码来源:DumpRenderTreeSupportQt.cpp

示例11: jsWrapperForWorld

JSValueRef WebFrame::jsWrapperForWorld(InjectedBundleNodeHandle* nodeHandle, InjectedBundleScriptWorld* world)
{
#if 0 //CMP_ERROR_TODO InjectedBundle
    if (!m_coreFrame)
        return 0;

    JSDOMWindow* globalObject = m_coreFrame->script().globalObject(world->coreWorld());
    ExecState* exec = globalObject->globalExec();

    JSLockHolder lock(exec);
    return toRef(exec, toJS(exec, globalObject, nodeHandle->coreNode()));
#else
    return 0;
#endif
}
开发者ID:sinoory,项目名称:webv8,代码行数:15,代码来源:WebFrame.cpp

示例12: computedStyleIncludingVisitedInfo

JSValueRef WebFrame::computedStyleIncludingVisitedInfo(JSObjectRef element)
{
    if (!m_coreFrame)
        return 0;

    JSDOMWindow* globalObject = m_coreFrame->script()->globalObject(mainThreadNormalWorld());
    ExecState* exec = globalObject->globalExec();

    if (!toJS(element)->inherits(&JSElement::s_info))
        return JSValueMakeUndefined(toRef(exec));

    RefPtr<CSSComputedStyleDeclaration> style = computedStyle(static_cast<JSElement*>(toJS(element))->impl(), true);

    JSLock lock(SilenceAssertionsOnly);
    return toRef(exec, toJS(exec, globalObject, style.get()));
}
开发者ID:dankurka,项目名称:webkit_titanium,代码行数:16,代码来源:WebFrame.cpp

示例13: injectInternalsObject

void DumpRenderTreeSupportQt::injectInternalsObject(QWebFrame* frame)
{
    WebCore::Frame* coreFrame = QWebFramePrivate::core(frame);
#if USE(JSC)
    JSC::JSLock lock(JSC::SilenceAssertionsOnly);

    JSDOMWindow* window = toJSDOMWindow(coreFrame, mainThreadNormalWorld());
    Q_ASSERT(window);

    JSC::ExecState* exec = window->globalExec();
    Q_ASSERT(exec);

    JSContextRef context = toRef(exec);
    WebCoreTestSupport::injectInternalsObject(context);
#elif USE(V8)
    WebCoreTestSupport::injectInternalsObject(V8Proxy::mainWorldContext(coreFrame));
#endif
}
开发者ID:,项目名称:,代码行数:18,代码来源:

示例14: jsWrapperForWorld

JSValueRef WebFrame::jsWrapperForWorld(InjectedBundleRangeHandle* rangeHandle, InjectedBundleScriptWorld* world)
{
    if (!m_coreFrame)
        return 0;

#if USE(JSC)
    JSDOMWindow* globalObject = m_coreFrame->script()->globalObject(world->coreWorld());
    ExecState* exec = globalObject->globalExec();

    JSLock lock(SilenceAssertionsOnly);
    return toRef(exec, toJS(exec, globalObject, rangeHandle->coreRange()));
#elif USE(V8)
    v8::HandleScope handleScope;
    v8::Handle<v8::Value> wrapper = toV8(rangeHandle->coreRange());
    if (wrapper.IsEmpty())
        return 0;
    return toRef(wrapper);
#endif
}
开发者ID:,项目名称:,代码行数:19,代码来源:

示例15: addToJSWindowObject

void WebFrame::addToJSWindowObject(const char* name, void *object)
{
    JSC::JSLock lock(false);
    JSDOMWindow *window = toJSDOMWindow(core(this));
    if (!window)
        return;
    
    JSC::Bindings::RootObject *root = core(this)->script()->bindingRootObject();
    JSC::ExecState* exec = window->globalExec();
    JSC::PropertySlot pr;

    if (!window->getOwnPropertySlot(exec, JSC::Identifier(exec, name), pr)) {
        //printf("addToJSWindowObject %p name =%s ok \n", core(this), name);
        //JSC::JSObject *runtimeObject = JSC::Bindings::Instance::createRuntimeObject(exec, JSC::Bindings::BalInstance::create(static_cast<BalObject*>(object), root));
        JSC::JSObject *runtimeObject = JSC::Bindings::Instance::createRuntimeObject(exec, JSC::Bindings::BalInstance::getBalInstance(static_cast<BalObject*>(object), root));
        JSC::PutPropertySlot prop;
        window->put(exec, JSC::Identifier(exec, name), runtimeObject, prop);
    }
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:19,代码来源:WebFrame.cpp


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