mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
bug 1172377 change RunInStableState API to receive ownership of nsIRunnable r=roc
This commit is contained in:
parent
dfec676114
commit
9314668ae3
@ -5162,9 +5162,7 @@ nsContentUtils::RunInStableState(already_AddRefed<nsIRunnable> aRunnable,
|
||||
MOZ_ASSERT(aHandling == DispatchFailureHandling::IgnoreFailure);
|
||||
return;
|
||||
}
|
||||
DebugOnly<nsresult> rv = appShell->RunInStableState(runnable);
|
||||
MOZ_ASSERT(NS_SUCCEEDED(rv) ||
|
||||
aHandling == DispatchFailureHandling::IgnoreFailure);
|
||||
appShell->RunInStableState(runnable.forget());
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -171,9 +171,9 @@ ScreenProxy::InvalidateCacheOnNextTick()
|
||||
|
||||
nsCOMPtr<nsIAppShell> appShell = do_GetService(kAppShellCID);
|
||||
if (appShell) {
|
||||
appShell->RunInStableState(
|
||||
NS_NewRunnableMethod(this, &ScreenProxy::InvalidateCache)
|
||||
);
|
||||
nsCOMPtr<nsIRunnable> r =
|
||||
NS_NewRunnableMethod(this, &ScreenProxy::InvalidateCache);
|
||||
appShell->RunInStableState(r.forget());
|
||||
} else {
|
||||
// It's pretty bad news if we can't get the appshell. In that case,
|
||||
// let's just invalidate the cache right away.
|
||||
|
@ -387,7 +387,8 @@ nsBaseAppShell::RunSyncSectionsInternal(bool aStable,
|
||||
}
|
||||
|
||||
void
|
||||
nsBaseAppShell::ScheduleSyncSection(nsIRunnable* aRunnable, bool aStable)
|
||||
nsBaseAppShell::ScheduleSyncSection(already_AddRefed<nsIRunnable> aRunnable,
|
||||
bool aStable)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
|
||||
|
||||
@ -444,16 +445,16 @@ nsBaseAppShell::Observe(nsISupports *subject, const char *topic,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseAppShell::RunInStableState(nsIRunnable* aRunnable)
|
||||
void
|
||||
nsBaseAppShell::RunInStableState(already_AddRefed<nsIRunnable> aRunnable)
|
||||
{
|
||||
ScheduleSyncSection(aRunnable, true);
|
||||
return NS_OK;
|
||||
ScheduleSyncSection(mozilla::Move(aRunnable), true);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBaseAppShell::RunBeforeNextEvent(nsIRunnable* aRunnable)
|
||||
{
|
||||
ScheduleSyncSection(aRunnable, false);
|
||||
nsCOMPtr<nsIRunnable> runnable = aRunnable;
|
||||
ScheduleSyncSection(runnable.forget(), false);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -25,6 +25,8 @@ class nsBaseAppShell : public nsIAppShell, public nsIThreadObserver,
|
||||
public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSIAPPSHELL
|
||||
void RunInStableState(already_AddRefed<nsIRunnable> runnable) override;
|
||||
|
||||
NS_DECL_NSITHREADOBSERVER
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
@ -94,7 +96,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
void ScheduleSyncSection(nsIRunnable* runnable, bool stable);
|
||||
void ScheduleSyncSection(already_AddRefed<nsIRunnable> runnable, bool stable);
|
||||
|
||||
struct SyncSection {
|
||||
SyncSection()
|
||||
|
@ -7,12 +7,15 @@
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIRunnable;
|
||||
%{ C++
|
||||
template <class T> struct already_AddRefed;
|
||||
%}
|
||||
|
||||
/**
|
||||
* Interface for the native event system layer. This interface is designed
|
||||
* to be used on the main application thread only.
|
||||
*/
|
||||
[uuid(2d10ca53-f143-439a-bb2e-c1fbc71f6a05)]
|
||||
[uuid(3d09973e-3975-4fd4-b103-276300cc8437)]
|
||||
interface nsIAppShell : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -71,16 +74,20 @@ interface nsIAppShell : nsISupports
|
||||
*/
|
||||
readonly attribute unsigned long eventloopNestingLevel;
|
||||
|
||||
%{ C++
|
||||
/**
|
||||
* 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:
|
||||
* Add a "synchronous section", in the form of an nsIRunnable run once the
|
||||
* event loop has reached a "stable state". |runnable| must not cause any
|
||||
* queued events to be processed (i.e. must not spin the event loop). 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.
|
||||
*/
|
||||
void runInStableState(in nsIRunnable runnable);
|
||||
virtual void RunInStableState(already_AddRefed<nsIRunnable> runnable) = 0;
|
||||
%}
|
||||
|
||||
/**
|
||||
* Run the given runnable before the next iteration of the event loop (this
|
||||
|
@ -200,9 +200,9 @@ nsScreenManagerProxy::InvalidateCacheOnNextTick()
|
||||
|
||||
nsCOMPtr<nsIAppShell> appShell = do_GetService(kAppShellCID);
|
||||
if (appShell) {
|
||||
appShell->RunInStableState(
|
||||
NS_NewRunnableMethod(this, &nsScreenManagerProxy::InvalidateCache)
|
||||
);
|
||||
nsCOMPtr<nsIRunnable> r =
|
||||
NS_NewRunnableMethod(this, &nsScreenManagerProxy::InvalidateCache);
|
||||
appShell->RunInStableState(r.forget());
|
||||
} else {
|
||||
// It's pretty bad news if we can't get the appshell. In that case,
|
||||
// let's just invalidate the cache right away.
|
||||
|
Loading…
Reference in New Issue
Block a user