зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1261439 - replace nsAccUtils::IsEmbeddedObject on a bit flag check, r=marcoz
This commit is contained in:
Родитель
7d26b6ad37
Коммит
f34bc138b9
|
@ -286,7 +286,7 @@ AccessibleWrap::GetNativeInterface(void** aOutAccessible)
|
|||
*aOutAccessible = nullptr;
|
||||
|
||||
if (!mAtkObject) {
|
||||
if (IsDefunct() || !nsAccUtils::IsEmbeddedObject(this)) {
|
||||
if (IsDefunct() || IsText()) {
|
||||
// We don't create ATK objects for node which has been shutdown or
|
||||
// plain text leaves
|
||||
return;
|
||||
|
|
|
@ -83,8 +83,9 @@ enum AccGenericType {
|
|||
eTable = 1 << 12,
|
||||
eTableCell = 1 << 13,
|
||||
eTableRow = 1 << 14,
|
||||
eText = 1 << 15,
|
||||
|
||||
eLastAccGenericType = eTableRow
|
||||
eLastAccGenericType = eText
|
||||
};
|
||||
|
||||
} // namespace a11y
|
||||
|
|
|
@ -53,6 +53,5 @@ filters::GetCell(Accessible* aAccessible)
|
|||
uint32_t
|
||||
filters::GetEmbeddedObject(Accessible* aAccessible)
|
||||
{
|
||||
return nsAccUtils::IsEmbeddedObject(aAccessible) ?
|
||||
eMatch | eSkipSubtree : eSkipSubtree;
|
||||
return aAccessible->IsText() ? eSkipSubtree : eMatch | eSkipSubtree;
|
||||
}
|
||||
|
|
|
@ -49,10 +49,10 @@ TextAttrsMgr::GetAttributes(nsIPersistentProperties* aAttributes,
|
|||
"Wrong usage of TextAttrsMgr!");
|
||||
|
||||
// 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--) {
|
||||
Accessible* currAcc = mHyperTextAcc->GetChildAt(childIdx);
|
||||
if (!nsAccUtils::IsEmbeddedObject(currAcc))
|
||||
if (currAcc->IsText())
|
||||
break;
|
||||
|
||||
(*aStartOffset)--;
|
||||
|
@ -62,7 +62,7 @@ TextAttrsMgr::GetAttributes(nsIPersistentProperties* aAttributes,
|
|||
for (uint32_t childIdx = mOffsetAccIdx + 1; childIdx < childCount;
|
||||
childIdx++) {
|
||||
Accessible* currAcc = mHyperTextAcc->GetChildAt(childIdx);
|
||||
if (!nsAccUtils::IsEmbeddedObject(currAcc))
|
||||
if (currAcc->IsText())
|
||||
break;
|
||||
|
||||
(*aEndOffset)++;
|
||||
|
@ -162,7 +162,7 @@ TextAttrsMgr::GetRange(TextAttr* aAttrArray[], uint32_t aAttrArrayLen,
|
|||
|
||||
// Stop on embedded accessible since embedded accessibles are combined into
|
||||
// own range.
|
||||
if (nsAccUtils::IsEmbeddedObject(currAcc))
|
||||
if (!currAcc->IsText())
|
||||
break;
|
||||
|
||||
bool offsetFound = false;
|
||||
|
@ -184,7 +184,7 @@ TextAttrsMgr::GetRange(TextAttr* aAttrArray[], uint32_t aAttrArrayLen,
|
|||
uint32_t childLen = mHyperTextAcc->ChildCount();
|
||||
for (uint32_t childIdx = mOffsetAccIdx + 1; childIdx < childLen; childIdx++) {
|
||||
Accessible* currAcc = mHyperTextAcc->GetChildAt(childIdx);
|
||||
if (nsAccUtils::IsEmbeddedObject(currAcc))
|
||||
if (!currAcc->IsText())
|
||||
break;
|
||||
|
||||
bool offsetFound = false;
|
||||
|
|
|
@ -66,8 +66,9 @@ TextRange::EmbeddedChildren(nsTArray<Accessible*>* aChildren) const
|
|||
int32_t endIdx = mStartContainer->GetChildIndexAtOffset(mEndOffset);
|
||||
for (int32_t idx = startIdx; idx <= endIdx; idx++) {
|
||||
Accessible* child = mStartContainer->GetChildAt(idx);
|
||||
if (nsAccUtils::IsEmbeddedObject(child))
|
||||
if (!child->IsText()) {
|
||||
aChildren->AppendElement(child);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -87,8 +88,9 @@ TextRange::EmbeddedChildren(nsTArray<Accessible*>* aChildren) const
|
|||
uint32_t childCount = parent->ChildCount();
|
||||
for (uint32_t childIdx = child->IndexInParent(); childIdx < childCount; childIdx++) {
|
||||
Accessible* next = parent->GetChildAt(childIdx);
|
||||
if (nsAccUtils::IsEmbeddedObject(next))
|
||||
if (!next->IsText()) {
|
||||
aChildren->AppendElement(next);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,8 +99,9 @@ TextRange::EmbeddedChildren(nsTArray<Accessible*>* aChildren) const
|
|||
int32_t childIdx = parents1[pos1 - 1]->IndexInParent() + 1;
|
||||
for (; childIdx < endIdx; childIdx++) {
|
||||
Accessible* next = container->GetChildAt(childIdx);
|
||||
if (nsAccUtils::IsEmbeddedObject(next))
|
||||
if (!next->IsText()) {
|
||||
aChildren->AppendElement(next);
|
||||
}
|
||||
}
|
||||
|
||||
// Traverse down from the container to end point.
|
||||
|
@ -108,8 +111,9 @@ TextRange::EmbeddedChildren(nsTArray<Accessible*>* aChildren) const
|
|||
int32_t endIdx = child->IndexInParent();
|
||||
for (int32_t childIdx = 0; childIdx < endIdx; childIdx++) {
|
||||
Accessible* next = parent->GetChildAt(childIdx);
|
||||
if (nsAccUtils::IsEmbeddedObject(next))
|
||||
if (!next->IsText()) {
|
||||
aChildren->AppendElement(next);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -392,7 +392,7 @@ nsAccUtils::IsTextInterfaceSupportCorrect(Accessible* aAccessible)
|
|||
uint32_t childCount = aAccessible->ChildCount();
|
||||
for (uint32_t childIdx = 0; childIdx < childCount; childIdx++) {
|
||||
Accessible* child = aAccessible->GetChildAt(childIdx);
|
||||
if (!IsEmbeddedObject(child)) {
|
||||
if (child->IsText()) {
|
||||
foundText = true;
|
||||
break;
|
||||
}
|
||||
|
@ -405,8 +405,9 @@ nsAccUtils::IsTextInterfaceSupportCorrect(Accessible* aAccessible)
|
|||
uint32_t
|
||||
nsAccUtils::TextLength(Accessible* aAccessible)
|
||||
{
|
||||
if (IsEmbeddedObject(aAccessible))
|
||||
if (!aAccessible->IsText()) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
TextLeafAccessible* textLeaf = aAccessible->AsTextLeaf();
|
||||
if (textLeaf)
|
||||
|
|
|
@ -203,17 +203,6 @@ public:
|
|||
*/
|
||||
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.
|
||||
*/
|
||||
|
|
|
@ -393,7 +393,7 @@ nsAccessiblePivot::MoveNextByText(TextBoundaryType aBoundary,
|
|||
Accessible* childAtOffset = nullptr;
|
||||
for (int32_t i = tempStart; i < tempEnd; i++) {
|
||||
childAtOffset = text->GetChildAtOffset(i);
|
||||
if (childAtOffset && nsAccUtils::IsEmbeddedObject(childAtOffset)) {
|
||||
if (childAtOffset && !childAtOffset->IsText()) {
|
||||
tempEnd = i;
|
||||
break;
|
||||
}
|
||||
|
@ -401,7 +401,7 @@ nsAccessiblePivot::MoveNextByText(TextBoundaryType aBoundary,
|
|||
// 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
|
||||
// the child as the starting point.
|
||||
if (childAtOffset && nsAccUtils::IsEmbeddedObject(childAtOffset) &&
|
||||
if (childAtOffset && !childAtOffset->IsText() &&
|
||||
tempStart == static_cast<int32_t>(childAtOffset->StartOffset())) {
|
||||
tempPosition = childAtOffset;
|
||||
tempStart = tempEnd = -1;
|
||||
|
@ -524,7 +524,7 @@ nsAccessiblePivot::MovePreviousByText(TextBoundaryType aBoundary,
|
|||
Accessible* childAtOffset = nullptr;
|
||||
for (int32_t i = tempEnd - 1; i >= tempStart; i--) {
|
||||
childAtOffset = text->GetChildAtOffset(i);
|
||||
if (childAtOffset && nsAccUtils::IsEmbeddedObject(childAtOffset)) {
|
||||
if (childAtOffset && !childAtOffset->IsText()) {
|
||||
tempStart = childAtOffset->EndOffset();
|
||||
break;
|
||||
}
|
||||
|
@ -532,7 +532,7 @@ nsAccessiblePivot::MovePreviousByText(TextBoundaryType aBoundary,
|
|||
// 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
|
||||
// the child as the starting point.
|
||||
if (childAtOffset && nsAccUtils::IsEmbeddedObject(childAtOffset) &&
|
||||
if (childAtOffset && !childAtOffset->IsText() &&
|
||||
tempEnd == static_cast<int32_t>(childAtOffset->EndOffset())) {
|
||||
tempPosition = childAtOffset;
|
||||
tempStart = tempEnd = childAtOffset->AsHyperText()->CharacterCount();
|
||||
|
|
|
@ -2076,7 +2076,7 @@ Accessible::InsertChildAt(uint32_t aIndex, Accessible* aChild)
|
|||
MOZ_ASSERT(mStateFlags & eKidsMutating, "Illicit children change");
|
||||
}
|
||||
|
||||
if (!nsAccUtils::IsEmbeddedObject(aChild)) {
|
||||
if (aChild->IsText()) {
|
||||
mStateFlags |= eHasTextKids;
|
||||
}
|
||||
|
||||
|
@ -2235,7 +2235,7 @@ Accessible::IsLink()
|
|||
{
|
||||
// Every embedded accessible within hypertext accessible implements
|
||||
// hyperlink interface.
|
||||
return mParent && mParent->IsHyperText() && nsAccUtils::IsEmbeddedObject(this);
|
||||
return mParent && mParent->IsHyperText() && !IsText();
|
||||
}
|
||||
|
||||
uint32_t
|
||||
|
|
|
@ -641,6 +641,8 @@ public:
|
|||
|
||||
bool IsTextField() const { return mType == eHTMLTextFieldType; }
|
||||
|
||||
bool IsText() const { return mGenericTypes & eText; }
|
||||
|
||||
bool IsTextLeaf() const { return mType == eTextLeafType; }
|
||||
TextLeafAccessible* AsTextLeaf();
|
||||
|
||||
|
@ -1099,7 +1101,7 @@ protected:
|
|||
static const uint8_t kStateFlagsBits = 13;
|
||||
static const uint8_t kContextFlagsBits = 3;
|
||||
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.
|
||||
|
|
|
@ -20,6 +20,7 @@ TextLeafAccessible::
|
|||
LinkableAccessible(aContent, aDoc)
|
||||
{
|
||||
mType = eTextLeafType;
|
||||
mGenericTypes |= eText;
|
||||
mStateFlags |= eNoKidsFromDOM;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ public:
|
|||
LeafAccessible(aContent, aDoc)
|
||||
{
|
||||
mType = eHTMLBRType;
|
||||
mGenericTypes |= eText;
|
||||
}
|
||||
|
||||
// Accessible
|
||||
|
|
|
@ -125,6 +125,7 @@ HTMLListBulletAccessible::
|
|||
HTMLListBulletAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
||||
LeafAccessible(aContent, aDoc)
|
||||
{
|
||||
mGenericTypes |= eText;
|
||||
mStateFlags |= eSharedNode;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче