Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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()) | |
|
Yuki
2016/08/24 12:02:08
It seems not guaranteed to me that m_attributeChan
| |
| 199 return; | |
| 200 | |
| 201 v8::Local<v8::Value> argv[] = { | 193 v8::Local<v8::Value> argv[] = { |
| 202 v8String(isolate, name), | 194 v8String(isolate, name), |
| 203 oldValue.isNull() ? v8::Local<v8::Value>(v8::Null(isolate)) : v8::Local< v8::Value>(v8String(isolate, oldValue)), | 195 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)) | 196 newValue.isNull() ? v8::Local<v8::Value>(v8::Null(isolate)) : v8::Local< v8::Value>(v8String(isolate, newValue)) |
| 205 }; | 197 }; |
| 206 | 198 |
| 207 v8::TryCatch exceptionCatcher(isolate); | 199 v8::TryCatch exceptionCatcher(isolate); |
| 208 exceptionCatcher.SetVerbose(true); | 200 exceptionCatcher.SetVerbose(true); |
| 209 V8ScriptRunner::callFunction(callback, getExecutionContext(), receiver, WTF_ ARRAY_LENGTH(argv), argv, isolate); | 201 V8ScriptRunner::callFunction(callback, getExecutionContext(), receiver, WTF_ ARRAY_LENGTH(argv), argv, isolate); |
| 210 } | 202 } |
| 211 | 203 |
| 212 void V8V0CustomElementLifecycleCallbacks::call(const ScopedPersistent<v8::Functi on>& weakCallback, Element* element) | 204 void V8V0CustomElementLifecycleCallbacks::call(const ScopedPersistent<v8::Functi on>& weakCallback, Element* element) |
| 213 { | 205 { |
| 214 // FIXME: callbacks while paused should be queued up for execution to | 206 // FIXME: callbacks while paused should be queued up for execution to |
| 215 // continue then be delivered in order rather than delivered immediately. | 207 // continue then be delivered in order rather than delivered immediately. |
| 216 // Bug 329665 tracks similar behavior for other synchronous events. | 208 // Bug 329665 tracks similar behavior for other synchronous events. |
| 217 if (!getExecutionContext() || getExecutionContext()->activeDOMObjectsAreStop ped()) | 209 if (!getExecutionContext() || getExecutionContext()->activeDOMObjectsAreStop ped()) |
| 218 return; | 210 return; |
| 219 | 211 |
| 220 if (!m_scriptState->contextIsValid()) | 212 if (!m_scriptState->contextIsValid()) |
| 221 return; | 213 return; |
| 222 ScriptState::Scope scope(m_scriptState.get()); | 214 ScriptState::Scope scope(m_scriptState.get()); |
| 223 v8::Isolate* isolate = m_scriptState->isolate(); | 215 v8::Isolate* isolate = m_scriptState->isolate(); |
| 224 v8::Local<v8::Context> context = m_scriptState->context(); | 216 v8::Local<v8::Context> context = m_scriptState->context(); |
| 225 v8::Local<v8::Function> callback = weakCallback.newLocal(isolate); | 217 v8::Local<v8::Function> callback = weakCallback.newLocal(isolate); |
| 226 if (callback.IsEmpty()) | 218 if (callback.IsEmpty()) |
| 227 return; | 219 return; |
| 228 | 220 |
| 229 v8::Local<v8::Value> receiver = toV8(element, context->Global(), isolate); | 221 v8::Local<v8::Value> receiver = toV8(element, context->Global(), isolate); |
| 230 if (receiver.IsEmpty()) | |
| 231 return; | |
| 232 | |
| 233 v8::TryCatch exceptionCatcher(isolate); | 222 v8::TryCatch exceptionCatcher(isolate); |
| 234 exceptionCatcher.SetVerbose(true); | 223 exceptionCatcher.SetVerbose(true); |
| 235 V8ScriptRunner::callFunction(callback, getExecutionContext(), receiver, 0, 0 , isolate); | 224 V8ScriptRunner::callFunction(callback, getExecutionContext(), receiver, 0, 0 , isolate); |
| 236 } | 225 } |
| 237 | 226 |
| 238 DEFINE_TRACE(V8V0CustomElementLifecycleCallbacks) | 227 DEFINE_TRACE(V8V0CustomElementLifecycleCallbacks) |
| 239 { | 228 { |
| 240 V0CustomElementLifecycleCallbacks::trace(visitor); | 229 V0CustomElementLifecycleCallbacks::trace(visitor); |
| 241 ContextLifecycleObserver::trace(visitor); | 230 ContextLifecycleObserver::trace(visitor); |
| 242 } | 231 } |
| 243 | 232 |
| 244 } // namespace blink | 233 } // namespace blink |
| OLD | NEW |