2016-04-07 16:30:22 +03:00
|
|
|
/* -*- 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_EventTree_h_
|
|
|
|
#define mozilla_a11y_EventTree_h_
|
|
|
|
|
|
|
|
#include "AccEvent.h"
|
2021-02-20 02:14:32 +03:00
|
|
|
#include "LocalAccessible.h"
|
2016-04-07 16:30:22 +03:00
|
|
|
|
2018-03-12 21:03:55 +03:00
|
|
|
#include "mozilla/a11y/DocAccessible.h"
|
2016-04-07 16:30:22 +03:00
|
|
|
#include "mozilla/RefPtr.h"
|
2016-06-29 13:57:00 +03:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2016-04-07 16:30:22 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace a11y {
|
|
|
|
|
2018-03-12 21:03:55 +03:00
|
|
|
class NotificationController;
|
|
|
|
|
2016-04-07 16:30:22 +03:00
|
|
|
/**
|
|
|
|
* This class makes sure required tasks are done before and after tree
|
|
|
|
* mutations. Currently this only includes group info invalidation. You must
|
|
|
|
* have an object of this class on the stack when calling methods that mutate
|
|
|
|
* the accessible tree.
|
|
|
|
*/
|
|
|
|
class TreeMutation final {
|
|
|
|
public:
|
|
|
|
static const bool kNoEvents = true;
|
|
|
|
static const bool kNoShutdown = true;
|
|
|
|
|
2021-02-20 02:14:32 +03:00
|
|
|
explicit TreeMutation(LocalAccessible* aParent, bool aNoEvents = false);
|
2016-04-07 16:30:22 +03:00
|
|
|
~TreeMutation();
|
|
|
|
|
2021-02-20 02:14:32 +03:00
|
|
|
void AfterInsertion(LocalAccessible* aChild);
|
|
|
|
void BeforeRemoval(LocalAccessible* aChild, bool aNoShutdown = false);
|
2016-04-07 16:30:22 +03:00
|
|
|
void Done();
|
|
|
|
|
|
|
|
private:
|
|
|
|
NotificationController* Controller() const {
|
|
|
|
return mParent->Document()->Controller();
|
|
|
|
}
|
|
|
|
|
|
|
|
static EventTree* const kNoEventTree;
|
|
|
|
|
2016-06-20 18:35:38 +03:00
|
|
|
#ifdef A11Y_LOG
|
2021-02-20 02:14:32 +03:00
|
|
|
static const char* PrefixLog(void* aData, LocalAccessible*);
|
2016-06-20 18:35:38 +03:00
|
|
|
#endif
|
|
|
|
|
2021-02-20 02:14:32 +03:00
|
|
|
LocalAccessible* mParent;
|
2016-04-07 16:30:22 +03:00
|
|
|
uint32_t mStartIdx;
|
|
|
|
uint32_t mStateFlagsCopy;
|
|
|
|
|
2016-09-05 21:52:12 +03:00
|
|
|
/*
|
|
|
|
* True if mutation events should be queued.
|
|
|
|
*/
|
|
|
|
bool mQueueEvents;
|
|
|
|
|
2016-04-07 16:30:22 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
bool mIsDone;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A mutation events coalescence structure.
|
|
|
|
*/
|
|
|
|
class EventTree final {
|
|
|
|
public:
|
|
|
|
EventTree()
|
2016-04-12 22:48:29 +03:00
|
|
|
: mFirst(nullptr),
|
|
|
|
mNext(nullptr),
|
|
|
|
mContainer(nullptr),
|
|
|
|
mFireReorder(false) {}
|
2021-02-20 02:14:32 +03:00
|
|
|
explicit EventTree(LocalAccessible* aContainer, bool aFireReorder)
|
2016-04-13 18:22:19 +03:00
|
|
|
: mFirst(nullptr),
|
|
|
|
mNext(nullptr),
|
|
|
|
mContainer(aContainer),
|
|
|
|
mFireReorder(aFireReorder) {}
|
2016-04-07 16:30:22 +03:00
|
|
|
~EventTree() { Clear(); }
|
|
|
|
|
2021-02-20 02:14:32 +03:00
|
|
|
void Shown(LocalAccessible* aTarget);
|
|
|
|
void Hidden(LocalAccessible*, bool);
|
2016-04-07 16:30:22 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return an event tree node for the given accessible.
|
|
|
|
*/
|
2021-02-20 02:14:32 +03:00
|
|
|
const EventTree* Find(const LocalAccessible* aContainer) const;
|
2016-04-07 16:30:22 +03:00
|
|
|
|
2016-09-05 23:09:28 +03:00
|
|
|
/**
|
|
|
|
* Add a mutation event to this event tree.
|
|
|
|
*/
|
|
|
|
void Mutated(AccMutationEvent* aEv);
|
|
|
|
|
2016-04-07 16:30:22 +03:00
|
|
|
#ifdef A11Y_LOG
|
|
|
|
void Log(uint32_t aLevel = UINT32_MAX) const;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* Processes the event queue and fires events.
|
|
|
|
*/
|
2016-05-19 21:35:20 +03:00
|
|
|
void Process(const RefPtr<DocAccessible>& aDeathGrip);
|
2016-04-07 16:30:22 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return an event subtree for the given accessible.
|
|
|
|
*/
|
2021-02-20 02:14:32 +03:00
|
|
|
EventTree* FindOrInsert(LocalAccessible* aContainer);
|
2016-04-07 16:30:22 +03:00
|
|
|
|
2016-04-12 22:48:29 +03:00
|
|
|
void Clear();
|
2016-04-07 16:30:22 +03:00
|
|
|
|
2016-06-29 13:57:00 +03:00
|
|
|
UniquePtr<EventTree> mFirst;
|
|
|
|
UniquePtr<EventTree> mNext;
|
2016-04-07 16:30:22 +03:00
|
|
|
|
2021-02-20 02:14:32 +03:00
|
|
|
LocalAccessible* mContainer;
|
2016-04-07 16:30:22 +03:00
|
|
|
nsTArray<RefPtr<AccMutationEvent>> mDependentEvents;
|
|
|
|
bool mFireReorder;
|
|
|
|
|
2021-02-20 02:14:32 +03:00
|
|
|
static NotificationController* Controller(LocalAccessible* aAcc) {
|
2016-09-29 22:44:18 +03:00
|
|
|
return aAcc->Document()->Controller();
|
|
|
|
}
|
|
|
|
|
2016-04-07 16:30:22 +03:00
|
|
|
friend class NotificationController;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace a11y
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_a11y_EventQueue_h_
|