mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
b91a6a24cc
- Bug 1001637 - Make math tables implement the nsIAccessibleTable interface. r=surkov (ebbb4325d6) - Bug 1149118 - Expose radio group with the correct role on OS X, r=surkov (4d4a95735c) - Bug 1113153 - use 'paragraph' role for paragraphs only, introduce 'text' role for small text containers, r=marcoz (14c4fa5881) - Bug 1175164 - Do not expose MathML semantics element in the accessibility tree. r=surkov (3945ae0367) - Bug 930843 part.1 Add test for checking isTrust attribute value of DOMActivate event r=smaug (14a49dd447) - Bug 930843 part.2 NS_UI_ACTIVATE event should be trusted event even if it's caused by an untrusted event r=smaug (e0af6165b5) - Bug 1156315 - Call DispatchInputEvent in more places on OS X. r=dvander (e24f42c09f) - Bug 1186015 part.1 Rename nsIMEContext to mozilla::widget::IMEContext r=jimm (077bf6e772) - Bug 1186015 part.2 Rename nsIMM32Handler to mozilla::widget::IMMHandler r=jimm+m_kato (a2098e33b5) - Bug 1184533 Rewrite range check in aOffset of nsIMM32Handler::GetCharacterRectOfSelectedTextAt() r=emk (fb68bc3c56) - Bug 555642 part.1 nsCaret should have a way to override the caret visible state for hiding caret temporarily and nsEditor should hide caret if composition string doesn't have caret information r=roc (9de4aa366c) - Bug 1171847 Remove unnecessary ',' in logging code in nsTextStore::Initialize() r=m_kato (78d0d43625) - Bug 1181714 nsTextStore should store previous focused document manager until new document manager actually gets focus r=m_kato (fd7e820af2) - Bug 1176950 nsTextStore should keep storing locked content until NOTIFY_IME_OF_COMPOSITION_UPDATE is notified r=emk (0a12349575) - Bug 1137539 part.1 Implement TSFStaticSink::IsGoogleJapaneseInputActive() r=emk (68d1f9a0ec) - Bug 1137539 part.2 Implement TSFStaticSink::IsATOKActive() r=emk (51a4208bfa) - Bug 1137539 part.3 Implement TSFStaticSink::IsFreeChangJieActive() r=emk (affbb81b96) - Bug 1137539 part.4 Implement TSFStaticSink::IsEasyChangjeiActive() r=emk (abd3e674b6) - Bug 1186014 Rename nsTextStore to mozilla::widget::TSFTextStore r=jimm+m_kato (ca63351f94) - Bug 1187351 TSFTextStore should forget modified range at notifying TSF of layout change since GetTextExt() shouldn't return TS_E_NOLAYOUT after that r=emk (48878793e0) - Bg 1187367 TSFTextStore shouldn't destroy native caret for ATOK until notifying TSF of layout change r=emk (a2a4022d15) - Bug 1187566 TSFTextStore::Content should compute mMinTextModified Offset only with the latest composition string and original composition string, and also the hack should be enabled on Win10 r=emk (1368885efe) - Bug 1050644 part.1 Add methods to check whether the active TIP is Chinese TIP which deosn't show candidate window in e10s mode r=emk (1b783e682e) - Bug 1050644 part.2 Hack ITextStoreACP::GetTextExt()'s offset for some Chinese TIPs of MS r=emk (c05cec10ce) - Bug 1187579 Enable TSF in e10s mode r=m_kato (1ae106231a) - Bug 555642 part.2 IME handlers on Windows shouldn't append caret range if the caret is in the target clause which doesn't have specific style r=m_kato (88bae2c8da) - Bug 1196124 Fix mismatch of printf style string and following arguments of MOZ_LOG() in IMMHandler::GetCharacterRectOfSelectedTextAt() r=m_kato (0f6debd0d3) - Bug 90712 Cancel composition when Enter key message isn't consumed by IME r=m_kato (0febdb1fd9) - pointer style (6c984274cd) - Bug 1177268 - implement aria-rowcount/index and aria-colcount/index, r=marcoz (92ac300374) - Bug 1153135 - Return possibility PEN working while APZC is enabled. r=jimm (8bc77ff84f) - Bug 1171073 - Suppress content scrolling issue on 64-bit platforms. r=kats (62db0dead3) - Bug 1121946, Implement e10 cursor drag feedback on Windows, r=jmathies (6e8218d202) - Bug 1144650 - Don't dispatch touch-based mouse events when APZ is handling touch. r=jimm (53ebea0d90) - Bug 1163056 - InkCollector activation at first PEN event. r=jimm (b28e0ee58b) - Bug 895274 part.3 Make the enum of event messages a named enum IGNORE IDL r=smaug (32e04a4e90) - spacing (b9249221dc) - Bug 1182966 - Part 3: Add some final annotations to DomainSet. r=mrbkap (3455822e89) - Bug 1050122 - Part 1: Enable Nuwa on debug builds, and kill it if the preference is false. r=khuey (46685a7bf3) - Bug 1146229: Remove calling convention modifier from local variable. r=surkov (e5f4b6e5d5) - bug 1168932 - Implement ProxyCreated and ProxyDestroyed to update mozAccessibles r=tbsaunde (77a007fa21) - Bug 1169701 - Fire native OS X accessibility events for proxied accessibles r=tbsaunde (c4847135a8) - bug 1172523 - fire useful text change events for proxies r=lsock (85b7f995b8) - remove spurious file (229c787360) - bug 1171117 - Fix cairo to build on iOS. r=jrmuizel (45709c8fe3) - Bug 963738 - Annotate XPCNativeMember, r=terrence (d1afdde52b) - Bug 1148383 - Add testcase for previously fixed object metadata issue r=terrence (2c1b762cba) - Bug 1149797 - Update browser jstests to treat ecma_6/extensions tests as 1.8, so that let is interpreted as a statement and not as an expression. r=bustage in a CLOSED TREE (ac6127d6bc) - Bug 1150858 - Unwrap the correct object in ArrayBuffer.transfer (r=sfink) (cf67906802) - Bug 1150380 - IonMonkey: MIPS: Fix JitRuntime::generateProfilerExitFrameTailStub. r=rankov (eeac49ddce) - use RootedValue for POW as in 1135708 (34c1c3d191) - Bug 1196648: IonMonkey - Don't run the lazy link stub for asmjs to jit fastpath, r=nbp (686d495371) - Bug 1121947, Implement e10 cursor drag feedback on Mac, r=smaug (f48df2d1) - and sync widget/TextEvents.h and TextRange.h with AF.
445 lines
12 KiB
C++
445 lines
12 KiB
C++
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* 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/. */
|
|
|
|
#include "nsAccUtils.h"
|
|
|
|
#include "Accessible-inl.h"
|
|
#include "ARIAMap.h"
|
|
#include "nsAccessibilityService.h"
|
|
#include "nsCoreUtils.h"
|
|
#include "DocAccessible.h"
|
|
#include "HyperTextAccessible.h"
|
|
#include "nsIAccessibleTypes.h"
|
|
#include "Role.h"
|
|
#include "States.h"
|
|
#include "TextLeafAccessible.h"
|
|
|
|
#include "nsIDOMXULContainerElement.h"
|
|
#include "nsIPersistentProperties2.h"
|
|
#include "mozilla/dom/Element.h"
|
|
|
|
using namespace mozilla;
|
|
using namespace mozilla::a11y;
|
|
|
|
void
|
|
nsAccUtils::GetAccAttr(nsIPersistentProperties *aAttributes,
|
|
nsIAtom *aAttrName, nsAString& aAttrValue)
|
|
{
|
|
aAttrValue.Truncate();
|
|
|
|
aAttributes->GetStringProperty(nsAtomCString(aAttrName), aAttrValue);
|
|
}
|
|
|
|
void
|
|
nsAccUtils::SetAccAttr(nsIPersistentProperties *aAttributes,
|
|
nsIAtom *aAttrName, const nsAString& aAttrValue)
|
|
{
|
|
nsAutoString oldValue;
|
|
aAttributes->SetStringProperty(nsAtomCString(aAttrName), aAttrValue, oldValue);
|
|
}
|
|
|
|
void
|
|
nsAccUtils::SetAccAttr(nsIPersistentProperties *aAttributes,
|
|
nsIAtom* aAttrName, nsIAtom* aAttrValue)
|
|
{
|
|
nsAutoString oldValue;
|
|
aAttributes->SetStringProperty(nsAtomCString(aAttrName),
|
|
nsAtomString(aAttrValue), oldValue);
|
|
}
|
|
|
|
void
|
|
nsAccUtils::SetAccGroupAttrs(nsIPersistentProperties *aAttributes,
|
|
int32_t aLevel, int32_t aSetSize,
|
|
int32_t aPosInSet)
|
|
{
|
|
nsAutoString value;
|
|
|
|
if (aLevel) {
|
|
value.AppendInt(aLevel);
|
|
SetAccAttr(aAttributes, nsGkAtoms::level, value);
|
|
}
|
|
|
|
if (aSetSize && aPosInSet) {
|
|
value.Truncate();
|
|
value.AppendInt(aPosInSet);
|
|
SetAccAttr(aAttributes, nsGkAtoms::posinset, value);
|
|
|
|
value.Truncate();
|
|
value.AppendInt(aSetSize);
|
|
SetAccAttr(aAttributes, nsGkAtoms::setsize, value);
|
|
}
|
|
}
|
|
|
|
int32_t
|
|
nsAccUtils::GetDefaultLevel(Accessible* aAccessible)
|
|
{
|
|
roles::Role role = aAccessible->Role();
|
|
|
|
if (role == roles::OUTLINEITEM)
|
|
return 1;
|
|
|
|
if (role == roles::ROW) {
|
|
Accessible* parent = aAccessible->Parent();
|
|
// It is a row inside flatten treegrid. Group level is always 1 until it
|
|
// is overriden by aria-level attribute.
|
|
if (parent && parent->Role() == roles::TREE_TABLE)
|
|
return 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
int32_t
|
|
nsAccUtils::GetARIAOrDefaultLevel(Accessible* aAccessible)
|
|
{
|
|
int32_t level = 0;
|
|
nsCoreUtils::GetUIntAttr(aAccessible->GetContent(),
|
|
nsGkAtoms::aria_level, &level);
|
|
|
|
if (level != 0)
|
|
return level;
|
|
|
|
return GetDefaultLevel(aAccessible);
|
|
}
|
|
|
|
int32_t
|
|
nsAccUtils::GetLevelForXULContainerItem(nsIContent *aContent)
|
|
{
|
|
nsCOMPtr<nsIDOMXULContainerItemElement> item(do_QueryInterface(aContent));
|
|
if (!item)
|
|
return 0;
|
|
|
|
nsCOMPtr<nsIDOMXULContainerElement> container;
|
|
item->GetParentContainer(getter_AddRefs(container));
|
|
if (!container)
|
|
return 0;
|
|
|
|
// Get level of the item.
|
|
int32_t level = -1;
|
|
while (container) {
|
|
level++;
|
|
|
|
nsCOMPtr<nsIDOMXULContainerElement> parentContainer;
|
|
container->GetParentContainer(getter_AddRefs(parentContainer));
|
|
parentContainer.swap(container);
|
|
}
|
|
|
|
return level;
|
|
}
|
|
|
|
void
|
|
nsAccUtils::SetLiveContainerAttributes(nsIPersistentProperties *aAttributes,
|
|
nsIContent *aStartContent,
|
|
nsIContent *aTopContent)
|
|
{
|
|
nsAutoString live, relevant, busy;
|
|
nsIContent *ancestor = aStartContent;
|
|
while (ancestor) {
|
|
|
|
// container-relevant attribute
|
|
if (relevant.IsEmpty() &&
|
|
HasDefinedARIAToken(ancestor, nsGkAtoms::aria_relevant) &&
|
|
ancestor->GetAttr(kNameSpaceID_None, nsGkAtoms::aria_relevant, relevant))
|
|
SetAccAttr(aAttributes, nsGkAtoms::containerRelevant, relevant);
|
|
|
|
// container-live, and container-live-role attributes
|
|
if (live.IsEmpty()) {
|
|
nsRoleMapEntry* role = aria::GetRoleMap(ancestor);
|
|
if (HasDefinedARIAToken(ancestor, nsGkAtoms::aria_live)) {
|
|
ancestor->GetAttr(kNameSpaceID_None, nsGkAtoms::aria_live,
|
|
live);
|
|
} else if (role) {
|
|
GetLiveAttrValue(role->liveAttRule, live);
|
|
}
|
|
if (!live.IsEmpty()) {
|
|
SetAccAttr(aAttributes, nsGkAtoms::containerLive, live);
|
|
if (role) {
|
|
SetAccAttr(aAttributes, nsGkAtoms::containerLiveRole,
|
|
role->ARIARoleString());
|
|
}
|
|
}
|
|
}
|
|
|
|
// container-atomic attribute
|
|
if (ancestor->AttrValueIs(kNameSpaceID_None, nsGkAtoms::aria_atomic,
|
|
nsGkAtoms::_true, eCaseMatters)) {
|
|
SetAccAttr(aAttributes, nsGkAtoms::containerAtomic,
|
|
NS_LITERAL_STRING("true"));
|
|
}
|
|
|
|
// container-busy attribute
|
|
if (busy.IsEmpty() &&
|
|
HasDefinedARIAToken(ancestor, nsGkAtoms::aria_busy) &&
|
|
ancestor->GetAttr(kNameSpaceID_None, nsGkAtoms::aria_busy, busy))
|
|
SetAccAttr(aAttributes, nsGkAtoms::containerBusy, busy);
|
|
|
|
if (ancestor == aTopContent)
|
|
break;
|
|
|
|
ancestor = ancestor->GetParent();
|
|
if (!ancestor)
|
|
ancestor = aTopContent; // Use <body>/<frameset>
|
|
}
|
|
}
|
|
|
|
bool
|
|
nsAccUtils::HasDefinedARIAToken(nsIContent *aContent, nsIAtom *aAtom)
|
|
{
|
|
NS_ASSERTION(aContent, "aContent is null in call to HasDefinedARIAToken!");
|
|
|
|
if (!aContent->HasAttr(kNameSpaceID_None, aAtom) ||
|
|
aContent->AttrValueIs(kNameSpaceID_None, aAtom,
|
|
nsGkAtoms::_empty, eCaseMatters) ||
|
|
aContent->AttrValueIs(kNameSpaceID_None, aAtom,
|
|
nsGkAtoms::_undefined, eCaseMatters)) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
nsIAtom*
|
|
nsAccUtils::GetARIAToken(dom::Element* aElement, nsIAtom* aAttr)
|
|
{
|
|
if (!HasDefinedARIAToken(aElement, aAttr))
|
|
return nsGkAtoms::_empty;
|
|
|
|
static nsIContent::AttrValuesArray tokens[] =
|
|
{ &nsGkAtoms::_false, &nsGkAtoms::_true,
|
|
&nsGkAtoms::mixed, nullptr};
|
|
|
|
int32_t idx = aElement->FindAttrValueIn(kNameSpaceID_None,
|
|
aAttr, tokens, eCaseMatters);
|
|
if (idx >= 0)
|
|
return *(tokens[idx]);
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
Accessible*
|
|
nsAccUtils::GetSelectableContainer(Accessible* aAccessible, uint64_t aState)
|
|
{
|
|
if (!aAccessible)
|
|
return nullptr;
|
|
|
|
if (!(aState & states::SELECTABLE))
|
|
return nullptr;
|
|
|
|
Accessible* parent = aAccessible;
|
|
while ((parent = parent->Parent()) && !parent->IsSelect()) {
|
|
if (parent->Role() == roles::PANE)
|
|
return nullptr;
|
|
}
|
|
return parent;
|
|
}
|
|
|
|
bool
|
|
nsAccUtils::IsARIASelected(Accessible* aAccessible)
|
|
{
|
|
return aAccessible->GetContent()->
|
|
AttrValueIs(kNameSpaceID_None, nsGkAtoms::aria_selected,
|
|
nsGkAtoms::_true, eCaseMatters);
|
|
}
|
|
|
|
Accessible*
|
|
nsAccUtils::TableFor(Accessible* aRow)
|
|
{
|
|
if (aRow) {
|
|
Accessible* table = aRow->Parent();
|
|
if (table) {
|
|
roles::Role tableRole = table->Role();
|
|
if (tableRole == roles::GROUPING) { // if there's a rowgroup.
|
|
table = table->Parent();
|
|
if (table)
|
|
tableRole = table->Role();
|
|
}
|
|
|
|
return tableRole == roles::TABLE || tableRole == roles::TREE_TABLE ?
|
|
table : nullptr;
|
|
}
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
HyperTextAccessible*
|
|
nsAccUtils::GetTextContainer(nsINode* aNode)
|
|
{
|
|
// Get text accessible containing the result node.
|
|
DocAccessible* doc =
|
|
GetAccService()->GetDocAccessible(aNode->OwnerDoc());
|
|
Accessible* accessible =
|
|
doc ? doc->GetAccessibleOrContainer(aNode) : nullptr;
|
|
if (!accessible)
|
|
return nullptr;
|
|
|
|
do {
|
|
HyperTextAccessible* textAcc = accessible->AsHyperText();
|
|
if (textAcc)
|
|
return textAcc;
|
|
|
|
accessible = accessible->Parent();
|
|
} while (accessible);
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
nsIntPoint
|
|
nsAccUtils::ConvertToScreenCoords(int32_t aX, int32_t aY,
|
|
uint32_t aCoordinateType,
|
|
Accessible* aAccessible)
|
|
{
|
|
nsIntPoint coords(aX, aY);
|
|
|
|
switch (aCoordinateType) {
|
|
case nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE:
|
|
break;
|
|
|
|
case nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE:
|
|
{
|
|
coords += nsCoreUtils::GetScreenCoordsForWindow(aAccessible->GetNode());
|
|
break;
|
|
}
|
|
|
|
case nsIAccessibleCoordinateType::COORDTYPE_PARENT_RELATIVE:
|
|
{
|
|
coords += GetScreenCoordsForParent(aAccessible);
|
|
break;
|
|
}
|
|
|
|
default:
|
|
NS_NOTREACHED("invalid coord type!");
|
|
}
|
|
|
|
return coords;
|
|
}
|
|
|
|
void
|
|
nsAccUtils::ConvertScreenCoordsTo(int32_t *aX, int32_t *aY,
|
|
uint32_t aCoordinateType,
|
|
Accessible* aAccessible)
|
|
{
|
|
switch (aCoordinateType) {
|
|
case nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE:
|
|
break;
|
|
|
|
case nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE:
|
|
{
|
|
nsIntPoint coords = nsCoreUtils::GetScreenCoordsForWindow(aAccessible->GetNode());
|
|
*aX -= coords.x;
|
|
*aY -= coords.y;
|
|
break;
|
|
}
|
|
|
|
case nsIAccessibleCoordinateType::COORDTYPE_PARENT_RELATIVE:
|
|
{
|
|
nsIntPoint coords = GetScreenCoordsForParent(aAccessible);
|
|
*aX -= coords.x;
|
|
*aY -= coords.y;
|
|
break;
|
|
}
|
|
|
|
default:
|
|
NS_NOTREACHED("invalid coord type!");
|
|
}
|
|
}
|
|
|
|
nsIntPoint
|
|
nsAccUtils::GetScreenCoordsForParent(Accessible* aAccessible)
|
|
{
|
|
Accessible* parent = aAccessible->Parent();
|
|
if (!parent)
|
|
return nsIntPoint(0, 0);
|
|
|
|
nsIFrame *parentFrame = parent->GetFrame();
|
|
if (!parentFrame)
|
|
return nsIntPoint(0, 0);
|
|
|
|
nsRect rect = parentFrame->GetScreenRectInAppUnits();
|
|
return nsPoint(rect.x, rect.y).
|
|
ToNearestPixels(parentFrame->PresContext()->AppUnitsPerDevPixel());
|
|
}
|
|
|
|
bool
|
|
nsAccUtils::GetLiveAttrValue(uint32_t aRule, nsAString& aValue)
|
|
{
|
|
switch (aRule) {
|
|
case eOffLiveAttr:
|
|
aValue = NS_LITERAL_STRING("off");
|
|
return true;
|
|
case ePoliteLiveAttr:
|
|
aValue = NS_LITERAL_STRING("polite");
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
#ifdef DEBUG
|
|
|
|
bool
|
|
nsAccUtils::IsTextInterfaceSupportCorrect(Accessible* aAccessible)
|
|
{
|
|
// Don't test for accessible docs, it makes us create accessibles too
|
|
// early and fire mutation events before we need to
|
|
if (aAccessible->IsDoc())
|
|
return true;
|
|
|
|
bool foundText = false;
|
|
uint32_t childCount = aAccessible->ChildCount();
|
|
for (uint32_t childIdx = 0; childIdx < childCount; childIdx++) {
|
|
Accessible* child = aAccessible->GetChildAt(childIdx);
|
|
if (!IsEmbeddedObject(child)) {
|
|
foundText = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
return !foundText || aAccessible->IsHyperText();
|
|
}
|
|
#endif
|
|
|
|
uint32_t
|
|
nsAccUtils::TextLength(Accessible* aAccessible)
|
|
{
|
|
if (IsEmbeddedObject(aAccessible))
|
|
return 1;
|
|
|
|
TextLeafAccessible* textLeaf = aAccessible->AsTextLeaf();
|
|
if (textLeaf)
|
|
return textLeaf->Text().Length();
|
|
|
|
// For list bullets (or anything other accessible which would compute its own
|
|
// text. They don't have their own frame.
|
|
// XXX In the future, list bullets may have frame and anon content, so
|
|
// we should be able to remove this at that point
|
|
nsAutoString text;
|
|
aAccessible->AppendTextTo(text); // Get all the text
|
|
return text.Length();
|
|
}
|
|
|
|
bool
|
|
nsAccUtils::MustPrune(Accessible* aAccessible)
|
|
{
|
|
roles::Role role = aAccessible->Role();
|
|
|
|
// Don't prune the tree for certain roles if the tree is more complex than
|
|
// a single text leaf.
|
|
return
|
|
(role == roles::MENUITEM ||
|
|
role == roles::COMBOBOX_OPTION ||
|
|
role == roles::OPTION ||
|
|
role == roles::ENTRY ||
|
|
role == roles::FLAT_EQUATION ||
|
|
role == roles::PASSWORD_TEXT ||
|
|
role == roles::PUSHBUTTON ||
|
|
role == roles::TOGGLE_BUTTON ||
|
|
role == roles::GRAPHIC ||
|
|
role == roles::SLIDER ||
|
|
role == roles::PROGRESSBAR ||
|
|
role == roles::SEPARATOR) &&
|
|
aAccessible->ContentChildCount() == 1 &&
|
|
aAccessible->ContentChildAt(0)->IsTextLeaf();
|
|
}
|