Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(431)

Side by Side Diff: Source/bindings/v8/V8EventListenerList.h

Issue 34393005: IDL compiler: merge and simplify EventHandler non-callable value check (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Formatting Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/bindings/v8/V8Utilities.cpp » ('j') | Source/bindings/v8/V8Utilities.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 ListenerFindOnly, 45 ListenerFindOnly,
46 ListenerFindOrCreate, 46 ListenerFindOrCreate,
47 }; 47 };
48 48
49 // This is a container for V8EventListener objects that uses hidden properties o f v8::Object to speed up lookups. 49 // This is a container for V8EventListener objects that uses hidden properties o f v8::Object to speed up lookups.
50 class V8EventListenerList { 50 class V8EventListenerList {
51 public: 51 public:
52 static PassRefPtr<V8EventListener> findWrapper(v8::Local<v8::Value> value, b ool isAttribute, v8::Isolate* isolate) 52 static PassRefPtr<V8EventListener> findWrapper(v8::Local<v8::Value> value, b ool isAttribute, v8::Isolate* isolate)
53 { 53 {
54 ASSERT(v8::Context::InContext()); 54 ASSERT(v8::Context::InContext());
55 // Non-callable input should be treated as null 55 if (!value->IsObject()
56 if (!value->IsNull() && !value->IsFunction()) 56 // Non-callable attribute setter input is treated as null (no wrappe r)
57 value = v8::Null(isolate); 57 || (isAttribute && !value->IsFunction()))
haraken 2013/10/22 12:05:30 Looks like you newly added the isAttribute check.
Nils Barth (inactive) 2013/10/22 12:16:51 We only want to check if it's a function on attrib
haraken 2013/10/22 12:24:23 Makes sense. However, this changes web-exposed beh
Nils Barth (inactive) 2013/10/23 01:43:51 I looked into this, and found out this is always c
58 if (!value->IsObject())
59 return 0; 58 return 0;
60 59
61 v8::Handle<v8::String> wrapperProperty = getHiddenProperty(isAttribute, isolate); 60 v8::Handle<v8::String> wrapperProperty = getHiddenProperty(isAttribute, isolate);
62 return doFindWrapper(v8::Local<v8::Object>::Cast(value), wrapperProperty , isolate); 61 return doFindWrapper(v8::Local<v8::Object>::Cast(value), wrapperProperty , isolate);
63 } 62 }
64 63
65 template<typename WrapperType> 64 template<typename WrapperType>
66 static PassRefPtr<V8EventListener> findOrCreateWrapper(v8::Local<v8::Value>, bool isAttribute, v8::Isolate*); 65 static PassRefPtr<V8EventListener> findOrCreateWrapper(v8::Local<v8::Value>, bool isAttribute, v8::Isolate*);
67 66
68 static void clearWrapper(v8::Handle<v8::Object> listenerObject, bool isAttri bute, v8::Isolate* isolate) 67 static void clearWrapper(v8::Handle<v8::Object> listenerObject, bool isAttri bute, v8::Isolate* isolate)
(...skipping 18 matching lines...) Expand all
87 static inline v8::Handle<v8::String> getHiddenProperty(bool isAttribute, v8: :Isolate* isolate) 86 static inline v8::Handle<v8::String> getHiddenProperty(bool isAttribute, v8: :Isolate* isolate)
88 { 87 {
89 return isAttribute ? V8HiddenPropertyName::attributeListener(isolate) : V8HiddenPropertyName::listener(isolate); 88 return isAttribute ? V8HiddenPropertyName::attributeListener(isolate) : V8HiddenPropertyName::listener(isolate);
90 } 89 }
91 }; 90 };
92 91
93 template<typename WrapperType> 92 template<typename WrapperType>
94 PassRefPtr<V8EventListener> V8EventListenerList::findOrCreateWrapper(v8::Local<v 8::Value> value, bool isAttribute, v8::Isolate* isolate) 93 PassRefPtr<V8EventListener> V8EventListenerList::findOrCreateWrapper(v8::Local<v 8::Value> value, bool isAttribute, v8::Isolate* isolate)
95 { 94 {
96 ASSERT(v8::Context::InContext()); 95 ASSERT(v8::Context::InContext());
97 // Non-callable attribute setter input should be treated as null 96 if (!value->IsObject()
98 if (isAttribute && !value->IsNull() && !value->IsFunction()) 97 // Non-callable attribute setter input is treated as null (no wrapper)
99 value = v8::Null(isolate); 98 || (isAttribute && !value->IsFunction()))
100 if (!value->IsObject())
101 return 0; 99 return 0;
102 100
103 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value); 101 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value);
104 v8::Handle<v8::String> wrapperProperty = getHiddenProperty(isAttribute, isol ate); 102 v8::Handle<v8::String> wrapperProperty = getHiddenProperty(isAttribute, isol ate);
105 103
106 V8EventListener* wrapper = doFindWrapper(object, wrapperProperty, isolate); 104 V8EventListener* wrapper = doFindWrapper(object, wrapperProperty, isolate);
107 if (wrapper) 105 if (wrapper)
108 return wrapper; 106 return wrapper;
109 107
110 RefPtr<V8EventListener> wrapperPtr = WrapperType::create(object, isAttribute , isolate); 108 RefPtr<V8EventListener> wrapperPtr = WrapperType::create(object, isAttribute , isolate);
111 if (wrapperPtr) 109 if (wrapperPtr)
112 object->SetHiddenValue(wrapperProperty, v8::External::New(wrapperPtr.get ())); 110 object->SetHiddenValue(wrapperProperty, v8::External::New(wrapperPtr.get ()));
113 111
114 return wrapperPtr; 112 return wrapperPtr;
115 } 113 }
116 114
117 } // namespace WebCore 115 } // namespace WebCore
118 116
119 #endif // V8EventListenerList_h 117 #endif // V8EventListenerList_h
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/v8/V8Utilities.cpp » ('j') | Source/bindings/v8/V8Utilities.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698