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 #ifndef ElementVisibilityObserver_h | 5 #ifndef ElementVisibilityObserver_h |
6 #define ElementVisibilityObserver_h | 6 #define ElementVisibilityObserver_h |
7 | 7 |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
9 #include "core/dom/IntersectionObserver.h" | 9 #include "core/dom/IntersectionObserver.h" |
10 #include "platform/heap/Heap.h" | 10 #include "platform/heap/Heap.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 public: | 30 public: |
31 using VisibilityCallback = Function<void(bool), WTF::SameThreadAffinity>; | 31 using VisibilityCallback = Function<void(bool), WTF::SameThreadAffinity>; |
32 | 32 |
33 ElementVisibilityObserver(Element*, std::unique_ptr<VisibilityCallback>); | 33 ElementVisibilityObserver(Element*, std::unique_ptr<VisibilityCallback>); |
34 virtual ~ElementVisibilityObserver(); | 34 virtual ~ElementVisibilityObserver(); |
35 | 35 |
36 void start(); | 36 void start(); |
37 void stop(); | 37 void stop(); |
38 | 38 |
39 void deliverObservationsForTesting(); | |
40 | |
41 DECLARE_VIRTUAL_TRACE(); | 39 DECLARE_VIRTUAL_TRACE(); |
42 | 40 |
43 private: | 41 private: |
44 class ElementVisibilityCallback; | 42 class ElementVisibilityCallback; |
45 | 43 |
46 void onVisibilityChanged( | 44 void onVisibilityChanged( |
47 const HeapVector<Member<IntersectionObserverEntry>>&); | 45 const HeapVector<Member<IntersectionObserverEntry>>&); |
48 | 46 |
49 Member<Element> m_element; | 47 Member<Element> m_element; |
50 Member<IntersectionObserver> m_intersectionObserver; | 48 Member<IntersectionObserver> m_intersectionObserver; |
51 std::unique_ptr<VisibilityCallback> m_callback; | 49 std::unique_ptr<VisibilityCallback> m_callback; |
52 }; | 50 }; |
53 | 51 |
54 } // namespace blink | 52 } // namespace blink |
55 | 53 |
56 #endif // ElementVisibilityObserver_h | 54 #endif // ElementVisibilityObserver_h |
OLD | NEW |