michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_a11y_EventQueue_h_ michael@0: #define mozilla_a11y_EventQueue_h_ michael@0: michael@0: #include "AccEvent.h" michael@0: michael@0: namespace mozilla { michael@0: namespace a11y { michael@0: michael@0: class DocAccessible; michael@0: michael@0: /** michael@0: * Used to organize and coalesce pending events. michael@0: */ michael@0: class EventQueue michael@0: { michael@0: protected: michael@0: EventQueue(DocAccessible* aDocument) : mDocument(aDocument) { } michael@0: michael@0: /** michael@0: * Put an accessible event into the queue to process it later. michael@0: */ michael@0: bool PushEvent(AccEvent* aEvent); michael@0: michael@0: /** michael@0: * Process events from the queue and fires events. michael@0: */ michael@0: void ProcessEventQueue(); michael@0: michael@0: private: michael@0: EventQueue(const EventQueue&) MOZ_DELETE; michael@0: EventQueue& operator = (const EventQueue&) MOZ_DELETE; michael@0: michael@0: // Event queue processing michael@0: /** michael@0: * Coalesce redundant events from the queue. michael@0: */ michael@0: void CoalesceEvents(); michael@0: michael@0: /** michael@0: * Coalesce events from the same subtree. michael@0: */ michael@0: void CoalesceReorderEvents(AccEvent* aTailEvent); michael@0: michael@0: /** michael@0: * Coalesce two selection change events within the same select control. michael@0: */ michael@0: void CoalesceSelChangeEvents(AccSelChangeEvent* aTailEvent, michael@0: AccSelChangeEvent* aThisEvent, michael@0: uint32_t aThisIndex); michael@0: michael@0: /** michael@0: * Coalesce text change events caused by sibling hide events. michael@0: */ michael@0: void CoalesceTextChangeEventsFor(AccHideEvent* aTailEvent, michael@0: AccHideEvent* aThisEvent); michael@0: void CoalesceTextChangeEventsFor(AccShowEvent* aTailEvent, michael@0: AccShowEvent* aThisEvent); michael@0: michael@0: /** michael@0: * Create text change event caused by hide or show event. When a node is michael@0: * hidden/removed or shown/appended, the text in an ancestor hyper text will michael@0: * lose or get new characters. michael@0: */ michael@0: void CreateTextChangeEventFor(AccMutationEvent* aEvent); michael@0: michael@0: protected: michael@0: michael@0: /** michael@0: * The document accessible reference owning this queue. michael@0: */ michael@0: DocAccessible* mDocument; michael@0: michael@0: /** michael@0: * Pending events array. Don't make this an nsAutoTArray; we use michael@0: * SwapElements() on it. michael@0: */ michael@0: nsTArray > mEvents; michael@0: }; michael@0: michael@0: } // namespace a11y michael@0: } // namespace mozilla michael@0: michael@0: #endif // mozilla_a11y_EventQueue_h_