|
1 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #include "nsISupports.idl" |
|
7 |
|
8 interface nsIDOMEvent; |
|
9 interface nsIDOMNode; |
|
10 interface imgIContainer; |
|
11 interface nsIURI; |
|
12 interface nsIContextMenuInfo; |
|
13 |
|
14 /* THIS IS A PUBLIC EMBEDDING API */ |
|
15 |
|
16 /** |
|
17 * nsIContextMenuListener2 |
|
18 * |
|
19 * This is an extended version of nsIContextMenuListener |
|
20 * It provides a helper class, nsIContextMenuInfo, to allow access to |
|
21 * background images as well as various utilities. |
|
22 * |
|
23 * @see nsIContextMenuListener |
|
24 * @see nsIContextMenuInfo |
|
25 */ |
|
26 |
|
27 [scriptable, uuid(7fb719b3-d804-4964-9596-77cf924ee314)] |
|
28 interface nsIContextMenuListener2 : nsISupports |
|
29 { |
|
30 /** Flag. No context. */ |
|
31 const unsigned long CONTEXT_NONE = 0; |
|
32 /** Flag. Context is a link element. */ |
|
33 const unsigned long CONTEXT_LINK = 1; |
|
34 /** Flag. Context is an image element. */ |
|
35 const unsigned long CONTEXT_IMAGE = 2; |
|
36 /** Flag. Context is the whole document. */ |
|
37 const unsigned long CONTEXT_DOCUMENT = 4; |
|
38 /** Flag. Context is a text area element. */ |
|
39 const unsigned long CONTEXT_TEXT = 8; |
|
40 /** Flag. Context is an input element. */ |
|
41 const unsigned long CONTEXT_INPUT = 16; |
|
42 /** Flag. Context is a background image. */ |
|
43 const unsigned long CONTEXT_BACKGROUND_IMAGE = 32; |
|
44 |
|
45 /** |
|
46 * Called when the browser receives a context menu event (e.g. user is right-mouse |
|
47 * clicking somewhere on the document). The combination of flags, along with the |
|
48 * attributes of <CODE>aUtils</CODE>, indicate where and what was clicked on. |
|
49 * |
|
50 * The following table describes what context flags and node combinations are |
|
51 * possible. |
|
52 * |
|
53 * aContextFlags aUtils.targetNode |
|
54 * |
|
55 * CONTEXT_LINK <A> |
|
56 * CONTEXT_IMAGE <IMG> |
|
57 * CONTEXT_IMAGE | CONTEXT_LINK <IMG> with <A> as an ancestor |
|
58 * CONTEXT_INPUT <INPUT> |
|
59 * CONTEXT_INPUT | CONTEXT_IMAGE <INPUT> with type=image |
|
60 * CONTEXT_TEXT <TEXTAREA> |
|
61 * CONTEXT_DOCUMENT <HTML> |
|
62 * CONTEXT_BACKGROUND_IMAGE <HTML> with background image |
|
63 * |
|
64 * @param aContextFlags Flags indicating the kind of context. |
|
65 * @param aUtils Context information and helper utilities. |
|
66 * |
|
67 * @see nsIContextMenuInfo |
|
68 */ |
|
69 void onShowContextMenu(in unsigned long aContextFlags, in nsIContextMenuInfo aUtils); |
|
70 }; |
|
71 |
|
72 /** |
|
73 * nsIContextMenuInfo |
|
74 * |
|
75 * A helper object for implementors of nsIContextMenuListener2. |
|
76 */ |
|
77 |
|
78 [scriptable, uuid(2f977d56-5485-11d4-87e2-0010a4e75ef2)] |
|
79 interface nsIContextMenuInfo : nsISupports |
|
80 { |
|
81 /** |
|
82 * The DOM context menu event. |
|
83 */ |
|
84 readonly attribute nsIDOMEvent mouseEvent; |
|
85 |
|
86 /** |
|
87 * The DOM node most relevant to the context. |
|
88 */ |
|
89 readonly attribute nsIDOMNode targetNode; |
|
90 |
|
91 /** |
|
92 * Given the <CODE>CONTEXT_LINK</CODE> flag, <CODE>targetNode</CODE> may not |
|
93 * nescesarily be a link. This returns the anchor from <CODE>targetNode</CODE> |
|
94 * if it has one or that of its nearest ancestor if it does not. |
|
95 */ |
|
96 readonly attribute AString associatedLink; |
|
97 |
|
98 /** |
|
99 * Given the <CODE>CONTEXT_IMAGE</CODE> flag, these methods can be |
|
100 * used in order to get the image for viewing, saving, or for the clipboard. |
|
101 * |
|
102 * @return <CODE>NS_OK</CODE> if successful, otherwise <CODE>NS_ERROR_FAILURE</CODE> if no |
|
103 * image was found, or NS_ERROR_NULL_POINTER if an internal error occurs where we think there |
|
104 * is an image, but for some reason it cannot be returned. |
|
105 */ |
|
106 |
|
107 readonly attribute imgIContainer imageContainer; |
|
108 readonly attribute nsIURI imageSrc; |
|
109 |
|
110 /** |
|
111 * Given the <CODE>CONTEXT_BACKGROUND_IMAGE</CODE> flag, these methods can be |
|
112 * used in order to get the image for viewing, saving, or for the clipboard. |
|
113 * |
|
114 * @return <CODE>NS_OK</CODE> if successful, otherwise <CODE>NS_ERROR_FAILURE</CODE> if no background |
|
115 * image was found, or NS_ERROR_NULL_POINTER if an internal error occurs where we think there is a |
|
116 * background image, but for some reason it cannot be returned. |
|
117 */ |
|
118 |
|
119 readonly attribute imgIContainer backgroundImageContainer; |
|
120 readonly attribute nsIURI backgroundImageSrc; |
|
121 }; |