This source file includes following definitions.
- createExpression
- createNSResolver
- evaluate
#include "config.h"
#include "core/xml/XPathEvaluator.h"
#include "bindings/v8/ExceptionState.h"
#include "core/dom/ExceptionCode.h"
#include "core/dom/Node.h"
#include "core/xml/NativeXPathNSResolver.h"
#include "core/xml/XPathExpression.h"
#include "core/xml/XPathResult.h"
#include "core/xml/XPathUtil.h"
namespace WebCore {
using namespace XPath;
PassRefPtrWillBeRawPtr<XPathExpression> XPathEvaluator::createExpression(const String& expression, PassRefPtrWillBeRawPtr<XPathNSResolver> resolver, ExceptionState& exceptionState)
{
return XPathExpression::createExpression(expression, resolver, exceptionState);
}
PassRefPtrWillBeRawPtr<XPathNSResolver> XPathEvaluator::createNSResolver(Node* nodeResolver)
{
return NativeXPathNSResolver::create(nodeResolver);
}
PassRefPtrWillBeRawPtr<XPathResult> XPathEvaluator::evaluate(const String& expression, Node* contextNode,
PassRefPtrWillBeRawPtr<XPathNSResolver> resolver, unsigned short type, XPathResult* result, ExceptionState& exceptionState)
{
if (!contextNode) {
exceptionState.throwDOMException(NotSupportedError, "The context node provided is null.");
return nullptr;
}
if (!isValidContextNode(contextNode)) {
exceptionState.throwDOMException(NotSupportedError, "The node provided is '" + contextNode->nodeName() + "', which is not a valid context node type.");
return nullptr;
}
RefPtrWillBeRawPtr<XPathExpression> expr = createExpression(expression, resolver, exceptionState);
if (exceptionState.hadException())
return nullptr;
return expr->evaluate(contextNode, type, result, exceptionState);
}
}