| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005 Frerich Raabe <raabe@kde.org> | 2 * Copyright (C) 2005 Frerich Raabe <raabe@kde.org> |
| 3 * Copyright (C) 2006, 2009 Apple Inc. All rights reserved. | 3 * Copyright (C) 2006, 2009 Apple Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 #include "core/xml/XPathNSResolver.h" | 33 #include "core/xml/XPathNSResolver.h" |
| 34 #include "core/xml/XPathParser.h" | 34 #include "core/xml/XPathParser.h" |
| 35 #include "core/xml/XPathResult.h" | 35 #include "core/xml/XPathResult.h" |
| 36 #include "core/xml/XPathUtil.h" | 36 #include "core/xml/XPathUtil.h" |
| 37 #include "wtf/text/WTFString.h" | 37 #include "wtf/text/WTFString.h" |
| 38 | 38 |
| 39 namespace WebCore { | 39 namespace WebCore { |
| 40 | 40 |
| 41 using namespace XPath; | 41 using namespace XPath; |
| 42 | 42 |
| 43 PassRefPtr<XPathExpression> XPathExpression::createExpression(const String& expr
ession, XPathNSResolver* resolver, ExceptionState& es) | 43 PassRefPtr<XPathExpression> XPathExpression::createExpression(const String& expr
ession, XPathNSResolver* resolver, ExceptionState& exceptionState) |
| 44 { | 44 { |
| 45 RefPtr<XPathExpression> expr = XPathExpression::create(); | 45 RefPtr<XPathExpression> expr = XPathExpression::create(); |
| 46 Parser parser; | 46 Parser parser; |
| 47 | 47 |
| 48 expr->m_topExpression = parser.parseStatement(expression, resolver, es); | 48 expr->m_topExpression = parser.parseStatement(expression, resolver, exceptio
nState); |
| 49 if (!expr->m_topExpression) | 49 if (!expr->m_topExpression) |
| 50 return 0; | 50 return 0; |
| 51 | 51 |
| 52 return expr.release(); | 52 return expr.release(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 XPathExpression::~XPathExpression() | 55 XPathExpression::~XPathExpression() |
| 56 { | 56 { |
| 57 delete m_topExpression; | 57 delete m_topExpression; |
| 58 } | 58 } |
| 59 | 59 |
| 60 PassRefPtr<XPathResult> XPathExpression::evaluate(Node* contextNode, unsigned sh
ort type, XPathResult*, ExceptionState& es) | 60 PassRefPtr<XPathResult> XPathExpression::evaluate(Node* contextNode, unsigned sh
ort type, XPathResult*, ExceptionState& exceptionState) |
| 61 { | 61 { |
| 62 if (!isValidContextNode(contextNode)) { | 62 if (!isValidContextNode(contextNode)) { |
| 63 es.throwUninformativeAndGenericDOMException(NotSupportedError); | 63 exceptionState.throwUninformativeAndGenericDOMException(NotSupportedErro
r); |
| 64 return 0; | 64 return 0; |
| 65 } | 65 } |
| 66 | 66 |
| 67 EvaluationContext& evaluationContext = Expression::evaluationContext(); | 67 EvaluationContext& evaluationContext = Expression::evaluationContext(); |
| 68 evaluationContext.node = contextNode; | 68 evaluationContext.node = contextNode; |
| 69 evaluationContext.size = 1; | 69 evaluationContext.size = 1; |
| 70 evaluationContext.position = 1; | 70 evaluationContext.position = 1; |
| 71 evaluationContext.hadTypeConversionError = false; | 71 evaluationContext.hadTypeConversionError = false; |
| 72 RefPtr<XPathResult> result = XPathResult::create(&contextNode->document(), m
_topExpression->evaluate()); | 72 RefPtr<XPathResult> result = XPathResult::create(&contextNode->document(), m
_topExpression->evaluate()); |
| 73 evaluationContext.node = 0; // Do not hold a reference to the context node,
as this may prevent the whole document from being destroyed in time. | 73 evaluationContext.node = 0; // Do not hold a reference to the context node,
as this may prevent the whole document from being destroyed in time. |
| 74 | 74 |
| 75 if (evaluationContext.hadTypeConversionError) { | 75 if (evaluationContext.hadTypeConversionError) { |
| 76 // It is not specified what to do if type conversion fails while evaluat
ing an expression. | 76 // It is not specified what to do if type conversion fails while evaluat
ing an expression. |
| 77 es.throwUninformativeAndGenericDOMException(SyntaxError); | 77 exceptionState.throwUninformativeAndGenericDOMException(SyntaxError); |
| 78 return 0; | 78 return 0; |
| 79 } | 79 } |
| 80 | 80 |
| 81 if (type != XPathResult::ANY_TYPE) { | 81 if (type != XPathResult::ANY_TYPE) { |
| 82 result->convertTo(type, es); | 82 result->convertTo(type, exceptionState); |
| 83 if (es.hadException()) | 83 if (exceptionState.hadException()) |
| 84 return 0; | 84 return 0; |
| 85 } | 85 } |
| 86 | 86 |
| 87 return result; | 87 return result; |
| 88 } | 88 } |
| 89 | 89 |
| 90 } | 90 } |
| OLD | NEW |