| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 if (!isValidContextNode(contextNode)) { | 62 if (!isValidContextNode(contextNode)) { |
| 63 es.throwDOMException(NotSupportedError); | 63 es.throwDOMException(NotSupportedError); |
| 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.throwDOMException(SyntaxError); | 77 es.throwDOMException(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, es); |
| 83 if (es.hadException()) | 83 if (es.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 |