| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2005 Frerich Raabe <raabe@kde.org> | 2 * Copyright 2005 Frerich Raabe <raabe@kde.org> |
| 3 * Copyright (C) 2006 Apple Computer, Inc. | 3 * Copyright (C) 2006 Apple Computer, Inc. |
| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 delete m_topExpression; | 60 delete m_topExpression; |
| 61 } | 61 } |
| 62 | 62 |
| 63 PassRefPtr<XPathResult> XPathExpression::evaluate(Node* contextNode, unsigned sh
ort type, XPathResult*, ExceptionCode& ec) | 63 PassRefPtr<XPathResult> XPathExpression::evaluate(Node* contextNode, unsigned sh
ort type, XPathResult*, ExceptionCode& ec) |
| 64 { | 64 { |
| 65 if (!isValidContextNode(contextNode)) { | 65 if (!isValidContextNode(contextNode)) { |
| 66 ec = NOT_SUPPORTED_ERR; | 66 ec = NOT_SUPPORTED_ERR; |
| 67 return 0; | 67 return 0; |
| 68 } | 68 } |
| 69 | 69 |
| 70 Node* eventTarget = contextNode->ownerDocument() ? contextNode->ownerDocumen
t() : contextNode; | 70 EventTargetNode* eventTarget = contextNode->ownerDocument() |
| 71 ? contextNode->ownerDocument() |
| 72 : static_cast<EventTargetNode*>(contextNode); |
| 71 | 73 |
| 72 EvaluationContext& evaluationContext = Expression::evaluationContext(); | 74 EvaluationContext& evaluationContext = Expression::evaluationContext(); |
| 73 evaluationContext.node = contextNode; | 75 evaluationContext.node = contextNode; |
| 74 evaluationContext.size = 1; | 76 evaluationContext.size = 1; |
| 75 evaluationContext.position = 1; | 77 evaluationContext.position = 1; |
| 76 RefPtr<XPathResult> result = XPathResult::create(eventTarget, m_topExpressio
n->evaluate()); | 78 RefPtr<XPathResult> result = XPathResult::create(eventTarget, m_topExpressio
n->evaluate()); |
| 77 evaluationContext.node = 0; // Do not hold a reference to the context node,
as this may prevent the whole document from being destroyed in time. | 79 evaluationContext.node = 0; // Do not hold a reference to the context node,
as this may prevent the whole document from being destroyed in time. |
| 78 | 80 |
| 79 if (type != XPathResult::ANY_TYPE) { | 81 if (type != XPathResult::ANY_TYPE) { |
| 80 ec = 0; | 82 ec = 0; |
| 81 result->convertTo(type, ec); | 83 result->convertTo(type, ec); |
| 82 if (ec) | 84 if (ec) |
| 83 return 0; | 85 return 0; |
| 84 } | 86 } |
| 85 | 87 |
| 86 return result; | 88 return result; |
| 87 } | 89 } |
| 88 | 90 |
| 89 } | 91 } |
| 90 | 92 |
| 91 #endif // ENABLE(XPATH) | 93 #endif // ENABLE(XPATH) |
| OLD | NEW |