From 894d0f00856b8d17976bc8049bd0c832e52b647c Mon Sep 17 00:00:00 2001 From: "buster%netscape.com" Date: Thu, 1 Jul 1999 20:46:59 +0000 Subject: [PATCH] minor bug fixes --- editor/base/nsEditor.cpp | 4 ++-- editor/base/nsTextEditor.cpp | 15 +++++++++++---- editor/libeditor/base/nsEditor.cpp | 4 ++-- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/editor/base/nsEditor.cpp b/editor/base/nsEditor.cpp index e9a5e4b5709f..071f8548041e 100644 --- a/editor/base/nsEditor.cpp +++ b/editor/base/nsEditor.cpp @@ -3221,7 +3221,7 @@ nsEditor::CountEditableChildren(nsIDOMNode *aNode, PRUint32 &outCount) { nsCOMPtrnodeList; PRUint32 len; - PRInt32 i; + PRUint32 i; res = aNode->GetChildNodes(getter_AddRefs(nodeList)); if (NS_SUCCEEDED(res) && nodeList) { @@ -3229,7 +3229,7 @@ nsEditor::CountEditableChildren(nsIDOMNode *aNode, PRUint32 &outCount) for (i=0 ; i child; - res = nodeList->Item(i, getter_AddRefs(child)); + res = nodeList->Item((PRInt32)i, getter_AddRefs(child)); if ((NS_SUCCEEDED(res)) && (child)) { if (IsEditable(child)) diff --git a/editor/base/nsTextEditor.cpp b/editor/base/nsTextEditor.cpp index ffe871861220..e3b11385411b 100644 --- a/editor/base/nsTextEditor.cpp +++ b/editor/base/nsTextEditor.cpp @@ -2137,6 +2137,8 @@ nsTextEditor::SetTextPropertiesForNodeWithDifferentParents(nsIDOMRange *aRange, PRUint32 count; if (!aRange || !aStartNode || !aEndNode || !aParent || !aPropName) return NS_ERROR_NULL_POINTER; + + PRInt32 startOffset, endOffset; // create a style node for the text in the start parent nsCOMPtrparent; @@ -2210,7 +2212,6 @@ nsTextEditor::SetTextPropertiesForNodeWithDifferentParents(nsIDOMRange *aRange, nsCOMPtrparentContent; parentContent = do_QueryInterface(parent); nsCOMPtrparentNode = do_QueryInterface(parent); - PRInt32 startOffset, endOffset; if (PR_TRUE==IsTextNode(node)) { startOffset = 0; @@ -2249,12 +2250,15 @@ nsTextEditor::SetTextPropertiesForNodeWithDifferentParents(nsIDOMRange *aRange, { nodeAsChar->GetLength(&count); result = SetTextPropertiesForNode(startNode, parent, aStartOffset, count, aPropName, aAttribute, aValue); + startOffset = 0; } else { nsCOMPtrgrandParent; result = parent->GetParentNode(getter_AddRefs(grandParent)); result = SetTextPropertiesForNode(parent, grandParent, aStartOffset, aStartOffset+1, aPropName, aAttribute, aValue); + startNode = do_QueryInterface(parent); + startOffset = aStartOffset; } @@ -2271,6 +2275,7 @@ nsTextEditor::SetTextPropertiesForNodeWithDifferentParents(nsIDOMRange *aRange, { nodeAsChar->GetLength(&count); result = SetTextPropertiesForNode(endNode, parent, 0, aEndOffset, aPropName, aAttribute, aValue); + endOffset = aEndOffset; } else { @@ -2279,6 +2284,8 @@ nsTextEditor::SetTextPropertiesForNodeWithDifferentParents(nsIDOMRange *aRange, nsCOMPtrgrandParent; result = parent->GetParentNode(getter_AddRefs(grandParent)); result = SetTextPropertiesForNode(parent, grandParent, aEndOffset-1, aEndOffset, aPropName, aAttribute, aValue); + endNode = do_QueryInterface(parent); + endOffset = 0; } if (NS_SUCCEEDED(result)) { @@ -2286,8 +2293,8 @@ nsTextEditor::SetTextPropertiesForNodeWithDifferentParents(nsIDOMRange *aRange, result = nsEditor::GetSelection(getter_AddRefs(selection)); if (NS_SUCCEEDED(result)) { - selection->Collapse(aStartNode, aStartOffset); - selection->Extend(aEndNode, aEndOffset); + selection->Collapse(startNode, startOffset); + selection->Extend(endNode, aEndOffset); } } } @@ -2916,7 +2923,7 @@ nsTextEditor::GetDocumentLength(PRInt32 *aCount) *aCount = 0; nsCOMPtr sel; - GetSelection(getter_AddRefs(sel)); + result = GetSelection(getter_AddRefs(sel)); if ((NS_SUCCEEDED(result)) && sel) { nsAutoSelectionReset selectionResetter(sel); diff --git a/editor/libeditor/base/nsEditor.cpp b/editor/libeditor/base/nsEditor.cpp index e9a5e4b5709f..071f8548041e 100644 --- a/editor/libeditor/base/nsEditor.cpp +++ b/editor/libeditor/base/nsEditor.cpp @@ -3221,7 +3221,7 @@ nsEditor::CountEditableChildren(nsIDOMNode *aNode, PRUint32 &outCount) { nsCOMPtrnodeList; PRUint32 len; - PRInt32 i; + PRUint32 i; res = aNode->GetChildNodes(getter_AddRefs(nodeList)); if (NS_SUCCEEDED(res) && nodeList) { @@ -3229,7 +3229,7 @@ nsEditor::CountEditableChildren(nsIDOMNode *aNode, PRUint32 &outCount) for (i=0 ; i child; - res = nodeList->Item(i, getter_AddRefs(child)); + res = nodeList->Item((PRInt32)i, getter_AddRefs(child)); if ((NS_SUCCEEDED(res)) && (child)) { if (IsEditable(child))