1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/accessible/src/generic/DocAccessible-inl.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,129 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim: set ts=2 et sw=2 tw=80: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.8 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef mozilla_a11y_DocAccessible_inl_h_ 1.11 +#define mozilla_a11y_DocAccessible_inl_h_ 1.12 + 1.13 +#include "DocAccessible.h" 1.14 +#include "nsAccessibilityService.h" 1.15 +#include "NotificationController.h" 1.16 +#include "States.h" 1.17 +#include "nsIScrollableFrame.h" 1.18 + 1.19 +#ifdef A11Y_LOG 1.20 +#include "Logging.h" 1.21 +#endif 1.22 + 1.23 +namespace mozilla { 1.24 +namespace a11y { 1.25 + 1.26 +inline void 1.27 +DocAccessible::FireDelayedEvent(AccEvent* aEvent) 1.28 +{ 1.29 +#ifdef A11Y_LOG 1.30 + if (logging::IsEnabled(logging::eDocLoad)) 1.31 + logging::DocLoadEventFired(aEvent); 1.32 +#endif 1.33 + 1.34 + mNotificationController->QueueEvent(aEvent); 1.35 +} 1.36 + 1.37 +inline void 1.38 +DocAccessible::FireDelayedEvent(uint32_t aEventType, Accessible* aTarget) 1.39 +{ 1.40 + nsRefPtr<AccEvent> event = new AccEvent(aEventType, aTarget); 1.41 + FireDelayedEvent(event); 1.42 +} 1.43 + 1.44 +inline void 1.45 +DocAccessible::BindChildDocument(DocAccessible* aDocument) 1.46 +{ 1.47 + mNotificationController->ScheduleChildDocBinding(aDocument); 1.48 +} 1.49 + 1.50 +template<class Class, class Arg> 1.51 +inline void 1.52 +DocAccessible::HandleNotification(Class* aInstance, 1.53 + typename TNotification<Class, Arg>::Callback aMethod, 1.54 + Arg* aArg) 1.55 +{ 1.56 + if (mNotificationController) { 1.57 + mNotificationController->HandleNotification<Class, Arg>(aInstance, 1.58 + aMethod, aArg); 1.59 + } 1.60 +} 1.61 + 1.62 +inline void 1.63 +DocAccessible::UpdateText(nsIContent* aTextNode) 1.64 +{ 1.65 + NS_ASSERTION(mNotificationController, "The document was shut down!"); 1.66 + 1.67 + // Ignore the notification if initial tree construction hasn't been done yet. 1.68 + if (mNotificationController && HasLoadState(eTreeConstructed)) 1.69 + mNotificationController->ScheduleTextUpdate(aTextNode); 1.70 +} 1.71 + 1.72 +inline void 1.73 +DocAccessible::AddScrollListener() 1.74 +{ 1.75 + // Delay scroll initializing until the document has a root frame. 1.76 + if (!mPresShell->GetRootFrame()) 1.77 + return; 1.78 + 1.79 + mDocFlags |= eScrollInitialized; 1.80 + nsIScrollableFrame* sf = mPresShell->GetRootScrollFrameAsScrollable(); 1.81 + if (sf) { 1.82 + sf->AddScrollPositionListener(this); 1.83 + 1.84 +#ifdef A11Y_LOG 1.85 + if (logging::IsEnabled(logging::eDocCreate)) 1.86 + logging::Text("add scroll listener"); 1.87 +#endif 1.88 + } 1.89 +} 1.90 + 1.91 +inline void 1.92 +DocAccessible::RemoveScrollListener() 1.93 +{ 1.94 + nsIScrollableFrame* sf = mPresShell->GetRootScrollFrameAsScrollable(); 1.95 + if (sf) 1.96 + sf->RemoveScrollPositionListener(this); 1.97 +} 1.98 + 1.99 +inline void 1.100 +DocAccessible::NotifyOfLoad(uint32_t aLoadEventType) 1.101 +{ 1.102 + mLoadState |= eDOMLoaded; 1.103 + mLoadEventType = aLoadEventType; 1.104 + 1.105 + // If the document is loaded completely then network activity was presumingly 1.106 + // caused by file loading. Fire busy state change event. 1.107 + if (HasLoadState(eCompletelyLoaded) && IsLoadEventTarget()) { 1.108 + nsRefPtr<AccEvent> stateEvent = 1.109 + new AccStateChangeEvent(this, states::BUSY, false); 1.110 + FireDelayedEvent(stateEvent); 1.111 + } 1.112 +} 1.113 + 1.114 +inline void 1.115 +DocAccessible::MaybeNotifyOfValueChange(Accessible* aAccessible) 1.116 +{ 1.117 + a11y::role role = aAccessible->Role(); 1.118 + if (role == roles::ENTRY || role == roles::COMBOBOX) 1.119 + FireDelayedEvent(nsIAccessibleEvent::EVENT_VALUE_CHANGE, aAccessible); 1.120 +} 1.121 + 1.122 +inline Accessible* 1.123 +DocAccessible::GetAccessibleEvenIfNotInMapOrContainer(nsINode* aNode) const 1.124 +{ 1.125 + Accessible* acc = GetAccessibleEvenIfNotInMap(aNode); 1.126 + return acc ? acc : GetContainerAccessible(aNode); 1.127 +} 1.128 + 1.129 +} // namespace a11y 1.130 +} // namespace mozilla 1.131 + 1.132 +#endif