Bug 1260651 part.2 Rename nsEditorHookUtils to mozilla::EditorHookUtils r=mccr8 draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 23 Jun 2016 16:59:15 +0900
changeset 385692 cb7ec5b461d0432880beb4debeea253ac1a77d99
parent 385691 0147a9c79800924614157f1fa74cda3b9397f688
child 385693 861094d965e80f7ac3033e2322c95bc8512472bd
push id22582
push usermasayuki@d-toybox.com
push dateSat, 09 Jul 2016 03:13:39 +0000
reviewersmccr8
bugs1260651
milestone50.0a1
Bug 1260651 part.2 Rename nsEditorHookUtils to mozilla::EditorHookUtils r=mccr8 MozReview-Commit-ID: 1BRj1wcBljc
editor/libeditor/EditorUtils.cpp
editor/libeditor/EditorUtils.h
editor/libeditor/nsHTMLDataTransfer.cpp
editor/libeditor/nsPlaintextDataTransfer.cpp
--- a/editor/libeditor/EditorUtils.cpp
+++ b/editor/libeditor/EditorUtils.cpp
@@ -165,39 +165,38 @@ bool
 EditorUtils::IsLeafNode(nsIDOMNode* aNode)
 {
   bool hasChildren = false;
   if (aNode)
     aNode->HasChildNodes(&hasChildren);
   return !hasChildren;
 }
 
-} // namespace mozilla
-
 /******************************************************************************
  * utility methods for drag/drop/copy/paste hooks
  *****************************************************************************/
 
 nsresult
-nsEditorHookUtils::GetHookEnumeratorFromDocument(nsIDOMDocument *aDoc,
-                                                 nsISimpleEnumerator **aResult)
+EditorHookUtils::GetHookEnumeratorFromDocument(nsIDOMDocument* aDoc,
+                                               nsISimpleEnumerator** aResult)
 {
   nsCOMPtr<nsIDocument> doc = do_QueryInterface(aDoc);
   NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
 
   nsCOMPtr<nsIDocShell> docShell = doc->GetDocShell();
   nsCOMPtr<nsIClipboardDragDropHookList> hookObj = do_GetInterface(docShell);
   NS_ENSURE_TRUE(hookObj, NS_ERROR_FAILURE);
 
   return hookObj->GetHookEnumerator(aResult);
 }
 
 bool
-nsEditorHookUtils::DoInsertionHook(nsIDOMDocument *aDoc, nsIDOMEvent *aDropEvent,
-                                   nsITransferable *aTrans)
+EditorHookUtils::DoInsertionHook(nsIDOMDocument* aDoc,
+                                 nsIDOMEvent* aDropEvent,
+                                 nsITransferable *aTrans)
 {
   nsCOMPtr<nsISimpleEnumerator> enumerator;
   GetHookEnumeratorFromDocument(aDoc, getter_AddRefs(enumerator));
   NS_ENSURE_TRUE(enumerator, true);
 
   bool hasMoreHooks = false;
   while (NS_SUCCEEDED(enumerator->HasMoreElements(&hasMoreHooks)) && hasMoreHooks)
   {
@@ -215,8 +214,10 @@ nsEditorHookUtils::DoInsertionHook(nsIDO
       override->OnPasteOrDrop(aDropEvent, aTrans, &doInsert);
       NS_ASSERTION(NS_SUCCEEDED(hookResult), "hook failure in OnPasteOrDrop");
       NS_ENSURE_TRUE(doInsert, false);
     }
   }
 
   return true;
 }
+
+} // namespace mozilla
--- a/editor/libeditor/EditorUtils.h
+++ b/editor/libeditor/EditorUtils.h
@@ -13,16 +13,19 @@
 #include "nsIDOMNode.h"
 #include "nsIEditor.h"
 #include "nscore.h"
 #include "mozilla/GuardObjects.h"
 
 class nsIAtom;
 class nsIContentIterator;
 class nsIDOMDocument;
+class nsIDOMEvent;
+class nsISimpleEnumerator;
+class nsITransferable;
 class nsRange;
 namespace mozilla {
 template <class T> class OwningNonNull;
 namespace dom {
 class Selection;
 } // namespace dom
 } // namespace mozilla
 
@@ -270,25 +273,23 @@ class EditorUtils final
 public:
   static bool IsDescendantOf(nsINode* aNode, nsINode* aParent,
                              int32_t* aOffset = 0);
   static bool IsDescendantOf(nsIDOMNode* aNode, nsIDOMNode* aParent,
                              int32_t* aOffset = 0);
   static bool IsLeafNode(nsIDOMNode* aNode);
 };
 
