本文整理汇总了C++中OwnArrayPtr::get方法的典型用法代码示例。如果您正苦于以下问题:C++ OwnArrayPtr::get方法的具体用法?C++ OwnArrayPtr::get怎么用?C++ OwnArrayPtr::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OwnArrayPtr
的用法示例。
在下文中一共展示了OwnArrayPtr::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: throwTypeError
void V8HTMLDocument::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
{
HTMLDocument* htmlDocument = V8HTMLDocument::toNative(args.Holder());
if (args.Length() > 2) {
if (RefPtr<Frame> frame = htmlDocument->frame()) {
// Fetch the global object for the frame.
v8::Local<v8::Context> context = frame->script()->currentWorldContext();
// Bail out if we cannot get the context.
if (context.IsEmpty())
return;
v8::Local<v8::Object> global = context->Global();
// Get the open property of the global object.
v8::Local<v8::Value> function = global->Get(v8::String::NewSymbol("open"));
// If the open property is not a function throw a type error.
if (!function->IsFunction()) {
throwTypeError("open is not a function", args.GetIsolate());
return;
}
// Wrap up the arguments and call the function.
OwnArrayPtr<v8::Local<v8::Value> > params = adoptArrayPtr(new v8::Local<v8::Value>[args.Length()]);
for (int i = 0; i < args.Length(); i++)
params[i] = args[i];
v8SetReturnValue(args, frame->script()->callFunction(v8::Local<v8::Function>::Cast(function), global, args.Length(), params.get()));
return;
}
}
htmlDocument->open(activeDOMWindow()->document());
v8SetReturnValue(args, args.Holder());
}
示例2: getGDKKeySymForKeyRef
int getGDKKeySymForKeyRef(WKStringRef keyRef, unsigned location, guint* modifiers)
{
if (location == DOMKeyLocationNumpad) {
if (WKStringIsEqualToUTF8CString(keyRef, "leftArrow"))
return GDK_KEY_KP_Left;
if (WKStringIsEqualToUTF8CString(keyRef, "rightArror"))
return GDK_KEY_KP_Right;
if (WKStringIsEqualToUTF8CString(keyRef, "upArrow"))
return GDK_KEY_KP_Up;
if (WKStringIsEqualToUTF8CString(keyRef, "downArrow"))
return GDK_KEY_KP_Down;
if (WKStringIsEqualToUTF8CString(keyRef, "pageUp"))
return GDK_KEY_KP_Page_Up;
if (WKStringIsEqualToUTF8CString(keyRef, "pageDown"))
return GDK_KEY_KP_Page_Down;
if (WKStringIsEqualToUTF8CString(keyRef, "home"))
return GDK_KEY_KP_Home;
if (WKStringIsEqualToUTF8CString(keyRef, "end"))
return GDK_KEY_KP_End;
if (WKStringIsEqualToUTF8CString(keyRef, "insert"))
return GDK_KEY_KP_Insert;
if (WKStringIsEqualToUTF8CString(keyRef, "delete"))
return GDK_KEY_KP_Delete;
return GDK_KEY_VoidSymbol;
}
if (WKStringIsEqualToUTF8CString(keyRef, "leftArrow"))
return GDK_KEY_Left;
if (WKStringIsEqualToUTF8CString(keyRef, "rightArrow"))
return GDK_KEY_Right;
if (WKStringIsEqualToUTF8CString(keyRef, "upArrow"))
return GDK_KEY_Up;
if (WKStringIsEqualToUTF8CString(keyRef, "downArrow"))
return GDK_KEY_Down;
if (WKStringIsEqualToUTF8CString(keyRef, "pageUp"))
return GDK_KEY_Page_Up;
if (WKStringIsEqualToUTF8CString(keyRef, "pageDown"))
return GDK_KEY_Page_Down;
if (WKStringIsEqualToUTF8CString(keyRef, "home"))
return GDK_KEY_Home;
if (WKStringIsEqualToUTF8CString(keyRef, "end"))
return GDK_KEY_End;
if (WKStringIsEqualToUTF8CString(keyRef, "insert"))
return GDK_KEY_Insert;
if (WKStringIsEqualToUTF8CString(keyRef, "delete"))
return GDK_KEY_Delete;
if (WKStringIsEqualToUTF8CString(keyRef, "printScreen"))
return GDK_KEY_Print;
if (WKStringIsEqualToUTF8CString(keyRef, "menu"))
return GDK_KEY_Menu;
if (WKStringIsEqualToUTF8CString(keyRef, "F1"))
return GDK_KEY_F1;
if (WKStringIsEqualToUTF8CString(keyRef, "F2"))
return GDK_KEY_F2;
if (WKStringIsEqualToUTF8CString(keyRef, "F3"))
return GDK_KEY_F3;
if (WKStringIsEqualToUTF8CString(keyRef, "F4"))
return GDK_KEY_F4;
if (WKStringIsEqualToUTF8CString(keyRef, "F5"))
return GDK_KEY_F5;
if (WKStringIsEqualToUTF8CString(keyRef, "F6"))
return GDK_KEY_F6;
if (WKStringIsEqualToUTF8CString(keyRef, "F7"))
return GDK_KEY_F7;
if (WKStringIsEqualToUTF8CString(keyRef, "F8"))
return GDK_KEY_F8;
if (WKStringIsEqualToUTF8CString(keyRef, "F9"))
return GDK_KEY_F9;
if (WKStringIsEqualToUTF8CString(keyRef, "F10"))
return GDK_KEY_F10;
if (WKStringIsEqualToUTF8CString(keyRef, "F11"))
return GDK_KEY_F11;
if (WKStringIsEqualToUTF8CString(keyRef, "F12"))
return GDK_KEY_F12;
size_t bufferSize = WKStringGetMaximumUTF8CStringSize(keyRef);
OwnArrayPtr<char> buffer = adoptArrayPtr(new char[bufferSize]);
WKStringGetUTF8CString(keyRef, buffer.get(), bufferSize);
char charCode = buffer.get()[0];
if (charCode == '\n' || charCode == '\r')
return GDK_KEY_Return;
if (charCode == '\t')
return GDK_KEY_Tab;
if (charCode == '\x8')
return GDK_KEY_BackSpace;
if (WTF::isASCIIUpper(charCode))
*modifiers |= GDK_SHIFT_MASK;
return gdk_unicode_to_keyval(static_cast<guint32>(buffer.get()[0]));
}
示例3: invokeMethod
JavaValue JavaInstance::invokeMethod(const JavaMethod* method, JavaValue* args)
{
ASSERT(getClass()->methodsNamed(method->name().utf8().data()).find(method) != notFound);
unsigned int numParams = method->numParameters();
OwnArrayPtr<jvalue> jvalueArgs = adoptArrayPtr(new jvalue[numParams]);
for (unsigned int i = 0; i < numParams; ++i)
jvalueArgs[i] = javaValueToJvalue(args[i]);
jvalue result = callJNIMethod(javaInstance(), method->returnType(), method->name().utf8().data(), method->signature(), jvalueArgs.get());
return jvalueToJavaValue(result, method->returnType());
}
示例4: call
ScriptValue ScriptFunctionCall::call(bool& hadException, bool reportExceptions)
{
ScriptScope scope(m_scriptState, reportExceptions);
v8::Handle<v8::Object> thisObject = m_thisObject.v8Object();
v8::Local<v8::Value> value = thisObject->Get(v8String(m_name, m_scriptState->isolate()));
if (!scope.success()) {
hadException = true;
return ScriptValue();
}
ASSERT(value->IsFunction());
v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(value);
OwnArrayPtr<v8::Handle<v8::Value> > args = adoptArrayPtr(new v8::Handle<v8::Value>[m_arguments.size()]);
for (size_t i = 0; i < m_arguments.size(); ++i) {
args[i] = m_arguments[i].v8Value();
ASSERT(!args[i].IsEmpty());
}
v8::Local<v8::Value> result = V8ScriptRunner::callFunction(function, getScriptExecutionContext(), thisObject, m_arguments.size(), args.get());
if (!scope.success()) {
hadException = true;
return ScriptValue();
}
return ScriptValue(result);
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_external_chromium_org_third_party_WebKit,代码行数:28,代码来源:ScriptFunctionCall.cpp
示例5: invokeMethod
// ANDROID
JavaValue JavaInstanceJobject::invokeMethod(const JavaMethod* method, JavaValue* args, bool& didRaiseUncaughtException)
{
didRaiseUncaughtException = false;
// END ANDROID
ASSERT(getClass()->methodsNamed(method->name().utf8().data()).find(method) != notFound);
unsigned int numParams = method->numParameters();
OwnArrayPtr<jvalue> jvalueArgs = adoptArrayPtr(new jvalue[numParams]);
for (unsigned int i = 0; i < numParams; ++i)
jvalueArgs[i] = javaValueToJvalue(args[i]);
jvalue result = callJNIMethod(javaInstance(), method->returnType(), method->name().utf8().data(), method->signature(), jvalueArgs.get());
// ANDROID
JNIEnv* env = getJNIEnv();
if (env->ExceptionCheck() != JNI_FALSE) {
env->ExceptionClear();
didRaiseUncaughtException = true;
return JavaValue();
}
return jvalueToJavaValue(result, method->returnType());
// END ANDROID
}
示例6: dumpImage
void TestShell::dumpImage(SkCanvas* canvas) const
{
// Fix the alpha. The expected PNGs on Mac have an alpha channel, so we want
// to keep it. On Windows, the alpha channel is wrong since text/form control
// drawing may have erased it in a few places. So on Windows we force it to
// opaque and also don't write the alpha channel for the reference. Linux
// doesn't have the wrong alpha like Windows, but we match Windows.
#if OS(MAC_OS_X)
bool discardTransparency = false;
#else
bool discardTransparency = true;
makeCanvasOpaque(canvas);
#endif
const SkBitmap& sourceBitmap = canvas->getTopDevice()->accessBitmap(false);
SkAutoLockPixels sourceBitmapLock(sourceBitmap);
// Compute MD5 sum.
MD5 digester;
Vector<uint8_t, 16> digestValue;
#if OS(ANDROID)
// On Android, pixel layout is RGBA (see third_party/skia/include/core/SkColorPriv.h);
// however, other Chrome platforms use BGRA (see skia/config/SkUserConfig.h).
// To match the checksum of other Chrome platforms, we need to reorder the layout of pixels.
// NOTE: The following code assumes we use SkBitmap::kARGB_8888_Config,
// which has been checked in device.makeOpaque() (see above).
const uint8_t* rawPixels = reinterpret_cast<const uint8_t*>(sourceBitmap.getPixels());
size_t bitmapSize = sourceBitmap.getSize();
OwnArrayPtr<uint8_t> reorderedPixels = adoptArrayPtr(new uint8_t[bitmapSize]);
for (size_t i = 0; i < bitmapSize; i += 4) {
reorderedPixels[i] = rawPixels[i + 2]; // R
reorderedPixels[i + 1] = rawPixels[i + 1]; // G
reorderedPixels[i + 2] = rawPixels[i]; // B
reorderedPixels[i + 3] = rawPixels[i + 3]; // A
}
digester.addBytes(reorderedPixels.get(), bitmapSize);
reorderedPixels.clear();
#else
digester.addBytes(reinterpret_cast<const uint8_t*>(sourceBitmap.getPixels()), sourceBitmap.getSize());
#endif
digester.checksum(digestValue);
string md5hash;
md5hash.reserve(16 * 2);
for (unsigned i = 0; i < 16; ++i) {
char hex[3];
// Use "x", not "X". The string must be lowercased.
sprintf(hex, "%02x", digestValue[i]);
md5hash.append(hex);
}
// Only encode and dump the png if the hashes don't match. Encoding the
// image is really expensive.
if (md5hash.compare(m_params.pixelHash)) {
std::vector<unsigned char> png;
#if OS(ANDROID)
webkit_support::EncodeRGBAPNGWithChecksum(reinterpret_cast<const unsigned char*>(sourceBitmap.getPixels()), sourceBitmap.width(),
sourceBitmap.height(), static_cast<int>(sourceBitmap.rowBytes()), discardTransparency, md5hash, &png);
#else
webkit_support::EncodeBGRAPNGWithChecksum(reinterpret_cast<const unsigned char*>(sourceBitmap.getPixels()), sourceBitmap.width(),
sourceBitmap.height(), static_cast<int>(sourceBitmap.rowBytes()), discardTransparency, md5hash, &png);
#endif
m_printer->handleImage(md5hash.c_str(), m_params.pixelHash.c_str(), &png[0], png.size(), m_params.pixelFileName.c_str());
} else
m_printer->handleImage(md5hash.c_str(), m_params.pixelHash.c_str(), 0, 0, m_params.pixelFileName.c_str());
}
示例7: invokeMethod
JavaValue JavaInstanceJobject::invokeMethod(const JavaMethod* method, JavaValue* args)
{
ASSERT(getClass()->methodsNamed(method->name().utf8().data()).find(method) != notFound);
unsigned int numParams = method->numParameters();
OwnArrayPtr<jvalue> jvalueArgs = adoptArrayPtr(new jvalue[numParams]);
for (unsigned int i = 0; i < numParams; ++i)
jvalueArgs[i] = javaValueToJvalue(args[i]);
jvalue result = callJNIMethod(javaInstance(), method->returnType(), method->name().utf8().data(), method->signature(), jvalueArgs.get());
//CVE-2012-5114 : Control access to inherited methods of jsinterface objects
//return jvalueToJavaValue(result, method->returnType());
return jvalueToJavaValue(result, method->returnType(), m_requireAnnotation);
}
示例8: npObjectInvokeImpl
// FIXME: need comments.
// Params: holder could be HTMLEmbedElement or NPObject
static void npObjectInvokeImpl(const v8::FunctionCallbackInfo<v8::Value>& args, InvokeFunctionType functionId)
{
NPObject* npObject;
WrapperWorldType currentWorldType = worldType(args.GetIsolate());
// These three types are subtypes of HTMLPlugInElement.
if (V8HTMLAppletElement::HasInstance(args.Holder(), args.GetIsolate(), currentWorldType) || V8HTMLEmbedElement::HasInstance(args.Holder(), args.GetIsolate(), currentWorldType)
|| V8HTMLObjectElement::HasInstance(args.Holder(), args.GetIsolate(), currentWorldType)) {
// The holder object is a subtype of HTMLPlugInElement.
HTMLPlugInElement* element;
if (V8HTMLAppletElement::HasInstance(args.Holder(), args.GetIsolate(), currentWorldType))
element = V8HTMLAppletElement::toNative(args.Holder());
else if (V8HTMLEmbedElement::HasInstance(args.Holder(), args.GetIsolate(), currentWorldType))
element = V8HTMLEmbedElement::toNative(args.Holder());
else
element = V8HTMLObjectElement::toNative(args.Holder());
ScriptInstance scriptInstance = element->getInstance();
if (scriptInstance) {
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::HandleScope handleScope(isolate);
npObject = v8ObjectToNPObject(scriptInstance->newLocal(isolate));
} else
npObject = 0;
} else {
// The holder object is not a subtype of HTMLPlugInElement, it must be an NPObject which has three
// internal fields.
if (args.Holder()->InternalFieldCount() != npObjectInternalFieldCount) {
throwError(v8ReferenceError, "NPMethod called on non-NPObject", args.GetIsolate());
return;
}
npObject = v8ObjectToNPObject(args.Holder());
}
// Verify that our wrapper wasn't using a NPObject which has already been deleted.
if (!npObject || !_NPN_IsAlive(npObject)) {
throwError(v8ReferenceError, "NPObject deleted", args.GetIsolate());
return;
}
// Wrap up parameters.
int numArgs = args.Length();
OwnArrayPtr<NPVariant> npArgs = adoptArrayPtr(new NPVariant[numArgs]);
for (int i = 0; i < numArgs; i++)
convertV8ObjectToNPVariant(args[i], npObject, &npArgs[i]);
NPVariant result;
VOID_TO_NPVARIANT(result);
bool retval = true;
switch (functionId) {
case InvokeMethod:
if (npObject->_class->invoke) {
v8::Handle<v8::String> functionName = v8::Handle<v8::String>::Cast(args.Data());
NPIdentifier identifier = getStringIdentifier(functionName);
retval = npObject->_class->invoke(npObject, identifier, npArgs.get(), numArgs, &result);
}
break;
case InvokeConstruct:
if (npObject->_class->construct)
retval = npObject->_class->construct(npObject, npArgs.get(), numArgs, &result);
break;
case InvokeDefault:
if (npObject->_class->invokeDefault)
retval = npObject->_class->invokeDefault(npObject, npArgs.get(), numArgs, &result);
break;
default:
break;
}
if (!retval)
throwError(v8GeneralError, "Error calling method on NPObject.", args.GetIsolate());
for (int i = 0; i < numArgs; i++)
_NPN_ReleaseVariantValue(&npArgs[i]);
// Unwrap return values.
v8::Handle<v8::Value> returnValue;
if (_NPN_IsAlive(npObject))
returnValue = convertNPVariantToV8Object(&result, npObject, args.GetIsolate());
_NPN_ReleaseVariantValue(&result);
v8SetReturnValue(args, returnValue);
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_external_chromium_org_third_party_WebKit,代码行数:87,代码来源:V8NPObject.cpp
示例9: handleScope
short V8NodeFilterCondition::acceptNode(ScriptState* state, Node* node) const
{
ASSERT(v8::Context::InContext());
v8::Isolate* isolate = state->isolate();
v8::HandleScope handleScope(isolate);
v8::Handle<v8::Value> filter = m_filter.newLocal(isolate);
ASSERT(!filter.IsEmpty());
if (!filter->IsObject())
return NodeFilter::FILTER_ACCEPT;
v8::TryCatch exceptionCatcher;
v8::Handle<v8::Function> callback;
if (filter->IsFunction())
callback = v8::Handle<v8::Function>::Cast(filter);
else {
v8::Local<v8::Value> value = filter->ToObject()->Get(v8::String::NewSymbol("acceptNode"));
if (!value->IsFunction()) {
throwTypeError("NodeFilter object does not have an acceptNode function", state->isolate());
return NodeFilter::FILTER_REJECT;
}
callback = v8::Handle<v8::Function>::Cast(value);
}
OwnArrayPtr<v8::Handle<v8::Value> > args = adoptArrayPtr(new v8::Handle<v8::Value>[1]);
args[0] = toV8(node, v8::Handle<v8::Object>(), state->isolate());
v8::Handle<v8::Object> object = v8::Context::GetCurrent()->Global();
v8::Handle<v8::Value> result = ScriptController::callFunctionWithInstrumentation(0, callback, object, 1, args.get(), isolate);
if (exceptionCatcher.HasCaught()) {
state->setException(exceptionCatcher.Exception());
return NodeFilter::FILTER_REJECT;
}
ASSERT(!result.IsEmpty());
return result->Int32Value();
}
示例10: _NPN_Construct
bool _NPN_Construct(NPP npp, NPObject* npObject, const NPVariant* arguments, uint32_t argumentCount, NPVariant* result)
{
if (!npObject)
return false;
v8::Isolate* isolate = v8::Isolate::GetCurrent();
if (npObject->_class == npScriptObjectClass) {
V8NPObject* object = reinterpret_cast<V8NPObject*>(npObject);
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 constructor function.
v8::Handle<v8::Object> ctorObj(object->v8Object);
if (!ctorObj->IsFunction())
return false;
// Call the constructor.
v8::Local<v8::Value> resultObject;
v8::Handle<v8::Function> ctor(v8::Function::Cast(*ctorObj));
if (!ctor->IsNull()) {
Frame* frame = object->rootObject->frame();
ASSERT(frame);
OwnArrayPtr<v8::Handle<v8::Value> > argv = createValueListFromVariantArgs(arguments, argumentCount, npObject, isolate);
resultObject = V8ObjectConstructor::newInstanceInDocument(ctor, argumentCount, argv.get(), frame ? frame->document() : 0);
}
if (resultObject.IsEmpty())
return false;
convertV8ObjectToNPVariant(resultObject, npObject, result);
return true;
}
if (NP_CLASS_STRUCT_VERSION_HAS_CTOR(npObject->_class) && npObject->_class->construct)
return npObject->_class->construct(npObject, arguments, argumentCount, result);
return false;
}
示例11: _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;
v8::Isolate* isolate = v8::Isolate::GetCurrent();
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()) {
Frame* frame = v8NpObject->rootObject->frame();
ASSERT(frame);
OwnArrayPtr<v8::Handle<v8::Value> > argv = createValueListFromVariantArgs(arguments, argumentCount, npObject, isolate);
resultObject = frame->script()->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;
}
示例12: _NPN_Invoke
bool _NPN_Invoke(NPP npp, NPObject* npObject, NPIdentifier methodName, const NPVariant* arguments, uint32_t argumentCount, NPVariant* result)
{
if (!npObject)
return false;
v8::Isolate* isolate = v8::Isolate::GetCurrent();
if (npObject->_class != npScriptObjectClass) {
if (npObject->_class->invoke)
return npObject->_class->invoke(npObject, methodName, arguments, argumentCount, result);
VOID_TO_NPVARIANT(*result);
return true;
}
V8NPObject* v8NpObject = reinterpret_cast<V8NPObject*>(npObject);
PrivateIdentifier* identifier = static_cast<PrivateIdentifier*>(methodName);
if (!identifier->isString)
return false;
if (!strcmp(identifier->value.string, "eval")) {
if (argumentCount != 1)
return false;
if (arguments[0].type != NPVariantType_String)
return false;
return _NPN_Evaluate(npp, npObject, const_cast<NPString*>(&arguments[0].value.stringValue), result);
}
v8::HandleScope handleScope;
// FIXME: should use the plugin's owner frame as the security context.
v8::Handle<v8::Context> context = toV8Context(npp, npObject);
if (context.IsEmpty())
return false;
v8::Context::Scope scope(context);
ExceptionCatcher exceptionCatcher;
v8::Handle<v8::Value> functionObject = v8NpObject->v8Object->Get(v8::String::NewSymbol(identifier->value.string));
if (functionObject.IsEmpty() || functionObject->IsNull()) {
NULL_TO_NPVARIANT(*result);
return false;
}
if (functionObject->IsUndefined()) {
VOID_TO_NPVARIANT(*result);
return false;
}
Frame* frame = v8NpObject->rootObject->frame();
ASSERT(frame);
// Call the function object.
v8::Handle<v8::Function> function = v8::Handle<v8::Function>::Cast(functionObject);
OwnArrayPtr<v8::Handle<v8::Value> > argv = createValueListFromVariantArgs(arguments, argumentCount, npObject, isolate);
v8::Local<v8::Value> resultObject = frame->script()->callFunction(function, v8NpObject->v8Object, 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;
}
示例13: WindowSetTimeoutImpl
// FIXME: There is a lot of duplication with SetTimeoutOrInterval() in V8WorkerGlobalScopeCustom.cpp.
// We should refactor this.
void WindowSetTimeoutImpl(const v8::FunctionCallbackInfo<v8::Value>& args, bool singleShot)
{
int argumentCount = args.Length();
if (argumentCount < 1)
return;
DOMWindow* imp = V8Window::toNative(args.Holder());
ScriptExecutionContext* scriptContext = static_cast<ScriptExecutionContext*>(imp->document());
if (!scriptContext) {
setDOMException(InvalidAccessError, args.GetIsolate());
return;
}
v8::Handle<v8::Value> function = args[0];
String functionString;
if (!function->IsFunction()) {
if (function->IsString()) {
functionString = toWebCoreString(function);
} else {
v8::Handle<v8::Value> v8String = function->ToString();
// Bail out if string conversion failed.
if (v8String.IsEmpty())
return;
functionString = toWebCoreString(v8String);
}
// Don't allow setting timeouts to run empty functions!
// (Bug 1009597)
if (!functionString.length())
return;
}
if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame()))
return;
OwnPtr<ScheduledAction> action;
if (function->IsFunction()) {
int paramCount = argumentCount >= 2 ? argumentCount - 2 : 0;
OwnArrayPtr<v8::Local<v8::Value> > params;
if (paramCount > 0) {
params = adoptArrayPtr(new v8::Local<v8::Value>[paramCount]);
for (int i = 0; i < paramCount; i++) {
// parameters must be globalized
params[i] = args[i+2];
}
}
// params is passed to action, and released in action's destructor
ASSERT(imp->frame());
action = adoptPtr(new ScheduledAction(imp->frame()->script()->currentWorldContext(), v8::Handle<v8::Function>::Cast(function), paramCount, params.get(), args.GetIsolate()));
} else {
if (imp->document() && !imp->document()->contentSecurityPolicy()->allowEval()) {
v8SetReturnValue(args, 0);
return;
}
ASSERT(imp->frame());
action = adoptPtr(new ScheduledAction(imp->frame()->script()->currentWorldContext(), functionString, KURL(), args.GetIsolate()));
}
int32_t timeout = argumentCount >= 2 ? args[1]->Int32Value() : 0;
int timerId;
if (singleShot)
timerId = DOMWindowTimers::setTimeout(imp, action.release(), timeout);
else
timerId = DOMWindowTimers::setInterval(imp, action.release(), timeout);
// Try to do the idle notification before the timeout expires to get better
// use of any idle time. Aim for the middle of the interval for simplicity.
if (timeout >= 0) {
double maximumFireInterval = static_cast<double>(timeout) / 1000 / 2;
V8GCForContextDispose::instance().notifyIdleSooner(maximumFireInterval);
}
v8SetReturnValue(args, timerId);
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_external_chromium_org_third_party_WebKit,代码行数:81,代码来源:V8WindowCustom.cpp
示例14: adoptRef
static const PassRefPtr<KeyEventInfo> keyName(WKStringRef keyRef)
{
if (WKStringIsEqualToUTF8CString(keyRef, "leftArrow"))
return adoptRef(new KeyEventInfo("Left", ""));
if (WKStringIsEqualToUTF8CString(keyRef, "rightArrow"))
return adoptRef(new KeyEventInfo("Right", ""));
if (WKStringIsEqualToUTF8CString(keyRef, "upArrow"))
return adoptRef(new KeyEventInfo("Up", ""));
if (WKStringIsEqualToUTF8CString(keyRef, "downArrow"))
return adoptRef(new KeyEventInfo("Down", ""));
if (WKStringIsEqualToUTF8CString(keyRef, "pageUp"))
return adoptRef(new KeyEventInfo("Prior", ""));
if (WKStringIsEqualToUTF8CString(keyRef, "pageDown"))
return adoptRef(new KeyEventInfo("Next", ""));
if (WKStringIsEqualToUTF8CString(keyRef, "home"))
return adoptRef(new KeyEventInfo("Home", ""));
if (WKStringIsEqualToUTF8CString(keyRef, "end"))
return adoptRef(new KeyEventInfo("End", ""));
if (WKStringIsEqualToUTF8CString(keyRef, "insert"))
return adoptRef(new KeyEventInfo("Insert", ""));
if (WKStringIsEqualToUTF8CString(keyRef, "delete"))
return adoptRef(new KeyEventInfo("Delete", ""));
if (WKStringIsEqualToUTF8CString(keyRef, "printScreen"))
return adoptRef(new KeyEventInfo("Print", ""));
if (WKStringIsEqualToUTF8CString(keyRef, "menu"))
return adoptRef(new KeyEventInfo("Menu", ""));
if (WKStringIsEqualToUTF8CString(keyRef, "leftControl"))
return adoptRef(new KeyEventInfo("Control_L", ""));
if (WKStringIsEqualToUTF8CString(keyRef, "rightControl"))
return adoptRef(new KeyEventInfo("Control_R", ""));
if (WKStringIsEqualToUTF8CString(keyRef, "leftShift"))
return adoptRef(new KeyEventInfo("Shift_L", ""));
if (WKStringIsEqualToUTF8CString(keyRef, "rightShift"))
return adoptRef(new KeyEventInfo("Shift_R", ""));
if (WKStringIsEqualToUTF8CString(keyRef, "leftAlt"))
return adoptRef(new KeyEventInfo("Alt_L", ""));
if (WKStringIsEqualToUTF8CString(keyRef, "rightAlt"))
return adoptRef(new KeyEventInfo("Alt_R", ""));
if (WKStringIsEqualToUTF8CString(keyRef, "F1"))
return adoptRef(new KeyEventInfo("F1", ""));
if (WKStringIsEqualToUTF8CString(keyRef, "F2"))
return adoptRef(new KeyEventInfo("F2", ""));
if (WKStringIsEqualToUTF8CString(keyRef, "F3"))
return adoptRef(new KeyEventInfo("F3", ""));
if (WKStringIsEqualToUTF8CString(keyRef, "F4"))
return adoptRef(new KeyEventInfo("F4", ""));
if (WKStringIsEqualToUTF8CString(keyRef, "F5"))
return adoptRef(new KeyEventInfo("F5", ""));
if (WKStringIsEqualToUTF8CString(keyRef, "F6"))
return adoptRef(new KeyEventInfo("F6", ""));
if (WKStringIsEqualToUTF8CString(keyRef, "F7"))
return adoptRef(new KeyEventInfo("F7", ""));
if (WKStringIsEqualToUTF8CString(keyRef, "F8"))
return adoptRef(new KeyEventInfo("F8", ""));
if (WKStringIsEqualToUTF8CString(keyRef, "F9"))
return adoptRef(new KeyEventInfo("F9", ""));
if (WKStringIsEqualToUTF8CString(keyRef, "F10"))
return adoptRef(new KeyEventInfo("F10", ""));
if (WKStringIsEqualToUTF8CString(keyRef, "F11"))
return adoptRef(new KeyEventInfo("F11", ""));
if (WKStringIsEqualToUTF8CString(keyRef, "F12"))
return adoptRef(new KeyEventInfo("F12", ""));
size_t bufferSize = WKStringGetMaximumUTF8CStringSize(keyRef);
OwnArrayPtr<char> buffer = adoptArrayPtr(new char[bufferSize]);
WKStringGetUTF8CString(keyRef, buffer.get(), bufferSize);
char charCode = buffer.get()[0];
if (charCode == '\n' || charCode == '\r')
return adoptRef(new KeyEventInfo("Return", "\r"));
if (charCode == '\t')
return adoptRef(new KeyEventInfo("Tab", "\t"));
if (charCode == '\x8')
return adoptRef(new KeyEventInfo("BackSpace", "\x8"));
if (charCode == ' ')
return adoptRef(new KeyEventInfo("space", " "));
return adoptRef(new KeyEventInfo(buffer.get(), buffer.get()));
}
示例15: ASSERT
short V8NodeFilterCondition::acceptNode(ScriptState* state, Node* node) const
{
ASSERT(v8::Context::InContext());
if (!m_filter->IsObject())
return NodeFilter::FILTER_ACCEPT;
v8::TryCatch exceptionCatcher;
v8::Handle<v8::Function> callback;
if (m_filter->IsFunction())
callback = v8::Handle<v8::Function>::Cast(m_filter);
else {
v8::Local<v8::Value> value = m_filter->ToObject()->Get(v8::String::New("acceptNode"));
if (!value->IsFunction()) {
V8Proxy::throwError(V8Proxy::TypeError, "NodeFilter object does not have an acceptNode function");
return NodeFilter::FILTER_REJECT;
}
callback = v8::Handle<v8::Function>::Cast(value);
}
v8::Handle<v8::Object> object = v8::Context::GetCurrent()->Global();
OwnArrayPtr<v8::Handle<v8::Value> > args = adoptArrayPtr(new v8::Handle<v8::Value>[1]);
args[0] = toV8(node);
v8::Handle<v8::Value> result = V8Proxy::callFunctionWithoutFrame(callback, object, 1, args.get());
if (exceptionCatcher.HasCaught()) {
state->setException(exceptionCatcher.Exception());
return NodeFilter::FILTER_REJECT;
}
ASSERT(!result.IsEmpty());
return result->Int32Value();
}