From 684cee26a83d4c0a86b37ad15b1b9d1c57c3f6d4 Mon Sep 17 00:00:00 2001 From: "kaie%netscape.com" Date: Wed, 14 May 2003 13:17:32 +0000 Subject: [PATCH] b=200417 backspace, enter keys have no visible impact r=jfrancis sr=sfraser a=sspitzer --- editor/libeditor/html/nsHTMLEditRules.cpp | 46 ++++++++++++++++++----- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/editor/libeditor/html/nsHTMLEditRules.cpp b/editor/libeditor/html/nsHTMLEditRules.cpp index f2933e8e29d0..3729acb35ef4 100644 --- a/editor/libeditor/html/nsHTMLEditRules.cpp +++ b/editor/libeditor/html/nsHTMLEditRules.cpp @@ -4519,23 +4519,51 @@ nsHTMLEditRules::CheckForInvisibleBR(nsIDOMNode *aBlock, nsCOMPtr *outBRNode, PRInt32 aOffset) { - // for now I'm relying on fact that user has scrubbed any invisible whitespace - // in the vicinity, so we don't need more complicated code here to check for that. if (!aBlock || !outBRNode) return NS_ERROR_NULL_POINTER; *outBRNode = nsnull; + + nsCOMPtr testNode; + PRInt32 testOffset = 0; + PRBool runTest = PR_FALSE; + if (aWhere == kBlockEnd) { - nsCOMPtr node = mHTMLEditor->GetRightmostChild(aBlock, PR_TRUE); - if (nsTextEditUtils::IsBreak(node)) - *outBRNode = node; + nsCOMPtr rightmostNode; + rightmostNode = mHTMLEditor->GetRightmostChild(aBlock, PR_TRUE); // no block crossing + + if (rightmostNode) + { + nsCOMPtr nodeParent; + PRInt32 nodeOffset; + + if (NS_SUCCEEDED(nsEditor::GetNodeLocation(rightmostNode, + address_of(nodeParent), + &nodeOffset))) + { + runTest = PR_TRUE; + testNode = nodeParent; + // use offset + 1, because we want the last node included in our evaluation + testOffset = nodeOffset + 1; + } + } } else if (aOffset) { - nsCOMPtr prevItem; - mHTMLEditor->GetPriorHTMLNode(aBlock, aOffset, address_of(prevItem), PR_TRUE); - if (nsTextEditUtils::IsBreak(prevItem)) - *outBRNode = prevItem; + runTest = PR_TRUE; + testNode = aBlock; + // we'll check everything to the left of the input position + testOffset = aOffset; } + + if (runTest) + { + nsWSRunObject wsTester(mHTMLEditor, testNode, testOffset); + if (nsWSRunObject::eBreak == wsTester.mStartReason) + { + *outBRNode = wsTester.mStartReasonNode; + } + } + return NS_OK; }