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

Side by Side Diff: Source/core/xml/XPathExpression.cpp

Issue 166903010: Oilpan: Move core/xml/ to oilpan's heap (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
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 20 matching lines...) Expand all
31 #include "core/dom/ExceptionCode.h" 31 #include "core/dom/ExceptionCode.h"
32 #include "core/xml/XPathExpressionNode.h" 32 #include "core/xml/XPathExpressionNode.h"
33 #include "core/xml/XPathNSResolver.h" 33 #include "core/xml/XPathNSResolver.h"
34 #include "core/xml/XPathParser.h" 34 #include "core/xml/XPathParser.h"
35 #include "core/xml/XPathResult.h" 35 #include "core/xml/XPathResult.h"
36 #include "core/xml/XPathUtil.h" 36 #include "core/xml/XPathUtil.h"
37 #include "wtf/text/WTFString.h" 37 #include "wtf/text/WTFString.h"
38 38
39 namespace WebCore { 39 namespace WebCore {
40 40
41 DEFINE_GC_INFO(XPathExpression);
42
41 using namespace XPath; 43 using namespace XPath;
42 44
43 PassRefPtr<XPathExpression> XPathExpression::createExpression(const String& expr ession, PassRefPtr<XPathNSResolver> resolver, ExceptionState& exceptionState) 45 PassRefPtrWillBeRawPtr<XPathExpression> XPathExpression::createExpression(const String& expression, PassRefPtrWillBeRawPtr<XPathNSResolver> resolver, ExceptionS tate& exceptionState)
44 { 46 {
45 RefPtr<XPathExpression> expr = XPathExpression::create(); 47 RefPtrWillBeRawPtr<XPathExpression> expr = XPathExpression::create();
46 Parser parser; 48 Parser parser;
47 49
48 expr->m_topExpression = parser.parseStatement(expression, resolver, exceptio nState); 50 expr->m_topExpression = parser.parseStatement(expression, resolver, exceptio nState);
49 if (!expr->m_topExpression) 51 if (!expr->m_topExpression)
50 return 0; 52 return 0;
51 53
52 return expr.release(); 54 return expr.release();
53 } 55 }
54 56
55 XPathExpression::~XPathExpression() 57 XPathExpression::~XPathExpression()
56 { 58 {
57 delete m_topExpression; 59 delete m_topExpression;
58 } 60 }
59 61
60 PassRefPtr<XPathResult> XPathExpression::evaluate(Node* contextNode, unsigned sh ort type, XPathResult*, ExceptionState& exceptionState) 62 PassRefPtrWillBeRawPtr<XPathResult> XPathExpression::evaluate(Node* contextNode, unsigned short type, XPathResult*, ExceptionState& exceptionState)
61 { 63 {
62 if (!contextNode) { 64 if (!contextNode) {
63 exceptionState.throwDOMException(NotSupportedError, "The context node pr ovided is null."); 65 exceptionState.throwDOMException(NotSupportedError, "The context node pr ovided is null.");
64 return 0; 66 return 0;
65 } 67 }
66 68
67 if (!isValidContextNode(contextNode)) { 69 if (!isValidContextNode(contextNode)) {
68 exceptionState.throwDOMException(NotSupportedError, "The node provided i s '" + contextNode->nodeName() + "', which is not a valid context node type."); 70 exceptionState.throwDOMException(NotSupportedError, "The node provided i s '" + contextNode->nodeName() + "', which is not a valid context node type.");
69 return 0; 71 return 0;
70 } 72 }
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 evaluationContext.hadTypeConversionError = false; 78 evaluationContext.hadTypeConversionError = false;
77 RefPtr<XPathResult> result = XPathResult::create(&contextNode->document(), m _topExpression->evaluate()); 79 RefPtrWillBeRawPtr<XPathResult> result = XPathResult::create(&contextNode->d ocument(), m_topExpression->evaluate());
78 evaluationContext.node = 0; // Do not hold a reference to the context node, as this may prevent the whole document from being destroyed in time. 80 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 81
80 if (evaluationContext.hadTypeConversionError) { 82 if (evaluationContext.hadTypeConversionError) {
81 // It is not specified what to do if type conversion fails while evaluat ing an expression. 83 // It is not specified what to do if type conversion fails while evaluat ing an expression.
82 exceptionState.throwDOMException(SyntaxError, "Type conversion failed wh ile evaluating the expression."); 84 exceptionState.throwDOMException(SyntaxError, "Type conversion failed wh ile evaluating the expression.");
83 return 0; 85 return 0;
84 } 86 }
85 87
86 if (type != XPathResult::ANY_TYPE) { 88 if (type != XPathResult::ANY_TYPE) {
87 result->convertTo(type, exceptionState); 89 result->convertTo(type, exceptionState);
88 if (exceptionState.hadException()) 90 if (exceptionState.hadException())
89 return 0; 91 return 0;
90 } 92 }
91 93
92 return result; 94 return result;
93 } 95 }
94 96
95 } 97 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698