2c67da4aa61cff38fc0e3613ce4cb78b48cc723f
[platform/framework/web/chromium-efl.git] /
1 // Copyright 2017 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "third_party/blink/renderer/modules/media_controls/elements/media_control_remaining_time_display_element.h"
6
7 #include "third_party/blink/public/strings/grit/blink_strings.h"
8 #include "third_party/blink/renderer/modules/media_controls/media_controls_impl.h"
9 #if BUILDFLAG(IS_TIZEN_TV)
10 #include "third_party/blink/renderer/core/html/media/html_media_element.h"
11 #endif
12
13 namespace {
14
15 // The during element has extra '/ ' in the text which takes approximately
16 // 9 pixels.
17 constexpr int kTimeDisplayExtraCharacterWidth = 9;
18
19 }  // namespace
20
21 namespace blink {
22
23 MediaControlRemainingTimeDisplayElement::
24     MediaControlRemainingTimeDisplayElement(MediaControlsImpl& media_controls)
25     : MediaControlTimeDisplayElement(media_controls) {
26   SetShadowPseudoId(
27       AtomicString("-webkit-media-controls-time-remaining-display"));
28 }
29
30 int MediaControlRemainingTimeDisplayElement::EstimateElementWidth() const {
31   // Add extra pixel width for during display since we have an extra  "/ ".
32   return kTimeDisplayExtraCharacterWidth +
33          MediaControlTimeDisplayElement::EstimateElementWidth();
34 }
35
36 String MediaControlRemainingTimeDisplayElement::FormatTime() const {
37 #if BUILDFLAG(IS_TIZEN_TV)
38   if (MediaElement().IsFullscreen()) {
39     return MediaControlTimeDisplayElement::FormatTime();
40   } else
41 #endif
42     // For the duration display, we prepend a "/ " to deliminate the current
43     // time from the duration, e.g. "0:12 / 3:45".
44     return "/ " + MediaControlTimeDisplayElement::FormatTime();
45 }
46
47 }  // namespace blink