| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights | 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights |
| 3 * reserved. | 3 * reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #ifndef HTMLMediaElement_h | 27 #ifndef HTMLMediaElement_h |
| 28 #define HTMLMediaElement_h | 28 #define HTMLMediaElement_h |
| 29 | 29 |
| 30 #include "bindings/core/v8/ActiveScriptWrappable.h" | 30 #include "bindings/core/v8/ActiveScriptWrappable.h" |
| 31 #include "bindings/core/v8/ScriptPromise.h" | 31 #include "bindings/core/v8/ScriptPromise.h" |
| 32 #include "bindings/core/v8/TraceWrapperMember.h" | 32 #include "bindings/core/v8/TraceWrapperMember.h" |
| 33 #include "core/CoreExport.h" | 33 #include "core/CoreExport.h" |
| 34 #include "core/dom/ActiveDOMObject.h" | 34 #include "core/dom/ActiveDOMObject.h" |
| 35 #include "core/dom/ExceptionCode.h" | 35 #include "core/dom/ExceptionCode.h" |
| 36 #include "core/events/GenericEventQueue.h" | 36 #include "core/events/GenericEventQueue.h" |
| 37 #include "core/html/AutoplayExperimentHelper.h" | |
| 38 #include "core/html/HTMLElement.h" | 37 #include "core/html/HTMLElement.h" |
| 39 #include "core/html/track/TextTrack.h" | 38 #include "core/html/track/TextTrack.h" |
| 40 #include "platform/MIMETypeRegistry.h" | 39 #include "platform/MIMETypeRegistry.h" |
| 41 #include "platform/Supplementable.h" | 40 #include "platform/Supplementable.h" |
| 42 #include "platform/WebTaskRunner.h" | 41 #include "platform/WebTaskRunner.h" |
| 43 #include "platform/audio/AudioSourceProvider.h" | 42 #include "platform/audio/AudioSourceProvider.h" |
| 44 #include "public/platform/WebAudioSourceProviderClient.h" | 43 #include "public/platform/WebAudioSourceProviderClient.h" |
| 45 #include "public/platform/WebMediaPlayerClient.h" | 44 #include "public/platform/WebMediaPlayerClient.h" |
| 46 #include <memory> | 45 #include <memory> |
| 47 | 46 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 bool paused() const; | 165 bool paused() const; |
| 167 double defaultPlaybackRate() const; | 166 double defaultPlaybackRate() const; |
| 168 void setDefaultPlaybackRate(double); | 167 void setDefaultPlaybackRate(double); |
| 169 double playbackRate() const; | 168 double playbackRate() const; |
| 170 void setPlaybackRate(double); | 169 void setPlaybackRate(double); |
| 171 void updatePlaybackRate(); | 170 void updatePlaybackRate(); |
| 172 TimeRanges* played(); | 171 TimeRanges* played(); |
| 173 TimeRanges* seekable() const; | 172 TimeRanges* seekable() const; |
| 174 bool ended() const; | 173 bool ended() const; |
| 175 bool autoplay() const; | 174 bool autoplay() const; |
| 176 bool shouldAutoplay( | 175 bool shouldAutoplay(); |
| 177 const RecordMetricsBehavior = RecordMetricsBehavior::DoNotRecord); | |
| 178 bool loop() const; | 176 bool loop() const; |
| 179 void setLoop(bool); | 177 void setLoop(bool); |
| 180 ScriptPromise playForBindings(ScriptState*); | 178 ScriptPromise playForBindings(ScriptState*); |
| 181 Nullable<ExceptionCode> play(); | 179 Nullable<ExceptionCode> play(); |
| 182 void pause(); | 180 void pause(); |
| 183 void requestRemotePlayback(); | 181 void requestRemotePlayback(); |
| 184 void requestRemotePlaybackControl(); | 182 void requestRemotePlaybackControl(); |
| 185 void requestRemotePlaybackStop(); | 183 void requestRemotePlaybackStop(); |
| 186 | 184 |
| 187 // statistics | 185 // statistics |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 // Returns the "effective media volume" value as specified in the HTML5 spec. | 293 // Returns the "effective media volume" value as specified in the HTML5 spec. |
| 296 double effectiveMediaVolume() const; | 294 double effectiveMediaVolume() const; |
| 297 | 295 |
| 298 // Predicates also used when dispatching wrapper creation (cf. | 296 // Predicates also used when dispatching wrapper creation (cf. |
| 299 // [SpecialWrapFor] IDL attribute usage.) | 297 // [SpecialWrapFor] IDL attribute usage.) |
| 300 virtual bool isHTMLAudioElement() const { return false; } | 298 virtual bool isHTMLAudioElement() const { return false; } |
| 301 virtual bool isHTMLVideoElement() const { return false; } | 299 virtual bool isHTMLVideoElement() const { return false; } |
| 302 | 300 |
| 303 void videoWillBeDrawnToCanvas() const; | 301 void videoWillBeDrawnToCanvas() const; |
| 304 | 302 |
| 305 // Temporary callback for crbug.com/487345,402044 | |
| 306 void notifyPositionMayHaveChanged(const IntRect&); | |
| 307 void updatePositionNotificationRegistration(); | |
| 308 | |
| 309 WebRemotePlaybackClient* remotePlaybackClient() { | 303 WebRemotePlaybackClient* remotePlaybackClient() { |
| 310 return m_remotePlaybackClient; | 304 return m_remotePlaybackClient; |
| 311 } | 305 } |
| 312 const WebRemotePlaybackClient* remotePlaybackClient() const { | 306 const WebRemotePlaybackClient* remotePlaybackClient() const { |
| 313 return m_remotePlaybackClient; | 307 return m_remotePlaybackClient; |
| 314 } | 308 } |
| 315 | 309 |
| 316 protected: | 310 protected: |
| 317 HTMLMediaElement(const QualifiedName&, Document&); | 311 HTMLMediaElement(const QualifiedName&, Document&); |
| 318 ~HTMLMediaElement() override; | 312 ~HTMLMediaElement() override; |
| 319 void dispose(); | 313 void dispose(); |
| 320 | 314 |
| 321 void parseAttribute(const QualifiedName&, | 315 void parseAttribute(const QualifiedName&, |
| 322 const AtomicString&, | 316 const AtomicString&, |
| 323 const AtomicString&) override; | 317 const AtomicString&) override; |
| 324 void finishParsingChildren() final; | 318 void finishParsingChildren() final; |
| 325 bool isURLAttribute(const Attribute&) const override; | 319 bool isURLAttribute(const Attribute&) const override; |
| 326 void attachLayoutTree(const AttachContext& = AttachContext()) override; | 320 void attachLayoutTree(const AttachContext& = AttachContext()) override; |
| 327 | 321 |
| 328 void didMoveToNewDocument(Document& oldDocument) override; | 322 void didMoveToNewDocument(Document& oldDocument) override; |
| 329 virtual KURL posterImageURL() const { return KURL(); } | 323 virtual KURL posterImageURL() const { return KURL(); } |
| 330 | 324 |
| 331 enum DisplayMode { Unknown, Poster, Video }; | 325 enum DisplayMode { Unknown, Poster, Video }; |
| 332 DisplayMode getDisplayMode() const { return m_displayMode; } | 326 DisplayMode getDisplayMode() const { return m_displayMode; } |
| 333 virtual void setDisplayMode(DisplayMode mode) { m_displayMode = mode; } | 327 virtual void setDisplayMode(DisplayMode mode) { m_displayMode = mode; } |
| 334 | 328 |
| 335 void recordAutoplayMetric(AutoplayMetrics); | |
| 336 | |
| 337 private: | 329 private: |
| 338 void resetMediaPlayerAndMediaSource(); | 330 void resetMediaPlayerAndMediaSource(); |
| 339 | 331 |
| 340 bool alwaysCreateUserAgentShadowRoot() const final { return true; } | 332 bool alwaysCreateUserAgentShadowRoot() const final { return true; } |
| 341 bool areAuthorShadowsAllowed() const final { return false; } | 333 bool areAuthorShadowsAllowed() const final { return false; } |
| 342 | 334 |
| 343 bool supportsFocus() const final; | 335 bool supportsFocus() const final; |
| 344 bool isMouseFocusable() const final; | 336 bool isMouseFocusable() const final; |
| 345 bool layoutObjectIsNeeded(const ComputedStyle&) override; | 337 bool layoutObjectIsNeeded(const ComputedStyle&) override; |
| 346 LayoutObject* createLayoutObject(const ComputedStyle&) override; | 338 LayoutObject* createLayoutObject(const ComputedStyle&) override; |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 bool isGestureNeededForPlayback() const; | 515 bool isGestureNeededForPlayback() const; |
| 524 | 516 |
| 525 // Return true if and only if the settings allow autoplay of media on this | 517 // Return true if and only if the settings allow autoplay of media on this |
| 526 // frame. | 518 // frame. |
| 527 bool isAutoplayAllowedPerSettings() const; | 519 bool isAutoplayAllowedPerSettings() const; |
| 528 | 520 |
| 529 void setNetworkState(NetworkState); | 521 void setNetworkState(NetworkState); |
| 530 | 522 |
| 531 void audioTracksTimerFired(TimerBase*); | 523 void audioTracksTimerFired(TimerBase*); |
| 532 | 524 |
| 533 // TODO(liberato): remove once autoplay gesture override experiment concludes. | |
| 534 void triggerAutoplayViewportCheckForTesting(); | |
| 535 | |
| 536 void scheduleResolvePlayPromises(); | 525 void scheduleResolvePlayPromises(); |
| 537 void scheduleRejectPlayPromises(ExceptionCode); | 526 void scheduleRejectPlayPromises(ExceptionCode); |
| 538 void scheduleNotifyPlaying(); | 527 void scheduleNotifyPlaying(); |
| 539 void resolveScheduledPlayPromises(); | 528 void resolveScheduledPlayPromises(); |
| 540 void rejectScheduledPlayPromises(); | 529 void rejectScheduledPlayPromises(); |
| 541 void rejectPlayPromises(ExceptionCode, const String&); | 530 void rejectPlayPromises(ExceptionCode, const String&); |
| 542 void rejectPlayPromisesInternal(ExceptionCode, const String&); | 531 void rejectPlayPromisesInternal(ExceptionCode, const String&); |
| 543 | 532 |
| 544 EnumerationHistogram& showControlsHistogram() const; | 533 EnumerationHistogram& showControlsHistogram() const; |
| 545 | 534 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 DECLARE_TRACE(); | 697 DECLARE_TRACE(); |
| 709 | 698 |
| 710 private: | 699 private: |
| 711 WebAudioSourceProvider* m_webAudioSourceProvider; | 700 WebAudioSourceProvider* m_webAudioSourceProvider; |
| 712 Member<AudioClientImpl> m_client; | 701 Member<AudioClientImpl> m_client; |
| 713 Mutex provideInputLock; | 702 Mutex provideInputLock; |
| 714 }; | 703 }; |
| 715 | 704 |
| 716 AudioSourceProviderImpl m_audioSourceProvider; | 705 AudioSourceProviderImpl m_audioSourceProvider; |
| 717 | 706 |
| 718 class AutoplayHelperClientImpl; | |
| 719 | |
| 720 friend class AutoplayUmaHelper; // for isAutoplayAllowedPerSettings | 707 friend class AutoplayUmaHelper; // for isAutoplayAllowedPerSettings |
| 721 friend class Internals; | 708 friend class Internals; |
| 722 friend class TrackDisplayUpdateScope; | 709 friend class TrackDisplayUpdateScope; |
| 723 friend class AutoplayExperimentHelper; | |
| 724 friend class MediaControlsTest; | 710 friend class MediaControlsTest; |
| 725 | 711 |
| 726 Member<AutoplayExperimentHelper::Client> m_autoplayHelperClient; | |
| 727 Member<AutoplayExperimentHelper> m_autoplayHelper; | |
| 728 Member<AutoplayUmaHelper> m_autoplayUmaHelper; | 712 Member<AutoplayUmaHelper> m_autoplayUmaHelper; |
| 729 | 713 |
| 730 WebRemotePlaybackClient* m_remotePlaybackClient; | 714 WebRemotePlaybackClient* m_remotePlaybackClient; |
| 731 | 715 |
| 732 // class AutoplayVisibilityObserver; | 716 // class AutoplayVisibilityObserver; |
| 733 Member<ElementVisibilityObserver> m_autoplayVisibilityObserver; | 717 Member<ElementVisibilityObserver> m_autoplayVisibilityObserver; |
| 734 | 718 |
| 735 static URLRegistry* s_mediaStreamRegistry; | 719 static URLRegistry* s_mediaStreamRegistry; |
| 736 }; | 720 }; |
| 737 | 721 |
| 738 inline bool isHTMLMediaElement(const HTMLElement& element) { | 722 inline bool isHTMLMediaElement(const HTMLElement& element) { |
| 739 return isHTMLAudioElement(element) || isHTMLVideoElement(element); | 723 return isHTMLAudioElement(element) || isHTMLVideoElement(element); |
| 740 } | 724 } |
| 741 | 725 |
| 742 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); | 726 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); |
| 743 | 727 |
| 744 } // namespace blink | 728 } // namespace blink |
| 745 | 729 |
| 746 #endif // HTMLMediaElement_h | 730 #endif // HTMLMediaElement_h |
| OLD | NEW |