本文整理汇总了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
}
示例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);
}
示例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();
}
示例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());
}
示例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;
}
示例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);
}
示例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()));
}
示例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()));
}
示例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);
}
示例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);
}
示例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
}
示例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()));
}
示例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
}
示例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
}
示例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);
}
}