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

Side by Side Diff: Source/bindings/core/v8/V8CustomElementLifecycleCallbacks.cpp

Issue 1100223003: bindings: Add empty checks for toV8() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 5 years, 7 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
« no previous file with comments | « Source/bindings/core/v8/V8Binding.cpp ('k') | Source/bindings/core/v8/V8ErrorHandler.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 return; 146 return;
147 147
148 if (!m_scriptState->contextIsValid()) 148 if (!m_scriptState->contextIsValid())
149 return; 149 return;
150 150
151 element->setCustomElementState(Element::Upgraded); 151 element->setCustomElementState(Element::Upgraded);
152 152
153 ScriptState::Scope scope(m_scriptState.get()); 153 ScriptState::Scope scope(m_scriptState.get());
154 v8::Isolate* isolate = m_scriptState->isolate(); 154 v8::Isolate* isolate = m_scriptState->isolate();
155 v8::Local<v8::Context> context = m_scriptState->context(); 155 v8::Local<v8::Context> context = m_scriptState->context();
156 v8::Local<v8::Object> receiver = m_scriptState->world().domDataStore().get(e lement, isolate); 156 v8::Local<v8::Value> receiverValue = toV8(element, context->Global(), isolat e);
157 if (receiver.IsEmpty()) 157 if (receiverValue.IsEmpty())
158 receiver = toV8(element, context->Global(), isolate).As<v8::Object>(); 158 return;
159 v8::Local<v8::Object> receiver = receiverValue.As<v8::Object>();
159 160
160 // Swizzle the prototype of the wrapper. 161 // Swizzle the prototype of the wrapper.
161 v8::Local<v8::Object> prototype = m_prototype.newLocal(isolate); 162 v8::Local<v8::Object> prototype = m_prototype.newLocal(isolate);
162 if (prototype.IsEmpty()) 163 if (prototype.IsEmpty())
163 return; 164 return;
164 if (!v8CallBoolean(receiver->SetPrototype(context, prototype))) 165 if (!v8CallBoolean(receiver->SetPrototype(context, prototype)))
165 return; 166 return;
166 167
167 v8::Local<v8::Function> callback = m_created.newLocal(isolate); 168 v8::Local<v8::Function> callback = m_created.newLocal(isolate);
168 if (callback.IsEmpty()) 169 if (callback.IsEmpty())
(...skipping 20 matching lines...) Expand all
189 // continue then be delivered in order rather than delivered immediately. 190 // continue then be delivered in order rather than delivered immediately.
190 // Bug 329665 tracks similar behavior for other synchronous events. 191 // Bug 329665 tracks similar behavior for other synchronous events.
191 if (!executionContext() || executionContext()->activeDOMObjectsAreStopped()) 192 if (!executionContext() || executionContext()->activeDOMObjectsAreStopped())
192 return; 193 return;
193 194
194 if (!m_scriptState->contextIsValid()) 195 if (!m_scriptState->contextIsValid())
195 return; 196 return;
196 ScriptState::Scope scope(m_scriptState.get()); 197 ScriptState::Scope scope(m_scriptState.get());
197 v8::Isolate* isolate = m_scriptState->isolate(); 198 v8::Isolate* isolate = m_scriptState->isolate();
198 v8::Local<v8::Context> context = m_scriptState->context(); 199 v8::Local<v8::Context> context = m_scriptState->context();
199 v8::Local<v8::Object> receiver = toV8(element, context->Global(), isolate).A s<v8::Object>(); 200 v8::Local<v8::Value> receiver = toV8(element, context->Global(), isolate);
200 ASSERT(!receiver.IsEmpty()); 201 if (receiver.IsEmpty())
202 return;
201 203
202 v8::Local<v8::Function> callback = m_attributeChanged.newLocal(isolate); 204 v8::Local<v8::Function> callback = m_attributeChanged.newLocal(isolate);
203 if (callback.IsEmpty()) 205 if (callback.IsEmpty())
204 return; 206 return;
205 207
206 v8::Local<v8::Value> argv[] = { 208 v8::Local<v8::Value> argv[] = {
207 v8String(isolate, name), 209 v8String(isolate, name),
208 oldValue.isNull() ? v8::Local<v8::Value>(v8::Null(isolate)) : v8::Local< v8::Value>(v8String(isolate, oldValue)), 210 oldValue.isNull() ? v8::Local<v8::Value>(v8::Null(isolate)) : v8::Local< v8::Value>(v8String(isolate, oldValue)),
209 newValue.isNull() ? v8::Local<v8::Value>(v8::Null(isolate)) : v8::Local< v8::Value>(v8String(isolate, newValue)) 211 newValue.isNull() ? v8::Local<v8::Value>(v8::Null(isolate)) : v8::Local< v8::Value>(v8String(isolate, newValue))
210 }; 212 };
(...skipping 13 matching lines...) Expand all
224 226
225 if (!m_scriptState->contextIsValid()) 227 if (!m_scriptState->contextIsValid())
226 return; 228 return;
227 ScriptState::Scope scope(m_scriptState.get()); 229 ScriptState::Scope scope(m_scriptState.get());
228 v8::Isolate* isolate = m_scriptState->isolate(); 230 v8::Isolate* isolate = m_scriptState->isolate();
229 v8::Local<v8::Context> context = m_scriptState->context(); 231 v8::Local<v8::Context> context = m_scriptState->context();
230 v8::Local<v8::Function> callback = weakCallback.newLocal(isolate); 232 v8::Local<v8::Function> callback = weakCallback.newLocal(isolate);
231 if (callback.IsEmpty()) 233 if (callback.IsEmpty())
232 return; 234 return;
233 235
234 v8::Local<v8::Object> receiver = toV8(element, context->Global(), isolate).A s<v8::Object>(); 236 v8::Local<v8::Value> receiver = toV8(element, context->Global(), isolate);
235 ASSERT(!receiver.IsEmpty()); 237 if (receiver.IsEmpty())
238 return;
236 239
237 v8::TryCatch exceptionCatcher; 240 v8::TryCatch exceptionCatcher;
238 exceptionCatcher.SetVerbose(true); 241 exceptionCatcher.SetVerbose(true);
239 ScriptController::callFunction(executionContext(), callback, receiver, 0, 0, isolate); 242 ScriptController::callFunction(executionContext(), callback, receiver, 0, 0, isolate);
240 } 243 }
241 244
242 DEFINE_TRACE(V8CustomElementLifecycleCallbacks) 245 DEFINE_TRACE(V8CustomElementLifecycleCallbacks)
243 { 246 {
244 CustomElementLifecycleCallbacks::trace(visitor); 247 CustomElementLifecycleCallbacks::trace(visitor);
245 ContextLifecycleObserver::trace(visitor); 248 ContextLifecycleObserver::trace(visitor);
246 } 249 }
247 250
248 } // namespace blink 251 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/V8Binding.cpp ('k') | Source/bindings/core/v8/V8ErrorHandler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698