2012-05-29 19:21:24 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=2 et sw=2 tw=80: */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_a11y_DocAccessible_inl_h_
|
|
|
|
#define mozilla_a11y_DocAccessible_inl_h_
|
|
|
|
|
|
|
|
#include "DocAccessible.h"
|
|
|
|
#include "nsAccessibilityService.h"
|
2014-09-23 05:23:02 -07:00
|
|
|
#include "nsAccessiblePivot.h"
|
2012-06-01 11:39:47 -07:00
|
|
|
#include "NotificationController.h"
|
2012-11-16 19:32:51 -08:00
|
|
|
#include "States.h"
|
2013-09-10 15:18:59 -07:00
|
|
|
#include "nsIScrollableFrame.h"
|
2012-05-29 19:21:24 -07:00
|
|
|
|
2012-11-19 20:53:38 -08:00
|
|
|
#ifdef A11Y_LOG
|
|
|
|
#include "Logging.h"
|
|
|
|
#endif
|
|
|
|
|
2012-11-17 18:01:44 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace a11y {
|
|
|
|
|
2014-09-23 05:23:02 -07:00
|
|
|
inline nsIAccessiblePivot*
|
|
|
|
DocAccessible::VirtualCursor()
|
|
|
|
{
|
|
|
|
if (!mVirtualCursor) {
|
|
|
|
mVirtualCursor = new nsAccessiblePivot(this);
|
|
|
|
mVirtualCursor->AddObserver(this);
|
|
|
|
}
|
|
|
|
return mVirtualCursor;
|
|
|
|
}
|
|
|
|
|
2012-11-19 20:53:38 -08:00
|
|
|
inline void
|
|
|
|
DocAccessible::FireDelayedEvent(AccEvent* aEvent)
|
|
|
|
{
|
|
|
|
#ifdef A11Y_LOG
|
|
|
|
if (logging::IsEnabled(logging::eDocLoad))
|
|
|
|
logging::DocLoadEventFired(aEvent);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
mNotificationController->QueueEvent(aEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
|
|
|
DocAccessible::FireDelayedEvent(uint32_t aEventType, Accessible* aTarget)
|
|
|
|
{
|
|
|
|
nsRefPtr<AccEvent> event = new AccEvent(aEventType, aTarget);
|
|
|
|
FireDelayedEvent(event);
|
|
|
|
}
|
|
|
|
|
2012-06-01 11:39:47 -07:00
|
|
|
inline void
|
|
|
|
DocAccessible::BindChildDocument(DocAccessible* aDocument)
|
|
|
|
{
|
|
|
|
mNotificationController->ScheduleChildDocBinding(aDocument);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class Class, class Arg>
|
|
|
|
inline void
|
|
|
|
DocAccessible::HandleNotification(Class* aInstance,
|
|
|
|
typename TNotification<Class, Arg>::Callback aMethod,
|
|
|
|
Arg* aArg)
|
|
|
|
{
|
|
|
|
if (mNotificationController) {
|
|
|
|
mNotificationController->HandleNotification<Class, Arg>(aInstance,
|
|
|
|
aMethod, aArg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
|
|
|
DocAccessible::UpdateText(nsIContent* aTextNode)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(mNotificationController, "The document was shut down!");
|
|
|
|
|
|
|
|
// Ignore the notification if initial tree construction hasn't been done yet.
|
|
|
|
if (mNotificationController && HasLoadState(eTreeConstructed))
|
|
|
|
mNotificationController->ScheduleTextUpdate(aTextNode);
|
|
|
|
}
|
|
|
|
|
2012-12-26 20:25:27 -08:00
|
|
|
inline void
|
|
|
|
DocAccessible::AddScrollListener()
|
|
|
|
{
|
|
|
|
// Delay scroll initializing until the document has a root frame.
|
|
|
|
if (!mPresShell->GetRootFrame())
|
|
|
|
return;
|
|
|
|
|
|
|
|
mDocFlags |= eScrollInitialized;
|
|
|
|
nsIScrollableFrame* sf = mPresShell->GetRootScrollFrameAsScrollable();
|
|
|
|
if (sf) {
|
|
|
|
sf->AddScrollPositionListener(this);
|
|
|
|
|
|
|
|
#ifdef A11Y_LOG
|
|
|
|
if (logging::IsEnabled(logging::eDocCreate))
|
|
|
|
logging::Text("add scroll listener");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
|
|
|
DocAccessible::RemoveScrollListener()
|
|
|
|
{
|
|
|
|
nsIScrollableFrame* sf = mPresShell->GetRootScrollFrameAsScrollable();
|
|
|
|
if (sf)
|
|
|
|
sf->RemoveScrollPositionListener(this);
|
|
|
|
}
|
|
|
|
|
2012-11-16 19:32:51 -08:00
|
|
|
inline void
|
|
|
|
DocAccessible::NotifyOfLoad(uint32_t aLoadEventType)
|
|
|
|
{
|
|
|
|
mLoadState |= eDOMLoaded;
|
|
|
|
mLoadEventType = aLoadEventType;
|
|
|
|
|
|
|
|
// If the document is loaded completely then network activity was presumingly
|
|
|
|
// caused by file loading. Fire busy state change event.
|
|
|
|
if (HasLoadState(eCompletelyLoaded) && IsLoadEventTarget()) {
|
|
|
|
nsRefPtr<AccEvent> stateEvent =
|
2012-11-17 18:01:44 -08:00
|
|
|
new AccStateChangeEvent(this, states::BUSY, false);
|
2012-11-19 20:53:38 -08:00
|
|
|
FireDelayedEvent(stateEvent);
|
2012-11-16 19:32:51 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-27 21:21:40 -07:00
|
|
|
inline void
|
|
|
|
DocAccessible::MaybeNotifyOfValueChange(Accessible* aAccessible)
|
|
|
|
{
|
2012-11-19 20:53:38 -08:00
|
|
|
a11y::role role = aAccessible->Role();
|
|
|
|
if (role == roles::ENTRY || role == roles::COMBOBOX)
|
|
|
|
FireDelayedEvent(nsIAccessibleEvent::EVENT_VALUE_CHANGE, aAccessible);
|
2012-11-12 22:29:22 -08:00
|
|
|
}
|
2012-07-27 21:21:40 -07:00
|
|
|
|
2014-03-05 16:36:56 -08:00
|
|
|
inline Accessible*
|
|
|
|
DocAccessible::GetAccessibleEvenIfNotInMapOrContainer(nsINode* aNode) const
|
|
|
|
{
|
|
|
|
Accessible* acc = GetAccessibleEvenIfNotInMap(aNode);
|
|
|
|
return acc ? acc : GetContainerAccessible(aNode);
|
|
|
|
}
|
|
|
|
|
2012-11-17 18:01:44 -08:00
|
|
|
} // namespace a11y
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2012-05-29 19:21:24 -07:00
|
|
|
#endif
|