1999-10-01 12:19:08 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
2012-05-21 15:12:37 +04:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
1999-10-01 12:19:08 +04:00
|
|
|
|
|
|
|
#include "nsISupports.idl"
|
2012-04-07 00:40:10 +04:00
|
|
|
|
|
|
|
interface nsIRunnable;
|
1999-10-01 12:19:08 +04:00
|
|
|
|
|
|
|
/**
|
2006-05-10 21:30:15 +04:00
|
|
|
* Interface for the native event system layer. This interface is designed
|
|
|
|
* to be used on the main application thread only.
|
1999-10-01 12:19:08 +04:00
|
|
|
*/
|
2012-04-07 00:40:10 +04:00
|
|
|
[uuid(2d10ca53-f143-439a-bb2e-c1fbc71f6a05)]
|
1999-10-01 12:19:08 +04:00
|
|
|
interface nsIAppShell : nsISupports
|
|
|
|
{
|
2006-05-10 21:30:15 +04:00
|
|
|
/**
|
|
|
|
* Enter an event loop. Don't leave until exit() is called.
|
|
|
|
*/
|
|
|
|
void run();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Exit the handle event loop
|
|
|
|
*/
|
|
|
|
void exit();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Give hint to native event queue notification mechanism. If the native
|
|
|
|
* platform needs to tradeoff performance vs. native event starvation this
|
|
|
|
* hint tells the native dispatch code which to favor. The default is to
|
|
|
|
* prevent native event starvation.
|
|
|
|
*
|
|
|
|
* Calls to this function may be nested. When the number of calls that pass
|
|
|
|
* PR_TRUE is subtracted from the number of calls that pass PR_FALSE is
|
|
|
|
* greater than 0, performance is given precedence over preventing event
|
|
|
|
* starvation.
|
|
|
|
*
|
|
|
|
* The starvationDelay arg is only used when favorPerfOverStarvation is
|
|
|
|
* PR_FALSE. It is the amount of time in milliseconds to wait before the
|
|
|
|
* PR_FALSE actually takes effect.
|
|
|
|
*/
|
|
|
|
void favorPerformanceHint(in boolean favorPerfOverStarvation,
|
|
|
|
in unsigned long starvationDelay);
|
2007-03-23 02:04:51 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Suspends the use of additional platform-specific methods (besides the
|
|
|
|
* nsIAppShell->run() event loop) to run Gecko events on the main
|
|
|
|
* application thread. Under some circumstances these "additional methods"
|
|
|
|
* can cause Gecko event handlers to be re-entered, sometimes leading to
|
|
|
|
* hangs and crashes. Calls to suspendNative() and resumeNative() may be
|
|
|
|
* nested. On some platforms (those that don't use any "additional
|
|
|
|
* methods") this will be a no-op. Does not (in itself) stop Gecko events
|
|
|
|
* from being processed on the main application thread. But if the
|
|
|
|
* nsIAppShell->run() event loop is blocked when this call is made, Gecko
|
|
|
|
* events will stop being processed until resumeNative() is called (even
|
|
|
|
* if a plugin or library is temporarily processing events on a nested
|
|
|
|
* event loop).
|
|
|
|
*/
|
|
|
|
void suspendNative();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resumes the use of additional platform-specific methods to run Gecko
|
|
|
|
* events on the main application thread. Calls to suspendNative() and
|
|
|
|
* resumeNative() may be nested. On some platforms this will be a no-op.
|
|
|
|
*/
|
|
|
|
void resumeNative();
|
2008-03-25 19:56:04 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The current event loop nesting level.
|
|
|
|
*/
|
|
|
|
readonly attribute unsigned long eventloopNestingLevel;
|
2010-09-03 04:03:03 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Allows running of a "synchronous section", in the form of an nsIRunnable
|
|
|
|
* once the event loop has reached a "stable state". We've reached a stable
|
|
|
|
* state when the currently executing task/event has finished, see:
|
|
|
|
* http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#synchronous-section
|
|
|
|
* In practice this runs aRunnable once the currently executing event
|
|
|
|
* finishes. If called multiple times per task/event, all the runnables will
|
|
|
|
* be executed, in the order in which runInStableState() was called.
|
|
|
|
*/
|
2012-04-07 00:40:10 +04:00
|
|
|
void runInStableState(in nsIRunnable runnable);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Run the given runnable before the next iteration of the event loop (this
|
|
|
|
* includes native events too). If a nested loop is spawned within the current
|
|
|
|
* event then the runnable will not be run until that loop has terminated.
|
|
|
|
*/
|
|
|
|
void runBeforeNextEvent(in nsIRunnable runnable);
|
1999-10-01 12:19:08 +04:00
|
|
|
};
|