~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/WebCore/bindings/v8/custom/V8HTMLPlugInElementCustom.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 "HTMLPlugInElement.h"
 
33
 
 
34
#include "ScriptInstance.h"
 
35
#include "V8Binding.h"
 
36
#include "V8HTMLAppletElement.h"
 
37
#include "V8HTMLEmbedElement.h"
 
38
#include "V8HTMLObjectElement.h"
 
39
#include "V8NPObject.h"
 
40
 
 
41
namespace WebCore {
 
42
 
 
43
// FIXME: Consider moving getter/setter helpers to V8NPObject and renaming this file to V8PluginElementFunctions
 
44
// to match JSC bindings naming convention.
 
45
 
 
46
template <class C>
 
47
static v8::Handle<v8::Value> npObjectNamedGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
 
48
{
 
49
    HTMLPlugInElement* imp = C::toNative(info.Holder());
 
50
    ScriptInstance scriptInstance = imp->getInstance();
 
51
    if (!scriptInstance)
 
52
        return v8Undefined();
 
53
 
 
54
    v8::Local<v8::Object> instance = v8::Local<v8::Object>::New(scriptInstance->instance());
 
55
    if (instance.IsEmpty())
 
56
        return v8Undefined();
 
57
 
 
58
    return npObjectGetNamedProperty(instance, name, info);
 
59
}
 
60
 
 
61
template <class C>
 
62
static v8::Handle<v8::Value> npObjectNamedSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
 
63
{
 
64
    HTMLPlugInElement* imp = C::toNative(info.Holder());
 
65
    ScriptInstance scriptInstance = imp->getInstance();
 
66
    if (!scriptInstance)
 
67
        return v8Undefined();
 
68
 
 
69
    v8::Local<v8::Object> instance = v8::Local<v8::Object>::New(scriptInstance->instance());
 
70
    if (instance.IsEmpty())
 
71
        return v8Undefined();
 
72
 
 
73
    return npObjectSetNamedProperty(instance, name, value, info);
 
74
}
 
75
 
 
76
v8::Handle<v8::Value> V8HTMLAppletElement::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
 
77
{
 
78
    INC_STATS("DOM.HTMLAppletElement.NamedPropertyGetter");
 
79
    return npObjectNamedGetter<V8HTMLAppletElement>(name, info);
 
80
}
 
81
 
 
82
v8::Handle<v8::Value> V8HTMLEmbedElement::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
 
83
{
 
84
    INC_STATS("DOM.HTMLEmbedElement.NamedPropertyGetter");
 
85
    return npObjectNamedGetter<V8HTMLEmbedElement>(name, info);
 
86
}
 
87
 
 
88
v8::Handle<v8::Value> V8HTMLObjectElement::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
 
89
{
 
90
    INC_STATS("DOM.HTMLObjectElement.NamedPropertyGetter");
 
91
    return npObjectNamedGetter<V8HTMLObjectElement>(name, info);
 
92
}
 
93
 
 
94
v8::Handle<v8::Value> V8HTMLAppletElement::namedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
 
95
{
 
96
    INC_STATS("DOM.HTMLAppletElement.NamedPropertySetter");
 
97
    return npObjectNamedSetter<V8HTMLAppletElement>(name, value, info);
 
98
}
 
99
 
 
100
v8::Handle<v8::Value> V8HTMLEmbedElement::namedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
 
101
{
 
102
    INC_STATS("DOM.HTMLEmbedElement.NamedPropertySetter");
 
103
    return npObjectNamedSetter<V8HTMLEmbedElement>(name, value, info);
 
104
}
 
105
 
 
106
v8::Handle<v8::Value> V8HTMLObjectElement::namedPropertySetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
 
107
{
 
108
    INC_STATS("DOM.HTMLObjectElement.NamedPropertySetter");
 
109
    return npObjectNamedSetter<V8HTMLObjectElement>(name, value, info);
 
110
}
 
111
 
 
112
v8::Handle<v8::Value> V8HTMLAppletElement::callAsFunctionCallback(const v8::Arguments& args)
 
113
{
 
114
    INC_STATS("DOM.HTMLAppletElement()");
 
115
    return npObjectInvokeDefaultHandler(args);
 
116
}
 
117
 
 
118
v8::Handle<v8::Value> V8HTMLEmbedElement::callAsFunctionCallback(const v8::Arguments& args)
 
119
{
 
120
    INC_STATS("DOM.HTMLEmbedElement()");
 
121
    return npObjectInvokeDefaultHandler(args);
 
122
}
 
123
 
 
124
v8::Handle<v8::Value> V8HTMLObjectElement::callAsFunctionCallback(const v8::Arguments& args)
 
125
{
 
126
    INC_STATS("DOM.HTMLObjectElement()");
 
127
    return npObjectInvokeDefaultHandler(args);
 
128
}
 
129
 
 
130
template <class C>
 
131
v8::Handle<v8::Value> npObjectIndexedGetter(uint32_t index, const v8::AccessorInfo& info)
 
132
{
 
133
    INC_STATS("DOM.HTMLPlugInElement.IndexedPropertyGetter");
 
134
    HTMLPlugInElement* imp = C::toNative(info.Holder());
 
135
    ScriptInstance scriptInstance = imp->getInstance();
 
136
    if (!scriptInstance)
 
137
        return v8Undefined();
 
138
 
 
139
    v8::Local<v8::Object> instance = v8::Local<v8::Object>::New(scriptInstance->instance());
 
140
    if (instance.IsEmpty())
 
141
        return v8Undefined();
 
142
 
 
143
    return npObjectGetIndexedProperty(instance, index, info);
 
144
}
 
145
 
 
146
template <class C>
 
147
v8::Handle<v8::Value> npObjectIndexedSetter(uint32_t index, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
 
148
{
 
149
    INC_STATS("DOM.HTMLPlugInElement.IndexedPropertySetter");
 
150
    HTMLPlugInElement* imp = C::toNative(info.Holder());
 
151
    ScriptInstance scriptInstance = imp->getInstance();
 
152
    if (!scriptInstance)
 
153
        return v8Undefined();
 
154
 
 
155
    v8::Local<v8::Object> instance = v8::Local<v8::Object>::New(scriptInstance->instance());
 
156
    if (instance.IsEmpty())
 
157
        return v8Undefined();
 
158
 
 
159
    return npObjectSetIndexedProperty(instance, index, value, info);
 
160
}
 
161
 
 
162
v8::Handle<v8::Value> V8HTMLAppletElement::indexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info)
 
163
{
 
164
    INC_STATS("DOM.HTMLAppletElement.IndexedPropertyGetter");
 
165
    return npObjectIndexedGetter<V8HTMLAppletElement>(index, info);
 
166
}
 
167
 
 
168
v8::Handle<v8::Value> V8HTMLEmbedElement::indexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info)
 
