void TextAttrsMgr::GetRange(TextAttr* aAttrArray[], uint32_t aAttrArrayLen, uint32_t* aStartOffset, uint32_t* aEndOffset) { // Navigate backward from anchor accessible to find start offset. for (int32_t childIdx = mOffsetAccIdx - 1; childIdx >= 0; childIdx--) { Accessible* currAcc = mHyperTextAcc->GetChildAt(childIdx); // Stop on embedded accessible since embedded accessibles are combined into // own range. if (!currAcc->IsText()) break; MOZ_ASSERT(nsCoreUtils::GetDOMElementFor(currAcc->GetContent()), "Text accessible has to have an associated DOM element"); bool offsetFound = false; for (uint32_t attrIdx = 0; attrIdx < aAttrArrayLen; attrIdx++) { TextAttr* textAttr = aAttrArray[attrIdx]; if (!textAttr->Equal(currAcc)) { offsetFound = true; break; } } if (offsetFound) break; *(aStartOffset) -= nsAccUtils::TextLength(currAcc); } // Navigate forward from anchor accessible to find end offset. uint32_t childLen = mHyperTextAcc->ChildCount(); for (uint32_t childIdx = mOffsetAccIdx + 1; childIdx < childLen; childIdx++) { Accessible* currAcc = mHyperTextAcc->GetChildAt(childIdx); if (!currAcc->IsText()) break; MOZ_ASSERT(nsCoreUtils::GetDOMElementFor(currAcc->GetContent()), "Text accessible has to have an associated DOM element"); bool offsetFound = false; for (uint32_t attrIdx = 0; attrIdx < aAttrArrayLen; attrIdx++) { TextAttr* textAttr = aAttrArray[attrIdx]; // Alter the end offset when text attribute changes its value and stop // the search. if (!textAttr->Equal(currAcc)) { offsetFound = true; break; } } if (offsetFound) break; (*aEndOffset) += nsAccUtils::TextLength(currAcc); } }
void TextAttrsMgr::GetRange(TextAttr* aAttrArray[], PRUint32 aAttrArrayLen, PRInt32* aStartHTOffset, PRInt32* aEndHTOffset) { // Navigate backward from anchor accessible to find start offset. for (PRInt32 childIdx = mOffsetAccIdx - 1; childIdx >= 0; childIdx--) { Accessible* currAcc = mHyperTextAcc->GetChildAt(childIdx); // Stop on embedded accessible since embedded accessibles are combined into // own range. if (nsAccUtils::IsEmbeddedObject(currAcc)) break; bool offsetFound = false; for (PRUint32 attrIdx = 0; attrIdx < aAttrArrayLen; attrIdx++) { TextAttr* textAttr = aAttrArray[attrIdx]; if (!textAttr->Equal(currAcc)) { offsetFound = true; break; } } if (offsetFound) break; *(aStartHTOffset) -= nsAccUtils::TextLength(currAcc); } // Navigate forward from anchor accessible to find end offset. PRUint32 childLen = mHyperTextAcc->ChildCount(); for (PRUint32 childIdx = mOffsetAccIdx + 1; childIdx < childLen; childIdx++) { Accessible* currAcc = mHyperTextAcc->GetChildAt(childIdx); if (nsAccUtils::IsEmbeddedObject(currAcc)) break; bool offsetFound = false; for (PRUint32 attrIdx = 0; attrIdx < aAttrArrayLen; attrIdx++) { TextAttr* textAttr = aAttrArray[attrIdx]; // Alter the end offset when text attribute changes its value and stop // the search. if (!textAttr->Equal(currAcc)) { offsetFound = true; break; } } if (offsetFound) break; (*aEndHTOffset) += nsAccUtils::TextLength(currAcc); } }