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 17 matching lines...) Expand all Loading... |
28 #include "bindings/core/v8/ExceptionState.h" | 28 #include "bindings/core/v8/ExceptionState.h" |
29 #include "core/xml/XPathExpression.h" | 29 #include "core/xml/XPathExpression.h" |
30 #include "core/xml/XPathResult.h" | 30 #include "core/xml/XPathResult.h" |
31 | 31 |
32 namespace blink { | 32 namespace blink { |
33 | 33 |
34 DocumentXPathEvaluator::DocumentXPathEvaluator() | 34 DocumentXPathEvaluator::DocumentXPathEvaluator() |
35 { | 35 { |
36 } | 36 } |
37 | 37 |
38 DocumentXPathEvaluator& DocumentXPathEvaluator::from(HeapSupplementable<Document
>& document) | 38 DocumentXPathEvaluator& DocumentXPathEvaluator::from(Supplementable<Document>& d
ocument) |
39 { | 39 { |
40 DocumentXPathEvaluator* cache = static_cast<DocumentXPathEvaluator*>(HeapSup
plement<Document>::from(document, supplementName())); | 40 DocumentXPathEvaluator* cache = static_cast<DocumentXPathEvaluator*>(Supplem
ent<Document>::from(document, supplementName())); |
41 if (!cache) { | 41 if (!cache) { |
42 cache = new DocumentXPathEvaluator(); | 42 cache = new DocumentXPathEvaluator; |
43 HeapSupplement<Document>::provideTo(document, supplementName(), adoptPtr
WillBeNoop(cache)); | 43 Supplement<Document>::provideTo(document, supplementName(), cache); |
44 } | 44 } |
45 return *cache; | 45 return *cache; |
46 } | 46 } |
47 | 47 |
48 XPathExpression* DocumentXPathEvaluator::createExpression(HeapSupplementable<Doc
ument>& document, const String& expression, XPathNSResolver* resolver, Exception
State& exceptionState) | 48 XPathExpression* DocumentXPathEvaluator::createExpression(Supplementable<Documen
t>& document, const String& expression, XPathNSResolver* resolver, ExceptionStat
e& exceptionState) |
49 { | 49 { |
50 DocumentXPathEvaluator& suplement = from(document); | 50 DocumentXPathEvaluator& suplement = from(document); |
51 if (!suplement.m_xpathEvaluator) | 51 if (!suplement.m_xpathEvaluator) |
52 suplement.m_xpathEvaluator = XPathEvaluator::create(); | 52 suplement.m_xpathEvaluator = XPathEvaluator::create(); |
53 return suplement.m_xpathEvaluator->createExpression(expression, resolver, ex
ceptionState); | 53 return suplement.m_xpathEvaluator->createExpression(expression, resolver, ex
ceptionState); |
54 } | 54 } |
55 | 55 |
56 XPathNSResolver* DocumentXPathEvaluator::createNSResolver(HeapSupplementable<Doc
ument>& document, Node* nodeResolver) | 56 XPathNSResolver* DocumentXPathEvaluator::createNSResolver(Supplementable<Documen
t>& document, Node* nodeResolver) |
57 { | 57 { |
58 DocumentXPathEvaluator& suplement = from(document); | 58 DocumentXPathEvaluator& suplement = from(document); |
59 if (!suplement.m_xpathEvaluator) | 59 if (!suplement.m_xpathEvaluator) |
60 suplement.m_xpathEvaluator = XPathEvaluator::create(); | 60 suplement.m_xpathEvaluator = XPathEvaluator::create(); |
61 return suplement.m_xpathEvaluator->createNSResolver(nodeResolver); | 61 return suplement.m_xpathEvaluator->createNSResolver(nodeResolver); |
62 } | 62 } |
63 | 63 |
64 XPathResult* DocumentXPathEvaluator::evaluate(HeapSupplementable<Document>& docu
ment, const String& expression, | 64 XPathResult* DocumentXPathEvaluator::evaluate(Supplementable<Document>& document
, const String& expression, |
65 Node* contextNode, XPathNSResolver* resolver, unsigned short type, | 65 Node* contextNode, XPathNSResolver* resolver, unsigned short type, |
66 const ScriptValue&, ExceptionState& exceptionState) | 66 const ScriptValue&, ExceptionState& exceptionState) |
67 { | 67 { |
68 DocumentXPathEvaluator& suplement = from(document); | 68 DocumentXPathEvaluator& suplement = from(document); |
69 if (!suplement.m_xpathEvaluator) | 69 if (!suplement.m_xpathEvaluator) |
70 suplement.m_xpathEvaluator = XPathEvaluator::create(); | 70 suplement.m_xpathEvaluator = XPathEvaluator::create(); |
71 return suplement.m_xpathEvaluator->evaluate(expression, contextNode, resolve
r, type, ScriptValue(), exceptionState); | 71 return suplement.m_xpathEvaluator->evaluate(expression, contextNode, resolve
r, type, ScriptValue(), exceptionState); |
72 } | 72 } |
73 | 73 |
74 DEFINE_TRACE(DocumentXPathEvaluator) | 74 DEFINE_TRACE(DocumentXPathEvaluator) |
75 { | 75 { |
76 visitor->trace(m_xpathEvaluator); | 76 visitor->trace(m_xpathEvaluator); |
77 HeapSupplement<Document>::trace(visitor); | 77 Supplement<Document>::trace(visitor); |
78 } | 78 } |
79 | 79 |
80 } // namespace blink | 80 } // namespace blink |
OLD | NEW |