mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1387168 - Use custom clipboard constructor instead of singleton. r=jrmuizel
This allows instances of the clipboard to be created (like it was pre-headless).
This commit is contained in:
parent
ce7bf90ba4
commit
d1dd2ea172
@ -36,8 +36,6 @@
|
||||
#include "nsIOutputStream.h"
|
||||
#include "nsEscape.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "HeadlessClipboard.h"
|
||||
#include "mozilla/ClearOnShutdown.h"
|
||||
|
||||
using mozilla::LogLevel;
|
||||
|
||||
@ -47,28 +45,6 @@ static mozilla::LazyLogModule gWin32ClipboardLog("nsClipboard");
|
||||
UINT nsClipboard::CF_HTML = ::RegisterClipboardFormatW(L"HTML Format");
|
||||
UINT nsClipboard::CF_CUSTOMTYPES = ::RegisterClipboardFormatW(L"application/x-moz-custom-clipdata");
|
||||
|
||||
namespace mozilla {
|
||||
namespace clipboard {
|
||||
StaticRefPtr<nsIClipboard> sInstance;
|
||||
}
|
||||
}
|
||||
/* static */ already_AddRefed<nsIClipboard>
|
||||
nsClipboard::GetInstance()
|
||||
{
|
||||
using namespace mozilla::clipboard;
|
||||
|
||||
if (!sInstance) {
|
||||
if (gfxPlatform::IsHeadless()) {
|
||||
sInstance = new widget::HeadlessClipboard();
|
||||
} else {
|
||||
sInstance = new nsClipboard();
|
||||
}
|
||||
ClearOnShutdown(&sInstance);
|
||||
}
|
||||
|
||||
RefPtr<nsIClipboard> service = sInstance.get();
|
||||
return service.forget();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
|
@ -33,8 +33,6 @@ public:
|
||||
// nsIObserver
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
static already_AddRefed<nsIClipboard> GetInstance();
|
||||
|
||||
// nsIClipboard
|
||||
NS_IMETHOD HasDataMatchingFlavors(const char** aFlavorList, uint32_t aLength,
|
||||
int32_t aWhichClipboard, bool *_retval) override;
|
||||
|
@ -35,6 +35,7 @@
|
||||
// Drag & Drop, Clipboard
|
||||
#include "nsClipboardHelper.h"
|
||||
#include "nsClipboard.h"
|
||||
#include "HeadlessClipboard.h"
|
||||
#include "nsBidiKeyboard.h"
|
||||
#include "nsDragService.h"
|
||||
#include "nsTransferable.h"
|
||||
@ -103,9 +104,25 @@ ColorPickerConstructor(nsISupports *aOuter, REFNSIID aIID,
|
||||
return picker->QueryInterface(aIID, aResult);
|
||||
}
|
||||
|
||||
static nsresult
|
||||
nsClipboardConstructor(nsISupports *aOuter, REFNSIID aIID,
|
||||
void **aResult)
|
||||
{
|
||||
*aResult = nullptr;
|
||||
if (aOuter != nullptr) {
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
}
|
||||
nsCOMPtr<nsIClipboard> inst;
|
||||
if (gfxPlatform::IsHeadless()) {
|
||||
inst = new HeadlessClipboard();
|
||||
} else {
|
||||
inst = new nsClipboard();
|
||||
}
|
||||
return inst->QueryInterface(aIID, aResult);
|
||||
}
|
||||
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(ScreenManager, ScreenManager::GetAddRefedSingleton)
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIdleServiceWin, nsIdleServiceWin::GetInstance)
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIClipboard, nsClipboard::GetInstance)
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsISound, nsSound::GetInstance)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(WinTaskbar)
|
||||
@ -177,7 +194,7 @@ static const mozilla::Module::CIDEntry kWidgetCIDs[] = {
|
||||
{ &kNS_GFXINFO_CID, false, nullptr, GfxInfoConstructor },
|
||||
{ &kNS_THEMERENDERER_CID, false, nullptr, NS_NewNativeTheme },
|
||||
{ &kNS_IDLE_SERVICE_CID, false, nullptr, nsIdleServiceWinConstructor },
|
||||
{ &kNS_CLIPBOARD_CID, false, nullptr, nsIClipboardConstructor, Module::MAIN_PROCESS_ONLY },
|
||||
{ &kNS_CLIPBOARD_CID, false, nullptr, nsClipboardConstructor, Module::MAIN_PROCESS_ONLY },
|
||||
{ &kNS_CLIPBOARDHELPER_CID, false, nullptr, nsClipboardHelperConstructor },
|
||||
{ &kNS_SOUND_CID, false, nullptr, nsISoundConstructor, Module::MAIN_PROCESS_ONLY },
|
||||
{ &kNS_TRANSFERABLE_CID, false, nullptr, nsTransferableConstructor },
|
||||
|
Loading…
Reference in New Issue
Block a user