summaryrefslogtreecommitdiff
path: root/chromium/third_party/WebKit/Source/bindings/core/v8/V8IntersectionObserverDelegate.h
blob: 9c97e13b9db2262a688e996ba308e01dab1c4361 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8IntersectionObserverDelegate_h
#define V8IntersectionObserverDelegate_h

#include "core/CoreExport.h"
#include "core/dom/ExecutionContext.h"
#include "core/intersection_observer/IntersectionObserverDelegate.h"
#include "platform/bindings/DOMWrapperWorld.h"
#include "platform/bindings/ScopedPersistent.h"
#include "platform/bindings/TraceWrapperMember.h"

namespace blink {

class V8IntersectionObserverCallback;

class V8IntersectionObserverDelegate final
    : public IntersectionObserverDelegate {
 public:
  CORE_EXPORT V8IntersectionObserverDelegate(V8IntersectionObserverCallback*,
                                             ScriptState*);
  ~V8IntersectionObserverDelegate() override;

  DECLARE_VIRTUAL_TRACE();
  DECLARE_VIRTUAL_TRACE_WRAPPERS();

  void Deliver(const HeapVector<Member<IntersectionObserverEntry>>&,
               IntersectionObserver&) override;

  ExecutionContext* GetExecutionContext() const override {
    return ExecutionContext::From(script_state_.get());
  }

 private:
  TraceWrapperMember<V8IntersectionObserverCallback> callback_;
  // TODO(bashi): Use ContextClient rather than holding ScriptState.
  RefPtr<ScriptState> script_state_;
};

}  // namespace blink
#endif  // V8IntersectionObserverDelegate_h