Bug 1428237 - Remove unused nsIHTMLEditor.getHeadContentsAsHTML. r=masayuki
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Fri, 05 Jan 2018 10:59:37 +0900
changeset 452210 08b45ade75ed26f7f1cb0c0205caba2558a88912
parent 452176 96c9efcb4a31b996cb92cf8fc56a9c3764f91250
child 452211 a5f886553c4beaea9816d24058a797a033b3e804
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1428237
milestone59.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 1428237 - Remove unused nsIHTMLEditor.getHeadContentsAsHTML. r=masayuki c-c and bluegriffon don't use this method, so let's remove it to clean up. MozReview-Commit-ID: BC5Ooy2Jlb9
editor/libeditor/HTMLEditor.cpp
editor/nsIHTMLEditor.idl
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -3262,84 +3262,16 @@ HTMLEditor::IsModifiableNode(nsIDOMNode*
 }
 
 bool
 HTMLEditor::IsModifiableNode(nsINode* aNode)
 {
   return !aNode || aNode->IsEditable();
 }
 
-static nsresult
-SetSelectionAroundHeadChildren(Selection* aSelection,
-                               nsCOMPtr<nsIDocument>& aDocument)
-{
-  MOZ_ASSERT(aDocument);
-
-  // Set selection around <head> node
-  dom::Element* headNode = aDocument->GetHeadElement();
-  NS_ENSURE_STATE(headNode);
-
-  // Collapse selection to before first child of the head,
-  nsresult rv = aSelection->Collapse(headNode, 0);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  // Then extend it to just after.
-  uint32_t childCount = headNode->GetChildCount();
-  return aSelection->Extend(headNode, childCount + 1);
-}
-
-NS_IMETHODIMP
-HTMLEditor::GetHeadContentsAsHTML(nsAString& aOutputString)
-{
-  RefPtr<Selection> selection = GetSelection();
-  NS_ENSURE_TRUE(selection, NS_ERROR_NULL_POINTER);
-
-  // Save current selection
-  AutoSelectionRestorer selectionRestorer(selection, this);
-
-  nsCOMPtr<nsIDocument> document = GetDocument();
-  if (NS_WARN_IF(!document)) {
-    return NS_ERROR_NOT_INITIALIZED;
-  }
-  nsresult rv = SetSelectionAroundHeadChildren(selection, document);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  rv = OutputToString(NS_LITERAL_STRING("text/html"),
-                      nsIDocumentEncoder::OutputSelectionOnly,
-                      aOutputString);
-  if (NS_FAILED(rv)) {
-    return rv;
-  }
-
-  // Selection always includes <body></body>,
-  //  so terminate there
-  nsReadingIterator<char16_t> findIter,endFindIter;
-  aOutputString.BeginReading(findIter);
-  aOutputString.EndReading(endFindIter);
-  //counting on our parser to always lower case!!!
-  if (CaseInsensitiveFindInReadable(NS_LITERAL_STRING("<body"),
-                                    findIter, endFindIter)) {
-    nsReadingIterator<char16_t> beginIter;
-    aOutputString.BeginReading(beginIter);
-    int32_t offset = Distance(beginIter, findIter);//get the distance
-
-    nsWritingIterator<char16_t> writeIter;
-    aOutputString.BeginWriting(writeIter);
-    // Ensure the string ends in a newline
-    char16_t newline ('\n');
-    findIter.advance(-1);
-    if (!offset || (offset > 0 && (*findIter) != newline)) {
-      writeIter.advance(offset);
-      *writeIter = newline;
-      aOutputString.Truncate(offset+1);
-    }
-  }
-  return NS_OK;
-}
-
 NS_IMETHODIMP
 HTMLEditor::DebugUnitTests(int32_t* outNumTests,
                            int32_t* outNumTestsFailed)
 {
 #ifdef DEBUG
   NS_ENSURE_TRUE(outNumTests && outNumTestsFailed, NS_ERROR_NULL_POINTER);
 
   TextEditorTest *tester = new TextEditorTest();
--- a/editor/nsIHTMLEditor.idl
+++ b/editor/nsIHTMLEditor.idl
@@ -377,21 +377,16 @@ interface nsIHTMLEditor : nsISupports
    *    Use "anchor" or "namedanchor" to get a named anchor node
    *      (an "A" tag with the "name" attribute set)
    * @return          NS_EDITOR_ELEMENT_NOT_FOUND if an element is not found
    *                  (passes NS_SUCCEEDED macro)
    */
   nsIDOMElement getSelectedElement(in AString aTagName);
 
   /**
-   * Output the contents of the <HEAD> section as text/HTML format
-   */
-  AString getHeadContentsAsHTML();
-
-  /**
    * Replace all children of <HEAD> with string of HTML source
    */
   void replaceHeadContentsWithHTML(in AString aSourceToInsert);
 
   /**
    * Return a new element with default attribute values
    *
    * This does not rely on the selection, and is not sensitive to context.