Chromium Code Reviews| 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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 296 double effectiveMediaVolume() const; | 295 double effectiveMediaVolume() const; |
| 297 | 296 |
| 298 // Predicates also used when dispatching wrapper creation (cf. | 297 // Predicates also used when dispatching wrapper creation (cf. |
| 299 // [SpecialWrapFor] IDL attribute usage.) | 298 // [SpecialWrapFor] IDL attribute usage.) |
| 300 virtual bool isHTMLAudioElement() const { return false; } | 299 virtual bool isHTMLAudioElement() const { return false; } |
| 301 virtual bool isHTMLVideoElement() const { return false; } | 300 virtual bool isHTMLVideoElement() const { return false; } |
| 302 | 301 |
| 303 void videoWillBeDrawnToCanvas() const; | 302 void videoWillBeDrawnToCanvas() const; |
| 304 | 303 |
| 305 // Temporary callback for crbug.com/487345,402044 | 304 // Temporary callback for crbug.com/487345,402044 |
| 306 void notifyPositionMayHaveChanged(const IntRect&); | 305 // |
| 307 void updatePositionNotificationRegistration(); | 306 // TODO(zqzhang): remove these callbacks and related plumbing in layout code |
|
foolip
2016/11/23 12:40:55
Can you clean this up now or send a CL based on th
Zhiqiang Zhang (Slow)
2016/11/23 18:27:34
Done.
| |
| 307 // as AutoplayExperimentHelper is deprecated. See https://crbug.com/666370 | |
| 308 void notifyPositionMayHaveChanged(const IntRect&) {} | |
| 309 void updatePositionNotificationRegistration() {} | |
| 308 | 310 |
| 309 WebRemotePlaybackClient* remotePlaybackClient() { | 311 WebRemotePlaybackClient* remotePlaybackClient() { |
| 310 return m_remotePlaybackClient; | 312 return m_remotePlaybackClient; |
| 311 } | 313 } |
| 312 const WebRemotePlaybackClient* remotePlaybackClient() const { | 314 const WebRemotePlaybackClient* remotePlaybackClient() const { |
| 313 return m_remotePlaybackClient; | 315 return m_remotePlaybackClient; |
| 314 } | 316 } |
| 315 | 317 |
| 316 protected: | 318 protected: |
| 317 HTMLMediaElement(const QualifiedName&, Document&); | 319 HTMLMediaElement(const QualifiedName&, Document&); |
| 318 ~HTMLMediaElement() override; | 320 ~HTMLMediaElement() override; |
| 319 void dispose(); | 321 void dispose(); |
| 320 | 322 |
| 321 void parseAttribute(const QualifiedName&, | 323 void parseAttribute(const QualifiedName&, |
| 322 const AtomicString&, | 324 const AtomicString&, |
| 323 const AtomicString&) override; | 325 const AtomicString&) override; |
| 324 void finishParsingChildren() final; | 326 void finishParsingChildren() final; |
| 325 bool isURLAttribute(const Attribute&) const override; | 327 bool isURLAttribute(const Attribute&) const override; |
| 326 void attachLayoutTree(const AttachContext& = AttachContext()) override; | 328 void attachLayoutTree(const AttachContext& = AttachContext()) override; |
| 327 | 329 |
| 328 void didMoveToNewDocument(Document& oldDocument) override; | 330 void didMoveToNewDocument(Document& oldDocument) override; |
| 329 virtual KURL posterImageURL() const { return KURL(); } | 331 virtual KURL posterImageURL() const { return KURL(); } |
| 330 | 332 |
| 331 enum DisplayMode { Unknown, Poster, Video }; | 333 enum DisplayMode { Unknown, Poster, Video }; |
| 332 DisplayMode getDisplayMode() const { return m_displayMode; } | 334 DisplayMode getDisplayMode() const { return m_displayMode; } |
| 333 virtual void setDisplayMode(DisplayMode mode) { m_displayMode = mode; } | 335 virtual void setDisplayMode(DisplayMode mode) { m_displayMode = mode; } |
| 334 | 336 |
| 335 void recordAutoplayMetric(AutoplayMetrics); | |
| 336 | |
| 337 private: | 337 private: |
| 338 void resetMediaPlayerAndMediaSource(); | 338 void resetMediaPlayerAndMediaSource(); |
| 339 | 339 |
| 340 bool alwaysCreateUserAgentShadowRoot() const final { return true; } | 340 bool alwaysCreateUserAgentShadowRoot() const final { return true; } |
| 341 bool areAuthorShadowsAllowed() const final { return false; } | 341 bool areAuthorShadowsAllowed() const final { return false; } |
| 342 | 342 |
| 343 bool supportsFocus() const final; | 343 bool supportsFocus() const final; |
| 344 bool isMouseFocusable() const final; | 344 bool isMouseFocusable() const final; |
| 345 bool layoutObjectIsNeeded(const ComputedStyle&) override; | 345 bool layoutObjectIsNeeded(const ComputedStyle&) override; |
| 346 LayoutObject* createLayoutObject(const ComputedStyle&) override; | 346 LayoutObject* createLayoutObject(const ComputedStyle&) override; |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 523 bool isGestureNeededForPlayback() const; | 523 bool isGestureNeededForPlayback() const; |
| 524 | 524 |
| 525 // Return true if and only if the settings allow autoplay of media on this | 525 // Return true if and only if the settings allow autoplay of media on this |
| 526 // frame. | 526 // frame. |
| 527 bool isAutoplayAllowedPerSettings() const; | 527 bool isAutoplayAllowedPerSettings() const; |
| 528 | 528 |
| 529 void setNetworkState(NetworkState); | 529 void setNetworkState(NetworkState); |
| 530 | 530 |
| 531 void audioTracksTimerFired(TimerBase*); | 531 void audioTracksTimerFired(TimerBase*); |
| 532 | 532 |
| 533 // TODO(liberato): remove once autoplay gesture override experiment concludes. | |
| 534 void triggerAutoplayViewportCheckForTesting(); | |
| 535 | |
| 536 void scheduleResolvePlayPromises(); | 533 void scheduleResolvePlayPromises(); |
| 537 void scheduleRejectPlayPromises(ExceptionCode); | 534 void scheduleRejectPlayPromises(ExceptionCode); |
| 538 void scheduleNotifyPlaying(); | 535 void scheduleNotifyPlaying(); |
| 539 void resolveScheduledPlayPromises(); | 536 void resolveScheduledPlayPromises(); |
| 540 void rejectScheduledPlayPromises(); | 537 void rejectScheduledPlayPromises(); |
| 541 void rejectPlayPromises(ExceptionCode, const String&); | 538 void rejectPlayPromises(ExceptionCode, const String&); |
| 542 void rejectPlayPromisesInternal(ExceptionCode, const String&); | 539 void rejectPlayPromisesInternal(ExceptionCode, const String&); |
| 543 | 540 |
| 544 EnumerationHistogram& showControlsHistogram() const; | 541 EnumerationHistogram& showControlsHistogram() const; |
| 545 | 542 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 708 DECLARE_TRACE(); | 705 DECLARE_TRACE(); |
| 709 | 706 |
| 710 private: | 707 private: |
| 711 WebAudioSourceProvider* m_webAudioSourceProvider; | 708 WebAudioSourceProvider* m_webAudioSourceProvider; |
| 712 Member<AudioClientImpl> m_client; | 709 Member<AudioClientImpl> m_client; |
| 713 Mutex provideInputLock; | 710 Mutex provideInputLock; |
| 714 }; | 711 }; |
| 715 | 712 |
| 716 AudioSourceProviderImpl m_audioSourceProvider; | 713 AudioSourceProviderImpl m_audioSourceProvider; |
| 717 | 714 |
| 718 class AutoplayHelperClientImpl; | |
| 719 | |
| 720 friend class AutoplayUmaHelper; // for isAutoplayAllowedPerSettings | 715 friend class AutoplayUmaHelper; // for isAutoplayAllowedPerSettings |
| 721 friend class Internals; | 716 friend class Internals; |
| 722 friend class TrackDisplayUpdateScope; | 717 friend class TrackDisplayUpdateScope; |
| 723 friend class AutoplayExperimentHelper; | |
| 724 friend class MediaControlsTest; | 718 friend class MediaControlsTest; |
| 725 | 719 |
| 726 Member<AutoplayExperimentHelper::Client> m_autoplayHelperClient; | |
| 727 Member<AutoplayExperimentHelper> m_autoplayHelper; | |
| 728 Member<AutoplayUmaHelper> m_autoplayUmaHelper; | 720 Member<AutoplayUmaHelper> m_autoplayUmaHelper; |
| 729 | 721 |
| 730 WebRemotePlaybackClient* m_remotePlaybackClient; | 722 WebRemotePlaybackClient* m_remotePlaybackClient; |
| 731 | 723 |
| 732 // class AutoplayVisibilityObserver; | 724 // class AutoplayVisibilityObserver; |
| 733 Member<ElementVisibilityObserver> m_autoplayVisibilityObserver; | 725 Member<ElementVisibilityObserver> m_autoplayVisibilityObserver; |
| 734 | 726 |
| 735 static URLRegistry* s_mediaStreamRegistry; | 727 static URLRegistry* s_mediaStreamRegistry; |
| 736 }; | 728 }; |
| 737 | 729 |
| 738 inline bool isHTMLMediaElement(const HTMLElement& element) { | 730 inline bool isHTMLMediaElement(const HTMLElement& element) { |
| 739 return isHTMLAudioElement(element) || isHTMLVideoElement(element); | 731 return isHTMLAudioElement(element) || isHTMLVideoElement(element); |
| 740 } | 732 } |
| 741 | 733 |
| 742 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); | 734 DEFINE_HTMLELEMENT_TYPE_CASTS_WITH_FUNCTION(HTMLMediaElement); |
| 743 | 735 |
| 744 } // namespace blink | 736 } // namespace blink |
| 745 | 737 |
| 746 #endif // HTMLMediaElement_h | 738 #endif // HTMLMediaElement_h |
| OLD | NEW |