Bug 1373739 - Hook HeadlessSound and HeadlessScreenHelper into Windows widgets. r?bdahl
MozReview-Commit-ID: 1KOlPyLmJaY
--- a/widget/windows/nsAppShell.cpp
+++ b/widget/windows/nsAppShell.cpp
@@ -21,16 +21,17 @@
#include "mozilla/StaticPtr.h"
#include "nsTHashtable.h"
#include "nsHashKeys.h"
#include "GeckoProfiler.h"
#include "nsComponentManagerUtils.h"
#include "nsINamed.h"
#include "nsITimer.h"
#include "ScreenHelperWin.h"
+#include "HeadlessScreenHelper.h"
#include "mozilla/widget/ScreenManager.h"
// These are two messages that the code in winspool.drv on Windows 7 explicitly
// waits for while it is pumping other Windows messages, during display of the
// Printer Properties dialog.
#define MOZ_WM_PRINTER_PROPERTIES_COMPLETION 0x5b7a
#define MOZ_WM_PRINTER_PROPERTIES_FAILURE 0x5b7f
@@ -247,18 +248,22 @@ nsAppShell::Init()
mEventWnd = CreateWindowW(kWindowClass, L"nsAppShell:EventWindow",
0, 0, 0, 10, 10, HWND_MESSAGE, nullptr, module,
nullptr);
NS_ENSURE_STATE(mEventWnd);
if (XRE_IsParentProcess()) {
ScreenManager& screenManager = ScreenManager::GetSingleton();
- screenManager.SetHelper(mozilla::MakeUnique<ScreenHelperWin>());
- ScreenHelperWin::RefreshScreens();
+ if (gfxPlatform::IsHeadless()) {
+ screenManager.SetHelper(mozilla::MakeUnique<HeadlessScreenHelper>());
+ } else {
+ screenManager.SetHelper(mozilla::MakeUnique<ScreenHelperWin>());
+ ScreenHelperWin::RefreshScreens();
+ }
}
return nsBaseAppShell::Init();
}
NS_IMETHODIMP
nsAppShell::Run(void)
{
--- a/widget/windows/nsSound.cpp
+++ b/widget/windows/nsSound.cpp
@@ -8,16 +8,17 @@
#include "plstr.h"
#include <stdio.h>
#include "nsString.h"
#include <windows.h>
// mmsystem.h is needed to build with WIN32_LEAN_AND_MEAN
#include <mmsystem.h>
+#include "HeadlessSound.h"
#include "nsSound.h"
#include "nsIURL.h"
#include "nsNetUtil.h"
#include "nsIChannel.h"
#include "nsContentUtils.h"
#include "nsCRT.h"
#include "nsIObserverService.h"
@@ -85,22 +86,26 @@ nsSoundPlayer::~nsSoundPlayer()
}
mozilla::StaticRefPtr<nsISound> nsSound::sInstance;
/* static */ already_AddRefed<nsISound>
nsSound::GetInstance()
{
if (!sInstance) {
- RefPtr<nsSound> sound = new nsSound();
- nsresult rv = sound->CreatePlayerThread();
- if(NS_WARN_IF(NS_FAILED(rv))) {
- return nullptr;
+ if (gfxPlatform::IsHeadless()) {
+ sInstance = new widget::HeadlessSound();
+ } else {
+ RefPtr<nsSound> sound = new nsSound();
+ nsresult rv = sound->CreatePlayerThread();
+ if(NS_WARN_IF(NS_FAILED(rv))) {
+ return nullptr;
+ }
+ sInstance = sound.forget();
}
- sInstance = sound.forget();
ClearOnShutdown(&sInstance);
}
RefPtr<nsISound> service = sInstance;
return service.forget();
}
#ifndef SND_PURGE