Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Side by Side Diff: third_party/WebKit/Source/core/xml/DocumentXPathEvaluator.cpp

Issue 2617103002: Use a new Supplement constructor for Supplement<Document> (Part 1) (Closed)
Patch Set: temp Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 13 matching lines...) Expand all
24 */ 24 */
25 25
26 #include "core/xml/DocumentXPathEvaluator.h" 26 #include "core/xml/DocumentXPathEvaluator.h"
27 27
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(Document& document)
35 : Supplement<Document>(document) {}
35 36
36 DocumentXPathEvaluator& DocumentXPathEvaluator::from( 37 DocumentXPathEvaluator& DocumentXPathEvaluator::from(Document& document) {
37 Supplementable<Document>& document) {
38 DocumentXPathEvaluator* cache = static_cast<DocumentXPathEvaluator*>( 38 DocumentXPathEvaluator* cache = static_cast<DocumentXPathEvaluator*>(
39 Supplement<Document>::from(document, supplementName())); 39 Supplement<Document>::from(document, supplementName()));
40 if (!cache) { 40 if (!cache) {
41 cache = new DocumentXPathEvaluator; 41 cache = new DocumentXPathEvaluator(document);
42 Supplement<Document>::provideTo(document, supplementName(), cache); 42 Supplement<Document>::provideTo(document, supplementName(), cache);
43 } 43 }
44 return *cache; 44 return *cache;
45 } 45 }
46 46
47 XPathExpression* DocumentXPathEvaluator::createExpression( 47 XPathExpression* DocumentXPathEvaluator::createExpression(
48 Supplementable<Document>& document, 48 Document& document,
49 const String& expression, 49 const String& expression,
50 XPathNSResolver* resolver, 50 XPathNSResolver* resolver,
51 ExceptionState& exceptionState) { 51 ExceptionState& exceptionState) {
52 DocumentXPathEvaluator& suplement = from(document); 52 DocumentXPathEvaluator& suplement = from(document);
53 if (!suplement.m_xpathEvaluator) 53 if (!suplement.m_xpathEvaluator)
54 suplement.m_xpathEvaluator = XPathEvaluator::create(); 54 suplement.m_xpathEvaluator = XPathEvaluator::create();
55 return suplement.m_xpathEvaluator->createExpression(expression, resolver, 55 return suplement.m_xpathEvaluator->createExpression(expression, resolver,
56 exceptionState); 56 exceptionState);
57 } 57 }
58 58
59 XPathNSResolver* DocumentXPathEvaluator::createNSResolver( 59 XPathNSResolver* DocumentXPathEvaluator::createNSResolver(Document& document,
60 Supplementable<Document>& document, 60 Node* nodeResolver) {
61 Node* nodeResolver) {
62 DocumentXPathEvaluator& suplement = from(document); 61 DocumentXPathEvaluator& suplement = from(document);
63 if (!suplement.m_xpathEvaluator) 62 if (!suplement.m_xpathEvaluator)
64 suplement.m_xpathEvaluator = XPathEvaluator::create(); 63 suplement.m_xpathEvaluator = XPathEvaluator::create();
65 return suplement.m_xpathEvaluator->createNSResolver(nodeResolver); 64 return suplement.m_xpathEvaluator->createNSResolver(nodeResolver);
66 } 65 }
67 66
68 XPathResult* DocumentXPathEvaluator::evaluate( 67 XPathResult* DocumentXPathEvaluator::evaluate(Document& document,
69 Supplementable<Document>& document, 68 const String& expression,
70 const String& expression, 69 Node* contextNode,
71 Node* contextNode, 70 XPathNSResolver* resolver,
72 XPathNSResolver* resolver, 71 unsigned short type,
73 unsigned short type, 72 const ScriptValue&,
74 const ScriptValue&, 73 ExceptionState& exceptionState) {
75 ExceptionState& exceptionState) {
76 DocumentXPathEvaluator& suplement = from(document); 74 DocumentXPathEvaluator& suplement = from(document);
77 if (!suplement.m_xpathEvaluator) 75 if (!suplement.m_xpathEvaluator)
78 suplement.m_xpathEvaluator = XPathEvaluator::create(); 76 suplement.m_xpathEvaluator = XPathEvaluator::create();
79 return suplement.m_xpathEvaluator->evaluate( 77 return suplement.m_xpathEvaluator->evaluate(
80 expression, contextNode, resolver, type, ScriptValue(), exceptionState); 78 expression, contextNode, resolver, type, ScriptValue(), exceptionState);
81 } 79 }
82 80
83 DEFINE_TRACE(DocumentXPathEvaluator) { 81 DEFINE_TRACE(DocumentXPathEvaluator) {
84 visitor->trace(m_xpathEvaluator); 82 visitor->trace(m_xpathEvaluator);
85 Supplement<Document>::trace(visitor); 83 Supplement<Document>::trace(visitor);
86 } 84 }
87 85
88 } // namespace blink 86 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698