summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/modules/media_controls/elements/media_control_slider_element.h
blob: 195b27fa0a34dd982b9b0f8c768d6ca62fdb293e (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
61
62
63
64
65
66
67
68
// 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_MODULES_MEDIA_CONTROLS_ELEMENTS_MEDIA_CONTROL_SLIDER_ELEMENT_H_
#define THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIA_CONTROLS_ELEMENTS_MEDIA_CONTROL_SLIDER_ELEMENT_H_

#include "third_party/blink/renderer/modules/media_controls/elements/media_control_input_element.h"
#include "third_party/blink/renderer/modules/modules_export.h"

namespace blink {

class Element;
class MediaControlsImpl;
class ResizeObserver;

// MediaControlInputElement with additional logic for sliders.
class MODULES_EXPORT MediaControlSliderElement
    : public MediaControlInputElement {
  USING_GARBAGE_COLLECTED_MIXIN(MediaControlSliderElement);

 public:
  void Trace(Visitor*) override;

  // Stores the position of the segment in proportion from 0.0 to 1.0.
  struct Position {
    Position(double left, double width) : left(left), width(width) {}
    double left;
    double width;
  };

  // Width in CSS pixels * pageZoomFactor (ignores CSS transforms for
  // simplicity; deliberately ignores pinch zoom's pageScaleFactor).
  int TrackWidth();

  void OnControlsShown();
  void OnControlsHidden();

 protected:
  friend class MediaControlsImplTest;

  class MediaControlSliderElementResizeObserverDelegate;

  MediaControlSliderElement(MediaControlsImpl&);

  void SetupBarSegments();
  void SetBeforeSegmentPosition(Position);
  void SetAfterSegmentPosition(Position);

  void NotifyElementSizeChanged();

  Element& GetTrackElement();

  float ZoomFactor() const;

 private:
  Position before_segment_position_;
  Position after_segment_position_;

  Member<HTMLDivElement> segment_highlight_before_;
  Member<HTMLDivElement> segment_highlight_after_;

  Member<ResizeObserver> resize_observer_;
};

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_MODULES_MEDIA_CONTROLS_ELEMENTS_MEDIA_CONTROL_SLIDER_ELEMENT_H_