1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
|
// Copyright 2008, Google Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef V8_CUSTOM_H__
#define V8_CUSTOM_H__
#include <v8.h>
struct NPObject;
namespace WebCore {
class Frame;
class V8Proxy;
class String;
class HTMLCollection;
class V8Custom {
public:
// Constants.
static const int kDefaultWrapperInternalFieldCount = 2;
static const int kDocumentMinimumInternalFieldCount = 3;
static const int kDocumentImplementationIndex = 2;
static const int kHTMLDocumentInternalFieldCount = 5;
static const int kHTMLDocumentMarkerIndex = 3;
static const int kHTMLDocumentShadowIndex = 4;
#define DECLARE_PROPERTY_ACCESSOR_GETTER(NAME) \
static v8::Handle<v8::Value> v8##NAME##AccessorGetter(\
v8::Local<v8::String> name, const v8::AccessorInfo& info);
#define DECLARE_PROPERTY_ACCESSOR_SETTER(NAME) \
static void v8##NAME##AccessorSetter(v8::Local<v8::String> name, \
v8::Local<v8::Value> value, \
const v8::AccessorInfo& info);
#define DECLARE_PROPERTY_ACCESSOR(NAME) \
DECLARE_PROPERTY_ACCESSOR_GETTER(NAME) \
DECLARE_PROPERTY_ACCESSOR_SETTER(NAME)
#define DECLARE_NAMED_PROPERTY_GETTER(NAME) \
static v8::Handle<v8::Value> v8##NAME##NamedPropertyGetter(\
v8::Local<v8::String> name, const v8::AccessorInfo& info);
#define DECLARE_NAMED_PROPERTY_SETTER(NAME) \
static v8::Handle<v8::Value> v8##NAME##NamedPropertySetter(\
v8::Local<v8::String> name, \
v8::Local<v8::Value> value, \
const v8::AccessorInfo& info);
#define DECLARE_NAMED_PROPERTY_DELETER(NAME) \
static v8::Handle<v8::Boolean> v8##NAME##NamedPropertyDeleter(\
v8::Local<v8::String> name, const v8::AccessorInfo& info);
#define USE_NAMED_PROPERTY_GETTER(NAME) \
V8Custom::v8##NAME##NamedPropertyGetter
#define USE_NAMED_PROPERTY_SETTER(NAME) \
V8Custom::v8##NAME##NamedPropertySetter
#define USE_NAMED_PROPERTY_DELETER(NAME) \
V8Custom::v8##NAME##NamedPropertyDeleter
#define DECLARE_INDEXED_PROPERTY_GETTER(NAME) \
static v8::Handle<v8::Value> v8##NAME##IndexedPropertyGetter(\
uint32_t index, const v8::AccessorInfo& info);
#define DECLARE_INDEXED_PROPERTY_SETTER(NAME) \
static v8::Handle<v8::Value> v8##NAME##IndexedPropertySetter(\
uint32_t index, v8::Local<v8::Value> value, const v8::AccessorInfo& info);
#define DECLARE_INDEXED_PROPERTY_DELETER(NAME) \
static v8::Handle<v8::Boolean> v8##NAME##IndexedPropertyDeleter(\
uint32_t index, const v8::AccessorInfo& info);
#define USE_INDEXED_PROPERTY_GETTER(NAME) \
V8Custom::v8##NAME##IndexedPropertyGetter
#define USE_INDEXED_PROPERTY_SETTER(NAME) \
V8Custom::v8##NAME##IndexedPropertySetter
#define USE_INDEXED_PROPERTY_DELETER(NAME) \
V8Custom::v8##NAME##IndexedPropertyDeleter
#define DECLARE_CALLBACK(NAME) \
static v8::Handle<v8::Value> v8##NAME##Callback(const v8::Arguments& args);
#define USE_CALLBACK(NAME) \
V8Custom::v8##NAME##Callback
#define DECLARE_NAMED_ACCESS_CHECK(NAME) \
static bool v8##NAME##NamedSecurityCheck(v8::Local<v8::Object> host, \
v8::Local<v8::Value> key, \
v8::AccessType type, \
v8::Local<v8::Value> data);
#define DECLARE_INDEXED_ACCESS_CHECK(NAME) \
static bool v8##NAME##IndexedSecurityCheck(v8::Local<v8::Object> host, \
uint32_t index, \
v8::AccessType type, \
v8::Local<v8::Value> data);
DECLARE_PROPERTY_ACCESSOR(CanvasRenderingContext2DStrokeStyle)
DECLARE_PROPERTY_ACCESSOR(CanvasRenderingContext2DFillStyle)
// Customized getter&setter of DOMWindow.location
DECLARE_PROPERTY_ACCESSOR(DOMWindowLocation)
// Customized setter of DOMWindow.opener
DECLARE_PROPERTY_ACCESSOR_SETTER(DOMWindowOpener)
DECLARE_PROPERTY_ACCESSOR(DocumentLocation)
DECLARE_PROPERTY_ACCESSOR(DocumentImplementation)
DECLARE_PROPERTY_ACCESSOR_GETTER(EventSrcElement)
DECLARE_PROPERTY_ACCESSOR(EventReturnValue)
DECLARE_PROPERTY_ACCESSOR_GETTER(EventDataTransfer)
DECLARE_PROPERTY_ACCESSOR_GETTER(EventClipboardData)
// Getter/Setter for window event handlers
DECLARE_PROPERTY_ACCESSOR(DOMWindowEventHandler)
// Getter/Setter for Element event handlers
DECLARE_PROPERTY_ACCESSOR(ElementEventHandler)
// Customized setter of src and location on HTMLFrameElement
DECLARE_PROPERTY_ACCESSOR_SETTER(HTMLFrameElementSrc)
DECLARE_PROPERTY_ACCESSOR_SETTER(HTMLFrameElementLocation)
// Customized setter of src on HTMLIFrameElement
DECLARE_PROPERTY_ACCESSOR_SETTER(HTMLIFrameElementSrc)
// Customized setter of Attr.value
DECLARE_PROPERTY_ACCESSOR_SETTER(AttrValue)
// Customized setter of HTMLOptionsCollection length
DECLARE_PROPERTY_ACCESSOR_SETTER(HTMLOptionsCollectionLength)
DECLARE_NAMED_ACCESS_CHECK(Location)
DECLARE_INDEXED_ACCESS_CHECK(History)
DECLARE_NAMED_ACCESS_CHECK(History)
DECLARE_INDEXED_ACCESS_CHECK(Location)
// HTMLCollection customized functions.
DECLARE_CALLBACK(HTMLCollectionItem)
DECLARE_CALLBACK(HTMLCollectionNamedItem)
// HTMLCollections are callable as functions.
DECLARE_CALLBACK(HTMLCollectionCallAsFunction)
// HTMLSelectElement customized functions.
DECLARE_CALLBACK(HTMLSelectElementRemove)
// HTMLOptionsCollection customized functions.
DECLARE_CALLBACK(HTMLOptionsCollectionRemove)
DECLARE_CALLBACK(HTMLOptionsCollectionAdd)
// HTMLDocument customized functions
DECLARE_CALLBACK(HTMLDocumentWrite)
DECLARE_CALLBACK(HTMLDocumentWriteln)
DECLARE_CALLBACK(HTMLDocumentOpen)
DECLARE_CALLBACK(HTMLDocumentClear)
// Document customized functions
DECLARE_CALLBACK(DocumentEvaluate)
// Window customized functions
DECLARE_CALLBACK(DOMWindowAddEventListener)
DECLARE_CALLBACK(DOMWindowRemoveEventListener)
DECLARE_CALLBACK(DOMWindowPostMessage)
DECLARE_CALLBACK(DOMWindowSetTimeout)
DECLARE_CALLBACK(DOMWindowSetInterval)
DECLARE_CALLBACK(DOMWindowAtob)
DECLARE_CALLBACK(DOMWindowBtoa)
DECLARE_CALLBACK(DOMWindowNOP)
DECLARE_CALLBACK(DOMWindowToString)
DECLARE_CALLBACK(DOMWindowShowModalDialog)
DECLARE_CALLBACK(DOMWindowOpen)
DECLARE_CALLBACK(DOMParserConstructor)
DECLARE_CALLBACK(XMLHttpRequestConstructor)
DECLARE_CALLBACK(XMLSerializerConstructor)
DECLARE_CALLBACK(XPathEvaluatorConstructor)
DECLARE_CALLBACK(XSLTProcessorConstructor)
// Implementation of custom XSLTProcessor methods.
DECLARE_CALLBACK(XSLTProcessorImportStylesheet)
DECLARE_CALLBACK(XSLTProcessorTransformToFragment)
DECLARE_CALLBACK(XSLTProcessorTransformToDocument)
DECLARE_CALLBACK(XSLTProcessorSetParameter)
DECLARE_CALLBACK(XSLTProcessorGetParameter)
DECLARE_CALLBACK(XSLTProcessorRemoveParameter)
// CSSPrimitiveValue customized functions
DECLARE_CALLBACK(CSSPrimitiveValueGetRGBColorValue)
// Canvas 2D customized functions
DECLARE_CALLBACK(CanvasRenderingContext2DSetStrokeColor)
DECLARE_CALLBACK(CanvasRenderingContext2DSetFillColor)
DECLARE_CALLBACK(CanvasRenderingContext2DStrokeRect)
DECLARE_CALLBACK(CanvasRenderingContext2DSetShadow)
DECLARE_CALLBACK(CanvasRenderingContext2DDrawImage)
DECLARE_CALLBACK(CanvasRenderingContext2DDrawImageFromRect)
DECLARE_CALLBACK(CanvasRenderingContext2DCreatePattern)
// Implementation of Clipboard methods.
DECLARE_CALLBACK(ClipboardClearData)
DECLARE_CALLBACK(ClipboardGetData)
DECLARE_CALLBACK(ClipboardSetData)
// Implementation of Element methods.
DECLARE_CALLBACK(ElementSetAttribute)
DECLARE_CALLBACK(ElementSetAttributeNode)
DECLARE_CALLBACK(ElementSetAttributeNS)
DECLARE_CALLBACK(ElementSetAttributeNodeNS)
// Implementation of EventTarget::addEventListener
// and EventTarget::removeEventListener
DECLARE_CALLBACK(EventTargetNodeAddEventListener)
DECLARE_CALLBACK(EventTargetNodeRemoveEventListener)
// Custom implementation of XMLHttpRequest properties
DECLARE_PROPERTY_ACCESSOR_SETTER(XMLHttpRequestOnreadystatechange)
DECLARE_PROPERTY_ACCESSOR_SETTER(XMLHttpRequestOnload)
DECLARE_CALLBACK(XMLHttpRequestAddEventListener)
DECLARE_CALLBACK(XMLHttpRequestRemoveEventListener)
DECLARE_CALLBACK(XMLHttpRequestOpen)
DECLARE_CALLBACK(XMLHttpRequestSend)
DECLARE_CALLBACK(XMLHttpRequestSetRequestHeader)
DECLARE_CALLBACK(XMLHttpRequestGetResponseHeader)
DECLARE_CALLBACK(XMLHttpRequestOverrideMimeType)
// Custom implementation of TreeWalker functions
DECLARE_CALLBACK(TreeWalkerParentNode)
DECLARE_CALLBACK(TreeWalkerFirstChild)
DECLARE_CALLBACK(TreeWalkerLastChild)
DECLARE_CALLBACK(TreeWalkerNextNode)
DECLARE_CALLBACK(TreeWalkerPreviousNode)
DECLARE_CALLBACK(TreeWalkerNextSibling)
DECLARE_CALLBACK(TreeWalkerPreviousSibling)
// Custom implementation of NodeIterator functions
DECLARE_CALLBACK(NodeIteratorNextNode)
DECLARE_CALLBACK(NodeIteratorPreviousNode)
// Custom implementation of NodeFilter function
DECLARE_CALLBACK(NodeFilterAcceptNode)
DECLARE_NAMED_PROPERTY_GETTER(DOMWindow)
DECLARE_INDEXED_PROPERTY_GETTER(DOMWindow)
DECLARE_NAMED_ACCESS_CHECK(DOMWindow)
DECLARE_INDEXED_ACCESS_CHECK(DOMWindow)
DECLARE_NAMED_PROPERTY_GETTER(HTMLFrameSetElement)
DECLARE_NAMED_PROPERTY_GETTER(HTMLFormElement)
DECLARE_NAMED_PROPERTY_GETTER(HTMLDocument)
DECLARE_NAMED_PROPERTY_SETTER(HTMLDocument)
DECLARE_NAMED_PROPERTY_DELETER(HTMLDocument)
DECLARE_NAMED_PROPERTY_GETTER(NodeList)
DECLARE_NAMED_PROPERTY_GETTER(NamedNodeMap)
DECLARE_NAMED_PROPERTY_GETTER(CSSStyleDeclaration)
DECLARE_NAMED_PROPERTY_SETTER(CSSStyleDeclaration)
DECLARE_NAMED_PROPERTY_GETTER(HTMLPlugInElement)
DECLARE_NAMED_PROPERTY_SETTER(HTMLPlugInElement)
DECLARE_INDEXED_PROPERTY_GETTER(HTMLPlugInElement)
DECLARE_INDEXED_PROPERTY_SETTER(HTMLPlugInElement)
// Plugin object can be called as function.
DECLARE_CALLBACK(HTMLPlugInElement)
DECLARE_NAMED_PROPERTY_GETTER(StyleSheetList)
DECLARE_INDEXED_PROPERTY_GETTER(NamedNodeMap)
DECLARE_INDEXED_PROPERTY_GETTER(HTMLFormElement)
DECLARE_INDEXED_PROPERTY_GETTER(HTMLOptionsCollection)
DECLARE_INDEXED_PROPERTY_SETTER(HTMLOptionsCollection)
DECLARE_INDEXED_PROPERTY_SETTER(HTMLSelectElementCollection)
DECLARE_NAMED_PROPERTY_GETTER(HTMLCollection)
// SVG custom properties and callbacks
#if ENABLE(SVG)
DECLARE_CALLBACK(SVGMatrixInverse)
DECLARE_CALLBACK(SVGMatrixRotateFromVector)
#endif
#undef DECLARE_INDEXED_ACCESS_CHECK
#undef DECLARE_NAMED_ACCESS_CHECK
#undef DECLARE_PROPERTY_ACCESSOR_SETTER
#undef DECLARE_PROPERTY_ACCESSOR_GETTER
#undef DECLARE_PROPERTY_ACCESSOR
#undef DECLARE_NAMED_PROPERTY_GETTER
#undef DECLARE_NAMED_PROPERTY_SETTER
#undef DECLARE_NAMED_PROPERTY_DELETER
#undef DECLARE_INDEXED_PROPERTY_GETTER
#undef DECLARE_INDEXED_PROPERTY_SETTER
#undef DECLARE_INDEXED_PROPERTY_DELETER
#undef DECLARE_CALLBACK
// Returns the NPObject corresponding to an HTMLElement object.
static NPObject* GetHTMLPlugInElementNPObject(v8::Handle<v8::Object> object);
// Returns the owner frame pointer of a DOM wrapper object. It only works for
// these DOM objects requiring cross-domain access check.
static Frame* GetTargetFrame(v8::Local<v8::Object> host,
v8::Local<v8::Value> data);
// Special case for downcasting SVG path segments
#if ENABLE(SVG)
static V8ClassIndex::V8WrapperType DowncastSVGPathSeg(void* path_seg);
#endif
private:
static v8::Handle<v8::Value> WindowSetTimeoutImpl(const v8::Arguments& args,
bool single_shot);
};
} // namespace WebCore
#endif // V8_CUSTOM_H__
|