1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/embedding/browser/webBrowser/nsIContextMenuListener2.idl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,121 @@ 1.4 +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "nsISupports.idl" 1.10 + 1.11 +interface nsIDOMEvent; 1.12 +interface nsIDOMNode; 1.13 +interface imgIContainer; 1.14 +interface nsIURI; 1.15 +interface nsIContextMenuInfo; 1.16 + 1.17 +/* THIS IS A PUBLIC EMBEDDING API */ 1.18 + 1.19 +/** 1.20 + * nsIContextMenuListener2 1.21 + * 1.22 + * This is an extended version of nsIContextMenuListener 1.23 + * It provides a helper class, nsIContextMenuInfo, to allow access to 1.24 + * background images as well as various utilities. 1.25 + * 1.26 + * @see nsIContextMenuListener 1.27 + * @see nsIContextMenuInfo 1.28 + */ 1.29 + 1.30 +[scriptable, uuid(7fb719b3-d804-4964-9596-77cf924ee314)] 1.31 +interface nsIContextMenuListener2 : nsISupports 1.32 +{ 1.33 + /** Flag. No context. */ 1.34 + const unsigned long CONTEXT_NONE = 0; 1.35 + /** Flag. Context is a link element. */ 1.36 + const unsigned long CONTEXT_LINK = 1; 1.37 + /** Flag. Context is an image element. */ 1.38 + const unsigned long CONTEXT_IMAGE = 2; 1.39 + /** Flag. Context is the whole document. */ 1.40 + const unsigned long CONTEXT_DOCUMENT = 4; 1.41 + /** Flag. Context is a text area element. */ 1.42 + const unsigned long CONTEXT_TEXT = 8; 1.43 + /** Flag. Context is an input element. */ 1.44 + const unsigned long CONTEXT_INPUT = 16; 1.45 + /** Flag. Context is a background image. */ 1.46 + const unsigned long CONTEXT_BACKGROUND_IMAGE = 32; 1.47 + 1.48 + /** 1.49 + * Called when the browser receives a context menu event (e.g. user is right-mouse 1.50 + * clicking somewhere on the document). The combination of flags, along with the 1.51 + * attributes of <CODE>aUtils</CODE>, indicate where and what was clicked on. 1.52 + * 1.53 + * The following table describes what context flags and node combinations are 1.54 + * possible. 1.55 + * 1.56 + * aContextFlags aUtils.targetNode 1.57 + * 1.58 + * CONTEXT_LINK <A> 1.59 + * CONTEXT_IMAGE <IMG> 1.60 + * CONTEXT_IMAGE | CONTEXT_LINK <IMG> with <A> as an ancestor 1.61 + * CONTEXT_INPUT <INPUT> 1.62 + * CONTEXT_INPUT | CONTEXT_IMAGE <INPUT> with type=image 1.63 + * CONTEXT_TEXT <TEXTAREA> 1.64 + * CONTEXT_DOCUMENT <HTML> 1.65 + * CONTEXT_BACKGROUND_IMAGE <HTML> with background image 1.66 + * 1.67 + * @param aContextFlags Flags indicating the kind of context. 1.68 + * @param aUtils Context information and helper utilities. 1.69 + * 1.70 + * @see nsIContextMenuInfo 1.71 + */ 1.72 + void onShowContextMenu(in unsigned long aContextFlags, in nsIContextMenuInfo aUtils); 1.73 +}; 1.74 + 1.75 +/** 1.76 + * nsIContextMenuInfo 1.77 + * 1.78 + * A helper object for implementors of nsIContextMenuListener2. 1.79 + */ 1.80 + 1.81 +[scriptable, uuid(2f977d56-5485-11d4-87e2-0010a4e75ef2)] 1.82 +interface nsIContextMenuInfo : nsISupports 1.83 +{ 1.84 + /** 1.85 + * The DOM context menu event. 1.86 + */ 1.87 + readonly attribute nsIDOMEvent mouseEvent; 1.88 + 1.89 + /** 1.90 + * The DOM node most relevant to the context. 1.91 + */ 1.92 + readonly attribute nsIDOMNode targetNode; 1.93 + 1.94 + /** 1.95 + * Given the <CODE>CONTEXT_LINK</CODE> flag, <CODE>targetNode</CODE> may not 1.96 + * nescesarily be a link. This returns the anchor from <CODE>targetNode</CODE> 1.97 + * if it has one or that of its nearest ancestor if it does not. 1.98 + */ 1.99 + readonly attribute AString associatedLink; 1.100 + 1.101 + /** 1.102 + * Given the <CODE>CONTEXT_IMAGE</CODE> flag, these methods can be 1.103 + * used in order to get the image for viewing, saving, or for the clipboard. 1.104 + * 1.105 + * @return <CODE>NS_OK</CODE> if successful, otherwise <CODE>NS_ERROR_FAILURE</CODE> if no 1.106 + * image was found, or NS_ERROR_NULL_POINTER if an internal error occurs where we think there 1.107 + * is an image, but for some reason it cannot be returned. 1.108 + */ 1.109 + 1.110 + readonly attribute imgIContainer imageContainer; 1.111 + readonly attribute nsIURI imageSrc; 1.112 + 1.113 + /** 1.114 + * Given the <CODE>CONTEXT_BACKGROUND_IMAGE</CODE> flag, these methods can be 1.115 + * used in order to get the image for viewing, saving, or for the clipboard. 1.116 + * 1.117 + * @return <CODE>NS_OK</CODE> if successful, otherwise <CODE>NS_ERROR_FAILURE</CODE> if no background 1.118 + * image was found, or NS_ERROR_NULL_POINTER if an internal error occurs where we think there is a 1.119 + * background image, but for some reason it cannot be returned. 1.120 + */ 1.121 + 1.122 + readonly attribute imgIContainer backgroundImageContainer; 1.123 + readonly attribute nsIURI backgroundImageSrc; 1.124 +};