mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Bug 1320753 - Stop using already_AddRefed for EventTargetFor (r=ehsan)
MozReview-Commit-ID: ECy1jlQ7qne
This commit is contained in:
parent
e4426ae30f
commit
12ee63dc2d
@ -29,11 +29,11 @@ DispatcherTrait::Dispatch(const char* aName,
|
||||
}
|
||||
}
|
||||
|
||||
already_AddRefed<nsIEventTarget>
|
||||
nsIEventTarget*
|
||||
DispatcherTrait::EventTargetFor(TaskCategory aCategory) const
|
||||
{
|
||||
nsCOMPtr<nsIEventTarget> main = do_GetMainThread();
|
||||
return main.forget();
|
||||
return main;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
@ -56,8 +56,7 @@ public:
|
||||
// This method may or may not be safe off of the main thread. For nsIDocument
|
||||
// it is safe. For nsIGlobalWindow it is not safe. The nsIEventTarget can
|
||||
// always be used off the main thread.
|
||||
virtual already_AddRefed<nsIEventTarget>
|
||||
EventTargetFor(TaskCategory aCategory) const;
|
||||
virtual nsIEventTarget* EventTargetFor(TaskCategory aCategory) const;
|
||||
};
|
||||
|
||||
// Base class for DocGroup and TabGroup.
|
||||
@ -70,8 +69,7 @@ public:
|
||||
|
||||
// This method is always safe to call off the main thread. The nsIEventTarget
|
||||
// can always be used off the main thread.
|
||||
virtual already_AddRefed<nsIEventTarget>
|
||||
EventTargetFor(TaskCategory aCategory) const = 0;
|
||||
virtual nsIEventTarget* EventTargetFor(TaskCategory aCategory) const = 0;
|
||||
|
||||
// These methods perform a safe cast. They return null if |this| is not of the
|
||||
// requested type.
|
||||
|
@ -63,7 +63,7 @@ DocGroup::Dispatch(const char* aName,
|
||||
return mTabGroup->Dispatch(aName, aCategory, Move(aRunnable));
|
||||
}
|
||||
|
||||
already_AddRefed<nsIEventTarget>
|
||||
nsIEventTarget*
|
||||
DocGroup::EventTargetFor(TaskCategory aCategory) const
|
||||
{
|
||||
return mTabGroup->EventTargetFor(aCategory);
|
||||
|
@ -69,8 +69,7 @@ public:
|
||||
TaskCategory aCategory,
|
||||
already_AddRefed<nsIRunnable>&& aRunnable) override;
|
||||
|
||||
virtual already_AddRefed<nsIEventTarget>
|
||||
EventTargetFor(TaskCategory aCategory) const override;
|
||||
virtual nsIEventTarget* EventTargetFor(TaskCategory aCategory) const override;
|
||||
|
||||
private:
|
||||
DocGroup(TabGroup* aTabGroup, const nsACString& aKey);
|
||||
|
@ -255,12 +255,11 @@ TabGroup::Dispatch(const char* aName,
|
||||
}
|
||||
}
|
||||
|
||||
already_AddRefed<nsIEventTarget>
|
||||
nsIEventTarget*
|
||||
TabGroup::EventTargetFor(TaskCategory aCategory) const
|
||||
{
|
||||
MOZ_RELEASE_ASSERT(!mLastWindowLeft);
|
||||
nsCOMPtr<nsIEventTarget> target = mEventTargets[size_t(aCategory)];
|
||||
return target.forget();
|
||||
return mEventTargets[size_t(aCategory)];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "nsTHashtable.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#include "mozilla/Atomics.h"
|
||||
#include "mozilla/dom/Dispatcher.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
|
||||
@ -114,12 +115,14 @@ public:
|
||||
ThrottledEventQueue*
|
||||
GetThrottledEventQueue() const;
|
||||
|
||||
// This method is always safe to call off the main thread.
|
||||
virtual nsresult Dispatch(const char* aName,
|
||||
TaskCategory aCategory,
|
||||
already_AddRefed<nsIRunnable>&& aRunnable) override;
|
||||
|
||||
virtual already_AddRefed<nsIEventTarget>
|
||||
EventTargetFor(TaskCategory aCategory) const override;
|
||||
// This method is always safe to call off the main thread. The nsIEventTarget
|
||||
// can always be used off the main thread.
|
||||
virtual nsIEventTarget* EventTargetFor(TaskCategory aCategory) const override;
|
||||
|
||||
TabGroup* AsTabGroup() override { return this; }
|
||||
|
||||
@ -128,7 +131,7 @@ private:
|
||||
|
||||
~TabGroup();
|
||||
DocGroupMap mDocGroups;
|
||||
bool mLastWindowLeft;
|
||||
Atomic<bool> mLastWindowLeft;
|
||||
nsTArray<nsPIDOMWindowOuter*> mWindows;
|
||||
bool mThrottledQueuesInitialized;
|
||||
RefPtr<ThrottledEventQueue> mThrottledEventQueue;
|
||||
|
@ -2891,7 +2891,7 @@ nsIDocument::Dispatch(const char* aName,
|
||||
return DispatcherTrait::Dispatch(aName, aCategory, Move(aRunnable));
|
||||
}
|
||||
|
||||
already_AddRefed<nsIEventTarget>
|
||||
nsIEventTarget*
|
||||
nsIDocument::EventTargetFor(TaskCategory aCategory) const
|
||||
{
|
||||
if (mDocGroup) {
|
||||
|
@ -14266,7 +14266,7 @@ nsGlobalWindow::Dispatch(const char* aName,
|
||||
return DispatcherTrait::Dispatch(aName, aCategory, Move(aRunnable));
|
||||
}
|
||||
|
||||
already_AddRefed<nsIEventTarget>
|
||||
nsIEventTarget*
|
||||
nsGlobalWindow::EventTargetFor(TaskCategory aCategory) const
|
||||
{
|
||||
MOZ_RELEASE_ASSERT(NS_IsMainThread());
|
||||
|
@ -1770,7 +1770,7 @@ public:
|
||||
mozilla::dom::TaskCategory aCategory,
|
||||
already_AddRefed<nsIRunnable>&& aRunnable) override;
|
||||
|
||||
virtual already_AddRefed<nsIEventTarget>
|
||||
virtual nsIEventTarget*
|
||||
EventTargetFor(mozilla::dom::TaskCategory aCategory) const override;
|
||||
|
||||
protected:
|
||||
|
@ -2872,7 +2872,7 @@ public:
|
||||
mozilla::dom::TaskCategory aCategory,
|
||||
already_AddRefed<nsIRunnable>&& aRunnable) override;
|
||||
|
||||
virtual already_AddRefed<nsIEventTarget>
|
||||
virtual nsIEventTarget*
|
||||
EventTargetFor(mozilla::dom::TaskCategory aCategory) const override;
|
||||
|
||||
// The URLs passed to these functions should match what
|
||||
|
Loading…
Reference in New Issue
Block a user