| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google, Inc. | 2 * Copyright (C) 2013 Google, Inc. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 namespace WebCore { | 34 namespace WebCore { |
| 35 | 35 |
| 36 DocumentXPathEvaluator::DocumentXPathEvaluator() | 36 DocumentXPathEvaluator::DocumentXPathEvaluator() |
| 37 { | 37 { |
| 38 } | 38 } |
| 39 | 39 |
| 40 DocumentXPathEvaluator::~DocumentXPathEvaluator() | 40 DocumentXPathEvaluator::~DocumentXPathEvaluator() |
| 41 { | 41 { |
| 42 } | 42 } |
| 43 | 43 |
| 44 DocumentXPathEvaluator* DocumentXPathEvaluator::from(DocumentSupplementable* doc
ument) | 44 DocumentXPathEvaluator& DocumentXPathEvaluator::from(DocumentSupplementable& doc
ument) |
| 45 { | 45 { |
| 46 DocumentXPathEvaluator* cache = static_cast<DocumentXPathEvaluator*>(Documen
tSupplement::from(document, supplementName())); | 46 DocumentXPathEvaluator* cache = static_cast<DocumentXPathEvaluator*>(Documen
tSupplement::from(document, supplementName())); |
| 47 if (!cache) { | 47 if (!cache) { |
| 48 cache = new DocumentXPathEvaluator(); | 48 cache = new DocumentXPathEvaluator(); |
| 49 DocumentSupplement::provideTo(document, supplementName(), adoptPtr(cache
)); | 49 DocumentSupplement::provideTo(document, supplementName(), adoptPtr(cache
)); |
| 50 } | 50 } |
| 51 return cache; | 51 return *cache; |
| 52 } | 52 } |
| 53 | 53 |
| 54 PassRefPtr<XPathExpression> DocumentXPathEvaluator::createExpression(DocumentSup
plementable* document, | 54 PassRefPtr<XPathExpression> DocumentXPathEvaluator::createExpression(DocumentSup
plementable& document, |
| 55 const String& expression, PassRefPtr<XPathNSResolver> resolver, ExceptionSta
te& exceptionState) | 55 const String& expression, PassRefPtr<XPathNSResolver> resolver, ExceptionSta
te& exceptionState) |
| 56 { | 56 { |
| 57 DocumentXPathEvaluator* suplement = from(document); | 57 DocumentXPathEvaluator& suplement = from(document); |
| 58 if (!suplement->m_xpathEvaluator) | 58 if (!suplement.m_xpathEvaluator) |
| 59 suplement->m_xpathEvaluator = XPathEvaluator::create(); | 59 suplement.m_xpathEvaluator = XPathEvaluator::create(); |
| 60 return suplement->m_xpathEvaluator->createExpression(expression, resolver, e
xceptionState); | 60 return suplement.m_xpathEvaluator->createExpression(expression, resolver, ex
ceptionState); |
| 61 } | 61 } |
| 62 | 62 |
| 63 PassRefPtr<XPathNSResolver> DocumentXPathEvaluator::createNSResolver(DocumentSup
plementable* document, Node* nodeResolver) | 63 PassRefPtr<XPathNSResolver> DocumentXPathEvaluator::createNSResolver(DocumentSup
plementable& document, Node* nodeResolver) |
| 64 { | 64 { |
| 65 DocumentXPathEvaluator* suplement = from(document); | 65 DocumentXPathEvaluator& suplement = from(document); |
| 66 if (!suplement->m_xpathEvaluator) | 66 if (!suplement.m_xpathEvaluator) |
| 67 suplement->m_xpathEvaluator = XPathEvaluator::create(); | 67 suplement.m_xpathEvaluator = XPathEvaluator::create(); |
| 68 return suplement->m_xpathEvaluator->createNSResolver(nodeResolver); | 68 return suplement.m_xpathEvaluator->createNSResolver(nodeResolver); |
| 69 } | 69 } |
| 70 | 70 |
| 71 PassRefPtr<XPathResult> DocumentXPathEvaluator::evaluate(DocumentSupplementable*
document, const String& expression, | 71 PassRefPtr<XPathResult> DocumentXPathEvaluator::evaluate(DocumentSupplementable&
document, const String& expression, |
| 72 Node* contextNode, PassRefPtr<XPathNSResolver> resolver, unsigned short type
, | 72 Node* contextNode, PassRefPtr<XPathNSResolver> resolver, unsigned short type
, |
| 73 XPathResult* result, ExceptionState& exceptionState) | 73 XPathResult* result, ExceptionState& exceptionState) |
| 74 { | 74 { |
| 75 DocumentXPathEvaluator* suplement = from(document); | 75 DocumentXPathEvaluator& suplement = from(document); |
| 76 if (!suplement->m_xpathEvaluator) | 76 if (!suplement.m_xpathEvaluator) |
| 77 suplement->m_xpathEvaluator = XPathEvaluator::create(); | 77 suplement.m_xpathEvaluator = XPathEvaluator::create(); |
| 78 return suplement->m_xpathEvaluator->evaluate(expression, contextNode, resolv
er, type, result, exceptionState); | 78 return suplement.m_xpathEvaluator->evaluate(expression, contextNode, resolve
r, type, result, exceptionState); |
| 79 } | 79 } |
| 80 | 80 |
| 81 } // namespace WebCore | 81 } // namespace WebCore |
| OLD | NEW |