accessible/src/generic/DocAccessible-inl.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim: set ts=2 et sw=2 tw=80: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef mozilla_a11y_DocAccessible_inl_h_
michael@0 8 #define mozilla_a11y_DocAccessible_inl_h_
michael@0 9
michael@0 10 #include "DocAccessible.h"
michael@0 11 #include "nsAccessibilityService.h"
michael@0 12 #include "NotificationController.h"
michael@0 13 #include "States.h"
michael@0 14 #include "nsIScrollableFrame.h"
michael@0 15
michael@0 16 #ifdef A11Y_LOG
michael@0 17 #include "Logging.h"
michael@0 18 #endif
michael@0 19
michael@0 20 namespace mozilla {
michael@0 21 namespace a11y {
michael@0 22
michael@0 23 inline void
michael@0 24 DocAccessible::FireDelayedEvent(AccEvent* aEvent)
michael@0 25 {
michael@0 26 #ifdef A11Y_LOG
michael@0 27 if (logging::IsEnabled(logging::eDocLoad))
michael@0 28 logging::DocLoadEventFired(aEvent);
michael@0 29 #endif
michael@0 30
michael@0 31 mNotificationController->QueueEvent(aEvent);
michael@0 32 }
michael@0 33
michael@0 34 inline void
michael@0 35 DocAccessible::FireDelayedEvent(uint32_t aEventType, Accessible* aTarget)
michael@0 36 {
michael@0 37 nsRefPtr<AccEvent> event = new AccEvent(aEventType, aTarget);
michael@0 38 FireDelayedEvent(event);
michael@0 39 }
michael@0 40
michael@0 41 inline void
michael@0 42 DocAccessible::BindChildDocument(DocAccessible* aDocument)
michael@0 43 {
michael@0 44 mNotificationController->ScheduleChildDocBinding(aDocument);
michael@0 45 }
michael@0 46
michael@0 47 template<class Class, class Arg>
michael@0 48 inline void
michael@0 49 DocAccessible::HandleNotification(Class* aInstance,
michael@0 50 typename TNotification<Class, Arg>::Callback aMethod,
michael@0 51 Arg* aArg)
michael@0 52 {
michael@0 53 if (mNotificationController) {
michael@0 54 mNotificationController->HandleNotification<Class, Arg>(aInstance,
michael@0 55 aMethod, aArg);
michael@0 56 }
michael@0 57 }
michael@0 58
michael@0 59 inline void
michael@0 60 DocAccessible::UpdateText(nsIContent* aTextNode)
michael@0 61 {
michael@0 62 NS_ASSERTION(mNotificationController, "The document was shut down!");
michael@0 63
michael@0 64 // Ignore the notification if initial tree construction hasn't been done yet.
michael@0 65 if (mNotificationController && HasLoadState(eTreeConstructed))
michael@0 66 mNotificationController->ScheduleTextUpdate(aTextNode);
michael@0 67 }
michael@0 68
michael@0 69 inline void
michael@0 70 DocAccessible::AddScrollListener()
michael@0 71 {
michael@0 72 // Delay scroll initializing until the document has a root frame.
michael@0 73 if (!mPresShell->GetRootFrame())
michael@0 74 return;
michael@0 75
michael@0 76 mDocFlags |= eScrollInitialized;
michael@0 77 nsIScrollableFrame* sf = mPresShell->GetRootScrollFrameAsScrollable();
michael@0 78 if (sf) {
michael@0 79 sf->AddScrollPositionListener(this);
michael@0 80
michael@0 81 #ifdef A11Y_LOG
michael@0 82 if (logging::IsEnabled(logging::eDocCreate))
michael@0 83 logging::Text("add scroll listener");
michael@0 84 #endif
michael@0 85 }
michael@0 86 }
michael@0 87
michael@0 88 inline void
michael@0 89 DocAccessible::RemoveScrollListener()
michael@0 90 {
michael@0 91 nsIScrollableFrame* sf = mPresShell->GetRootScrollFrameAsScrollable();
michael@0 92 if (sf)
michael@0 93 sf->RemoveScrollPositionListener(this);
michael@0 94 }
michael@0 95
michael@0 96 inline void
michael@0 97 DocAccessible::NotifyOfLoad(uint32_t aLoadEventType)
michael@0 98 {
michael@0 99 mLoadState |= eDOMLoaded;
michael@0 100 mLoadEventType = aLoadEventType;
michael@0 101
michael@0 102 // If the document is loaded completely then network activity was presumingly
michael@0 103 // caused by file loading. Fire busy state change event.
michael@0 104 if (HasLoadState(eCompletelyLoaded) && IsLoadEventTarget()) {
michael@0 105 nsRefPtr<AccEvent> stateEvent =
michael@0 106 new AccStateChangeEvent(this, states::BUSY, false);
michael@0 107 FireDelayedEvent(stateEvent);
michael@0 108 }
michael@0 109 }
michael@0 110
michael@0 111 inline void
michael@0 112 DocAccessible::MaybeNotifyOfValueChange(Accessible* aAccessible)
michael@0 113 {
michael@0 114 a11y::role role = aAccessible->Role();
michael@0 115 if (role == roles::ENTRY || role == roles::COMBOBOX)
michael@0 116 FireDelayedEvent(nsIAccessibleEvent::EVENT_VALUE_CHANGE, aAccessible);
michael@0 117 }
michael@0 118
michael@0 119 inline Accessible*
michael@0 120 DocAccessible::GetAccessibleEvenIfNotInMapOrContainer(nsINode* aNode) const
michael@0 121 {
michael@0 122 Accessible* acc = GetAccessibleEvenIfNotInMap(aNode);
michael@0 123 return acc ? acc : GetContainerAccessible(aNode);
michael@0 124 }
michael@0 125
michael@0 126 } // namespace a11y
michael@0 127 } // namespace mozilla
michael@0 128
michael@0 129 #endif

mercurial