Bug 971831 - Replace the call of |RangeBoundToHypertextOffset| with its content. r=surkov

This commit is contained in:
Peiyong Lin 2014-02-14 11:40:08 -05:00
parent ba44b7e8bd
commit 0c5507d8b8
2 changed files with 9 additions and 53 deletions

View File

@ -1761,28 +1761,6 @@ HyperTextAccessible::GetDOMPointByFrameOffset(nsIFrame* aFrame, int32_t aOffset,
return NS_OK; return NS_OK;
} }
// HyperTextAccessible
nsresult
HyperTextAccessible::RangeBoundToHypertextOffset(nsRange* aRange,
bool aIsStartBound,
bool aIsStartHTOffset,
int32_t* aOffset)
{
nsINode* node = nullptr;
int32_t nodeOffset = 0;
if (aIsStartBound) {
node = aRange->GetStartParent();
nodeOffset = aRange->StartOffset();
} else {
node = aRange->GetEndParent();
nodeOffset = aRange->EndOffset();
}
*aOffset = DOMPointToOffset(node, nodeOffset);
return NS_OK;
}
// HyperTextAccessible // HyperTextAccessible
nsresult nsresult
HyperTextAccessible::GetSpellTextAttribute(nsINode* aNode, HyperTextAccessible::GetSpellTextAttribute(nsINode* aNode,
@ -1825,11 +1803,9 @@ HyperTextAccessible::GetSpellTextAttribute(nsINode* aNode,
int32_t startOffset = range->StartOffset(); int32_t startOffset = range->StartOffset();
if (nsContentUtils::ComparePoints(startNode, startOffset, aNode, if (nsContentUtils::ComparePoints(startNode, startOffset, aNode,
aNodeOffset) <= 0) { aNodeOffset) <= 0) {
rv = RangeBoundToHypertextOffset(range, true, true, &startHTOffset); startHTOffset = DOMPointToOffset(startNode, startOffset);
NS_ENSURE_SUCCESS(rv, rv);
rv = RangeBoundToHypertextOffset(range, false, false, &endHTOffset); endHTOffset = DOMPointToOffset(endNode, endOffset);
NS_ENSURE_SUCCESS(rv, rv);
if (startHTOffset > *aHTStartOffset) if (startHTOffset > *aHTStartOffset)
*aHTStartOffset = startHTOffset; *aHTStartOffset = startHTOffset;
@ -1846,13 +1822,12 @@ HyperTextAccessible::GetSpellTextAttribute(nsINode* aNode,
} }
// This range came after the point. // This range came after the point.
rv = RangeBoundToHypertextOffset(range, true, false, &endHTOffset); endHTOffset = DOMPointToOffset(startNode, startOffset);
NS_ENSURE_SUCCESS(rv, rv);
if (idx > 0) { if (idx > 0) {
rv = RangeBoundToHypertextOffset(domSel->GetRangeAt(idx - 1), false, nsRange* prevRange = domSel->GetRangeAt(idx - 1);
true, &startHTOffset); startHTOffset = DOMPointToOffset(prevRange->GetEndParent(),
NS_ENSURE_SUCCESS(rv, rv); prevRange->EndOffset());
} }
if (startHTOffset > *aHTStartOffset) if (startHTOffset > *aHTStartOffset)
@ -1868,9 +1843,9 @@ HyperTextAccessible::GetSpellTextAttribute(nsINode* aNode,
// the point is not in a range, that we do not need to compute an end offset, // the point is not in a range, that we do not need to compute an end offset,
// and that we should use the end offset of the last range to compute the // and that we should use the end offset of the last range to compute the
// start offset of the text attribute range. // start offset of the text attribute range.
rv = RangeBoundToHypertextOffset(domSel->GetRangeAt(rangeCount - 1), false, nsRange* prevRange = domSel->GetRangeAt(rangeCount - 1);
true, &startHTOffset); startHTOffset = DOMPointToOffset(prevRange->GetEndParent(),
NS_ENSURE_SUCCESS(rv, rv); prevRange->EndOffset());
if (startHTOffset > *aHTStartOffset) if (startHTOffset > *aHTStartOffset)
*aHTStartOffset = startHTOffset; *aHTStartOffset = startHTOffset;

View File

@ -473,25 +473,6 @@ protected:
Accessible* aAccessible, Accessible* aAccessible,
mozilla::a11y::DOMPoint* aPoint); mozilla::a11y::DOMPoint* aPoint);
/**
* Return hyper text offset for the specified bound of the given DOM range.
* If the bound is outside of the hyper text then offset value is either
* 0 or number of characters of hyper text, it depends on type of requested
* offset. The method is a wrapper for DOMPointToOffset.
*
* @param aRange [in] the given range
* @param aIsStartBound [in] specifies whether the required range bound is
* start bound
* @param aIsStartOffset [in] the offset type, used when the range bound is
* outside of hyper text
* @param aHTOffset [out] the result offset
*/
nsresult RangeBoundToHypertextOffset(nsRange *aRange,
bool aIsStartBound,
bool aIsStartOffset,
int32_t *aHTOffset);
/** /**
* Set 'misspelled' text attribute and return range offsets where the * Set 'misspelled' text attribute and return range offsets where the
* attibute is stretched. If the text is not misspelled at the given offset * attibute is stretched. If the text is not misspelled at the given offset