OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. |
3 * Copyright (C) 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2011 Google Inc. All rights reserved. |
4 * Copyright (C) 2012 Research In Motion Limited. All rights reserved. | 4 * Copyright (C) 2012 Research In Motion Limited. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 15 matching lines...) Expand all Loading... |
26 */ | 26 */ |
27 | 27 |
28 #include "config.h" | 28 #include "config.h" |
29 | 29 |
30 #if ENABLE(VIDEO) | 30 #if ENABLE(VIDEO) |
31 #include "MediaControlsBlackBerry.h" | 31 #include "MediaControlsBlackBerry.h" |
32 | 32 |
33 #include "Chrome.h" | 33 #include "Chrome.h" |
34 #include "DOMTokenList.h" | 34 #include "DOMTokenList.h" |
35 #include "ExceptionCodePlaceholder.h" | 35 #include "ExceptionCodePlaceholder.h" |
36 #include "FloatConversion.h" | |
37 #include "Frame.h" | 36 #include "Frame.h" |
38 #include "HTMLMediaElement.h" | 37 #include "HTMLMediaElement.h" |
39 #include "HTMLNames.h" | 38 #include "HTMLNames.h" |
40 #include "MediaControlElements.h" | 39 #include "MediaControlElements.h" |
41 #include "MouseEvent.h" | 40 #include "MouseEvent.h" |
42 #include "Page.h" | 41 #include "Page.h" |
43 #include "RenderDeprecatedFlexibleBox.h" | 42 #include "RenderDeprecatedFlexibleBox.h" |
44 #include "RenderSlider.h" | 43 #include "RenderSlider.h" |
45 #include "RenderTheme.h" | 44 #include "RenderTheme.h" |
46 #include "Settings.h" | 45 #include "Settings.h" |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 { | 473 { |
475 } | 474 } |
476 | 475 |
477 PassRefPtr<MediaControlFullscreenTimelineElement> MediaControlFullscreenTimeline
Element::create(Document* document, MediaControls* controls) | 476 PassRefPtr<MediaControlFullscreenTimelineElement> MediaControlFullscreenTimeline
Element::create(Document* document, MediaControls* controls) |
478 { | 477 { |
479 ASSERT(controls); | 478 ASSERT(controls); |
480 | 479 |
481 RefPtr<MediaControlFullscreenTimelineElement> timeline = adoptRef(new MediaC
ontrolFullscreenTimelineElement(document, controls)); | 480 RefPtr<MediaControlFullscreenTimelineElement> timeline = adoptRef(new MediaC
ontrolFullscreenTimelineElement(document, controls)); |
482 timeline->ensureUserAgentShadowRoot(); | 481 timeline->ensureUserAgentShadowRoot(); |
483 timeline->setType("range"); | 482 timeline->setType("range"); |
484 timeline->setAttribute(precisionAttr, "float"); | 483 timeline->setAttribute(precisionAttr, "double"); |
485 return timeline.release(); | 484 return timeline.release(); |
486 } | 485 } |
487 | 486 |
488 void MediaControlFullscreenTimelineElement::defaultEventHandler(Event* event) | 487 void MediaControlFullscreenTimelineElement::defaultEventHandler(Event* event) |
489 { | 488 { |
490 // Left button is 0. Rejects mouse events not from left button. | 489 // Left button is 0. Rejects mouse events not from left button. |
491 if (event->isMouseEvent() && static_cast<MouseEvent*>(event)->button()) | 490 if (event->isMouseEvent() && static_cast<MouseEvent*>(event)->button()) |
492 return; | 491 return; |
493 | 492 |
494 if (!attached()) | 493 if (!attached()) |
495 return; | 494 return; |
496 | 495 |
497 if (event->type() == eventNames().mousedownEvent) | 496 if (event->type() == eventNames().mousedownEvent) |
498 mediaController()->beginScrubbing(); | 497 mediaController()->beginScrubbing(); |
499 | 498 |
500 if (event->type() == eventNames().mouseupEvent) | 499 if (event->type() == eventNames().mouseupEvent) |
501 mediaController()->endScrubbing(); | 500 mediaController()->endScrubbing(); |
502 | 501 |
503 MediaControlInputElement::defaultEventHandler(event); | 502 MediaControlInputElement::defaultEventHandler(event); |
504 | 503 |
505 if (event->type() == eventNames().mouseoverEvent || event->type() == eventNa
mes().mouseoutEvent || event->type() == eventNames().mousemoveEvent) | 504 if (event->type() == eventNames().mouseoverEvent || event->type() == eventNa
mes().mouseoutEvent || event->type() == eventNames().mousemoveEvent) |
506 return; | 505 return; |
507 | 506 |
508 float time = narrowPrecisionToFloat(value().toDouble()); | 507 double time = value().toDouble(); |
509 if (event->type() == eventNames().inputEvent && time != mediaController()->c
urrentTime()) | 508 if (event->type() == eventNames().inputEvent && time != mediaController()->c
urrentTime()) |
510 mediaController()->setCurrentTime(time, IGNORE_EXCEPTION); | 509 mediaController()->setCurrentTime(time, IGNORE_EXCEPTION); |
511 | 510 |
512 RenderSlider* slider = toRenderSlider(renderer()); | 511 RenderSlider* slider = toRenderSlider(renderer()); |
513 if (slider && slider->inDragMode()) | 512 if (slider && slider->inDragMode()) |
514 m_controls->updateCurrentTimeDisplay(); | 513 m_controls->updateCurrentTimeDisplay(); |
515 } | 514 } |
516 | 515 |
517 bool MediaControlFullscreenTimelineElement::willRespondToMouseClickEvents() | 516 bool MediaControlFullscreenTimelineElement::willRespondToMouseClickEvents() |
518 { | 517 { |
519 if (!attached()) | 518 if (!attached()) |
520 return false; | 519 return false; |
521 | 520 |
522 return true; | 521 return true; |
523 } | 522 } |
524 | 523 |
525 void MediaControlFullscreenTimelineElement::setPosition(float currentTime) | 524 void MediaControlFullscreenTimelineElement::setPosition(double currentTime) |
526 { | 525 { |
527 setValue(String::number(currentTime)); | 526 setValue(String::number(currentTime)); |
528 } | 527 } |
529 | 528 |
530 void MediaControlFullscreenTimelineElement::setDuration(float duration) | 529 void MediaControlFullscreenTimelineElement::setDuration(double duration) |
531 { | 530 { |
532 setAttribute(maxAttr, String::number(std::isfinite(duration) ? duration : 0)
); | 531 setAttribute(maxAttr, String::number(std::isfinite(duration) ? duration : 0)
); |
533 } | 532 } |
534 | 533 |
535 const AtomicString& MediaControlFullscreenTimelineElement::shadowPseudoId() cons
t | 534 const AtomicString& MediaControlFullscreenTimelineElement::shadowPseudoId() cons
t |
536 { | 535 { |
537 DEFINE_STATIC_LOCAL(AtomicString, id, ("-webkit-media-controls-fullscreen-ti
meline", AtomicString::ConstructFromLiteral)); | 536 DEFINE_STATIC_LOCAL(AtomicString, id, ("-webkit-media-controls-fullscreen-ti
meline", AtomicString::ConstructFromLiteral)); |
538 return id; | 537 return id; |
539 } | 538 } |
540 | 539 |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 m_fullScreenButton->show(); | 903 m_fullScreenButton->show(); |
905 else | 904 else |
906 m_fullScreenButton->hide(); | 905 m_fullScreenButton->hide(); |
907 } | 906 } |
908 if (m_fullscreenFullScreenButton) { | 907 if (m_fullscreenFullScreenButton) { |
909 if (m_mediaController->supportsFullscreen()) | 908 if (m_mediaController->supportsFullscreen()) |
910 m_fullscreenFullScreenButton->show(); | 909 m_fullscreenFullScreenButton->show(); |
911 else | 910 else |
912 m_fullscreenFullScreenButton->hide(); | 911 m_fullscreenFullScreenButton->hide(); |
913 } | 912 } |
914 float duration = m_mediaController->duration(); | 913 double duration = m_mediaController->duration(); |
915 if (std::isfinite(duration) || page->theme()->hasOwnDisabledStateHandlingFor
(MediaSliderPart)) { | 914 if (std::isfinite(duration) || page->theme()->hasOwnDisabledStateHandlingFor
(MediaSliderPart)) { |
916 float now = m_mediaController->currentTime(); | 915 double now = m_mediaController->currentTime(); |
917 m_timeline->setDuration(duration); | 916 m_timeline->setDuration(duration); |
918 m_fullscreenTimeline->setDuration(duration); | 917 m_fullscreenTimeline->setDuration(duration); |
919 m_timelineContainer->show(); | 918 m_timelineContainer->show(); |
920 m_fullscreenTimelineContainer->show(); | 919 m_fullscreenTimelineContainer->show(); |
921 m_timeline->setPosition(now); | 920 m_timeline->setPosition(now); |
922 m_fullscreenTimeline->setPosition(now); | 921 m_fullscreenTimeline->setPosition(now); |
923 updateCurrentTimeDisplay(); | 922 updateCurrentTimeDisplay(); |
924 } else { | 923 } else { |
925 m_timelineContainer->hide(); | 924 m_timelineContainer->hide(); |
926 m_fullscreenTimelineContainer->hide(); | 925 m_fullscreenTimelineContainer->hide(); |
(...skipping 21 matching lines...) Expand all Loading... |
948 m_fullscreenPlayButton->updateDisplayType(); | 947 m_fullscreenPlayButton->updateDisplayType(); |
949 | 948 |
950 makeOpaque(); | 949 makeOpaque(); |
951 } | 950 } |
952 | 951 |
953 void MediaControlsBlackBerry::bufferingProgressed() | 952 void MediaControlsBlackBerry::bufferingProgressed() |
954 { | 953 { |
955 // We only need to update buffering progress when paused, during normal | 954 // We only need to update buffering progress when paused, during normal |
956 // playback playbackProgressed() will take care of it. | 955 // playback playbackProgressed() will take care of it. |
957 if (m_mediaController->paused()) { | 956 if (m_mediaController->paused()) { |
958 float now = m_mediaController->currentTime(); | 957 double now = m_mediaController->currentTime(); |
959 m_timeline->setPosition(now); | 958 m_timeline->setPosition(now); |
960 m_fullscreenTimeline->setPosition(now); | 959 m_fullscreenTimeline->setPosition(now); |
961 } | 960 } |
962 } | 961 } |
963 | 962 |
964 void MediaControlsBlackBerry::playbackStarted() | 963 void MediaControlsBlackBerry::playbackStarted() |
965 { | 964 { |
966 float now = m_mediaController->currentTime(); | 965 double now = m_mediaController->currentTime(); |
967 m_playButton->updateDisplayType(); | 966 m_playButton->updateDisplayType(); |
968 m_fullscreenPlayButton->updateDisplayType(); | 967 m_fullscreenPlayButton->updateDisplayType(); |
969 m_timeline->setPosition(now); | 968 m_timeline->setPosition(now); |
970 m_fullscreenTimeline->setPosition(now); | 969 m_fullscreenTimeline->setPosition(now); |
971 updateCurrentTimeDisplay(); | 970 updateCurrentTimeDisplay(); |
972 | 971 |
973 if (m_isFullscreen) | 972 if (m_isFullscreen) |
974 startHideFullscreenControlsTimer(); | 973 startHideFullscreenControlsTimer(); |
975 } | 974 } |
976 | 975 |
977 void MediaControlsBlackBerry::playbackProgressed() | 976 void MediaControlsBlackBerry::playbackProgressed() |
978 { | 977 { |
979 float now = m_mediaController->currentTime(); | 978 double now = m_mediaController->currentTime(); |
980 m_timeline->setPosition(now); | 979 m_timeline->setPosition(now); |
981 m_fullscreenTimeline->setPosition(now); | 980 m_fullscreenTimeline->setPosition(now); |
982 updateCurrentTimeDisplay(); | 981 updateCurrentTimeDisplay(); |
983 | 982 |
984 if (!m_isMouseOverControls && m_mediaController->hasVideo()) | 983 if (!m_isMouseOverControls && m_mediaController->hasVideo()) |
985 makeTransparent(); | 984 makeTransparent(); |
986 } | 985 } |
987 | 986 |
988 void MediaControlsBlackBerry::playbackStopped() | 987 void MediaControlsBlackBerry::playbackStopped() |
989 { | 988 { |
990 float now = m_mediaController->currentTime(); | 989 double now = m_mediaController->currentTime(); |
991 m_playButton->updateDisplayType(); | 990 m_playButton->updateDisplayType(); |
992 m_fullscreenPlayButton->updateDisplayType(); | 991 m_fullscreenPlayButton->updateDisplayType(); |
993 m_timeline->setPosition(now); | 992 m_timeline->setPosition(now); |
994 m_fullscreenTimeline->setPosition(now); | 993 m_fullscreenTimeline->setPosition(now); |
995 updateCurrentTimeDisplay(); | 994 updateCurrentTimeDisplay(); |
996 makeOpaque(); | 995 makeOpaque(); |
997 | 996 |
998 stopHideFullscreenControlsTimer(); | 997 stopHideFullscreenControlsTimer(); |
999 } | 998 } |
1000 | 999 |
1001 void MediaControlsBlackBerry::updateCurrentTimeDisplay() | 1000 void MediaControlsBlackBerry::updateCurrentTimeDisplay() |
1002 { | 1001 { |
1003 float now = m_mediaController->currentTime(); | 1002 double now = m_mediaController->currentTime(); |
1004 float duration = m_mediaController->duration(); | 1003 double duration = m_mediaController->duration(); |
1005 | 1004 |
1006 Page* page = document()->page(); | 1005 Page* page = document()->page(); |
1007 if (!page) | 1006 if (!page) |
1008 return; | 1007 return; |
1009 | 1008 |
1010 // Allow the theme to format the time. | 1009 // Allow the theme to format the time. |
1011 m_currentTimeDisplay->setInnerText(page->theme()->formatMediaControlsCurrent
Time(now, duration), IGNORE_EXCEPTION); | 1010 m_currentTimeDisplay->setInnerText(page->theme()->formatMediaControlsCurrent
Time(now, duration), IGNORE_EXCEPTION); |
1012 m_currentTimeDisplay->setCurrentValue(now); | 1011 m_currentTimeDisplay->setCurrentValue(now); |
1013 m_fullscreenCurrentTimeDisplay->setInnerText(page->theme()->formatMediaContr
olsCurrentTime(now, duration), IGNORE_EXCEPTION); | 1012 m_fullscreenCurrentTimeDisplay->setInnerText(page->theme()->formatMediaContr
olsCurrentTime(now, duration), IGNORE_EXCEPTION); |
1014 m_fullscreenCurrentTimeDisplay->setCurrentValue(now); | 1013 m_fullscreenCurrentTimeDisplay->setCurrentValue(now); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1105 | 1104 |
1106 bool MediaControlsBlackBerry::shouldHideControls() | 1105 bool MediaControlsBlackBerry::shouldHideControls() |
1107 { | 1106 { |
1108 if (m_isFullscreen) | 1107 if (m_isFullscreen) |
1109 return !m_panel->hovered(); | 1108 return !m_panel->hovered(); |
1110 return !m_embeddedPanel->hovered(); | 1109 return !m_embeddedPanel->hovered(); |
1111 } | 1110 } |
1112 } | 1111 } |
1113 | 1112 |
1114 #endif | 1113 #endif |
OLD | NEW |