зеркало из https://github.com/mozilla/pjs.git
Bug 414133. Accessible selection methods not working in form controls. r=surkov, a=dsicore
This commit is contained in:
Родитель
81674153f7
Коммит
cf5c0c49ed
|
@ -1001,9 +1001,6 @@ nsresult nsHyperTextAccessible::GetTextHelper(EGetTextType aType, nsAccessibleTe
|
||||||
nsCOMPtr<nsIAccessible> endAcc;
|
nsCOMPtr<nsIAccessible> endAcc;
|
||||||
nsIFrame *endFrame = GetPosAndText(startOffset, endOffset, nsnull, nsnull,
|
nsIFrame *endFrame = GetPosAndText(startOffset, endOffset, nsnull, nsnull,
|
||||||
nsnull, getter_AddRefs(endAcc));
|
nsnull, getter_AddRefs(endAcc));
|
||||||
if (!endFrame) {
|
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
}
|
|
||||||
if (endAcc && Role(endAcc) == nsIAccessibleRole::ROLE_STATICTEXT) {
|
if (endAcc && Role(endAcc) == nsIAccessibleRole::ROLE_STATICTEXT) {
|
||||||
// Static text like list bullets will ruin our forward calculation,
|
// Static text like list bullets will ruin our forward calculation,
|
||||||
// since the caret cannot be in the static text. Start just after the static text.
|
// since the caret cannot be in the static text. Start just after the static text.
|
||||||
|
@ -1011,6 +1008,9 @@ nsresult nsHyperTextAccessible::GetTextHelper(EGetTextType aType, nsAccessibleTe
|
||||||
endFrame = GetPosAndText(startOffset, endOffset, nsnull, nsnull,
|
endFrame = GetPosAndText(startOffset, endOffset, nsnull, nsnull,
|
||||||
nsnull, getter_AddRefs(endAcc));
|
nsnull, getter_AddRefs(endAcc));
|
||||||
}
|
}
|
||||||
|
if (!endFrame) {
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
finalEndOffset = GetRelativeOffset(presShell, endFrame, endOffset, endAcc,
|
finalEndOffset = GetRelativeOffset(presShell, endFrame, endOffset, endAcc,
|
||||||
amount, eDirNext, needsStart);
|
amount, eDirNext, needsStart);
|
||||||
NS_ENSURE_TRUE(endOffset >= 0, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(endOffset >= 0, NS_ERROR_FAILURE);
|
||||||
|
@ -1593,6 +1593,7 @@ nsresult nsHyperTextAccessible::GetSelections(nsISelectionController **aSelCon,
|
||||||
nsCOMPtr<nsISelection> domSel;
|
nsCOMPtr<nsISelection> domSel;
|
||||||
nsCOMPtr<nsISelectionController> selCon;
|
nsCOMPtr<nsISelectionController> selCon;
|
||||||
|
|
||||||
|
nsCOMPtr<nsIDOMNode> startNode;
|
||||||
nsCOMPtr<nsIEditor> editor;
|
nsCOMPtr<nsIEditor> editor;
|
||||||
GetAssociatedEditor(getter_AddRefs(editor));
|
GetAssociatedEditor(getter_AddRefs(editor));
|
||||||
nsCOMPtr<nsIPlaintextEditor> peditor(do_QueryInterface(editor));
|
nsCOMPtr<nsIPlaintextEditor> peditor(do_QueryInterface(editor));
|
||||||
|
@ -1608,7 +1609,12 @@ nsresult nsHyperTextAccessible::GetSelections(nsISelectionController **aSelCon,
|
||||||
|
|
||||||
editor->GetSelection(getter_AddRefs(domSel));
|
editor->GetSelection(getter_AddRefs(domSel));
|
||||||
NS_ENSURE_TRUE(domSel, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(domSel, NS_ERROR_FAILURE);
|
||||||
}
|
|
||||||
|
nsCOMPtr<nsIDOMElement> editorRoot;
|
||||||
|
editor->GetRootElement(getter_AddRefs(editorRoot));
|
||||||
|
startNode = do_QueryInterface(editorRoot);
|
||||||
|
NS_ENSURE_STATE(startNode);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
// Case 2: rich content subtree (can be rich editor)
|
// Case 2: rich content subtree (can be rich editor)
|
||||||
// This uses the selection controller from the entire document
|
// This uses the selection controller from the entire document
|
||||||
|
@ -1622,6 +1628,8 @@ nsresult nsHyperTextAccessible::GetSelections(nsISelectionController **aSelCon,
|
||||||
selCon->GetSelection(nsISelectionController::SELECTION_NORMAL,
|
selCon->GetSelection(nsISelectionController::SELECTION_NORMAL,
|
||||||
getter_AddRefs(domSel));
|
getter_AddRefs(domSel));
|
||||||
NS_ENSURE_TRUE(domSel, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(domSel, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
|
startNode = mDOMNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aSelCon) {
|
if (aSelCon) {
|
||||||
|
@ -1635,13 +1643,13 @@ nsresult nsHyperTextAccessible::GetSelections(nsISelectionController **aSelCon,
|
||||||
NS_ENSURE_TRUE(selection2, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(selection2, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
nsCOMPtr<nsIDOMNodeList> childNodes;
|
nsCOMPtr<nsIDOMNodeList> childNodes;
|
||||||
nsresult rv = mDOMNode->GetChildNodes(getter_AddRefs(childNodes));
|
nsresult rv = startNode->GetChildNodes(getter_AddRefs(childNodes));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
PRUint32 numChildren;
|
PRUint32 numChildren;
|
||||||
rv = childNodes->GetLength(&numChildren);
|
rv = childNodes->GetLength(&numChildren);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
rv = selection2->GetRangesForIntervalCOMArray(mDOMNode, 0,
|
rv = selection2->GetRangesForIntervalCOMArray(startNode, 0,
|
||||||
mDOMNode, numChildren,
|
startNode, numChildren,
|
||||||
PR_TRUE, aRanges);
|
PR_TRUE, aRanges);
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
// Remove collapsed ranges
|
// Remove collapsed ranges
|
||||||
|
|
Загрузка…
Ссылка в новой задаче