summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/html/media/media_custom_controls_fullscreen_detector.h
blob: 072c68fa7f66710e0b97b411289681f0b4c80ffa (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// 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 THIRD_PARTY_BLINK_RENDERER_CORE_HTML_MEDIA_MEDIA_CUSTOM_CONTROLS_FULLSCREEN_DETECTOR_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_HTML_MEDIA_MEDIA_CUSTOM_CONTROLS_FULLSCREEN_DETECTOR_H_

#include "base/macros.h"
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/dom/events/event_listener.h"
#include "third_party/blink/renderer/platform/timer.h"

namespace blink {

class HTMLVideoElement;
class IntRect;
class TimerBase;

class CORE_EXPORT MediaCustomControlsFullscreenDetector final
    : public EventListener {
 public:
  explicit MediaCustomControlsFullscreenDetector(HTMLVideoElement&);

  // EventListener implementation.
  bool operator==(const EventListener&) const override;

  void Attach();
  void Detach();
  void ContextDestroyed();

  void Trace(blink::Visitor*) override;

 private:
  friend class MediaCustomControlsFullscreenDetectorTest;
  friend class HTMLMediaElementEventListenersTest;

  // EventListener implementation.
  void Invoke(ExecutionContext*, Event*) override;

  HTMLVideoElement& VideoElement() { return *video_element_; }

  void OnCheckViewportIntersectionTimerFired(TimerBase*);

  bool IsVideoOrParentFullscreen();

  static bool ComputeIsDominantVideoForTests(const IntRect& target_rect,
                                             const IntRect& root_rect,
                                             const IntRect& intersection_rect);

  // `video_element_` owns |this|.
  Member<HTMLVideoElement> video_element_;
  TaskRunnerTimer<MediaCustomControlsFullscreenDetector>
      check_viewport_intersection_timer_;

  DISALLOW_COPY_AND_ASSIGN(MediaCustomControlsFullscreenDetector);
};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_CORE_HTML_MEDIA_MEDIA_CUSTOM_CONTROLS_FULLSCREEN_DETECTOR_H_