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

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: Created 5 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) 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::Object> receiver = m_scriptState->world().domDataStore().get(e lement, isolate);
157 if (receiver.IsEmpty()) 157 if (receiver.IsEmpty())
158 receiver = toV8(element, context->Global(), isolate).As<v8::Object>(); 158 receiver = toV8(element, context->Global(), isolate).As<v8::Object>();
159 if (receiver.IsEmpty())
160 return;
haraken 2015/04/28 04:24:59 Not related to your CL, this code is doing somethi
Yuki 2015/04/28 04:47:57 and it should be done inside toV8(). I agree that
bashi 2015/04/28 05:41:53 As chatted offline, we can simply use toV8(). Done
159 161
160 // Swizzle the prototype of the wrapper. 162 // Swizzle the prototype of the wrapper.
161 v8::Local<v8::Object> prototype = m_prototype.newLocal(isolate); 163 v8::Local<v8::Object> prototype = m_prototype.newLocal(isolate);
162 if (prototype.IsEmpty()) 164 if (prototype.IsEmpty())
163 return; 165 return;
164 if (!v8CallBoolean(receiver->SetPrototype(context, prototype))) 166 if (!v8CallBoolean(receiver->SetPrototype(context, prototype)))
165 return; 167 return;
166 168
167 v8::Local<v8::Function> callback = m_created.newLocal(isolate); 169 v8::Local<v8::Function> callback = m_created.newLocal(isolate);
168 if (callback.IsEmpty()) 170 if (callback.IsEmpty())
(...skipping 21 matching lines...) Expand all
190 // Bug 329665 tracks similar behavior for other synchronous events. 192 // Bug 329665 tracks similar behavior for other synchronous events.
191 if (!executionContext() || executionContext()->activeDOMObjectsAreStopped()) 193 if (!executionContext() || executionContext()->activeDOMObjectsAreStopped())
192 return; 194 return;
193 195
194 if (!m_scriptState->contextIsValid()) 196 if (!m_scriptState->contextIsValid())
195 return; 197 return;
196 ScriptState::Scope scope(m_scriptState.get()); 198 ScriptState::Scope scope(m_scriptState.get());
197 v8::Isolate* isolate = m_scriptState->isolate(); 199 v8::Isolate* isolate = m_scriptState->isolate();
198 v8::Local<v8::Context> context = m_scriptState->context(); 200 v8::Local<v8::Context> context = m_scriptState->context();
199 v8::Local<v8::Object> receiver = toV8(element, context->Global(), isolate).A s<v8::Object>(); 201 v8::Local<v8::Object> receiver = toV8(element, context->Global(), isolate).A s<v8::Object>();
200 ASSERT(!receiver.IsEmpty()); 202 if (receiver.IsEmpty())
203 return;
201 204
202 v8::Local<v8::Function> callback = m_attributeChanged.newLocal(isolate); 205 v8::Local<v8::Function> callback = m_attributeChanged.newLocal(isolate);
203 if (callback.IsEmpty()) 206 if (callback.IsEmpty())
204 return; 207 return;
205 208
206 v8::Local<v8::Value> argv[] = { 209 v8::Local<v8::Value> argv[] = {
207 v8String(isolate, name), 210 v8String(isolate, name),
208 oldValue.isNull() ? v8::Local<v8::Value>(v8::Null(isolate)) : v8::Local< v8::Value>(v8String(isolate, oldValue)), 211 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)) 212 newValue.isNull() ? v8::Local<v8::Value>(v8::Null(isolate)) : v8::Local< v8::Value>(v8String(isolate, newValue))
210 }; 213 };
(...skipping 14 matching lines...) Expand all
225 if (!m_scriptState->contextIsValid()) 228 if (!m_scriptState->contextIsValid())
226 return; 229 return;
227 ScriptState::Scope scope(m_scriptState.get()); 230 ScriptState::Scope scope(m_scriptState.get());
228 v8::Isolate* isolate = m_scriptState->isolate(); 231 v8::Isolate* isolate = m_scriptState->isolate();
229 v8::Local<v8::Context> context = m_scriptState->context(); 232 v8::Local<v8::Context> context = m_scriptState->context();
230 v8::Local<v8::Function> callback = weakCallback.newLocal(isolate); 233 v8::Local<v8::Function> callback = weakCallback.newLocal(isolate);
231 if (callback.IsEmpty()) 234 if (callback.IsEmpty())
232 return; 235 return;
233 236
234 v8::Local<v8::Object> receiver = toV8(element, context->Global(), isolate).A s<v8::Object>(); 237 v8::Local<v8::Object> receiver = toV8(element, context->Global(), isolate).A s<v8::Object>();
235 ASSERT(!receiver.IsEmpty()); 238 if (receiver.IsEmpty())
haraken 2015/04/28 04:24:59 Ditto. A bit too late to check the emptiness.
bashi 2015/04/28 05:41:53 Done.
239 return;
236 240
237 v8::TryCatch exceptionCatcher; 241 v8::TryCatch exceptionCatcher;
238 exceptionCatcher.SetVerbose(true); 242 exceptionCatcher.SetVerbose(true);
239 ScriptController::callFunction(executionContext(), callback, receiver, 0, 0, isolate); 243 ScriptController::callFunction(executionContext(), callback, receiver, 0, 0, isolate);
240 } 244 }
241 245
242 DEFINE_TRACE(V8CustomElementLifecycleCallbacks) 246 DEFINE_TRACE(V8CustomElementLifecycleCallbacks)
243 { 247 {
244 CustomElementLifecycleCallbacks::trace(visitor); 248 CustomElementLifecycleCallbacks::trace(visitor);
245 ContextLifecycleObserver::trace(visitor); 249 ContextLifecycleObserver::trace(visitor);
246 } 250 }
247 251
248 } // namespace blink 252 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698