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 11 matching lines...) Expand all Loading... |
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 */ | 30 */ |
31 | 31 |
32 #include "bindings/core/v8/NPV8Object.h" | |
33 #include "bindings/core/v8/SharedPersistent.h" | 32 #include "bindings/core/v8/SharedPersistent.h" |
34 #include "bindings/core/v8/V8Binding.h" | 33 #include "bindings/core/v8/V8Binding.h" |
35 #include "bindings/core/v8/V8HTMLEmbedElement.h" | 34 #include "bindings/core/v8/V8HTMLEmbedElement.h" |
36 #include "bindings/core/v8/V8HTMLObjectElement.h" | 35 #include "bindings/core/v8/V8HTMLObjectElement.h" |
37 #include "bindings/core/v8/V8NPObject.h" | |
38 #include "core/frame/UseCounter.h" | 36 #include "core/frame/UseCounter.h" |
39 #include "wtf/OwnPtr.h" | 37 #include "wtf/OwnPtr.h" |
40 #include "wtf/PassOwnPtr.h" | 38 #include "wtf/PassOwnPtr.h" |
41 | 39 |
42 namespace blink { | 40 namespace blink { |
43 | 41 |
44 namespace { | 42 namespace { |
45 | 43 |
46 template <typename ElementType, typename PropertyType> | 44 template <typename ElementType, typename PropertyType> |
47 void getScriptableObjectProperty(PropertyType property, const v8::PropertyCallba
ckInfo<v8::Value>& info) | 45 void getScriptableObjectProperty(PropertyType property, const v8::PropertyCallba
ckInfo<v8::Value>& info) |
(...skipping 12 matching lines...) Expand all Loading... |
60 return; | 58 return; |
61 | 59 |
62 // We quit here to allow the binding code to look up general HTMLObjectEleme
nt properties | 60 // We quit here to allow the binding code to look up general HTMLObjectEleme
nt properties |
63 // if they are not overriden by plugin. | 61 // if they are not overriden by plugin. |
64 if (value->IsUndefined() && !v8CallBoolean(instance->Has(info.GetIsolate()->
GetCurrentContext(), property))) | 62 if (value->IsUndefined() && !v8CallBoolean(instance->Has(info.GetIsolate()->
GetCurrentContext(), property))) |
65 return; | 63 return; |
66 | 64 |
67 v8SetReturnValue(info, value); | 65 v8SetReturnValue(info, value); |
68 } | 66 } |
69 | 67 |
70 namespace { | |
71 void callNpObjectSetter(v8::Local<v8::Object> self, v8::Local<v8::String> name,
v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info) | |
72 { | |
73 npObjectSetNamedProperty(self, name, value, info); | |
74 } | |
75 | |
76 void callNpObjectSetter(v8::Local<v8::Object> self, uint32_t index, v8::Local<v8
::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info) | |
77 { | |
78 npObjectSetIndexedProperty(self, index, value, info); | |
79 } | |
80 } // namespace | |
81 | |
82 template <typename ElementType, typename PropertyType> | 68 template <typename ElementType, typename PropertyType> |
83 void setScriptableObjectProperty(PropertyType property, v8::Local<v8::Value> val
ue, const v8::PropertyCallbackInfo<v8::Value>& info) | 69 void setScriptableObjectProperty(PropertyType property, v8::Local<v8::Value> val
ue, const v8::PropertyCallbackInfo<v8::Value>& info) |
84 { | 70 { |
85 ASSERT(!value.IsEmpty()); | 71 ASSERT(!value.IsEmpty()); |
86 HTMLPlugInElement* impl = ElementType::toImpl(info.Holder()); | 72 HTMLPlugInElement* impl = ElementType::toImpl(info.Holder()); |
87 RefPtr<SharedPersistent<v8::Object>> wrapper = impl->pluginWrapper(); | 73 RefPtr<SharedPersistent<v8::Object>> wrapper = impl->pluginWrapper(); |
88 if (!wrapper) | 74 if (!wrapper) |
89 return; | 75 return; |
90 | 76 |
91 v8::Local<v8::Object> instance = wrapper->newLocal(info.GetIsolate()); | 77 v8::Local<v8::Object> instance = wrapper->newLocal(info.GetIsolate()); |
92 if (instance.IsEmpty()) | 78 if (instance.IsEmpty()) |
93 return; | 79 return; |
94 | 80 |
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 | |
97 // to be able to lookup standard DOM property. | |
98 // This information is lost when retrieving it through v8::Object. | |
99 if (isWrappedNPObject(instance)) { | |
100 callNpObjectSetter(instance, property, value, info); | |
101 return; | |
102 } | |
103 | |
104 // FIXME: The gTalk pepper plugin is the only plugin to make use of | 81 // FIXME: The gTalk pepper plugin is the only plugin to make use of |
105 // SetProperty and that is being deprecated. This can be removed as soon as | 82 // SetProperty and that is being deprecated. This can be removed as soon as |
106 // it goes away. | 83 // it goes away. |
107 // Call SetProperty on a pepper plugin's scriptable object. Note that we | 84 // Call SetProperty on a pepper plugin's scriptable object. Note that we |
108 // never set the return value here which would indicate that the plugin has | 85 // never set the return value here which would indicate that the plugin has |
109 // intercepted the SetProperty call, which means that the property on the | 86 // intercepted the SetProperty call, which means that the property on the |
110 // DOM element will also be set. For plugin's that don't intercept the call | 87 // DOM element will also be set. For plugin's that don't intercept the call |
111 // (all except gTalk) this makes no difference at all. For gTalk the fact | 88 // (all except gTalk) this makes no difference at all. For gTalk the fact |
112 // that the property on the DOM element also gets set is inconsequential. | 89 // that the property on the DOM element also gets set is inconsequential. |
113 v8::Maybe<bool> unused = instance->Set(info.GetIsolate()->GetCurrentContext(
), property, value); | 90 v8::Maybe<bool> unused = instance->Set(info.GetIsolate()->GetCurrentContext(
), property, value); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 UseCounter::countIfNotPrivateScript(info.GetIsolate(), V8HTMLEmbedElement::t
oImpl(info.Holder())->document(), UseCounter::HTMLEmbedElementLegacyCall); | 172 UseCounter::countIfNotPrivateScript(info.GetIsolate(), V8HTMLEmbedElement::t
oImpl(info.Holder())->document(), UseCounter::HTMLEmbedElementLegacyCall); |
196 } | 173 } |
197 | 174 |
198 void V8HTMLObjectElement::legacyCallCustom(const v8::FunctionCallbackInfo<v8::Va
lue>& info) | 175 void V8HTMLObjectElement::legacyCallCustom(const v8::FunctionCallbackInfo<v8::Va
lue>& info) |
199 { | 176 { |
200 invokeOnScriptableObject<V8HTMLObjectElement>(info); | 177 invokeOnScriptableObject<V8HTMLObjectElement>(info); |
201 UseCounter::countIfNotPrivateScript(info.GetIsolate(), V8HTMLObjectElement::
toImpl(info.Holder())->document(), UseCounter::HTMLObjectElementLegacyCall); | 178 UseCounter::countIfNotPrivateScript(info.GetIsolate(), V8HTMLObjectElement::
toImpl(info.Holder())->document(), UseCounter::HTMLObjectElementLegacyCall); |
202 } | 179 } |
203 | 180 |
204 } // namespace blink | 181 } // namespace blink |
OLD | NEW |