OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // This file has been auto-generated by code_generator_v8.py. DO NOT MODIFY! |
| 6 |
| 7 #include "config.h" |
| 8 #include "bindings/core/v8/V8IntersectionObserverCallback.h" |
| 9 |
| 10 #include "bindings/core/v8/ScriptController.h" |
| 11 #include "bindings/core/v8/V8Binding.h" |
| 12 #include "bindings/core/v8/V8IntersectionObserver.h" |
| 13 #include "core/dom/ExecutionContext.h" |
| 14 #include "wtf/Assertions.h" |
| 15 |
| 16 namespace blink { |
| 17 |
| 18 V8IntersectionObserverCallback::V8IntersectionObserverCallback(v8::Local<v8::Fun
ction> callback, v8::Local<v8::Object> owner, ScriptState* scriptState) |
| 19 : ActiveDOMCallback(scriptState->executionContext()) |
| 20 , m_callback(scriptState->isolate(), callback) |
| 21 , m_scriptState(scriptState) |
| 22 { |
| 23 V8HiddenValue::setHiddenValue(scriptState->isolate(), owner, V8HiddenValue::
callback(scriptState->isolate()), callback); |
| 24 m_callback.setWeak(this, &setWeakCallback); |
| 25 } |
| 26 |
| 27 V8IntersectionObserverCallback::~V8IntersectionObserverCallback() |
| 28 { |
| 29 } |
| 30 |
| 31 void V8IntersectionObserverCallback::handleEvent(WillBeHeapVector<RefPtrWillBeMe
mber<IntersectionObserverEntry>>& entries, IntersectionObserver* observer) |
| 32 { |
| 33 if (!canInvokeCallback()) |
| 34 return; |
| 35 |
| 36 if (!m_scriptState->contextIsValid()) |
| 37 return; |
| 38 ScriptState::Scope scope(m_scriptState.get()); |
| 39 |
| 40 if (m_callback.isEmpty()) |
| 41 return; |
| 42 v8::Local<v8::Value> observerHandle = toV8(observer, m_scriptState->context(
)->Global(), m_scriptState->isolate()); |
| 43 if (observerHandle.IsEmpty()) { |
| 44 if (!isScriptControllerTerminating()) |
| 45 CRASH(); |
| 46 return; |
| 47 } |
| 48 |
| 49 if (!observerHandle->IsObject()) |
| 50 return; |
| 51 |
| 52 v8::Local<v8::Object> thisObject = v8::Local<v8::Object>::Cast(observerHandl
e); |
| 53 v8::Local<v8::Value> entriesHandle = toV8(entries, m_scriptState->context()-
>Global(), m_scriptState->isolate()); |
| 54 if (entriesHandle.IsEmpty()) { |
| 55 return; |
| 56 } |
| 57 v8::Local<v8::Value> argv[] = { entriesHandle, observerHandle }; |
| 58 |
| 59 v8::TryCatch exceptionCatcher; |
| 60 exceptionCatcher.SetVerbose(true); |
| 61 ScriptController::callFunction(m_scriptState->executionContext(), m_callback
.newLocal(m_scriptState->isolate()), thisObject, 2, argv, m_scriptState->isolate
()); |
| 62 } |
| 63 |
| 64 void V8IntersectionObserverCallback::setWeakCallback(const v8::WeakCallbackInfo<
V8IntersectionObserverCallback>& data) |
| 65 { |
| 66 data.GetParameter()->m_callback.clear(); |
| 67 } |
| 68 |
| 69 DEFINE_TRACE(V8IntersectionObserverCallback) |
| 70 { |
| 71 IntersectionObserverCallback::trace(visitor); |
| 72 ActiveDOMCallback::trace(visitor); |
| 73 } |
| 74 |
| 75 } // namespace blink |
OLD | NEW |