Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef mozilla_a11y_EventQueue_h_ |
michael@0 | 7 | #define mozilla_a11y_EventQueue_h_ |
michael@0 | 8 | |
michael@0 | 9 | #include "AccEvent.h" |
michael@0 | 10 | |
michael@0 | 11 | namespace mozilla { |
michael@0 | 12 | namespace a11y { |
michael@0 | 13 | |
michael@0 | 14 | class DocAccessible; |
michael@0 | 15 | |
michael@0 | 16 | /** |
michael@0 | 17 | * Used to organize and coalesce pending events. |
michael@0 | 18 | */ |
michael@0 | 19 | class EventQueue |
michael@0 | 20 | { |
michael@0 | 21 | protected: |
michael@0 | 22 | EventQueue(DocAccessible* aDocument) : mDocument(aDocument) { } |
michael@0 | 23 | |
michael@0 | 24 | /** |
michael@0 | 25 | * Put an accessible event into the queue to process it later. |
michael@0 | 26 | */ |
michael@0 | 27 | bool PushEvent(AccEvent* aEvent); |
michael@0 | 28 | |
michael@0 | 29 | /** |
michael@0 | 30 | * Process events from the queue and fires events. |
michael@0 | 31 | */ |
michael@0 | 32 | void ProcessEventQueue(); |
michael@0 | 33 | |
michael@0 | 34 | private: |
michael@0 | 35 | EventQueue(const EventQueue&) MOZ_DELETE; |
michael@0 | 36 | EventQueue& operator = (const EventQueue&) MOZ_DELETE; |
michael@0 | 37 | |
michael@0 | 38 | // Event queue processing |
michael@0 | 39 | /** |
michael@0 | 40 | * Coalesce redundant events from the queue. |
michael@0 | 41 | */ |
michael@0 | 42 | void CoalesceEvents(); |
michael@0 | 43 | |
michael@0 | 44 | /** |
michael@0 | 45 | * Coalesce events from the same subtree. |
michael@0 | 46 | */ |
michael@0 | 47 | void CoalesceReorderEvents(AccEvent* aTailEvent); |
michael@0 | 48 | |
michael@0 | 49 | /** |
michael@0 | 50 | * Coalesce two selection change events within the same select control. |
michael@0 | 51 | */ |
michael@0 | 52 | void CoalesceSelChangeEvents(AccSelChangeEvent* aTailEvent, |
michael@0 | 53 | AccSelChangeEvent* aThisEvent, |
michael@0 | 54 | uint32_t aThisIndex); |
michael@0 | 55 | |
michael@0 | 56 | /** |
michael@0 | 57 | * Coalesce text change events caused by sibling hide events. |
michael@0 | 58 | */ |
michael@0 | 59 | void CoalesceTextChangeEventsFor(AccHideEvent* aTailEvent, |
michael@0 | 60 | AccHideEvent* aThisEvent); |
michael@0 | 61 | void CoalesceTextChangeEventsFor(AccShowEvent* aTailEvent, |
michael@0 | 62 | AccShowEvent* aThisEvent); |
michael@0 | 63 | |
michael@0 | 64 | /** |
michael@0 | 65 | * Create text change event caused by hide or show event. When a node is |
michael@0 | 66 | * hidden/removed or shown/appended, the text in an ancestor hyper text will |
michael@0 | 67 | * lose or get new characters. |
michael@0 | 68 | */ |
michael@0 | 69 | void CreateTextChangeEventFor(AccMutationEvent* aEvent); |
michael@0 | 70 | |
michael@0 | 71 | protected: |
michael@0 | 72 | |
michael@0 | 73 | /** |
michael@0 | 74 | * The document accessible reference owning this queue. |
michael@0 | 75 | */ |
michael@0 | 76 | DocAccessible* mDocument; |
michael@0 | 77 | |
michael@0 | 78 | /** |
michael@0 | 79 | * Pending events array. Don't make this an nsAutoTArray; we use |
michael@0 | 80 | * SwapElements() on it. |
michael@0 | 81 | */ |
michael@0 | 82 | nsTArray<nsRefPtr<AccEvent> > mEvents; |
michael@0 | 83 | }; |
michael@0 | 84 | |
michael@0 | 85 | } // namespace a11y |
michael@0 | 86 | } // namespace mozilla |
michael@0 | 87 | |
michael@0 | 88 | #endif // mozilla_a11y_EventQueue_h_ |