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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/V8EventListenerList.h

Issue 1883663005: Remove remaining binding layer RawPtr<>s. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
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 30 matching lines...) Expand all
41 41
42 enum ListenerLookupType { 42 enum ListenerLookupType {
43 ListenerFindOnly, 43 ListenerFindOnly,
44 ListenerFindOrCreate, 44 ListenerFindOrCreate,
45 }; 45 };
46 46
47 // This is a container for V8EventListener objects that uses hidden properties o f v8::Object to speed up lookups. 47 // This is a container for V8EventListener objects that uses hidden properties o f v8::Object to speed up lookups.
48 class V8EventListenerList { 48 class V8EventListenerList {
49 STATIC_ONLY(V8EventListenerList); 49 STATIC_ONLY(V8EventListenerList);
50 public: 50 public:
51 static RawPtr<V8EventListener> findWrapper(v8::Local<v8::Value> value, Scrip tState* scriptState) 51 static V8EventListener* findWrapper(v8::Local<v8::Value> value, ScriptState* scriptState)
52 { 52 {
53 ASSERT(scriptState->isolate()->InContext()); 53 ASSERT(scriptState->isolate()->InContext());
54 if (!value->IsObject()) 54 if (!value->IsObject())
55 return nullptr; 55 return nullptr;
56 56
57 v8::Local<v8::String> wrapperProperty = getHiddenProperty(false, scriptS tate->isolate()); 57 v8::Local<v8::String> wrapperProperty = getHiddenProperty(false, scriptS tate->isolate());
58 return doFindWrapper(v8::Local<v8::Object>::Cast(value), wrapperProperty , scriptState); 58 return doFindWrapper(v8::Local<v8::Object>::Cast(value), wrapperProperty , scriptState);
59 } 59 }
60 60
61 template<typename WrapperType> 61 template<typename WrapperType>
62 static RawPtr<V8EventListener> findOrCreateWrapper(v8::Local<v8::Value>, boo l isAttribute, ScriptState*); 62 static V8EventListener* findOrCreateWrapper(v8::Local<v8::Value>, bool isAtt ribute, ScriptState*);
63 63
64 CORE_EXPORT static RawPtr<EventListener> getEventListener(ScriptState*, v8:: Local<v8::Value>, bool isAttribute, ListenerLookupType); 64 CORE_EXPORT static EventListener* getEventListener(ScriptState*, v8::Local<v 8::Value>, bool isAttribute, ListenerLookupType);
65 65
66 private: 66 private:
67 static V8EventListener* doFindWrapper(v8::Local<v8::Object> object, v8::Loca l<v8::String> wrapperProperty, ScriptState* scriptState) 67 static V8EventListener* doFindWrapper(v8::Local<v8::Object> object, v8::Loca l<v8::String> wrapperProperty, ScriptState* scriptState)
68 { 68 {
69 v8::HandleScope scope(scriptState->isolate()); 69 v8::HandleScope scope(scriptState->isolate());
70 ASSERT(scriptState->isolate()->InContext()); 70 ASSERT(scriptState->isolate()->InContext());
71 v8::Local<v8::Value> listener = V8HiddenValue::getHiddenValue(scriptStat e, object, wrapperProperty); 71 v8::Local<v8::Value> listener = V8HiddenValue::getHiddenValue(scriptStat e, object, wrapperProperty);
72 if (listener.IsEmpty()) 72 if (listener.IsEmpty())
73 return 0; 73 return 0;
74 return static_cast<V8EventListener*>(v8::External::Cast(*listener)->Valu e()); 74 return static_cast<V8EventListener*>(v8::External::Cast(*listener)->Valu e());
75 } 75 }
76 76
77 static inline v8::Local<v8::String> getHiddenProperty(bool isAttribute, v8:: Isolate* isolate) 77 static inline v8::Local<v8::String> getHiddenProperty(bool isAttribute, v8:: Isolate* isolate)
78 { 78 {
79 return isAttribute ? v8AtomicString(isolate, "EventListenerList::attribu teListener") : v8AtomicString(isolate, "EventListenerList::listener"); 79 return isAttribute ? v8AtomicString(isolate, "EventListenerList::attribu teListener") : v8AtomicString(isolate, "EventListenerList::listener");
80 } 80 }
81 }; 81 };
82 82
83 template<typename WrapperType> 83 template<typename WrapperType>
84 RawPtr<V8EventListener> V8EventListenerList::findOrCreateWrapper(v8::Local<v8::V alue> value, bool isAttribute, ScriptState* scriptState) 84 V8EventListener* V8EventListenerList::findOrCreateWrapper(v8::Local<v8::Value> v alue, bool isAttribute, ScriptState* scriptState)
85 { 85 {
86 v8::Isolate* isolate = scriptState->isolate(); 86 v8::Isolate* isolate = scriptState->isolate();
87 ASSERT(isolate->InContext()); 87 ASSERT(isolate->InContext());
88 if (!value->IsObject()) 88 if (!value->IsObject())
89 return nullptr; 89 return nullptr;
90 90
91 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value); 91 v8::Local<v8::Object> object = v8::Local<v8::Object>::Cast(value);
92 v8::Local<v8::String> wrapperProperty = getHiddenProperty(isAttribute, isola te); 92 v8::Local<v8::String> wrapperProperty = getHiddenProperty(isAttribute, isola te);
93 93
94 V8EventListener* wrapper = doFindWrapper(object, wrapperProperty, scriptStat e); 94 V8EventListener* wrapper = doFindWrapper(object, wrapperProperty, scriptStat e);
95 if (wrapper) 95 if (wrapper)
96 return wrapper; 96 return wrapper;
97 97
98 wrapper = WrapperType::create(object, isAttribute, scriptState); 98 wrapper = WrapperType::create(object, isAttribute, scriptState);
99 if (wrapper) 99 if (wrapper)
100 V8HiddenValue::setHiddenValue(scriptState, object, wrapperProperty, v8:: External::New(isolate, wrapper)); 100 V8HiddenValue::setHiddenValue(scriptState, object, wrapperProperty, v8:: External::New(isolate, wrapper));
101 101
102 return wrapper; 102 return wrapper;
103 } 103 }
104 104
105 } // namespace blink 105 } // namespace blink
106 106
107 #endif // V8EventListenerList_h 107 #endif // V8EventListenerList_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698