1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/accessible/src/base/EventQueue.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,88 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#ifndef mozilla_a11y_EventQueue_h_ 1.10 +#define mozilla_a11y_EventQueue_h_ 1.11 + 1.12 +#include "AccEvent.h" 1.13 + 1.14 +namespace mozilla { 1.15 +namespace a11y { 1.16 + 1.17 +class DocAccessible; 1.18 + 1.19 +/** 1.20 + * Used to organize and coalesce pending events. 1.21 + */ 1.22 +class EventQueue 1.23 +{ 1.24 +protected: 1.25 + EventQueue(DocAccessible* aDocument) : mDocument(aDocument) { } 1.26 + 1.27 + /** 1.28 + * Put an accessible event into the queue to process it later. 1.29 + */ 1.30 + bool PushEvent(AccEvent* aEvent); 1.31 + 1.32 + /** 1.33 + * Process events from the queue and fires events. 1.34 + */ 1.35 + void ProcessEventQueue(); 1.36 + 1.37 +private: 1.38 + EventQueue(const EventQueue&) MOZ_DELETE; 1.39 + EventQueue& operator = (const EventQueue&) MOZ_DELETE; 1.40 + 1.41 + // Event queue processing 1.42 + /** 1.43 + * Coalesce redundant events from the queue. 1.44 + */ 1.45 + void CoalesceEvents(); 1.46 + 1.47 + /** 1.48 + * Coalesce events from the same subtree. 1.49 + */ 1.50 + void CoalesceReorderEvents(AccEvent* aTailEvent); 1.51 + 1.52 + /** 1.53 + * Coalesce two selection change events within the same select control. 1.54 + */ 1.55 + void CoalesceSelChangeEvents(AccSelChangeEvent* aTailEvent, 1.56 + AccSelChangeEvent* aThisEvent, 1.57 + uint32_t aThisIndex); 1.58 + 1.59 + /** 1.60 + * Coalesce text change events caused by sibling hide events. 1.61 + */ 1.62 + void CoalesceTextChangeEventsFor(AccHideEvent* aTailEvent, 1.63 + AccHideEvent* aThisEvent); 1.64 + void CoalesceTextChangeEventsFor(AccShowEvent* aTailEvent, 1.65 + AccShowEvent* aThisEvent); 1.66 + 1.67 + /** 1.68 + * Create text change event caused by hide or show event. When a node is 1.69 + * hidden/removed or shown/appended, the text in an ancestor hyper text will 1.70 + * lose or get new characters. 1.71 + */ 1.72 + void CreateTextChangeEventFor(AccMutationEvent* aEvent); 1.73 + 1.74 +protected: 1.75 + 1.76 + /** 1.77 + * The document accessible reference owning this queue. 1.78 + */ 1.79 + DocAccessible* mDocument; 1.80 + 1.81 + /** 1.82 + * Pending events array. Don't make this an nsAutoTArray; we use 1.83 + * SwapElements() on it. 1.84 + */ 1.85 + nsTArray<nsRefPtr<AccEvent> > mEvents; 1.86 +}; 1.87 + 1.88 +} // namespace a11y 1.89 +} // namespace mozilla 1.90 + 1.91 +#endif // mozilla_a11y_EventQueue_h_