| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2014 Opera Software ASA. All rights reserved. | 3 * Copyright (C) 2014 Opera Software ASA. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "wtf/OwnPtr.h" | 42 #include "wtf/OwnPtr.h" |
| 43 #include "wtf/PassOwnPtr.h" | 43 #include "wtf/PassOwnPtr.h" |
| 44 | 44 |
| 45 namespace blink { | 45 namespace blink { |
| 46 | 46 |
| 47 namespace { | 47 namespace { |
| 48 | 48 |
| 49 template <typename ElementType, typename PropertyType> | 49 template <typename ElementType, typename PropertyType> |
| 50 void getScriptableObjectProperty(PropertyType property, const v8::PropertyCallba
ckInfo<v8::Value>& info) | 50 void getScriptableObjectProperty(PropertyType property, const v8::PropertyCallba
ckInfo<v8::Value>& info) |
| 51 { | 51 { |
| 52 HTMLPlugInElement* impl = ElementType::toNative(info.Holder()); | 52 HTMLPlugInElement* impl = ElementType::toImpl(info.Holder()); |
| 53 RefPtr<SharedPersistent<v8::Object> > wrapper = impl->pluginWrapper(); | 53 RefPtr<SharedPersistent<v8::Object> > wrapper = impl->pluginWrapper(); |
| 54 if (!wrapper) | 54 if (!wrapper) |
| 55 return; | 55 return; |
| 56 | 56 |
| 57 v8::Local<v8::Object> instance = wrapper->newLocal(info.GetIsolate()); | 57 v8::Local<v8::Object> instance = wrapper->newLocal(info.GetIsolate()); |
| 58 if (instance.IsEmpty()) | 58 if (instance.IsEmpty()) |
| 59 return; | 59 return; |
| 60 | 60 |
| 61 TONATIVE_VOID(v8::Local<v8::Value>, value, instance->Get(property)); | 61 TONATIVE_VOID(v8::Local<v8::Value>, value, instance->Get(property)); |
| 62 | 62 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 76 | 76 |
| 77 void callNpObjectSetter(v8::Local<v8::Object> self, uint32_t index, v8::Local<v8
::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info) | 77 void callNpObjectSetter(v8::Local<v8::Object> self, uint32_t index, v8::Local<v8
::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info) |
| 78 { | 78 { |
| 79 npObjectSetIndexedProperty(self, index, value, info); | 79 npObjectSetIndexedProperty(self, index, value, info); |
| 80 } | 80 } |
| 81 } | 81 } |
| 82 | 82 |
| 83 template <typename ElementType, typename PropertyType> | 83 template <typename ElementType, typename PropertyType> |
| 84 void setScriptableObjectProperty(PropertyType property, v8::Local<v8::Value> val
ue, const v8::PropertyCallbackInfo<v8::Value>& info) | 84 void setScriptableObjectProperty(PropertyType property, v8::Local<v8::Value> val
ue, const v8::PropertyCallbackInfo<v8::Value>& info) |
| 85 { | 85 { |
| 86 HTMLPlugInElement* impl = ElementType::toNative(info.Holder()); | 86 HTMLPlugInElement* impl = ElementType::toImpl(info.Holder()); |
| 87 RefPtr<SharedPersistent<v8::Object> > wrapper = impl->pluginWrapper(); | 87 RefPtr<SharedPersistent<v8::Object> > wrapper = impl->pluginWrapper(); |
| 88 if (!wrapper) | 88 if (!wrapper) |
| 89 return; | 89 return; |
| 90 | 90 |
| 91 v8::Local<v8::Object> instance = wrapper->newLocal(info.GetIsolate()); | 91 v8::Local<v8::Object> instance = wrapper->newLocal(info.GetIsolate()); |
| 92 if (instance.IsEmpty()) | 92 if (instance.IsEmpty()) |
| 93 return; | 93 return; |
| 94 | 94 |
| 95 // We need to directly call setter on NPObject to be able to detect | 95 // We need to directly call setter on NPObject to be able to detect |
| 96 // situation where NPObject notifies it does not possess the property | 96 // situation where NPObject notifies it does not possess the property |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 void V8HTMLObjectElement::indexedPropertySetterCustom(uint32_t index, v8::Local<
v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info) | 161 void V8HTMLObjectElement::indexedPropertySetterCustom(uint32_t index, v8::Local<
v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info) |
| 162 { | 162 { |
| 163 setScriptableObjectProperty<V8HTMLObjectElement>(index, value, info); | 163 setScriptableObjectProperty<V8HTMLObjectElement>(index, value, info); |
| 164 } | 164 } |
| 165 | 165 |
| 166 namespace { | 166 namespace { |
| 167 | 167 |
| 168 template <typename ElementType> | 168 template <typename ElementType> |
| 169 void invokeOnScriptableObject(const v8::FunctionCallbackInfo<v8::Value>& info) | 169 void invokeOnScriptableObject(const v8::FunctionCallbackInfo<v8::Value>& info) |
| 170 { | 170 { |
| 171 HTMLPlugInElement* impl = ElementType::toNative(info.Holder()); | 171 HTMLPlugInElement* impl = ElementType::toImpl(info.Holder()); |
| 172 RefPtr<SharedPersistent<v8::Object> > wrapper = impl->pluginWrapper(); | 172 RefPtr<SharedPersistent<v8::Object> > wrapper = impl->pluginWrapper(); |
| 173 if (!wrapper) | 173 if (!wrapper) |
| 174 return; | 174 return; |
| 175 | 175 |
| 176 v8::Local<v8::Object> instance = wrapper->newLocal(info.GetIsolate()); | 176 v8::Local<v8::Object> instance = wrapper->newLocal(info.GetIsolate()); |
| 177 if (instance.IsEmpty()) | 177 if (instance.IsEmpty()) |
| 178 return; | 178 return; |
| 179 | 179 |
| 180 WTF::OwnPtr<v8::Handle<v8::Value>[] > arguments = adoptArrayPtr(new v8::Hand
le<v8::Value>[info.Length()]); | 180 WTF::OwnPtr<v8::Handle<v8::Value>[] > arguments = adoptArrayPtr(new v8::Hand
le<v8::Value>[info.Length()]); |
| 181 for (int i = 0; i < info.Length(); ++i) | 181 for (int i = 0; i < info.Length(); ++i) |
| 182 arguments[i] = info[i]; | 182 arguments[i] = info[i]; |
| 183 | 183 |
| 184 TONATIVE_VOID(v8::Local<v8::Value>, retVal, instance->CallAsFunction(info.Th
is(), info.Length(), arguments.get())); | 184 TONATIVE_VOID(v8::Local<v8::Value>, retVal, instance->CallAsFunction(info.Th
is(), info.Length(), arguments.get())); |
| 185 v8SetReturnValue(info, retVal); | 185 v8SetReturnValue(info, retVal); |
| 186 } | 186 } |
| 187 | 187 |
| 188 } // namespace | 188 } // namespace |
| 189 | 189 |
| 190 void V8HTMLAppletElement::legacyCallCustom(const v8::FunctionCallbackInfo<v8::Va
lue>& info) | 190 void V8HTMLAppletElement::legacyCallCustom(const v8::FunctionCallbackInfo<v8::Va
lue>& info) |
| 191 { | 191 { |
| 192 invokeOnScriptableObject<V8HTMLAppletElement>(info); | 192 invokeOnScriptableObject<V8HTMLAppletElement>(info); |
| 193 UseCounter::count(V8HTMLAppletElement::toNative(info.Holder())->document(),
UseCounter::HTMLAppletElementLegacyCall); | 193 UseCounter::count(V8HTMLAppletElement::toImpl(info.Holder())->document(), Us
eCounter::HTMLAppletElementLegacyCall); |
| 194 } | 194 } |
| 195 | 195 |
| 196 void V8HTMLEmbedElement::legacyCallCustom(const v8::FunctionCallbackInfo<v8::Val
ue>& info) | 196 void V8HTMLEmbedElement::legacyCallCustom(const v8::FunctionCallbackInfo<v8::Val
ue>& info) |
| 197 { | 197 { |
| 198 invokeOnScriptableObject<V8HTMLEmbedElement>(info); | 198 invokeOnScriptableObject<V8HTMLEmbedElement>(info); |
| 199 UseCounter::count(V8HTMLEmbedElement::toNative(info.Holder())->document(), U
seCounter::HTMLEmbedElementLegacyCall); | 199 UseCounter::count(V8HTMLEmbedElement::toImpl(info.Holder())->document(), Use
Counter::HTMLEmbedElementLegacyCall); |
| 200 } | 200 } |
| 201 | 201 |
| 202 void V8HTMLObjectElement::legacyCallCustom(const v8::FunctionCallbackInfo<v8::Va
lue>& info) | 202 void V8HTMLObjectElement::legacyCallCustom(const v8::FunctionCallbackInfo<v8::Va
lue>& info) |
| 203 { | 203 { |
| 204 invokeOnScriptableObject<V8HTMLObjectElement>(info); | 204 invokeOnScriptableObject<V8HTMLObjectElement>(info); |
| 205 UseCounter::count(V8HTMLObjectElement::toNative(info.Holder())->document(),
UseCounter::HTMLObjectElementLegacyCall); | 205 UseCounter::count(V8HTMLObjectElement::toImpl(info.Holder())->document(), Us
eCounter::HTMLObjectElementLegacyCall); |
| 206 } | 206 } |
| 207 | 207 |
| 208 } // namespace blink | 208 } // namespace blink |
| OLD | NEW |