blob: 57c9b42217fb198af642a293f4a4dc7f484d6fa7 [file] [log] [blame]
// 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.
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/platform/heap/handle.h"
#include "third_party/blink/renderer/platform/heap/visitor.h"
namespace blink {
class HTMLDivElement;
class HTMLMediaElement;
class LayoutObject;
// The CSS class names for the different sizing thresholds.
const char kMediaControlsSizingSmallCSSClass[] = "sizing-small";
const char kMediaControlsSizingMediumCSSClass[] = "sizing-medium";
const char kMediaControlsSizingLargeCSSClass[] = "sizing-large";
// The different media controls sizing classes.
enum class MediaControlsSizingClass { kSmall, kMedium, kLarge };
// MediaControls is an interface to abstract the HTMLMediaElement controls. The
// implementation will be used using a Factory (see below).
class CORE_EXPORT MediaControls : public GarbageCollectedMixin {
// Get the |MediaControlsSizingClass| based on the width of the element in
// pixels.
static MediaControlsSizingClass GetSizingClass(int width);
// Get the CSS class name from the |MediaControlsSizingClass|.
static AtomicString GetSizingCSSClass(MediaControlsSizingClass sizing_class);
virtual ~MediaControls() = default;
HTMLMediaElement& MediaElement() const;
// Enables showing of the controls - only shows if appropriate.
virtual void MaybeShow() = 0;
// Disables showing of the controls - immediately hides.
virtual void Hide() = 0;
virtual void Reset() = 0;
// Notify the media controls that the controlsList attribute has changed.
virtual void OnControlsListUpdated() = 0;
// TODO(mlamouri): this is temporary to notify the controls that an
// HTMLTrackElement failed to load because there is no web exposed way to
// be notified on the TextTrack object. See
virtual void OnTrackElementFailedToLoad() = 0;
// TODO(mlamouri): this method should be moved away from the interface to
// become an implementation detail.
virtual void NetworkStateChanged() = 0;
// Returns the layout object for the part of the controls that should be
// used for overlap checking during text track layout. May be null.
// TODO(mlamouri): required by LayoutVTTCue.
virtual LayoutObject* PanelLayoutObject() = 0;
virtual LayoutObject* TimelineLayoutObject() = 0;
virtual LayoutObject* ButtonPanelLayoutObject() = 0;
// Returns the layout object of the media controls container. Maybe null.
// TODO(mlamouri): required by LayoutVTTCue.
virtual LayoutObject* ContainerLayoutObject() = 0;
// Used for web tests to disable some animations.
virtual void SetTestMode(bool) = 0;
// TODO: the following are required by other parts of the media controls
// implementation and could be removed when the full implementation has moved
// to modules.
virtual HTMLDivElement* PanelElement() = 0;
virtual void OnMediaControlsEnabledChange() = 0;
void Trace(Visitor*) override;
Member<HTMLMediaElement> media_element_;
} // namespace blink