2001-09-26 02:32:32 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2001-02-14 23:51:33 +03:00
|
|
|
|
2012-04-09 14:18:03 +04:00
|
|
|
#include "nsAccessibilityService.h"
|
2011-10-11 09:50:08 +04:00
|
|
|
|
2001-12-17 04:21:29 +03:00
|
|
|
// NOTE: alphabetically ordered
|
2012-04-25 15:29:40 +04:00
|
|
|
#include "ApplicationAccessibleWrap.h"
|
2012-04-09 14:18:03 +04:00
|
|
|
#include "ARIAGridAccessibleWrap.h"
|
2013-04-25 07:48:26 +04:00
|
|
|
#include "ARIAMap.h"
|
2012-06-01 22:39:47 +04:00
|
|
|
#include "DocAccessible-inl.h"
|
2012-04-09 14:18:03 +04:00
|
|
|
#include "FocusManager.h"
|
2012-06-06 14:27:51 +04:00
|
|
|
#include "HTMLCanvasAccessible.h"
|
2012-06-02 15:30:29 +04:00
|
|
|
#include "HTMLElementAccessibles.h"
|
2012-06-04 16:32:34 +04:00
|
|
|
#include "HTMLImageMapAccessible.h"
|
2012-06-04 16:32:38 +04:00
|
|
|
#include "HTMLLinkAccessible.h"
|
2012-05-08 09:16:40 +04:00
|
|
|
#include "HTMLListAccessible.h"
|
2012-06-06 14:27:46 +04:00
|
|
|
#include "HTMLSelectAccessible.h"
|
2012-06-11 03:44:50 +04:00
|
|
|
#include "HTMLTableAccessibleWrap.h"
|
2012-05-31 12:04:41 +04:00
|
|
|
#include "HyperTextAccessibleWrap.h"
|
2013-09-11 02:18:59 +04:00
|
|
|
#include "RootAccessible.h"
|
2012-02-02 10:14:51 +04:00
|
|
|
#include "nsAccessiblePivot.h"
|
2008-10-16 13:12:05 +04:00
|
|
|
#include "nsAccUtils.h"
|
2015-08-05 06:35:54 +03:00
|
|
|
#include "nsArrayUtils.h"
|
2013-09-11 02:18:59 +04:00
|
|
|
#include "nsAttrName.h"
|
2012-07-28 08:21:40 +04:00
|
|
|
#include "nsEventShell.h"
|
2013-09-11 02:18:59 +04:00
|
|
|
#include "nsIURI.h"
|
2012-04-09 14:18:03 +04:00
|
|
|
#include "OuterDocAccessible.h"
|
2012-12-02 04:58:25 +04:00
|
|
|
#include "Platform.h"
|
2012-01-12 07:07:35 +04:00
|
|
|
#include "Role.h"
|
2013-09-11 02:18:59 +04:00
|
|
|
#ifdef MOZ_ACCESSIBILITY_ATK
|
2012-05-04 10:09:22 +04:00
|
|
|
#include "RootAccessibleWrap.h"
|
2013-09-11 02:18:59 +04:00
|
|
|
#endif
|
2011-04-10 03:38:06 +04:00
|
|
|
#include "States.h"
|
2011-08-11 15:01:27 +04:00
|
|
|
#include "Statistics.h"
|
2012-10-13 10:34:21 +04:00
|
|
|
#include "TextLeafAccessibleWrap.h"
|
2014-09-20 04:02:30 +04:00
|
|
|
#include "TreeWalker.h"
|
2014-10-22 04:49:28 +04:00
|
|
|
#include "xpcAccessibleApplication.h"
|
|
|
|
#include "xpcAccessibleDocument.h"
|
2012-10-13 10:34:21 +04:00
|
|
|
|
|
|
|
#ifdef MOZ_ACCESSIBILITY_ATK
|
|
|
|
#include "AtkSocketAccessible.h"
|
|
|
|
#endif
|
|
|
|
|
2012-04-09 14:18:03 +04:00
|
|
|
#ifdef XP_WIN
|
2013-02-27 02:07:24 +04:00
|
|
|
#include "mozilla/a11y/Compatibility.h"
|
2012-10-13 10:34:21 +04:00
|
|
|
#include "HTMLWin32ObjectAccessible.h"
|
2013-09-11 02:18:59 +04:00
|
|
|
#include "mozilla/StaticPtr.h"
|
2012-04-09 14:18:03 +04:00
|
|
|
#endif
|
2010-04-06 04:41:28 +04:00
|
|
|
|
2012-10-04 13:57:09 +04:00
|
|
|
#ifdef A11Y_LOG
|
2012-05-23 13:21:40 +04:00
|
|
|
#include "Logging.h"
|
|
|
|
#endif
|
|
|
|
|
2012-07-20 22:43:49 +04:00
|
|
|
#ifdef MOZ_CRASHREPORTER
|
|
|
|
#include "nsExceptionHandler.h"
|
|
|
|
#endif
|
|
|
|
|
2011-04-26 10:52:19 +04:00
|
|
|
#include "nsImageFrame.h"
|
2003-04-22 11:38:18 +04:00
|
|
|
#include "nsIObserverService.h"
|
2011-10-05 10:24:44 +04:00
|
|
|
#include "nsLayoutUtils.h"
|
2014-09-24 08:33:00 +04:00
|
|
|
#include "nsPluginFrame.h"
|
2013-01-04 08:26:00 +04:00
|
|
|
#include "nsSVGPathGeometryFrame.h"
|
2012-11-20 00:36:05 +04:00
|
|
|
#include "nsTreeBodyFrame.h"
|
|
|
|
#include "nsTreeColumns.h"
|
|
|
|
#include "nsTreeUtils.h"
|
2013-07-19 08:13:35 +04:00
|
|
|
#include "nsXBLPrototypeBinding.h"
|
|
|
|
#include "nsXBLBinding.h"
|
2013-12-09 06:52:54 +04:00
|
|
|
#include "mozilla/ArrayUtils.h"
|
2013-07-09 21:54:21 +04:00
|
|
|
#include "mozilla/dom/DOMStringList.h"
|
2012-06-20 03:19:13 +04:00
|
|
|
#include "mozilla/Preferences.h"
|
Bug 560095 - Use mozilla::services::GetObserverService(). r=biesi,dveditz,gavin,josh,jst,mrbkap,roc,sdwilsh,shaver,sicking,smontagu,surkov
2010-04-29 20:59:13 +04:00
|
|
|
#include "mozilla/Services.h"
|
2012-12-28 12:15:02 +04:00
|
|
|
#include "nsDeckFrame.h"
|
2003-04-22 11:38:18 +04:00
|
|
|
|
2003-04-11 04:56:27 +04:00
|
|
|
#ifdef MOZ_XUL
|
2012-06-11 03:44:50 +04:00
|
|
|
#include "XULAlertAccessible.h"
|
|
|
|
#include "XULColorPickerAccessible.h"
|
|
|
|
#include "XULComboboxAccessible.h"
|
|
|
|
#include "XULElementAccessibles.h"
|
2012-06-09 12:21:07 +04:00
|
|
|
#include "XULFormControlAccessible.h"
|
2012-06-11 03:44:50 +04:00
|
|
|
#include "XULListboxAccessibleWrap.h"
|
|
|
|
#include "XULMenuAccessibleWrap.h"
|
|
|
|
#include "XULSliderAccessible.h"
|
|
|
|
#include "XULTabAccessible.h"
|
|
|
|
#include "XULTreeGridAccessibleWrap.h"
|
2003-04-11 04:56:27 +04:00
|
|
|
#endif
|
2001-05-12 01:11:38 +04:00
|
|
|
|
2013-09-11 02:18:59 +04:00
|
|
|
#if defined(XP_WIN) || defined(MOZ_ACCESSIBILITY_ATK)
|
|
|
|
#include "nsNPAPIPluginInstance.h"
|
|
|
|
#endif
|
|
|
|
|
2011-10-11 09:50:08 +04:00
|
|
|
using namespace mozilla;
|
2011-07-27 16:43:01 +04:00
|
|
|
using namespace mozilla::a11y;
|
2013-07-09 21:54:21 +04:00
|
|
|
using namespace mozilla::dom;
|
2011-07-27 16:43:01 +04:00
|
|
|
|
2012-11-10 14:26:58 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Statics
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return true if the element must be accessible.
|
|
|
|
*/
|
|
|
|
static bool
|
|
|
|
MustBeAccessible(nsIContent* aContent, DocAccessible* aDocument)
|
|
|
|
{
|
|
|
|
if (aContent->GetPrimaryFrame()->IsFocusable())
|
|
|
|
return true;
|
|
|
|
|
2013-01-08 03:21:50 +04:00
|
|
|
uint32_t attrCount = aContent->GetAttrCount();
|
|
|
|
for (uint32_t attrIdx = 0; attrIdx < attrCount; attrIdx++) {
|
2012-11-10 14:26:58 +04:00
|
|
|
const nsAttrName* attr = aContent->GetAttrNameAt(attrIdx);
|
|
|
|
if (attr->NamespaceEquals(kNameSpaceID_None)) {
|
|
|
|
nsIAtom* attrAtom = attr->Atom();
|
|
|
|
nsDependentAtomString attrStr(attrAtom);
|
|
|
|
if (!StringBeginsWith(attrStr, NS_LITERAL_STRING("aria-")))
|
|
|
|
continue; // not ARIA
|
|
|
|
|
|
|
|
// A global state or a property and in case of token defined.
|
2013-04-25 07:48:26 +04:00
|
|
|
uint8_t attrFlags = aria::AttrCharacteristicsFor(attrAtom);
|
2012-11-10 14:26:58 +04:00
|
|
|
if ((attrFlags & ATTR_GLOBAL) && (!(attrFlags & ATTR_VALTOKEN) ||
|
|
|
|
nsAccUtils::HasDefinedARIAToken(aContent, attrAtom))) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the given ID is referred by relation attribute then create an accessible
|
|
|
|
// for it.
|
|
|
|
nsAutoString id;
|
|
|
|
if (nsCoreUtils::GetID(aContent, id) && !id.IsEmpty())
|
|
|
|
return aDocument->IsDependentID(id);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-03-05 06:56:57 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Accessible constructors
|
|
|
|
|
2015-03-14 03:42:57 +03:00
|
|
|
static Accessible*
|
2015-03-05 06:56:57 +03:00
|
|
|
New_HTMLLink(nsIContent* aContent, Accessible* aContext)
|
|
|
|
{
|
|
|
|
// Only some roles truly enjoy life as HTMLLinkAccessibles, for details
|
|
|
|
// see closed bug 494807.
|
2016-03-11 05:13:01 +03:00
|
|
|
const nsRoleMapEntry* roleMapEntry = aria::GetRoleMap(aContent->AsElement());
|
2015-03-05 06:56:57 +03:00
|
|
|
if (roleMapEntry && roleMapEntry->role != roles::NOTHING &&
|
|
|
|
roleMapEntry->role != roles::LINK) {
|
|
|
|
return new HyperTextAccessibleWrap(aContent, aContext->Document());
|
|
|
|
}
|
|
|
|
|
|
|
|
return new HTMLLinkAccessible(aContent, aContext->Document());
|
|
|
|
}
|
|
|
|
|
2015-03-14 03:42:57 +03:00
|
|
|
static Accessible* New_HyperText(nsIContent* aContent, Accessible* aContext)
|
2015-03-05 06:56:57 +03:00
|
|
|
{ return new HyperTextAccessibleWrap(aContent, aContext->Document()); }
|
|
|
|
|
2015-03-14 03:42:57 +03:00
|
|
|
static Accessible* New_HTMLFigcaption(nsIContent* aContent, Accessible* aContext)
|
2015-03-05 06:56:57 +03:00
|
|
|
{ return new HTMLFigcaptionAccessible(aContent, aContext->Document()); }
|
|
|
|
|
2015-03-14 03:42:57 +03:00
|
|
|
static Accessible* New_HTMLFigure(nsIContent* aContent, Accessible* aContext)
|
2015-03-05 06:56:57 +03:00
|
|
|
{ return new HTMLFigureAccessible(aContent, aContext->Document()); }
|
|
|
|
|
2015-03-14 03:42:57 +03:00
|
|
|
static Accessible* New_HTMLLegend(nsIContent* aContent, Accessible* aContext)
|
2015-03-05 06:56:57 +03:00
|
|
|
{ return new HTMLLegendAccessible(aContent, aContext->Document()); }
|
|
|
|
|
2015-03-14 03:42:57 +03:00
|
|
|
static Accessible* New_HTMLOption(nsIContent* aContent, Accessible* aContext)
|
2015-03-05 06:56:57 +03:00
|
|
|
{ return new HTMLSelectOptionAccessible(aContent, aContext->Document()); }
|
|
|
|
|
2015-03-14 03:42:57 +03:00
|
|
|
static Accessible* New_HTMLOptgroup(nsIContent* aContent, Accessible* aContext)
|
2015-03-05 06:56:57 +03:00
|
|
|
{ return new HTMLSelectOptGroupAccessible(aContent, aContext->Document()); }
|
|
|
|
|
2015-03-14 03:42:57 +03:00
|
|
|
static Accessible* New_HTMLList(nsIContent* aContent, Accessible* aContext)
|
2015-03-05 06:56:57 +03:00
|
|
|
{ return new HTMLListAccessible(aContent, aContext->Document()); }
|
|
|
|
|
2015-03-14 03:42:57 +03:00
|
|
|
static Accessible*
|
2015-03-05 06:56:57 +03:00
|
|
|
New_HTMLListitem(nsIContent* aContent, Accessible* aContext)
|
|
|
|
{
|
|
|
|
// If list item is a child of accessible list then create an accessible for
|
|
|
|
// it unconditionally by tag name. nsBlockFrame creates the list item
|
|
|
|
// accessible for other elements styled as list items.
|
|
|
|
if (aContext->IsList() && aContext->GetContent() == aContent->GetParent())
|
|
|
|
return new HTMLLIAccessible(aContent, aContext->Document());
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-03-14 03:42:57 +03:00
|
|
|
static Accessible*
|
2015-03-05 06:56:57 +03:00
|
|
|
New_HTMLDefinition(nsIContent* aContent, Accessible* aContext)
|
|
|
|
{
|
|
|
|
if (aContext->IsList())
|
|
|
|
return new HyperTextAccessibleWrap(aContent, aContext->Document());
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-03-14 03:42:57 +03:00
|
|
|
static Accessible* New_HTMLLabel(nsIContent* aContent, Accessible* aContext)
|
2015-03-05 06:56:57 +03:00
|
|
|
{ return new HTMLLabelAccessible(aContent, aContext->Document()); }
|
|
|
|
|
2015-03-14 03:42:57 +03:00
|
|
|
static Accessible* New_HTMLOutput(nsIContent* aContent, Accessible* aContext)
|
2015-03-05 06:56:57 +03:00
|
|
|
{ return new HTMLOutputAccessible(aContent, aContext->Document()); }
|
|
|
|
|
2015-03-14 03:42:57 +03:00
|
|
|
static Accessible* New_HTMLProgress(nsIContent* aContent, Accessible* aContext)
|
2015-03-05 06:56:57 +03:00
|
|
|
{ return new HTMLProgressMeterAccessible(aContent, aContext->Document()); }
|
|
|
|
|
2015-03-19 19:45:59 +03:00
|
|
|
static Accessible*
|
|
|
|
New_HTMLTableAccessible(nsIContent* aContent, Accessible* aContext)
|
|
|
|
{ return new HTMLTableAccessible(aContent, aContext->Document()); }
|
|
|
|
|
|
|
|
static Accessible*
|
|
|
|
New_HTMLTableRowAccessible(nsIContent* aContent, Accessible* aContext)
|
|
|
|
{ return new HTMLTableRowAccessible(aContent, aContext->Document()); }
|
|
|
|
|
|
|
|
static Accessible*
|
|
|
|
New_HTMLTableCellAccessible(nsIContent* aContent, Accessible* aContext)
|
|
|
|
{ return new HTMLTableCellAccessible(aContent, aContext->Document()); }
|
|
|
|
|
2015-03-14 03:42:57 +03:00
|
|
|
static Accessible*
|
2015-03-05 06:56:57 +03:00
|
|
|
New_HTMLTableHeaderCell(nsIContent* aContent, Accessible* aContext)
|
|
|
|
{
|
|
|
|
if (aContext->IsTableRow() && aContext->GetContent() == aContent->GetParent())
|
|
|
|
return new HTMLTableHeaderCellAccessibleWrap(aContent, aContext->Document());
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-03-14 03:42:57 +03:00
|
|
|
static Accessible*
|
2015-03-05 06:56:57 +03:00
|
|
|
New_HTMLTableHeaderCellIfScope(nsIContent* aContent, Accessible* aContext)
|
|
|
|
{
|
|
|
|
if (aContext->IsTableRow() && aContext->GetContent() == aContent->GetParent() &&
|
|
|
|
aContent->HasAttr(kNameSpaceID_None, nsGkAtoms::scope))
|
|
|
|
return new HTMLTableHeaderCellAccessibleWrap(aContent, aContext->Document());
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Markup maps array.
|
|
|
|
|
2015-03-08 04:20:17 +03:00
|
|
|
#define Attr(name, value) \
|
|
|
|
{ &nsGkAtoms::name, &nsGkAtoms::value }
|
|
|
|
|
|
|
|
#define AttrFromDOM(name, DOMAttrName) \
|
|
|
|
{ &nsGkAtoms::name, nullptr, &nsGkAtoms::DOMAttrName }
|
|
|
|
|
|
|
|
#define AttrFromDOMIf(name, DOMAttrName, DOMAttrValue) \
|
|
|
|
{ &nsGkAtoms::name, nullptr, &nsGkAtoms::DOMAttrName, &nsGkAtoms::DOMAttrValue }
|
|
|
|
|
|
|
|
#define MARKUPMAP(atom, new_func, r, ... ) \
|
|
|
|
{ &nsGkAtoms::atom, new_func, static_cast<a11y::role>(r), { __VA_ARGS__ } },
|
2015-03-05 06:56:57 +03:00
|
|
|
|
|
|
|
static const MarkupMapInfo sMarkupMapList[] = {
|
|
|
|
#include "MarkupMap.h"
|
|
|
|
};
|
|
|
|
|
2015-03-08 04:20:17 +03:00
|
|
|
#undef Attr
|
|
|
|
#undef AttrFromDOM
|
|
|
|
#undef AttrFromDOMIf
|
2015-03-05 06:56:57 +03:00
|
|
|
#undef MARKUPMAP
|
|
|
|
|
2010-02-21 03:56:35 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsAccessibilityService
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
nsAccessibilityService *nsAccessibilityService::gAccessibilityService = nullptr;
|
2012-09-10 17:20:26 +04:00
|
|
|
ApplicationAccessible* nsAccessibilityService::gApplicationAccessible = nullptr;
|
2014-10-22 04:49:28 +04:00
|
|
|
xpcAccessibleApplication* nsAccessibilityService::gXPCApplicationAccessible = nullptr;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool nsAccessibilityService::gIsShutdown = true;
|
2003-07-09 11:01:46 +04:00
|
|
|
|
2011-09-28 05:46:11 +04:00
|
|
|
nsAccessibilityService::nsAccessibilityService() :
|
2015-03-05 21:16:12 +03:00
|
|
|
DocManager(), FocusManager(), mMarkupMaps(ArrayLength(sMarkupMapList))
|
2001-03-05 23:21:39 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAccessibilityService::~nsAccessibilityService()
|
|
|
|
{
|
2009-07-29 13:01:48 +04:00
|
|
|
NS_ASSERTION(gIsShutdown, "Accessibility wasn't shutdown!");
|
2012-07-30 18:20:58 +04:00
|
|
|
gAccessibilityService = nullptr;
|
2001-03-05 23:21:39 +03:00
|
|
|
}
|
|
|
|
|
2015-08-05 06:35:54 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIListenerChangeListener
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsAccessibilityService::ListenersChanged(nsIArray* aEventChanges)
|
|
|
|
{
|
|
|
|
uint32_t targetCount;
|
|
|
|
nsresult rv = aEventChanges->GetLength(&targetCount);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
for (uint32_t i = 0 ; i < targetCount ; i++) {
|
|
|
|
nsCOMPtr<nsIEventListenerChange> change = do_QueryElementAt(aEventChanges, i);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMEventTarget> target;
|
|
|
|
change->GetTarget(getter_AddRefs(target));
|
|
|
|
nsCOMPtr<nsIContent> node(do_QueryInterface(target));
|
|
|
|
if (!node || !node->IsHTMLElement()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIArray> listenerNames;
|
|
|
|
change->GetChangedListenerNames(getter_AddRefs(listenerNames));
|
|
|
|
|
|
|
|
uint32_t changeCount;
|
|
|
|
rv = listenerNames->GetLength(&changeCount);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
for (uint32_t i = 0 ; i < changeCount ; i++) {
|
|
|
|
nsCOMPtr<nsIAtom> listenerName = do_QueryElementAt(listenerNames, i);
|
|
|
|
|
|
|
|
// We are only interested in event listener changes which may
|
|
|
|
// make an element accessible or inaccessible.
|
|
|
|
if (listenerName != nsGkAtoms::onclick &&
|
|
|
|
listenerName != nsGkAtoms::onmousedown &&
|
|
|
|
listenerName != nsGkAtoms::onmouseup) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIDocument* ownerDoc = node->OwnerDoc();
|
|
|
|
DocAccessible* document = GetExistingDocAccessible(ownerDoc);
|
|
|
|
|
|
|
|
// Always recreate for onclick changes.
|
|
|
|
if (document) {
|
|
|
|
if (nsCoreUtils::HasClickListener(node)) {
|
|
|
|
if (!document->GetAccessible(node)) {
|
|
|
|
document->RecreateAccessible(node);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (document->GetAccessible(node)) {
|
|
|
|
document->RecreateAccessible(node);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-06-08 20:39:58 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsISupports
|
2003-04-15 12:45:55 +04:00
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED(nsAccessibilityService,
|
|
|
|
DocManager,
|
|
|
|
nsIAccessibilityService,
|
|
|
|
nsIAccessibleRetrieval,
|
|
|
|
nsIObserver,
|
2015-08-05 06:35:54 +03:00
|
|
|
nsIListenerChangeListener,
|
2014-04-27 11:06:00 +04:00
|
|
|
nsISelectionListener) // from SelectionManager
|
2010-02-21 03:56:35 +03:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2003-04-15 12:45:55 +04:00
|
|
|
// nsIObserver
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsAccessibilityService::Observe(nsISupports *aSubject, const char *aTopic,
|
2014-01-04 19:02:17 +04:00
|
|
|
const char16_t *aData)
|
2003-04-15 12:45:55 +04:00
|
|
|
{
|
2010-06-08 20:39:58 +04:00
|
|
|
if (!nsCRT::strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID))
|
|
|
|
Shutdown();
|
2010-01-25 18:08:08 +03:00
|
|
|
|
2008-02-26 11:51:10 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2003-06-26 12:45:39 +04:00
|
|
|
|
2010-02-21 03:56:35 +03:00
|
|
|
// nsIAccessibilityService
|
2010-04-28 19:58:38 +04:00
|
|
|
void
|
2011-01-25 06:33:37 +03:00
|
|
|
nsAccessibilityService::NotifyOfAnchorJumpTo(nsIContent* aTargetNode)
|
2009-11-02 04:02:09 +03:00
|
|
|
{
|
2011-01-25 06:33:37 +03:00
|
|
|
nsIDocument* documentNode = aTargetNode->GetCurrentDoc();
|
|
|
|
if (documentNode) {
|
2012-05-27 13:01:40 +04:00
|
|
|
DocAccessible* document = GetDocAccessible(documentNode);
|
2011-01-25 06:33:37 +03:00
|
|
|
if (document)
|
2011-10-08 09:16:37 +04:00
|
|
|
document->SetAnchorJump(aTargetNode);
|
2011-01-25 06:33:37 +03:00
|
|
|
}
|
2009-11-02 04:02:09 +03:00
|
|
|
}
|
|
|
|
|
2010-02-21 03:56:35 +03:00
|
|
|
// nsIAccessibilityService
|
2010-09-23 07:35:39 +04:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsAccessibilityService::FireAccessibleEvent(uint32_t aEvent,
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* aTarget)
|
2008-11-04 06:36:36 +03:00
|
|
|
{
|
2010-09-23 07:35:39 +04:00
|
|
|
nsEventShell::FireEvent(aEvent, aTarget);
|
2008-11-04 06:36:36 +03:00
|
|
|
}
|
|
|
|
|
2010-02-21 03:56:35 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIAccessibilityService
|
2001-05-12 01:11:38 +04:00
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible*
|
2010-09-23 07:35:39 +04:00
|
|
|
nsAccessibilityService::GetRootDocumentAccessible(nsIPresShell* aPresShell,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aCanCreate)
|
2010-09-23 07:35:39 +04:00
|
|
|
{
|
2012-11-03 03:57:58 +04:00
|
|
|
nsIPresShell* ps = aPresShell;
|
2010-09-23 07:35:39 +04:00
|
|
|
nsIDocument* documentNode = aPresShell->GetDocument();
|
|
|
|
if (documentNode) {
|
2013-11-15 20:32:12 +04:00
|
|
|
nsCOMPtr<nsIDocShellTreeItem> treeItem(documentNode->GetDocShell());
|
2010-09-23 07:35:39 +04:00
|
|
|
if (treeItem) {
|
|
|
|
nsCOMPtr<nsIDocShellTreeItem> rootTreeItem;
|
|
|
|
treeItem->GetRootTreeItem(getter_AddRefs(rootTreeItem));
|
|
|
|
if (treeItem != rootTreeItem) {
|
|
|
|
nsCOMPtr<nsIDocShell> docShell(do_QueryInterface(rootTreeItem));
|
2012-12-29 05:56:42 +04:00
|
|
|
ps = docShell->GetPresShell();
|
2010-09-23 07:35:39 +04:00
|
|
|
}
|
|
|
|
|
2012-11-03 03:57:58 +04:00
|
|
|
return aCanCreate ? GetDocAccessible(ps) : ps->GetDocAccessible();
|
2010-09-23 07:35:39 +04:00
|
|
|
}
|
|
|
|
}
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2010-09-23 07:35:39 +04:00
|
|
|
}
|
2012-06-04 16:32:34 +04:00
|
|
|
|
2013-02-27 02:07:24 +04:00
|
|
|
#ifdef XP_WIN
|
|
|
|
static StaticAutoPtr<nsTArray<nsCOMPtr<nsIContent> > > sPendingPlugins;
|
|
|
|
static StaticAutoPtr<nsTArray<nsCOMPtr<nsITimer> > > sPluginTimers;
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class PluginTimerCallBack final : public nsITimerCallback
|
2013-02-27 02:07:24 +04:00
|
|
|
{
|
2014-07-15 22:57:48 +04:00
|
|
|
~PluginTimerCallBack() {}
|
|
|
|
|
2013-02-27 02:07:24 +04:00
|
|
|
public:
|
|
|
|
PluginTimerCallBack(nsIContent* aContent) : mContent(aContent) {}
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHODIMP Notify(nsITimer* aTimer) final
|
2013-02-27 02:07:24 +04:00
|
|
|
{
|
2013-09-27 01:17:13 +04:00
|
|
|
if (!mContent->IsInDoc())
|
|
|
|
return NS_OK;
|
|
|
|
|
2013-02-27 02:07:24 +04:00
|
|
|
nsIPresShell* ps = mContent->OwnerDoc()->GetShell();
|
|
|
|
if (ps) {
|
|
|
|
DocAccessible* doc = ps->GetDocAccessible();
|
|
|
|
if (doc) {
|
|
|
|
// Make sure that if we created an accessible for the plugin that wasn't
|
|
|
|
// a plugin accessible we remove it before creating the right accessible.
|
|
|
|
doc->RecreateAccessible(mContent);
|
|
|
|
sPluginTimers->RemoveElement(aTimer);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// We couldn't get a doc accessible so presumably the document went away.
|
|
|
|
// In this case don't leak our ref to the content or timer.
|
|
|
|
sPendingPlugins->RemoveElement(mContent);
|
|
|
|
sPluginTimers->RemoveElement(aTimer);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsCOMPtr<nsIContent> mContent;
|
|
|
|
};
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(PluginTimerCallBack, nsITimerCallback)
|
2013-02-27 02:07:24 +04:00
|
|
|
#endif
|
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
already_AddRefed<Accessible>
|
2014-09-24 08:34:00 +04:00
|
|
|
nsAccessibilityService::CreatePluginAccessible(nsPluginFrame* aFrame,
|
2012-12-12 14:04:12 +04:00
|
|
|
nsIContent* aContent,
|
|
|
|
Accessible* aContext)
|
2002-02-18 10:35:10 +03:00
|
|
|
{
|
2014-09-24 08:34:00 +04:00
|
|
|
// nsPluginFrame means a plugin, so we need to use the accessibility support
|
2012-11-30 05:33:52 +04:00
|
|
|
// of the plugin.
|
2010-06-28 16:02:03 +04:00
|
|
|
if (aFrame->GetRect().IsEmpty())
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2010-06-11 12:23:18 +04:00
|
|
|
|
2011-04-27 17:42:18 +04:00
|
|
|
#if defined(XP_WIN) || defined(MOZ_ACCESSIBILITY_ATK)
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsNPAPIPluginInstance> pluginInstance;
|
2011-05-18 05:48:34 +04:00
|
|
|
if (NS_SUCCEEDED(aFrame->GetPluginInstance(getter_AddRefs(pluginInstance))) &&
|
2011-04-27 17:42:18 +04:00
|
|
|
pluginInstance) {
|
|
|
|
#ifdef XP_WIN
|
2013-02-27 02:07:24 +04:00
|
|
|
if (!sPendingPlugins->Contains(aContent) &&
|
|
|
|
(Preferences::GetBool("accessibility.delay_plugins") ||
|
|
|
|
Compatibility::IsJAWS() || Compatibility::IsWE())) {
|
|
|
|
nsCOMPtr<nsITimer> timer = do_CreateInstance(NS_TIMER_CONTRACTID);
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<PluginTimerCallBack> cb = new PluginTimerCallBack(aContent);
|
2013-02-27 02:07:24 +04:00
|
|
|
timer->InitWithCallback(cb, Preferences::GetUint("accessibility.delay_plugin_time"),
|
|
|
|
nsITimer::TYPE_ONE_SHOT);
|
|
|
|
sPluginTimers->AppendElement(timer);
|
|
|
|
sPendingPlugins->AppendElement(aContent);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We need to remove aContent from the pending plugins here to avoid
|
|
|
|
// reentrancy. When the timer fires it calls
|
|
|
|
// DocAccessible::ContentInserted() which does the work async.
|
|
|
|
sPendingPlugins->RemoveElement(aContent);
|
|
|
|
|
2009-10-15 07:53:08 +04:00
|
|
|
// Note: pluginPort will be null if windowless.
|
2012-07-30 18:20:58 +04:00
|
|
|
HWND pluginPort = nullptr;
|
2003-04-15 12:45:55 +04:00
|
|
|
aFrame->GetPluginPort(&pluginPort);
|
2009-10-15 07:53:08 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Accessible> accessible =
|
2012-11-30 11:33:01 +04:00
|
|
|
new HTMLWin32ObjectOwnerAccessible(aContent, aContext->Document(),
|
|
|
|
pluginPort);
|
2013-04-28 15:52:10 +04:00
|
|
|
return accessible.forget();
|
2011-04-27 17:42:18 +04:00
|
|
|
|
|
|
|
#elif MOZ_ACCESSIBILITY_ATK
|
|
|
|
if (!AtkSocketAccessible::gCanEmbed)
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2011-04-27 17:42:18 +04:00
|
|
|
|
2012-11-30 05:33:52 +04:00
|
|
|
// Note this calls into the plugin, so crazy things may happen and aFrame
|
|
|
|
// may go away.
|
2011-04-27 17:42:18 +04:00
|
|
|
nsCString plugId;
|
|
|
|
nsresult rv = pluginInstance->GetValueFromPlugin(
|
|
|
|
NPPVpluginNativeAccessibleAtkPlugId, &plugId);
|
2012-01-26 23:58:29 +04:00
|
|
|
if (NS_SUCCEEDED(rv) && !plugId.IsEmpty()) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<AtkSocketAccessible> socketAccessible =
|
2012-11-30 11:33:01 +04:00
|
|
|
new AtkSocketAccessible(aContent, aContext->Document(), plugId);
|
2011-04-27 17:42:18 +04:00
|
|
|
|
2013-04-22 15:15:59 +04:00
|
|
|
return socketAccessible.forget();
|
2011-04-27 17:42:18 +04:00
|
|
|
}
|
|
|
|
#endif
|
2003-04-15 12:45:55 +04:00
|
|
|
}
|
2002-05-11 02:34:53 +04:00
|
|
|
#endif
|
2003-04-15 12:45:55 +04:00
|
|
|
|
2012-11-30 05:33:52 +04:00
|
|
|
return nullptr;
|
2007-07-05 19:39:29 +04:00
|
|
|
}
|
|
|
|
|
2012-12-28 12:15:02 +04:00
|
|
|
void
|
|
|
|
nsAccessibilityService::DeckPanelSwitched(nsIPresShell* aPresShell,
|
|
|
|
nsIContent* aDeckNode,
|
|
|
|
nsIFrame* aPrevBoxFrame,
|
|
|
|
nsIFrame* aCurrentBoxFrame)
|
|
|
|
{
|
|
|
|
// Ignore tabpanels elements (a deck having an accessible) since their
|
|
|
|
// children are accessible not depending on selected tab.
|
|
|
|
DocAccessible* document = GetDocAccessible(aPresShell);
|
|
|
|
if (!document || document->HasAccessible(aDeckNode))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (aPrevBoxFrame) {
|
|
|
|
nsIContent* panelNode = aPrevBoxFrame->GetContent();
|
|
|
|
#ifdef A11Y_LOG
|
|
|
|
if (logging::IsEnabled(logging::eTree)) {
|
|
|
|
logging::MsgBegin("TREE", "deck panel unselected");
|
|
|
|
logging::Node("container", panelNode);
|
|
|
|
logging::Node("content", aDeckNode);
|
|
|
|
logging::MsgEnd();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
document->ContentRemoved(aDeckNode, panelNode);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aCurrentBoxFrame) {
|
|
|
|
nsIContent* panelNode = aCurrentBoxFrame->GetContent();
|
|
|
|
#ifdef A11Y_LOG
|
|
|
|
if (logging::IsEnabled(logging::eTree)) {
|
|
|
|
logging::MsgBegin("TREE", "deck panel selected");
|
|
|
|
logging::Node("container", panelNode);
|
|
|
|
logging::Node("content", aDeckNode);
|
|
|
|
logging::MsgEnd();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
document->ContentInserted(aDeckNode, panelNode, panelNode->GetNextSibling());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-21 08:16:10 +04:00
|
|
|
void
|
|
|
|
nsAccessibilityService::ContentRangeInserted(nsIPresShell* aPresShell,
|
|
|
|
nsIContent* aContainer,
|
|
|
|
nsIContent* aStartChild,
|
|
|
|
nsIContent* aEndChild)
|
|
|
|
{
|
2012-10-04 13:57:09 +04:00
|
|
|
#ifdef A11Y_LOG
|
2012-06-01 08:27:25 +04:00
|
|
|
if (logging::IsEnabled(logging::eTree)) {
|
|
|
|
logging::MsgBegin("TREE", "content inserted");
|
|
|
|
logging::Node("container", aContainer);
|
|
|
|
for (nsIContent* child = aStartChild; child != aEndChild;
|
|
|
|
child = child->GetNextSibling()) {
|
|
|
|
logging::Node("content", child);
|
|
|
|
}
|
|
|
|
logging::MsgEnd();
|
2012-11-04 06:19:56 +04:00
|
|
|
logging::Stack();
|
2010-11-06 07:11:08 +03:00
|
|
|
}
|
2010-10-21 08:16:10 +04:00
|
|
|
#endif
|
|
|
|
|
2012-05-27 13:01:40 +04:00
|
|
|
DocAccessible* docAccessible = GetDocAccessible(aPresShell);
|
2010-11-06 07:11:08 +03:00
|
|
|
if (docAccessible)
|
2011-01-18 11:03:38 +03:00
|
|
|
docAccessible->ContentInserted(aContainer, aStartChild, aEndChild);
|
2010-10-21 08:16:10 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsAccessibilityService::ContentRemoved(nsIPresShell* aPresShell,
|
2014-09-20 04:02:30 +04:00
|
|
|
nsIContent* aChildNode)
|
2010-10-21 08:16:10 +04:00
|
|
|
{
|
2012-10-04 13:57:09 +04:00
|
|
|
#ifdef A11Y_LOG
|
2012-06-01 08:27:25 +04:00
|
|
|
if (logging::IsEnabled(logging::eTree)) {
|
|
|
|
logging::MsgBegin("TREE", "content removed");
|
2014-09-20 04:02:30 +04:00
|
|
|
logging::Node("container", aChildNode->GetFlattenedTreeParent());
|
|
|
|
logging::Node("content", aChildNode);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
DocAccessible* document = GetDocAccessible(aPresShell);
|
|
|
|
if (document) {
|
|
|
|
// Flatten hierarchy may be broken at this point so we cannot get a true
|
|
|
|
// container by traversing up the DOM tree. Find a parent of first accessible
|
|
|
|
// from the subtree of the given DOM node, that'll be a container. If no
|
|
|
|
// accessibles in subtree then we don't care about the change.
|
|
|
|
Accessible* child = document->GetAccessible(aChildNode);
|
|
|
|
if (!child) {
|
2015-03-26 21:59:16 +03:00
|
|
|
Accessible* container = document->GetContainerAccessible(aChildNode);
|
|
|
|
a11y::TreeWalker walker(container ? container : document, aChildNode,
|
|
|
|
a11y::TreeWalker::eWalkCache);
|
2016-02-19 01:57:17 +03:00
|
|
|
child = walker.Next();
|
2014-09-20 04:02:30 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (child) {
|
|
|
|
document->ContentRemoved(child->Parent(), aChildNode);
|
|
|
|
#ifdef A11Y_LOG
|
|
|
|
if (logging::IsEnabled(logging::eTree))
|
|
|
|
logging::AccessibleNNode("real container", child->Parent());
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef A11Y_LOG
|
|
|
|
if (logging::IsEnabled(logging::eTree)) {
|
2012-06-01 08:27:25 +04:00
|
|
|
logging::MsgEnd();
|
2012-11-04 06:19:56 +04:00
|
|
|
logging::Stack();
|
2010-10-21 08:16:10 +04:00
|
|
|
}
|
2010-11-06 07:11:08 +03:00
|
|
|
#endif
|
2010-10-21 08:16:10 +04:00
|
|
|
}
|
|
|
|
|
2011-01-28 11:42:22 +03:00
|
|
|
void
|
|
|
|
nsAccessibilityService::UpdateText(nsIPresShell* aPresShell,
|
|
|
|
nsIContent* aContent)
|
|
|
|
{
|
2012-05-27 13:01:40 +04:00
|
|
|
DocAccessible* document = GetDocAccessible(aPresShell);
|
2011-01-28 11:42:22 +03:00
|
|
|
if (document)
|
|
|
|
document->UpdateText(aContent);
|
|
|
|
}
|
|
|
|
|
2012-04-02 15:31:10 +04:00
|
|
|
void
|
|
|
|
nsAccessibilityService::TreeViewChanged(nsIPresShell* aPresShell,
|
|
|
|
nsIContent* aContent,
|
|
|
|
nsITreeView* aView)
|
|
|
|
{
|
2012-05-27 13:01:40 +04:00
|
|
|
DocAccessible* document = GetDocAccessible(aPresShell);
|
2012-04-02 15:31:10 +04:00
|
|
|
if (document) {
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* accessible = document->GetAccessible(aContent);
|
2012-04-02 15:31:10 +04:00
|
|
|
if (accessible) {
|
2012-06-11 03:44:50 +04:00
|
|
|
XULTreeAccessible* treeAcc = accessible->AsXULTree();
|
2014-06-06 21:22:46 +04:00
|
|
|
if (treeAcc)
|
2012-04-02 15:31:10 +04:00
|
|
|
treeAcc->TreeViewChanged(aView);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-28 04:54:54 +04:00
|
|
|
void
|
|
|
|
nsAccessibilityService::RangeValueChanged(nsIPresShell* aPresShell,
|
|
|
|
nsIContent* aContent)
|
|
|
|
{
|
|
|
|
DocAccessible* document = GetDocAccessible(aPresShell);
|
|
|
|
if (document) {
|
|
|
|
Accessible* accessible = document->GetAccessible(aContent);
|
|
|
|
if (accessible) {
|
|
|
|
document->FireDelayedEvent(nsIAccessibleEvent::EVENT_VALUE_CHANGE,
|
|
|
|
accessible);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-28 17:59:54 +04:00
|
|
|
void
|
|
|
|
nsAccessibilityService::UpdateListBullet(nsIPresShell* aPresShell,
|
|
|
|
nsIContent* aHTMLListItemContent,
|
|
|
|
bool aHasBullet)
|
|
|
|
{
|
2012-05-27 13:01:40 +04:00
|
|
|
DocAccessible* document = GetDocAccessible(aPresShell);
|
2011-03-28 17:59:54 +04:00
|
|
|
if (document) {
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* accessible = document->GetAccessible(aHTMLListItemContent);
|
2011-03-28 17:59:54 +04:00
|
|
|
if (accessible) {
|
2012-05-08 09:16:40 +04:00
|
|
|
HTMLLIAccessible* listItem = accessible->AsHTMLListItem();
|
2011-03-28 17:59:54 +04:00
|
|
|
if (listItem)
|
|
|
|
listItem->UpdateBullet(aHasBullet);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-16 00:16:02 +04:00
|
|
|
void
|
|
|
|
nsAccessibilityService::UpdateImageMap(nsImageFrame* aImageFrame)
|
|
|
|
{
|
|
|
|
nsIPresShell* presShell = aImageFrame->PresContext()->PresShell();
|
2012-05-27 13:01:40 +04:00
|
|
|
DocAccessible* document = GetDocAccessible(presShell);
|
2012-03-16 00:16:02 +04:00
|
|
|
if (document) {
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* accessible =
|
2012-03-16 00:16:02 +04:00
|
|
|
document->GetAccessible(aImageFrame->GetContent());
|
|
|
|
if (accessible) {
|
2012-06-04 16:32:34 +04:00
|
|
|
HTMLImageMapAccessible* imageMap = accessible->AsImageMap();
|
2012-03-16 00:16:02 +04:00
|
|
|
if (imageMap) {
|
|
|
|
imageMap->UpdateChildAreas();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If image map was initialized after we created an accessible (that'll
|
|
|
|
// be an image accessible) then recreate it.
|
|
|
|
RecreateAccessible(presShell, aImageFrame->GetContent());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-01 08:06:16 +04:00
|
|
|
void
|
|
|
|
nsAccessibilityService::UpdateLabelValue(nsIPresShell* aPresShell,
|
|
|
|
nsIContent* aLabelElm,
|
|
|
|
const nsString& aNewValue)
|
|
|
|
{
|
|
|
|
DocAccessible* document = GetDocAccessible(aPresShell);
|
|
|
|
if (document) {
|
|
|
|
Accessible* accessible = document->GetAccessible(aLabelElm);
|
|
|
|
if (accessible) {
|
|
|
|
XULLabelAccessible* xulLabel = accessible->AsXULLabel();
|
|
|
|
NS_ASSERTION(xulLabel,
|
|
|
|
"UpdateLabelValue was called for wrong accessible!");
|
|
|
|
if (xulLabel)
|
|
|
|
xulLabel->UpdateLabelValue(aNewValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-02 17:41:42 +03:00
|
|
|
void
|
|
|
|
nsAccessibilityService::PresShellActivated(nsIPresShell* aPresShell)
|
|
|
|
{
|
2012-11-03 03:57:58 +04:00
|
|
|
DocAccessible* document = aPresShell->GetDocAccessible();
|
|
|
|
if (document) {
|
|
|
|
RootAccessible* rootDocument = document->RootAccessible();
|
|
|
|
NS_ASSERTION(rootDocument, "Entirely broken tree: no root document!");
|
|
|
|
if (rootDocument)
|
|
|
|
rootDocument->DocumentActivated(document);
|
2011-03-02 17:41:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-21 08:16:10 +04:00
|
|
|
void
|
|
|
|
nsAccessibilityService::RecreateAccessible(nsIPresShell* aPresShell,
|
|
|
|
nsIContent* aContent)
|
|
|
|
{
|
2012-05-27 13:01:40 +04:00
|
|
|
DocAccessible* document = GetDocAccessible(aPresShell);
|
2012-03-23 05:49:55 +04:00
|
|
|
if (document)
|
|
|
|
document->RecreateAccessible(aContent);
|
2010-10-21 08:16:10 +04:00
|
|
|
}
|
|
|
|
|
2010-02-21 03:56:35 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIAccessibleRetrieval
|
|
|
|
|
2010-03-18 08:45:10 +03:00
|
|
|
NS_IMETHODIMP
|
2012-04-25 15:29:40 +04:00
|
|
|
nsAccessibilityService::GetApplicationAccessible(nsIAccessible** aAccessibleApplication)
|
2010-03-18 08:45:10 +03:00
|
|
|
{
|
2010-03-18 21:49:39 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(aAccessibleApplication);
|
2010-03-18 08:45:10 +03:00
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
NS_IF_ADDREF(*aAccessibleApplication = XPCApplicationAcc());
|
2010-03-18 21:49:39 +03:00
|
|
|
return NS_OK;
|
2010-03-18 08:45:10 +03:00
|
|
|
}
|
|
|
|
|
2010-06-11 12:23:18 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsAccessibilityService::GetAccessibleFor(nsIDOMNode *aNode,
|
|
|
|
nsIAccessible **aAccessible)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aAccessible);
|
2012-07-30 18:20:58 +04:00
|
|
|
*aAccessible = nullptr;
|
2011-06-29 03:26:37 +04:00
|
|
|
if (!aNode)
|
|
|
|
return NS_OK;
|
2010-06-11 12:23:18 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsINode> node(do_QueryInterface(aNode));
|
2011-09-01 11:12:40 +04:00
|
|
|
if (!node)
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
|
2012-06-07 00:33:37 +04:00
|
|
|
DocAccessible* document = GetDocAccessible(node->OwnerDoc());
|
|
|
|
if (document)
|
2014-10-22 04:49:28 +04:00
|
|
|
NS_IF_ADDREF(*aAccessible = ToXPC(document->GetAccessible(node)));
|
2012-06-07 00:33:37 +04:00
|
|
|
|
2010-06-11 12:23:18 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-06-02 07:23:58 +04:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsAccessibilityService::GetStringRole(uint32_t aRole, nsAString& aString)
|
2007-06-02 07:23:58 +04:00
|
|
|
{
|
2012-07-21 22:32:25 +04:00
|
|
|
#define ROLE(geckoRole, stringRole, atkRole, \
|
|
|
|
macRole, msaaRole, ia2Role, nameRule) \
|
2012-04-26 22:25:33 +04:00
|
|
|
case roles::geckoRole: \
|
|
|
|
CopyUTF8toUTF16(stringRole, aString); \
|
2007-06-02 07:23:58 +04:00
|
|
|
return NS_OK;
|
2012-04-26 22:25:33 +04:00
|
|
|
|
|
|
|
switch (aRole) {
|
|
|
|
#include "RoleMap.h"
|
|
|
|
default:
|
|
|
|
aString.AssignLiteral("unknown");
|
|
|
|
return NS_OK;
|
2007-06-02 07:23:58 +04:00
|
|
|
}
|
|
|
|
|
2012-04-26 22:25:33 +04:00
|
|
|
#undef ROLE
|
2007-06-02 07:23:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsAccessibilityService::GetStringStates(uint32_t aState, uint32_t aExtraState,
|
2013-07-09 21:54:21 +04:00
|
|
|
nsISupports **aStringStates)
|
2007-06-02 07:23:58 +04:00
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<DOMStringList> stringStates = new DOMStringList();
|
2007-06-02 07:23:58 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint64_t state = nsAccUtils::To64State(aState, aExtraState);
|
2011-04-10 03:38:06 +04:00
|
|
|
|
|
|
|
// states
|
|
|
|
if (state & states::UNAVAILABLE)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("unavailable"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::SELECTED)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("selected"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::FOCUSED)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("focused"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::PRESSED)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("pressed"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::CHECKED)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("checked"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::MIXED)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("mixed"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::READONLY)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("readonly"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::HOTTRACKED)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("hottracked"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::DEFAULT)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("default"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::EXPANDED)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("expanded"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::COLLAPSED)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("collapsed"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::BUSY)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("busy"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::FLOATING)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("floating"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::ANIMATED)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("animated"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::INVISIBLE)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("invisible"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::OFFSCREEN)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("offscreen"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::SIZEABLE)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("sizeable"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::MOVEABLE)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("moveable"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::SELFVOICING)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("selfvoicing"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::FOCUSABLE)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("focusable"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::SELECTABLE)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("selectable"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::LINKED)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("linked"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::TRAVERSED)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("traversed"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::MULTISELECTABLE)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("multiselectable"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::EXTSELECTABLE)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("extselectable"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::PROTECTED)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("protected"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::HASPOPUP)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("haspopup"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::REQUIRED)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("required"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::ALERT)
|
|
|
|
stringStates->Add(NS_LITERAL_STRING("alert"));
|
|
|
|
if (state & states::INVALID)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("invalid"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::CHECKABLE)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("checkable"));
|
|
|
|
|
2011-04-10 03:38:06 +04:00
|
|
|
// extraStates
|
|
|
|
if (state & states::SUPPORTS_AUTOCOMPLETION)
|
2007-07-16 11:57:46 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("autocompletion"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::DEFUNCT)
|
2007-07-16 11:57:46 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("defunct"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::SELECTABLE_TEXT)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("selectable text"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::EDITABLE)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("editable"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::ACTIVE)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("active"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::MODAL)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("modal"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::MULTI_LINE)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("multi line"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::HORIZONTAL)
|
2007-07-16 11:57:46 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("horizontal"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::OPAQUE1)
|
2007-07-16 11:57:46 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("opaque"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::SINGLE_LINE)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("single line"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::TRANSIENT)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("transient"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::VERTICAL)
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("vertical"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::STALE)
|
2007-07-16 11:57:46 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("stale"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::ENABLED)
|
2007-07-16 11:57:46 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("enabled"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::SENSITIVE)
|
2007-07-16 11:57:46 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("sensitive"));
|
2011-04-10 03:38:06 +04:00
|
|
|
if (state & states::EXPANDABLE)
|
2007-07-16 11:57:46 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("expandable"));
|
2007-06-02 07:23:58 +04:00
|
|
|
|
|
|
|
//unknown states
|
2013-07-09 21:54:21 +04:00
|
|
|
if (!stringStates->Length())
|
2007-06-02 07:23:58 +04:00
|
|
|
stringStates->Add(NS_LITERAL_STRING("unknown"));
|
|
|
|
|
2013-07-09 21:54:21 +04:00
|
|
|
stringStates.forget(aStringStates);
|
2007-06-02 07:23:58 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-08-23 07:26:38 +04:00
|
|
|
// nsIAccessibleRetrieval::getStringEventType()
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsAccessibilityService::GetStringEventType(uint32_t aEventType,
|
2007-08-23 07:26:38 +04:00
|
|
|
nsAString& aString)
|
|
|
|
{
|
2011-10-11 09:50:08 +04:00
|
|
|
NS_ASSERTION(nsIAccessibleEvent::EVENT_LAST_ENTRY == ArrayLength(kEventTypeNames),
|
2007-09-25 07:36:51 +04:00
|
|
|
"nsIAccessibleEvent constants are out of sync to kEventTypeNames");
|
|
|
|
|
2011-10-11 09:50:08 +04:00
|
|
|
if (aEventType >= ArrayLength(kEventTypeNames)) {
|
2007-08-23 07:26:38 +04:00
|
|
|
aString.AssignLiteral("unknown");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
CopyUTF8toUTF16(kEventTypeNames[aEventType], aString);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-10-11 06:02:09 +04:00
|
|
|
// nsIAccessibleRetrieval::getStringRelationType()
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsAccessibilityService::GetStringRelationType(uint32_t aRelationType,
|
2007-10-11 06:02:09 +04:00
|
|
|
nsAString& aString)
|
|
|
|
{
|
2013-10-23 03:55:27 +04:00
|
|
|
NS_ENSURE_ARG(aRelationType <= static_cast<uint32_t>(RelationType::LAST));
|
|
|
|
|
|
|
|
#define RELATIONTYPE(geckoType, geckoTypeName, atkType, msaaType, ia2Type) \
|
|
|
|
case RelationType::geckoType: \
|
|
|
|
aString.AssignLiteral(geckoTypeName); \
|
2007-10-11 06:02:09 +04:00
|
|
|
return NS_OK;
|
2013-10-23 03:55:27 +04:00
|
|
|
|
|
|
|
RelationType relationType = static_cast<RelationType>(aRelationType);
|
|
|
|
switch (relationType) {
|
|
|
|
#include "RelationTypeMap.h"
|
|
|
|
default:
|
|
|
|
aString.AssignLiteral("unknown");
|
|
|
|
return NS_OK;
|
2007-10-11 06:02:09 +04:00
|
|
|
}
|
|
|
|
|
2013-10-23 03:55:27 +04:00
|
|
|
#undef RELATIONTYPE
|
2010-06-18 06:43:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsAccessibilityService::GetAccessibleFromCache(nsIDOMNode* aNode,
|
|
|
|
nsIAccessible** aAccessible)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aAccessible);
|
2012-07-30 18:20:58 +04:00
|
|
|
*aAccessible = nullptr;
|
2011-09-01 11:12:40 +04:00
|
|
|
if (!aNode)
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
nsCOMPtr<nsINode> node(do_QueryInterface(aNode));
|
|
|
|
if (!node)
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
2010-06-18 06:43:58 +04:00
|
|
|
|
|
|
|
// Search for an accessible in each of our per document accessible object
|
|
|
|
// caches. If we don't find it, and the given node is itself a document, check
|
|
|
|
// our cache of document accessibles (document cache). Note usually shutdown
|
|
|
|
// document accessibles are not stored in the document cache, however an
|
2012-11-20 18:15:32 +04:00
|
|
|
// "unofficially" shutdown document (i.e. not from DocManager) can still
|
2010-06-18 06:43:58 +04:00
|
|
|
// exist in the document cache.
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible* accessible = FindAccessibleInCache(node);
|
2010-06-18 06:43:58 +04:00
|
|
|
if (!accessible) {
|
|
|
|
nsCOMPtr<nsIDocument> document(do_QueryInterface(node));
|
|
|
|
if (document)
|
2012-11-03 03:57:58 +04:00
|
|
|
accessible = GetExistingDocAccessible(document);
|
2010-06-18 06:43:58 +04:00
|
|
|
}
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
NS_IF_ADDREF(*aAccessible = ToXPC(accessible));
|
2010-06-18 06:43:58 +04:00
|
|
|
return NS_OK;
|
2007-10-11 06:02:09 +04:00
|
|
|
}
|
|
|
|
|
2012-02-02 10:14:51 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsAccessibilityService::CreateAccessiblePivot(nsIAccessible* aRoot,
|
|
|
|
nsIAccessiblePivot** aPivot)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aPivot);
|
|
|
|
NS_ENSURE_ARG(aRoot);
|
2012-07-30 18:20:58 +04:00
|
|
|
*aPivot = nullptr;
|
2012-02-02 10:14:51 +04:00
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
Accessible* accessibleRoot = aRoot->ToInternalAccessible();
|
2012-02-02 10:14:51 +04:00
|
|
|
NS_ENSURE_TRUE(accessibleRoot, NS_ERROR_INVALID_ARG);
|
|
|
|
|
|
|
|
nsAccessiblePivot* pivot = new nsAccessiblePivot(accessibleRoot);
|
|
|
|
NS_ADDREF(*aPivot = pivot);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-05-23 13:21:40 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsAccessibilityService::SetLogging(const nsACString& aModules)
|
|
|
|
{
|
2012-10-04 13:57:09 +04:00
|
|
|
#ifdef A11Y_LOG
|
2012-05-23 13:21:40 +04:00
|
|
|
logging::Enable(PromiseFlatCString(aModules));
|
|
|
|
#endif
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-11-04 06:19:56 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsAccessibilityService::IsLogged(const nsAString& aModule, bool* aIsLogged)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aIsLogged);
|
|
|
|
*aIsLogged = false;
|
|
|
|
|
|
|
|
#ifdef A11Y_LOG
|
|
|
|
*aIsLogged = logging::IsEnabled(aModule);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-02-21 03:56:35 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsAccessibilityService public
|
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible*
|
2016-04-06 14:23:41 +03:00
|
|
|
nsAccessibilityService::CreateAccessible(nsINode* aNode,
|
|
|
|
Accessible* aContext,
|
|
|
|
bool* aIsSubtreeHidden)
|
2001-09-26 02:32:32 +04:00
|
|
|
{
|
2016-04-06 14:23:41 +03:00
|
|
|
MOZ_ASSERT(aContext, "No context provided");
|
|
|
|
MOZ_ASSERT(aNode, "No node to create an accessible for");
|
|
|
|
MOZ_ASSERT(!gIsShutdown, "No creation after shutdown");
|
2001-10-31 09:10:44 +03:00
|
|
|
|
2010-11-13 20:49:26 +03:00
|
|
|
if (aIsSubtreeHidden)
|
|
|
|
*aIsSubtreeHidden = false;
|
2009-11-16 17:03:53 +03:00
|
|
|
|
2012-11-30 11:33:01 +04:00
|
|
|
DocAccessible* document = aContext->Document();
|
2016-04-06 14:23:41 +03:00
|
|
|
MOZ_ASSERT(!document->GetAccessible(aNode),
|
|
|
|
"We already have an accessible for this node.");
|
2008-06-11 10:27:22 +04:00
|
|
|
|
2010-06-11 12:23:18 +04:00
|
|
|
if (aNode->IsNodeOfType(nsINode::eDOCUMENT)) {
|
2010-06-08 20:39:58 +04:00
|
|
|
// If it's document node then ask accessible document loader for
|
|
|
|
// document accessible, otherwise return null.
|
|
|
|
nsCOMPtr<nsIDocument> document(do_QueryInterface(aNode));
|
2011-03-31 13:30:58 +04:00
|
|
|
return GetDocAccessible(document);
|
2001-06-30 04:25:09 +04:00
|
|
|
}
|
2001-08-03 12:15:20 +04:00
|
|
|
|
2010-02-21 03:56:35 +03:00
|
|
|
// We have a content node.
|
2014-06-18 21:58:52 +04:00
|
|
|
if (!aNode->GetCrossShadowCurrentDoc()) {
|
2010-06-08 20:39:58 +04:00
|
|
|
NS_WARNING("Creating accessible for node with no document");
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2005-09-09 06:30:16 +04:00
|
|
|
}
|
2010-02-21 03:56:35 +03:00
|
|
|
|
2012-11-30 11:33:01 +04:00
|
|
|
if (aNode->OwnerDoc() != document->DocumentNode()) {
|
2012-02-09 20:49:17 +04:00
|
|
|
NS_ERROR("Creating accessible for wrong document");
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2005-09-09 06:30:16 +04:00
|
|
|
}
|
|
|
|
|
2012-09-06 01:41:10 +04:00
|
|
|
if (!aNode->IsContent())
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2010-06-11 12:23:18 +04:00
|
|
|
|
2012-09-06 01:41:10 +04:00
|
|
|
nsIContent* content = aNode->AsContent();
|
|
|
|
nsIFrame* frame = content->GetPrimaryFrame();
|
2009-11-16 17:03:53 +03:00
|
|
|
|
2010-11-13 20:49:26 +03:00
|
|
|
// Check frame and its visibility. Note, hidden frame allows visible
|
|
|
|
// elements in subtree.
|
2013-02-17 01:51:02 +04:00
|
|
|
if (!frame || !frame->StyleVisibility()->IsVisible()) {
|
2012-09-06 01:41:10 +04:00
|
|
|
if (aIsSubtreeHidden && !frame)
|
2010-11-13 20:49:26 +03:00
|
|
|
*aIsSubtreeHidden = true;
|
2006-05-01 19:52:56 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2010-02-21 03:56:35 +03:00
|
|
|
}
|
|
|
|
|
2012-09-06 01:41:10 +04:00
|
|
|
if (frame->GetContent() != content) {
|
2010-04-08 10:43:08 +04:00
|
|
|
// Not the main content for this frame. This happens because <area>
|
|
|
|
// elements return the image frame as their primary frame. The main content
|
|
|
|
// for the image frame is the image content. If the frame is not an image
|
|
|
|
// frame or the node is not an area element then null is returned.
|
2011-10-04 17:05:17 +04:00
|
|
|
// This setup will change when bug 135040 is fixed. Make sure we don't
|
|
|
|
// create area accessible here. Hopefully assertion below will handle that.
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2012-09-06 01:41:10 +04:00
|
|
|
nsImageFrame* imageFrame = do_QueryFrame(frame);
|
2015-03-03 14:08:59 +03:00
|
|
|
NS_ASSERTION(imageFrame && content->IsHTMLElement(nsGkAtoms::area),
|
2011-10-04 17:05:17 +04:00
|
|
|
"Unknown case of not main content for the frame!");
|
|
|
|
#endif
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2004-05-26 17:01:13 +04:00
|
|
|
}
|
2001-06-30 04:25:09 +04:00
|
|
|
|
2011-10-04 17:05:17 +04:00
|
|
|
#ifdef DEBUG
|
2012-09-06 01:41:10 +04:00
|
|
|
nsImageFrame* imageFrame = do_QueryFrame(frame);
|
2015-03-03 14:08:59 +03:00
|
|
|
NS_ASSERTION(!imageFrame || !content->IsHTMLElement(nsGkAtoms::area),
|
2011-10-04 17:05:17 +04:00
|
|
|
"Image map manages the area accessible creation!");
|
|
|
|
#endif
|
|
|
|
|
2010-02-21 03:56:35 +03:00
|
|
|
// Attempt to create an accessible based on what we know.
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Accessible> newAcc;
|
2011-01-31 18:53:09 +03:00
|
|
|
|
|
|
|
// Create accessible for visible text frames.
|
2006-05-05 10:52:21 +04:00
|
|
|
if (content->IsNodeOfType(nsINode::eTEXT)) {
|
2015-11-30 16:21:25 +03:00
|
|
|
nsIFrame::RenderedText text = frame->GetRenderedText(0,
|
|
|
|
UINT32_MAX, nsIFrame::TextOffsetType::OFFSETS_IN_CONTENT_TEXT,
|
|
|
|
nsIFrame::TrailingWhitespace::DONT_TRIM_TRAILING_WHITESPACE);
|
2013-07-18 19:09:45 +04:00
|
|
|
// Ignore not rendered text nodes and whitespace text nodes between table
|
|
|
|
// cells.
|
2015-10-30 09:23:10 +03:00
|
|
|
if (text.mString.IsEmpty() ||
|
|
|
|
(aContext->IsTableRow() && nsCoreUtils::IsWhitespaceString(text.mString))) {
|
2011-01-31 18:53:09 +03:00
|
|
|
if (aIsSubtreeHidden)
|
|
|
|
*aIsSubtreeHidden = true;
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2009-11-16 17:03:53 +03:00
|
|
|
}
|
2009-11-19 02:42:18 +03:00
|
|
|
|
2012-11-30 11:33:01 +04:00
|
|
|
newAcc = CreateAccessibleByFrameType(frame, content, aContext);
|
2013-09-06 23:27:07 +04:00
|
|
|
document->BindToDocument(newAcc, nullptr);
|
2015-10-30 09:23:10 +03:00
|
|
|
newAcc->AsTextLeaf()->SetText(text.mString);
|
2013-09-06 23:27:07 +04:00
|
|
|
return newAcc;
|
2004-05-26 17:01:13 +04:00
|
|
|
}
|
2006-07-13 16:55:15 +04:00
|
|
|
|
2015-03-03 14:08:59 +03:00
|
|
|
if (content->IsHTMLElement(nsGkAtoms::map)) {
|
2008-06-11 10:27:22 +04:00
|
|
|
// Create hyper text accessible for HTML map if it is used to group links
|
|
|
|
// (see http://www.w3.org/TR/WCAG10-HTML-TECHS/#group-bypass). If the HTML
|
2011-10-05 10:24:44 +04:00
|
|
|
// map rect is empty then it is used for links grouping. Otherwise it should
|
|
|
|
// be used in conjunction with HTML image element and in this case we don't
|
|
|
|
// create any accessible for it and don't walk into it. The accessibles for
|
2012-06-04 16:32:34 +04:00
|
|
|
// HTML area (HTMLAreaAccessible) the map contains are attached as
|
2011-10-05 10:24:44 +04:00
|
|
|
// children of the appropriate accessible for HTML image
|
2012-06-02 15:30:34 +04:00
|
|
|
// (ImageAccessible).
|
2012-09-06 01:41:10 +04:00
|
|
|
if (nsLayoutUtils::GetAllInFlowRectsUnion(frame,
|
|
|
|
frame->GetParent()).IsEmpty()) {
|
2010-11-13 20:49:26 +03:00
|
|
|
if (aIsSubtreeHidden)
|
|
|
|
*aIsSubtreeHidden = true;
|
2010-02-21 03:56:35 +03:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2008-06-11 10:27:22 +04:00
|
|
|
}
|
2010-02-21 03:56:35 +03:00
|
|
|
|
2012-11-30 11:33:01 +04:00
|
|
|
newAcc = new HyperTextAccessibleWrap(content, document);
|
2016-03-03 15:45:47 +03:00
|
|
|
document->BindToDocument(newAcc, aria::GetRoleMap(content->AsElement()));
|
2013-09-06 23:27:07 +04:00
|
|
|
return newAcc;
|
2008-06-11 10:27:22 +04:00
|
|
|
}
|
|
|
|
|
2016-03-11 05:13:01 +03:00
|
|
|
const nsRoleMapEntry* roleMapEntry = aria::GetRoleMap(content->AsElement());
|
2012-09-18 06:51:39 +04:00
|
|
|
|
|
|
|
// If the element is focusable or global ARIA attribute is applied to it or
|
|
|
|
// it is referenced by ARIA relationship then treat role="presentation" on
|
|
|
|
// the element as the role is not there.
|
2015-02-19 20:50:34 +03:00
|
|
|
if (roleMapEntry &&
|
|
|
|
(roleMapEntry->Is(nsGkAtoms::presentation) ||
|
|
|
|
roleMapEntry->Is(nsGkAtoms::none))) {
|
2012-11-30 11:33:01 +04:00
|
|
|
if (!MustBeAccessible(content, document))
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2012-09-18 06:51:39 +04:00
|
|
|
|
|
|
|
roleMapEntry = nullptr;
|
2006-07-13 16:55:15 +04:00
|
|
|
}
|
|
|
|
|
2015-03-03 14:08:59 +03:00
|
|
|
if (!newAcc && content->IsHTMLElement()) { // HTML accessibles
|
2015-06-27 00:41:22 +03:00
|
|
|
bool isARIATablePart = roleMapEntry &&
|
|
|
|
(roleMapEntry->accTypes & (eTableCell | eTableRow | eTable));
|
2015-02-14 04:09:51 +03:00
|
|
|
|
2015-06-27 00:41:22 +03:00
|
|
|
if (!isARIATablePart ||
|
2015-02-14 04:09:51 +03:00
|
|
|
frame->AccessibleType() == eHTMLTableCellType ||
|
2015-06-27 00:41:22 +03:00
|
|
|
frame->AccessibleType() == eHTMLTableRowType ||
|
2015-02-14 04:09:51 +03:00
|
|
|
frame->AccessibleType() == eHTMLTableType) {
|
2015-03-05 06:56:57 +03:00
|
|
|
// Prefer to use markup to decide if and what kind of accessible to create,
|
2015-03-05 21:16:12 +03:00
|
|
|
const MarkupMapInfo* markupMap =
|
|
|
|
mMarkupMaps.Get(content->NodeInfo()->NameAtom());
|
|
|
|
if (markupMap && markupMap->new_func)
|
|
|
|
newAcc = markupMap->new_func(content, aContext);
|
2015-03-05 06:56:57 +03:00
|
|
|
|
2015-02-14 04:09:51 +03:00
|
|
|
if (!newAcc) // try by frame accessible type.
|
|
|
|
newAcc = CreateAccessibleByFrameType(frame, content, aContext);
|
|
|
|
}
|
|
|
|
|
2015-06-27 00:41:22 +03:00
|
|
|
// In case of ARIA grid or table use table-specific classes if it's not
|
|
|
|
// native table based.
|
|
|
|
if (isARIATablePart && (!newAcc || newAcc->IsGenericHyperText())) {
|
2012-12-18 09:22:26 +04:00
|
|
|
if ((roleMapEntry->accTypes & eTableCell)) {
|
2015-02-14 04:09:51 +03:00
|
|
|
if (aContext->IsTableRow())
|
2012-11-30 11:33:01 +04:00
|
|
|
newAcc = new ARIAGridCellAccessibleWrap(content, document);
|
|
|
|
|
2015-06-27 00:41:22 +03:00
|
|
|
} else if (roleMapEntry->IsOfType(eTableRow)) {
|
|
|
|
if (aContext->IsTable())
|
|
|
|
newAcc = new ARIARowAccessible(content, document);
|
|
|
|
|
2015-02-14 04:09:51 +03:00
|
|
|
} else if (roleMapEntry->IsOfType(eTable)) {
|
2012-11-30 11:33:01 +04:00
|
|
|
newAcc = new ARIAGridAccessibleWrap(content, document);
|
2009-05-18 12:35:21 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-14 04:09:51 +03:00
|
|
|
// If table has strong ARIA role then all table descendants shouldn't
|
|
|
|
// expose their native roles.
|
|
|
|
if (!roleMapEntry && newAcc && aContext->HasStrongARIARole()) {
|
|
|
|
if (frame->AccessibleType() == eHTMLTableRowType) {
|
2016-03-11 05:13:01 +03:00
|
|
|
const nsRoleMapEntry* contextRoleMap = aContext->ARIARoleMap();
|
2015-02-14 04:09:51 +03:00
|
|
|
if (!contextRoleMap->IsOfType(eTable))
|
|
|
|
roleMapEntry = &aria::gEmptyRoleMap;
|
2012-11-30 11:33:01 +04:00
|
|
|
|
2015-02-14 04:09:51 +03:00
|
|
|
} else if (frame->AccessibleType() == eHTMLTableCellType &&
|
|
|
|
aContext->ARIARoleMap() == &aria::gEmptyRoleMap) {
|
|
|
|
roleMapEntry = &aria::gEmptyRoleMap;
|
2012-11-30 11:33:01 +04:00
|
|
|
|
2015-03-03 14:08:59 +03:00
|
|
|
} else if (content->IsAnyOfHTMLElements(nsGkAtoms::dt,
|
|
|
|
nsGkAtoms::li,
|
|
|
|
nsGkAtoms::dd) ||
|
2015-02-14 04:09:51 +03:00
|
|
|
frame->AccessibleType() == eHTMLLiType) {
|
2016-03-11 05:13:01 +03:00
|
|
|
const nsRoleMapEntry* contextRoleMap = aContext->ARIARoleMap();
|
2015-02-14 04:09:51 +03:00
|
|
|
if (!contextRoleMap->IsOfType(eList))
|
2013-04-25 07:48:26 +04:00
|
|
|
roleMapEntry = &aria::gEmptyRoleMap;
|
2012-11-30 11:33:01 +04:00
|
|
|
}
|
2006-07-13 16:55:15 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-28 12:15:02 +04:00
|
|
|
// Accessible XBL types and deck stuff are used in XUL only currently.
|
2015-03-03 14:08:59 +03:00
|
|
|
if (!newAcc && content->IsXULElement()) {
|
2012-12-28 12:15:02 +04:00
|
|
|
// No accessible for not selected deck panel and its children.
|
|
|
|
if (!aContext->IsXULTabpanels()) {
|
|
|
|
nsDeckFrame* deckFrame = do_QueryFrame(frame->GetParent());
|
|
|
|
if (deckFrame && deckFrame->GetSelectedBox() != frame) {
|
|
|
|
if (aIsSubtreeHidden)
|
|
|
|
*aIsSubtreeHidden = true;
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-05 20:07:53 +04:00
|
|
|
// XBL bindings may use @role attribute to point the accessible type
|
|
|
|
// they belong to.
|
2012-11-30 11:33:01 +04:00
|
|
|
newAcc = CreateAccessibleByType(content, document);
|
2012-12-28 12:15:02 +04:00
|
|
|
|
|
|
|
// Any XUL box can be used as tabpanel, make sure we create a proper
|
|
|
|
// accessible for it.
|
|
|
|
if (!newAcc && aContext->IsXULTabpanels() &&
|
|
|
|
content->GetParent() == aContext->GetContent()) {
|
|
|
|
nsIAtom* frameType = frame->GetType();
|
|
|
|
if (frameType == nsGkAtoms::boxFrame ||
|
|
|
|
frameType == nsGkAtoms::scrollFrame) {
|
|
|
|
newAcc = new XULTabpanelAccessible(content, document);
|
|
|
|
}
|
|
|
|
}
|
2009-05-18 12:35:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!newAcc) {
|
2015-03-03 14:08:59 +03:00
|
|
|
if (content->IsSVGElement()) {
|
2013-01-04 08:26:00 +04:00
|
|
|
nsSVGPathGeometryFrame* pathGeometryFrame = do_QueryFrame(frame);
|
|
|
|
if (pathGeometryFrame) {
|
|
|
|
// A graphic elements: rect, circle, ellipse, line, path, polygon,
|
|
|
|
// polyline and image. A 'use' and 'text' graphic elements require
|
|
|
|
// special support.
|
2015-03-05 03:04:46 +03:00
|
|
|
newAcc = new EnumRoleAccessible<roles::GRAPHIC>(content, document);
|
2015-03-03 14:08:59 +03:00
|
|
|
} else if (content->IsSVGElement(nsGkAtoms::svg)) {
|
2015-03-05 03:04:46 +03:00
|
|
|
newAcc = new EnumRoleAccessible<roles::DIAGRAM>(content, document);
|
2013-01-04 08:26:00 +04:00
|
|
|
}
|
2015-03-09 15:16:12 +03:00
|
|
|
|
2015-03-03 14:08:59 +03:00
|
|
|
} else if (content->IsMathMLElement()) {
|
2015-03-09 15:16:12 +03:00
|
|
|
const MarkupMapInfo* markupMap =
|
|
|
|
mMarkupMaps.Get(content->NodeInfo()->NameAtom());
|
|
|
|
if (markupMap && markupMap->new_func)
|
|
|
|
newAcc = markupMap->new_func(content, aContext);
|
|
|
|
|
|
|
|
// Fall back to text when encountering Content MathML.
|
2015-06-16 17:15:00 +03:00
|
|
|
if (!newAcc && !content->IsAnyOfMathMLElements(nsGkAtoms::annotation_,
|
|
|
|
nsGkAtoms::annotation_xml_,
|
|
|
|
nsGkAtoms::mpadded_,
|
2015-03-09 15:16:12 +03:00
|
|
|
nsGkAtoms::mphantom_,
|
|
|
|
nsGkAtoms::maligngroup_,
|
|
|
|
nsGkAtoms::malignmark_,
|
2015-06-16 17:15:00 +03:00
|
|
|
nsGkAtoms::mspace_,
|
|
|
|
nsGkAtoms::semantics_)) {
|
|
|
|
newAcc = new HyperTextAccessible(content, document);
|
2015-03-09 15:16:12 +03:00
|
|
|
}
|
2009-05-18 12:35:21 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-13 16:55:15 +04:00
|
|
|
// If no accessible, see if we need to create a generic accessible because
|
|
|
|
// of some property that makes this object interesting
|
2012-06-04 16:32:38 +04:00
|
|
|
// We don't do this for <body>, <html>, <window>, <dialog> etc. which
|
2006-08-17 17:21:41 +04:00
|
|
|
// correspond to the doc accessible and will be created in any case
|
2015-03-03 14:08:59 +03:00
|
|
|
if (!newAcc && !content->IsHTMLElement(nsGkAtoms::body) &&
|
|
|
|
content->GetParent() &&
|
2012-11-30 11:33:01 +04:00
|
|
|
(roleMapEntry || MustBeAccessible(content, document) ||
|
2015-03-03 14:08:59 +03:00
|
|
|
(content->IsHTMLElement() &&
|
|
|
|
nsCoreUtils::HasClickListener(content)))) {
|
2006-07-13 16:55:15 +04:00
|
|
|
// This content is focusable or has an interesting dynamic content accessibility property.
|
|
|
|
// If it's interesting we need it in the accessibility hierarchy so that events or
|
|
|
|
// other accessibles can point to it, or so that it can hold a state, etc.
|
2015-03-03 14:08:59 +03:00
|
|
|
if (content->IsHTMLElement()) {
|
2006-07-13 16:55:15 +04:00
|
|
|
// Interesting HTML container which may have selectable text and/or embedded objects
|
2012-11-30 11:33:01 +04:00
|
|
|
newAcc = new HyperTextAccessibleWrap(content, document);
|
2012-09-06 01:41:10 +04:00
|
|
|
} else { // XUL, SVG, MathML etc.
|
2006-07-13 16:55:15 +04:00
|
|
|
// Interesting generic non-HTML container
|
2012-11-30 11:33:01 +04:00
|
|
|
newAcc = new AccessibleWrap(content, document);
|
2001-08-14 10:01:48 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-24 16:01:21 +03:00
|
|
|
if (newAcc) {
|
|
|
|
document->BindToDocument(newAcc, roleMapEntry);
|
|
|
|
}
|
2013-09-06 23:27:07 +04:00
|
|
|
return newAcc;
|
2001-06-30 04:25:09 +04:00
|
|
|
}
|
|
|
|
|
2010-06-08 20:39:58 +04:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsAccessibilityService private
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2010-06-08 20:39:58 +04:00
|
|
|
nsAccessibilityService::Init()
|
|
|
|
{
|
|
|
|
// Initialize accessible document manager.
|
2012-11-20 18:15:32 +04:00
|
|
|
if (!DocManager::Init())
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2010-06-08 20:39:58 +04:00
|
|
|
|
|
|
|
// Add observers.
|
|
|
|
nsCOMPtr<nsIObserverService> observerService =
|
|
|
|
mozilla::services::GetObserverService();
|
|
|
|
if (!observerService)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2010-06-08 20:39:58 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false);
|
2010-06-08 20:39:58 +04:00
|
|
|
|
2014-01-04 19:02:17 +04:00
|
|
|
static const char16_t kInitIndicator[] = { '1', 0 };
|
2012-07-30 18:20:58 +04:00
|
|
|
observerService->NotifyObservers(nullptr, "a11y-init-or-shutdown", kInitIndicator);
|
2012-05-07 13:14:27 +04:00
|
|
|
|
2015-08-05 06:35:54 +03:00
|
|
|
// Subscribe to EventListenerService.
|
|
|
|
nsCOMPtr<nsIEventListenerService> eventListenerService =
|
|
|
|
do_GetService("@mozilla.org/eventlistenerservice;1");
|
|
|
|
if (!eventListenerService)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
eventListenerService->AddListenerChangeListener(this);
|
|
|
|
|
2015-03-05 06:56:57 +03:00
|
|
|
for (uint32_t i = 0; i < ArrayLength(sMarkupMapList); i++)
|
2015-03-05 21:16:12 +03:00
|
|
|
mMarkupMaps.Put(*sMarkupMapList[i].tag, &sMarkupMapList[i]);
|
2015-03-05 06:56:57 +03:00
|
|
|
|
2012-10-04 13:57:09 +04:00
|
|
|
#ifdef A11Y_LOG
|
2012-05-23 13:21:40 +04:00
|
|
|
logging::CheckEnv();
|
|
|
|
#endif
|
|
|
|
|
2016-04-01 17:57:06 +03:00
|
|
|
gAccessibilityService = this;
|
|
|
|
|
2015-07-04 04:29:00 +03:00
|
|
|
if (XRE_IsParentProcess())
|
2014-06-10 23:54:06 +04:00
|
|
|
gApplicationAccessible = new ApplicationAccessibleWrap();
|
|
|
|
else
|
|
|
|
gApplicationAccessible = new ApplicationAccessible();
|
|
|
|
|
2012-09-10 17:20:26 +04:00
|
|
|
NS_ADDREF(gApplicationAccessible); // will release in Shutdown()
|
2016-04-01 17:57:06 +03:00
|
|
|
gApplicationAccessible->Init();
|
2012-09-10 17:20:26 +04:00
|
|
|
|
2012-07-20 22:43:49 +04:00
|
|
|
#ifdef MOZ_CRASHREPORTER
|
|
|
|
CrashReporter::
|
|
|
|
AnnotateCrashReport(NS_LITERAL_CSTRING("Accessibility"),
|
|
|
|
NS_LITERAL_CSTRING("Active"));
|
|
|
|
#endif
|
|
|
|
|
2013-02-27 02:07:24 +04:00
|
|
|
#ifdef XP_WIN
|
|
|
|
sPendingPlugins = new nsTArray<nsCOMPtr<nsIContent> >;
|
|
|
|
sPluginTimers = new nsTArray<nsCOMPtr<nsITimer> >;
|
|
|
|
#endif
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
gIsShutdown = false;
|
2012-12-02 04:58:25 +04:00
|
|
|
|
|
|
|
// Now its safe to start platform accessibility.
|
2015-07-04 04:29:00 +03:00
|
|
|
if (XRE_IsParentProcess())
|
2014-06-10 23:54:06 +04:00
|
|
|
PlatformInit();
|
2012-12-02 04:58:25 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2010-06-08 20:39:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsAccessibilityService::Shutdown()
|
|
|
|
{
|
|
|
|
// Remove observers.
|
|
|
|
nsCOMPtr<nsIObserverService> observerService =
|
|
|
|
mozilla::services::GetObserverService();
|
2012-05-07 13:14:27 +04:00
|
|
|
if (observerService) {
|
2010-06-08 20:39:58 +04:00
|
|
|
observerService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
|
|
|
|
|
2014-01-04 19:02:17 +04:00
|
|
|
static const char16_t kShutdownIndicator[] = { '0', 0 };
|
2012-07-30 18:20:58 +04:00
|
|
|
observerService->NotifyObservers(nullptr, "a11y-init-or-shutdown", kShutdownIndicator);
|
2012-05-07 13:14:27 +04:00
|
|
|
}
|
|
|
|
|
2010-06-08 20:39:58 +04:00
|
|
|
// Stop accessible document loader.
|
2012-11-20 18:15:32 +04:00
|
|
|
DocManager::Shutdown();
|
2010-06-08 20:39:58 +04:00
|
|
|
|
2013-03-07 16:16:10 +04:00
|
|
|
SelectionManager::Shutdown();
|
|
|
|
|
2013-02-27 02:07:24 +04:00
|
|
|
#ifdef XP_WIN
|
|
|
|
sPendingPlugins = nullptr;
|
|
|
|
|
|
|
|
uint32_t timerCount = sPluginTimers->Length();
|
|
|
|
for (uint32_t i = 0; i < timerCount; i++)
|
|
|
|
sPluginTimers->ElementAt(i)->Cancel();
|
|
|
|
|
|
|
|
sPluginTimers = nullptr;
|
|
|
|
#endif
|
|
|
|
|
2010-06-08 20:39:58 +04:00
|
|
|
// Application is going to be closed, shutdown accessibility and mark
|
|
|
|
// accessibility service as shutdown to prevent calls of its methods.
|
|
|
|
// Don't null accessibility service static member at this point to be safe
|
|
|
|
// if someone will try to operate with it.
|
|
|
|
|
|
|
|
NS_ASSERTION(!gIsShutdown, "Accessibility was shutdown already");
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
gIsShutdown = true;
|
2010-06-08 20:39:58 +04:00
|
|
|
|
2015-07-04 04:29:00 +03:00
|
|
|
if (XRE_IsParentProcess())
|
2014-06-10 23:54:06 +04:00
|
|
|
PlatformShutdown();
|
|
|
|
|
2012-09-10 17:20:26 +04:00
|
|
|
gApplicationAccessible->Shutdown();
|
|
|
|
NS_RELEASE(gApplicationAccessible);
|
|
|
|
gApplicationAccessible = nullptr;
|
2014-10-22 04:49:28 +04:00
|
|
|
|
|
|
|
NS_IF_RELEASE(gXPCApplicationAccessible);
|
|
|
|
gXPCApplicationAccessible = nullptr;
|
2010-06-08 20:39:58 +04:00
|
|
|
}
|
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
already_AddRefed<Accessible>
|
2010-06-28 16:02:03 +04:00
|
|
|
nsAccessibilityService::CreateAccessibleByType(nsIContent* aContent,
|
2012-05-27 13:01:40 +04:00
|
|
|
DocAccessible* aDoc)
|
2006-07-24 20:12:08 +04:00
|
|
|
{
|
2013-07-19 08:13:35 +04:00
|
|
|
nsAutoString role;
|
2016-02-24 16:01:21 +03:00
|
|
|
nsCoreUtils::XBLBindingRole(aContent, role);
|
2013-07-19 08:13:35 +04:00
|
|
|
if (role.IsEmpty() || role.EqualsLiteral("none"))
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2006-07-24 20:12:08 +04:00
|
|
|
|
2013-07-19 08:13:35 +04:00
|
|
|
if (role.EqualsLiteral("outerdoc")) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Accessible> accessible = new OuterDocAccessible(aContent, aDoc);
|
2013-04-22 15:15:59 +04:00
|
|
|
return accessible.forget();
|
2010-02-21 03:56:35 +03:00
|
|
|
}
|
2014-06-06 21:22:46 +04:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Accessible> accessible;
|
2006-08-25 01:14:44 +04:00
|
|
|
#ifdef MOZ_XUL
|
2013-07-19 08:13:35 +04:00
|
|
|
// XUL controls
|
|
|
|
if (role.EqualsLiteral("xul:alert")) {
|
|
|
|
accessible = new XULAlertAccessible(aContent, aDoc);
|
2010-06-28 16:02:03 +04:00
|
|
|
|
2013-07-19 08:13:35 +04:00
|
|
|
} else if (role.EqualsLiteral("xul:button")) {
|
|
|
|
accessible = new XULButtonAccessible(aContent, aDoc);
|
2010-06-28 16:02:03 +04:00
|
|
|
|
2013-07-19 08:13:35 +04:00
|
|
|
} else if (role.EqualsLiteral("xul:checkbox")) {
|
|
|
|
accessible = new XULCheckboxAccessible(aContent, aDoc);
|
2010-06-28 16:02:03 +04:00
|
|
|
|
2013-07-19 08:13:35 +04:00
|
|
|
} else if (role.EqualsLiteral("xul:colorpicker")) {
|
|
|
|
accessible = new XULColorPickerAccessible(aContent, aDoc);
|
2010-06-28 16:02:03 +04:00
|
|
|
|
2013-07-19 08:13:35 +04:00
|
|
|
} else if (role.EqualsLiteral("xul:colorpickertile")) {
|
|
|
|
accessible = new XULColorPickerTileAccessible(aContent, aDoc);
|
2010-06-28 16:02:03 +04:00
|
|
|
|
2013-07-19 08:13:35 +04:00
|
|
|
} else if (role.EqualsLiteral("xul:combobox")) {
|
|
|
|
accessible = new XULComboboxAccessible(aContent, aDoc);
|
2010-06-28 16:02:03 +04:00
|
|
|
|
2013-07-19 08:13:35 +04:00
|
|
|
} else if (role.EqualsLiteral("xul:tabpanels")) {
|
2012-12-28 12:15:02 +04:00
|
|
|
accessible = new XULTabpanelsAccessible(aContent, aDoc);
|
2012-06-29 03:04:50 +04:00
|
|
|
|
2013-07-19 08:13:35 +04:00
|
|
|
} else if (role.EqualsLiteral("xul:dropmarker")) {
|
2012-04-12 15:11:40 +04:00
|
|
|
accessible = new XULDropmarkerAccessible(aContent, aDoc);
|
2010-06-28 16:02:03 +04:00
|
|
|
|
2013-07-19 08:13:35 +04:00
|
|
|
} else if (role.EqualsLiteral("xul:groupbox")) {
|
2012-04-12 15:11:40 +04:00
|
|
|
accessible = new XULGroupboxAccessible(aContent, aDoc);
|
2010-06-28 16:02:03 +04:00
|
|
|
|
2013-07-19 08:13:35 +04:00
|
|
|
} else if (role.EqualsLiteral("xul:image")) {
|
|
|
|
if (aContent->HasAttr(kNameSpaceID_None, nsGkAtoms::onclick)) {
|
|
|
|
accessible = new XULToolbarButtonAccessible(aContent, aDoc);
|
|
|
|
|
|
|
|
} else {
|
2010-06-11 12:23:18 +04:00
|
|
|
// Don't include nameless images in accessible tree.
|
|
|
|
if (!aContent->HasAttr(kNameSpaceID_None,
|
2011-06-04 01:35:17 +04:00
|
|
|
nsGkAtoms::tooltiptext))
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2006-07-24 20:12:08 +04:00
|
|
|
|
2012-06-02 15:30:34 +04:00
|
|
|
accessible = new ImageAccessibleWrap(aContent, aDoc);
|
2006-07-24 20:12:08 +04:00
|
|
|
}
|
2010-06-28 16:02:03 +04:00
|
|
|
|
2013-07-19 08:13:35 +04:00
|
|
|
} else if (role.EqualsLiteral("xul:link")) {
|
|
|
|
accessible = new XULLinkAccessible(aContent, aDoc);
|
|
|
|
|
|
|
|
} else if (role.EqualsLiteral("xul:listbox")) {
|
2012-06-11 03:44:50 +04:00
|
|
|
accessible = new XULListboxAccessibleWrap(aContent, aDoc);
|
2010-06-28 16:02:03 +04:00
|
|
|
|
2013-07-19 08:13:35 +04:00
|
|
|
} else if (role.EqualsLiteral("xul:listcell")) {
|
|
|
|
// Only create cells if there's more than one per row.
|
|
|
|
nsIContent* listItem = aContent->GetParent();
|
|
|
|
if (!listItem)
|
|
|
|
return nullptr;
|
2010-06-28 16:02:03 +04:00
|
|
|
|
2013-07-19 08:13:35 +04:00
|
|
|
for (nsIContent* child = listItem->GetFirstChild(); child;
|
|
|
|
child = child->GetNextSibling()) {
|
2015-03-03 14:08:59 +03:00
|
|
|
if (child->IsXULElement(nsGkAtoms::listcell) && child != aContent) {
|
2013-07-19 08:13:35 +04:00
|
|
|
accessible = new XULListCellAccessibleWrap(aContent, aDoc);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-06-28 16:02:03 +04:00
|
|
|
|
2013-07-19 08:13:35 +04:00
|
|
|
} else if (role.EqualsLiteral("xul:listhead")) {
|
|
|
|
accessible = new XULColumAccessible(aContent, aDoc);
|
2010-06-28 16:02:03 +04:00
|
|
|
|
2013-07-19 08:13:35 +04:00
|
|
|
} else if (role.EqualsLiteral("xul:listheader")) {
|
|
|
|
accessible = new XULColumnItemAccessible(aContent, aDoc);
|
2010-06-28 16:02:03 +04:00
|
|
|
|
2013-07-19 08:13:35 +04:00
|
|
|
} else if (role.EqualsLiteral("xul:listitem")) {
|
|
|
|
accessible = new XULListitemAccessible(aContent, aDoc);
|
2010-06-28 16:02:03 +04:00
|
|
|
|
2013-07-19 08:13:35 +04:00
|
|
|
} else if (role.EqualsLiteral("xul:menubar")) {
|
|
|
|
accessible = new XULMenubarAccessible(aContent, aDoc);
|
2010-06-28 16:02:03 +04:00
|
|
|
|
2013-07-19 08:13:35 +04:00
|
|
|
} else if (role.EqualsLiteral("xul:menulist")) {
|
2013-12-07 09:40:02 +04:00
|
|
|
accessible = new XULComboboxAccessible(aContent, aDoc);
|
2013-07-19 08:13:35 +04:00
|
|
|
|
|
|
|
} else if (role.EqualsLiteral("xul:menuitem")) {
|
|
|
|
accessible = new XULMenuitemAccessibleWrap(aContent, aDoc);
|
|
|
|
|
|
|
|
} else if (role.EqualsLiteral("xul:menupopup")) {
|
2006-07-24 20:12:08 +04:00
|
|
|
#ifdef MOZ_ACCESSIBILITY_ATK
|
2013-07-19 08:13:35 +04:00
|
|
|
// ATK considers this node to be redundant when within menubars, and it makes menu
|
|
|
|
// navigation with assistive technologies more difficult
|
|
|
|
// XXX In the future we will should this for consistency across the nsIAccessible
|
|
|
|
// implementations on each platform for a consistent scripting environment, but
|
|
|
|
// then strip out redundant accessibles in the AccessibleWrap class for each platform.
|
|
|
|
nsIContent *parent = aContent->GetParent();
|
2015-03-03 14:08:59 +03:00
|
|
|
if (parent && parent->IsXULElement(nsGkAtoms::menu))
|
2013-07-19 08:13:35 +04:00
|
|
|
return nullptr;
|
2006-07-24 20:12:08 +04:00
|
|
|
#endif
|
2010-06-28 16:02:03 +04:00
|
|
|
|
2013-07-19 08:13:35 +04:00
|
|
|
accessible = new XULMenupopupAccessible(aContent, aDoc);
|
2010-06-28 16:02:03 +04:00
|
|
|
|
2013-07-19 08:13:35 +04:00
|
|
|
} else if(role.EqualsLiteral("xul:menuseparator")) {
|
|
|
|
accessible = new XULMenuSeparatorAccessible(aContent, aDoc);
|
2010-06-28 16:02:03 +04:00
|
|
|
|
2013-07-19 08:13:35 +04:00
|
|
|
} else if(role.EqualsLiteral("xul:pane")) {
|
2015-03-05 03:04:46 +03:00
|
|
|
accessible = new EnumRoleAccessible<roles::PANE>(aContent, aDoc);
|
2010-06-28 16:02:03 +04:00
|
|
|
|
2013-07-19 08:13:35 +04:00
|
|
|
} else if (role.EqualsLiteral("xul:panel")) {
|
|
|
|
if (aContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::noautofocus,
|
|
|
|
nsGkAtoms::_true, eCaseMatters))
|
|
|
|
accessible = new XULAlertAccessible(aContent, aDoc);
|
|
|
|
else
|
2015-03-05 03:04:46 +03:00
|
|
|
accessible = new EnumRoleAccessible<roles::PANE>(aContent, aDoc);
|
2010-06-28 16:02:03 +04:00
|
|
|
|
2013-07-19 08:13:35 +04:00
|
|
|
} else if (role.EqualsLiteral("xul:progressmeter")) {
|
|
|
|
accessible = new XULProgressMeterAccessible(aContent, aDoc);
|
2010-06-28 16:02:03 +04:00
|
|
|
|
2014-08-14 23:19:58 +04:00
|
|
|
} else if (role.EqualsLiteral("xul:statusbar")) {
|
2013-07-19 08:13:35 +04:00
|
|
|
accessible = new XULStatusBarAccessible(aContent, aDoc);
|
2010-06-28 16:02:03 +04:00
|
|
|
|
2013-07-19 08:13:35 +04:00
|
|
|
} else if (role.EqualsLiteral("xul:scale")) {
|
|
|
|
accessible = new XULSliderAccessible(aContent, aDoc);
|
2010-06-28 16:02:03 +04:00
|
|
|
|
2013-07-19 08:13:35 +04:00
|
|
|
} else if (role.EqualsLiteral("xul:radiobutton")) {
|
|
|
|
accessible = new XULRadioButtonAccessible(aContent, aDoc);
|
2010-06-28 16:02:03 +04:00
|
|
|
|
2013-07-19 08:13:35 +04:00
|
|
|
} else if (role.EqualsLiteral("xul:radiogroup")) {
|
|
|
|
accessible = new XULRadioGroupAccessible(aContent, aDoc);
|
2010-06-28 16:02:03 +04:00
|
|
|
|
2013-07-19 08:13:35 +04:00
|
|
|
} else if (role.EqualsLiteral("xul:tab")) {
|
|
|
|
accessible = new XULTabAccessible(aContent, aDoc);
|
2010-06-28 16:02:03 +04:00
|
|
|
|
2013-07-19 08:13:35 +04:00
|
|
|
} else if (role.EqualsLiteral("xul:tabs")) {
|
|
|
|
accessible = new XULTabsAccessible(aContent, aDoc);
|
2010-06-28 16:02:03 +04:00
|
|
|
|
2013-07-19 08:13:35 +04:00
|
|
|
} else if (role.EqualsLiteral("xul:text")) {
|
|
|
|
accessible = new XULLabelAccessible(aContent, aDoc);
|
2010-06-28 16:02:03 +04:00
|
|
|
|
2013-07-19 08:13:35 +04:00
|
|
|
} else if (role.EqualsLiteral("xul:textbox")) {
|
2015-03-05 03:04:46 +03:00
|
|
|
accessible = new EnumRoleAccessible<roles::SECTION>(aContent, aDoc);
|
2010-02-21 03:56:35 +03:00
|
|
|
|
2013-07-19 08:13:35 +04:00
|
|
|
} else if (role.EqualsLiteral("xul:thumb")) {
|
|
|
|
accessible = new XULThumbAccessible(aContent, aDoc);
|
2010-06-28 16:02:03 +04:00
|
|
|
|
2013-07-19 08:13:35 +04:00
|
|
|
} else if (role.EqualsLiteral("xul:tree")) {
|
|
|
|
accessible = CreateAccessibleForXULTree(aContent, aDoc);
|
2010-06-28 16:02:03 +04:00
|
|
|
|
2013-07-19 08:13:35 +04:00
|
|
|
} else if (role.EqualsLiteral("xul:treecolumns")) {
|
|
|
|
accessible = new XULTreeColumAccessible(aContent, aDoc);
|
2010-06-28 16:02:03 +04:00
|
|
|
|
2013-07-19 08:13:35 +04:00
|
|
|
} else if (role.EqualsLiteral("xul:treecolumnitem")) {
|
|
|
|
accessible = new XULColumnItemAccessible(aContent, aDoc);
|
2010-06-28 16:02:03 +04:00
|
|
|
|
2013-07-19 08:13:35 +04:00
|
|
|
} else if (role.EqualsLiteral("xul:toolbar")) {
|
|
|
|
accessible = new XULToolbarAccessible(aContent, aDoc);
|
2010-06-28 16:02:03 +04:00
|
|
|
|
2013-07-19 08:13:35 +04:00
|
|
|
} else if (role.EqualsLiteral("xul:toolbarseparator")) {
|
|
|
|
accessible = new XULToolbarSeparatorAccessible(aContent, aDoc);
|
2010-06-28 16:02:03 +04:00
|
|
|
|
2013-07-19 08:13:35 +04:00
|
|
|
} else if (role.EqualsLiteral("xul:tooltip")) {
|
|
|
|
accessible = new XULTooltipAccessible(aContent, aDoc);
|
|
|
|
|
|
|
|
} else if (role.EqualsLiteral("xul:toolbarbutton")) {
|
|
|
|
accessible = new XULToolbarButtonAccessible(aContent, aDoc);
|
2006-08-25 01:14:44 +04:00
|
|
|
|
2006-07-24 20:12:08 +04:00
|
|
|
}
|
2013-07-19 08:13:35 +04:00
|
|
|
#endif // MOZ_XUL
|
2006-07-24 20:12:08 +04:00
|
|
|
|
2013-04-22 15:15:59 +04:00
|
|
|
return accessible.forget();
|
2006-07-24 20:12:08 +04:00
|
|
|
}
|
|
|
|
|
2012-09-29 01:53:44 +04:00
|
|
|
already_AddRefed<Accessible>
|
|
|
|
nsAccessibilityService::CreateAccessibleByFrameType(nsIFrame* aFrame,
|
|
|
|
nsIContent* aContent,
|
2012-11-30 11:33:01 +04:00
|
|
|
Accessible* aContext)
|
2012-09-29 01:53:44 +04:00
|
|
|
{
|
2012-11-30 11:33:01 +04:00
|
|
|
DocAccessible* document = aContext->Document();
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Accessible> newAcc;
|
2012-09-29 01:53:44 +04:00
|
|
|
switch (aFrame->AccessibleType()) {
|
2012-12-12 14:04:12 +04:00
|
|
|
case eNoType:
|
2012-09-29 01:53:44 +04:00
|
|
|
return nullptr;
|
2012-12-18 05:25:52 +04:00
|
|
|
case eHTMLBRType:
|
2012-11-30 11:33:01 +04:00
|
|
|
newAcc = new HTMLBRAccessible(aContent, document);
|
2012-09-29 01:53:44 +04:00
|
|
|
break;
|
2012-12-18 05:25:52 +04:00
|
|
|
case eHTMLButtonType:
|
2012-11-30 11:33:01 +04:00
|
|
|
newAcc = new HTMLButtonAccessible(aContent, document);
|
2012-09-29 01:53:44 +04:00
|
|
|
break;
|
2012-12-18 05:25:52 +04:00
|
|
|
case eHTMLCanvasType:
|
2012-11-30 11:33:01 +04:00
|
|
|
newAcc = new HTMLCanvasAccessible(aContent, document);
|
2012-09-29 01:53:44 +04:00
|
|
|
break;
|
2012-12-18 05:25:52 +04:00
|
|
|
case eHTMLCaptionType:
|
2012-12-18 09:22:26 +04:00
|
|
|
if (aContext->IsTable() &&
|
2012-11-30 11:33:01 +04:00
|
|
|
aContext->GetContent() == aContent->GetParent()) {
|
|
|
|
newAcc = new HTMLCaptionAccessible(aContent, document);
|
|
|
|
}
|
2012-09-29 01:53:44 +04:00
|
|
|
break;
|
2012-12-18 05:25:52 +04:00
|
|
|
case eHTMLCheckboxType:
|
2012-11-30 11:33:01 +04:00
|
|
|
newAcc = new HTMLCheckboxAccessible(aContent, document);
|
2012-09-29 01:53:44 +04:00
|
|
|
break;
|
2012-12-18 05:25:52 +04:00
|
|
|
case eHTMLComboboxType:
|
2012-11-30 11:33:01 +04:00
|
|
|
newAcc = new HTMLComboboxAccessible(aContent, document);
|
2012-09-29 01:53:44 +04:00
|
|
|
break;
|
2012-12-18 05:25:52 +04:00
|
|
|
case eHTMLFileInputType:
|
2012-11-30 11:33:01 +04:00
|
|
|
newAcc = new HTMLFileInputAccessible(aContent, document);
|
2012-09-29 01:53:44 +04:00
|
|
|
break;
|
2012-12-18 05:25:52 +04:00
|
|
|
case eHTMLGroupboxType:
|
2012-11-30 11:33:01 +04:00
|
|
|
newAcc = new HTMLGroupboxAccessible(aContent, document);
|
2012-09-29 01:53:44 +04:00
|
|
|
break;
|
2012-12-18 05:25:52 +04:00
|
|
|
case eHTMLHRType:
|
2012-11-30 11:33:01 +04:00
|
|
|
newAcc = new HTMLHRAccessible(aContent, document);
|
2012-09-29 01:53:44 +04:00
|
|
|
break;
|
2012-12-18 05:25:52 +04:00
|
|
|
case eHTMLImageMapType:
|
2012-11-30 11:33:01 +04:00
|
|
|
newAcc = new HTMLImageMapAccessible(aContent, document);
|
2012-09-29 01:53:44 +04:00
|
|
|
break;
|
2012-12-18 05:25:52 +04:00
|
|
|
case eHTMLLiType:
|
2012-12-18 09:22:26 +04:00
|
|
|
if (aContext->IsList() &&
|
2012-12-02 15:35:41 +04:00
|
|
|
aContext->GetContent() == aContent->GetParent()) {
|
|
|
|
newAcc = new HTMLLIAccessible(aContent, document);
|
2014-11-21 17:13:32 +03:00
|
|
|
} else {
|
|
|
|
// Otherwise create a generic text accessible to avoid text jamming.
|
|
|
|
newAcc = new HyperTextAccessibleWrap(aContent, document);
|
2012-12-02 15:35:41 +04:00
|
|
|
}
|
2012-09-29 01:53:44 +04:00
|
|
|
break;
|
2012-12-18 05:25:52 +04:00
|
|
|
case eHTMLSelectListType:
|
2012-11-30 11:33:01 +04:00
|
|
|
newAcc = new HTMLSelectListAccessible(aContent, document);
|
2012-09-29 01:53:44 +04:00
|
|
|
break;
|
2012-12-18 05:25:52 +04:00
|
|
|
case eHTMLMediaType:
|
2015-03-05 03:04:46 +03:00
|
|
|
newAcc = new EnumRoleAccessible<roles::GROUPING>(aContent, document);
|
2012-09-29 01:53:44 +04:00
|
|
|
break;
|
2012-12-18 05:25:52 +04:00
|
|
|
case eHTMLRadioButtonType:
|
2012-11-30 11:33:01 +04:00
|
|
|
newAcc = new HTMLRadioButtonAccessible(aContent, document);
|
2012-09-29 01:53:44 +04:00
|
|
|
break;
|
2013-04-28 04:54:54 +04:00
|
|
|
case eHTMLRangeType:
|
|
|
|
newAcc = new HTMLRangeAccessible(aContent, document);
|
|
|
|
break;
|
2013-12-11 07:19:26 +04:00
|
|
|
case eHTMLSpinnerType:
|
|
|
|
newAcc = new HTMLSpinnerAccessible(aContent, document);
|
|
|
|
break;
|
2012-12-18 05:25:52 +04:00
|
|
|
case eHTMLTableType:
|
2015-10-19 15:46:54 +03:00
|
|
|
if (aContent->IsHTMLElement(nsGkAtoms::table))
|
|
|
|
newAcc = new HTMLTableAccessibleWrap(aContent, document);
|
|
|
|
else
|
|
|
|
newAcc = new HyperTextAccessibleWrap(aContent, document);
|
2012-09-29 01:53:44 +04:00
|
|
|
break;
|
2012-12-18 05:25:52 +04:00
|
|
|
case eHTMLTableCellType:
|
2013-02-16 09:42:00 +04:00
|
|
|
// Accessible HTML table cell should be a child of accessible HTML table
|
|
|
|
// or its row (CSS HTML tables are polite to the used markup at
|
|
|
|
// certain degree).
|
2013-12-18 21:25:07 +04:00
|
|
|
// Otherwise create a generic text accessible to avoid text jamming
|
|
|
|
// when reading by AT.
|
2013-02-16 09:42:00 +04:00
|
|
|
if (aContext->IsHTMLTableRow() || aContext->IsHTMLTable())
|
2012-11-30 11:33:01 +04:00
|
|
|
newAcc = new HTMLTableCellAccessibleWrap(aContent, document);
|
2013-12-18 21:25:07 +04:00
|
|
|
else
|
|
|
|
newAcc = new HyperTextAccessibleWrap(aContent, document);
|
2012-09-29 01:53:44 +04:00
|
|
|
break;
|
2012-11-30 11:33:01 +04:00
|
|
|
|
2012-12-18 05:25:52 +04:00
|
|
|
case eHTMLTableRowType: {
|
2014-06-06 21:22:46 +04:00
|
|
|
// Accessible HTML table row may be a child of tbody/tfoot/thead of
|
|
|
|
// accessible HTML table or a direct child of accessible of HTML table.
|
2014-07-15 18:17:16 +04:00
|
|
|
Accessible* table = aContext->IsTable() ? aContext : nullptr;
|
|
|
|
if (!table && aContext->Parent() && aContext->Parent()->IsTable())
|
|
|
|
table = aContext->Parent();
|
2014-06-06 21:22:46 +04:00
|
|
|
|
|
|
|
if (table) {
|
2012-11-30 11:33:01 +04:00
|
|
|
nsIContent* parentContent = aContent->GetParent();
|
|
|
|
nsIFrame* parentFrame = parentContent->GetPrimaryFrame();
|
2014-06-06 21:22:46 +04:00
|
|
|
if (parentFrame->GetType() != nsGkAtoms::tableOuterFrame) {
|
2012-11-30 11:33:01 +04:00
|
|
|
parentContent = parentContent->GetParent();
|
|
|
|
parentFrame = parentContent->GetPrimaryFrame();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (parentFrame->GetType() == nsGkAtoms::tableOuterFrame &&
|
2014-06-06 21:22:46 +04:00
|
|
|
table->GetContent() == parentContent) {
|
2012-11-30 11:33:01 +04:00
|
|
|
newAcc = new HTMLTableRowAccessible(aContent, document);
|
|
|
|
}
|
|
|
|
}
|
2012-09-29 01:53:44 +04:00
|
|
|
break;
|
2012-11-30 11:33:01 +04:00
|
|
|
}
|
2012-12-18 05:25:52 +04:00
|
|
|
case eHTMLTextFieldType:
|
2012-11-30 11:33:01 +04:00
|
|
|
newAcc = new HTMLTextFieldAccessible(aContent, document);
|
2012-09-29 01:53:44 +04:00
|
|
|
break;
|
2012-12-18 05:25:52 +04:00
|
|
|
case eHyperTextType:
|
2015-03-03 14:08:59 +03:00
|
|
|
if (!aContent->IsAnyOfHTMLElements(nsGkAtoms::dt, nsGkAtoms::dd))
|
2012-12-02 15:35:41 +04:00
|
|
|
newAcc = new HyperTextAccessibleWrap(aContent, document);
|
2012-09-29 01:53:44 +04:00
|
|
|
break;
|
2012-12-02 15:35:41 +04:00
|
|
|
|
2012-12-18 05:25:52 +04:00
|
|
|
case eImageType:
|
2012-11-30 11:33:01 +04:00
|
|
|
newAcc = new ImageAccessibleWrap(aContent, document);
|
2012-09-29 01:53:44 +04:00
|
|
|
break;
|
2012-12-18 05:25:52 +04:00
|
|
|
case eOuterDocType:
|
2012-11-30 11:33:01 +04:00
|
|
|
newAcc = new OuterDocAccessible(aContent, document);
|
2012-09-29 01:53:44 +04:00
|
|
|
break;
|
2012-12-18 09:22:26 +04:00
|
|
|
case ePluginType: {
|
2014-09-24 08:35:00 +04:00
|
|
|
nsPluginFrame* pluginFrame = do_QueryFrame(aFrame);
|
|
|
|
newAcc = CreatePluginAccessible(pluginFrame, aContent, aContext);
|
2012-12-12 14:04:12 +04:00
|
|
|
break;
|
|
|
|
}
|
2012-12-18 05:25:52 +04:00
|
|
|
case eTextLeafType:
|
2012-11-30 11:33:01 +04:00
|
|
|
newAcc = new TextLeafAccessibleWrap(aContent, document);
|
2012-09-29 01:53:44 +04:00
|
|
|
break;
|
2013-01-02 04:49:19 +04:00
|
|
|
default:
|
|
|
|
MOZ_ASSERT(false);
|
|
|
|
break;
|
2012-09-29 01:53:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return newAcc.forget();
|
|
|
|
}
|
|
|
|
|
2015-03-08 04:20:17 +03:00
|
|
|
void
|
|
|
|
nsAccessibilityService::MarkupAttributes(const nsIContent* aContent,
|
|
|
|
nsIPersistentProperties* aAttributes) const
|
|
|
|
{
|
|
|
|
const mozilla::a11y::MarkupMapInfo* markupMap =
|
|
|
|
mMarkupMaps.Get(aContent->NodeInfo()->NameAtom());
|
|
|
|
if (!markupMap)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < ArrayLength(markupMap->attrs); i++) {
|
|
|
|
const MarkupAttrInfo* info = markupMap->attrs + i;
|
|
|
|
if (!info->name)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (info->DOMAttrName) {
|
|
|
|
if (info->DOMAttrValue) {
|
|
|
|
if (aContent->AttrValueIs(kNameSpaceID_None, *info->DOMAttrName,
|
|
|
|
*info->DOMAttrValue, eCaseMatters)) {
|
|
|
|
nsAccUtils::SetAccAttr(aAttributes, *info->name, *info->DOMAttrValue);
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoString value;
|
|
|
|
aContent->GetAttr(kNameSpaceID_None, *info->DOMAttrName, value);
|
|
|
|
if (!value.IsEmpty())
|
|
|
|
nsAccUtils::SetAccAttr(aAttributes, *info->name, value);
|
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAccUtils::SetAccAttr(aAttributes, *info->name, *info->value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-21 03:56:35 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsIAccessibilityService (DON'T put methods here)
|
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
Accessible*
|
2010-06-25 13:50:23 +04:00
|
|
|
nsAccessibilityService::AddNativeRootAccessible(void* aAtkAccessible)
|
2012-05-04 10:09:22 +04:00
|
|
|
{
|
2006-08-30 09:19:06 +04:00
|
|
|
#ifdef MOZ_ACCESSIBILITY_ATK
|
2012-09-10 17:20:26 +04:00
|
|
|
ApplicationAccessible* applicationAcc = ApplicationAcc();
|
2010-06-25 13:50:23 +04:00
|
|
|
if (!applicationAcc)
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2007-06-02 07:01:38 +04:00
|
|
|
|
2012-10-13 10:34:21 +04:00
|
|
|
GtkWindowAccessible* nativeWnd =
|
|
|
|
new GtkWindowAccessible(static_cast<AtkObject*>(aAtkAccessible));
|
2006-08-30 09:19:06 +04:00
|
|
|
|
2012-10-13 10:34:21 +04:00
|
|
|
if (applicationAcc->AppendChild(nativeWnd))
|
|
|
|
return nativeWnd;
|
2006-08-30 09:19:06 +04:00
|
|
|
#endif
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2012-05-04 10:09:22 +04:00
|
|
|
}
|
2010-06-25 13:50:23 +04:00
|
|
|
|
|
|
|
void
|
2012-05-29 05:18:45 +04:00
|
|
|
nsAccessibilityService::RemoveNativeRootAccessible(Accessible* aAccessible)
|
2006-08-30 09:19:06 +04:00
|
|
|
{
|
|
|
|
#ifdef MOZ_ACCESSIBILITY_ATK
|
2012-09-10 17:20:26 +04:00
|
|
|
ApplicationAccessible* applicationAcc = ApplicationAcc();
|
2007-06-02 07:01:38 +04:00
|
|
|
|
2010-06-25 13:50:23 +04:00
|
|
|
if (applicationAcc)
|
|
|
|
applicationAcc->RemoveChild(aAccessible);
|
2006-08-30 09:19:06 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
bool
|
|
|
|
nsAccessibilityService::HasAccessible(nsIDOMNode* aDOMNode)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsINode> node(do_QueryInterface(aDOMNode));
|
|
|
|
if (!node)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
DocAccessible* document = GetDocAccessible(node->OwnerDoc());
|
|
|
|
if (!document)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return document->HasAccessible(node);
|
|
|
|
}
|
|
|
|
|
2010-02-21 03:56:35 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// NS_GetAccessibilityService
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2001-02-14 23:51:33 +03:00
|
|
|
|
2010-02-02 05:27:32 +03:00
|
|
|
/**
|
|
|
|
* Return accessibility service; creating one if necessary.
|
|
|
|
*/
|
2003-07-09 11:01:46 +04:00
|
|
|
nsresult
|
|
|
|
NS_GetAccessibilityService(nsIAccessibilityService** aResult)
|
|
|
|
{
|
2010-06-08 20:39:58 +04:00
|
|
|
NS_ENSURE_TRUE(aResult, NS_ERROR_NULL_POINTER);
|
2012-07-30 18:20:58 +04:00
|
|
|
*aResult = nullptr;
|
2014-06-06 21:22:46 +04:00
|
|
|
|
2010-06-08 20:39:58 +04:00
|
|
|
if (nsAccessibilityService::gAccessibilityService) {
|
|
|
|
NS_ADDREF(*aResult = nsAccessibilityService::gAccessibilityService);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsAccessibilityService> service = new nsAccessibilityService();
|
2010-06-08 20:39:58 +04:00
|
|
|
NS_ENSURE_TRUE(service, NS_ERROR_OUT_OF_MEMORY);
|
|
|
|
|
|
|
|
if (!service->Init()) {
|
|
|
|
service->Shutdown();
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2011-08-11 15:01:27 +04:00
|
|
|
statistics::A11yInitialized();
|
|
|
|
|
2010-06-08 20:39:58 +04:00
|
|
|
NS_ADDREF(*aResult = service);
|
2010-02-02 05:27:32 +03:00
|
|
|
return NS_OK;
|
2003-07-09 11:01:46 +04:00
|
|
|
}
|
2001-12-17 04:21:29 +03:00
|
|
|
|
2010-02-21 03:56:35 +03:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsAccessibilityService private (DON'T put methods here)
|
|
|
|
|
2009-08-20 10:45:19 +04:00
|
|
|
#ifdef MOZ_XUL
|
2012-05-29 05:18:45 +04:00
|
|
|
already_AddRefed<Accessible>
|
2010-06-28 16:02:03 +04:00
|
|
|
nsAccessibilityService::CreateAccessibleForXULTree(nsIContent* aContent,
|
2012-05-27 13:01:40 +04:00
|
|
|
DocAccessible* aDoc)
|
2009-08-20 10:45:19 +04:00
|
|
|
{
|
2012-11-20 00:36:05 +04:00
|
|
|
nsIContent* child = nsTreeUtils::GetDescendantChild(aContent,
|
|
|
|
nsGkAtoms::treechildren);
|
|
|
|
if (!child)
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2009-08-20 10:45:19 +04:00
|
|
|
|
2012-11-20 00:36:05 +04:00
|
|
|
nsTreeBodyFrame* treeFrame = do_QueryFrame(child->GetPrimaryFrame());
|
|
|
|
if (!treeFrame)
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2010-02-21 03:56:35 +03:00
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsTreeColumns> treeCols = treeFrame->Columns();
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t count = 0;
|
2012-11-20 00:36:05 +04:00
|
|
|
treeCols->GetCount(&count);
|
2009-08-20 10:45:19 +04:00
|
|
|
|
2010-06-28 16:02:03 +04:00
|
|
|
// Outline of list accessible.
|
|
|
|
if (count == 1) {
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Accessible> accessible =
|
2013-04-22 15:15:59 +04:00
|
|
|
new XULTreeAccessible(aContent, aDoc, treeFrame);
|
|
|
|
return accessible.forget();
|
2010-06-28 16:02:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Table or tree table accessible.
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<Accessible> accessible =
|
2013-04-22 15:15:59 +04:00
|
|
|
new XULTreeGridAccessibleWrap(aContent, aDoc, treeFrame);
|
|
|
|
return accessible.forget();
|
2009-08-20 10:45:19 +04:00
|
|
|
}
|
|
|
|
#endif
|
2011-09-28 05:46:11 +04:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Services
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-06-20 03:19:13 +04:00
|
|
|
namespace mozilla {
|
|
|
|
namespace a11y {
|
|
|
|
|
|
|
|
FocusManager*
|
|
|
|
FocusMgr()
|
2011-09-28 05:46:11 +04:00
|
|
|
{
|
|
|
|
return nsAccessibilityService::gAccessibilityService;
|
|
|
|
}
|
2012-06-20 03:19:13 +04:00
|
|
|
|
2013-03-07 16:16:10 +04:00
|
|
|
SelectionManager*
|
|
|
|
SelectionMgr()
|
|
|
|
{
|
|
|
|
return nsAccessibilityService::gAccessibilityService;
|
|
|
|
}
|
|
|
|
|
2012-09-10 17:20:26 +04:00
|
|
|
ApplicationAccessible*
|
|
|
|
ApplicationAcc()
|
|
|
|
{
|
|
|
|
return nsAccessibilityService::gApplicationAccessible;
|
|
|
|
}
|
|
|
|
|
2014-10-22 04:49:28 +04:00
|
|
|
xpcAccessibleApplication*
|
|
|
|
XPCApplicationAcc()
|
|
|
|
{
|
|
|
|
if (!nsAccessibilityService::gXPCApplicationAccessible &&
|
|
|
|
nsAccessibilityService::gApplicationAccessible) {
|
|
|
|
nsAccessibilityService::gXPCApplicationAccessible =
|
|
|
|
new xpcAccessibleApplication(nsAccessibilityService::gApplicationAccessible);
|
|
|
|
NS_ADDREF(nsAccessibilityService::gXPCApplicationAccessible);
|
|
|
|
}
|
|
|
|
|
|
|
|
return nsAccessibilityService::gXPCApplicationAccessible;
|
|
|
|
}
|
|
|
|
|
2012-06-20 03:19:13 +04:00
|
|
|
EPlatformDisabledState
|
|
|
|
PlatformDisabledState()
|
|
|
|
{
|
|
|
|
static int disabledState = 0xff;
|
|
|
|
|
|
|
|
if (disabledState == 0xff) {
|
|
|
|
disabledState = Preferences::GetInt("accessibility.force_disabled", 0);
|
|
|
|
if (disabledState < ePlatformIsForceEnabled)
|
|
|
|
disabledState = ePlatformIsForceEnabled;
|
|
|
|
else if (disabledState > ePlatformIsDisabled)
|
|
|
|
disabledState = ePlatformIsDisabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (EPlatformDisabledState)disabledState;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|