зеркало из https://github.com/mozilla/gecko-dev.git
Bug 873683 - Make runBeforeNextEvent and runInStableState available off nsIDOMWindowUtils. r=bent
--HG-- extra : rebase_source : 4bafd49139375ef7ed7ef5a9a03dcf8c69af63aa
This commit is contained in:
Родитель
eb2f07591c
Коммит
3548d2447f
|
@ -72,12 +72,16 @@
|
|||
#include "nsViewportInfo.h"
|
||||
#include "nsIFormControl.h"
|
||||
#include "nsIScriptError.h"
|
||||
#include "nsIAppShell.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
using namespace mozilla::layers;
|
||||
using namespace mozilla::widget;
|
||||
|
||||
static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
|
||||
|
||||
DOMCI_DATA(WindowUtils, nsDOMWindowUtils)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsDOMWindowUtils)
|
||||
|
@ -3305,3 +3309,34 @@ nsDOMWindowUtils::DispatchEventToChromeOnly(nsIDOMEventTarget* aTarget,
|
|||
aTarget->DispatchEvent(aEvent, aRetVal);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWindowUtils::RunInStableState(nsIRunnable *runnable)
|
||||
{
|
||||
if (!nsContentUtils::IsCallerChrome()) {
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAppShell> appShell(do_GetService(kAppShellCID));
|
||||
if (!appShell) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
return appShell->RunInStableState(runnable);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWindowUtils::RunBeforeNextEvent(nsIRunnable *runnable)
|
||||
{
|
||||
if (!nsContentUtils::IsCallerChrome()) {
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAppShell> appShell(do_GetService(kAppShellCID));
|
||||
if (!appShell) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
return appShell->RunBeforeNextEvent(runnable);
|
||||
}
|
||||
|
||||
|
|
|
@ -40,8 +40,9 @@ interface nsIDOMTouch;
|
|||
interface nsIDOMClientRect;
|
||||
interface nsIURI;
|
||||
interface nsIDOMEventTarget;
|
||||
interface nsIRunnable;
|
||||
|
||||
[scriptable, uuid(04429978-3417-411b-882b-81cd5cec5ecd)]
|
||||
[scriptable, uuid(e57ba9cd-289e-46ba-9c3c-f9a1ddc690d8)]
|
||||
interface nsIDOMWindowUtils : nsISupports {
|
||||
|
||||
/**
|
||||
|
@ -1369,4 +1370,28 @@ interface nsIDOMWindowUtils : nsISupports {
|
|||
* Setting paintFlashing to true will flash newly painted area.
|
||||
*/
|
||||
attribute boolean paintFlashing;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* XXX - This can wreak havoc if you're not using this for very simple
|
||||
* purposes, eg testing or setting a flag.
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* XXX - This can wreak havoc if you're not using this for very simple
|
||||
* purposes, eg testing or setting a flag.
|
||||
*/
|
||||
void runBeforeNextEvent(in nsIRunnable runnable);
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче