зеркало из https://github.com/mozilla/pjs.git
Bug 392818 - getTextAtOffset broken for all but the first line in a multi-line entry, r=ginn.chen, a=dsicore
This commit is contained in:
Родитель
c0c8114b7a
Коммит
db8a59dfa3
|
@ -624,8 +624,14 @@ nsresult nsHyperTextAccessible::DOMPointToHypertextOffset(nsIDOMNode* aNode, PRI
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRInt32 nsHyperTextAccessible::GetRelativeOffset(nsIPresShell *aPresShell, nsIFrame *aFromFrame, PRInt32 aFromOffset,
|
PRInt32
|
||||||
nsSelectionAmount aAmount, nsDirection aDirection, PRBool aNeedsStart)
|
nsHyperTextAccessible::GetRelativeOffset(nsIPresShell *aPresShell,
|
||||||
|
nsIFrame *aFromFrame,
|
||||||
|
PRInt32 aFromOffset,
|
||||||
|
nsIAccessible *aFromAccessible,
|
||||||
|
nsSelectionAmount aAmount,
|
||||||
|
nsDirection aDirection,
|
||||||
|
PRBool aNeedsStart)
|
||||||
{
|
{
|
||||||
const PRBool kIsJumpLinesOk = PR_TRUE; // okay to jump lines
|
const PRBool kIsJumpLinesOk = PR_TRUE; // okay to jump lines
|
||||||
const PRBool kIsScrollViewAStop = PR_FALSE; // do not stop at scroll views
|
const PRBool kIsScrollViewAStop = PR_FALSE; // do not stop at scroll views
|
||||||
|
@ -640,9 +646,18 @@ PRInt32 nsHyperTextAccessible::GetRelativeOffset(nsIPresShell *aPresShell, nsIFr
|
||||||
// Ask layout for the new node and offset, after moving the appropriate amount
|
// Ask layout for the new node and offset, after moving the appropriate amount
|
||||||
nsPeekOffsetStruct pos;
|
nsPeekOffsetStruct pos;
|
||||||
|
|
||||||
PRInt32 contentOffset;
|
nsresult rv;
|
||||||
nsresult rv = RenderedToContentOffset(aFromFrame, aFromOffset, &contentOffset);
|
PRInt32 contentOffset = aFromOffset;
|
||||||
|
if (IsText(aFromAccessible)) {
|
||||||
|
nsCOMPtr<nsPIAccessNode> accessNode(do_QueryInterface(aFromAccessible));
|
||||||
|
NS_ASSERTION(accessNode, "nsIAccessible doesn't support nsPIAccessNode");
|
||||||
|
|
||||||
|
nsIFrame *frame = accessNode->GetFrame();
|
||||||
|
NS_ENSURE_TRUE(frame, -1);
|
||||||
|
|
||||||
|
rv = RenderedToContentOffset(frame, aFromOffset, &contentOffset);
|
||||||
NS_ENSURE_SUCCESS(rv, -1);
|
NS_ENSURE_SUCCESS(rv, -1);
|
||||||
|
}
|
||||||
|
|
||||||
pos.SetData(aAmount, aDirection, contentOffset,
|
pos.SetData(aAmount, aDirection, contentOffset,
|
||||||
0, kIsJumpLinesOk, kIsScrollViewAStop, kIsKeyboardSelect, kIsVisualBidi,
|
0, kIsJumpLinesOk, kIsScrollViewAStop, kIsKeyboardSelect, kIsVisualBidi,
|
||||||
|
@ -740,7 +755,10 @@ nsresult nsHyperTextAccessible::GetTextHelper(EGetTextType aType, nsAccessibleTe
|
||||||
++ endOffset;
|
++ endOffset;
|
||||||
}
|
}
|
||||||
// Convert offsets to frame-relative
|
// Convert offsets to frame-relative
|
||||||
nsIFrame *startFrame = GetPosAndText(startOffset, endOffset);
|
nsCOMPtr<nsIAccessible> startAcc;
|
||||||
|
nsIFrame *startFrame = GetPosAndText(startOffset, endOffset, nsnull, nsnull,
|
||||||
|
nsnull, getter_AddRefs(startAcc));
|
||||||
|
|
||||||
if (!startFrame) {
|
if (!startFrame) {
|
||||||
PRInt32 textLength;
|
PRInt32 textLength;
|
||||||
GetCharacterCount(&textLength);
|
GetCharacterCount(&textLength);
|
||||||
|
@ -810,7 +828,8 @@ nsresult nsHyperTextAccessible::GetTextHelper(EGetTextType aType, nsAccessibleTe
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
finalStartOffset = GetRelativeOffset(presShell, startFrame, startOffset,
|
finalStartOffset = GetRelativeOffset(presShell, startFrame, startOffset,
|
||||||
amount, eDirPrevious, needsStart);
|
startAcc, amount, eDirPrevious,
|
||||||
|
needsStart);
|
||||||
NS_ENSURE_TRUE(finalStartOffset >= 0, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(finalStartOffset >= 0, NS_ERROR_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -822,12 +841,14 @@ nsresult nsHyperTextAccessible::GetTextHelper(EGetTextType aType, nsAccessibleTe
|
||||||
// 2 words/lines if the offset occured on whitespace boundary
|
// 2 words/lines if the offset occured on whitespace boundary
|
||||||
// Careful, startOffset and endOffset are passed by reference to GetPosAndText() and changed
|
// Careful, startOffset and endOffset are passed by reference to GetPosAndText() and changed
|
||||||
startOffset = endOffset = finalStartOffset;
|
startOffset = endOffset = finalStartOffset;
|
||||||
nsIFrame *endFrame = GetPosAndText(startOffset, endOffset);
|
nsCOMPtr<nsIAccessible> endAcc;
|
||||||
|
nsIFrame *endFrame = GetPosAndText(startOffset, endOffset, nsnull, nsnull,
|
||||||
|
nsnull, getter_AddRefs(endAcc));
|
||||||
if (!endFrame) {
|
if (!endFrame) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
finalEndOffset = GetRelativeOffset(presShell, endFrame, endOffset, amount,
|
finalEndOffset = GetRelativeOffset(presShell, endFrame, endOffset, endAcc,
|
||||||
eDirNext, needsStart);
|
amount, eDirNext, needsStart);
|
||||||
NS_ENSURE_TRUE(endOffset >= 0, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(endOffset >= 0, NS_ERROR_FAILURE);
|
||||||
if (finalEndOffset == aOffset) {
|
if (finalEndOffset == aOffset) {
|
||||||
// This happens sometimes when current character at finalStartOffset
|
// This happens sometimes when current character at finalStartOffset
|
||||||
|
|
|
@ -131,17 +131,23 @@ protected:
|
||||||
nsAString & aText);
|
nsAString & aText);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used by GetPosAndText to move backward/forward from a given point by word/line/etc.
|
* Used by GetTextHelper() to move backward/forward from a given point
|
||||||
* @param aPresShell, the current presshell we're moving in
|
* by word/line/etc.
|
||||||
* @param aFromFrame, the starting frame we're moving from
|
*
|
||||||
* @param aFromOffset, the starting offset we're moving from
|
* @param aPresShell the current presshell we're moving in
|
||||||
* @param aAmount, how much are we moving (word/line/etc.) ?
|
* @param aFromFrame the starting frame we're moving from
|
||||||
* @param aDirection, forward or backward?
|
* @param aFromOffset the starting offset we're moving from
|
||||||
* @param aNeedsStart, for word and line cases, are we basing this on the start or end?
|
* @param aFromAccessible the starting accessible we're moving from
|
||||||
* @return, the resulting offset into this hypertext
|
* @param aAmount how much are we moving (word/line/etc.) ?
|
||||||
|
* @param aDirection forward or backward?
|
||||||
|
* @param aNeedsStart for word and line cases, are we basing this on
|
||||||
|
* the start or end?
|
||||||
|
* @return the resulting offset into this hypertext
|
||||||
*/
|
*/
|
||||||
PRInt32 GetRelativeOffset(nsIPresShell *aPresShell, nsIFrame *aFromFrame, PRInt32 aFromOffset,
|
PRInt32 GetRelativeOffset(nsIPresShell *aPresShell, nsIFrame *aFromFrame,
|
||||||
nsSelectionAmount aAmount, nsDirection aDirection, PRBool aNeedsStart);
|
PRInt32 aFromOffset, nsIAccessible *aFromAccessible,
|
||||||
|
nsSelectionAmount aAmount, nsDirection aDirection,
|
||||||
|
PRBool aNeedsStart);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides information for substring that is defined by the given start
|
* Provides information for substring that is defined by the given start
|
||||||
|
|
Загрузка…
Ссылка в новой задаче