Bug 1436663 - EditorBase::JoinNodeDeep() should set result after actually joining the nodes r?m_kato
EditorBase::JoinNodeDeep() returns a DOM point which was start of right node.
Currently, this is set before actually joining the nodes. Therefore, we see
warnings since right node which becomes joined node may have less children
than left node.
This patch also makes the NS_WARNING_ASSERTION to NS_ASSERTION since no tests
hit this. So, we can use it to detect regressions.
MozReview-Commit-ID: 3RmRP588AkF
--- a/editor/libeditor/EditorBase.cpp
+++ b/editor/libeditor/EditorBase.cpp
@@ -4355,24 +4355,24 @@ EditorBase::JoinNodeDeep(nsIContent& aLe
nsCOMPtr<nsIContent> rightNodeToJoin = &aRightNode;
nsCOMPtr<nsINode> parentNode = aRightNode.GetParentNode();
EditorDOMPoint ret;
while (leftNodeToJoin && rightNodeToJoin && parentNode &&
AreNodesSameType(leftNodeToJoin, rightNodeToJoin)) {
uint32_t length = leftNodeToJoin->Length();
- ret.Set(rightNodeToJoin, length);
-
// Do the join
nsresult rv = JoinNodes(*leftNodeToJoin, *rightNodeToJoin);
if (NS_WARN_IF(NS_FAILED(rv))) {
return EditorDOMPoint();
}
+ ret.Set(rightNodeToJoin, length);
+
if (parentNode->GetAsText()) {
// We've joined all the way down to text nodes, we're done!
return ret;
}
// Get new left and right nodes, and begin anew
parentNode = rightNodeToJoin;
rightNodeToJoin = parentNode->GetChildAt_Deprecated(length);
--- a/editor/libeditor/EditorDOMPoint.h
+++ b/editor/libeditor/EditorDOMPoint.h
@@ -364,17 +364,17 @@ public:
*/
void
Set(nsINode* aContainer, int32_t aOffset)
{
mParent = aContainer;
mChild = nullptr;
mOffset = mozilla::Some(aOffset);
mIsChildInitialized = false;
- NS_WARNING_ASSERTION(!mParent || mOffset.value() <= mParent->Length(),
+ NS_ASSERTION(!mParent || mOffset.value() <= mParent->Length(),
"The offset is out of bounds");
}
void
Set(const nsINode* aChild)
{
MOZ_ASSERT(aChild);
if (NS_WARN_IF(!aChild->IsContent())) {
Clear();