2 * Copyright (C) 2009 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
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
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.
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.
33 #include "bindings/core/v8/V8HTMLAppletElement.h"
34 #include "bindings/core/v8/V8HTMLEmbedElement.h"
35 #include "bindings/core/v8/V8HTMLObjectElement.h"
36 #include "bindings/v8/SharedPersistent.h"
37 #include "bindings/v8/V8Binding.h"
38 #include "bindings/v8/V8NPObject.h"
39 #include "core/frame/UseCounter.h"
43 // FIXME: Consider moving getter/setter helpers to V8NPObject and renaming this file to V8PluginElementFunctions
44 // to match JSC bindings naming convention.
47 static void npObjectNamedGetter(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
49 HTMLPlugInElement* impl = C::toNative(info.Holder());
50 RefPtr<SharedPersistent<v8::Object> > wrapper = impl->pluginWrapper();
54 v8::Local<v8::Object> instanceTemplate = wrapper->newLocal(info.GetIsolate());
55 if (instanceTemplate.IsEmpty())
58 npObjectGetNamedProperty(instanceTemplate, name, info);
62 static void npObjectNamedSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)
64 HTMLPlugInElement* impl = C::toNative(info.Holder());
65 RefPtr<SharedPersistent<v8::Object> > wrapper = impl->pluginWrapper();
69 v8::Local<v8::Object> instanceTemplate = wrapper->newLocal(info.GetIsolate());
70 if (instanceTemplate.IsEmpty())
73 npObjectSetNamedProperty(instanceTemplate, name, value, info);
76 void V8HTMLAppletElement::namedPropertyGetterCustom(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
78 npObjectNamedGetter<V8HTMLAppletElement>(name, info);
81 void V8HTMLEmbedElement::namedPropertyGetterCustom(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
83 npObjectNamedGetter<V8HTMLEmbedElement>(name, info);
86 void V8HTMLObjectElement::namedPropertyGetterCustom(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
88 npObjectNamedGetter<V8HTMLObjectElement>(name, info);
91 void V8HTMLAppletElement::namedPropertySetterCustom(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)
93 npObjectNamedSetter<V8HTMLAppletElement>(name, value, info);
96 void V8HTMLEmbedElement::namedPropertySetterCustom(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)
98 npObjectNamedSetter<V8HTMLEmbedElement>(name, value, info);
101 void V8HTMLObjectElement::namedPropertySetterCustom(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)
103 return npObjectNamedSetter<V8HTMLObjectElement>(name, value, info);
106 void V8HTMLAppletElement::legacyCallCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
108 HTMLPlugInElement* impl = V8HTMLAppletElement::toNative(info.Holder());
109 UseCounter::count(impl->document(), UseCounter::HTMLAppletElementLegacyCall);
110 npObjectInvokeDefaultHandler(info);
113 void V8HTMLEmbedElement::legacyCallCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
115 HTMLPlugInElement* impl = V8HTMLEmbedElement::toNative(info.Holder());
116 UseCounter::count(impl->document(), UseCounter::HTMLEmbedElementLegacyCall);
117 npObjectInvokeDefaultHandler(info);
120 void V8HTMLObjectElement::legacyCallCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
122 HTMLPlugInElement* impl = V8HTMLObjectElement::toNative(info.Holder());
123 UseCounter::count(impl->document(), UseCounter::HTMLObjectElementLegacyCall);
124 npObjectInvokeDefaultHandler(info);
128 void npObjectIndexedGetter(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info)
130 HTMLPlugInElement* impl = C::toNative(info.Holder());
131 RefPtr<SharedPersistent<v8::Object> > wrapper = impl->pluginWrapper();
135 v8::Local<v8::Object> instanceTemplate = wrapper->newLocal(info.GetIsolate());
136 if (instanceTemplate.IsEmpty())
139 npObjectGetIndexedProperty(instanceTemplate, index, info);
143 void npObjectIndexedSetter(uint32_t index, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)
145 HTMLPlugInElement* impl = C::toNative(info.Holder());
146 RefPtr<SharedPersistent<v8::Object> > wrapper = impl->pluginWrapper();
150 v8::Local<v8::Object> instanceTemplate = wrapper->newLocal(info.GetIsolate());
151 if (instanceTemplate.IsEmpty())
154 npObjectSetIndexedProperty(instanceTemplate, index, value, info);
157 void V8HTMLAppletElement::indexedPropertyGetterCustom(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info)
159 npObjectIndexedGetter<V8HTMLAppletElement>(index, info);
162 void V8HTMLEmbedElement::indexedPropertyGetterCustom(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info)
164 npObjectIndexedGetter<V8HTMLEmbedElement>(index, info);
167 void V8HTMLObjectElement::indexedPropertyGetterCustom(uint32_t index, const v8::PropertyCallbackInfo<v8::Value>& info)
169 npObjectIndexedGetter<V8HTMLObjectElement>(index, info);
172 void V8HTMLAppletElement::indexedPropertySetterCustom(uint32_t index, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)
174 npObjectIndexedSetter<V8HTMLAppletElement>(index, value, info);
177 void V8HTMLEmbedElement::indexedPropertySetterCustom(uint32_t index, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)
179 npObjectIndexedSetter<V8HTMLEmbedElement>(index, value, info);
182 void V8HTMLObjectElement::indexedPropertySetterCustom(uint32_t index, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)
184 npObjectIndexedSetter<V8HTMLObjectElement>(index, value, info);
187 } // namespace WebCore