OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 MediaCustomControlsFullscreenDetector_h | 5 #ifndef MediaCustomControlsFullscreenDetector_h |
6 #define MediaCustomControlsFullscreenDetector_h | 6 #define MediaCustomControlsFullscreenDetector_h |
7 | 7 |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
| 9 #include "core/dom/ContextLifecycleObserver.h" |
9 #include "core/events/EventListener.h" | 10 #include "core/events/EventListener.h" |
10 #include "platform/Timer.h" | 11 #include "platform/Timer.h" |
11 | 12 |
12 namespace blink { | 13 namespace blink { |
13 | 14 |
14 class HTMLVideoElement; | 15 class HTMLVideoElement; |
15 class IntRect; | 16 class IntRect; |
16 class TimerBase; | 17 class TimerBase; |
17 | 18 |
18 class CORE_EXPORT MediaCustomControlsFullscreenDetector final | 19 class CORE_EXPORT MediaCustomControlsFullscreenDetector final |
19 : public EventListener { | 20 : public EventListener, |
| 21 public ContextLifecycleObserver { |
| 22 USING_GARBAGE_COLLECTED_MIXIN(MediaCustomControlsFullscreenDetector); |
20 WTF_MAKE_NONCOPYABLE(MediaCustomControlsFullscreenDetector); | 23 WTF_MAKE_NONCOPYABLE(MediaCustomControlsFullscreenDetector); |
21 | 24 |
22 public: | 25 public: |
23 explicit MediaCustomControlsFullscreenDetector(HTMLVideoElement&); | 26 explicit MediaCustomControlsFullscreenDetector(HTMLVideoElement&); |
24 | 27 |
25 // EventListener implementation. | 28 // EventListener implementation. |
26 bool operator==(const EventListener&) const override; | 29 bool operator==(const EventListener&) const override; |
27 | 30 |
| 31 // ContextLifecycleObserver implemnetation. |
| 32 void contextDestroyed(ExecutionContext*); |
| 33 |
28 DECLARE_VIRTUAL_TRACE(); | 34 DECLARE_VIRTUAL_TRACE(); |
29 | 35 |
30 private: | 36 private: |
31 friend class MediaCustomControlsFullscreenDetectorTest; | 37 friend class MediaCustomControlsFullscreenDetectorTest; |
| 38 friend class HTMLMediaElementEventListenersTest; |
32 | 39 |
33 // EventListener implementation. | 40 // EventListener implementation. |
34 void handleEvent(ExecutionContext*, Event*) override; | 41 void handleEvent(ExecutionContext*, Event*) override; |
35 | 42 |
36 void attach(); | 43 void attach(); |
37 void detach(); | 44 void detach(); |
38 | 45 |
39 HTMLVideoElement& videoElement() { return *m_videoElement; } | 46 HTMLVideoElement& videoElement() { return *m_videoElement; } |
40 | 47 |
41 void onCheckViewportIntersectionTimerFired(TimerBase*); | 48 void onCheckViewportIntersectionTimerFired(TimerBase*); |
42 | 49 |
43 bool isVideoOrParentFullscreen(); | 50 bool isVideoOrParentFullscreen(); |
44 | 51 |
45 static bool computeIsDominantVideoForTests(const IntRect& targetRect, | 52 static bool computeIsDominantVideoForTests(const IntRect& targetRect, |
46 const IntRect& rootRect, | 53 const IntRect& rootRect, |
47 const IntRect& intersectionRect); | 54 const IntRect& intersectionRect); |
48 | 55 |
49 // `m_videoElement` owns |this|. | 56 // `m_videoElement` owns |this|. |
50 Member<HTMLVideoElement> m_videoElement; | 57 Member<HTMLVideoElement> m_videoElement; |
51 TaskRunnerTimer<MediaCustomControlsFullscreenDetector> | 58 TaskRunnerTimer<MediaCustomControlsFullscreenDetector> |
52 m_checkViewportIntersectionTimer; | 59 m_checkViewportIntersectionTimer; |
53 }; | 60 }; |
54 | 61 |
55 } // namespace blink | 62 } // namespace blink |
56 | 63 |
57 #endif // MediaCustomControlsFullscreenDetector_h | 64 #endif // MediaCustomControlsFullscreenDetector_h |
OLD | NEW |