Trying to fix orange.

This commit is contained in:
peterv@propagandism.org 2007-12-04 21:35:10 -08:00
parent 5c03d5bbdf
commit a0d5f60400
2 changed files with 17 additions and 31 deletions

View File

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

View File

@ -1065,8 +1065,11 @@ FindSelectionRoot(nsIEditor *aEditor, nsIContent *aContent)
CallQueryInterface(rootElement, &root);
if (!root && document) {
NS_IF_ADDREF(root = document->GetRootContent());
if (!root) {
nsIDocument *document = aContent->GetCurrentDoc();
if (document) {
NS_IF_ADDREF(root = document->GetRootContent());
}
}
return root;
@ -1116,33 +1119,26 @@ nsTextEditorFocusListener::Focus(nsIDOMEvent* aEvent)
{ // only enable caret and selection if the editor is not disabled
nsCOMPtr<nsIContent> content = do_QueryInterface(target);
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<nsIContent> editableRoot =
content ? FindSelectionRoot(mEditor, content) : nsnull;
nsCOMPtr<nsISelectionController> selCon;
mEditor->GetSelectionController(getter_AddRefs(selCon));
if (selCon && (targetIsEditableDoc || editableRoot))
if (selCon)
{
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);
}
}
}
@ -1206,16 +1202,6 @@ nsTextEditorFocusListener::Blur(nsIDOMEvent* aEvent)
selectionPrivate->SetAncestorLimiter(nsnull);
}
if (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();
}
}
nsCOMPtr<nsIPresShell> presShell = do_QueryReferent(mPresShell);
if (presShell) {
nsCOMPtr<nsICaret> caret;