mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
2fb4a5340d
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
84 lines
2.0 KiB
C++
84 lines
2.0 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#ifndef mozilla_a11y_EventQueue_h_
|
|
#define mozilla_a11y_EventQueue_h_
|
|
|
|
#include "AccEvent.h"
|
|
#include "mozilla/Assertions.h"
|
|
|
|
namespace mozilla {
|
|
namespace a11y {
|
|
|
|
class DocAccessible;
|
|
|
|
/**
|
|
* Used to organize and coalesce pending events.
|
|
*/
|
|
class EventQueue {
|
|
protected:
|
|
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.
|
|
*/
|
|
bool PushEvent(AccEvent* aEvent);
|
|
|
|
/**
|
|
* Puts name and/or description change events into the queue, if needed.
|
|
*/
|
|
bool PushNameOrDescriptionChange(AccEvent* aOrigEvent);
|
|
|
|
/**
|
|
* Process events from the queue and fires events.
|
|
*/
|
|
void ProcessEventQueue();
|
|
|
|
private:
|
|
EventQueue(const EventQueue&) = delete;
|
|
EventQueue& operator=(const EventQueue&) = delete;
|
|
|
|
// Event queue processing
|
|
/**
|
|
* Coalesce redundant events from the queue.
|
|
*/
|
|
void CoalesceEvents();
|
|
|
|
/**
|
|
* Coalesce events from the same subtree.
|
|
*/
|
|
void CoalesceReorderEvents(AccEvent* aTailEvent);
|
|
|
|
/**
|
|
* Coalesce two selection change events within the same select control.
|
|
*/
|
|
void CoalesceSelChangeEvents(AccSelChangeEvent* aTailEvent,
|
|
AccSelChangeEvent* aThisEvent,
|
|
uint32_t aThisIndex);
|
|
|
|
protected:
|
|
/**
|
|
* The document accessible reference owning this queue.
|
|
*/
|
|
DocAccessible* mDocument;
|
|
|
|
/**
|
|
* Pending events array. Don't make this an AutoTArray; we use
|
|
* SwapElements() on it.
|
|
*/
|
|
nsTArray<RefPtr<AccEvent>> mEvents;
|
|
|
|
// Pending focus event.
|
|
RefPtr<AccEvent> mFocusEvent;
|
|
};
|
|
|
|
} // namespace a11y
|
|
} // namespace mozilla
|
|
|
|
#endif // mozilla_a11y_EventQueue_h_
|