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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
293 | 293 |
294 void didMoveToNewDocument(Document& oldDocument) override; | 294 void didMoveToNewDocument(Document& oldDocument) override; |
295 | 295 |
296 enum DisplayMode { Unknown, Poster, Video }; | 296 enum DisplayMode { Unknown, Poster, Video }; |
297 DisplayMode displayMode() const { return m_displayMode; } | 297 DisplayMode displayMode() const { return m_displayMode; } |
298 virtual void setDisplayMode(DisplayMode mode) { m_displayMode = mode; } | 298 virtual void setDisplayMode(DisplayMode mode) { m_displayMode = mode; } |
299 | 299 |
300 void setControllerInternal(MediaController*); | 300 void setControllerInternal(MediaController*); |
301 | 301 |
302 private: | 302 private: |
303 // These values are used for a histogram. Do not reorder. | |
304 enum AutoplayMetrics { | |
305 // Media element with autoplay seen. | |
306 AutoplayMediaFound = 0, | |
307 // Autoplay enabled and user stopped media play at any point. | |
308 AutoplayStopped = 1, | |
309 // Autoplay enabled but user bailed out on media play early. | |
310 AutoplayBailout = 2, | |
311 // Autoplay disabled but user manually started media. | |
312 AutoplayManualStart = 3, | |
313 // Autoplay was (re)enabled through a user-gesture triggered load() | |
314 AutoplayEnabledThroughLoad = 4, | |
315 // Autoplay disabled by sandbox flags. | |
316 AutoplayDisabledBySandbox = 5, | |
317 // AutoplayStopped for a media play that was started by the experiment. | |
318 AutoplayExperimentStopped = 6, | |
319 // AutoplayBailout for media a play that was started by the experiment. | |
320 AutoplayExperimentBailout = 7, | |
321 // Autoplay started by experiment when media scrolled into view. We don 't | |
322 // record whether it was a javascript or attribute autoplay request. | |
323 AutoplayExperimentStartedByScroll = 8, | |
324 // Autoplay started by experiment during initial load. | |
325 AutoplayExperimentStartedByLoad = 9, | |
326 // Autoplay started by experiment in play() call. | |
327 AutoplayExperimentStartedByPlay = 10, | |
328 // This enum value must be last. | |
329 NumberOfAutoplayMetrics, | |
330 }; | |
331 | |
303 void createMediaPlayer(); | 332 void createMediaPlayer(); |
304 | 333 |
305 bool alwaysCreateUserAgentShadowRoot() const final { return true; } | 334 bool alwaysCreateUserAgentShadowRoot() const final { return true; } |
306 bool areAuthorShadowsAllowed() const final { return false; } | 335 bool areAuthorShadowsAllowed() const final { return false; } |
307 | 336 |
308 bool supportsFocus() const final; | 337 bool supportsFocus() const final; |
309 bool isMouseFocusable() const final; | 338 bool isMouseFocusable() const final; |
310 bool layoutObjectIsNeeded(const ComputedStyle&) override; | 339 bool layoutObjectIsNeeded(const ComputedStyle&) override; |
311 LayoutObject* createLayoutObject(const ComputedStyle&) override; | 340 LayoutObject* createLayoutObject(const ComputedStyle&) override; |
312 InsertionNotificationRequest insertedInto(ContainerNode*) final; | 341 InsertionNotificationRequest insertedInto(ContainerNode*) final; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
422 | 451 |
423 void changeNetworkStateFromLoadingToIdle(); | 452 void changeNetworkStateFromLoadingToIdle(); |
424 | 453 |
425 const AtomicString& mediaGroup() const; | 454 const AtomicString& mediaGroup() const; |
426 void setMediaGroup(const AtomicString&); | 455 void setMediaGroup(const AtomicString&); |
427 void updateMediaController(); | 456 void updateMediaController(); |
428 bool isBlocked() const; | 457 bool isBlocked() const; |
429 bool isBlockedOnMediaController() const; | 458 bool isBlockedOnMediaController() const; |
430 bool isAutoplaying() const { return m_autoplaying; } | 459 bool isAutoplaying() const { return m_autoplaying; } |
431 | 460 |
461 void recordAutoplayMetric(AutoplayMetrics); | |
462 | |
463 // vvvv Helpers for clank autoplay investigation vvvv | |
464 | |
465 // Install a scroll listener to check for changes in visibility. If a | |
466 // listener is already installed, then this does nothing. | |
467 void autoplayExperimentInstallScrollListenerIfNeeded(); | |
468 | |
469 // Remove any scroll listener. It's okay to call this if one isn't | |
470 // installed already. | |
471 void autoplayExperimentClearScrollListenerIfNeeded(); | |
472 | |
473 // Return true if any only if this player meets (most) of the eligibility | |
474 // requirements for the experiment to override the need for a user | |
475 // gesture. This includes everything except the visibility test. | |
476 bool autoplayExperimentIsEligible() const; | |
477 | |
478 // Return true if and only if the player is visible. | |
479 bool autoplayExperimentIsVisible(); | |
480 | |
481 // Set the mute flag on the media if we're in an experiment mode that | |
482 // requires it, else do nothing. | |
483 void autoplayExperimentMuteIfNeeded(); | |
484 | |
485 // In response to a scroll event, maybe start playing. Returns true if | |
486 // only if it starts playback. | |
487 bool autoplayExperimentMaybeStartPlaying(); | |
488 | |
489 // Configure internal state to record that the autoplay experiment is | |
490 // going to start playback. This doesn't actually start playback, since | |
491 // there are several different cases. | |
492 void autoplayExperimentPrepareToPlay(AutoplayMetrics); | |
493 | |
494 // ^^^^ Helpers for clank autoplay investigation ^^^^ | |
495 | |
432 WebMediaPlayer::CORSMode corsMode() const; | 496 WebMediaPlayer::CORSMode corsMode() const; |
433 | 497 |
434 // Returns the "direction of playback" value as specified in the HTML5 spec. | 498 // Returns the "direction of playback" value as specified in the HTML5 spec. |
435 enum DirectionOfPlayback { Backward, Forward }; | 499 enum DirectionOfPlayback { Backward, Forward }; |
436 DirectionOfPlayback directionOfPlayback() const; | 500 DirectionOfPlayback directionOfPlayback() const; |
437 | 501 |
438 // Returns the "effective playback rate" value as specified in the HTML5 spe c. | 502 // Returns the "effective playback rate" value as specified in the HTML5 spe c. |
439 double effectivePlaybackRate() const; | 503 double effectivePlaybackRate() const; |
440 | 504 |
441 // Creates placeholder AudioTrack and/or VideoTrack objects when WebMemediaP layer objects | 505 // Creates placeholder AudioTrack and/or VideoTrack objects when WebMemediaP layer objects |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
545 | 609 |
546 bool m_tracksAreReady : 1; | 610 bool m_tracksAreReady : 1; |
547 bool m_haveVisibleTextTrack : 1; | 611 bool m_haveVisibleTextTrack : 1; |
548 bool m_processingPreferenceChange : 1; | 612 bool m_processingPreferenceChange : 1; |
549 bool m_remoteRoutesAvailable : 1; | 613 bool m_remoteRoutesAvailable : 1; |
550 bool m_playingRemotely : 1; | 614 bool m_playingRemotely : 1; |
551 bool m_isFinalizing : 1; | 615 bool m_isFinalizing : 1; |
552 bool m_initialPlayWithoutUserGestures : 1; | 616 bool m_initialPlayWithoutUserGestures : 1; |
553 bool m_autoplayMediaCounted : 1; | 617 bool m_autoplayMediaCounted : 1; |
554 | 618 |
619 // Autoplay experiment state. | |
620 // True if we've received a play() without a pause(). | |
621 bool m_autoplayExperimentPlayPending : 1; | |
622 | |
623 // Autoplay experiment state. | |
624 // True if and only if we initiated playback because of the autoplay | |
625 // experiment. Once set, this is never unset. | |
626 bool m_autoplayExperimentStartedByExperiment : 1; | |
627 | |
628 // Autoplay experiment state. | |
629 // Scroll listener for the autoplay experiment. | |
630 class AutoplayExperimentScrollListener; | |
631 friend class AutoplayExperimentScrollListener; | |
632 RefPtrWillBeMember<EventListener> m_autoplayExperimentScrollListener; | |
633 | |
634 enum AutoplayExperimentMode { | |
635 ExperimentOff, | |
636 ExperimentAlways, | |
637 ExperimentIfMuted, | |
638 ExperimentPlayMuted | |
639 }; | |
640 AutoplayExperimentMode m_autoplayExperimentMode; | |
641 | |
555 RefPtrWillBeMember<AudioTrackList> m_audioTracks; | 642 RefPtrWillBeMember<AudioTrackList> m_audioTracks; |
556 RefPtrWillBeMember<VideoTrackList> m_videoTracks; | 643 RefPtrWillBeMember<VideoTrackList> m_videoTracks; |
557 RefPtrWillBeMember<TextTrackList> m_textTracks; | 644 RefPtrWillBeMember<TextTrackList> m_textTracks; |
558 WillBeHeapVector<RefPtrWillBeMember<TextTrack>> m_textTracksWhenResourceSele ctionBegan; | 645 WillBeHeapVector<RefPtrWillBeMember<TextTrack>> m_textTracksWhenResourceSele ctionBegan; |
559 | 646 |
560 OwnPtrWillBeMember<CueTimeline> m_cueTimeline; | 647 OwnPtrWillBeMember<CueTimeline> m_cueTimeline; |
561 | 648 |
562 #if ENABLE(WEB_AUDIO) | 649 #if ENABLE(WEB_AUDIO) |
563 // This is a weak reference, since m_audioSourceNode holds a reference to us . | 650 // This is a weak reference, since m_audioSourceNode holds a reference to us . |
564 // FIXME: Oilpan: Consider making this a strongly traced pointer with oilpan where strong cycles are not a problem. | 651 // FIXME: Oilpan: Consider making this a strongly traced pointer with oilpan where strong cycles are not a problem. |
565 GC_PLUGIN_IGNORE("http://crbug.com/404577") | 652 GC_PLUGIN_IGNORE("http://crbug.com/404577") |
566 RawPtrWillBeWeakMember<AudioSourceProviderClient> m_audioSourceNode; | 653 RawPtrWillBeWeakMember<AudioSourceProviderClient> m_audioSourceNode; |
567 #endif | 654 #endif |
568 | 655 |
569 friend class MediaController; | 656 friend class MediaController; |
570 PersistentWillBeMember<MediaController> m_mediaController; | 657 PersistentWillBeMember<MediaController> m_mediaController; |
658 friend class MyScrollListener; | |
philipj_slow
2015/07/21 12:51:29
MyScrollListener is nowhere to be found?
liberato (no reviews please)
2015/07/27 06:03:09
that was sloppy of me. thanks.
| |
571 | 659 |
572 friend class Internals; | 660 friend class Internals; |
573 friend class TrackDisplayUpdateScope; | 661 friend class TrackDisplayUpdateScope; |
574 | 662 |
575 static URLRegistry* s_mediaStreamRegistry; | 663 static URLRegistry* s_mediaStreamRegistry; |
576 }; | 664 }; |
577 | 665 |
578 inline bool isHTMLMediaElement(const HTMLElement& element) | 666 inline bool isHTMLMediaElement(const HTMLElement& element) |
579 { | 667 { |
580 return isHTMLAudioElement(element) || isHTMLVideoElement(element); | 668 return isHTMLAudioElement(element) || isHTMLVideoElement(element); |
581 } | 669 } |
582 | 670 |
583 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); | 671 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); |
584 | 672 |
585 } // namespace blink | 673 } // namespace blink |
586 | 674 |
587 #endif // HTMLMediaElement_h | 675 #endif // HTMLMediaElement_h |
OLD | NEW |