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

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

Issue 1099613003: Oilpan: have xml/ objects on the heap by default. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: simplify XPathResult dtor Created 5 years, 8 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
« no previous file with comments | « Source/core/xml/XPathExpression.h ('k') | Source/core/xml/XPathExpression.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 22 matching lines...) Expand all
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 blink { 39 namespace blink {
40 40
41 using namespace XPath; 41 using namespace XPath;
42 42
43 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(XPathExpression);
44
45 XPathExpression::XPathExpression() 43 XPathExpression::XPathExpression()
46 { 44 {
47 } 45 }
48 46
49 PassRefPtrWillBeRawPtr<XPathExpression> XPathExpression::createExpression(const String& expression, PassRefPtrWillBeRawPtr<XPathNSResolver> resolver, ExceptionS tate& exceptionState) 47 XPathExpression* XPathExpression::createExpression(const String& expression, XPa thNSResolver* resolver, ExceptionState& exceptionState)
50 { 48 {
51 RefPtrWillBeRawPtr<XPathExpression> expr = XPathExpression::create(); 49 XPathExpression* expr = XPathExpression::create();
52 Parser parser; 50 Parser parser;
53 51
54 expr->m_topExpression = parser.parseStatement(expression, resolver, exceptio nState); 52 expr->m_topExpression = parser.parseStatement(expression, resolver, exceptio nState);
55 if (!expr->m_topExpression) 53 if (!expr->m_topExpression)
56 return nullptr; 54 return nullptr;
57 55
58 return expr.release(); 56 return expr;
59 } 57 }
60 58
61 DEFINE_TRACE(XPathExpression) 59 DEFINE_TRACE(XPathExpression)
62 { 60 {
63 visitor->trace(m_topExpression); 61 visitor->trace(m_topExpression);
64 } 62 }
65 63
66 PassRefPtrWillBeRawPtr<XPathResult> XPathExpression::evaluate(Node* contextNode, unsigned short type, const ScriptValue&, ExceptionState& exceptionState) 64 XPathResult* XPathExpression::evaluate(Node* contextNode, unsigned short type, c onst ScriptValue&, ExceptionState& exceptionState)
67 { 65 {
68 if (!isValidContextNode(contextNode)) { 66 if (!isValidContextNode(contextNode)) {
69 exceptionState.throwDOMException(NotSupportedError, "The node provided i s '" + contextNode->nodeName() + "', which is not a valid context node type."); 67 exceptionState.throwDOMException(NotSupportedError, "The node provided i s '" + contextNode->nodeName() + "', which is not a valid context node type.");
70 return nullptr; 68 return nullptr;
71 } 69 }
72 70
73 EvaluationContext evaluationContext(*contextNode); 71 EvaluationContext evaluationContext(*contextNode);
74 RefPtrWillBeRawPtr<XPathResult> result = XPathResult::create(evaluationConte xt, m_topExpression->evaluate(evaluationContext)); 72 XPathResult* result = XPathResult::create(evaluationContext, m_topExpression ->evaluate(evaluationContext));
75 73
76 if (evaluationContext.hadTypeConversionError) { 74 if (evaluationContext.hadTypeConversionError) {
77 // It is not specified what to do if type conversion fails while evaluat ing an expression. 75 // It is not specified what to do if type conversion fails while evaluat ing an expression.
78 exceptionState.throwDOMException(SyntaxError, "Type conversion failed wh ile evaluating the expression."); 76 exceptionState.throwDOMException(SyntaxError, "Type conversion failed wh ile evaluating the expression.");
79 return nullptr; 77 return nullptr;
80 } 78 }
81 79
82 if (type != XPathResult::ANY_TYPE) { 80 if (type != XPathResult::ANY_TYPE) {
83 result->convertTo(type, exceptionState); 81 result->convertTo(type, exceptionState);
84 if (exceptionState.hadException()) 82 if (exceptionState.hadException())
85 return nullptr; 83 return nullptr;
86 } 84 }
87 85
88 return result; 86 return result;
89 } 87 }
90 88
91 } 89 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/xml/XPathExpression.h ('k') | Source/core/xml/XPathExpression.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698