Changeset 207541 in webkit for trunk/Source/WebCore/xml/XPathExpression.cpp
- Timestamp:
- Oct 19, 2016, 9:57:31 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/xml/XPathExpression.cpp
r200550 r207541 35 35 #include "XPathResult.h" 36 36 #include "XPathUtil.h" 37 #include <wtf/text/WTFString.h>38 37 39 38 namespace WebCore { … … 46 45 } 47 46 48 RefPtr<XPathExpression> XPathExpression::createExpression(const String& expression, RefPtr<XPathNSResolver>&& resolver, ExceptionCode& ec)47 ExceptionOr<Ref<XPathExpression>> XPathExpression::createExpression(const String& expression, RefPtr<XPathNSResolver>&& resolver) 49 48 { 50 auto parse dExpression = Parser::parseStatement(expression, WTFMove(resolver), ec);51 if ( !parsedExpression)52 return nullptr;49 auto parseResult = Parser::parseStatement(expression, WTFMove(resolver)); 50 if (parseResult.hasException()) 51 return parseResult.releaseException(); 53 52 54 return adoptRef(*new XPathExpression( WTFMove(parsedExpression)));53 return adoptRef(*new XPathExpression(parseResult.releaseReturnValue())); 55 54 } 56 55 … … 59 58 } 60 59 61 RefPtr<XPathResult> XPathExpression::evaluate(Node* contextNode, unsigned short type, XPathResult*, ExceptionCode& ec) 60 // FIXME: Why does this take an XPathResult that it ignores? 61 ExceptionOr<Ref<XPathResult>> XPathExpression::evaluate(Node* contextNode, unsigned short type, XPathResult*) 62 62 { 63 if (!isValidContextNode(contextNode)) { 64 ec = NOT_SUPPORTED_ERR; 65 return nullptr; 66 } 63 if (!isValidContextNode(contextNode)) 64 return Exception { NOT_SUPPORTED_ERR }; 67 65 68 66 EvaluationContext& evaluationContext = Expression::evaluationContext(); … … 71 69 evaluationContext.position = 1; 72 70 evaluationContext.hadTypeConversionError = false; 73 RefPtr<XPathResult> result = XPathResult::create(&contextNode->document(), m_topExpression->evaluate());71 auto result = XPathResult::create(contextNode->document(), m_topExpression->evaluate()); 74 72 evaluationContext.node = nullptr; // Do not hold a reference to the context node, as this may prevent the whole document from being destroyed in time. 75 73 … … 77 75 // It is not specified what to do if type conversion fails while evaluating an expression, and INVALID_EXPRESSION_ERR is not exactly right 78 76 // when the failure happens in an otherwise valid expression because of a variable. But XPathEvaluator does not support variables, so it's close enough. 79 ec = XPathException::INVALID_EXPRESSION_ERR; 80 return nullptr; 77 return Exception { XPathException::INVALID_EXPRESSION_ERR }; 81 78 } 82 79 83 80 if (type != XPathResult::ANY_TYPE) { 84 ec = 0; 85 result->convertTo(type, ec); 86 if (ec) 87 return nullptr; 81 auto convertToResult = result->convertTo(type); 82 if (convertToResult.hasException()) 83 return convertToResult.releaseException(); 88 84 } 89 85 90 return result;86 return WTFMove(result); 91 87 } 92 88
Note:
See TracChangeset
for help on using the changeset viewer.