Fix for bug 390278 (Shift+tab no longer navigates out of MIDAS area). r/sr=jst.

This commit is contained in:
peterv@propagandism.org 2008-01-20 08:53:08 -08:00
Родитель 91cb75a263
Коммит 688cb6d061
2 изменённых файлов: 33 добавлений и 17 удалений

Просмотреть файл

@ -3752,7 +3752,7 @@ nsGenericHTMLElement::IsEditableRoot() const
}
if (document->HasFlag(NODE_IS_EDITABLE)) {
return this == document->GetRootContent();
return PR_FALSE;
}
if (GetContentEditableValue() != eTrue) {

Просмотреть файл

@ -1065,11 +1065,8 @@ FindSelectionRoot(nsIEditor *aEditor, nsIContent *aContent)
CallQueryInterface(rootElement, &root);
if (!root) {
nsIDocument *document = aContent->GetCurrentDoc();
if (document) {
NS_IF_ADDREF(root = document->GetRootContent());
}
if (!root && document) {
NS_IF_ADDREF(root = document->GetRootContent());
}
return root;
@ -1119,26 +1116,33 @@ nsTextEditorFocusListener::Focus(nsIDOMEvent* aEvent)
{ // only enable caret and selection if the editor is not disabled
nsCOMPtr<nsIContent> content = do_QueryInterface(target);
nsCOMPtr<nsIContent> editableRoot =
content ? FindSelectionRoot(mEditor, content) : nsnull;
PRBool targetIsEditableDoc = PR_FALSE;
nsCOMPtr<nsIContent> editableRoot;
if (content) {
editableRoot = FindSelectionRoot(mEditor, content);
}
else {
nsCOMPtr<nsIDocument> document = do_QueryInterface(target);
targetIsEditableDoc = document && document->HasFlag(NODE_IS_EDITABLE);
}
nsCOMPtr<nsISelectionController> selCon;
mEditor->GetSelectionController(getter_AddRefs(selCon));
if (selCon)
if (selCon && (targetIsEditableDoc || editableRoot))
{
nsCOMPtr<nsISelection> selection;
selCon->GetSelection(nsISelectionController::SELECTION_NORMAL,
getter_AddRefs(selection));
nsCOMPtr<nsIPresShell> presShell = do_QueryReferent(mPresShell);
if (presShell) {
nsCOMPtr<nsICaret> caret;
presShell->GetCaret(getter_AddRefs(caret));
if (caret) {
caret->SetIgnoreUserModify(PR_FALSE);
if (selection) {
caret->SetCaretDOMSelection(selection);
}
if (presShell) {
nsCOMPtr<nsICaret> caret;
presShell->GetCaret(getter_AddRefs(caret));
if (caret) {
caret->SetIgnoreUserModify(PR_FALSE);
if (selection) {
caret->SetCaretDOMSelection(selection);
}
}
}
@ -1203,6 +1207,18 @@ nsTextEditorFocusListener::Blur(nsIDOMEvent* aEvent)
}
nsCOMPtr<nsIPresShell> presShell = do_QueryReferent(mPresShell);
nsCOMPtr<nsISelectionController> presSelCon =
do_QueryInterface(presShell);
if (presSelCon == selCon && selection) {
nsCOMPtr<nsIDOMEventTarget> target;
aEvent->GetTarget(getter_AddRefs(target));
nsCOMPtr<nsINode> node = do_QueryInterface(target);
nsIDocument* doc = node ? node->GetOwnerDoc() : nsnull;
if (doc && !doc->HasFlag(NODE_IS_EDITABLE)) {
selection->RemoveAllRanges();
}
}
if (presShell) {
nsCOMPtr<nsICaret> caret;
presShell->GetCaret(getter_AddRefs(caret));