JSValue* jsRangePrototypeFunctionDetach(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) { if (!thisValue->isObject(&JSRange::s_info)) return throwError(exec, TypeError); JSRange* castedThisObj = static_cast<JSRange*>(thisValue); Range* imp = static_cast<Range*>(castedThisObj->impl()); ExceptionCode ec = 0; imp->detach(ec); setDOMException(exec, ec); return jsUndefined(); }
JSValue* JSRangePrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args) { if (!thisObj->inherits(&JSRange::info)) return throwError(exec, TypeError); Range* imp = static_cast<Range*>(static_cast<JSRange*>(thisObj)->impl()); switch (id) { case JSRange::SetStartFuncNum: { ExceptionCode ec = 0; Node* refNode = toNode(args[0]); bool offsetOk; int offset = args[1]->toInt32(exec, offsetOk); if (!offsetOk) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); } imp->setStart(refNode, offset, ec); setDOMException(exec, ec); return jsUndefined(); } case JSRange::SetEndFuncNum: { ExceptionCode ec = 0; Node* refNode = toNode(args[0]); bool offsetOk; int offset = args[1]->toInt32(exec, offsetOk); if (!offsetOk) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); } imp->setEnd(refNode, offset, ec); setDOMException(exec, ec); return jsUndefined(); } case JSRange::SetStartBeforeFuncNum: { ExceptionCode ec = 0; Node* refNode = toNode(args[0]); imp->setStartBefore(refNode, ec); setDOMException(exec, ec); return jsUndefined(); } case JSRange::SetStartAfterFuncNum: { ExceptionCode ec = 0; Node* refNode = toNode(args[0]); imp->setStartAfter(refNode, ec); setDOMException(exec, ec); return jsUndefined(); } case JSRange::SetEndBeforeFuncNum: { ExceptionCode ec = 0; Node* refNode = toNode(args[0]); imp->setEndBefore(refNode, ec); setDOMException(exec, ec); return jsUndefined(); } case JSRange::SetEndAfterFuncNum: { ExceptionCode ec = 0; Node* refNode = toNode(args[0]); imp->setEndAfter(refNode, ec); setDOMException(exec, ec); return jsUndefined(); } case JSRange::CollapseFuncNum: { ExceptionCode ec = 0; bool toStart = args[0]->toBoolean(exec); imp->collapse(toStart, ec); setDOMException(exec, ec); return jsUndefined(); } case JSRange::SelectNodeFuncNum: { ExceptionCode ec = 0; Node* refNode = toNode(args[0]); imp->selectNode(refNode, ec); setDOMException(exec, ec); return jsUndefined(); } case JSRange::SelectNodeContentsFuncNum: { ExceptionCode ec = 0; Node* refNode = toNode(args[0]); imp->selectNodeContents(refNode, ec); setDOMException(exec, ec); return jsUndefined(); } case JSRange::CompareBoundaryPointsFuncNum: { ExceptionCode ec = 0; Range::CompareHow how = static_cast<Range::CompareHow>(args[0]->toInt32(exec)); Range* sourceRange = toRange(args[1]); KJS::JSValue* result = jsNumber(imp->compareBoundaryPoints(how, sourceRange, ec)); setDOMException(exec, ec); return result; } case JSRange::DeleteContentsFuncNum: { ExceptionCode ec = 0; imp->deleteContents(ec); setDOMException(exec, ec); return jsUndefined(); } case JSRange::ExtractContentsFuncNum: { ExceptionCode ec = 0; KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->extractContents(ec))); setDOMException(exec, ec); return result; } case JSRange::CloneContentsFuncNum: { ExceptionCode ec = 0; KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->cloneContents(ec))); setDOMException(exec, ec); return result; } case JSRange::InsertNodeFuncNum: { ExceptionCode ec = 0; Node* newNode = toNode(args[0]); imp->insertNode(newNode, ec); setDOMException(exec, ec); return jsUndefined(); } case JSRange::SurroundContentsFuncNum: { ExceptionCode ec = 0; Node* newParent = toNode(args[0]); imp->surroundContents(newParent, ec); setDOMException(exec, ec); return jsUndefined(); } case JSRange::CloneRangeFuncNum: { ExceptionCode ec = 0; KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->cloneRange(ec))); setDOMException(exec, ec); return result; } case JSRange::ToStringFuncNum: { ExceptionCode ec = 0; KJS::JSValue* result = jsString(imp->toString(ec)); setDOMException(exec, ec); return result; } case JSRange::DetachFuncNum: { ExceptionCode ec = 0; imp->detach(ec); setDOMException(exec, ec); return jsUndefined(); } case JSRange::CreateContextualFragmentFuncNum: { ExceptionCode ec = 0; String html = args[0]->toString(exec); KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->createContextualFragment(html, ec))); setDOMException(exec, ec); return result; } case JSRange::IntersectsNodeFuncNum: { ExceptionCode ec = 0; Node* refNode = toNode(args[0]); KJS::JSValue* result = jsBoolean(imp->intersectsNode(refNode, ec)); setDOMException(exec, ec); return result; } case JSRange::CompareNodeFuncNum: { ExceptionCode ec = 0; Node* refNode = toNode(args[0]); KJS::JSValue* result = jsNumber(imp->compareNode(refNode, ec)); setDOMException(exec, ec); return result; } case JSRange::ComparePointFuncNum: { ExceptionCode ec = 0; Node* refNode = toNode(args[0]); bool offsetOk; int offset = args[1]->toInt32(exec, offsetOk); if (!offsetOk) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); } KJS::JSValue* result = jsNumber(imp->comparePoint(refNode, offset, ec)); setDOMException(exec, ec); return result; } case JSRange::IsPointInRangeFuncNum: { ExceptionCode ec = 0; Node* refNode = toNode(args[0]); bool offsetOk; int offset = args[1]->toInt32(exec, offsetOk); if (!offsetOk) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); } KJS::JSValue* result = jsBoolean(imp->isPointInRange(refNode, offset, ec)); setDOMException(exec, ec); return result; } } return 0; }