Bug 1867358 part 2: Assert that EventQueue's mDocument member is initialized to something non-null. r=eeejay

This patch is non-functional; it's just adding a debug-only assert, for
documentation and lightweight validation purposes.

As far as I can tell, the asserted condition must hold, since it looks like
this constructor is only invoked via this instantiation of the subclass, which
passes `this` as the aDocument arg (and `this` must trivially be non-null):
https://searchfox.org/mozilla-central/rev/12ea2c521cdd071a6d25b0894f31f8f23b18b76a/accessible/generic/DocAccessible.cpp#422

This assertion makes it easier to reason about the usages of this member-var.
There are lots of checks for whether mDocument is nullptr, and it's useful to
know that it'll always be non-null to begin with (though it becomes null
eventually, as part of teardown, when NotificationController::Shutdown is
called).

Differential Revision: https://phabricator.services.mozilla.com/D195041
This commit is contained in:
Daniel Holbert 2023-12-01 17:18:23 +00:00
Родитель 6bc34b0d8d
Коммит 2fb4a5340d
1 изменённых файлов: 5 добавлений и 1 удалений

Просмотреть файл

@ -7,6 +7,7 @@
#define mozilla_a11y_EventQueue_h_
#include "AccEvent.h"
#include "mozilla/Assertions.h"
namespace mozilla {
namespace a11y {
@ -18,7 +19,10 @@ class DocAccessible;
*/
class EventQueue {
protected:
explicit EventQueue(DocAccessible* aDocument) : mDocument(aDocument) {}
explicit EventQueue(DocAccessible* aDocument) : mDocument(aDocument) {
MOZ_ASSERT(mDocument,
"There's no point creating an event queue for a null document");
}
/**
* Put an accessible event into the queue to process it later.