+class EditorHookUtils final
+{
+public:
+  static bool DoInsertionHook(nsIDOMDocument* aDoc, nsIDOMEvent* aEvent,
+                              nsITransferable* aTrans);
+
+private:
+  static nsresult GetHookEnumeratorFromDocument(
+                    nsIDOMDocument*aDoc,
+                    nsISimpleEnumerator** aEnumerator);
+};
+
 } // namespace mozilla
 
-class nsIDOMEvent;
-class nsISimpleEnumerator;
-class nsITransferable;
-
-class nsEditorHookUtils
-{
-  public:
-    static bool     DoInsertionHook(nsIDOMDocument *aDoc, nsIDOMEvent *aEvent,
-                                    nsITransferable *aTrans);
-  private:
-    static nsresult GetHookEnumeratorFromDocument(nsIDOMDocument *aDoc,
-                                                  nsISimpleEnumerator **aEnumerator);
-};
-
 #endif // #ifndef EditorUtils_h
--- a/editor/libeditor/nsHTMLDataTransfer.cpp
+++ b/editor/libeditor/nsHTMLDataTransfer.cpp
@@ -1488,35 +1488,37 @@ NS_IMETHODIMP nsHTMLEditor::Paste(int32_
       NS_ASSERTION(text.Length() <= (infoLen/2), "Invalid length!");
       infoStr.Assign(text.get(), infoLen / 2);
     }
   }
 
   // handle transferable hooks
   nsCOMPtr<nsIDOMDocument> domdoc;
   GetDocument(getter_AddRefs(domdoc));
-  if (!nsEditorHookUtils::DoInsertionHook(domdoc, nullptr, trans))
+  if (!EditorHookUtils::DoInsertionHook(domdoc, nullptr, trans)) {
     return NS_OK;
+  }
 
   return InsertFromTransferable(trans, nullptr, contextStr, infoStr, bHavePrivateHTMLFlavor,
                                 nullptr, 0, true);
 }
 
 NS_IMETHODIMP nsHTMLEditor::PasteTransferable(nsITransferable *aTransferable)
 {
   // Use an invalid value for the clipboard type as data comes from aTransferable
   // and we don't currently implement a way to put that in the data transfer yet.
   if (!FireClipboardEvent(ePaste, nsIClipboard::kGlobalClipboard)) {
     return NS_OK;
   }
 
   // handle transferable hooks
   nsCOMPtr<nsIDOMDocument> domdoc = GetDOMDocument();
-  if (!nsEditorHookUtils::DoInsertionHook(domdoc, nullptr, aTransferable))
+  if (!EditorHookUtils::DoInsertionHook(domdoc, nullptr, aTransferable)) {
     return NS_OK;
+  }
 
   nsAutoString contextStr, infoStr;
   return InsertFromTransferable(aTransferable, nullptr, contextStr, infoStr, false,
                                 nullptr, 0, true);
 }
 
 //
 // HTML PasteNoFormatting. Ignore any HTML styles and formating in paste source
--- a/editor/libeditor/nsPlaintextDataTransfer.cpp
+++ b/editor/libeditor/nsPlaintextDataTransfer.cpp
@@ -337,18 +337,19 @@ NS_IMETHODIMP nsPlaintextEditor::Paste(i
   rv = PrepareTransferable(getter_AddRefs(trans));
   if (NS_SUCCEEDED(rv) && trans)
   {
     // Get the Data from the clipboard
     if (NS_SUCCEEDED(clipboard->GetData(trans, aSelectionType)) && IsModifiable())
     {
       // handle transferable hooks
       nsCOMPtr<nsIDOMDocument> domdoc = GetDOMDocument();
-      if (!nsEditorHookUtils::DoInsertionHook(domdoc, nullptr, trans))
+      if (!EditorHookUtils::DoInsertionHook(domdoc, nullptr, trans)) {
         return NS_OK;
+      }
 
       rv = InsertTextFromTransferable(trans, nullptr, 0, true);
     }
   }
 
   return rv;
 }
 
@@ -360,18 +361,19 @@ NS_IMETHODIMP nsPlaintextEditor::PasteTr
     return NS_OK;
   }
 
   if (!IsModifiable())
     return NS_OK;
 
   // handle transferable hooks
   nsCOMPtr<nsIDOMDocument> domdoc = GetDOMDocument();
-  if (!nsEditorHookUtils::DoInsertionHook(domdoc, nullptr, aTransferable))
+  if (!EditorHookUtils::DoInsertionHook(domdoc, nullptr, aTransferable)) {
     return NS_OK;
+  }
 
   return InsertTextFromTransferable(aTransferable, nullptr, 0, true);
 }
 
 NS_IMETHODIMP nsPlaintextEditor::CanPaste(int32_t aSelectionType, bool *aCanPaste)
 {
   NS_ENSURE_ARG_POINTER(aCanPaste);
   *aCanPaste = false;