Follow-on fix for bug 457825. Use sheet principal for agent and user sheets. r=dbaron...
[wine-gecko.git] / content / events / public / nsIEventStateManager.h
blobbd1415c8a51b49c2e2cf9c989277244e8e686c2a
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
24 * Alternatively, the contents of this file may be used under the terms of
25 * either of the GNU General Public License Version 2 or later (the "GPL"),
26 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 #ifndef nsIEventStateManager_h__
39 #define nsIEventStateManager_h__
41 #include "nsEvent.h"
42 #include "nsISupports.h"
44 class nsIContent;
45 class nsPresContext;
46 class nsIDOMEvent;
47 class nsIFrame;
48 class nsIView;
49 class nsIWidget;
50 class imgIContainer;
53 * Event state manager interface.
55 // {fb7516ff-2f01-4893-84e8-e4b282813023}
56 #define NS_IEVENTSTATEMANAGER_IID \
57 { 0x522d12ec, 0xde51, 0x4635, \
58 { 0xb0, 0x10, 0x4, 0x2a, 0x6d, 0x5, 0xa0, 0x3e } }
60 #define NS_EVENT_NEEDS_FRAME(event) (!NS_IS_FOCUS_EVENT(event))
62 class nsIEventStateManager : public nsISupports {
64 public:
65 enum EFocusedWithType {
66 eEventFocusedByUnknown, // focus gained via unknown method
67 eEventFocusedByMouse, // focus gained via mouse
68 eEventFocusedByKey, // focus gained via key press (like tab)
69 eEventFocusedByContextMenu, // focus gained via context menu
70 eEventFocusedByApplication // focus gained via Application (like script)
73 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IEVENTSTATEMANAGER_IID)
75 NS_IMETHOD Init() = 0;
77 NS_IMETHOD PreHandleEvent(nsPresContext* aPresContext,
78 nsEvent *aEvent,
79 nsIFrame* aTargetFrame,
80 nsEventStatus* aStatus,
81 nsIView* aView) = 0;
83 NS_IMETHOD PostHandleEvent(nsPresContext* aPresContext,
84 nsEvent *aEvent,
85 nsIFrame* aTargetFrame,
86 nsEventStatus* aStatus,
87 nsIView* aView) = 0;
89 NS_IMETHOD SetPresContext(nsPresContext* aPresContext) = 0;
90 NS_IMETHOD ClearFrameRefs(nsIFrame* aFrame) = 0;
92 NS_IMETHOD GetEventTarget(nsIFrame **aFrame) = 0;
93 NS_IMETHOD GetEventTargetContent(nsEvent* aEvent, nsIContent** aContent) = 0;
95 NS_IMETHOD GetContentState(nsIContent *aContent, PRInt32& aState) = 0;
97 /**
98 * Notify that the given NS_EVENT_STATE_* bit has changed for this content.
99 * @param aContent Content which has changed states
100 * @param aState Corresponding state flags such as NS_EVENT_STATE_FOCUS
101 * defined in the nsIEventStateManager interface
102 * @return Whether the content was able to change all states. Returns PR_FALSE
103 * if a resulting DOM event causes the content node passed in
104 * to not change states. Note, the frame for the content may
105 * change as a result of the content state change, because of
106 * frame reconstructions that may occur, but this does not
107 * affect the return value.
109 virtual PRBool SetContentState(nsIContent *aContent, PRInt32 aState) = 0;
111 NS_IMETHOD GetFocusedContent(nsIContent **aContent) = 0;
112 NS_IMETHOD SetFocusedContent(nsIContent* aContent) = 0;
114 // Get the previously-focused content node for this document
115 NS_IMETHOD GetLastFocusedContent(nsIContent **aContent) = 0;
117 NS_IMETHOD GetFocusedFrame(nsIFrame **aFrame) = 0;
119 NS_IMETHOD ContentRemoved(nsIContent* aContent) = 0;
120 NS_IMETHOD EventStatusOK(nsGUIEvent* aEvent, PRBool *aOK) = 0;
122 // Return whether browse with caret is enabled or not
123 virtual PRBool GetBrowseWithCaret() = 0;
125 // This is called after find text or when a cursor movement key is pressed
126 // If aCanFocusDoc == PR_TRUE, the current document will be focused if caret is not on a focusable element
127 NS_IMETHOD MoveFocusToCaret(PRBool aCanFocusDoc, PRBool *aIsSelectionWithFocus) = 0;
128 NS_IMETHOD MoveCaretToFocus() = 0;
130 // Set focus on any element that can receive focus, or on document via aFocusContent == nsnull
131 // Must supply method that focus is being set with
132 NS_IMETHOD ChangeFocusWith(nsIContent *aFocusContent, EFocusedWithType aFocusedWith) = 0;
134 // Access Key Registration
137 * Register accesskey on the given element. When accesskey is activated then
138 * the element will be notified via nsIContent::PerformAccesskey() method.
140 * @param aContent the given element
141 * @param aKey accesskey
143 NS_IMETHOD RegisterAccessKey(nsIContent* aContent, PRUint32 aKey) = 0;
146 * Unregister accesskey for the given element.
148 * @param aContent the given element
149 * @param aKey accesskey
151 NS_IMETHOD UnregisterAccessKey(nsIContent* aContent, PRUint32 aKey) = 0;
154 * Get accesskey registered on the given element or 0 if there is none.
156 * @param aContent the given element
157 * @param aKey registered accesskey
158 * @return NS_OK
160 NS_IMETHOD GetRegisteredAccessKey(nsIContent* aContent, PRUint32* aKey) = 0;
162 NS_IMETHOD SetCursor(PRInt32 aCursor, imgIContainer* aContainer,
163 PRBool aHaveHotspot, float aHotspotX, float aHotspotY,
164 nsIWidget* aWidget, PRBool aLockCursor) = 0;
166 // Method for moving the focus forward/back.
167 NS_IMETHOD ShiftFocus(PRBool aDirection, nsIContent* aStart)=0;
169 NS_IMETHOD NotifyDestroyPresContext(nsPresContext* aPresContext) = 0;
172 * Returns true if the current code is being executed as a result of user input.
173 * This includes timers or anything else that is initiated from user input.
174 * However, mouse hover events are not counted as user input, nor are
175 * page load events. If this method is called from asynchronously executed code,
176 * such as during layout reflows, it will return false.
178 NS_IMETHOD_(PRBool) IsHandlingUserInputExternal() = 0;
181 NS_DEFINE_STATIC_IID_ACCESSOR(nsIEventStateManager, NS_IEVENTSTATEMANAGER_IID)
183 #define NS_EVENT_STATE_ACTIVE 0x00000001 // mouse is down on content
184 #define NS_EVENT_STATE_FOCUS 0x00000002 // content has focus
185 #define NS_EVENT_STATE_HOVER 0x00000004 // mouse is hovering over content
186 #define NS_EVENT_STATE_DRAGOVER 0x00000008 // drag is hovering over content
187 #define NS_EVENT_STATE_URLTARGET 0x00000010 // content is URL's target (ref)
189 // The following states are used only for ContentStatesChanged
191 #define NS_EVENT_STATE_CHECKED 0x00000020 // CSS3-Selectors
192 #define NS_EVENT_STATE_ENABLED 0x00000040 // CSS3-Selectors
193 #define NS_EVENT_STATE_DISABLED 0x00000080 // CSS3-Selectors
194 #define NS_EVENT_STATE_REQUIRED 0x00000100 // CSS3-UI
195 #define NS_EVENT_STATE_OPTIONAL 0x00000200 // CSS3-UI
196 #define NS_EVENT_STATE_VISITED 0x00000400 // CSS2
197 #define NS_EVENT_STATE_VALID 0x00000800 // CSS3-UI
198 #define NS_EVENT_STATE_INVALID 0x00001000 // CSS3-UI
199 #define NS_EVENT_STATE_INRANGE 0x00002000 // CSS3-UI
200 #define NS_EVENT_STATE_OUTOFRANGE 0x00004000 // CSS3-UI
201 // these two are temporary (see bug 302188)
202 #define NS_EVENT_STATE_MOZ_READONLY 0x00008000 // CSS3-UI
203 #define NS_EVENT_STATE_MOZ_READWRITE 0x00010000 // CSS3-UI
204 #define NS_EVENT_STATE_DEFAULT 0x00020000 // CSS3-UI
206 // Content could not be rendered (image/object/etc).
207 #define NS_EVENT_STATE_BROKEN 0x00040000
208 // Content disabled by the user (images turned off, say)
209 #define NS_EVENT_STATE_USERDISABLED 0x00080000
210 // Content suppressed by the user (ad blocking, etc)
211 #define NS_EVENT_STATE_SUPPRESSED 0x00100000
212 // Content is still loading such that there is nothing to show the
213 // user (eg an image which hasn't started coming in yet)
214 #define NS_EVENT_STATE_LOADING 0x00200000
215 // Content is of a type that gecko can't handle
216 #define NS_EVENT_STATE_TYPE_UNSUPPORTED \
217 0x00400000
218 #ifdef MOZ_MATHML
219 #define NS_EVENT_STATE_INCREMENT_SCRIPT_LEVEL 0x00800000
220 #endif
221 // Handler for the content has been blocked
222 #define NS_EVENT_STATE_HANDLER_BLOCKED \
223 0x01000000
224 // Handler for the content has been disabled
225 #define NS_EVENT_STATE_HANDLER_DISABLED \
226 0x02000000
228 #endif // nsIEventStateManager_h__