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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
279 void didMoveToNewDocument(Document& oldDocument) override; | 279 void didMoveToNewDocument(Document& oldDocument) override; |
280 virtual KURL posterImageURL() const { return KURL(); } | 280 virtual KURL posterImageURL() const { return KURL(); } |
281 | 281 |
282 enum DisplayMode { Unknown, Poster, Video }; | 282 enum DisplayMode { Unknown, Poster, Video }; |
283 DisplayMode displayMode() const { return m_displayMode; } | 283 DisplayMode displayMode() const { return m_displayMode; } |
284 virtual void setDisplayMode(DisplayMode mode) { m_displayMode = mode; } | 284 virtual void setDisplayMode(DisplayMode mode) { m_displayMode = mode; } |
285 | 285 |
286 void setControllerInternal(MediaController*); | 286 void setControllerInternal(MediaController*); |
287 | 287 |
288 private: | 288 private: |
289 // These values are used for a histogram. Do not reorder. | |
290 enum AutoplayMetrics { | |
291 // Media element with autoplay seen. | |
philipj_slow
2015/08/05 10:03:12
I'm not sure what this broad metric is for, but th
liberato (no reviews please)
2015/08/06 06:37:58
i've added some comments and renamed some of the n
philipj_slow
2015/08/13 09:27:53
I see, so entries 0-5 should be left as they are.
| |
292 AutoplayMediaFound = 0, | |
293 // Autoplay enabled and user stopped media play at any point. | |
294 AutoplayStopped = 1, | |
philipj_slow
2015/08/05 10:03:12
Isn't it necessary to have one stopped entry for e
liberato (no reviews please)
2015/08/06 06:37:58
i gave this more thought today, but still believe
philipj_slow
2015/08/13 09:27:53
I don't think I understand, if we don't have any p
philipj_slow
2015/09/02 09:35:37
Ping. If separate buckets are needed, as it seems
| |
295 // Autoplay enabled but user bailed out on media play early. | |
296 AutoplayBailout = 2, | |
297 // Autoplay disabled but user manually started media. | |
298 AutoplayManualStart = 3, | |
299 // Autoplay was (re)enabled through a user-gesture triggered load() | |
300 AutoplayEnabledThroughLoad = 4, | |
301 // Autoplay disabled by sandbox flags. | |
302 AutoplayDisabledBySandbox = 5, | |
303 // Autoplay started by experiment when media scrolled into view. We don 't | |
304 // record whether it was a javascript or attribute autoplay request. | |
305 AutoplayExperimentStartedByScroll = 6, | |
306 // Autoplay started by experiment during initial load. | |
307 AutoplayExperimentStartedByLoad = 7, | |
philipj_slow
2015/08/05 10:03:12
I think s/Load/AutoplayAttribute/, it's not really
liberato (no reviews please)
2015/08/06 06:37:58
true, but this is from a previous experiment. the
| |
308 // Autoplay started by experiment in play() call. | |
309 AutoplayExperimentStartedByPlay = 8, | |
310 // play() failed to play due to gesture requirement. | |
311 AutoplayPlayFailed = 9, | |
312 // This enum value must be last. | |
313 NumberOfAutoplayMetrics, | |
314 }; | |
315 | |
289 void resetMediaPlayerAndMediaSource(); | 316 void resetMediaPlayerAndMediaSource(); |
290 | 317 |
291 bool alwaysCreateUserAgentShadowRoot() const final { return true; } | 318 bool alwaysCreateUserAgentShadowRoot() const final { return true; } |
292 bool areAuthorShadowsAllowed() const final { return false; } | 319 bool areAuthorShadowsAllowed() const final { return false; } |
293 | 320 |
294 bool supportsFocus() const final; | 321 bool supportsFocus() const final; |
295 bool isMouseFocusable() const final; | 322 bool isMouseFocusable() const final; |
296 bool layoutObjectIsNeeded(const ComputedStyle&) override; | 323 bool layoutObjectIsNeeded(const ComputedStyle&) override; |
297 LayoutObject* createLayoutObject(const ComputedStyle&) override; | 324 LayoutObject* createLayoutObject(const ComputedStyle&) override; |
298 InsertionNotificationRequest insertedInto(ContainerNode*) final; | 325 InsertionNotificationRequest insertedInto(ContainerNode*) final; |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
419 | 446 |
420 void changeNetworkStateFromLoadingToIdle(); | 447 void changeNetworkStateFromLoadingToIdle(); |
421 | 448 |
422 const AtomicString& mediaGroup() const; | 449 const AtomicString& mediaGroup() const; |
423 void setMediaGroup(const AtomicString&); | 450 void setMediaGroup(const AtomicString&); |
424 void updateMediaController(); | 451 void updateMediaController(); |
425 bool isBlocked() const; | 452 bool isBlocked() const; |
426 bool isBlockedOnMediaController() const; | 453 bool isBlockedOnMediaController() const; |
427 bool isAutoplaying() const { return m_autoplaying; } | 454 bool isAutoplaying() const { return m_autoplaying; } |
428 | 455 |
456 void recordAutoplayMetric(AutoplayMetrics); | |
457 | |
458 // vvvv Helpers for clank autoplay investigation vvvv | |
459 | |
460 // Install an event listener to check for changes in visibility. If a | |
philipj_slow
2015/08/05 10:03:12
Instead of the touchend/touchcancel+timeout soluti
liberato (no reviews please)
2015/08/06 06:37:58
based on all the comments around this, i've merged
Rick Byers
2015/08/06 15:04:26
This sounds like a good plan to me. I'm sure webs
| |
461 // listener is already installed, then this does nothing. | |
462 void autoplayExperimentInstallEventListenerIfNeeded(); | |
463 | |
464 // Remove any event listener. It's okay to call this if one isn't | |
465 // installed already. | |
466 void autoplayExperimentClearEventListenerIfNeeded(); | |
467 | |
468 // Return true if any only if this player meets (most) of the eligibility | |
469 // requirements for the experiment to override the need for a user | |
470 // gesture. This includes everything except the visibility test. | |
471 bool autoplayExperimentIsEligible() const; | |
472 | |
473 // Return true if and only if the player is visible. | |
474 bool autoplayExperimentIsVisible(); | |
475 | |
476 // Set the mute flag on the media if we're in an experiment mode that | |
477 // requires it, else do nothing. | |
478 void autoplayExperimentMuteIfNeeded(); | |
479 | |
480 // Maybe override the requirement for a user gesture, and start playing | |
481 // autoplay media. Returns true if only if it starts playback. | |
482 bool autoplayExperimentMaybeStartPlaying(); | |
483 | |
484 // Configure internal state to record that the autoplay experiment is | |
485 // going to start playback. This doesn't actually start playback, since | |
486 // there are several different cases. | |
487 void autoplayExperimentPrepareToPlay(AutoplayMetrics); | |
488 | |
489 // Begin (or start over) a periodic check for visibility. We will poll | |
490 // during this check to see if the video is in view. | |
491 void beginPeriodicVisibilityCheck(); | |
492 | |
493 // Process a timer for checking visibility. | |
494 void visibilityTimerFired(Timer<HTMLMediaElement>*); | |
495 // ^^^^ Helpers for clank autoplay investigation ^^^^ | |
496 | |
429 WebMediaPlayer::CORSMode corsMode() const; | 497 WebMediaPlayer::CORSMode corsMode() const; |
430 | 498 |
431 // Returns the "direction of playback" value as specified in the HTML5 spec. | 499 // Returns the "direction of playback" value as specified in the HTML5 spec. |
432 enum DirectionOfPlayback { Backward, Forward }; | 500 enum DirectionOfPlayback { Backward, Forward }; |
433 DirectionOfPlayback directionOfPlayback() const; | 501 DirectionOfPlayback directionOfPlayback() const; |
434 | 502 |
435 // Returns the "effective playback rate" value as specified in the HTML5 spe c. | 503 // Returns the "effective playback rate" value as specified in the HTML5 spe c. |
436 double effectivePlaybackRate() const; | 504 double effectivePlaybackRate() const; |
437 | 505 |
438 // Creates placeholder AudioTrack and/or VideoTrack objects when WebMemediaP layer objects | 506 // Creates placeholder AudioTrack and/or VideoTrack objects when WebMemediaP layer objects |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
547 bool m_playingRemotely : 1; | 615 bool m_playingRemotely : 1; |
548 bool m_isFinalizing : 1; | 616 bool m_isFinalizing : 1; |
549 bool m_initialPlayWithoutUserGestures : 1; | 617 bool m_initialPlayWithoutUserGestures : 1; |
550 bool m_autoplayMediaCounted : 1; | 618 bool m_autoplayMediaCounted : 1; |
551 | 619 |
552 PersistentWillBeMember<AudioTrackList> m_audioTracks; | 620 PersistentWillBeMember<AudioTrackList> m_audioTracks; |
553 PersistentWillBeMember<VideoTrackList> m_videoTracks; | 621 PersistentWillBeMember<VideoTrackList> m_videoTracks; |
554 PersistentWillBeMember<TextTrackList> m_textTracks; | 622 PersistentWillBeMember<TextTrackList> m_textTracks; |
555 PersistentHeapVectorWillBeHeapVector<Member<TextTrack>> m_textTracksWhenReso urceSelectionBegan; | 623 PersistentHeapVectorWillBeHeapVector<Member<TextTrack>> m_textTracksWhenReso urceSelectionBegan; |
556 | 624 |
625 // Autoplay experiment state. | |
626 // True if we've received a play() without a pause(). | |
627 bool m_autoplayExperimentPlayPending : 1; | |
philipj_slow
2015/08/05 10:03:12
It looks like the delayed play is only done for ex
liberato (no reviews please)
2015/08/06 06:37:58
the delayed play will happen for autoplay attribut
philipj_slow
2015/08/13 09:27:53
OK, so the mechanism for delayed play is different
| |
628 | |
629 // Autoplay experiment state. | |
630 // True if and only if we initiated playback because of the autoplay | |
631 // experiment. Once set, this is never unset. | |
632 bool m_autoplayExperimentStartedByExperiment : 1; | |
633 | |
634 // Autoplay experiment state. | |
635 // Touch listener for the autoplay experiment. | |
636 class AutoplayExperimentTouchListener; | |
637 friend class AutoplayExperimentTouchListener; | |
638 RefPtrWillBeMember<EventListener> m_autoplayExperimentTouchListener; | |
639 | |
640 enum AutoplayExperimentMode { | |
641 ExperimentOff = 0, | |
642 ExperimentEnabled = 1, | |
643 ExperimentIfVisible = 2, | |
644 ExperimentIfMuted = 4, | |
645 ExperimentIfMobile = 8, | |
646 ExperimentPlayMuted = 16 | |
philipj_slow
2015/08/05 10:03:12
Bit fields are usually defined using 1 << n in Bli
liberato (no reviews please)
2015/08/06 06:37:58
Done.
| |
647 }; | |
648 int m_autoplayExperimentMode; // Bitwise-or of AutoplayExperimentMode | |
649 | |
557 OwnPtrWillBeMember<CueTimeline> m_cueTimeline; | 650 OwnPtrWillBeMember<CueTimeline> m_cueTimeline; |
558 | 651 |
559 #if ENABLE(WEB_AUDIO) | 652 #if ENABLE(WEB_AUDIO) |
560 // This is a weak reference, since m_audioSourceNode holds a reference to us . | 653 // This is a weak reference, since m_audioSourceNode holds a reference to us . |
561 // FIXME: Oilpan: Consider making this a strongly traced pointer with oilpan where strong cycles are not a problem. | 654 // FIXME: Oilpan: Consider making this a strongly traced pointer with oilpan where strong cycles are not a problem. |
562 GC_PLUGIN_IGNORE("http://crbug.com/404577") | 655 GC_PLUGIN_IGNORE("http://crbug.com/404577") |
563 RawPtrWillBeWeakMember<AudioSourceProviderClient> m_audioSourceNode; | 656 RawPtrWillBeWeakMember<AudioSourceProviderClient> m_audioSourceNode; |
564 | 657 |
565 // AudioClientImpl wraps an AudioSourceProviderClient. | 658 // AudioClientImpl wraps an AudioSourceProviderClient. |
566 // When the audio format is known, Chromium calls setFormat(). | 659 // When the audio format is known, Chromium calls setFormat(). |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
605 | 698 |
606 private: | 699 private: |
607 WebAudioSourceProvider* m_webAudioSourceProvider; | 700 WebAudioSourceProvider* m_webAudioSourceProvider; |
608 PersistentWillBeMember<AudioClientImpl> m_client; | 701 PersistentWillBeMember<AudioClientImpl> m_client; |
609 Mutex provideInputLock; | 702 Mutex provideInputLock; |
610 }; | 703 }; |
611 | 704 |
612 AudioSourceProviderImpl m_audioSourceProvider; | 705 AudioSourceProviderImpl m_audioSourceProvider; |
613 #endif | 706 #endif |
614 | 707 |
708 Timer<HTMLMediaElement> m_autoplayVisibilityTimer; | |
709 double m_autoplayLastScrollX; | |
710 double m_autoplayLastScrollY; | |
711 double m_autoplayVisibilityTimerSpan; | |
712 | |
615 friend class MediaController; | 713 friend class MediaController; |
616 PersistentWillBeMember<MediaController> m_mediaController; | 714 PersistentWillBeMember<MediaController> m_mediaController; |
617 | 715 |
618 friend class Internals; | 716 friend class Internals; |
619 friend class TrackDisplayUpdateScope; | 717 friend class TrackDisplayUpdateScope; |
620 | 718 |
621 static URLRegistry* s_mediaStreamRegistry; | 719 static URLRegistry* s_mediaStreamRegistry; |
622 }; | 720 }; |
623 | 721 |
624 inline bool isHTMLMediaElement(const HTMLElement& element) | 722 inline bool isHTMLMediaElement(const HTMLElement& element) |
625 { | 723 { |
626 return isHTMLAudioElement(element) || isHTMLVideoElement(element); | 724 return isHTMLAudioElement(element) || isHTMLVideoElement(element); |
627 } | 725 } |
628 | 726 |
629 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); | 727 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); |
630 | 728 |
631 } // namespace blink | 729 } // namespace blink |
632 | 730 |
633 #endif // HTMLMediaElement_h | 731 #endif // HTMLMediaElement_h |
OLD | NEW |