Bug 1390748 - Pre-declare MediaDecoder in HTMLMediaElement. r=jwwang
I noticed that touching MediaDecoder rebuilds a lot of seemingly unrelated
code. This is because HTMLMediaElement includes MediaDecoder.h, and
HTMLMediaElement is included in a number of places. Having HTMLMediaElement.h
predeclare rather than include fixes it.
MozReview-Commit-ID: I0vrPgqvvge
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -17,17 +17,16 @@
#include "imgIContainer.h"
#include "imgINotificationObserver.h"
#include "imgLoader.h"
#include "imgRequestProxy.h"
#include "jsapi.h"
#include "jsfriendapi.h"
#include "js/Value.h"
#include "Layers.h"
-#include "MediaDecoder.h"
#include "nsAppRunner.h"
// nsNPAPIPluginInstance must be included before nsIDocument.h, which is included in mozAutoDocUpdate.h.
#include "nsNPAPIPluginInstance.h"
#include "gfxDrawable.h"
#include "gfxPrefs.h"
#include "ImageOps.h"
#include "mozAutoDocUpdate.h"
#include "mozilla/ArrayUtils.h"
@@ -43,17 +42,16 @@
#include "mozilla/dom/DocumentFragment.h"
#include "mozilla/dom/DOMException.h"
#include "mozilla/dom/DOMExceptionBinding.h"
#include "mozilla/dom/DOMTypes.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/FileSystemSecurity.h"
#include "mozilla/dom/FileBlobImpl.h"
#include "mozilla/dom/HTMLInputElement.h"
-#include "mozilla/dom/HTMLMediaElement.h"
#include "mozilla/dom/HTMLTemplateElement.h"
#include "mozilla/dom/HTMLContentElement.h"
#include "mozilla/dom/HTMLShadowElement.h"
#include "mozilla/dom/IPCBlobUtils.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/dom/TabParent.h"
#include "mozilla/dom/TouchEvent.h"
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -7148,16 +7148,27 @@ HTMLMediaElement::NextFrameStatus()
if (mDecoder) {
return mDecoder->NextFrameStatus();
} else if (mMediaStreamListener) {
return mMediaStreamListener->NextFrameStatus();
}
return NEXT_FRAME_UNINITIALIZED;
}
+
+void
+HTMLMediaElement::SetDecoder(MediaDecoder* aDecoder)
+{
+ MOZ_ASSERT(aDecoder); // Use ShutdownDecoder() to clear.
+ if (mDecoder) {
+ ShutdownDecoder();
+ }
+ mDecoder = aDecoder;
+}
+
float
HTMLMediaElement::ComputedVolume() const
{
return mMuted ? 0.0f : mAudioChannelWrapper ?
mAudioChannelWrapper->GetEffectiveVolume() : mVolume;
}
bool
--- a/dom/html/HTMLMediaElement.h
+++ b/dom/html/HTMLMediaElement.h
@@ -4,26 +4,27 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_HTMLMediaElement_h
#define mozilla_dom_HTMLMediaElement_h
#include "nsAutoPtr.h"
#include "nsIDOMHTMLMediaElement.h"
#include "nsGenericHTMLElement.h"
+#include "MediaEventSource.h"
+#include "SeekTarget.h"
#include "MediaDecoderOwner.h"
#include "nsCycleCollectionParticipant.h"
#include "nsIObserver.h"
#include "mozilla/CORSMode.h"
#include "DecoderTraits.h"
#include "nsIAudioChannelAgent.h"
#include "mozilla/Attributes.h"
#include "mozilla/dom/TextTrackManager.h"
#include "mozilla/WeakPtr.h"
-#include "MediaDecoder.h"
#include "mozilla/dom/MediaKeys.h"
#include "mozilla/StateWatching.h"
#include "nsGkAtoms.h"
#include "PrincipalChangeObserver.h"
#include "nsStubMutationObserver.h"
// X.h on Linux #defines CurrentTime as 0L, so we have to #undef it here.
#ifdef CurrentTime
@@ -44,16 +45,19 @@ typedef uint8_t AudibleState;
namespace mozilla {
class AbstractThread;
class ChannelMediaDecoder;
class DecoderDoctorDiagnostics;
class DOMMediaStream;
class ErrorResult;
class MediaResource;
class MediaDecoder;
+class MediaInputPort;
+class MediaStream;
+class MediaStreamGraph;
class VideoFrameContainer;
namespace dom {
class MediaKeys;
class TextTrack;
class TimeRanges;
class WakeLock;
class MediaTrack;
class MediaStreamTrack;
@@ -803,23 +807,17 @@ protected:
class MediaStreamTracksAvailableCallback;
class MediaStreamTrackListener;
class StreamListener;
class StreamSizeListener;
class ShutdownObserver;
MediaDecoderOwner::NextFrameStatus NextFrameStatus();
- void SetDecoder(MediaDecoder* aDecoder) {
- MOZ_ASSERT(aDecoder); // Use ShutdownDecoder() to clear.
- if (mDecoder) {
- ShutdownDecoder();
- }
- mDecoder = aDecoder;
- }
+ void SetDecoder(MediaDecoder* aDecoder);
class WakeLockBoolWrapper {
public:
explicit WakeLockBoolWrapper(bool val = false)
: mValue(val), mCanPlay(true), mOuter(nullptr) {}
~WakeLockBoolWrapper();
--- a/dom/html/HTMLVideoElement.h
+++ b/dom/html/HTMLVideoElement.h
@@ -6,16 +6,19 @@
#ifndef mozilla_dom_HTMLVideoElement_h
#define mozilla_dom_HTMLVideoElement_h
#include "mozilla/Attributes.h"
#include "mozilla/dom/HTMLMediaElement.h"
namespace mozilla {
+
+class FrameStatistics;
+
namespace dom {
class WakeLock;
class VideoPlaybackQuality;
class HTMLVideoElement final : public HTMLMediaElement
{
public:
--- a/dom/media/MediaResource.cpp
+++ b/dom/media/MediaResource.cpp
@@ -28,16 +28,17 @@
#include "nsError.h"
#include "nsICachingChannel.h"
#include "nsIAsyncVerifyRedirectCallback.h"
#include "nsContentUtils.h"
#include "nsHostObjectProtocolHandler.h"
#include <algorithm>
#include "nsProxyRelease.h"
#include "nsIContentPolicy.h"
+#include "mozilla/ErrorNames.h"
using mozilla::media::TimeUnit;
#undef LOG
#undef ILOG
mozilla::LazyLogModule gMediaResourceLog("MediaResource");
// Debug logging macro with object pointer and class name.