Bug 389933 - "ASSERTION: JoinNode called with node not listed in offset table while editing HTML email in GMail" [p=chris@pearce.org.nz (Chris Pearce [cpearce]) r=peterv sr=roc a1.9=schrep]
authorreed@reedloden.com
Wed, 19 Dec 2007 03:32:20 -0800
changeset 9473 49aeb44c9f331cf27f7af25b0827f41f96ed67b1
parent 9472 e92be8bbe5ef68cc620799651581abc6188f9d5c
child 9474 2e25f4600f02e4f85c539d27909864266e2c2144
push idunknown
push userunknown
push dateunknown
reviewerspeterv, roc
bugs389933
milestone1.9b3pre
Bug 389933 - "ASSERTION: JoinNode called with node not listed in offset table while editing HTML email in GMail" [p=chris@pearce.org.nz (Chris Pearce [cpearce]) r=peterv sr=roc a1.9=schrep]
editor/libeditor/html/nsHTMLEditRules.cpp
editor/txtsvc/src/nsTextServicesDocument.cpp
--- a/editor/libeditor/html/nsHTMLEditRules.cpp
+++ b/editor/libeditor/html/nsHTMLEditRules.cpp
@@ -542,16 +542,23 @@ nsHTMLEditRules::AfterEditInner(PRInt32 
       mHTMLEditor->mTypeInState->UpdateSelState(selection);
       res = ReapplyCachedStyles();
       if (NS_FAILED(res)) return res;
       res = ClearCachedStyles();
       if (NS_FAILED(res)) return res;
     }    
   }
 
+  // Ensure range offsets are up to date.
+  if (mDocChangeRange) {
+    mDocChangeRange->GetStartContainer(getter_AddRefs(rangeStartParent));
+    mDocChangeRange->GetEndContainer(getter_AddRefs(rangeEndParent));
+    mDocChangeRange->GetStartOffset(&rangeStartOffset);
+    mDocChangeRange->GetEndOffset(&rangeEndOffset);
+  }
   res = mHTMLEditor->HandleInlineSpellCheck(action, selection, 
                                             mRangeItem.startNode, mRangeItem.startOffset,
                                             rangeStartParent, rangeStartOffset,
                                             rangeEndParent, rangeEndOffset);
   if (NS_FAILED(res)) 
     return res;
 
   // detect empty doc
--- a/editor/txtsvc/src/nsTextServicesDocument.cpp
+++ b/editor/txtsvc/src/nsTextServicesDocument.cpp
@@ -2621,29 +2621,31 @@ nsTextServicesDocument::JoinNodes(nsIDOM
 
   result = NodeHasOffsetEntry(&mOffsetTable, aLeftNode, &leftHasEntry, &leftIndex);
 
   if (NS_FAILED(result))
     return result;
 
   if (!leftHasEntry)
   {
-    // XXX: Not sure if we should be throwing an error here!
-    NS_ASSERTION(0, "JoinNode called with node not listed in offset table.");
-    return NS_ERROR_FAILURE;
+    // It's okay if the node isn't in the offset table, the
+    // editor could be cleaning house.
+    return NS_OK;
   }
 
   result = NodeHasOffsetEntry(&mOffsetTable, aRightNode, &rightHasEntry, &rightIndex);
 
   if (NS_FAILED(result))
     return result;
 
   if (!rightHasEntry)
   {
-    return NS_ERROR_FAILURE;
+    // It's okay if the node isn't in the offset table, the
+    // editor could be cleaning house.
+    return NS_OK;
   }
 
   NS_ASSERTION(leftIndex < rightIndex, "Indexes out of order.");
 
   if (leftIndex > rightIndex)
   {
     // Don't know how to handle this situation.
     return NS_ERROR_FAILURE;