Bug 1050001 - Remove `#ifdef DEBUG_username` lines in editor/. r=ehsan
authorBirunthan Mohanathas <birunthan@mohanathas.com>
Thu, 07 Aug 2014 21:52:05 -0700
changeset 198488 03efefeba91b510cad7a7f3b7e01ba03b5ada8ee
parent 198487 47e6b4d4291280401cd405915e7dc978f1c7f757
child 198489 b261b836ac919a4ab2625e56081362a43509870f
push id27272
push useremorley@mozilla.com
push dateFri, 08 Aug 2014 14:41:27 +0000
treeherdermozilla-central@96a566fa1599 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1050001
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1050001 - Remove `#ifdef DEBUG_username` lines in editor/. r=ehsan
editor/libeditor/base/nsEditor.cpp
editor/libeditor/html/nsHTMLDataTransfer.cpp
editor/libeditor/html/nsHTMLEditor.cpp
editor/libeditor/html/nsHTMLURIRefObject.cpp
editor/libeditor/html/nsTableEditor.cpp
editor/libeditor/text/nsInternetCiter.cpp
editor/libeditor/text/nsPlaintextEditor.cpp
editor/txtsvc/nsTextServicesDocument.cpp
editor/txtsvc/nsTextServicesDocument.h
--- a/editor/libeditor/base/nsEditor.cpp
+++ b/editor/libeditor/base/nsEditor.cpp
@@ -2318,19 +2318,16 @@ nsEditor::CloneAttributes(nsIDOMNode *aD
             result = SetAttributeOrEquivalent(destElement, sourceAttrName, sourceAttrValue, false);
           } else {
             // the element is not inserted in the document yet, we don't want to put a
             // transaction on the UndoStack
             result = SetAttributeOrEquivalent(destElement, sourceAttrName, sourceAttrValue, true);
           }
         } else {
           // Do we ever get here?
-#if DEBUG_cmanske
-          printf("Attribute in sourceAttribute has empty value in nsEditor::CloneAttributes()\n");
-#endif
         }
       }
     }
   }
   return result;
 }
 
 
