nsIAppShell.idl 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2. *
  3. * This Source Code Form is subject to the terms of the Mozilla Public
  4. * License, v. 2.0. If a copy of the MPL was not distributed with this
  5. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  6. #include "nsISupports.idl"
  7. interface nsIRunnable;
  8. %{ C++
  9. template <class T> struct already_AddRefed;
  10. %}
  11. /**
  12. * Interface for the native event system layer. This interface is designed
  13. * to be used on the main application thread only.
  14. */
  15. [uuid(7cd5c71d-223b-4afe-931d-5eedb1f2b01f)]
  16. interface nsIAppShell : nsISupports
  17. {
  18. /**
  19. * Enter an event loop. Don't leave until exit() is called.
  20. */
  21. void run();
  22. /**
  23. * Exit the handle event loop
  24. */
  25. void exit();
  26. /**
  27. * Give hint to native event queue notification mechanism. If the native
  28. * platform needs to tradeoff performance vs. native event starvation this
  29. * hint tells the native dispatch code which to favor. The default is to
  30. * prevent native event starvation.
  31. *
  32. * Calls to this function may be nested. When the number of calls that pass
  33. * PR_TRUE is subtracted from the number of calls that pass PR_FALSE is
  34. * greater than 0, performance is given precedence over preventing event
  35. * starvation.
  36. *
  37. * The starvationDelay arg is only used when favorPerfOverStarvation is
  38. * PR_FALSE. It is the amount of time in milliseconds to wait before the
  39. * PR_FALSE actually takes effect.
  40. */
  41. void favorPerformanceHint(in boolean favorPerfOverStarvation,
  42. in unsigned long starvationDelay);
  43. /**
  44. * Suspends the use of additional platform-specific methods (besides the
  45. * nsIAppShell->run() event loop) to run Gecko events on the main
  46. * application thread. Under some circumstances these "additional methods"
  47. * can cause Gecko event handlers to be re-entered, sometimes leading to
  48. * hangs and crashes. Calls to suspendNative() and resumeNative() may be
  49. * nested. On some platforms (those that don't use any "additional
  50. * methods") this will be a no-op. Does not (in itself) stop Gecko events
  51. * from being processed on the main application thread. But if the
  52. * nsIAppShell->run() event loop is blocked when this call is made, Gecko
  53. * events will stop being processed until resumeNative() is called (even
  54. * if a plugin or library is temporarily processing events on a nested
  55. * event loop).
  56. */
  57. void suspendNative();
  58. /**
  59. * Resumes the use of additional platform-specific methods to run Gecko
  60. * events on the main application thread. Calls to suspendNative() and
  61. * resumeNative() may be nested. On some platforms this will be a no-op.
  62. */
  63. void resumeNative();
  64. /**
  65. * The current event loop nesting level.
  66. */
  67. readonly attribute unsigned long eventloopNestingLevel;
  68. };