Bug 1260651 part.54 Rename nsHTMLEditorEventListeners to mozilla::HTMLEditorEventListener (and their file names) r=mccr8
MozReview-Commit-ID: DFW3E2WfXzJ
rename from editor/libeditor/nsHTMLEditorEventListener.cpp
rename to editor/libeditor/HTMLEditorEventListener.cpp
--- a/editor/libeditor/nsHTMLEditorEventListener.cpp
+++ b/editor/libeditor/HTMLEditorEventListener.cpp
@@ -1,14 +1,14 @@
/* -*- 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 "nsHTMLEditorEventListener.h"
+#include "HTMLEditorEventListener.h"
#include "HTMLEditUtils.h"
#include "mozilla/dom/Event.h"
#include "mozilla/dom/Selection.h"
#include "nsCOMPtr.h"
#include "nsDebug.h"
#include "nsEditor.h"
#include "nsError.h"
@@ -22,46 +22,42 @@
#include "nsIHTMLEditor.h"
#include "nsIHTMLInlineTableEditor.h"
#include "nsIHTMLObjectResizer.h"
#include "nsISupportsImpl.h"
#include "nsLiteralString.h"
#include "nsQueryObject.h"
#include "nsRange.h"
-using namespace mozilla;
-using namespace mozilla::dom;
+namespace mozilla {
-/*
- * nsHTMLEditorEventListener implementation
- *
- */
+using namespace dom;
#ifdef DEBUG
nsresult
-nsHTMLEditorEventListener::Connect(nsEditor* aEditor)
+HTMLEditorEventListener::Connect(nsEditor* aEditor)
{
nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryObject(aEditor);
nsCOMPtr<nsIHTMLInlineTableEditor> htmlInlineTableEditor =
do_QueryObject(aEditor);
NS_PRECONDITION(htmlEditor && htmlInlineTableEditor,
"Set nsHTMLEditor or its sub class");
return nsEditorEventListener::Connect(aEditor);
}
#endif
nsHTMLEditor*
-nsHTMLEditorEventListener::GetHTMLEditor()
+HTMLEditorEventListener::GetHTMLEditor()
{
// mEditor must be nsHTMLEditor or its subclass.
return static_cast<nsHTMLEditor*>(mEditor);
}
nsresult
-nsHTMLEditorEventListener::MouseUp(nsIDOMMouseEvent* aMouseEvent)
+HTMLEditorEventListener::MouseUp(nsIDOMMouseEvent* aMouseEvent)
{
nsHTMLEditor* htmlEditor = GetHTMLEditor();
nsCOMPtr<nsIDOMEventTarget> target;
nsresult rv = aMouseEvent->AsEvent()->GetTarget(getter_AddRefs(target));
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(target, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(target);
@@ -70,17 +66,17 @@ nsHTMLEditorEventListener::MouseUp(nsIDO
aMouseEvent->GetClientX(&clientX);
aMouseEvent->GetClientY(&clientY);
htmlEditor->MouseUp(clientX, clientY, element);
return nsEditorEventListener::MouseUp(aMouseEvent);
}
nsresult
-nsHTMLEditorEventListener::MouseDown(nsIDOMMouseEvent* aMouseEvent)
+HTMLEditorEventListener::MouseDown(nsIDOMMouseEvent* aMouseEvent)
{
nsHTMLEditor* htmlEditor = GetHTMLEditor();
// Contenteditable should disregard mousedowns outside it.
// IsAcceptableInputEvent() checks it for a mouse event.
if (!htmlEditor->IsAcceptableInputEvent(aMouseEvent->AsEvent())) {
// If it's not acceptable mousedown event (including when mousedown event
// is fired outside of the active editing host), we need to commit
// composition because it will be change the selection to the clicked
@@ -200,20 +196,22 @@ nsHTMLEditorEventListener::MouseDown(nsI
aMouseEvent->GetClientY(&clientY);
htmlEditor->MouseDown(clientX, clientY, element, aMouseEvent->AsEvent());
}
return nsEditorEventListener::MouseDown(aMouseEvent);
}
nsresult
-nsHTMLEditorEventListener::MouseClick(nsIDOMMouseEvent* aMouseEvent)
+HTMLEditorEventListener::MouseClick(nsIDOMMouseEvent* aMouseEvent)
{
nsCOMPtr<nsIDOMEventTarget> target;
nsresult rv = aMouseEvent->AsEvent()->GetTarget(getter_AddRefs(target));
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(target, NS_ERROR_NULL_POINTER);
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(target);
GetHTMLEditor()->DoInlineTableEditingAction(element);
return nsEditorEventListener::MouseClick(aMouseEvent);
}
+
+} // namespace mozilla
rename from editor/libeditor/nsHTMLEditorEventListener.h
rename to editor/libeditor/HTMLEditorEventListener.h
--- a/editor/libeditor/nsHTMLEditorEventListener.h
+++ b/editor/libeditor/HTMLEditorEventListener.h
@@ -1,41 +1,43 @@
/* -*- Mode: C++; tab-width: 4; 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 nsHTMLEditorEventListener_h__
-#define nsHTMLEditorEventListener_h__
+#ifndef HTMLEditorEventListener_h
+#define HTMLEditorEventListener_h
#include "nsEditorEventListener.h"
#include "nscore.h"
class nsEditor;
class nsHTMLEditor;
-class nsHTMLEditorEventListener : public nsEditorEventListener
+namespace mozilla {
+
+class HTMLEditorEventListener final : public nsEditorEventListener
{
public:
- nsHTMLEditorEventListener() :
- nsEditorEventListener()
+ HTMLEditorEventListener()
{
}
- virtual ~nsHTMLEditorEventListener()
+ virtual ~HTMLEditorEventListener()
{
}
#ifdef DEBUG
// WARNING: You must be use nsHTMLEditor or its sub class for this class.
virtual nsresult Connect(nsEditor* aEditor) override;
#endif
protected:
virtual nsresult MouseDown(nsIDOMMouseEvent* aMouseEvent) override;
virtual nsresult MouseUp(nsIDOMMouseEvent* aMouseEvent) override;
virtual nsresult MouseClick(nsIDOMMouseEvent* aMouseEvent) override;
inline nsHTMLEditor* GetHTMLEditor();
};
-#endif // nsHTMLEditorEventListener_h__
+} // namespace mozilla
+#endif // #ifndef HTMLEditorEventListener_h
--- a/editor/libeditor/moz.build
+++ b/editor/libeditor/moz.build
@@ -33,30 +33,30 @@ UNIFIED_SOURCES += [
'DeleteNodeTransaction.cpp',
'DeleteRangeTransaction.cpp',
'DeleteTextTransaction.cpp',
'EditAggregateTransaction.cpp',
'EditorCommands.cpp',
'EditorController.cpp',
'EditorUtils.cpp',
'EditTransactionBase.cpp',
+ 'HTMLEditorEventListener.cpp',
'HTMLEditRules.cpp',
'HTMLEditUtils.cpp',
'HTMLURIRefObject.cpp',
'InsertNodeTransaction.cpp',
'InsertTextTransaction.cpp',
'InternetCiter.cpp',
'JoinNodeTransaction.cpp',
'nsEditor.cpp',
'nsEditorEventListener.cpp',
'nsHTMLAbsPosition.cpp',
'nsHTMLAnonymousUtils.cpp',
'nsHTMLDataTransfer.cpp',
'nsHTMLEditor.cpp',
- 'nsHTMLEditorEventListener.cpp',
'nsHTMLEditorStyle.cpp',
'nsHTMLInlineTableEditor.cpp',
'nsHTMLObjectResizer.cpp',
'nsPlaintextDataTransfer.cpp',
'nsPlaintextEditor.cpp',
'nsTableEditor.cpp',
'PlaceholderTransaction.cpp',
'SelectionState.cpp',
--- a/editor/libeditor/nsEditorEventListener.cpp
+++ b/editor/libeditor/nsEditorEventListener.cpp
@@ -765,17 +765,17 @@ nsEditorEventListener::NotifyIMEOfMouseB
return IMEStateManager::OnMouseButtonEventInEditor(presContext,
GetFocusedRootContent(),
aMouseEvent);
}
nsresult
nsEditorEventListener::MouseDown(nsIDOMMouseEvent* aMouseEvent)
{
- // FYI: This may be called by nsHTMLEditorEventListener::MouseDown() even
+ // FYI: This may be called by HTMLEditorEventListener::MouseDown() even
// when the event is not acceptable for committing composition.
mEditor->ForceCompositionEnd();
return NS_OK;
}
nsresult
nsEditorEventListener::HandleText(nsIDOMEvent* aTextEvent)
{
--- a/editor/libeditor/nsHTMLEditor.cpp
+++ b/editor/libeditor/nsHTMLEditor.cpp
@@ -8,27 +8,25 @@
#include "mozilla/DebugOnly.h"
#include "mozilla/EventStates.h"
#include "mozilla/TextEvents.h"
#include "nsCRT.h"
#include "nsUnicharUtils.h"
+#include "HTMLEditorEventListener.h"
#include "HTMLEditRules.h"
#include "HTMLEditUtils.h"
#include "HTMLURIRefObject.h"
#include "SetDocumentTitleTransaction.h"
#include "StyleSheetTransactions.h"
#include "TextEditUtils.h"
-
-#include "nsHTMLEditorEventListener.h"
#include "TypeInState.h"
-
#include "nsIDOMText.h"
#include "nsIDOMMozNamedAttrMap.h"
#include "nsIDOMNodeList.h"
#include "nsIDOMDocument.h"
#include "nsIDOMAttr.h"
#include "nsIDocumentInlines.h"
#include "nsIDOMEventTarget.h"
#include "nsIDOMKeyEvent.h"
@@ -437,31 +435,31 @@ nsHTMLEditor::FindSelectionRoot(nsINode
}
/* virtual */
void
nsHTMLEditor::CreateEventListeners()
{
// Don't create the handler twice
if (!mEventListener) {
- mEventListener = new nsHTMLEditorEventListener();
+ mEventListener = new HTMLEditorEventListener();
}
}
nsresult
nsHTMLEditor::InstallEventListeners()
{
NS_ENSURE_TRUE(mDocWeak && mEventListener,
NS_ERROR_NOT_INITIALIZED);
// NOTE: nsHTMLEditor doesn't need to initialize mEventTarget here because
// the target must be document node and it must be referenced as weak pointer.
- nsHTMLEditorEventListener* listener =
- reinterpret_cast<nsHTMLEditorEventListener*>(mEventListener.get());
+ HTMLEditorEventListener* listener =
+ reinterpret_cast<HTMLEditorEventListener*>(mEventListener.get());
return listener->Connect(this);
}
void
nsHTMLEditor::RemoveEventListeners()
{
if (!mDocWeak)
{
--- a/editor/libeditor/nsHTMLEditor.h
+++ b/editor/libeditor/nsHTMLEditor.h
@@ -48,16 +48,17 @@ class nsIDOMKeyEvent;
class nsITransferable;
class nsIClipboard;
class nsILinkHandler;
class nsTableWrapperFrame;
class nsIDOMRange;
class nsRange;
namespace mozilla {
+class HTMLEditorEventListener;
class HTMLEditRules;
class TextEditRules;
class TypeInState;
class WSRunObject;
struct PropItem;
template<class T> class OwningNonNull;
namespace dom {
class DocumentFragment;
@@ -969,20 +970,20 @@ protected:
void AddMouseClickListener(nsIDOMElement * aElement);
void RemoveMouseClickListener(nsIDOMElement * aElement);
nsCOMPtr<nsILinkHandler> mLinkHandler;
public:
// friends
+ friend class mozilla::HTMLEditorEventListener;
friend class mozilla::HTMLEditRules;
friend class mozilla::TextEditRules;
friend class mozilla::WSRunObject;
- friend class nsHTMLEditorEventListener;
private:
// Helpers
bool IsSimpleModifiableNode(nsIContent* aContent,
nsIAtom* aProperty,
const nsAString* aAttribute,
const nsAString* aValue);
nsresult SetInlinePropertyOnNodeImpl(nsIContent& aNode,