summaryrefslogtreecommitdiff
path: root/Source/WebCore/xml/XPathExpression.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/xml/XPathExpression.cpp
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/xml/XPathExpression.cpp')
-rw-r--r--Source/WebCore/xml/XPathExpression.cpp36
1 files changed, 16 insertions, 20 deletions
diff --git a/Source/WebCore/xml/XPathExpression.cpp b/Source/WebCore/xml/XPathExpression.cpp
index c659c829a..99aacfde1 100644
--- a/Source/WebCore/xml/XPathExpression.cpp
+++ b/Source/WebCore/xml/XPathExpression.cpp
@@ -34,60 +34,56 @@
#include "XPathParser.h"
#include "XPathResult.h"
#include "XPathUtil.h"
-#include <wtf/text/WTFString.h>
namespace WebCore {
using namespace XPath;
inline XPathExpression::XPathExpression(std::unique_ptr<XPath::Expression> expression)
- : m_topExpression(std::move(expression))
+ : m_topExpression(WTFMove(expression))
{
}
-PassRefPtr<XPathExpression> XPathExpression::createExpression(const String& expression, XPathNSResolver* resolver, ExceptionCode& ec)
+ExceptionOr<Ref<XPathExpression>> XPathExpression::createExpression(const String& expression, RefPtr<XPathNSResolver>&& resolver)
{
- auto parsedExpression = Parser::parseStatement(expression, resolver, ec);
- if (!parsedExpression)
- return nullptr;
+ auto parseResult = Parser::parseStatement(expression, WTFMove(resolver));
+ if (parseResult.hasException())
+ return parseResult.releaseException();
- return adoptRef(new XPathExpression(std::move(parsedExpression)));
+ return adoptRef(*new XPathExpression(parseResult.releaseReturnValue()));
}
XPathExpression::~XPathExpression()
{
}
-PassRefPtr<XPathResult> XPathExpression::evaluate(Node* contextNode, unsigned short type, XPathResult*, ExceptionCode& ec)
+// FIXME: Why does this take an XPathResult that it ignores?
+ExceptionOr<Ref<XPathResult>> XPathExpression::evaluate(Node* contextNode, unsigned short type, XPathResult*)
{
- if (!isValidContextNode(contextNode)) {
- ec = NOT_SUPPORTED_ERR;
- return 0;
- }
+ if (!isValidContextNode(contextNode))
+ return Exception { NOT_SUPPORTED_ERR };
EvaluationContext& evaluationContext = Expression::evaluationContext();
evaluationContext.node = contextNode;
evaluationContext.size = 1;
evaluationContext.position = 1;
evaluationContext.hadTypeConversionError = false;
- RefPtr<XPathResult> result = XPathResult::create(&contextNode->document(), m_topExpression->evaluate());
+ auto result = XPathResult::create(contextNode->document(), m_topExpression->evaluate());
evaluationContext.node = nullptr; // Do not hold a reference to the context node, as this may prevent the whole document from being destroyed in time.
if (evaluationContext.hadTypeConversionError) {
// It is not specified what to do if type conversion fails while evaluating an expression, and INVALID_EXPRESSION_ERR is not exactly right
// when the failure happens in an otherwise valid expression because of a variable. But XPathEvaluator does not support variables, so it's close enough.
- ec = XPathException::INVALID_EXPRESSION_ERR;
- return nullptr;
+ return Exception { XPathException::INVALID_EXPRESSION_ERR };
}
if (type != XPathResult::ANY_TYPE) {
- ec = 0;
- result->convertTo(type, ec);
- if (ec)
- return nullptr;
+ auto convertToResult = result->convertTo(type);
+ if (convertToResult.hasException())
+ return convertToResult.releaseException();
}
- return result;
+ return WTFMove(result);
}
}