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

Side by Side Diff: third_party/WebKit/WebCore/bindings/js/ScriptFunctionCall.cpp

Issue 46097: WebKit merge 41660:41709 (WebKit side).... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 9 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
(Empty)
1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #include "config.h"
32 #include "ScriptFunctionCall.h"
33
34 #include "JSDOMBinding.h"
35 #include "ScriptValue.h"
36 #include <runtime/JSLock.h>
37
38 using namespace JSC;
39
40 namespace WebCore {
41
42 ScriptFunctionCall::ScriptFunctionCall(ScriptState* exec, const ScriptObject& th isObject, const char* name)
43 : m_exec(exec)
44 , m_thisObject(thisObject)
45 , m_name(name)
46 {
47 }
48
49 void ScriptFunctionCall::appendArgument(const ScriptObject& argument)
50 {
51 m_arguments.append(argument.jsObject());
52 }
53
54 void ScriptFunctionCall::appendArgument(const ScriptValue& argument)
55 {
56 m_arguments.append(argument.jsValue());
57 }
58
59 void ScriptFunctionCall::appendArgument(const String& argument)
60 {
61 JSLock lock(false);
62 m_arguments.append(jsString(m_exec, argument));
63 }
64
65 ScriptValue ScriptFunctionCall::call(bool& hadException)
66 {
67 JSObject* thisObject = m_thisObject.jsObject();
68
69 JSLock lock(false);
70
71 JSValuePtr function = thisObject->get(m_exec, Identifier(m_exec, m_name));
72 if (m_exec->hadException()) {
73 reportException(m_exec, m_exec->exception());
74 hadException = true;
75 return ScriptValue();
76 }
77
78 CallData callData;
79 CallType callType = function.getCallData(callData);
80 if (callType == CallTypeNone)
81 return ScriptValue();
82
83 JSValuePtr result = JSC::call(m_exec, function, callType, callData, thisObje ct, m_arguments);
84 if (m_exec->hadException()) {
85 reportException(m_exec, m_exec->exception());
86 hadException = true;
87 return ScriptValue();
88 }
89
90 return ScriptValue(result);
91 }
92
93 ScriptObject ScriptFunctionCall::construct(bool& hadException)
94 {
95 JSObject* thisObject = m_thisObject.jsObject();
96
97 JSLock lock(false);
98
99 JSObject* constructor = asObject(thisObject->get(m_exec, Identifier(m_exec, m_name)));
100 if (m_exec->hadException()) {
101 reportException(m_exec, m_exec->exception());
102 hadException = true;
103 return ScriptObject();
104 }
105
106 ConstructData constructData;
107 ConstructType constructType = constructor->getConstructData(constructData);
108 if (constructType == ConstructTypeNone)
109 return ScriptObject();
110
111 JSValuePtr result = JSC::construct(m_exec, constructor, constructType, const ructData, m_arguments);
112 if (m_exec->hadException()) {
113 reportException(m_exec, m_exec->exception());
114 hadException = true;
115 return ScriptObject();
116 }
117
118 return ScriptObject(asObject(result));
119 }
120
121 } // namespace WebCore
OLDNEW
« no previous file with comments | « third_party/WebKit/WebCore/bindings/js/ScriptFunctionCall.h ('k') | third_party/WebKit/WebCore/bindings/js/ScriptObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698