本文整理汇总了C++中V8Proxy类的典型用法代码示例。如果您正苦于以下问题:C++ V8Proxy类的具体用法?C++ V8Proxy怎么用?C++ V8Proxy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了V8Proxy类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ASSERT
short V8NodeFilterCondition::acceptNode(ScriptState* state, Node* node) const
{
ASSERT(v8::Context::InContext());
if (!m_filter->IsFunction())
return NodeFilter::FILTER_ACCEPT;
v8::TryCatch exceptionCatcher;
v8::Handle<v8::Object> object = v8::Context::GetCurrent()->Global();
v8::Handle<v8::Function> callback = v8::Handle<v8::Function>::Cast(m_filter);
OwnArrayPtr<v8::Handle<v8::Value> > args(new v8::Handle<v8::Value>[1]);
args[0] = toV8(node);
V8Proxy* proxy = V8Proxy::retrieve();
ASSERT(proxy);
v8::Handle<v8::Value> result = proxy->callFunction(callback, object, 1, args.get());
if (exceptionCatcher.HasCaught()) {
state->setException(exceptionCatcher.Exception());
return NodeFilter::FILTER_REJECT;
}
ASSERT(!result.IsEmpty());
return result->Int32Value();
}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:28,代码来源:V8NodeFilterCondition.cpp
示例2: _NPN_EvaluateHelper
bool _NPN_EvaluateHelper(NPP npp, bool popupsAllowed, NPObject* npObject, NPString* npScript, NPVariant* result)
{
VOID_TO_NPVARIANT(*result);
if (!npObject)
return false;
if (npObject->_class != npScriptObjectClass)
return false;
v8::HandleScope handleScope;
v8::Handle<v8::Context> context = toV8Context(npp, npObject);
if (context.IsEmpty())
return false;
V8Proxy* proxy = toV8Proxy(npObject);
ASSERT(proxy);
v8::Context::Scope scope(context);
WebCore::String filename;
if (!popupsAllowed)
filename = "npscript";
WebCore::String script = WebCore::String::fromUTF8(npScript->UTF8Characters, npScript->UTF8Length);
v8::Local<v8::Value> v8result = proxy->evaluate(WebCore::ScriptSourceCode(script, WebCore::KURL(WebCore::ParsedURLString, filename)), 0);
if (v8result.IsEmpty())
return false;
convertV8ObjectToNPVariant(v8result, npObject, result);
return true;
}
开发者ID:Androtos,项目名称:toolchain_benchmark,代码行数:32,代码来源:NPV8Object.cpp
示例3: scriptExecutionContext
void V8CustomPositionErrorCallback::handleEvent(PositionError* error)
{
v8::HandleScope handleScope;
// ActiveDOMObject will null our pointer to the ScriptExecutionContext when it goes away.
ScriptExecutionContext* scriptContext = scriptExecutionContext();
if (!scriptContext)
return;
// The lookup of the proxy will fail if the Frame has been detached.
V8Proxy* proxy = V8Proxy::retrieve(scriptContext);
if (!proxy)
return;
v8::Handle<v8::Context> context = proxy->context();
if (context.IsEmpty())
return;
v8::Context::Scope scope(context);
v8::Handle<v8::Value> argv[] = {
toV8(error)
};
// Protect the script context until the callback returns.
RefPtr<ScriptExecutionContext> protector(scriptContext);
bool callbackReturnValue = false;
invokeCallback(m_callback, 1, argv, callbackReturnValue, scriptContext);
}
开发者ID:0omega,项目名称:platform_external_webkit,代码行数:30,代码来源:V8CustomPositionErrorCallback.cpp
示例4: PLATFORM
bool V8Proxy::handleOutOfMemory()
{
v8::Local<v8::Context> context = v8::Context::GetCurrent();
if (!context->HasOutOfMemoryException())
return false;
// Warning, error, disable JS for this frame?
Frame* frame = V8Proxy::retrieveFrame(context);
V8Proxy* proxy = V8Proxy::retrieve(frame);
if (proxy) {
// Clean m_context, and event handlers.
proxy->clearForClose();
proxy->windowShell()->destroyGlobal();
}
#if PLATFORM(CHROMIUM)
PlatformBridge::notifyJSOutOfMemory(frame);
#endif
// Disable JS.
Settings* settings = frame->settings();
ASSERT(settings);
settings->setJavaScriptEnabled(false);
return true;
}
开发者ID:besk,项目名称:MT6589_kernel_source,代码行数:29,代码来源:V8Proxy.cpp
示例5: logInfo
String V8CustomXPathNSResolver::lookupNamespaceURI(const String& prefix)
{
v8::Handle<v8::Function> lookupNamespaceURIFunc;
v8::Handle<v8::String> lookupNamespaceURIName = v8::String::New("lookupNamespaceURI");
// Check if the resolver has a function property named lookupNamespaceURI.
if (m_resolver->Has(lookupNamespaceURIName)) {
v8::Handle<v8::Value> lookupNamespaceURI = m_resolver->Get(lookupNamespaceURIName);
if (lookupNamespaceURI->IsFunction())
lookupNamespaceURIFunc = v8::Handle<v8::Function>::Cast(lookupNamespaceURI);
}
if (lookupNamespaceURIFunc.IsEmpty() && !m_resolver->IsFunction()) {
Frame* frame = V8Proxy::retrieveFrameForEnteredContext();
logInfo(frame, "XPathNSResolver does not have a lookupNamespaceURI method.", String());
return String();
}
// Catch exceptions from calling the namespace resolver.
v8::TryCatch try_catch;
try_catch.SetVerbose(true); // Print exceptions to console.
const int argc = 1;
v8::Handle<v8::Value> argv[argc] = { v8String(prefix) };
v8::Handle<v8::Function> function = lookupNamespaceURIFunc.IsEmpty() ? v8::Handle<v8::Function>::Cast(m_resolver) : lookupNamespaceURIFunc;
V8Proxy* proxy = V8Proxy::retrieve();
v8::Handle<v8::Value> retval = proxy->callFunction(function, m_resolver, argc, argv);
// Eat exceptions from namespace resolver and return an empty string. This will most likely cause NAMESPACE_ERR.
if (try_catch.HasCaught())
return String();
return toWebCoreStringWithNullCheck(retval);
}
开发者ID:boyliang,项目名称:ComponentSuperAccessor,代码行数:35,代码来源:V8CustomXPathNSResolver.cpp
示例6: invokeCallback
bool invokeCallback(v8::Persistent<v8::Object> callback, int argc, v8::Handle<v8::Value> argv[], bool& callbackReturnValue)
{
// FIXME: If an exception was thrown by the callback, we should report it
v8::TryCatch exceptionCatcher;
v8::Local<v8::Function> callbackFunction;
if (callback->IsFunction()) {
callbackFunction = v8::Local<v8::Function>::New(v8::Persistent<v8::Function>::Cast(callback));
} else if (callback->IsObject()) {
v8::Local<v8::Value> handleEventFunction = callback->Get(v8::String::NewSymbol("handleEvent"));
if (handleEventFunction->IsFunction()) {
callbackFunction = v8::Local<v8::Function>::Cast(handleEventFunction);
}
} else
return false;
if (callbackFunction.IsEmpty())
return false;
v8::Handle<v8::Object> thisObject = v8::Context::GetCurrent()->Global();
V8Proxy* proxy = V8Proxy::retrieve();
ASSERT(proxy);
v8::Handle<v8::Value> result = proxy->CallFunction(callbackFunction, thisObject, argc, argv);
callbackReturnValue = result.IsEmpty() && result->IsBoolean() && result->BooleanValue();
return exceptionCatcher.HasCaught();
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:30,代码来源:V8CustomVoidCallback.cpp
示例7: getDOMNodeMap
v8::Handle<v8::Object> V8EntityReference::wrap(EntityReference* impl, bool forceNewObject) {
v8::Handle<v8::Object> wrapper;
V8Proxy* proxy = 0;
if (impl->document()) {
proxy = V8Proxy::retrieve(impl->document()->frame());
if (proxy && static_cast<Node*>(impl->document()) == static_cast<Node*>(impl))
proxy->windowShell()->initContextIfNeeded();
}
if (!forceNewObject) {
wrapper = V8DOMWrapper::getWrapper(impl);
if (!wrapper.IsEmpty())
return wrapper;
}
v8::Handle<v8::Context> context;
if (proxy)
context = proxy->context();
// Enter the node's context and create the wrapper in that context.
if (!context.IsEmpty())
context->Enter();
wrapper = V8DOMWrapper::instantiateV8Object(proxy, V8ClassIndex::ENTITYREFERENCE, impl);
// Exit the node's context if it was entered.
if (!context.IsEmpty())
context->Exit();
if (wrapper.IsEmpty())
return wrapper;
impl->ref();
getDOMNodeMap().set(impl, v8::Persistent<v8::Object>::New(wrapper));
return wrapper;
}
开发者ID:,项目名称:,代码行数:33,代码来源:
示例8:
v8::Handle<v8::Object> V8TestNode::wrapSlow(PassRefPtr<TestNode> impl, v8::Isolate* isolate)
{
v8::Handle<v8::Object> wrapper;
V8Proxy* proxy = V8Proxy::retrieve(impl->document()->frame());
// Enter the node's context and create the wrapper in that context.
v8::Handle<v8::Context> context;
if (proxy && !proxy->matchesCurrentContext()) {
// For performance, we enter the context only if the currently running context
// is different from the context that we are about to enter.
context = proxy->context();
if (!context.IsEmpty())
context->Enter();
}
wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl.get());
// Exit the node's context if it was entered.
if (!context.IsEmpty())
context->Exit();
if (UNLIKELY(wrapper.IsEmpty()))
return wrapper;
v8::Persistent<v8::Object> wrapperHandle = v8::Persistent<v8::Object>::New(wrapper);
if (!hasDependentLifetime)
wrapperHandle.MarkIndependent();
wrapperHandle.SetWrapperClassId(v8DOMSubtreeClassId);
V8DOMWrapper::setJSWrapperForDOMNode(impl, wrapperHandle, isolate);
return wrapper;
}
开发者ID:dzhshf,项目名称:WebKit,代码行数:29,代码来源:V8TestNode.cpp
示例9: getDOMNodeMap
v8::Handle<v8::Object> V8SVGFEFuncAElement::wrap(SVGFEFuncAElement* impl)
{
v8::Handle<v8::Object> wrapper;
V8Proxy* proxy = 0;
if (impl->document()) {
proxy = V8Proxy::retrieve(impl->document()->frame());
if (proxy && static_cast<Node*>(impl->document()) == static_cast<Node*>(impl))
proxy->windowShell()->initContextIfNeeded();
}
wrapper = V8DOMWrapper::getWrapper(impl);
if (!wrapper.IsEmpty())
return wrapper;
v8::Handle<v8::Context> context;
if (proxy)
context = proxy->context();
// Enter the node's context and create the wrapper in that context.
if (!context.IsEmpty())
context->Enter();
wrapper = V8DOMWrapper::instantiateV8Object(proxy, &info, impl);
// Exit the node's context if it was entered.
if (!context.IsEmpty())
context->Exit();
if (wrapper.IsEmpty())
return wrapper;
impl->ref();
getDOMNodeMap().set(impl, v8::Persistent<v8::Object>::New(wrapper));
return wrapper;
}
开发者ID:Treeeater,项目名称:chrome_bindings,代码行数:32,代码来源:V8SVGFEFuncAElement.cpp
示例10: retrieve
v8::Local<v8::Context> V8Proxy::mainWorldContext(Frame* frame)
{
V8Proxy* proxy = retrieve(frame);
if (!proxy)
return v8::Local<v8::Context>();
return proxy->mainWorldContext();
}
开发者ID:besk,项目名称:MT6589_kernel_source,代码行数:8,代码来源:V8Proxy.cpp
示例11: retrieve
v8::Local<v8::Context> V8Proxy::mainWorldContext(Frame* frame)
{
V8Proxy* proxy = retrieve(frame);
if (!proxy)
return v8::Local<v8::Context>();
proxy->initContextIfNeeded();
return v8::Local<v8::Context>::New(proxy->context());
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:9,代码来源:V8Proxy.cpp
示例12: ASSERT
V8ObjectEventListener::~V8ObjectEventListener()
{
if (m_frame) {
ASSERT(!m_listener.IsEmpty());
V8Proxy* proxy = V8Proxy::retrieve(m_frame);
if (proxy)
proxy->objectListeners()->remove(this);
}
disposeListenerObject();
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:11,代码来源:V8ObjectEventListener.cpp
示例13: contextScope
void ScriptCachedFrameData::restore(Frame* frame)
{
if (m_context.get().IsEmpty())
return;
v8::HandleScope handleScope;
v8::Context::Scope contextScope(m_context.get());
m_context.get()->ReattachGlobal(m_global.get());
V8Proxy* proxy = V8Proxy::retrieve(frame);
if (proxy)
proxy->windowShell()->setContext(m_context.get());
}
开发者ID:Treeeater,项目名称:WebPermission,代码行数:13,代码来源:ScriptCachedFrameData.cpp
示例14: exceptionCatcher
String JSNSResolver::lookupNamespaceURI(ExceptionContext* exceptionContext,
const String& prefix)
{
v8::Handle<v8::Function> lookupNamespaceURIFunc;
v8::Handle<v8::String> lookupNamespaceURIName =
v8::String::New("lookupNamespaceURI");
// Check if the resolver has a function property named lookupNamespaceURI.
if (m_resolver->Has(lookupNamespaceURIName)) {
// In case the property is a getter that throws an error,
// see LayoutTests/fast/dom/SelectorAPI/NSResolver-exceptions.xhtml
ExceptionCatcher exceptionCatcher(exceptionContext);
v8::Handle<v8::Value> lookupNamespaceURI = m_resolver->Get(
lookupNamespaceURIName);
if (exceptionContext->hadException())
return String();
if (lookupNamespaceURI->IsFunction()) {
lookupNamespaceURIFunc = v8::Handle<v8::Function>::Cast(
lookupNamespaceURI);
}
}
if (lookupNamespaceURIFunc.IsEmpty() && !m_resolver->IsFunction()) {
Frame* frame = ScriptController::retrieveActiveFrame();
log_info(frame, "NSResolver does not have a lookupNamespaceURI method.",
String());
return String();
}
// Catch exceptions from calling the namespace resolver.
ExceptionCatcher exceptionCatcher(exceptionContext);
const int argc = 1;
v8::Handle<v8::Value> argv[argc] = { v8String(prefix) };
v8::Handle<v8::Function> function = lookupNamespaceURIFunc.IsEmpty()
? v8::Handle<v8::Function>::Cast(m_resolver)
: lookupNamespaceURIFunc;
V8Proxy* proxy = V8Proxy::retrieve();
v8::Handle<v8::Value> retval = proxy->CallFunction(function, m_resolver,
argc, argv);
// Eat exceptions from namespace resolver and return an empty string. This
// will cause NAMESPACE_ERR.
if (exceptionContext->hadException())
return String();
return valueToStringWithNullOrUndefinedCheck(retval);
}
开发者ID:,项目名称:,代码行数:49,代码来源:
示例15: processingUserGesture
bool ScriptController::processingUserGesture(DOMWrapperWorld*) const
{
Frame* activeFrame = V8Proxy::retrieveFrameForEnteredContext();
// No script is running, so it is user-initiated unless the gesture stack
// explicitly says it is not.
if (!activeFrame)
return UserGestureIndicator::getUserGestureState() != DefinitelyNotProcessingUserGesture;
V8Proxy* activeProxy = activeFrame->script()->proxy();
v8::HandleScope handleScope;
v8::Handle<v8::Context> v8Context = V8Proxy::mainWorldContext(activeFrame);
// FIXME: find all cases context can be empty:
// 1) JS is disabled;
// 2) page is NULL;
if (v8Context.IsEmpty())
return true;
v8::Context::Scope scope(v8Context);
v8::Handle<v8::Object> global = v8Context->Global();
v8::Handle<v8::Value> jsEvent = global->Get(v8::String::NewSymbol("event"));
Event* event = V8DOMWrapper::isValidDOMObject(jsEvent) ? V8Event::toNative(v8::Handle<v8::Object>::Cast(jsEvent)) : 0;
// Based on code from kjs_bindings.cpp.
// Note: This is more liberal than Firefox's implementation.
if (event) {
if (!UserGestureIndicator::processingUserGesture())
return false;
const AtomicString& type = event->type();
bool eventOk =
// mouse events
type == eventNames().clickEvent || type == eventNames().mousedownEvent || type == eventNames().mouseupEvent || type == eventNames().dblclickEvent
// keyboard events
|| type == eventNames().keydownEvent || type == eventNames().keypressEvent || type == eventNames().keyupEvent
// other accepted events
|| type == eventNames().selectEvent || type == eventNames().changeEvent || type == eventNames().focusEvent || type == eventNames().blurEvent || type == eventNames().submitEvent;
if (eventOk)
return true;
} else if (m_sourceURL && m_sourceURL->isNull() && !activeProxy->timerCallback()) {
// This is the <a href="javascript:window.open('...')> case -> we let it through.
return true;
}
// This is the <script>window.open(...)</script> case or a timer callback -> block it.
return false;
}
开发者ID:mikedougherty,项目名称:webkit,代码行数:49,代码来源:ScriptController.cpp
示例16:
// static
v8::Handle<v8::Value> WebDevToolsAgentImpl::jsEvaluateOnSelf(const v8::Arguments& args)
{
String code;
{
v8::TryCatch exceptionCatcher;
code = WebCore::toWebCoreStringWithNullCheck(args[0]);
if (code.isEmpty() || exceptionCatcher.HasCaught())
return v8::Undefined();
}
WebDevToolsAgentImpl* agent = static_cast<WebDevToolsAgentImpl*>(v8::External::Cast(*args.Data())->Value());
v8::Context::Scope(agent->m_utilityContext);
V8Proxy* proxy = V8Proxy::retrieve(agent->m_webViewImpl->page()->mainFrame());
v8::Local<v8::Value> result = proxy->runScript(v8::Script::Compile(v8::String::New(code.utf8().data())), true);
return result;
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:16,代码来源:WebDevToolsAgentImpl.cpp
示例17: processingUserGesture
bool ScriptController::processingUserGesture() const
{
Frame* activeFrame = V8Proxy::retrieveFrameForEnteredContext();
// No script is running, so it must be run by users.
if (!activeFrame)
return true;
V8Proxy* activeProxy = activeFrame->script()->proxy();
v8::HandleScope handleScope;
v8::Handle<v8::Context> v8Context = V8Proxy::mainWorldContext(activeFrame);
// FIXME: find all cases context can be empty:
// 1) JS is disabled;
// 2) page is NULL;
if (v8Context.IsEmpty())
return true;
v8::Context::Scope scope(v8Context);
v8::Handle<v8::Object> global = v8Context->Global();
v8::Handle<v8::Value> jsEvent = global->Get(v8::String::NewSymbol("event"));
Event* event = V8DOMWrapper::convertToNativeEvent(jsEvent);
// Based on code from kjs_bindings.cpp.
// Note: This is more liberal than Firefox's implementation.
if (event) {
if (event->createdByDOM())
return false;
const AtomicString& type = event->type();
bool eventOk =
// mouse events
type == eventNames().clickEvent || type == eventNames().mousedownEvent || type == eventNames().mouseupEvent || type == eventNames().dblclickEvent
// keyboard events
|| type == eventNames().keydownEvent || type == eventNames().keypressEvent || type == eventNames().keyupEvent
// other accepted events
|| type == eventNames().selectEvent || type == eventNames().changeEvent || type == eventNames().focusEvent || type == eventNames().blurEvent || type == eventNames().submitEvent;
if (eventOk)
return true;
} else if (activeProxy->inlineCode() && !activeProxy->timerCallback()) {
// This is the <a href="javascript:window.open('...')> case -> we let it through.
return true;
}
// This is the <script>window.open(...)</script> case or a timer callback -> block it.
return false;
}
开发者ID:Androtos,项目名称:toolchain_benchmark,代码行数:48,代码来源:ScriptController.cpp
示例18:
PassRefPtr<SharedPersistent<v8::Context> > V8Proxy::shared_context(Frame* frame)
{
V8Proxy *proxy = V8Proxy::retrieve(frame);
if (!proxy)
return 0;
proxy->initContextIfNeeded();
RefPtr<SharedPersistent<v8::Context> > context = proxy->shared_context();
if (V8IsolatedWorld* world = V8IsolatedWorld::getEntered()) {
context = world->shared_context();
if (frame != V8Proxy::retrieveFrame(context->get()))
return 0;
}
return context;
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:16,代码来源:V8Proxy.cpp
示例19: _NPN_InvokeDefault
// FIXME: Fix it same as _NPN_Invoke (HandleScope and such).
bool _NPN_InvokeDefault(NPP npp, NPObject* npObject, const NPVariant* arguments, uint32_t argumentCount, NPVariant* result)
{
if (!npObject)
return false;
if (npObject->_class != npScriptObjectClass) {
if (npObject->_class->invokeDefault)
return npObject->_class->invokeDefault(npObject, arguments, argumentCount, result);
VOID_TO_NPVARIANT(*result);
return true;
}
V8NPObject* v8NpObject = reinterpret_cast<V8NPObject*>(npObject);
VOID_TO_NPVARIANT(*result);
v8::HandleScope handleScope;
v8::Handle<v8::Context> context = toV8Context(npp, npObject);
if (context.IsEmpty())
return false;
v8::Context::Scope scope(context);
ExceptionCatcher exceptionCatcher;
// Lookup the function object and call it.
v8::Handle<v8::Object> functionObject(v8NpObject->v8Object);
if (!functionObject->IsFunction())
return false;
v8::Local<v8::Value> resultObject;
v8::Handle<v8::Function> function(v8::Function::Cast(*functionObject));
if (!function->IsNull()) {
V8Proxy* proxy = toV8Proxy(npObject);
ASSERT(proxy);
OwnArrayPtr<v8::Handle<v8::Value> > argv(createValueListFromVariantArgs(arguments, argumentCount, npObject));
resultObject = proxy->callFunction(function, functionObject, argumentCount, argv.get());
}
// If we had an error, return false. The spec is a little unclear here, but says "Returns true if the method was
// successfully invoked". If we get an error return value, was that successfully invoked?
if (resultObject.IsEmpty())
return false;
convertV8ObjectToNPVariant(resultObject, npObject, result);
return true;
}
开发者ID:achellies,项目名称:WinCEWebKit,代码行数:48,代码来源:NPV8Object.cpp
示例20: weakObjectEventListenerCallback
static void weakObjectEventListenerCallback(v8::Persistent<v8::Value>, void* parameter)
{
V8ObjectEventListener* listener = static_cast<V8ObjectEventListener*>(parameter);
// Remove the wrapper
Frame* frame = listener->frame();
if (frame) {
V8Proxy* proxy = V8Proxy::retrieve(frame);
if (proxy)
proxy->objectListeners()->remove(listener);
// Because the listener is no longer in the list, it must be disconnected from the frame to avoid dangling frame pointer
// in the destructor.
listener->disconnectFrame();
}
listener->disposeListenerObject();
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:17,代码来源:V8ObjectEventListener.cpp
注:本文中的V8Proxy类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论