OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights
reserved. | 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights
reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 void didMoveToNewDocument(Document& oldDocument) override; | 280 void didMoveToNewDocument(Document& oldDocument) override; |
281 virtual KURL posterImageURL() const { return KURL(); } | 281 virtual KURL posterImageURL() const { return KURL(); } |
282 | 282 |
283 enum DisplayMode { Unknown, Poster, Video }; | 283 enum DisplayMode { Unknown, Poster, Video }; |
284 DisplayMode displayMode() const { return m_displayMode; } | 284 DisplayMode displayMode() const { return m_displayMode; } |
285 virtual void setDisplayMode(DisplayMode mode) { m_displayMode = mode; } | 285 virtual void setDisplayMode(DisplayMode mode) { m_displayMode = mode; } |
286 | 286 |
287 void setControllerInternal(MediaController*); | 287 void setControllerInternal(MediaController*); |
288 | 288 |
289 private: | 289 private: |
| 290 // These values are used for a histogram. Do not reorder. |
| 291 enum AutoplayMetrics { |
| 292 // Media element with autoplay seen. |
| 293 AutoplayMediaFound = 0, |
| 294 // Autoplay enabled and user stopped media play at any point. |
| 295 AutoplayStopped = 1, |
| 296 // Autoplay enabled but user bailed out on media play early. |
| 297 AutoplayBailout = 2, |
| 298 // Autoplay disabled but user manually started media. |
| 299 AutoplayManualStart = 3, |
| 300 // Autoplay was (re)enabled through a user-gesture triggered load() |
| 301 AutoplayEnabledThroughLoad = 4, |
| 302 // Autoplay disabled by sandbox flags. |
| 303 AutoplayDisabledBySandbox = 5, |
| 304 // AutoplayStopped for a media play that was started by the experiment. |
| 305 AutoplayExperimentStopped = 6, |
| 306 // AutoplayBailout for media a play that was started by the experiment. |
| 307 AutoplayExperimentBailout = 7, |
| 308 // Autoplay started by experiment when media scrolled into view. We don
't |
| 309 // record whether it was a javascript or attribute autoplay request. |
| 310 AutoplayExperimentStartedByScroll = 8, |
| 311 // Autoplay started by experiment during initial load. |
| 312 AutoplayExperimentStartedByLoad = 9, |
| 313 // Autoplay started by experiment in play() call. |
| 314 AutoplayExperimentStartedByPlay = 10, |
| 315 // This enum value must be last. |
| 316 NumberOfAutoplayMetrics, |
| 317 }; |
| 318 |
290 void resetMediaPlayerAndMediaSource(); | 319 void resetMediaPlayerAndMediaSource(); |
291 | 320 |
292 bool alwaysCreateUserAgentShadowRoot() const final { return true; } | 321 bool alwaysCreateUserAgentShadowRoot() const final { return true; } |
293 bool areAuthorShadowsAllowed() const final { return false; } | 322 bool areAuthorShadowsAllowed() const final { return false; } |
294 | 323 |
295 bool supportsFocus() const final; | 324 bool supportsFocus() const final; |
296 bool isMouseFocusable() const final; | 325 bool isMouseFocusable() const final; |
297 bool layoutObjectIsNeeded(const ComputedStyle&) override; | 326 bool layoutObjectIsNeeded(const ComputedStyle&) override; |
298 LayoutObject* createLayoutObject(const ComputedStyle&) override; | 327 LayoutObject* createLayoutObject(const ComputedStyle&) override; |
299 InsertionNotificationRequest insertedInto(ContainerNode*) final; | 328 InsertionNotificationRequest insertedInto(ContainerNode*) final; |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 | 449 |
421 void changeNetworkStateFromLoadingToIdle(); | 450 void changeNetworkStateFromLoadingToIdle(); |
422 | 451 |
423 const AtomicString& mediaGroup() const; | 452 const AtomicString& mediaGroup() const; |
424 void setMediaGroup(const AtomicString&); | 453 void setMediaGroup(const AtomicString&); |
425 void updateMediaController(); | 454 void updateMediaController(); |
426 bool isBlocked() const; | 455 bool isBlocked() const; |
427 bool isBlockedOnMediaController() const; | 456 bool isBlockedOnMediaController() const; |
428 bool isAutoplaying() const { return m_autoplaying; } | 457 bool isAutoplaying() const { return m_autoplaying; } |
429 | 458 |
| 459 void recordAutoplayMetric(AutoplayMetrics); |
| 460 |
| 461 // vvvv Helpers for clank autoplay investigation vvvv |
| 462 |
| 463 // Install an event listener to check for changes in visibility. If a |
| 464 // listener is already installed, then this does nothing. |
| 465 void autoplayExperimentInstallEventListenerIfNeeded(); |
| 466 |
| 467 // Remove any event listener. It's okay to call this if one isn't |
| 468 // installed already. |
| 469 void autoplayExperimentClearEventListenerIfNeeded(); |
| 470 |
| 471 // Return true if any only if this player meets (most) of the eligibility |
| 472 // requirements for the experiment to override the need for a user |
| 473 // gesture. This includes everything except the visibility test. |
| 474 bool autoplayExperimentIsEligible() const; |
| 475 |
| 476 // Return true if and only if the player is visible. |
| 477 bool autoplayExperimentIsVisible(); |
| 478 |
| 479 // Set the mute flag on the media if we're in an experiment mode that |
| 480 // requires it, else do nothing. |
| 481 void autoplayExperimentMuteIfNeeded(); |
| 482 |
| 483 // Maybe override the requirement for a user gesture, and start playing |
| 484 // autoplay media. Returns true if only if it starts playback. |
| 485 bool autoplayExperimentMaybeStartPlaying(); |
| 486 |
| 487 // Configure internal state to record that the autoplay experiment is |
| 488 // going to start playback. This doesn't actually start playback, since |
| 489 // there are several different cases. |
| 490 void autoplayExperimentPrepareToPlay(AutoplayMetrics); |
| 491 |
| 492 // Begin (or start over) a periodic check for visibility. We will poll |
| 493 // during this check to see if the video is in view. |
| 494 void beginPeriodicVisibilityCheck(); |
| 495 |
| 496 // Process a timer for checking visibility. |
| 497 void visibilityTimerFired(Timer<HTMLMediaElement>*); |
| 498 // ^^^^ Helpers for clank autoplay investigation ^^^^ |
| 499 |
430 WebMediaPlayer::CORSMode corsMode() const; | 500 WebMediaPlayer::CORSMode corsMode() const; |
431 | 501 |
432 // Returns the "direction of playback" value as specified in the HTML5 spec. | 502 // Returns the "direction of playback" value as specified in the HTML5 spec. |
433 enum DirectionOfPlayback { Backward, Forward }; | 503 enum DirectionOfPlayback { Backward, Forward }; |
434 DirectionOfPlayback directionOfPlayback() const; | 504 DirectionOfPlayback directionOfPlayback() const; |
435 | 505 |
436 // Returns the "effective playback rate" value as specified in the HTML5 spe
c. | 506 // Returns the "effective playback rate" value as specified in the HTML5 spe
c. |
437 double effectivePlaybackRate() const; | 507 double effectivePlaybackRate() const; |
438 | 508 |
439 // Creates placeholder AudioTrack and/or VideoTrack objects when WebMemediaP
layer objects | 509 // Creates placeholder AudioTrack and/or VideoTrack objects when WebMemediaP
layer objects |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 | 613 |
544 bool m_tracksAreReady : 1; | 614 bool m_tracksAreReady : 1; |
545 bool m_haveVisibleTextTrack : 1; | 615 bool m_haveVisibleTextTrack : 1; |
546 bool m_processingPreferenceChange : 1; | 616 bool m_processingPreferenceChange : 1; |
547 bool m_remoteRoutesAvailable : 1; | 617 bool m_remoteRoutesAvailable : 1; |
548 bool m_playingRemotely : 1; | 618 bool m_playingRemotely : 1; |
549 bool m_isFinalizing : 1; | 619 bool m_isFinalizing : 1; |
550 bool m_initialPlayWithoutUserGestures : 1; | 620 bool m_initialPlayWithoutUserGestures : 1; |
551 bool m_autoplayMediaCounted : 1; | 621 bool m_autoplayMediaCounted : 1; |
552 | 622 |
| 623 // Autoplay experiment state. |
| 624 // True if we've received a play() without a pause(). |
| 625 bool m_autoplayExperimentPlayPending : 1; |
| 626 |
| 627 // Autoplay experiment state. |
| 628 // True if and only if we initiated playback because of the autoplay |
| 629 // experiment. Once set, this is never unset. |
| 630 bool m_autoplayExperimentStartedByExperiment : 1; |
| 631 |
| 632 // Autoplay experiment state. |
| 633 // Touch listener for the autoplay experiment. |
| 634 class AutoplayExperimentTouchListener; |
| 635 friend class AutoplayExperimentTouchListener; |
| 636 RefPtrWillBeMember<EventListener> m_autoplayExperimentTouchListener; |
| 637 |
| 638 enum AutoplayExperimentMode { |
| 639 ExperimentOff, |
| 640 ExperimentAlways, |
| 641 ExperimentIfMuted, |
| 642 ExperimentPlayMuted |
| 643 }; |
| 644 AutoplayExperimentMode m_autoplayExperimentMode; |
| 645 |
553 RefPtrWillBeMember<AudioTrackList> m_audioTracks; | 646 RefPtrWillBeMember<AudioTrackList> m_audioTracks; |
554 RefPtrWillBeMember<VideoTrackList> m_videoTracks; | 647 RefPtrWillBeMember<VideoTrackList> m_videoTracks; |
555 RefPtrWillBeMember<TextTrackList> m_textTracks; | 648 RefPtrWillBeMember<TextTrackList> m_textTracks; |
556 WillBeHeapVector<RefPtrWillBeMember<TextTrack>> m_textTracksWhenResourceSele
ctionBegan; | 649 WillBeHeapVector<RefPtrWillBeMember<TextTrack>> m_textTracksWhenResourceSele
ctionBegan; |
557 | 650 |
558 OwnPtrWillBeMember<CueTimeline> m_cueTimeline; | 651 OwnPtrWillBeMember<CueTimeline> m_cueTimeline; |
559 | 652 |
560 #if ENABLE(WEB_AUDIO) | 653 #if ENABLE(WEB_AUDIO) |
561 // This is a weak reference, since m_audioSourceNode holds a reference to us
. | 654 // This is a weak reference, since m_audioSourceNode holds a reference to us
. |
562 // FIXME: Oilpan: Consider making this a strongly traced pointer with oilpan
where strong cycles are not a problem. | 655 // FIXME: Oilpan: Consider making this a strongly traced pointer with oilpan
where strong cycles are not a problem. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 | 699 |
607 private: | 700 private: |
608 WebAudioSourceProvider* m_webAudioSourceProvider; | 701 WebAudioSourceProvider* m_webAudioSourceProvider; |
609 PersistentWillBeMember<AudioClientImpl> m_client; | 702 PersistentWillBeMember<AudioClientImpl> m_client; |
610 Mutex provideInputLock; | 703 Mutex provideInputLock; |
611 }; | 704 }; |
612 | 705 |
613 AudioSourceProviderImpl m_audioSourceProvider; | 706 AudioSourceProviderImpl m_audioSourceProvider; |
614 #endif | 707 #endif |
615 | 708 |
| 709 Timer<HTMLMediaElement> m_autoplayVisibilityTimer; |
| 710 double m_autoplayLastScrollX; |
| 711 double m_autoplayLastScrollY; |
| 712 double m_autoplayVisibilityTimerSpan; |
| 713 |
616 friend class MediaController; | 714 friend class MediaController; |
617 PersistentWillBeMember<MediaController> m_mediaController; | 715 PersistentWillBeMember<MediaController> m_mediaController; |
618 | 716 |
619 friend class Internals; | 717 friend class Internals; |
620 friend class TrackDisplayUpdateScope; | 718 friend class TrackDisplayUpdateScope; |
621 | 719 |
622 static URLRegistry* s_mediaStreamRegistry; | 720 static URLRegistry* s_mediaStreamRegistry; |
623 }; | 721 }; |
624 | 722 |
625 inline bool isHTMLMediaElement(const HTMLElement& element) | 723 inline bool isHTMLMediaElement(const HTMLElement& element) |
626 { | 724 { |
627 return isHTMLAudioElement(element) || isHTMLVideoElement(element); | 725 return isHTMLAudioElement(element) || isHTMLVideoElement(element); |
628 } | 726 } |
629 | 727 |
630 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); | 728 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); |
631 | 729 |
632 } // namespace blink | 730 } // namespace blink |
633 | 731 |
634 #endif // HTMLMediaElement_h | 732 #endif // HTMLMediaElement_h |
OLD | NEW |