169
{
 
170
    INC_STATS("DOM.HTMLEmbedElement.IndexedPropertyGetter");
 
171
    return npObjectIndexedGetter<V8HTMLEmbedElement>(index, info);
 
172
}
 
173
 
 
174
v8::Handle<v8::Value> V8HTMLObjectElement::indexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info)
 
175
{
 
176
    INC_STATS("DOM.HTMLObjectElement.IndexedPropertyGetter");
 
177
    return npObjectIndexedGetter<V8HTMLObjectElement>(index, info);
 
178
}
 
179
 
 
180
v8::Handle<v8::Value> V8HTMLAppletElement::indexedPropertySetter(uint32_t index, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
 
181
{
 
182
    INC_STATS("DOM.HTMLAppletElement.IndexedPropertySetter");
 
183
    return npObjectIndexedSetter<V8HTMLAppletElement>(index, value, info);
 
184
}
 
185
 
 
186
v8::Handle<v8::Value> V8HTMLEmbedElement::indexedPropertySetter(uint32_t index, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
 
187
{
 
188
    INC_STATS("DOM.HTMLEmbedElement.IndexedPropertySetter");
 
189
    return npObjectIndexedSetter<V8HTMLEmbedElement>(index, value, info);
 
190
}
 
191
 
 
192
v8::Handle<v8::Value> V8HTMLObjectElement::indexedPropertySetter(uint32_t index, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
 
193
{
 
194
    INC_STATS("DOM.HTMLObjectElement.IndexedPropertySetter");
 
195
    return npObjectIndexedSetter<V8HTMLObjectElement>(index, value, info);
 
196
}
 
197
 
 
198
} // namespace WebCore