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

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

Issue 2810743003: Move ScriptState::GetExecutionContext (Part 3) (Closed)
Patch Set: Rebase Created 3 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 return; 171 return;
172 if (!V8CallBoolean(receiver->SetPrototype(context, prototype))) 172 if (!V8CallBoolean(receiver->SetPrototype(context, prototype)))
173 return; 173 return;
174 174
175 v8::Local<v8::Function> callback = created_.NewLocal(isolate); 175 v8::Local<v8::Function> callback = created_.NewLocal(isolate);
176 if (callback.IsEmpty()) 176 if (callback.IsEmpty())
177 return; 177 return;
178 178
179 v8::TryCatch exception_catcher(isolate); 179 v8::TryCatch exception_catcher(isolate);
180 exception_catcher.SetVerbose(true); 180 exception_catcher.SetVerbose(true);
181 V8ScriptRunner::CallFunction(callback, script_state_->GetExecutionContext(), 181 V8ScriptRunner::CallFunction(callback,
182 ExecutionContext::From(script_state_.Get()),
182 receiver, 0, 0, isolate); 183 receiver, 0, 0, isolate);
183 } 184 }
184 185
185 void V8V0CustomElementLifecycleCallbacks::Attached(Element* element) { 186 void V8V0CustomElementLifecycleCallbacks::Attached(Element* element) {
186 Call(attached_, element); 187 Call(attached_, element);
187 } 188 }
188 189
189 void V8V0CustomElementLifecycleCallbacks::Detached(Element* element) { 190 void V8V0CustomElementLifecycleCallbacks::Detached(Element* element) {
190 Call(detached_, element); 191 Call(detached_, element);
191 } 192 }
(...skipping 21 matching lines...) Expand all
213 214
214 v8::Local<v8::Value> argv[] = { 215 v8::Local<v8::Value> argv[] = {
215 V8String(isolate, name), 216 V8String(isolate, name),
216 old_value.IsNull() ? v8::Local<v8::Value>(v8::Null(isolate)) 217 old_value.IsNull() ? v8::Local<v8::Value>(v8::Null(isolate))
217 : v8::Local<v8::Value>(V8String(isolate, old_value)), 218 : v8::Local<v8::Value>(V8String(isolate, old_value)),
218 new_value.IsNull() ? v8::Local<v8::Value>(v8::Null(isolate)) 219 new_value.IsNull() ? v8::Local<v8::Value>(v8::Null(isolate))
219 : v8::Local<v8::Value>(V8String(isolate, new_value))}; 220 : v8::Local<v8::Value>(V8String(isolate, new_value))};
220 221
221 v8::TryCatch exception_catcher(isolate); 222 v8::TryCatch exception_catcher(isolate);
222 exception_catcher.SetVerbose(true); 223 exception_catcher.SetVerbose(true);
223 V8ScriptRunner::CallFunction(callback, script_state_->GetExecutionContext(), 224 V8ScriptRunner::CallFunction(callback,
225 ExecutionContext::From(script_state_.Get()),
224 receiver, WTF_ARRAY_LENGTH(argv), argv, isolate); 226 receiver, WTF_ARRAY_LENGTH(argv), argv, isolate);
225 } 227 }
226 228
227 void V8V0CustomElementLifecycleCallbacks::Call( 229 void V8V0CustomElementLifecycleCallbacks::Call(
228 const ScopedPersistent<v8::Function>& weak_callback, 230 const ScopedPersistent<v8::Function>& weak_callback,
229 Element* element) { 231 Element* element) {
230 // FIXME: callbacks while paused should be queued up for execution to 232 // FIXME: callbacks while paused should be queued up for execution to
231 // continue then be delivered in order rather than delivered immediately. 233 // continue then be delivered in order rather than delivered immediately.
232 // Bug 329665 tracks similar behavior for other synchronous events. 234 // Bug 329665 tracks similar behavior for other synchronous events.
233 if (!script_state_->ContextIsValid()) 235 if (!script_state_->ContextIsValid())
234 return; 236 return;
235 ScriptState::Scope scope(script_state_.Get()); 237 ScriptState::Scope scope(script_state_.Get());
236 v8::Isolate* isolate = script_state_->GetIsolate(); 238 v8::Isolate* isolate = script_state_->GetIsolate();
237 v8::Local<v8::Context> context = script_state_->GetContext(); 239 v8::Local<v8::Context> context = script_state_->GetContext();
238 v8::Local<v8::Function> callback = weak_callback.NewLocal(isolate); 240 v8::Local<v8::Function> callback = weak_callback.NewLocal(isolate);
239 if (callback.IsEmpty()) 241 if (callback.IsEmpty())
240 return; 242 return;
241 243
242 v8::Local<v8::Value> receiver = ToV8(element, context->Global(), isolate); 244 v8::Local<v8::Value> receiver = ToV8(element, context->Global(), isolate);
243 if (receiver.IsEmpty()) 245 if (receiver.IsEmpty())
244 return; 246 return;
245 247
246 v8::TryCatch exception_catcher(isolate); 248 v8::TryCatch exception_catcher(isolate);
247 exception_catcher.SetVerbose(true); 249 exception_catcher.SetVerbose(true);
248 V8ScriptRunner::CallFunction(callback, script_state_->GetExecutionContext(), 250 V8ScriptRunner::CallFunction(callback,
251 ExecutionContext::From(script_state_.Get()),
249 receiver, 0, 0, isolate); 252 receiver, 0, 0, isolate);
250 } 253 }
251 254
252 DEFINE_TRACE(V8V0CustomElementLifecycleCallbacks) { 255 DEFINE_TRACE(V8V0CustomElementLifecycleCallbacks) {
253 V0CustomElementLifecycleCallbacks::Trace(visitor); 256 V0CustomElementLifecycleCallbacks::Trace(visitor);
254 } 257 }
255 258
256 } // namespace blink 259 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698