Bug 1068811 - Make middle-mouse-click paste work in X11. r=billm

This commit is contained in:
Blake Kaplan 2014-10-20 18:42:40 -07:00
Родитель 0a433c81f2
Коммит c35784ec13
6 изменённых файлов: 56 добавлений и 11 удалений

Просмотреть файл

@ -79,6 +79,7 @@
#include "nsThreadManager.h"
#include "nsAnonymousTemporaryFile.h"
#include "nsISpellChecker.h"
#include "nsClipboardProxy.h"
#include "IHistory.h"
#include "nsNetUtil.h"
@ -717,9 +718,16 @@ ContentChild::InitXPCOM()
NS_WARNING("Couldn't register console listener for child process");
bool isOffline;
SendGetXPCOMProcessAttributes(&isOffline, &mAvailableDictionaries);
ClipboardCapabilities clipboardCaps;
SendGetXPCOMProcessAttributes(&isOffline, &mAvailableDictionaries, &clipboardCaps);
RecvSetOffline(isOffline);
nsCOMPtr<nsIClipboard> clipboard(do_GetService("@mozilla.org/widget/clipboard;1"));
MOZ_ASSERT(clipboard, "should have gotten a clipboard proxy");
auto clipboardProxy = static_cast<nsClipboardProxy *>(clipboard.get());
clipboardProxy->SetCapabilities(clipboardCaps);
DebugOnly<FileUpdateDispatcher*> observer = FileUpdateDispatcher::GetSingleton();
NS_ASSERTION(observer, "FileUpdateDispatcher is null");

Просмотреть файл

@ -2498,8 +2498,13 @@ ContentParent::RecvAddNewProcess(const uint32_t& aPid,
// Update offline settings.
bool isOffline;
InfallibleTArray<nsString> unusedDictionaries;
RecvGetXPCOMProcessAttributes(&isOffline, &unusedDictionaries);
ClipboardCapabilities clipboardCaps;
RecvGetXPCOMProcessAttributes(&isOffline, &unusedDictionaries,
&clipboardCaps);
content->SendSetOffline(isOffline);
MOZ_ASSERT(!clipboardCaps.supportsSelectionClipboard() &&
!clipboardCaps.supportsFindClipboard(),
"Unexpected values");
PreallocatedProcessManager::PublishSpareProcess(content);
return true;
@ -2747,7 +2752,8 @@ ContentParent::RecvGetProcessAttributes(uint64_t* aId,
bool
ContentParent::RecvGetXPCOMProcessAttributes(bool* aIsOffline,
InfallibleTArray<nsString>* dictionaries)
InfallibleTArray<nsString>* dictionaries,
ClipboardCapabilities* clipboardCaps)
{
nsCOMPtr<nsIIOService> io(do_GetIOService());
MOZ_ASSERT(io, "No IO service?");
@ -2759,6 +2765,15 @@ ContentParent::RecvGetXPCOMProcessAttributes(bool* aIsOffline,
spellChecker->GetDictionaryList(dictionaries);
nsCOMPtr<nsIClipboard> clipboard(do_GetService("@mozilla.org/widget/clipboard;1"));
MOZ_ASSERT(clipboard, "No clipboard?");
rv = clipboard->SupportsSelectionClipboard(&clipboardCaps->supportsSelectionClipboard());
MOZ_ASSERT(NS_SUCCEEDED(rv));
rv = clipboard->SupportsFindClipboard(&clipboardCaps->supportsFindClipboard());
MOZ_ASSERT(NS_SUCCEEDED(rv));
return true;
}

Просмотреть файл

@ -413,7 +413,8 @@ private:
bool* aIsForApp,
bool* aIsForBrowser) MOZ_OVERRIDE;
virtual bool RecvGetXPCOMProcessAttributes(bool* aIsOffline,
InfallibleTArray<nsString>* dictionaries)
InfallibleTArray<nsString>* dictionaries,
ClipboardCapabilities* clipboardCaps)
MOZ_OVERRIDE;
virtual bool DeallocPJavaScriptParent(mozilla::jsipc::PJavaScriptParent*) MOZ_OVERRIDE;

Просмотреть файл

@ -314,6 +314,11 @@ struct VolumeInfo {
bool isUnmounting;
};
struct ClipboardCapabilities {
bool supportsSelectionClipboard;
bool supportsFindClipboard;
};
union MaybeFileDesc {
FileDescriptor;
void_t;
@ -507,7 +512,8 @@ parent:
sync GetProcessAttributes()
returns (uint64_t id, bool isForApp, bool isForBrowser);
sync GetXPCOMProcessAttributes()
returns (bool isOffline, nsString[] dictionaries);
returns (bool isOffline, nsString[] dictionaries,
ClipboardCapabilities clipboardCaps);
sync CreateChildProcess(IPCTabContext context,
ProcessPriority priority)

Просмотреть файл

@ -10,17 +10,18 @@
#include "nsXULAppAPI.h"
using namespace mozilla;
using mozilla::dom::ContentChild;
using namespace mozilla::dom;
NS_IMPL_ISUPPORTS(nsClipboardProxy, nsIClipboard)
nsClipboardProxy::nsClipboardProxy()
: mClipboardCaps(false, false)
{
}
NS_IMETHODIMP
nsClipboardProxy::SetData(nsITransferable *aTransferable,
nsIClipboardOwner *anOwner, int32_t aWhichClipboard)
nsIClipboardOwner *anOwner, int32_t aWhichClipboard)
{
nsCOMPtr<nsISupports> tmp;
uint32_t len;
@ -36,7 +37,7 @@ nsClipboardProxy::SetData(nsITransferable *aTransferable,
bool isPrivateData = false;
aTransferable->GetIsPrivateData(&isPrivateData);
ContentChild::GetSingleton()->SendSetClipboardText(buffer, isPrivateData,
aWhichClipboard);
aWhichClipboard);
return NS_OK;
}
@ -87,7 +88,7 @@ nsClipboardProxy::HasDataMatchingFlavors(const char **aFlavorList,
NS_IMETHODIMP
nsClipboardProxy::SupportsSelectionClipboard(bool *aIsSupported)
{
*aIsSupported = false;
*aIsSupported = mClipboardCaps.supportsSelectionClipboard();
return NS_OK;
}
@ -95,6 +96,12 @@ nsClipboardProxy::SupportsSelectionClipboard(bool *aIsSupported)
NS_IMETHODIMP
nsClipboardProxy::SupportsFindClipboard(bool *aIsSupported)
{
*aIsSupported = false;
*aIsSupported = mClipboardCaps.supportsFindClipboard();
return NS_OK;
}
void
nsClipboardProxy::SetCapabilities(const ClipboardCapabilities& aClipboardCaps)
{
mClipboardCaps = aClipboardCaps;
}

Просмотреть файл

@ -7,16 +7,24 @@
#define NS_CLIPBOARD_PROXY_H
#include "nsIClipboard.h"
#include "mozilla/dom/PContent.h"
class nsClipboardProxy MOZ_FINAL : public nsIClipboard
{
~nsClipboardProxy() {}
typedef mozilla::dom::ClipboardCapabilities ClipboardCapabilities;
public:
NS_DECL_ISUPPORTS
NS_DECL_NSICLIPBOARD
nsClipboardProxy();
void SetCapabilities(const ClipboardCapabilities& aClipboardCaps);
private:
~nsClipboardProxy() {}
ClipboardCapabilities mClipboardCaps;
};
#endif