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/V8IntersectionObserverCallback.h" | 5 #include "bindings/core/v8/V8IntersectionObserverCallback.h" |
6 | 6 |
7 #include "bindings/core/v8/ScriptController.h" | 7 #include "bindings/core/v8/ScriptController.h" |
8 #include "bindings/core/v8/V8Binding.h" | 8 #include "bindings/core/v8/V8Binding.h" |
9 #include "bindings/core/v8/V8IntersectionObserver.h" | 9 #include "bindings/core/v8/V8IntersectionObserver.h" |
| 10 #include "bindings/core/v8/V8PrivateProperty.h" |
10 #include "core/dom/ExecutionContext.h" | 11 #include "core/dom/ExecutionContext.h" |
11 #include "wtf/Assertions.h" | 12 #include "wtf/Assertions.h" |
12 | 13 |
13 namespace blink { | 14 namespace blink { |
14 | 15 |
15 V8IntersectionObserverCallback::V8IntersectionObserverCallback(v8::Local<v8::Fun
ction> callback, v8::Local<v8::Object> owner, ScriptState* scriptState) | 16 V8IntersectionObserverCallback::V8IntersectionObserverCallback(v8::Local<v8::Fun
ction> callback, v8::Local<v8::Object> owner, ScriptState* scriptState) |
16 : ActiveDOMCallback(scriptState->getExecutionContext()) | 17 : ActiveDOMCallback(scriptState->getExecutionContext()) |
17 , m_callback(scriptState->isolate(), callback) | 18 , m_callback(scriptState->isolate(), callback) |
18 , m_scriptState(scriptState) | 19 , m_scriptState(scriptState) |
19 { | 20 { |
20 V8HiddenValue::setHiddenValue(scriptState, owner, V8HiddenValue::callback(sc
riptState->isolate()), callback); | 21 V8PrivateProperty::getIntersectionObserverCallback(scriptState->isolate()).s
et(scriptState->context(), owner, callback); |
21 m_callback.setWeak(this, &setWeakCallback); | 22 m_callback.setPhantom(); |
22 } | 23 } |
23 | 24 |
24 V8IntersectionObserverCallback::~V8IntersectionObserverCallback() | 25 V8IntersectionObserverCallback::~V8IntersectionObserverCallback() |
25 { | 26 { |
26 } | 27 } |
27 | 28 |
28 void V8IntersectionObserverCallback::handleEvent(const HeapVector<Member<Interse
ctionObserverEntry>>& entries, IntersectionObserver& observer) | 29 void V8IntersectionObserverCallback::handleEvent(const HeapVector<Member<Interse
ctionObserverEntry>>& entries, IntersectionObserver& observer) |
29 { | 30 { |
30 if (!canInvokeCallback()) | 31 if (!canInvokeCallback()) |
31 return; | 32 return; |
(...skipping 19 matching lines...) Expand all Loading... |
51 if (entriesHandle.IsEmpty()) { | 52 if (entriesHandle.IsEmpty()) { |
52 return; | 53 return; |
53 } | 54 } |
54 v8::Local<v8::Value> argv[] = { entriesHandle, observerHandle }; | 55 v8::Local<v8::Value> argv[] = { entriesHandle, observerHandle }; |
55 | 56 |
56 v8::TryCatch exceptionCatcher(m_scriptState->isolate()); | 57 v8::TryCatch exceptionCatcher(m_scriptState->isolate()); |
57 exceptionCatcher.SetVerbose(true); | 58 exceptionCatcher.SetVerbose(true); |
58 ScriptController::callFunction(m_scriptState->getExecutionContext(), m_callb
ack.newLocal(m_scriptState->isolate()), thisObject, 2, argv, m_scriptState->isol
ate()); | 59 ScriptController::callFunction(m_scriptState->getExecutionContext(), m_callb
ack.newLocal(m_scriptState->isolate()), thisObject, 2, argv, m_scriptState->isol
ate()); |
59 } | 60 } |
60 | 61 |
61 void V8IntersectionObserverCallback::setWeakCallback(const v8::WeakCallbackInfo<
V8IntersectionObserverCallback>& data) | |
62 { | |
63 data.GetParameter()->m_callback.clear(); | |
64 } | |
65 | |
66 DEFINE_TRACE(V8IntersectionObserverCallback) | 62 DEFINE_TRACE(V8IntersectionObserverCallback) |
67 { | 63 { |
68 IntersectionObserverCallback::trace(visitor); | 64 IntersectionObserverCallback::trace(visitor); |
69 ActiveDOMCallback::trace(visitor); | 65 ActiveDOMCallback::trace(visitor); |
70 } | 66 } |
71 | 67 |
72 } // namespace blink | 68 } // namespace blink |
OLD | NEW |