Bug 1260651 part.57 Move classes in nsHTMLObjectResizer.h into mozilla namespace and its file name should be HTMLEditorObjectResizerUtils.h r=mccr8
This patch renames:
ResizerSelectionListener -> mozilla::ResizerSelectionListener
ResizerMouseMotionListener -> mozilla::ResizerMouseMotionListener
DocumentResizeEventListener -> mozilla::DocumentResizeEventListener
And making the header file name HTMLEditorObjectResizerUtils.h because it doesn't define specific class related to its file name and should be clearer that it's related to HTMLEditor.
MozReview-Commit-ID: GOJyEwtFdJV
--- a/editor/libeditor/HTMLAbsPositionEditor.cpp
+++ b/editor/libeditor/HTMLAbsPositionEditor.cpp
@@ -2,32 +2,32 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/HTMLEditor.h"
#include <math.h>
#include "EditorUtils.h"
+#include "HTMLEditorObjectResizerUtils.h"
#include "HTMLEditRules.h"
#include "HTMLEditUtils.h"
#include "TextEditUtils.h"
#include "mozilla/Preferences.h"
#include "mozilla/dom/Selection.h"
#include "mozilla/dom/Element.h"
#include "mozilla/mozalloc.h"
#include "nsAString.h"
#include "nsAlgorithm.h"
#include "nsCOMPtr.h"
#include "nsComputedDOMStyle.h"
#include "nsDebug.h"
#include "nsEditor.h"
#include "nsError.h"
#include "nsGkAtoms.h"
-#include "nsHTMLObjectResizer.h"
#include "nsIContent.h"
#include "nsROCSSPrimitiveValue.h"
#include "nsIDOMCSSStyleDeclaration.h"
#include "nsIDOMElement.h"
#include "nsIDOMEventListener.h"
#include "nsIDOMEventTarget.h"
#include "nsIDOMNode.h"
#include "nsDOMCSSRGBColor.h"
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -51,20 +51,20 @@
#include "nsPIDOMWindow.h"
// netwerk
#include "nsIURI.h"
#include "nsNetUtil.h"
// Misc
#include "EditorUtils.h"
+#include "HTMLEditorObjectResizerUtils.h"
#include "TextEditorTest.h"
#include "WSRunObject.h"
#include "nsGkAtoms.h"
-#include "nsHTMLObjectResizer.h"
#include "nsIWidget.h"
#include "nsIFrame.h"
#include "nsIParserService.h"
#include "mozilla/dom/Selection.h"
#include "mozilla/dom/DocumentFragment.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/Event.h"
--- a/editor/libeditor/HTMLEditorObjectResizer.cpp
+++ b/editor/libeditor/HTMLEditorObjectResizer.cpp
@@ -1,15 +1,15 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/HTMLEditor.h"
-#include "nsHTMLObjectResizer.h"
+#include "HTMLEditorObjectResizerUtils.h"
#include "EditorUtils.h"
#include "HTMLEditUtils.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/LookAndFeel.h"
#include "mozilla/MathAlgorithms.h"
#include "mozilla/Preferences.h"
#include "mozilla/mozalloc.h"
@@ -40,55 +40,51 @@
#include "nsString.h"
#include "nsStringFwd.h"
#include "nsSubstringTuple.h"
#include "nscore.h"
#include <algorithm>
class nsISelection;
+namespace mozilla {
+
+using namespace dom;
+
/******************************************************************************
- * DocumentResizeEventListener
+ * mozilla::DocumentResizeEventListener
******************************************************************************/
NS_IMPL_ISUPPORTS(DocumentResizeEventListener, nsIDOMEventListener)
DocumentResizeEventListener::DocumentResizeEventListener(nsIHTMLEditor* aEditor)
{
mEditor = do_GetWeakReference(aEditor);
}
-DocumentResizeEventListener::~DocumentResizeEventListener()
-{
-}
-
NS_IMETHODIMP
DocumentResizeEventListener::HandleEvent(nsIDOMEvent* aMouseEvent)
{
nsCOMPtr<nsIHTMLObjectResizer> objectResizer = do_QueryReferent(mEditor);
if (objectResizer)
return objectResizer->RefreshResizers();
return NS_OK;
}
/******************************************************************************
- * ResizerSelectionListener
+ * mozilla::ResizerSelectionListener
******************************************************************************/
NS_IMPL_ISUPPORTS(ResizerSelectionListener, nsISelectionListener)
ResizerSelectionListener::ResizerSelectionListener(nsIHTMLEditor* aEditor)
{
mEditor = do_GetWeakReference(aEditor);
}
-ResizerSelectionListener::~ResizerSelectionListener()
-{
-}
-
NS_IMETHODIMP
ResizerSelectionListener::NotifySelectionChanged(nsIDOMDocument* aDOMDocument,
nsISelection* aSelection,
int16_t aReason)
{
if ((aReason & (nsISelectionListener::MOUSEDOWN_REASON |
nsISelectionListener::KEYPRESS_REASON |
nsISelectionListener::SELECTALL_REASON)) && aSelection)
@@ -99,30 +95,26 @@ ResizerSelectionListener::NotifySelectio
if (editor)
editor->CheckSelectionStateForAnonymousButtons(aSelection);
}
return NS_OK;
}
/******************************************************************************
- * ResizerMouseMotionListener
+ * mozilla::ResizerMouseMotionListener
******************************************************************************/
NS_IMPL_ISUPPORTS(ResizerMouseMotionListener, nsIDOMEventListener)
ResizerMouseMotionListener::ResizerMouseMotionListener(nsIHTMLEditor* aEditor)
{
mEditor = do_GetWeakReference(aEditor);
}
-ResizerMouseMotionListener::~ResizerMouseMotionListener()
-{
-}
-
NS_IMETHODIMP
ResizerMouseMotionListener::HandleEvent(nsIDOMEvent* aMouseEvent)
{
nsCOMPtr<nsIDOMMouseEvent> mouseEvent ( do_QueryInterface(aMouseEvent) );
if (!mouseEvent) {
//non-ui event passed in. bad things.
return NS_OK;
}
@@ -133,20 +125,16 @@ ResizerMouseMotionListener::HandleEvent(
{
// check if we have to redisplay a resizing shadow
objectResizer->MouseMove(aMouseEvent);
}
return NS_OK;
}
-namespace mozilla {
-
-using namespace dom;
-
/******************************************************************************
* mozilla::HTMLEditor
******************************************************************************/
already_AddRefed<Element>
HTMLEditor::CreateResizer(int16_t aLocation,
nsIDOMNode* aParentNode)
{
rename from editor/libeditor/nsHTMLObjectResizer.h
rename to editor/libeditor/HTMLEditorObjectResizerUtils.h
--- a/editor/libeditor/nsHTMLObjectResizer.h
+++ b/editor/libeditor/HTMLEditorObjectResizerUtils.h
@@ -1,89 +1,82 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-#ifndef _nshtmlobjectresizer__h
-#define _nshtmlobjectresizer__h
+#ifndef HTMLEditorObjectResizerUtils_h
+#define HTMLEditorObjectResizerUtils_h
#include "nsIDOMEventListener.h"
#include "nsISelectionListener.h"
#include "nsISupportsImpl.h"
#include "nsIWeakReferenceUtils.h"
#include "nsLiteralString.h"
class nsIHTMLEditor;
+namespace mozilla {
+
#define kTopLeft NS_LITERAL_STRING("nw")
#define kTop NS_LITERAL_STRING("n")
#define kTopRight NS_LITERAL_STRING("ne")
#define kLeft NS_LITERAL_STRING("w")
#define kRight NS_LITERAL_STRING("e")
#define kBottomLeft NS_LITERAL_STRING("sw")
#define kBottom NS_LITERAL_STRING("s")
#define kBottomRight NS_LITERAL_STRING("se")
-// ==================================================================
-// ResizerSelectionListener
-// ==================================================================
+/******************************************************************************
+ * mozilla::ResizerSelectionListener
+ ******************************************************************************/
-class ResizerSelectionListener : public nsISelectionListener
+class ResizerSelectionListener final : public nsISelectionListener
{
public:
-
- explicit ResizerSelectionListener(nsIHTMLEditor * aEditor);
+ explicit ResizerSelectionListener(nsIHTMLEditor* aEditor);
void Reset();
- /*interfaces for addref and release and queryinterface*/
NS_DECL_ISUPPORTS
-
NS_DECL_NSISELECTIONLISTENER
protected:
- virtual ~ResizerSelectionListener();
-
+ virtual ~ResizerSelectionListener() {}
nsWeakPtr mEditor;
};
-// ==================================================================
-// ResizerMouseMotionListener
-// ==================================================================
+/******************************************************************************
+ * mozilla::ResizerMouseMotionListener
+ ******************************************************************************/
-class ResizerMouseMotionListener : public nsIDOMEventListener
+class ResizerMouseMotionListener final : public nsIDOMEventListener
{
public:
- explicit ResizerMouseMotionListener(nsIHTMLEditor * aEditor);
+ explicit ResizerMouseMotionListener(nsIHTMLEditor* aEditor);
-/*interfaces for addref and release and queryinterface*/
NS_DECL_ISUPPORTS
-
NS_DECL_NSIDOMEVENTLISTENER
- protected:
- virtual ~ResizerMouseMotionListener();
-
+protected:
+ virtual ~ResizerMouseMotionListener() {}
nsWeakPtr mEditor;
-
};
-// ==================================================================
-// DocumentResizeEventListener
-// ==================================================================
+/******************************************************************************
+ * mozilla::DocumentResizeEventListener
+ ******************************************************************************/
-class DocumentResizeEventListener: public nsIDOMEventListener
+class DocumentResizeEventListener final : public nsIDOMEventListener
{
public:
- explicit DocumentResizeEventListener(nsIHTMLEditor * aEditor);
+ explicit DocumentResizeEventListener(nsIHTMLEditor* aEditor);
- /*interfaces for addref and release and queryinterface*/
NS_DECL_ISUPPORTS
-
NS_DECL_NSIDOMEVENTLISTENER
- protected:
- virtual ~DocumentResizeEventListener();
+protected:
+ virtual ~DocumentResizeEventListener() {}
nsWeakPtr mEditor;
-
};
-#endif /* _nshtmlobjectresizer__h */
+} // namespace mozilla
+
+#endif // #ifndef HTMLEditorObjectResizerUtils_h