Bug 882339 - Cache the blocklist state on plugin tags to avoid querying the blocklist...
[gecko.git] / widget / nsIWidgetListener.h
blobd3d166536085a284104fea4c9ab17f9be708aab2
1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
14 * The Original Code is mozila.org code.
16 * The Initial Developer of the Original Code is Mozilla Foundation.
17 * Portions created by the Initial Developer are Copyright (C) 2011
18 * the Initial Developer. All Rights Reserved.
20 * Contributor(s):
22 * Alternatively, the contents of this file may be used under the terms of
23 * either the GNU General Public License Version 2 or later (the "GPL"), or
24 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
25 * in which case the provisions of the GPL or the LGPL are applicable instead
26 * of those above. If you wish to allow use of your version of this file only
27 * under the terms of either the GPL or the LGPL, and not to allow others to
28 * use your version of this file under the terms of the MPL, indicate your
29 * decision by deleting the provisions above and replace them with the notice
30 * and other provisions required by the GPL or the LGPL. If you do not delete
31 * the provisions above, a recipient may use your version of this file under
32 * the terms of any one of the MPL, the GPL or the LGPL.
34 * ***** END LICENSE BLOCK ***** */
36 #ifndef nsIWidgetListener_h__
37 #define nsIWidgetListener_h__
39 #include "nscore.h"
40 #include "nsGUIEvent.h"
41 #include "nsIXULWindow.h"
43 class nsView;
44 class nsIPresShell;
46 class nsIWidgetListener
48 public:
50 /**
51 * If this listener is for an nsIXULWindow, return it. If this is null, then
52 * this is likely a listener for a view, which can be determined using
53 * GetView. If both methods return null, this will be an nsWebBrowser.
55 virtual nsIXULWindow* GetXULWindow() { return nullptr; }
57 /**
58 * If this listener is for an nsView, return it.
60 virtual nsView* GetView() { return nullptr; }
62 /**
63 * Return the presshell for this widget listener.
65 virtual nsIPresShell* GetPresShell() { return nullptr; }
67 /**
68 * Called when a window is moved to location (x, y). Returns true if the
69 * notification was handled. Coordinates are outer window screen coordinates.
71 virtual bool WindowMoved(nsIWidget* aWidget, int32_t aX, int32_t aY) { return false; }
73 /**
74 * Called when a window is resized to (width, height). Returns true if the
75 * notification was handled. Coordinates are outer window screen coordinates.
77 virtual bool WindowResized(nsIWidget* aWidget, int32_t aWidth, int32_t aHeight) { return false; }
79 /**
80 * Called when the size mode (minimized, maximized, fullscreen) is changed.
82 virtual void SizeModeChanged(nsSizeMode sizeMode) { }
84 /**
85 * Called when the z-order of the window is changed. Returns true if the
86 * notification was handled. aPlacement indicates the new z order. If
87 * placement is nsWindowZRelative, then aRequestBelow should be the
88 * window to place below. On return, aActualBelow will be set to the
89 * window actually behind. This generally only applies to Windows.
91 virtual bool ZLevelChanged(bool aImmediate, nsWindowZ *aPlacement,
92 nsIWidget* aRequestBelow, nsIWidget** aActualBelow) { return false; }
94 /**
95 * Called when the window is activated and focused.
97 virtual void WindowActivated() { }
99 /**
100 * Called when the window is deactivated and no longer focused.
102 virtual void WindowDeactivated() { }
105 * Called when the show/hide toolbar button on the Mac titlebar is pressed.
107 virtual void OSToolbarButtonPressed() { }
110 * Called when a request is made to close the window. Returns true if the
111 * notification was handled. Returns true if the notification was handled.
113 virtual bool RequestWindowClose(nsIWidget* aWidget) { return false; }
116 * Indicate that a paint is about to occur on this window. This is called
117 * at a time when it's OK to change the geometry of this widget or of
118 * other widgets. Must be called before every call to PaintWindow.
120 virtual void WillPaintWindow(nsIWidget* aWidget) { }
123 * Paint the specified region of the window. Returns true if the
124 * notification was handled.
125 * This is called at a time when it is not OK to change the geometry of
126 * this widget or of other widgets.
128 virtual bool PaintWindow(nsIWidget* aWidget, nsIntRegion aRegion) { return false; }
131 * Indicates that a paint occurred.
132 * This is called at a time when it is OK to change the geometry of
133 * this widget or of other widgets.
134 * Must be called after every call to PaintWindow.
136 virtual void DidPaintWindow() { }
139 * Request that layout schedules a repaint on the next refresh driver tick.
141 virtual void RequestRepaint() { }
144 * Handle an event.
146 virtual nsEventStatus HandleEvent(nsGUIEvent* event, bool useAttachedEvents)
148 return nsEventStatus_eIgnore;
152 #endif