diff --git a/mozilla/editor/libeditor/html/nsHTMLEditRules.cpp b/mozilla/editor/libeditor/html/nsHTMLEditRules.cpp
index f2933e8e29d..3729acb35ef 100644
--- a/mozilla/editor/libeditor/html/nsHTMLEditRules.cpp
+++ b/mozilla/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;
}