content/base/public/nsCopySupport.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef nsCopySupport_h__
michael@0 7 #define nsCopySupport_h__
michael@0 8
michael@0 9 #include "nscore.h"
michael@0 10 #include "nsINode.h"
michael@0 11
michael@0 12 class nsISelection;
michael@0 13 class nsIDocument;
michael@0 14 class nsIImageLoadingContent;
michael@0 15 class nsIContent;
michael@0 16 class nsITransferable;
michael@0 17 class nsACString;
michael@0 18 class nsAString;
michael@0 19 class nsIPresShell;
michael@0 20 class nsILoadContext;
michael@0 21
michael@0 22 class nsCopySupport
michael@0 23 {
michael@0 24 // class of static helper functions for copy support
michael@0 25 public:
michael@0 26 static nsresult HTMLCopy(nsISelection *aSel, nsIDocument *aDoc, int16_t aClipboardID);
michael@0 27 static nsresult DoHooks(nsIDocument *aDoc, nsITransferable *aTrans,
michael@0 28 bool *aDoPutOnClipboard);
michael@0 29
michael@0 30 // Get the selection, or entire document, in the format specified by the mime type
michael@0 31 // (text/html or text/plain). If aSel is non-null, use it, otherwise get the entire
michael@0 32 // doc.
michael@0 33 static nsresult GetContents(const nsACString& aMimeType, uint32_t aFlags, nsISelection *aSel, nsIDocument *aDoc, nsAString& outdata);
michael@0 34
michael@0 35 static nsresult ImageCopy(nsIImageLoadingContent* aImageElement,
michael@0 36 nsILoadContext* aLoadContext,
michael@0 37 int32_t aCopyFlags);
michael@0 38
michael@0 39 // Get the selection as a transferable. Similar to HTMLCopy except does
michael@0 40 // not deal with the clipboard.
michael@0 41 static nsresult GetTransferableForSelection(nsISelection* aSelection,
michael@0 42 nsIDocument* aDocument,
michael@0 43 nsITransferable** aTransferable);
michael@0 44
michael@0 45 // Same as GetTransferableForSelection, but doesn't skip invisible content.
michael@0 46 static nsresult GetTransferableForNode(nsINode* aNode,
michael@0 47 nsIDocument* aDoc,
michael@0 48 nsITransferable** aTransferable);
michael@0 49 /**
michael@0 50 * Retrieve the selection for the given document. If the current focus
michael@0 51 * within the document has its own selection, aSelection will be set to it
michael@0 52 * and this focused content node returned. Otherwise, aSelection will be
michael@0 53 * set to the document's selection and null will be returned.
michael@0 54 */
michael@0 55 static nsIContent* GetSelectionForCopy(nsIDocument* aDocument,
michael@0 56 nsISelection** aSelection);
michael@0 57
michael@0 58 /**
michael@0 59 * Returns true if a copy operation is currently permitted based on the
michael@0 60 * current focus and selection within the specified document.
michael@0 61 */
michael@0 62 static bool CanCopy(nsIDocument* aDocument);
michael@0 63
michael@0 64 /**
michael@0 65 * Fires a cut, copy or paste event, on the given presshell, depending
michael@0 66 * on the value of aType, which should be either NS_CUT, NS_COPY or
michael@0 67 * NS_PASTE, and perform the default copy action if the event was not
michael@0 68 * cancelled.
michael@0 69 *
michael@0 70 * If aSelection is specified, then this selection is used as the target
michael@0 71 * of the operation. Otherwise, GetSelectionForCopy is used to retrieve
michael@0 72 * the current selection.
michael@0 73 *
michael@0 74 * This will fire a cut, copy or paste event at the node at the start
michael@0 75 * point of the selection. If a cut or copy event is not cancelled, the
michael@0 76 * selection is copied to the clipboard and true is returned. Paste events
michael@0 77 * have no default behaviour but true will be returned. It is expected
michael@0 78 * that the caller will execute any needed default paste behaviour. Also,
michael@0 79 * note that this method only copies text to the clipboard, the caller is
michael@0 80 * responsible for removing the content during a cut operation if true is
michael@0 81 * returned.
michael@0 82 *
michael@0 83 * aClipboardType specifies which clipboard to use, from nsIClipboard.
michael@0 84 *
michael@0 85 * If the event is cancelled or an error occurs, false will be returned.
michael@0 86 */
michael@0 87 static bool FireClipboardEvent(int32_t aType,
michael@0 88 int32_t aClipboardType,
michael@0 89 nsIPresShell* aPresShell,
michael@0 90 nsISelection* aSelection);
michael@0 91 };
michael@0 92
michael@0 93 #endif

mercurial