예제 #1
0
JSValue* JSClipboard::getValueProperty(ExecState* exec, int token) const
{
    Clipboard* clipboard = impl();
    switch (token) {
        case DropEffect:
            ASSERT(clipboard->isForDragging() || clipboard->dropEffect().isNull());
            return jsStringOrUndefined(clipboard->dropEffect());
        case EffectAllowed:
            ASSERT(clipboard->isForDragging() || clipboard->effectAllowed().isNull());
            return jsStringOrUndefined(clipboard->effectAllowed());
        case Types:
        {
            HashSet<String> types = clipboard->types();
            if (types.isEmpty())
                return jsNull();
            else {
                List list;
                HashSet<String>::const_iterator end = types.end();
                for (HashSet<String>::const_iterator it = types.begin(); it != end; ++it)
                    list.append(jsString(UString(*it)));
                return exec->lexicalInterpreter()->builtinArray()->construct(exec, list);
            }
        }
        default:
            return 0;
    }
}
예제 #2
0
JSValue jsClipboardEffectAllowed(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSClipboard* castedThis = static_cast<JSClipboard*>(asObject(slotBase));
    UNUSED_PARAM(exec);
    Clipboard* imp = static_cast<Clipboard*>(castedThis->impl());
    JSValue result = jsStringOrUndefined(exec, imp->effectAllowed());
    return result;
}
예제 #3
0
JSValue JSXSLTProcessor::getParameter(ExecState& state)
{
    if (state.argument(1).isUndefinedOrNull())
        return jsUndefined();
    String namespaceURI = state.uncheckedArgument(0).toString(&state)->value(&state);
    String localName = state.uncheckedArgument(1).toString(&state)->value(&state);
    String value = wrapped().getParameter(namespaceURI, localName);
    return jsStringOrUndefined(&state, value);
}
예제 #4
0
JSValue JSXSLTProcessor::getParameter(ExecState* exec)
{
    if (exec->argument(1).isUndefinedOrNull())
        return jsUndefined();
    String namespaceURI = ustringToString(exec->argument(0).toString(exec));
    String localName = ustringToString(exec->argument(1).toString(exec));
    String value = impl()->getParameter(namespaceURI, localName);
    return jsStringOrUndefined(exec, value);
}
예제 #5
0
JSValue jsIDBRequestWebkitErrorMessage(ExecState* exec, JSValue slotBase, const Identifier&)
{
    JSIDBRequest* castedThis = static_cast<JSIDBRequest*>(asObject(slotBase));
    ExceptionCode ec = 0;
    IDBRequest* imp = static_cast<IDBRequest*>(castedThis->impl());
    JSC::JSValue result = jsStringOrUndefined(exec, imp->webkitErrorMessage(ec));
    setDOMException(exec, ec);
    return result;
}
예제 #6
0
JSValue* JSClipboard::getValueProperty(ExecState* exec, int token) const
{
    switch (token) {
    case DropEffectAttrNum: {
        Clipboard* imp = static_cast<Clipboard*>(impl());
        return jsStringOrUndefined(exec, imp->dropEffect());
    }
    case EffectAllowedAttrNum: {
        Clipboard* imp = static_cast<Clipboard*>(impl());
        return jsStringOrUndefined(exec, imp->effectAllowed());
    }
    case TypesAttrNum: {
        return types(exec);
    }
    case ConstructorAttrNum:
        return getConstructor(exec);
    }
    return 0;
}
예제 #7
0
JSValue* jsXMLHttpRequestPrototypeFunctionGetAllResponseHeaders(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
    if (!thisValue->isObject(&JSXMLHttpRequest::s_info))
        return throwError(exec, TypeError);
    JSXMLHttpRequest* castedThisObj = static_cast<JSXMLHttpRequest*>(thisValue);
    XMLHttpRequest* imp = static_cast<XMLHttpRequest*>(castedThisObj->impl());
    ExceptionCode ec = 0;


    KJS::JSValue* result = jsStringOrUndefined(exec, imp->getAllResponseHeaders(ec));
    setDOMException(exec, ec);
    return result;
}
JSValue* JSXMLHttpRequestPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
{
    if (!thisObj->inherits(&JSXMLHttpRequest::info))
        return throwError(exec, TypeError);

    JSXMLHttpRequest* request = static_cast<JSXMLHttpRequest*>(thisObj);

    ExceptionCode ec = 0;

    switch (id) {
        case JSXMLHttpRequest::Abort:
            request->m_impl->abort();
            return jsUndefined();

        case JSXMLHttpRequest::GetAllResponseHeaders:
            return jsStringOrUndefined(request->m_impl->getAllResponseHeaders());

        case JSXMLHttpRequest::GetResponseHeader:
            if (args.size() < 1)
                return throwError(exec, SyntaxError, "Not enough arguments");

            return jsStringOrNull(request->m_impl->getResponseHeader(args[0]->toString(exec)));

        case JSXMLHttpRequest::Open: {
            if (args.size() < 2)
                return throwError(exec, SyntaxError, "Not enough arguments");

            String method = args[0]->toString(exec);
            Frame* frame = Window::retrieveActive(exec)->impl()->frame();
            if (!frame)
                return jsUndefined();
            KURL url = frame->loader()->completeURL(DeprecatedString(args[1]->toString(exec)));

            bool async = true;
            if (args.size() >= 3)
                async = args[2]->toBoolean(exec);

            if (args.size() >= 4 && !args[3]->isUndefined()) {
                String user = valueToStringWithNullCheck(exec, args[3]);

                if (args.size() >= 5 && !args[4]->isUndefined()) {
                    String password = valueToStringWithNullCheck(exec, args[4]);
                    request->m_impl->open(method, url, async, user, password, ec);
                } else
                    request->m_impl->open(method, url, async, user, ec);
            } else
                request->m_impl->open(method, url, async, ec);

            setDOMException(exec, ec);
            return jsUndefined();
        }
        case JSXMLHttpRequest::Send: {
            String body;

            if (args.size() >= 1) {
                if (args[0]->toObject(exec)->inherits(&JSDocument::info)) {
                    Document* doc = static_cast<Document*>(static_cast<JSDocument*>(args[0]->toObject(exec))->impl());
                    body = doc->toString().deprecatedString();
                } else {
                    // converting certain values (like null) to object can set an exception
                    if (exec->hadException())
                        exec->clearException();
                    else
                        body = args[0]->toString(exec);
                }
            }

            request->m_impl->send(body, ec);
            setDOMException(exec, ec);

            return jsUndefined();
        }
        case JSXMLHttpRequest::SetRequestHeader:
            if (args.size() < 2)
                return throwError(exec, SyntaxError, "Not enough arguments");

            request->m_impl->setRequestHeader(args[0]->toString(exec), args[1]->toString(exec), ec);
            setDOMException(exec, ec);
            return jsUndefined();

        case JSXMLHttpRequest::OverrideMIMEType:
            if (args.size() < 1)
                return throwError(exec, SyntaxError, "Not enough arguments");

            request->m_impl->overrideMIMEType(args[0]->toString(exec));
            return jsUndefined();
        
        case JSXMLHttpRequest::AddEventListener: {
            Document* doc = request->m_impl->document();
            if (!doc)
                return jsUndefined();
            Frame* frame = doc->frame();
            if (!frame)
                return jsUndefined();
            JSUnprotectedEventListener* listener = KJS::Window::retrieveWindow(frame)->findOrCreateJSUnprotectedEventListener(args[1], true);
            if (!listener)
                return jsUndefined();
            request->m_impl->addEventListener(args[0]->toString(exec), listener, args[2]->toBoolean(exec));
            return jsUndefined();
        }
        case JSXMLHttpRequest::RemoveEventListener: {
            Document* doc = request->m_impl->document();
            if (!doc)
                return jsUndefined();
            Frame* frame = doc->frame();
            if (!frame)
                return jsUndefined();
            JSUnprotectedEventListener* listener = KJS::Window::retrieveWindow(frame)->findOrCreateJSUnprotectedEventListener(args[1], true);
            if (!listener)
                return jsUndefined();
            request->m_impl->removeEventListener(args[0]->toString(exec), listener, args[2]->toBoolean(exec));
            return jsUndefined();
        }
        case JSXMLHttpRequest::DispatchEvent: {
            bool result = request->m_impl->dispatchEvent(toEvent(args[0]), ec);
            setDOMException(exec, ec);
            return jsBoolean(result);
        }
    }

    return jsUndefined();
}
예제 #9
0
JSValue* JSDocument::getValueProperty(ExecState* exec, int token) const
{
    switch (token) {
    case DoctypeAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return toJS(exec, WTF::getPtr(imp->doctype()));
    }
    case ImplementationAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return toJS(exec, WTF::getPtr(imp->implementation()));
    }
    case DocumentElementAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return toJS(exec, WTF::getPtr(imp->documentElement()));
    }
    case InputEncodingAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return jsStringOrNull(imp->inputEncoding());
    }
    case XMLEncodingAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return jsStringOrNull(imp->xmlEncoding());
    }
    case XMLVersionAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return jsStringOrNull(imp->xmlVersion());
    }
    case XMLStandaloneAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return jsBoolean(imp->xmlStandalone());
    }
    case DocumentURIAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return jsStringOrNull(imp->documentURI());
    }
    case AsyncAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return jsBoolean(imp->async());
    }
    case DefaultViewAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return toJS(exec, WTF::getPtr(imp->defaultView()));
    }
    case StyleSheetsAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return toJS(exec, WTF::getPtr(imp->styleSheets()));
    }
    case TitleAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return jsString(imp->title());
    }
    case ReferrerAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return jsString(imp->referrer());
    }
    case DomainAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return jsString(imp->domain());
    }
    case URLAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return jsString(imp->URL());
    }
    case CookieAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return jsString(imp->cookie());
    }
    case BodyAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return toJS(exec, WTF::getPtr(imp->body()));
    }
    case ImagesAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return toJS(exec, WTF::getPtr(imp->images()));
    }
    case AppletsAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return toJS(exec, WTF::getPtr(imp->applets()));
    }
    case LinksAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return toJS(exec, WTF::getPtr(imp->links()));
    }
    case FormsAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return toJS(exec, WTF::getPtr(imp->forms()));
    }
    case AnchorsAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return toJS(exec, WTF::getPtr(imp->anchors()));
    }
    case LocationAttrNum: {
        return location(exec);
    }
    case CharsetAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return jsStringOrUndefined(imp->charset());
    }
    case DefaultCharsetAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return jsStringOrUndefined(imp->defaultCharset());
    }
    case ReadyStateAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return jsStringOrUndefined(imp->readyState());
    }
    case CharacterSetAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return jsStringOrNull(imp->characterSet());
    }
    case PreferredStylesheetSetAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return jsStringOrNull(imp->preferredStylesheetSet());
    }
    case SelectedStylesheetSetAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return jsStringOrNull(imp->selectedStylesheetSet());
    }
    case ConstructorAttrNum:
        return getConstructor(exec);
    }
    return 0;
}
EncodedJSValue JSDOMSettableTokenList::indexGetter(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue, unsigned index)
{
    JSDOMSettableTokenList* thisObj = jsCast<JSDOMSettableTokenList*>(JSValue::decode(slotBase));
    ASSERT_GC_OBJECT_INHERITS(thisObj, info());
    return JSValue::encode(jsStringOrUndefined(exec, thisObj->impl().item(index)));
}
예제 #11
0
JSValue* JSDocument::getValueProperty(ExecState* exec, int token) const
{
    switch (token) {
    case DoctypeAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return toJS(exec, WTF::getPtr(imp->doctype()));
    }
    case ImplementationAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return toJS(exec, WTF::getPtr(imp->implementation()));
    }
    case DocumentElementAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return toJS(exec, WTF::getPtr(imp->documentElement()));
    }
    case InputEncodingAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return jsStringOrNull(imp->inputEncoding());
    }
    case XMLEncodingAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return jsStringOrNull(imp->xmlEncoding());
    }
    case XMLVersionAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return jsStringOrNull(imp->xmlVersion());
    }
    case XMLStandaloneAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return jsBoolean(imp->xmlStandalone());
    }
    case DocumentURIAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return jsStringOrNull(imp->documentURI());
    }
    case DefaultViewAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return toJS(exec, WTF::getPtr(imp->defaultView()));
    }
    case StyleSheetsAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return toJS(exec, WTF::getPtr(imp->styleSheets()), imp);
    }
    case URLAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return jsString(imp->URL());
    }
    case CharsetAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return jsStringOrUndefined(imp->charset());
    }
    case DefaultCharsetAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return jsStringOrUndefined(imp->defaultCharset());
    }
    case ReadyStateAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return jsStringOrUndefined(imp->readyState());
    }
    case CharacterSetAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return jsStringOrNull(imp->characterSet());
    }
    case PreferredStylesheetSetAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return jsStringOrNull(imp->preferredStylesheetSet());
    }
    case SelectedStylesheetSetAttrNum: {
        Document* imp = static_cast<Document*>(impl());

        return jsStringOrNull(imp->selectedStylesheetSet());
    }
    case ConstructorAttrNum:
        return getConstructor(exec);
    }
    return 0;
}