Bug 1261439 - replace nsAccUtils::IsEmbeddedObject on a bit flag check, r=marcoz

This commit is contained in:
Alexander Surkov 2016-04-08 08:35:11 -04:00
Родитель 7d26b6ad37
Коммит f34bc138b9
13 изменённых файлов: 32 добавлений и 33 удалений

Просмотреть файл

@ -286,7 +286,7 @@ AccessibleWrap::GetNativeInterface(void** aOutAccessible)
*aOutAccessible = nullptr; *aOutAccessible = nullptr;
if (!mAtkObject) { if (!mAtkObject) {
if (IsDefunct() || !nsAccUtils::IsEmbeddedObject(this)) { if (IsDefunct() || IsText()) {
// We don't create ATK objects for node which has been shutdown or // We don't create ATK objects for node which has been shutdown or
// plain text leaves // plain text leaves
return; return;

Просмотреть файл

@ -83,8 +83,9 @@ enum AccGenericType {
eTable = 1 << 12, eTable = 1 << 12,
eTableCell = 1 << 13, eTableCell = 1 << 13,
eTableRow = 1 << 14, eTableRow = 1 << 14,
eText = 1 << 15,
eLastAccGenericType = eTableRow eLastAccGenericType = eText
}; };
} // namespace a11y } // namespace a11y

Просмотреть файл

@ -53,6 +53,5 @@ filters::GetCell(Accessible* aAccessible)
uint32_t uint32_t
filters::GetEmbeddedObject(Accessible* aAccessible) filters::GetEmbeddedObject(Accessible* aAccessible)
{ {
return nsAccUtils::IsEmbeddedObject(aAccessible) ? return aAccessible->IsText() ? eSkipSubtree : eMatch | eSkipSubtree;
eMatch | eSkipSubtree : eSkipSubtree;
} }

Просмотреть файл

@ -49,10 +49,10 @@ TextAttrsMgr::GetAttributes(nsIPersistentProperties* aAttributes,
"Wrong usage of TextAttrsMgr!"); "Wrong usage of TextAttrsMgr!");
// Embedded objects are combined into own range with empty attributes set. // Embedded objects are combined into own range with empty attributes set.
if (mOffsetAcc && nsAccUtils::IsEmbeddedObject(mOffsetAcc)) { if (mOffsetAcc && !mOffsetAcc->IsText()) {
for (int32_t childIdx = mOffsetAccIdx - 1; childIdx >= 0; childIdx--) { for (int32_t childIdx = mOffsetAccIdx - 1; childIdx >= 0; childIdx--) {
Accessible* currAcc = mHyperTextAcc->GetChildAt(childIdx); Accessible* currAcc = mHyperTextAcc->GetChildAt(childIdx);
if (!nsAccUtils::IsEmbeddedObject(currAcc)) if (currAcc->IsText())
break; break;
(*aStartOffset)--; (*aStartOffset)--;
@ -62,7 +62,7 @@ TextAttrsMgr::GetAttributes(nsIPersistentProperties* aAttributes,
for (uint32_t childIdx = mOffsetAccIdx + 1; childIdx < childCount; for (uint32_t childIdx = mOffsetAccIdx + 1; childIdx < childCount;
childIdx++) { childIdx++) {
Accessible* currAcc = mHyperTextAcc->GetChildAt(childIdx); Accessible* currAcc = mHyperTextAcc->GetChildAt(childIdx);
if (!nsAccUtils::IsEmbeddedObject(currAcc)) if (currAcc->IsText())
break; break;
(*aEndOffset)++; (*aEndOffset)++;
@ -162,7 +162,7 @@ TextAttrsMgr::GetRange(TextAttr* aAttrArray[], uint32_t aAttrArrayLen,
// Stop on embedded accessible since embedded accessibles are combined into // Stop on embedded accessible since embedded accessibles are combined into
// own range. // own range.
if (nsAccUtils::IsEmbeddedObject(currAcc)) if (!currAcc->IsText())
break; break;
bool offsetFound = false; bool offsetFound = false;
@ -184,7 +184,7 @@ TextAttrsMgr::GetRange(TextAttr* aAttrArray[], uint32_t aAttrArrayLen,
uint32_t childLen = mHyperTextAcc->ChildCount(); uint32_t childLen = mHyperTextAcc->ChildCount();
for (uint32_t childIdx = mOffsetAccIdx + 1; childIdx < childLen; childIdx++) { for (uint32_t childIdx = mOffsetAccIdx + 1; childIdx < childLen; childIdx++) {
Accessible* currAcc = mHyperTextAcc->GetChildAt(childIdx); Accessible* currAcc = mHyperTextAcc->GetChildAt(childIdx);
if (nsAccUtils::IsEmbeddedObject(currAcc)) if (!currAcc->IsText())
break; break;
bool offsetFound = false; bool offsetFound = false;

Просмотреть файл

@ -66,8 +66,9 @@ TextRange::EmbeddedChildren(nsTArray<Accessible*>* aChildren) const
int32_t endIdx = mStartContainer->GetChildIndexAtOffset(mEndOffset); int32_t endIdx = mStartContainer->GetChildIndexAtOffset(mEndOffset);
for (int32_t idx = startIdx; idx <= endIdx; idx++) { for (int32_t idx = startIdx; idx <= endIdx; idx++) {
Accessible* child = mStartContainer->GetChildAt(idx); Accessible* child = mStartContainer->GetChildAt(idx);
if (nsAccUtils::IsEmbeddedObject(child)) if (!child->IsText()) {
aChildren->AppendElement(child); aChildren->AppendElement(child);
}
} }
return; return;
} }
@ -87,8 +88,9 @@ TextRange::EmbeddedChildren(nsTArray<Accessible*>* aChildren) const
uint32_t childCount = parent->ChildCount(); uint32_t childCount = parent->ChildCount();
for (uint32_t childIdx = child->IndexInParent(); childIdx < childCount; childIdx++) { for (uint32_t childIdx = child->IndexInParent(); childIdx < childCount; childIdx++) {
Accessible* next = parent->GetChildAt(childIdx); Accessible* next = parent->GetChildAt(childIdx);
if (nsAccUtils::IsEmbeddedObject(next)) if (!next->IsText()) {
aChildren->AppendElement(next); aChildren->AppendElement(next);
}
} }
} }
@ -97,8 +99,9 @@ TextRange::EmbeddedChildren(nsTArray<Accessible*>* aChildren) const
int32_t childIdx = parents1[pos1 - 1]->IndexInParent() + 1; int32_t childIdx = parents1[pos1 - 1]->IndexInParent() + 1;
for (; childIdx < endIdx; childIdx++) { for (; childIdx < endIdx; childIdx++) {
Accessible* next = container->GetChildAt(childIdx); Accessible* next = container->GetChildAt(childIdx);
if (nsAccUtils::IsEmbeddedObject(next)) if (!next->IsText()) {
aChildren->AppendElement(next); aChildren->AppendElement(next);
}
} }
// Traverse down from the container to end point. // Traverse down from the container to end point.
@ -108,8 +111,9 @@ TextRange::EmbeddedChildren(nsTArray<Accessible*>* aChildren) const
int32_t endIdx = child->IndexInParent(); int32_t endIdx = child->IndexInParent();
for (int32_t childIdx = 0; childIdx < endIdx; childIdx++) { for (int32_t childIdx = 0; childIdx < endIdx; childIdx++) {
Accessible* next = parent->GetChildAt(childIdx); Accessible* next = parent->GetChildAt(childIdx);
if (nsAccUtils::IsEmbeddedObject(next)) if (!next->IsText()) {
aChildren->AppendElement(next); aChildren->AppendElement(next);
}
} }
} }
} }

Просмотреть файл

@ -392,7 +392,7 @@ nsAccUtils::IsTextInterfaceSupportCorrect(Accessible* aAccessible)
uint32_t childCount = aAccessible->ChildCount(); uint32_t childCount = aAccessible->ChildCount();
for (uint32_t childIdx = 0; childIdx < childCount; childIdx++) { for (uint32_t childIdx = 0; childIdx < childCount; childIdx++) {
Accessible* child = aAccessible->GetChildAt(childIdx); Accessible* child = aAccessible->GetChildAt(childIdx);
if (!IsEmbeddedObject(child)) { if (child->IsText()) {
foundText = true; foundText = true;
break; break;
} }
@ -405,8 +405,9 @@ nsAccUtils::IsTextInterfaceSupportCorrect(Accessible* aAccessible)
uint32_t uint32_t
nsAccUtils::TextLength(Accessible* aAccessible) nsAccUtils::TextLength(Accessible* aAccessible)
{ {
if (IsEmbeddedObject(aAccessible)) if (!aAccessible->IsText()) {
return 1; return 1;
}
TextLeafAccessible* textLeaf = aAccessible->AsTextLeaf(); TextLeafAccessible* textLeaf = aAccessible->AsTextLeaf();
if (textLeaf) if (textLeaf)

Просмотреть файл

@ -203,17 +203,6 @@ public:
*/ */
static uint32_t TextLength(Accessible* aAccessible); static uint32_t TextLength(Accessible* aAccessible);
/**
* Return true if the given accessible is embedded object.
*/
static bool IsEmbeddedObject(Accessible* aAcc)
{
uint32_t role = aAcc->Role();
return role != roles::TEXT_LEAF &&
role != roles::WHITESPACE &&
role != roles::STATICTEXT;
}
/** /**
* Transform nsIAccessibleStates constants to internal state constant. * Transform nsIAccessibleStates constants to internal state constant.
*/ */

Просмотреть файл

@ -393,7 +393,7 @@ nsAccessiblePivot::MoveNextByText(TextBoundaryType aBoundary,
Accessible* childAtOffset = nullptr; Accessible* childAtOffset = nullptr;
for (int32_t i = tempStart; i < tempEnd; i++) { for (int32_t i = tempStart; i < tempEnd; i++) {
childAtOffset = text->GetChildAtOffset(i); childAtOffset = text->GetChildAtOffset(i);
if (childAtOffset && nsAccUtils::IsEmbeddedObject(childAtOffset)) { if (childAtOffset && !childAtOffset->IsText()) {
tempEnd = i; tempEnd = i;
break; break;
} }
@ -401,7 +401,7 @@ nsAccessiblePivot::MoveNextByText(TextBoundaryType aBoundary,
// If there's an embedded character at the very start of the range, we // If there's an embedded character at the very start of the range, we
// instead want to traverse into it. So restart the movement with // instead want to traverse into it. So restart the movement with
// the child as the starting point. // the child as the starting point.
if (childAtOffset && nsAccUtils::IsEmbeddedObject(childAtOffset) && if (childAtOffset && !childAtOffset->IsText() &&
tempStart == static_cast<int32_t>(childAtOffset->StartOffset())) { tempStart == static_cast<int32_t>(childAtOffset->StartOffset())) {
tempPosition = childAtOffset; tempPosition = childAtOffset;
tempStart = tempEnd = -1; tempStart = tempEnd = -1;
@ -524,7 +524,7 @@ nsAccessiblePivot::MovePreviousByText(TextBoundaryType aBoundary,
Accessible* childAtOffset = nullptr; Accessible* childAtOffset = nullptr;
for (int32_t i = tempEnd - 1; i >= tempStart; i--) { for (int32_t i = tempEnd - 1; i >= tempStart; i--) {
childAtOffset = text->GetChildAtOffset(i); childAtOffset = text->GetChildAtOffset(i);
if (childAtOffset && nsAccUtils::IsEmbeddedObject(childAtOffset)) { if (childAtOffset && !childAtOffset->IsText()) {
tempStart = childAtOffset->EndOffset(); tempStart = childAtOffset->EndOffset();
break; break;
} }
@ -532,7 +532,7 @@ nsAccessiblePivot::MovePreviousByText(TextBoundaryType aBoundary,
// If there's an embedded character at the very end of the range, we // If there's an embedded character at the very end of the range, we
// instead want to traverse into it. So restart the movement with // instead want to traverse into it. So restart the movement with
// the child as the starting point. // the child as the starting point.
if (childAtOffset && nsAccUtils::IsEmbeddedObject(childAtOffset) && if (childAtOffset && !childAtOffset->IsText() &&
tempEnd == static_cast<int32_t>(childAtOffset->EndOffset())) { tempEnd == static_cast<int32_t>(childAtOffset->EndOffset())) {
tempPosition = childAtOffset; tempPosition = childAtOffset;
tempStart = tempEnd = childAtOffset->AsHyperText()->CharacterCount(); tempStart = tempEnd = childAtOffset->AsHyperText()->CharacterCount();

Просмотреть файл

@ -2076,7 +2076,7 @@ Accessible::InsertChildAt(uint32_t aIndex, Accessible* aChild)
MOZ_ASSERT(mStateFlags & eKidsMutating, "Illicit children change"); MOZ_ASSERT(mStateFlags & eKidsMutating, "Illicit children change");
} }
if (!nsAccUtils::IsEmbeddedObject(aChild)) { if (aChild->IsText()) {
mStateFlags |= eHasTextKids; mStateFlags |= eHasTextKids;
} }
@ -2235,7 +2235,7 @@ Accessible::IsLink()
{ {
// Every embedded accessible within hypertext accessible implements // Every embedded accessible within hypertext accessible implements
// hyperlink interface. // hyperlink interface.
return mParent && mParent->IsHyperText() && nsAccUtils::IsEmbeddedObject(this); return mParent && mParent->IsHyperText() && !IsText();
} }
uint32_t uint32_t

Просмотреть файл

@ -641,6 +641,8 @@ public:
bool IsTextField() const { return mType == eHTMLTextFieldType; } bool IsTextField() const { return mType == eHTMLTextFieldType; }
bool IsText() const { return mGenericTypes & eText; }
bool IsTextLeaf() const { return mType == eTextLeafType; } bool IsTextLeaf() const { return mType == eTextLeafType; }
TextLeafAccessible* AsTextLeaf(); TextLeafAccessible* AsTextLeaf();
@ -1099,7 +1101,7 @@ protected:
static const uint8_t kStateFlagsBits = 13; static const uint8_t kStateFlagsBits = 13;
static const uint8_t kContextFlagsBits = 3; static const uint8_t kContextFlagsBits = 3;
static const uint8_t kTypeBits = 6; static const uint8_t kTypeBits = 6;
static const uint8_t kGenericTypesBits = 15; static const uint8_t kGenericTypesBits = 16;
/** /**
* Keep in sync with StateFlags, ContextFlags, and AccTypes. * Keep in sync with StateFlags, ContextFlags, and AccTypes.

Просмотреть файл

@ -20,6 +20,7 @@ TextLeafAccessible::
LinkableAccessible(aContent, aDoc) LinkableAccessible(aContent, aDoc)
{ {
mType = eTextLeafType; mType = eTextLeafType;
mGenericTypes |= eText;
mStateFlags |= eNoKidsFromDOM; mStateFlags |= eNoKidsFromDOM;
} }

Просмотреть файл

@ -36,6 +36,7 @@ public:
LeafAccessible(aContent, aDoc) LeafAccessible(aContent, aDoc)
{ {
mType = eHTMLBRType; mType = eHTMLBRType;
mGenericTypes |= eText;
} }
// Accessible // Accessible

Просмотреть файл

@ -125,6 +125,7 @@ HTMLListBulletAccessible::
HTMLListBulletAccessible(nsIContent* aContent, DocAccessible* aDoc) : HTMLListBulletAccessible(nsIContent* aContent, DocAccessible* aDoc) :
LeafAccessible(aContent, aDoc) LeafAccessible(aContent, aDoc)
{ {
mGenericTypes |= eText;
mStateFlags |= eSharedNode; mStateFlags |= eSharedNode;
} }