EncodedJSValue JSC_HOST_CALL jsXPathEvaluatorPrototypeFunctionEvaluate(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    JSXPathEvaluator* castedThis = jsDynamicCast<JSXPathEvaluator*>(thisValue);
    if (!castedThis)
        return throwVMTypeError(exec);
    ASSERT_GC_OBJECT_INHERITS(castedThis, JSXPathEvaluator::info());
    XPathEvaluator& impl = castedThis->impl();
    ExceptionCode ec = 0;
    const String& expression(exec->argument(0).isEmpty() ? String() : exec->argument(0).toString(exec)->value(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    Node* contextNode(toNode(exec->argument(1)));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    RefPtr<XPathNSResolver> customResolver;
    XPathNSResolver* resolver = toXPathNSResolver(exec->argument(2));
    if (!resolver) {
        customResolver = JSCustomXPathNSResolver::create(exec, exec->argument(2));
        if (exec->hadException())
            return JSValue::encode(jsUndefined());
        resolver = customResolver.get();
    }
    uint16_t type(toUInt16(exec, exec->argument(3), NormalConversion));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    XPathResult* inResult(toXPathResult(exec->argument(4)));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());

    JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl.evaluate(expression, contextNode, resolver, type, inResult, ec)));
    setDOMException(exec, ec);
    return JSValue::encode(result);
}
示例#2
0
EncodedJSValue JSC_HOST_CALL jsXPathEvaluatorPrototypeFunctionEvaluate(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSXPathEvaluator::s_info))
        return throwVMTypeError(exec);
    JSXPathEvaluator* castedThis = static_cast<JSXPathEvaluator*>(asObject(thisValue));
    XPathEvaluator* imp = static_cast<XPathEvaluator*>(castedThis->impl());
    ExceptionCode ec = 0;
    const String& expression(ustringToString(exec->argument(0).toString(exec)));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    Node* contextNode(toNode(exec->argument(1)));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    RefPtr<XPathNSResolver> customResolver;
    XPathNSResolver* resolver = toXPathNSResolver(exec->argument(2));
    if (!resolver) {
        customResolver = JSCustomXPathNSResolver::create(exec, exec->argument(2));
        if (exec->hadException())
            return JSValue::encode(jsUndefined());
        resolver = customResolver.get();
    }
    unsigned short type(exec->argument(3).toUInt32(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    XPathResult* inResult(toXPathResult(exec->argument(4)));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());


    JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->evaluate(expression, contextNode, resolver, type, inResult, ec)));
    setDOMException(exec, ec);
    return JSValue::encode(result);
}
示例#3
0
JSValue* jsXPathEvaluatorPrototypeFunctionEvaluate(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args)
{
    if (!thisValue->isObject(&JSXPathEvaluator::s_info))
        return throwError(exec, TypeError);
    JSXPathEvaluator* castedThisObj = static_cast<JSXPathEvaluator*>(thisValue);
    XPathEvaluator* imp = static_cast<XPathEvaluator*>(castedThisObj->impl());
    ExceptionCode ec = 0;
    const UString& expression = args[0]->toString(exec);
    Node* contextNode = toNode(args[1]);
    RefPtr<XPathNSResolver> customResolver;
    XPathNSResolver* resolver = toXPathNSResolver(args[2]);
    if (!resolver) {
        customResolver = JSCustomXPathNSResolver::create(exec, args[2]);
        if (exec->hadException())
            return jsUndefined();
        resolver = customResolver.get();
    }
    unsigned short type = args[3]->toInt32(exec);
    XPathResult* inResult = toXPathResult(args[4]);


    KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->evaluate(expression, contextNode, resolver, type, inResult, ec)));
    setDOMException(exec, ec);
    return result;
}
示例#4
0
JSValue* JSXPathEvaluatorPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
{
    if (!thisObj->inherits(&JSXPathEvaluator::info))
      return throwError(exec, TypeError);

    JSXPathEvaluator* castedThisObj = static_cast<JSXPathEvaluator*>(thisObj);
    XPathEvaluator* imp = static_cast<XPathEvaluator*>(castedThisObj->impl());

    switch (id) {
    case JSXPathEvaluator::CreateExpressionFuncNum: {
        ExceptionCode ec = 0;
        String expression = args[0]->toString(exec);
        RefPtr<XPathNSResolver> customResolver;
        XPathNSResolver* resolver = toXPathNSResolver(args[1]);
        if (!resolver) {
            customResolver = JSCustomXPathNSResolver::create(exec, args[1]);
            if (exec->hadException())
                return jsUndefined();
            resolver = customResolver.get();
        }


        KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createExpression(expression, resolver, ec)));
        setDOMException(exec, ec);
        return result;
    }
    case JSXPathEvaluator::CreateNSResolverFuncNum: {
        Node* nodeResolver = toNode(args[0]);


        KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createNSResolver(nodeResolver)));
        return result;
    }
    case JSXPathEvaluator::EvaluateFuncNum: {
        ExceptionCode ec = 0;
        String expression = args[0]->toString(exec);
        Node* contextNode = toNode(args[1]);
        RefPtr<XPathNSResolver> customResolver;
        XPathNSResolver* resolver = toXPathNSResolver(args[2]);
        if (!resolver) {
            customResolver = JSCustomXPathNSResolver::create(exec, args[2]);
            if (exec->hadException())
                return jsUndefined();
            resolver = customResolver.get();
        }
        unsigned short type = args[3]->toInt32(exec);
        XPathResult* inResult = toXPathResult(args[4]);


        KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->evaluate(expression, contextNode, resolver, type, inResult, ec)));
        setDOMException(exec, ec);
        return result;
    }
    }
    return 0;
}
示例#5
0
EncodedJSValue JSC_HOST_CALL jsXPathExpressionPrototypeFunctionEvaluate(ExecState* exec)
{
    JSValue thisValue = exec->hostThisValue();
    if (!thisValue.inherits(&JSXPathExpression::s_info))
        return throwVMTypeError(exec);
    JSXPathExpression* castedThis = static_cast<JSXPathExpression*>(asObject(thisValue));
    ASSERT_GC_OBJECT_INHERITS(castedThis, &JSXPathExpression::s_info);
    XPathExpression* imp = static_cast<XPathExpression*>(castedThis->impl());
    ExceptionCode ec = 0;
    Node* contextNode(toNode(exec->argument(0)));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    unsigned short type(exec->argument(1).toUInt32(exec));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());
    XPathResult* inResult(toXPathResult(exec->argument(2)));
    if (exec->hadException())
        return JSValue::encode(jsUndefined());


    JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->evaluate(contextNode, type, inResult, ec)));
    setDOMException(exec, ec);
    return JSValue::encode(result);
}
示例#6
0
JSValue* JSDocumentPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args)
{
    if (!thisObj->inherits(&JSDocument::info))
      return throwError(exec, TypeError);

    Document* imp = static_cast<Document*>(static_cast<JSDocument*>(thisObj)->impl());

    switch (id) {
    case JSDocument::CreateElementFuncNum: {
        ExceptionCode ec = 0;
        String tagName = args[0]->toString(exec);


        KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createElement(tagName, ec)));
        setDOMException(exec, ec);
        return result;
    }
    case JSDocument::CreateDocumentFragmentFuncNum: {


        KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createDocumentFragment()));
        return result;
    }
    case JSDocument::CreateTextNodeFuncNum: {
        String data = args[0]->toString(exec);


        KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createTextNode(data)));
        return result;
    }
    case JSDocument::CreateCommentFuncNum: {
        String data = args[0]->toString(exec);


        KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createComment(data)));
        return result;
    }
    case JSDocument::CreateCDATASectionFuncNum: {
        ExceptionCode ec = 0;
        String data = args[0]->toString(exec);


        KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createCDATASection(data, ec)));
        setDOMException(exec, ec);
        return result;
    }
    case JSDocument::CreateProcessingInstructionFuncNum: {
        ExceptionCode ec = 0;
        String target = args[0]->toString(exec);
        String data = args[1]->toString(exec);


        KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createProcessingInstruction(target, data, ec)));
        setDOMException(exec, ec);
        return result;
    }
    case JSDocument::CreateAttributeFuncNum: {
        ExceptionCode ec = 0;
        String name = args[0]->toString(exec);


        KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createAttribute(name, ec)));
        setDOMException(exec, ec);
        return result;
    }
    case JSDocument::CreateEntityReferenceFuncNum: {
        ExceptionCode ec = 0;
        String name = args[0]->toString(exec);


        KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createEntityReference(name, ec)));
        setDOMException(exec, ec);
        return result;
    }
    case JSDocument::GetElementsByTagNameFuncNum: {
        String tagname = args[0]->toString(exec);


        KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->getElementsByTagName(tagname)));
        return result;
    }
    case JSDocument::ImportNodeFuncNum: {
        ExceptionCode ec = 0;
        Node* importedNode = toNode(args[0]);
        bool deep = args[1]->toBoolean(exec);


        KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->importNode(importedNode, deep, ec)));
        setDOMException(exec, ec);
        return result;
    }
    case JSDocument::CreateElementNSFuncNum: {
        ExceptionCode ec = 0;
        String namespaceURI = valueToStringWithNullCheck(exec, args[0]);
        String qualifiedName = args[1]->toString(exec);


        KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createElementNS(namespaceURI, qualifiedName, ec)));
        setDOMException(exec, ec);
        return result;
    }
    case JSDocument::CreateAttributeNSFuncNum: {
        ExceptionCode ec = 0;
        String namespaceURI = valueToStringWithNullCheck(exec, args[0]);
        String qualifiedName = args[1]->toString(exec);


        KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createAttributeNS(namespaceURI, qualifiedName, ec)));
        setDOMException(exec, ec);
        return result;
    }
    case JSDocument::GetElementsByTagNameNSFuncNum: {
        String namespaceURI = valueToStringWithNullCheck(exec, args[0]);
        String localName = args[1]->toString(exec);


        KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->getElementsByTagNameNS(namespaceURI, localName)));
        return result;
    }
    case JSDocument::GetElementByIdFuncNum: {
        String elementId = args[0]->toString(exec);


        KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->getElementById(elementId)));
        return result;
    }
    case JSDocument::AdoptNodeFuncNum: {
        ExceptionCode ec = 0;
        Node* source = toNode(args[0]);


        KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->adoptNode(source, ec)));
        setDOMException(exec, ec);
        return result;
    }
    case JSDocument::CreateEventFuncNum: {
        ExceptionCode ec = 0;
        String eventType = args[0]->toString(exec);


        KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createEvent(eventType, ec)));
        setDOMException(exec, ec);
        return result;
    }
    case JSDocument::CreateRangeFuncNum: {


        KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createRange()));
        return result;
    }
    case JSDocument::CreateNodeIteratorFuncNum: {
        ExceptionCode ec = 0;
        Node* root = toNode(args[0]);
        bool whatToShowOk;
        unsigned whatToShow = args[1]->toInt32(exec, whatToShowOk);
        if (!whatToShowOk) {
            setDOMException(exec, TYPE_MISMATCH_ERR);
            return jsUndefined();
        }
        NodeFilter* filter = toNodeFilter(args[2]);
        bool entityReferenceExpansion = args[3]->toBoolean(exec);


        KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createNodeIterator(root, whatToShow, filter, entityReferenceExpansion, ec)));
        setDOMException(exec, ec);
        return result;
    }
    case JSDocument::CreateTreeWalkerFuncNum: {
        ExceptionCode ec = 0;
        Node* root = toNode(args[0]);
        bool whatToShowOk;
        unsigned whatToShow = args[1]->toInt32(exec, whatToShowOk);
        if (!whatToShowOk) {
            setDOMException(exec, TYPE_MISMATCH_ERR);
            return jsUndefined();
        }
        NodeFilter* filter = toNodeFilter(args[2]);
        bool entityReferenceExpansion = args[3]->toBoolean(exec);


        KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createTreeWalker(root, whatToShow, filter, entityReferenceExpansion, ec)));
        setDOMException(exec, ec);
        return result;
    }
    case JSDocument::GetOverrideStyleFuncNum: {
        Element* element = toElement(args[0]);
        String pseudoElement = args[1]->toString(exec);


        KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->getOverrideStyle(element, pseudoElement)));
        return result;
    }
    case JSDocument::CreateExpressionFuncNum: {
        ExceptionCode ec = 0;
        String expression = args[0]->toString(exec);
        RefPtr<XPathNSResolver> customResolver;
        XPathNSResolver* resolver = toXPathNSResolver(args[1]);
        if (!resolver) {
            customResolver = JSCustomXPathNSResolver::create(exec, args[1]);
            if (exec->hadException())
                return jsUndefined();
            resolver = customResolver.get();
        }


        KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createExpression(expression, resolver, ec)));
        setDOMException(exec, ec);
        return result;
    }
    case JSDocument::CreateNSResolverFuncNum: {
        Node* nodeResolver = toNode(args[0]);


        KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createNSResolver(nodeResolver)));
        return result;
    }
    case JSDocument::EvaluateFuncNum: {
        ExceptionCode ec = 0;
        String expression = args[0]->toString(exec);
        Node* contextNode = toNode(args[1]);
        RefPtr<XPathNSResolver> customResolver;
        XPathNSResolver* resolver = toXPathNSResolver(args[2]);
        if (!resolver) {
            customResolver = JSCustomXPathNSResolver::create(exec, args[2]);
            if (exec->hadException())
                return jsUndefined();
            resolver = customResolver.get();
        }
        unsigned short type = args[3]->toInt32(exec);
        XPathResult* inResult = toXPathResult(args[4]);


        KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->evaluate(expression, contextNode, resolver, type, inResult, ec)));
        setDOMException(exec, ec);
        return result;
    }
    case JSDocument::ExecCommandFuncNum: {
        String command = args[0]->toString(exec);
        bool userInterface = args[1]->toBoolean(exec);
        String value = valueToStringWithUndefinedOrNullCheck(exec, args[2]);


        KJS::JSValue* result = jsBoolean(imp->execCommand(command, userInterface, value));
        return result;
    }
    case JSDocument::QueryCommandEnabledFuncNum: {
        String command = args[0]->toString(exec);


        KJS::JSValue* result = jsBoolean(imp->queryCommandEnabled(command));
        return result;
    }
    case JSDocument::QueryCommandIndetermFuncNum: {
        String command = args[0]->toString(exec);


        KJS::JSValue* result = jsBoolean(imp->queryCommandIndeterm(command));
        return result;
    }
    case JSDocument::QueryCommandStateFuncNum: {
        String command = args[0]->toString(exec);


        KJS::JSValue* result = jsBoolean(imp->queryCommandState(command));
        return result;
    }
    case JSDocument::QueryCommandSupportedFuncNum: {
        String command = args[0]->toString(exec);


        KJS::JSValue* result = jsBoolean(imp->queryCommandSupported(command));
        return result;
    }
    case JSDocument::QueryCommandValueFuncNum: {
        String command = args[0]->toString(exec);


        KJS::JSValue* result = jsStringOrFalse(imp->queryCommandValue(command));
        return result;
    }
    case JSDocument::ElementFromPointFuncNum: {
        bool xOk;
        int x = args[0]->toInt32(exec, xOk);
        if (!xOk) {
            setDOMException(exec, TYPE_MISMATCH_ERR);
            return jsUndefined();
        }
        bool yOk;
        int y = args[1]->toInt32(exec, yOk);
        if (!yOk) {
            setDOMException(exec, TYPE_MISMATCH_ERR);
            return jsUndefined();
        }


        KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->elementFromPoint(x, y)));
        return result;
    }
    }
    return 0;
}