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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/V8V0CustomElementLifecycleCallbacks.cpp

Issue 2267403006: Remove redundant IsEmpty checks after calling toV8() Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: temp Created 4 years, 3 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 140
141 if (!m_scriptState->contextIsValid()) 141 if (!m_scriptState->contextIsValid())
142 return; 142 return;
143 143
144 element->setV0CustomElementState(Element::V0Upgraded); 144 element->setV0CustomElementState(Element::V0Upgraded);
145 145
146 ScriptState::Scope scope(m_scriptState.get()); 146 ScriptState::Scope scope(m_scriptState.get());
147 v8::Isolate* isolate = m_scriptState->isolate(); 147 v8::Isolate* isolate = m_scriptState->isolate();
148 v8::Local<v8::Context> context = m_scriptState->context(); 148 v8::Local<v8::Context> context = m_scriptState->context();
149 v8::Local<v8::Value> receiverValue = toV8(element, context->Global(), isolat e); 149 v8::Local<v8::Value> receiverValue = toV8(element, context->Global(), isolat e);
150 if (receiverValue.IsEmpty())
151 return;
152 v8::Local<v8::Object> receiver = receiverValue.As<v8::Object>(); 150 v8::Local<v8::Object> receiver = receiverValue.As<v8::Object>();
153 151
154 // Swizzle the prototype of the wrapper. 152 // Swizzle the prototype of the wrapper.
155 v8::Local<v8::Object> prototype = m_prototype.newLocal(isolate); 153 v8::Local<v8::Object> prototype = m_prototype.newLocal(isolate);
156 if (prototype.IsEmpty()) 154 if (prototype.IsEmpty())
157 return; 155 return;
158 if (!v8CallBoolean(receiver->SetPrototype(context, prototype))) 156 if (!v8CallBoolean(receiver->SetPrototype(context, prototype)))
159 return; 157 return;
160 158
161 v8::Local<v8::Function> callback = m_created.newLocal(isolate); 159 v8::Local<v8::Function> callback = m_created.newLocal(isolate);
(...skipping 22 matching lines...) Expand all
184 // Bug 329665 tracks similar behavior for other synchronous events. 182 // Bug 329665 tracks similar behavior for other synchronous events.
185 if (!getExecutionContext() || getExecutionContext()->activeDOMObjectsAreStop ped()) 183 if (!getExecutionContext() || getExecutionContext()->activeDOMObjectsAreStop ped())
186 return; 184 return;
187 185
188 if (!m_scriptState->contextIsValid()) 186 if (!m_scriptState->contextIsValid())
189 return; 187 return;
190 ScriptState::Scope scope(m_scriptState.get()); 188 ScriptState::Scope scope(m_scriptState.get());
191 v8::Isolate* isolate = m_scriptState->isolate(); 189 v8::Isolate* isolate = m_scriptState->isolate();
192 v8::Local<v8::Context> context = m_scriptState->context(); 190 v8::Local<v8::Context> context = m_scriptState->context();
193 v8::Local<v8::Value> receiver = toV8(element, context->Global(), isolate); 191 v8::Local<v8::Value> receiver = toV8(element, context->Global(), isolate);
194 if (receiver.IsEmpty())
195 return;
196
197 v8::Local<v8::Function> callback = m_attributeChanged.newLocal(isolate); 192 v8::Local<v8::Function> callback = m_attributeChanged.newLocal(isolate);
198 if (callback.IsEmpty()) 193 if (callback.IsEmpty())
199 return; 194 return;
200
201 v8::Local<v8::Value> argv[] = { 195 v8::Local<v8::Value> argv[] = {
202 v8String(isolate, name), 196 v8String(isolate, name),
203 oldValue.isNull() ? v8::Local<v8::Value>(v8::Null(isolate)) : v8::Local< v8::Value>(v8String(isolate, oldValue)), 197 oldValue.isNull() ? v8::Local<v8::Value>(v8::Null(isolate)) : v8::Local< v8::Value>(v8String(isolate, oldValue)),
204 newValue.isNull() ? v8::Local<v8::Value>(v8::Null(isolate)) : v8::Local< v8::Value>(v8String(isolate, newValue)) 198 newValue.isNull() ? v8::Local<v8::Value>(v8::Null(isolate)) : v8::Local< v8::Value>(v8String(isolate, newValue))
205 }; 199 };
206 200
207 v8::TryCatch exceptionCatcher(isolate); 201 v8::TryCatch exceptionCatcher(isolate);
208 exceptionCatcher.SetVerbose(true); 202 exceptionCatcher.SetVerbose(true);
209 V8ScriptRunner::callFunction(callback, getExecutionContext(), receiver, WTF_ ARRAY_LENGTH(argv), argv, isolate); 203 V8ScriptRunner::callFunction(callback, getExecutionContext(), receiver, WTF_ ARRAY_LENGTH(argv), argv, isolate);
210 } 204 }
211 205
212 void V8V0CustomElementLifecycleCallbacks::call(const ScopedPersistent<v8::Functi on>& weakCallback, Element* element) 206 void V8V0CustomElementLifecycleCallbacks::call(const ScopedPersistent<v8::Functi on>& weakCallback, Element* element)
213 { 207 {
214 // FIXME: callbacks while paused should be queued up for execution to 208 // FIXME: callbacks while paused should be queued up for execution to
215 // continue then be delivered in order rather than delivered immediately. 209 // continue then be delivered in order rather than delivered immediately.
216 // Bug 329665 tracks similar behavior for other synchronous events. 210 // Bug 329665 tracks similar behavior for other synchronous events.
217 if (!getExecutionContext() || getExecutionContext()->activeDOMObjectsAreStop ped()) 211 if (!getExecutionContext() || getExecutionContext()->activeDOMObjectsAreStop ped())
218 return; 212 return;
219 213
220 if (!m_scriptState->contextIsValid()) 214 if (!m_scriptState->contextIsValid())
221 return; 215 return;
222 ScriptState::Scope scope(m_scriptState.get()); 216 ScriptState::Scope scope(m_scriptState.get());
223 v8::Isolate* isolate = m_scriptState->isolate(); 217 v8::Isolate* isolate = m_scriptState->isolate();
224 v8::Local<v8::Context> context = m_scriptState->context(); 218 v8::Local<v8::Context> context = m_scriptState->context();
225 v8::Local<v8::Function> callback = weakCallback.newLocal(isolate); 219 v8::Local<v8::Function> callback = weakCallback.newLocal(isolate);
226 if (callback.IsEmpty()) 220 if (callback.IsEmpty())
227 return; 221 return;
228 222
229 v8::Local<v8::Value> receiver = toV8(element, context->Global(), isolate); 223 v8::Local<v8::Value> receiver = toV8(element, context->Global(), isolate);
230 if (receiver.IsEmpty())
231 return;
232
233 v8::TryCatch exceptionCatcher(isolate); 224 v8::TryCatch exceptionCatcher(isolate);
234 exceptionCatcher.SetVerbose(true); 225 exceptionCatcher.SetVerbose(true);
235 V8ScriptRunner::callFunction(callback, getExecutionContext(), receiver, 0, 0 , isolate); 226 V8ScriptRunner::callFunction(callback, getExecutionContext(), receiver, 0, 0 , isolate);
236 } 227 }
237 228
238 DEFINE_TRACE(V8V0CustomElementLifecycleCallbacks) 229 DEFINE_TRACE(V8V0CustomElementLifecycleCallbacks)
239 { 230 {
240 V0CustomElementLifecycleCallbacks::trace(visitor); 231 V0CustomElementLifecycleCallbacks::trace(visitor);
241 ContextLifecycleObserver::trace(visitor); 232 ContextLifecycleObserver::trace(visitor);
242 } 233 }
243 234
244 } // namespace blink 235 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698