2012-05-30 02:21:24 +00: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 12:23:02 +00:00
|
|
|
#include "nsAccessiblePivot.h"
|
2012-06-01 18:39:47 +00:00
|
|
|
#include "NotificationController.h"
|
2012-11-17 03:32:51 +00:00
|
|
|
#include "States.h"
|
2013-09-10 22:18:59 +00:00
|
|
|
#include "nsIScrollableFrame.h"
|
2016-03-04 15:36:18 +00:00
|
|
|
#include "nsIDocumentInlines.h"
|
2012-05-30 02:21:24 +00:00
|
|
|
|
2012-11-20 04:53:38 +00:00
|
|
|
#ifdef A11Y_LOG
|
|
|
|
#include "Logging.h"
|
|
|
|
#endif
|
|
|
|
|
2012-11-18 02:01:44 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace a11y {
|
|
|
|
|
2016-03-28 17:40:21 +00:00
|
|
|
inline Accessible*
|
|
|
|
DocAccessible::AccessibleOrTrueContainer(nsINode* aNode) const
|
|
|
|
{
|
|
|
|
// HTML comboboxes have no-content list accessible as an intermediate
|
|
|
|
// containing all options.
|
|
|
|
Accessible* container = GetAccessibleOrContainer(aNode);
|
|
|
|
if (container && container->IsHTMLCombobox()) {
|
|
|
|
return container->FirstChild();
|
|
|
|
}
|
|
|
|
return container;
|
|
|
|
}
|
|
|
|
|
2014-09-23 12:23:02 +00:00
|
|
|
inline nsIAccessiblePivot*
|
|
|
|
DocAccessible::VirtualCursor()
|
|
|
|
{
|
|
|
|
if (!mVirtualCursor) {
|
|
|
|
mVirtualCursor = new nsAccessiblePivot(this);
|
|
|
|
mVirtualCursor->AddObserver(this);
|
|
|
|
}
|
|
|
|
return mVirtualCursor;
|
|
|
|
}
|
|
|
|
|
2012-11-20 04:53:38 +00: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)
|
|
|
|
{
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<AccEvent> event = new AccEvent(aEventType, aTarget);
|
2012-11-20 04:53:38 +00:00
|
|
|
FireDelayedEvent(event);
|
|
|
|
}
|
|
|
|
|
2012-06-01 18:39:47 +00: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);
|
|
|
|
}
|
|
|
|
|
2016-03-04 15:36:18 +00:00
|
|
|
inline void
|
|
|
|
DocAccessible::UpdateRootElIfNeeded()
|
|
|
|
{
|
|
|
|
dom::Element* rootEl = mDocumentNode->GetBodyElement();
|
|
|
|
if (!rootEl) {
|
|
|
|
rootEl = mDocumentNode->GetRootElement();
|
|
|
|
}
|
|
|
|
if (rootEl != mContent) {
|
|
|
|
mContent = rootEl;
|
|
|
|
SetRoleMapEntry(aria::GetRoleMap(rootEl));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-27 04:25:27 +00: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-17 03:32:51 +00: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()) {
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<AccEvent> stateEvent =
|
2012-11-18 02:01:44 +00:00
|
|
|
new AccStateChangeEvent(this, states::BUSY, false);
|
2012-11-20 04:53:38 +00:00
|
|
|
FireDelayedEvent(stateEvent);
|
2012-11-17 03:32:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-28 04:21:40 +00:00
|
|
|
inline void
|
|
|
|
DocAccessible::MaybeNotifyOfValueChange(Accessible* aAccessible)
|
|
|
|
{
|
2012-11-20 04:53:38 +00:00
|
|
|
a11y::role role = aAccessible->Role();
|
|
|
|
if (role == roles::ENTRY || role == roles::COMBOBOX)
|
2015-11-02 20:34:51 +00:00
|
|
|
FireDelayedEvent(nsIAccessibleEvent::EVENT_TEXT_VALUE_CHANGE, aAccessible);
|
2012-11-13 06:29:22 +00:00
|
|
|
}
|
2012-07-28 04:21:40 +00:00
|
|
|
|
2014-03-06 00:36:56 +00:00
|
|
|
inline Accessible*
|
|
|
|
DocAccessible::GetAccessibleEvenIfNotInMapOrContainer(nsINode* aNode) const
|
|
|
|
{
|
|
|
|
Accessible* acc = GetAccessibleEvenIfNotInMap(aNode);
|
|
|
|
return acc ? acc : GetContainerAccessible(aNode);
|
|
|
|
}
|
|
|
|
|
2012-11-18 02:01:44 +00:00
|
|
|
} // namespace a11y
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2012-05-30 02:21:24 +00:00
|
|
|
#endif
|