--- a/editor/libeditor/html/nsHTMLDataTransfer.cpp
+++ b/editor/libeditor/html/nsHTMLDataTransfer.cpp
@@ -1130,20 +1130,16 @@ NS_IMETHODIMP nsHTMLEditor::InsertFromTr
   nsCOMPtr<nsISupports> genericDataObj;
   uint32_t len = 0;
   if (NS_SUCCEEDED(transferable->GetAnyTransferData(getter_Copies(bestFlavor), getter_AddRefs(genericDataObj), &len)))
   {
     nsAutoTxnsConserveSelection dontSpazMySelection(this);
     nsAutoString flavor;
     flavor.AssignWithConversion(bestFlavor);
     nsAutoString stuffToPaste;
-#ifdef DEBUG_clipboard
-    printf("Got flavor [%s]\n", bestFlavor.get());
-#endif
-
     bool isSafe = IsSafeToInsertData(aSourceDoc);
 
     if (0 == nsCRT::strcmp(bestFlavor, kFileMime) ||
         0 == nsCRT::strcmp(bestFlavor, kJPEGImageMime) ||
         0 == nsCRT::strcmp(bestFlavor, kJPGImageMime) ||
         0 == nsCRT::strcmp(bestFlavor, kPNGImageMime) ||
         0 == nsCRT::strcmp(bestFlavor, kGIFImageMime)) {
       rv = InsertObject(bestFlavor, genericDataObj, isSafe,
@@ -1641,19 +1637,16 @@ NS_IMETHODIMP nsHTMLEditor::PasteAsPlain
   nsCOMPtr<nsISupports> genericDataObj;
   uint32_t len = 0;
   char* flav = 0;
   rv = trans->GetAnyTransferData(&flav, getter_AddRefs(genericDataObj), &len);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (flav && 0 == nsCRT::strcmp(flav, kUnicodeMime))
   {
-#ifdef DEBUG_clipboard
-    printf("Got flavor [%s]\n", flav);
-#endif
     nsCOMPtr<nsISupportsString> textDataObj = do_QueryInterface(genericDataObj);
     if (textDataObj && len > 0)
     {
       nsAutoString stuffToPaste;
       textDataObj->GetData(stuffToPaste);
       NS_ASSERTION(stuffToPaste.Length() <= (len/2), "Invalid length!");
       nsAutoEditBatch beginBatching(this);
       rv = InsertAsPlaintextQuotation(stuffToPaste, true, 0);
@@ -1727,21 +1720,16 @@ nsHTMLEditor::InsertTextWithQuotations(c
       if (curHunkIsQuoted)
         lineStart = firstNewline;
     }
 
     // If no newline found, lineStart is now strEnd and we can finish up,
     // inserting from curHunk to lineStart then returning.
     const nsAString &curHunk = Substring(hunkStart, lineStart);
     nsCOMPtr<nsIDOMNode> dummyNode;
-#ifdef DEBUG_akkana_verbose
-    printf("==== Inserting text as %squoted: ---\n%s---\n",
-           curHunkIsQuoted ? "" : "non-",
-           NS_LossyConvertUTF16toASCII(curHunk).get());
-#endif
     if (curHunkIsQuoted)
       rv = InsertAsPlaintextQuotation(curHunk, false,
                                       getter_AddRefs(dummyNode));
     else
       rv = InsertText(curHunk);
 
     if (!found)
       break;
--- a/editor/libeditor/html/nsHTMLEditor.cpp
+++ b/editor/libeditor/html/nsHTMLEditor.cpp
@@ -1548,26 +1548,16 @@ nsHTMLEditor::InsertElementAtSelection(n
     }
 
     nsCOMPtr<nsIDOMNode> parentSelectedNode;
     int32_t offsetForInsert;
     res = selection->GetAnchorNode(getter_AddRefs(parentSelectedNode));
     // XXX: ERROR_HANDLING bad XPCOM usage
     if (NS_SUCCEEDED(res) && NS_SUCCEEDED(selection->GetAnchorOffset(&offsetForInsert)) && parentSelectedNode)
     {
-#ifdef DEBUG_cmanske
-      {
-      nsAutoString name;
-      parentSelectedNode->GetNodeName(name);
-      printf("InsertElement: Anchor node of selection: ");
-      wprintf(name.get());
-      printf(" Offset: %d\n", offsetForInsert);
-      }
-#endif
-
       // Adjust position based on the node we are going to insert.
       NormalizeEOLInsertPosition(node, address_of(parentSelectedNode), &offsetForInsert);
 
       res = InsertNodeAtPoint(node, address_of(parentSelectedNode), &offsetForInsert, false);
       NS_ENSURE_SUCCESS(res, res);
       // Set caret after element, but check for special case 
       //  of inserting table-related elements: set in first cell instead
       if (!SetCaretInTableCell(aElement))
--- a/editor/libeditor/html/nsHTMLURIRefObject.cpp
+++ b/editor/libeditor/html/nsHTMLURIRefObject.cpp
@@ -121,35 +121,28 @@ nsHTMLURIRefObject::GetNextURI(nsAString
     element->GetAttributes(getter_AddRefs(mAttributes));
     NS_ENSURE_TRUE(mAttributes, NS_ERROR_NOT_INITIALIZED);
 
     rv = mAttributes->GetLength(&mAttributeCnt);
     NS_ENSURE_SUCCESS(rv, rv);
     NS_ENSURE_TRUE(mAttributeCnt, NS_ERROR_FAILURE);
     mCurAttrIndex = 0;
   }
-#ifdef DEBUG_akkana
-  printf("Looking at tag '%s'\n",
-         NS_LossyConvertUTF16toASCII(tagName).get());
-#endif
+
   while (mCurAttrIndex < mAttributeCnt)
   {
     nsCOMPtr<nsIDOMAttr> attrNode;
     rv = mAttributes->Item(mCurAttrIndex++, getter_AddRefs(attrNode));
     NS_ENSURE_SUCCESS(rv, rv);
     NS_ENSURE_ARG_POINTER(attrNode);
     nsString curAttr;
     rv = attrNode->GetName(curAttr);
     NS_ENSURE_SUCCESS(rv, rv);
 
     // href >> A, AREA, BASE, LINK
-#ifdef DEBUG_akkana
-    printf("Trying to match attribute '%s'\n",
-           NS_LossyConvertUTF16toASCII(curAttr).get());
-#endif
     if (MATCHES(curAttr, "href"))
     {
       if (!MATCHES(tagName, "a") && !MATCHES(tagName, "area")
           && !MATCHES(tagName, "base") && !MATCHES(tagName, "link"))
         continue;
       rv = attrNode->GetValue(aURI);
       NS_ENSURE_SUCCESS(rv, rv);
       nsString uri (aURI);
@@ -243,19 +236,16 @@ nsHTMLURIRefObject::GetNextURI(nsAString
   return NS_ERROR_NOT_AVAILABLE;
 }
 
 NS_IMETHODIMP
 nsHTMLURIRefObject::RewriteAllURIs(const nsAString & aOldPat,
                             const nsAString & aNewPat,
                             bool aMakeRel)
 {
-#ifdef DEBUG_akkana
-  printf("Can't rewrite URIs yet\n");
-#endif
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
 nsHTMLURIRefObject::GetNode(nsIDOMNode** aNode)
 {
   NS_ENSURE_TRUE(mNode, NS_ERROR_NOT_INITIALIZED);
   NS_ENSURE_TRUE(aNode, NS_ERROR_NULL_POINTER);
--- a/editor/libeditor/html/nsTableEditor.cpp
+++ b/editor/libeditor/html/nsTableEditor.cpp
@@ -344,19 +344,17 @@ nsHTMLEditor::GetNextRow(nsIDOMNode* aCu
       nextRow = nextNode;
     }
     if(nextRow)
     {
       *aRowNode = nextRow.get();
       NS_ADDREF(*aRowNode);
       return NS_OK;
     }
-#ifdef DEBUG_cmanske
-    printf("GetNextRow: firstChild of row's parent's sibling is not a TR!\n");
-#endif
+
     // We arrive here only if a table section has no children 
     //  or first child of section is not a row (bad HTML or more "_moz_text" nodes!)
     // So look for another section sibling
     res = parentSibling->GetNextSibling(getter_AddRefs(nextNode));
     NS_ENSURE_SUCCESS(res, res);
 
     parentSibling = nextNode;
   }
@@ -452,21 +450,16 @@ nsHTMLEditor::InsertTableColumn(int32_t 
   // Make sure table is "well formed"
   //  before appending new column
   if (startColIndex >= colCount)
     NormalizeTable(table);
 
   nsCOMPtr<nsIDOMNode> rowNode;
   for ( rowIndex = 0; rowIndex < rowCount; rowIndex++)
   {
-#ifdef DEBUG_cmanske
-    if (rowIndex == rowCount-1)
-      printf(" ***InsertTableColumn: Inserting cell at last row: %d\n", rowIndex);
-#endif
-
     if (startColIndex < colCount)
     {
       // We are inserting before an existing column
       res = GetCellDataAt(table, rowIndex, startColIndex,
                           getter_AddRefs(curCell),
                           &curStartRowIndex, &curStartColIndex,
                           &rowSpan, &colSpan, 
                           &actualRowSpan, &actualColSpan, &isSelected);
@@ -3018,20 +3011,16 @@ nsHTMLEditor::GetNextSelectedCell(nsIDOM
     NS_ENSURE_TRUE(range, NS_ERROR_FAILURE);
 
     res = GetCellFromRange(range, aCell);
     // Failure here means the range doesn't contain a cell
     NS_ENSURE_SUCCESS(res, NS_EDITOR_ELEMENT_NOT_FOUND);
     
     // We found a selected cell
     if (*aCell) break;
-#ifdef DEBUG_cmanske
-    else
-      printf("GetNextSelectedCell: Collapsed range found\n");
-#endif
 
     // If we didn't find a cell, continue to next range in selection
   }
   // No cell means all remaining ranges were collapsed (cells were deleted)
   NS_ENSURE_TRUE(*aCell, NS_EDITOR_ELEMENT_NOT_FOUND);
 
   if (aRange)
   {
@@ -3086,19 +3075,16 @@ nsHTMLEditor::SetSelectionAfterTableEdit
 {
   NS_ENSURE_TRUE(aTable, NS_ERROR_NOT_INITIALIZED);
 
   nsRefPtr<Selection> selection = GetSelection();
   nsresult res;
   
   if (!selection)
   {
-#ifdef DEBUG_cmanske
-    printf("Selection not found after table manipulation!\n");
-#endif
     return NS_ERROR_FAILURE;
   }
 
   nsCOMPtr<nsIDOMElement> cell;
   bool done = false;
   do {
     res = GetCellAt(aTable, aRow, aCol, getter_AddRefs(cell));
     if (NS_SUCCEEDED(res))
--- a/editor/libeditor/text/nsInternetCiter.cpp
+++ b/editor/libeditor/text/nsInternetCiter.cpp
@@ -166,30 +166,18 @@ nsInternetCiter::Rewrap(const nsAString&
 
   // Loop over lines in the input string, rewrapping each one.
   uint32_t length;
   uint32_t posInString = 0;
   uint32_t outStringCol = 0;
   uint32_t citeLevel = 0;
   const nsPromiseFlatString &tString = PromiseFlatString(aInString);
   length = tString.Length();
-#ifdef DEBUG_wrapping
-  int loopcount = 0;
-#endif
   while (posInString < length)
   {
-#ifdef DEBUG_wrapping
-    printf("Outer loop: '%s'\n",
-           NS_LossyConvertUTF16toASCII(Substring(tString, posInString,
-                                                length-posInString)).get());
-    printf("out string is now: '%s'\n",
-           NS_LossyConvertUTF16toASCII(aOutString).get());
-
-#endif
-
     // Get the new cite level here since we're at the beginning of a line
     uint32_t newCiteLevel = 0;
     while (posInString < length && tString[posInString] == gt)
     {
       ++newCiteLevel;
       ++posInString;
       while (posInString < length && tString[posInString] == space)
         ++posInString;
@@ -260,25 +248,16 @@ nsInternetCiter::Rewrap(const nsAString&
       posInString = nextNewline+1;
       continue;
     }
 
     // Otherwise we have to use the line breaker and loop
     // over this line of the input string to get all of it:
     while ((int32_t)posInString < nextNewline)
     {
-#ifdef DEBUG_wrapping
-      if (++loopcount > 1000)
-        NS_ASSERTION(false, "possible infinite loop in nsInternetCiter\n");
-
-      printf("Inner loop: '%s'\n",
-             NS_LossyConvertUTF16toASCII(Substring(tString, posInString,
-                                              nextNewline-posInString)).get());
-#endif
-
       // Skip over initial spaces:
       while ((int32_t)posInString < nextNewline
              && nsCRT::IsAsciiSpace(tString[posInString]))
         ++posInString;
 
       // If this is a short line, just append it and continue:
       if (outStringCol + nextNewline - posInString <= aWrapCol-citeLevel-1)
       {
@@ -336,19 +315,16 @@ nsInternetCiter::Rewrap(const nsAString&
         }
         else rv = NS_OK;
       }
       // If rv is okay, then breakPt is the place to break.
       // If we get out here and rv is set, something went wrong with line
       // breaker.  Just break the line, hard.
       if (NS_FAILED(rv))
       {
-#ifdef DEBUG_akkana
-        printf("nsInternetCiter: LineBreaker not working -- breaking hard\n");
-#endif
         breakPt = eol;
       }
 
       // Special case: maybe we should have wrapped last time.
       // If the first breakpoint here makes the current line too long,
       // then if we already have text on the current line,
       // break and loop around again.
       // If we're at the beginning of the current line, though,
@@ -375,23 +351,14 @@ nsInternetCiter::Rewrap(const nsAString&
       while (posInString < length && IsSpace(tString[posInString]))
         ++posInString;
 
       // Add a newline and the quote level to the out string
       if (posInString < length)    // not for the last line, though
         BreakLine(aOutString, outStringCol, citeLevel);
 
     } // end inner loop within one line of aInString
-#ifdef DEBUG_wrapping
-    printf("---------\nEnd inner loop: out string is now '%s'\n-----------\n",
-           NS_LossyConvertUTF16toASCII(aOutString).get());
-#endif
   } // end outer loop over lines of aInString
 
-#ifdef DEBUG_wrapping
-  printf("Final out string is now: '%s'\n",
-         NS_LossyConvertUTF16toASCII(aOutString).get());
-
-#endif
   return NS_OK;
 }
 
 
--- a/editor/libeditor/text/nsPlaintextEditor.cpp
+++ b/editor/libeditor/text/nsPlaintextEditor.cpp
@@ -1358,24 +1358,19 @@ nsPlaintextEditor::PasteAsQuotation(int3
     // If it can't support a "text" output of the data the call will fail
     nsCOMPtr<nsISupports> genericDataObj;
     uint32_t len;
     char* flav = nullptr;
     rv = trans->GetAnyTransferData(&flav, getter_AddRefs(genericDataObj),
                                    &len);
     if (NS_FAILED(rv) || !flav)
     {
-#ifdef DEBUG_akkana
-      printf("PasteAsPlaintextQuotation: GetAnyTransferData failed, %d\n", rv);
-#endif
       return rv;
     }
-#ifdef DEBUG_clipboard
-    printf("Got flavor [%s]\n", flav);
-#endif
+
     if (0 == nsCRT::strcmp(flav, kUnicodeMime) ||
         0 == nsCRT::strcmp(flav, kMozTextInternal))
     {
       nsCOMPtr<nsISupportsString> textDataObj ( do_QueryInterface(genericDataObj) );
       if (textDataObj && len > 0)
       {
         nsAutoString stuffToPaste;
         textDataObj->GetData ( stuffToPaste );
@@ -1474,20 +1469,16 @@ nsPlaintextEditor::Rewrap(bool aRespectN
   int32_t wrapCol;
   nsresult rv = GetWrapWidth(&wrapCol);
   NS_ENSURE_SUCCESS(rv, NS_OK);
 
   // Rewrap makes no sense if there's no wrap column; default to 72.
   if (wrapCol <= 0)
     wrapCol = 72;
 
-#ifdef DEBUG_akkana
-  printf("nsPlaintextEditor::Rewrap to %ld columns\n", (long)wrapCol);
-#endif
-
   nsAutoString current;
   bool isCollapsed;
   rv = SharedOutputString(nsIDocumentEncoder::OutputFormatted
                           | nsIDocumentEncoder::OutputLFLineBreak,
                           &isCollapsed, current);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsString wrapped;
@@ -1500,20 +1491,16 @@ nsPlaintextEditor::Rewrap(bool aRespectN
     SelectAll();
 
   return InsertTextWithQuotations(wrapped);
 }
 
 NS_IMETHODIMP    
 nsPlaintextEditor::StripCites()
 {
-#ifdef DEBUG_akkana
-  printf("nsPlaintextEditor::StripCites()\n");
-#endif
-
   nsAutoString current;
   bool isCollapsed;
   nsresult rv = SharedOutputString(nsIDocumentEncoder::OutputFormatted,
                                    &isCollapsed, current);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsString stripped;
   rv = nsInternetCiter::StripCites(current, stripped);
--- a/editor/txtsvc/nsTextServicesDocument.cpp
+++ b/editor/txtsvc/nsTextServicesDocument.cpp
@@ -3706,54 +3706,16 @@ nsTextServicesDocument::FindWordBounds(n
       break;
     }
   }
 
 
   return NS_OK;
 }
 
-#ifdef DEBUG_kin
-void
-nsTextServicesDocument::PrintOffsetTable()
-{
-  OffsetEntry *entry;
-  uint32_t i;
-
-  for (i = 0; i < mOffsetTable.Length(); i++)
-  {
-    entry = mOffsetTable[i];
-    printf("ENTRY %4d: %p  %c  %c  %4d  %4d  %4d\n",
-           i, entry->mNode,  entry->mIsValid ? 'V' : 'N',
-           entry->mIsInsertedText ? 'I' : 'B',
-           entry->mNodeOffset, entry->mStrOffset, entry->mLength);
-  }
-
-  fflush(stdout);
-}
-
-void
-nsTextServicesDocument::PrintContentNode(nsIContent *aContent)
-{
-  nsString tmpStr, str;
-
-  aContent->Tag()->ToString(tmpStr);
-  printf("%s", NS_LossyConvertUTF16toASCII(tmpStr).get());
-
-  if (nsIDOMNode::TEXT_NODE == aContent->NodeType())
-  {
-    aContent->AppendTextTo(str);
-    printf(":  \"%s\"", NS_LossyConvertUTF16toASCII(str).get());
-  }
-
-  printf("\n");
-  fflush(stdout);
-}
-#endif
-
 NS_IMETHODIMP
 nsTextServicesDocument::WillInsertNode(nsIDOMNode *aNode,
                               nsIDOMNode *aParent,
                               int32_t     aPosition)
 {
   return NS_OK;
 }
 
--- a/editor/txtsvc/nsTextServicesDocument.h
+++ b/editor/txtsvc/nsTextServicesDocument.h
@@ -219,16 +219,11 @@ private:
 
   static nsresult FindWordBounds(nsTArray<OffsetEntry*> *offsetTable,
                                  nsString *blockStr,
                                  nsIDOMNode *aNode, int32_t aNodeOffset,
                                  nsIDOMNode **aWordStartNode,
                                  int32_t *aWordStartOffset,
                                  nsIDOMNode **aWordEndNode,
                                  int32_t *aWordEndOffset);
-
-#ifdef DEBUG_kin
-  void PrintOffsetTable();
-  void PrintContentNode(nsIContent *aContent);
-#endif
 };
 
 #endif // nsTextServicesDocument_h__