コード例 #1
0
static v8::Handle<v8::Value> setDataCallback(const v8::Arguments& args)
{
    if (args.Length() < 2)
        return throwNotEnoughArgumentsError(args.GetIsolate());
    Clipboard* imp = V8Clipboard::toNative(args.Holder());
    V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, type, MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined));
    V8TRYCATCH_FOR_V8STRINGRESOURCE(V8StringResource<>, data, MAYBE_MISSING_PARAMETER(args, 1, DefaultIsUndefined));
    return v8Boolean(imp->setData(type, data), args.GetIsolate());
}
コード例 #2
0
JSValuePtr JSClipboard::setData(ExecState* exec, const ArgList& args)
{
    Clipboard* clipboard = impl();

    // FIXME: It does not match the rest of the JS bindings to throw on invalid number of arguments. 
    if (args.size() != 2)
        return throwError(exec, SyntaxError, "setData: Invalid number of arguments");

    return jsBoolean(clipboard->setData(args.at(exec, 0).toString(exec), args.at(exec, 1).toString(exec)));
}
コード例 #3
0
static v8::Handle<v8::Value> setDataCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.Clipboard.setData");
    if (args.Length() < 2)
        return v8::Handle<v8::Value>();
    Clipboard* imp = V8Clipboard::toNative(args.Holder());
    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, type, args[0]);
    STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, data, args[1]);
    return v8Boolean(imp->setData(type, data));
}
コード例 #4
0
v8::Handle<v8::Value> V8Clipboard::setDataCallback(const v8::Arguments& args)
{
    INC_STATS("DOM.Clipboard.setData()");
    Clipboard* clipboard = V8Clipboard::toNative(args.Holder());

    if (args.Length() != 2)
        return throwError("setData: Invalid number of arguments", V8Proxy::SyntaxError);

    String type = toWebCoreString(args[0]);
    String data = toWebCoreString(args[1]);
    return v8Boolean(clipboard->setData(type, data));
}
コード例 #5
0
ファイル: JSClipboard.cpp プロジェクト: Xertz/EAWebKit
EncodedJSValue JSC_HOST_CALL jsClipboardPrototypeFunctionSetData(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSClipboard::s_info))
        return throwVMTypeError(exec);
    JSClipboard* castedThis = static_cast<JSClipboard*>(asObject(thisValue));
    ASSERT_GC_OBJECT_INHERITS(castedThis, &JSClipboard::s_info);
    Clipboard* imp = static_cast<Clipboard*>(castedThis->impl());
    if (exec->argumentCount() < 2)
        return JSValue::encode(jsUndefined());
    const String& type(ustringToString(exec->argument(0).toString(exec)));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    const String& data(ustringToString(exec->argument(1).toString(exec)));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());


    JSC::JSValue result = jsBoolean(imp->setData(type, data));
    return JSValue::encode(result);
}
コード例 #6
0
ファイル: kjs_events.cpp プロジェクト: jackiekaon/owb-mirror
JSValue* JSClipboardPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
{
    if (!thisObj->inherits(&JSClipboard::info))
        return throwError(exec, TypeError);

    Clipboard* clipboard = static_cast<JSClipboard*>(thisObj)->impl();
    switch (id) {
        case JSClipboard::ClearData:
            if (args.size() == 0) {
                clipboard->clearAllData();
                return jsUndefined();
            } else if (args.size() == 1) {
                clipboard->clearData(args[0]->toString(exec));
                return jsUndefined();
            } else
                return throwError(exec, SyntaxError, "clearData: Invalid number of arguments");
        case JSClipboard::GetData:
        {
            if (args.size() == 1) {
                bool success;
                String result = clipboard->getData(args[0]->toString(exec), success);
                if (success)
                    return jsString(result);
                return jsUndefined();
            } else
                return throwError(exec, SyntaxError, "getData: Invalid number of arguments");
        }
        case JSClipboard::SetData:
            if (args.size() == 2)
                return jsBoolean(clipboard->setData(args[0]->toString(exec), args[1]->toString(exec)));
            return throwError(exec, SyntaxError, "setData: Invalid number of arguments");
        case JSClipboard::SetDragImage:
        {
            if (!clipboard->isForDragging())
                return jsUndefined();

            if (args.size() != 3)
                return throwError(exec, SyntaxError, "setDragImage: Invalid number of arguments");

            int x = args[1]->toInt32(exec);
            int y = args[2]->toInt32(exec);

            // See if they passed us a node
            Node* node = toNode(args[0]);
            if (!node)
                return throwError(exec, TypeError);

            if (!node->isElementNode())
                return throwError(exec, SyntaxError, "setDragImageFromElement: Invalid first argument");

            if (static_cast<Element*>(node)->hasLocalName(imgTag) &&
                !node->inDocument())
                clipboard->setDragImage(static_cast<HTMLImageElement*>(node)->cachedImage(), IntPoint(x, y));
            else
                clipboard->setDragImageElement(node, IntPoint(x, y));

            return jsUndefined();
        }
    }
    return jsUndefined();
}