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

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

Issue 99083002: WIP: Migrate generated bindings to new ExceptionState constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase. Created 7 years 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/XPathEvaluator.cpp ('k') | Source/core/xml/XPathParser.cpp » ('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.
11 * 2. Redistributions in binary form must reproduce the above copyright 11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the 12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution. 13 * documentation and/or other materials provided with the distribution.
14 * 14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */ 25 */
26 26
27 #include "config.h" 27 #include "config.h"
28 #include "core/xml/XPathExpression.h" 28 #include "core/xml/XPathExpression.h"
29 29
30 #include "bindings/v8/ExceptionMessages.h"
31 #include "bindings/v8/ExceptionState.h" 30 #include "bindings/v8/ExceptionState.h"
32 #include "core/dom/ExceptionCode.h" 31 #include "core/dom/ExceptionCode.h"
33 #include "core/xml/XPathExpressionNode.h" 32 #include "core/xml/XPathExpressionNode.h"
34 #include "core/xml/XPathNSResolver.h" 33 #include "core/xml/XPathNSResolver.h"
35 #include "core/xml/XPathParser.h" 34 #include "core/xml/XPathParser.h"
36 #include "core/xml/XPathResult.h" 35 #include "core/xml/XPathResult.h"
37 #include "core/xml/XPathUtil.h" 36 #include "core/xml/XPathUtil.h"
38 #include "wtf/text/WTFString.h" 37 #include "wtf/text/WTFString.h"
39 38
40 namespace WebCore { 39 namespace WebCore {
(...skipping 13 matching lines...) Expand all
54 } 53 }
55 54
56 XPathExpression::~XPathExpression() 55 XPathExpression::~XPathExpression()
57 { 56 {
58 delete m_topExpression; 57 delete m_topExpression;
59 } 58 }
60 59
61 PassRefPtr<XPathResult> XPathExpression::evaluate(Node* contextNode, unsigned sh ort type, XPathResult*, ExceptionState& exceptionState) 60 PassRefPtr<XPathResult> XPathExpression::evaluate(Node* contextNode, unsigned sh ort type, XPathResult*, ExceptionState& exceptionState)
62 { 61 {
63 if (!contextNode) { 62 if (!contextNode) {
64 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::f ailedToExecute("evaluate", "XPathExpression", "The context node provided is null .")); 63 exceptionState.throwDOMException(NotSupportedError, "The context node pr ovided is null.");
65 return 0; 64 return 0;
66 } 65 }
67 66
68 if (!isValidContextNode(contextNode)) { 67 if (!isValidContextNode(contextNode)) {
69 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::f ailedToExecute("evaluate", "XPathExpression", "The node provided is '" + context Node->nodeName() + "', which is not a valid context node type.")); 68 exceptionState.throwDOMException(NotSupportedError, "The node provided i s '" + contextNode->nodeName() + "', which is not a valid context node type.");
70 return 0; 69 return 0;
71 } 70 }
72 71
73 EvaluationContext& evaluationContext = Expression::evaluationContext(); 72 EvaluationContext& evaluationContext = Expression::evaluationContext();
74 evaluationContext.node = contextNode; 73 evaluationContext.node = contextNode;
75 evaluationContext.size = 1; 74 evaluationContext.size = 1;
76 evaluationContext.position = 1; 75 evaluationContext.position = 1;
77 evaluationContext.hadTypeConversionError = false; 76 evaluationContext.hadTypeConversionError = false;
78 RefPtr<XPathResult> result = XPathResult::create(&contextNode->document(), m _topExpression->evaluate()); 77 RefPtr<XPathResult> result = XPathResult::create(&contextNode->document(), m _topExpression->evaluate());
79 evaluationContext.node = 0; // Do not hold a reference to the context node, as this may prevent the whole document from being destroyed in time. 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 79
81 if (evaluationContext.hadTypeConversionError) { 80 if (evaluationContext.hadTypeConversionError) {
82 // It is not specified what to do if type conversion fails while evaluat ing an expression. 81 // It is not specified what to do if type conversion fails while evaluat ing an expression.
83 exceptionState.throwDOMException(SyntaxError, ExceptionMessages::failedT oExecute("evaluate", "XPathExpression", "Type conversion failed while evaluating the expression.")); 82 exceptionState.throwDOMException(SyntaxError, "Type conversion failed wh ile evaluating the expression.");
84 return 0; 83 return 0;
85 } 84 }
86 85
87 if (type != XPathResult::ANY_TYPE) { 86 if (type != XPathResult::ANY_TYPE) {
88 result->convertTo(type, exceptionState); 87 result->convertTo(type, exceptionState);
89 if (exceptionState.hadException()) 88 if (exceptionState.hadException())
90 return 0; 89 return 0;
91 } 90 }
92 91
93 return result; 92 return result;
94 } 93 }
95 94
96 } 95 }
OLDNEW
« no previous file with comments | « Source/core/xml/XPathEvaluator.cpp ('k') | Source/core/xml/XPathParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698