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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 DEFINE_TRACE(XPathExpression) { | 59 DEFINE_TRACE(XPathExpression) { |
60 visitor->trace(m_topExpression); | 60 visitor->trace(m_topExpression); |
61 } | 61 } |
62 | 62 |
63 XPathResult* XPathExpression::evaluate(Node* contextNode, | 63 XPathResult* XPathExpression::evaluate(Node* contextNode, |
64 unsigned short type, | 64 unsigned short type, |
65 const ScriptValue&, | 65 const ScriptValue&, |
66 ExceptionState& exceptionState) { | 66 ExceptionState& exceptionState) { |
67 if (!isValidContextNode(contextNode)) { | 67 if (!isValidContextNode(contextNode)) { |
68 exceptionState.throwDOMException( | 68 exceptionState.throwDOMException( |
69 NotSupportedError, "The node provided is '" + contextNode->nodeName() + | 69 NotSupportedError, |
70 "', which is not a valid context node type."); | 70 "The node provided is '" + contextNode->nodeName() + |
| 71 "', which is not a valid context node type."); |
71 return nullptr; | 72 return nullptr; |
72 } | 73 } |
73 | 74 |
74 EvaluationContext evaluationContext(*contextNode); | 75 EvaluationContext evaluationContext(*contextNode); |
75 XPathResult* result = XPathResult::create( | 76 XPathResult* result = XPathResult::create( |
76 evaluationContext, m_topExpression->evaluate(evaluationContext)); | 77 evaluationContext, m_topExpression->evaluate(evaluationContext)); |
77 | 78 |
78 if (evaluationContext.hadTypeConversionError) { | 79 if (evaluationContext.hadTypeConversionError) { |
79 // It is not specified what to do if type conversion fails while evaluating | 80 // It is not specified what to do if type conversion fails while evaluating |
80 // an expression. | 81 // an expression. |
81 exceptionState.throwDOMException( | 82 exceptionState.throwDOMException( |
82 SyntaxError, "Type conversion failed while evaluating the expression."); | 83 SyntaxError, "Type conversion failed while evaluating the expression."); |
83 return nullptr; | 84 return nullptr; |
84 } | 85 } |
85 | 86 |
86 if (type != XPathResult::kAnyType) { | 87 if (type != XPathResult::kAnyType) { |
87 result->convertTo(type, exceptionState); | 88 result->convertTo(type, exceptionState); |
88 if (exceptionState.hadException()) | 89 if (exceptionState.hadException()) |
89 return nullptr; | 90 return nullptr; |
90 } | 91 } |
91 | 92 |
92 return result; | 93 return result; |
93 } | 94 } |
94 | 95 |
95 } // namespace blink | 96 } // namespace blink |
OLD | NEW |