mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 1261299 - Add sSelectionTransferable and to get the current selection (chrome/content) needed for the OSX service menu. r=mstange
MozReview-Commit-ID: 4n5clge2tr8 *** Bug 1261299 - Add sSelectionTransferable and use in e10s to get the content selection needed for the OSX service menu. MozReview-Commit-ID: HbZ7S4HfFtn --HG-- extra : rebase_source : 6a520189d735c0c900e08d474ed838a68afbb4f8
This commit is contained in:
parent
6c6d5a3ec1
commit
7c6ec2835f
@ -8,6 +8,7 @@
|
||||
|
||||
#include "nsBaseClipboard.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@ -25,6 +26,11 @@ public:
|
||||
int32_t aWhichClipboard, bool *_retval);
|
||||
NS_IMETHOD SupportsFindClipboard(bool *_retval);
|
||||
|
||||
// On macOS, cache the transferable of the current selection (chrome/content)
|
||||
// in the parent process. This is needed for the services menu which
|
||||
// requires synchronous access to the current selection.
|
||||
static mozilla::StaticRefPtr<nsITransferable> sSelectionCache;
|
||||
|
||||
// Helper methods, used also by nsDragService
|
||||
static NSDictionary* PasteboardDictFromTransferable(nsITransferable *aTransferable);
|
||||
static bool IsStringType(const nsCString& aMIMEType, NSString** aPasteboardType);
|
||||
@ -36,6 +42,7 @@ protected:
|
||||
// impelement the native clipboard behavior
|
||||
NS_IMETHOD SetNativeClipboardData(int32_t aWhichClipboard);
|
||||
NS_IMETHOD GetNativeClipboardData(nsITransferable * aTransferable, int32_t aWhichClipboard);
|
||||
void SetSelectionCache(nsITransferable* aTransferable);
|
||||
|
||||
private:
|
||||
int32_t mCachedClipboard;
|
||||
|
@ -35,6 +35,8 @@ extern PRLogModuleInfo* sCocoaLog;
|
||||
|
||||
extern void EnsureLogInitialized();
|
||||
|
||||
mozilla::StaticRefPtr<nsITransferable> nsClipboard::sSelectionCache;
|
||||
|
||||
nsClipboard::nsClipboard() : nsBaseClipboard()
|
||||
{
|
||||
mCachedClipboard = -1;
|
||||
@ -45,6 +47,7 @@ nsClipboard::nsClipboard() : nsBaseClipboard()
|
||||
|
||||
nsClipboard::~nsClipboard()
|
||||
{
|
||||
sSelectionCache = nullptr;
|
||||
}
|
||||
|
||||
// We separate this into its own function because after an @try, all local
|
||||
@ -64,6 +67,12 @@ GetDataFromPasteboard(NSPasteboard* aPasteboard, NSString* aType)
|
||||
return data;
|
||||
}
|
||||
|
||||
void
|
||||
nsClipboard::SetSelectionCache(nsITransferable *aTransferable)
|
||||
{
|
||||
sSelectionCache = aTransferable;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsClipboard::SetNativeClipboardData(int32_t aWhichClipboard)
|
||||
{
|
||||
|
@ -34,6 +34,14 @@ NS_IMETHODIMP nsBaseClipboard::SetData(nsITransferable * aTransferable, nsIClipb
|
||||
{
|
||||
NS_ASSERTION ( aTransferable, "clipboard given a null transferable" );
|
||||
|
||||
if (aWhichClipboard == kSelectionCache) {
|
||||
if (aTransferable) {
|
||||
SetSelectionCache(aTransferable);
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if (aTransferable == mTransferable && anOwner == mClipboardOwner)
|
||||
return NS_OK;
|
||||
bool selectClipPresent;
|
||||
|
@ -34,6 +34,7 @@ protected:
|
||||
|
||||
NS_IMETHOD SetNativeClipboardData ( int32_t aWhichClipboard ) = 0;
|
||||
NS_IMETHOD GetNativeClipboardData ( nsITransferable * aTransferable, int32_t aWhichClipboard ) = 0;
|
||||
virtual void SetSelectionCache (nsITransferable* aTransferable) = 0;
|
||||
|
||||
bool mEmptyingForSetData;
|
||||
bool mIgnoreEmptyNotification;
|
||||
|
Loading…
Reference in New Issue
Block a user