mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-22 15:17:29 +09: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:
parent
b988c351ff
commit
8ac3ccd67a
6 changed files with 1 additions and 124 deletions
|
|
@ -12,8 +12,7 @@
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace dom {
|
namespace dom {
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(AbortController, mGlobal, mSignal,
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(AbortController, mGlobal, mSignal)
|
||||||
mFollowingSignal)
|
|
||||||
|
|
||||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(AbortController)
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(AbortController)
|
||||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(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
|
} // dom namespace
|
||||||
} // mozilla namespace
|
} // mozilla namespace
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ namespace dom {
|
||||||
|
|
||||||
class AbortController final : public nsISupports
|
class AbortController final : public nsISupports
|
||||||
, public nsWrapperCache
|
, public nsWrapperCache
|
||||||
, public AbortSignal::Follower
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||||
|
|
@ -45,19 +44,6 @@ public:
|
||||||
void
|
void
|
||||||
Abort();
|
Abort();
|
||||||
|
|
||||||
void
|
|
||||||
Follow(AbortSignal& aSignal);
|
|
||||||
|
|
||||||
void
|
|
||||||
Unfollow(AbortSignal& aSignal);
|
|
||||||
|
|
||||||
AbortSignal*
|
|
||||||
Following() const;
|
|
||||||
|
|
||||||
// AbortSignal::Follower
|
|
||||||
|
|
||||||
void Aborted() override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
~AbortController() = default;
|
~AbortController() = default;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,8 +68,6 @@ AbortSignal::Abort()
|
||||||
init.mBubbles = false;
|
init.mBubbles = false;
|
||||||
init.mCancelable = false;
|
init.mCancelable = false;
|
||||||
|
|
||||||
// TODO which kind of event should we dispatch here?
|
|
||||||
|
|
||||||
RefPtr<Event> event =
|
RefPtr<Event> event =
|
||||||
Event::Constructor(this, NS_LITERAL_STRING("abort"), init);
|
Event::Constructor(this, NS_LITERAL_STRING("abort"), init);
|
||||||
event->SetTrusted(true);
|
event->SetTrusted(true);
|
||||||
|
|
@ -94,27 +92,6 @@ AbortSignal::RemoveFollower(AbortSignal::Follower* aFollower)
|
||||||
mFollowers.RemoveElement(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
|
// AbortSignal::Follower
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -128,10 +105,6 @@ AbortSignal::Follower::Follow(AbortSignal* aSignal)
|
||||||
{
|
{
|
||||||
MOZ_DIAGNOSTIC_ASSERT(aSignal);
|
MOZ_DIAGNOSTIC_ASSERT(aSignal);
|
||||||
|
|
||||||
if (!aSignal->CanAcceptFollower(this)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Unfollow();
|
Unfollow();
|
||||||
|
|
||||||
mFollowingSignal = aSignal;
|
mFollowingSignal = aSignal;
|
||||||
|
|
|
||||||
|
|
@ -59,9 +59,6 @@ public:
|
||||||
void
|
void
|
||||||
RemoveFollower(Follower* aFollower);
|
RemoveFollower(Follower* aFollower);
|
||||||
|
|
||||||
bool
|
|
||||||
CanAcceptFollower(Follower* aFollower) const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
~AbortSignal() = default;
|
~AbortSignal() = default;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,49 +32,6 @@ function testUpdateData() {
|
||||||
next();
|
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() {
|
function testAbortEvent() {
|
||||||
var fc = new FetchController();
|
var fc = new FetchController();
|
||||||
fc.signal.onabort = function(e) {
|
fc.signal.onabort = function(e) {
|
||||||
|
|
@ -131,11 +88,6 @@ var steps = [
|
||||||
testWebIDL,
|
testWebIDL,
|
||||||
testUpdateData,
|
testUpdateData,
|
||||||
|
|
||||||
// Following algorithm
|
|
||||||
testFollowingOurself,
|
|
||||||
testFollowingOther,
|
|
||||||
testFollowingLoop,
|
|
||||||
|
|
||||||
// Event propagation
|
// Event propagation
|
||||||
testAbortEvent,
|
testAbortEvent,
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,4 @@ interface AbortController {
|
||||||
readonly attribute AbortSignal signal;
|
readonly attribute AbortSignal signal;
|
||||||
|
|
||||||
void abort();
|
void abort();
|
||||||
void follow(AbortSignal signal);
|
|
||||||
void unfollow(AbortSignal signal);
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue