| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "bindings/core/v8/ScriptCustomElementDefinition.h" | 5 #include "bindings/core/v8/ScriptCustomElementDefinition.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptState.h" | 7 #include "bindings/core/v8/ScriptState.h" |
| 8 #include "bindings/core/v8/V8Binding.h" | 8 #include "bindings/core/v8/V8Binding.h" |
| 9 #include "bindings/core/v8/V8BindingMacros.h" | 9 #include "bindings/core/v8/V8BindingMacros.h" |
| 10 #include "bindings/core/v8/V8CustomElementRegistry.h" | 10 #include "bindings/core/v8/V8CustomElementRegistry.h" |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 | 349 |
| 350 void ScriptCustomElementDefinition::runDisconnectedCallback(Element* element) | 350 void ScriptCustomElementDefinition::runDisconnectedCallback(Element* element) |
| 351 { | 351 { |
| 352 if (!m_scriptState->contextIsValid()) | 352 if (!m_scriptState->contextIsValid()) |
| 353 return; | 353 return; |
| 354 ScriptState::Scope scope(m_scriptState.get()); | 354 ScriptState::Scope scope(m_scriptState.get()); |
| 355 v8::Isolate* isolate = m_scriptState->isolate(); | 355 v8::Isolate* isolate = m_scriptState->isolate(); |
| 356 runCallback(m_disconnectedCallback.newLocal(isolate), element); | 356 runCallback(m_disconnectedCallback.newLocal(isolate), element); |
| 357 } | 357 } |
| 358 | 358 |
| 359 void ScriptCustomElementDefinition::runAdoptedCallback(Element* element) | 359 void ScriptCustomElementDefinition::runAdoptedCallback( |
| 360 Element* element, Document* oldOwner, Document *newOwner) |
| 360 { | 361 { |
| 361 if (!m_scriptState->contextIsValid()) | 362 if (!m_scriptState->contextIsValid()) |
| 362 return; | 363 return; |
| 363 ScriptState::Scope scope(m_scriptState.get()); | 364 ScriptState::Scope scope(m_scriptState.get()); |
| 364 v8::Isolate* isolate = m_scriptState->isolate(); | 365 v8::Isolate* isolate = m_scriptState->isolate(); |
| 365 runCallback(m_adoptedCallback.newLocal(isolate), element); | 366 v8::Local<v8::Value> argv[] = { |
| 367 toV8(oldOwner, m_scriptState->context()->Global(), isolate), |
| 368 toV8(newOwner, m_scriptState->context()->Global(), isolate) |
| 369 }; |
| 370 runCallback(m_adoptedCallback.newLocal(isolate), element, |
| 371 WTF_ARRAY_LENGTH(argv), argv); |
| 366 } | 372 } |
| 367 | 373 |
| 368 void ScriptCustomElementDefinition::runAttributeChangedCallback( | 374 void ScriptCustomElementDefinition::runAttributeChangedCallback( |
| 369 Element* element, const QualifiedName& name, | 375 Element* element, const QualifiedName& name, |
| 370 const AtomicString& oldValue, const AtomicString& newValue) | 376 const AtomicString& oldValue, const AtomicString& newValue) |
| 371 { | 377 { |
| 372 if (!m_scriptState->contextIsValid()) | 378 if (!m_scriptState->contextIsValid()) |
| 373 return; | 379 return; |
| 374 ScriptState::Scope scope(m_scriptState.get()); | 380 ScriptState::Scope scope(m_scriptState.get()); |
| 375 v8::Isolate* isolate = m_scriptState->isolate(); | 381 v8::Isolate* isolate = m_scriptState->isolate(); |
| 376 const int argc = 4; | 382 v8::Local<v8::Value> argv[] = { |
| 377 v8::Local<v8::Value> argv[argc] = { | |
| 378 v8String(isolate, name.localName()), | 383 v8String(isolate, name.localName()), |
| 379 v8StringOrNull(isolate, oldValue), | 384 v8StringOrNull(isolate, oldValue), |
| 380 v8StringOrNull(isolate, newValue), | 385 v8StringOrNull(isolate, newValue), |
| 381 v8String(isolate, name.namespaceURI()), | 386 v8String(isolate, name.namespaceURI()), |
| 382 }; | 387 }; |
| 383 runCallback(m_attributeChangedCallback.newLocal(isolate), element, | 388 runCallback(m_attributeChangedCallback.newLocal(isolate), element, |
| 384 argc, argv); | 389 WTF_ARRAY_LENGTH(argv), argv); |
| 385 } | 390 } |
| 386 | 391 |
| 387 } // namespace blink | 392 } // namespace blink |
| OLD | NEW |