mirror of
https://github.com/roytam1/UXP.git
synced 2026-05-26 05:38:39 +00:00
Issue #1587 - Part 8: Remove controller follow/unfollow
Since it didn't end up being in the final spec after all.
This commit is contained in:
@@ -12,8 +12,7 @@
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(AbortController, mGlobal, mSignal,
|
||||
mFollowingSignal)
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(AbortController, mGlobal, mSignal)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(AbortController)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(AbortController)
|
||||
@@ -95,33 +94,5 @@ AbortController::Abort()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AbortController::Follow(AbortSignal& aSignal)
|
||||
{
|
||||
AbortSignal::Follower::Follow(&aSignal);
|
||||
}
|
||||
|
||||
void
|
||||
AbortController::Unfollow(AbortSignal& aSignal)
|
||||
{
|
||||
if (mFollowingSignal != &aSignal) {
|
||||
return;
|
||||
}
|
||||
|
||||
AbortSignal::Follower::Unfollow();
|
||||
}
|
||||
|
||||
AbortSignal*
|
||||
AbortController::Following() const
|
||||
{
|
||||
return mFollowingSignal;
|
||||
}
|
||||
|
||||
void
|
||||
AbortController::Aborted()
|
||||
{
|
||||
Abort();
|
||||
}
|
||||
|
||||
} // dom namespace
|
||||
} // mozilla namespace
|
||||
|
||||
@@ -19,7 +19,6 @@ namespace dom {
|
||||
|
||||
class AbortController final : public nsISupports
|
||||
, public nsWrapperCache
|
||||
, public AbortSignal::Follower
|
||||
{
|
||||
public:
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
@@ -45,19 +44,6 @@ public:
|
||||
void
|
||||
Abort();
|
||||
|
||||
void
|
||||
Follow(AbortSignal& aSignal);
|
||||
|
||||
void
|
||||
Unfollow(AbortSignal& aSignal);
|
||||
|
||||
AbortSignal*
|
||||
Following() const;
|
||||
|
||||
// AbortSignal::Follower
|
||||
|
||||
void Aborted() override;
|
||||
|
||||
private:
|
||||
~AbortController() = default;
|
||||
|
||||
|
||||
@@ -68,8 +68,6 @@ AbortSignal::Abort()
|
||||
init.mBubbles = false;
|
||||
init.mCancelable = false;
|
||||
|
||||
// TODO which kind of event should we dispatch here?
|
||||
|
||||
RefPtr<Event> event =
|
||||
Event::Constructor(this, NS_LITERAL_STRING("abort"), init);
|
||||
event->SetTrusted(true);
|
||||
@@ -94,27 +92,6 @@ AbortSignal::RemoveFollower(AbortSignal::Follower* aFollower)
|
||||
mFollowers.RemoveElement(aFollower);
|
||||
}
|
||||
|
||||
bool
|
||||
AbortSignal::CanAcceptFollower(AbortSignal::Follower* aFollower) const
|
||||
{
|
||||
MOZ_DIAGNOSTIC_ASSERT(aFollower);
|
||||
|
||||
if (!mController) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (aFollower == mController) {
|
||||
return false;
|
||||
}
|
||||
|
||||
AbortSignal* following = mController->Following();
|
||||
if (!following) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return following->CanAcceptFollower(aFollower);
|
||||
}
|
||||
|
||||
// AbortSignal::Follower
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
@@ -128,10 +105,6 @@ AbortSignal::Follower::Follow(AbortSignal* aSignal)
|
||||
{
|
||||
MOZ_DIAGNOSTIC_ASSERT(aSignal);
|
||||
|
||||
if (!aSignal->CanAcceptFollower(this)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Unfollow();
|
||||
|
||||
mFollowingSignal = aSignal;
|
||||
|
||||
@@ -59,9 +59,6 @@ public:
|
||||
void
|
||||
RemoveFollower(Follower* aFollower);
|
||||
|
||||
bool
|
||||
CanAcceptFollower(Follower* aFollower) const;
|
||||
|
||||
private:
|
||||
~AbortSignal() = default;
|
||||
|
||||
|
||||
@@ -32,49 +32,6 @@ function testUpdateData() {
|
||||
next();
|
||||
}
|
||||
|
||||
function testFollowingOurself() {
|
||||
// Let's follow ourself
|
||||
var fc = new FetchController();
|
||||
fc.follow(fc.signal);
|
||||
|
||||
fc.abort();
|
||||
is(fc.signal.aborted, true, "Signal is aborted");
|
||||
|
||||
next();
|
||||
}
|
||||
|
||||
function testFollowingOther() {
|
||||
// Let's follow another one
|
||||
var fc1 = new FetchController();
|
||||
var fc2 = new FetchController();
|
||||
fc1.follow(fc2.signal);
|
||||
|
||||
fc2.abort();
|
||||
|
||||
is(fc1.signal.aborted, true, "Signal is aborted");
|
||||
is(fc2.signal.aborted, true, "Signal is aborted");
|
||||
|
||||
next();
|
||||
}
|
||||
|
||||
function testFollowingLoop() {
|
||||
// fc1 -> fc2 -> fc3 -> fc1
|
||||
var fc1 = new FetchController();
|
||||
var fc2 = new FetchController();
|
||||
var fc3 = new FetchController();
|
||||
fc1.follow(fc2.signal);
|
||||
fc2.follow(fc3.signal);
|
||||
fc3.follow(fc1.signal);
|
||||
|
||||
fc3.abort();
|
||||
|
||||
is(fc1.signal.aborted, true, "Signal is aborted");
|
||||
is(fc2.signal.aborted, true, "Signal is aborted");
|
||||
is(fc3.signal.aborted, true, "Signal is aborted");
|
||||
|
||||
next();
|
||||
}
|
||||
|
||||
function testAbortEvent() {
|
||||
var fc = new FetchController();
|
||||
fc.signal.onabort = function(e) {
|
||||
@@ -131,11 +88,6 @@ var steps = [
|
||||
testWebIDL,
|
||||
testUpdateData,
|
||||
|
||||
// Following algorithm
|
||||
testFollowingOurself,
|
||||
testFollowingOther,
|
||||
testFollowingLoop,
|
||||
|
||||
// Event propagation
|
||||
testAbortEvent,
|
||||
|
||||
|
||||
@@ -10,6 +10,4 @@ interface AbortController {
|
||||
readonly attribute AbortSignal signal;
|
||||
|
||||
void abort();
|
||||
void follow(AbortSignal signal);
|
||||
void unfollow(AbortSignal signal);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user