Skip to content

Commit 3eb9bca

Browse files
author
Sam Weinig
committed
Add additional convertValue overloads to JSDictionary
https://bugs.webkit.org/show_bug.cgi?id=67244 Reviewed by Darin Adler. Add overloads for convertValue that will be needed for Event constructors. * bindings/js/JSDictionary.cpp: (WebCore::JSDictionary::convertValue): * bindings/js/JSDictionary.h: Add overloads. Remove #include of <runtime/Error.h> and just include <interpreter/CallFrame.h> * bindings/js/JSEventConstructors.cpp: Add now necessary #include of <runtime/Error.h>. Canonical link: https://commits.webkit.org/83051@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@94123 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent a3fb12e commit 3eb9bca

4 files changed

Lines changed: 94 additions & 1 deletion

File tree

Source/WebCore/ChangeLog

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
2011-08-30 Sam Weinig <sam@webkit.org>
2+
3+
Add additional convertValue overloads to JSDictionary
4+
https://bugs.webkit.org/show_bug.cgi?id=67244
5+
6+
Reviewed by Darin Adler.
7+
8+
Add overloads for convertValue that will be needed for Event
9+
constructors.
10+
11+
* bindings/js/JSDictionary.cpp:
12+
(WebCore::JSDictionary::convertValue):
13+
* bindings/js/JSDictionary.h:
14+
Add overloads. Remove #include of <runtime/Error.h> and just include
15+
<interpreter/CallFrame.h>
16+
17+
* bindings/js/JSEventConstructors.cpp:
18+
Add now necessary #include of <runtime/Error.h>.
19+
120
2011-08-30 Aaron Colwell <acolwell@chromium.org>
221

322
Add MediaSource API to HTMLMediaElement

Source/WebCore/bindings/js/JSDictionary.cpp

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@
2727
#include "config.h"
2828
#include "JSDictionary.h"
2929

30+
#include "JSDOMWindow.h"
31+
#include "JSEventTarget.h"
32+
#include "JSNode.h"
33+
#include "SerializedScriptValue.h"
34+
#include "ScriptValue.h"
35+
3036
using namespace JSC;
3137

3238
namespace WebCore {
@@ -54,9 +60,59 @@ void JSDictionary::convertValue(ExecState* exec, JSValue value, bool& result)
5460
result = value.toBoolean(exec);
5561
}
5662

63+
void JSDictionary::convertValue(ExecState* exec, JSValue value, int& result)
64+
{
65+
result = value.toInt32(exec);
66+
}
67+
68+
void JSDictionary::convertValue(ExecState* exec, JSValue value, unsigned& result)
69+
{
70+
result = value.toUInt32(exec);
71+
}
72+
73+
void JSDictionary::convertValue(ExecState* exec, JSValue value, unsigned short& result)
74+
{
75+
result = static_cast<unsigned short>(value.toUInt32(exec));
76+
}
77+
78+
void JSDictionary::convertValue(ExecState* exec, JSValue value, unsigned long long& result)
79+
{
80+
result = static_cast<unsigned long long>(value.toInteger(exec));
81+
}
82+
5783
void JSDictionary::convertValue(ExecState* exec, JSValue value, double& result)
5884
{
5985
result = value.toNumber(exec);
6086
}
6187

88+
void JSDictionary::convertValue(ExecState* exec, JSValue value, String& result)
89+
{
90+
result = ustringToString(value.toString(exec));
91+
}
92+
93+
void JSDictionary::convertValue(ExecState* exec, JSValue value, ScriptValue& result)
94+
{
95+
result = ScriptValue(exec->globalData(), value);
96+
}
97+
98+
void JSDictionary::convertValue(ExecState* exec, JSValue value, RefPtr<SerializedScriptValue>& result)
99+
{
100+
result = SerializedScriptValue::create(exec, value);
101+
}
102+
103+
void JSDictionary::convertValue(ExecState*, JSValue value, RefPtr<DOMWindow>& result)
104+
{
105+
result = toDOMWindow(value);
106+
}
107+
108+
void JSDictionary::convertValue(ExecState*, JSValue value, RefPtr<EventTarget>& result)
109+
{
110+
result = toEventTarget(value);
111+
}
112+
113+
void JSDictionary::convertValue(ExecState*, JSValue value, RefPtr<Node>& result)
114+
{
115+
result = toNode(value);
116+
}
117+
62118
} // namespace WebCore

Source/WebCore/bindings/js/JSDictionary.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,17 @@
2626
#ifndef JSDictionary_h
2727
#define JSDictionary_h
2828

29-
#include <runtime/Error.h>
29+
#include <interpreter/CallFrame.h>
30+
#include <wtf/Forward.h>
3031

3132
namespace WebCore {
3233

34+
class DOMWindow;
35+
class EventTarget;
36+
class Node;
37+
class ScriptValue;
38+
class SerializedScriptValue;
39+
3340
class JSDictionary {
3441
public:
3542
JSDictionary(JSC::ExecState* exec, JSC::JSObject* initializerObject)
@@ -53,7 +60,17 @@ class JSDictionary {
5360
GetPropertyResult tryGetProperty(const char* propertyName, JSC::JSValue&);
5461

5562
static void convertValue(JSC::ExecState*, JSC::JSValue, bool& result);
63+
static void convertValue(JSC::ExecState*, JSC::JSValue, int& result);
64+
static void convertValue(JSC::ExecState*, JSC::JSValue, unsigned& result);
65+
static void convertValue(JSC::ExecState*, JSC::JSValue, unsigned short& result);
66+
static void convertValue(JSC::ExecState*, JSC::JSValue, unsigned long long& result);
5667
static void convertValue(JSC::ExecState*, JSC::JSValue, double& result);
68+
static void convertValue(JSC::ExecState*, JSC::JSValue, String& result);
69+
static void convertValue(JSC::ExecState*, JSC::JSValue, ScriptValue& result);
70+
static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<SerializedScriptValue>& result);
71+
static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<DOMWindow>& result);
72+
static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<EventTarget>& result);
73+
static void convertValue(JSC::ExecState*, JSC::JSValue, RefPtr<Node>& result);
5774

5875
JSC::ExecState* m_exec;
5976
JSC::JSObject* m_initializerObject;

Source/WebCore/bindings/js/JSEventConstructors.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "Event.h"
3030
#include "JSDictionary.h"
3131
#include "JSEvent.h"
32+
#include <runtime/Error.h>
3233

3334
using namespace JSC;
3435

0 commit comments

Comments
 (0)