Bug 1260651 part.46 Rename nsHTMLURIRefObject to mozilla::HTMLURIRefObject (and also their file names) r=mccr8
This patch also fixes new bustage of nsHTMLEditRules.cpp and nsWSRunObject.cpp.
MozReview-Commit-ID: 5xgZDP7d6wy
rename from editor/libeditor/nsHTMLURIRefObject.cpp
rename to editor/libeditor/HTMLURIRefObject.cpp
--- a/editor/libeditor/nsHTMLURIRefObject.cpp
+++ b/editor/libeditor/HTMLURIRefObject.cpp
@@ -34,55 +34,58 @@
applet: codebase, archive <list>
object: codebase, data, classid, usemap
head: profile
del: cite
ins: cite
q: cite
*/
-#include "nsHTMLURIRefObject.h"
+#include "HTMLURIRefObject.h"
#include "mozilla/mozalloc.h"
#include "nsAString.h"
#include "nsDebug.h"
#include "nsError.h"
#include "nsID.h"
#include "nsIDOMAttr.h"
#include "nsIDOMElement.h"
#include "nsIDOMMozNamedAttrMap.h"
#include "nsIDOMNode.h"
#include "nsISupportsUtils.h"
#include "nsString.h"
+namespace mozilla {
+
// String classes change too often and I can't keep up.
// Set this macro to this week's approved case-insensitive compare routine.
#define MATCHES(tagName, str) tagName.EqualsIgnoreCase(str)
-nsHTMLURIRefObject::nsHTMLURIRefObject()
- : mCurAttrIndex(0), mAttributeCnt(0)
+HTMLURIRefObject::HTMLURIRefObject()
+ : mCurAttrIndex(0)
+ , mAttributeCnt(0)
{
}
-nsHTMLURIRefObject::~nsHTMLURIRefObject()
+HTMLURIRefObject::~HTMLURIRefObject()
{
}
//Interfaces for addref and release and queryinterface
-NS_IMPL_ISUPPORTS(nsHTMLURIRefObject, nsIURIRefObject)
+NS_IMPL_ISUPPORTS(HTMLURIRefObject, nsIURIRefObject)
NS_IMETHODIMP
-nsHTMLURIRefObject::Reset()
+HTMLURIRefObject::Reset()
{
mCurAttrIndex = 0;
return NS_OK;
}
NS_IMETHODIMP
-nsHTMLURIRefObject::GetNextURI(nsAString & aURI)
+HTMLURIRefObject::GetNextURI(nsAString& aURI)
{
NS_ENSURE_TRUE(mNode, NS_ERROR_NOT_INITIALIZED);
nsAutoString tagName;
nsresult rv = mNode->GetNodeName(tagName);
NS_ENSURE_SUCCESS(rv, rv);
// Loop over attribute list:
@@ -206,54 +209,55 @@ nsHTMLURIRefObject::GetNextURI(nsAString
}
}
// Return a code to indicate that there are no more,
// to distinguish that case from real errors.
return NS_ERROR_NOT_AVAILABLE;
}
NS_IMETHODIMP
-nsHTMLURIRefObject::RewriteAllURIs(const nsAString & aOldPat,
- const nsAString & aNewPat,
- bool aMakeRel)
+HTMLURIRefObject::RewriteAllURIs(const nsAString& aOldPat,
+ const nsAString& aNewPat,
+ bool aMakeRel)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
-nsHTMLURIRefObject::GetNode(nsIDOMNode** aNode)
+HTMLURIRefObject::GetNode(nsIDOMNode** aNode)
{
NS_ENSURE_TRUE(mNode, NS_ERROR_NOT_INITIALIZED);
NS_ENSURE_TRUE(aNode, NS_ERROR_NULL_POINTER);
*aNode = mNode.get();
NS_ADDREF(*aNode);
return NS_OK;
}
NS_IMETHODIMP
-nsHTMLURIRefObject::SetNode(nsIDOMNode *aNode)
+HTMLURIRefObject::SetNode(nsIDOMNode* aNode)
{
mNode = aNode;
nsAutoString dummyURI;
if (NS_SUCCEEDED(GetNextURI(dummyURI)))
{
mCurAttrIndex = 0; // Reset so we'll get the first node next time
return NS_OK;
}
// If there weren't any URIs in the attributes,
// then don't accept this node.
mNode = 0;
return NS_ERROR_INVALID_ARG;
}
+} // namespace mozilla
+
nsresult NS_NewHTMLURIRefObject(nsIURIRefObject** aResult, nsIDOMNode* aNode)
{
- RefPtr<nsHTMLURIRefObject> refObject = new nsHTMLURIRefObject();
+ RefPtr<mozilla::HTMLURIRefObject> refObject = new mozilla::HTMLURIRefObject();
nsresult rv = refObject->SetNode(aNode);
if (NS_FAILED(rv)) {
*aResult = 0;
return rv;
}
refObject.forget(aResult);
return NS_OK;
}
-
rename from editor/libeditor/nsHTMLURIRefObject.h
rename to editor/libeditor/HTMLURIRefObject.h
--- a/editor/libeditor/nsHTMLURIRefObject.h
+++ b/editor/libeditor/HTMLURIRefObject.h
@@ -1,46 +1,48 @@
/* -*- 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 HTMLURIRefObject_h
+#define HTMLURIRefObject_h
#include "nsCOMPtr.h"
#include "nsISupportsImpl.h"
#include "nsIURIRefObject.h"
#include "nscore.h"
-class nsIDOMMozNamedAttrMap;
-class nsIDOMNode;
-
-#ifndef nsHTMLURIRefObject_h__
-#define nsHTMLURIRefObject_h__
-
#define NS_URI_REF_OBJECT_CID \
{ /* {bdd79df6-1dd1-11b2-b29c-c3d63a58f1d2} */ \
0xbdd79df6, 0x1dd1, 0x11b2, \
{ 0xb2, 0x9c, 0xc3, 0xd6, 0x3a, 0x58, 0xf1, 0xd2 } \
}
-class nsHTMLURIRefObject final : public nsIURIRefObject
+class nsIDOMMozNamedAttrMap;
+class nsIDOMNode;
+
+namespace mozilla {
+
+class HTMLURIRefObject final : public nsIURIRefObject
{
public:
- nsHTMLURIRefObject();
+ HTMLURIRefObject();
// Interfaces for addref and release and queryinterface
NS_DECL_ISUPPORTS
NS_DECL_NSIURIREFOBJECT
protected:
- virtual ~nsHTMLURIRefObject();
+ virtual ~HTMLURIRefObject();
nsCOMPtr<nsIDOMNode> mNode;
nsCOMPtr<nsIDOMMozNamedAttrMap> mAttributes;
uint32_t mCurAttrIndex;
uint32_t mAttributeCnt;
};
+} // namespace mozilla
+
nsresult NS_NewHTMLURIRefObject(nsIURIRefObject** aResult, nsIDOMNode* aNode);
-#endif /* nsHTMLURIRefObject_h__ */
-
+#endif // #ifndef HTMLURIRefObject_h
--- a/editor/libeditor/moz.build
+++ b/editor/libeditor/moz.build
@@ -27,32 +27,32 @@ UNIFIED_SOURCES += [
'DeleteRangeTransaction.cpp',
'DeleteTextTransaction.cpp',
'EditAggregateTransaction.cpp',
'EditorCommands.cpp',
'EditorController.cpp',
'EditorUtils.cpp',
'EditTransactionBase.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',
'nsHTMLEditRules.cpp',
'nsHTMLInlineTableEditor.cpp',
'nsHTMLObjectResizer.cpp',
- 'nsHTMLURIRefObject.cpp',
'nsPlaintextDataTransfer.cpp',
'nsPlaintextEditor.cpp',
'nsTableEditor.cpp',
'nsTextEditRules.cpp',
'nsTextEditRulesBidi.cpp',
'nsWSRunObject.cpp',
'PlaceholderTransaction.cpp',
'SelectionState.cpp',
--- a/editor/libeditor/nsHTMLEditRules.cpp
+++ b/editor/libeditor/nsHTMLEditRules.cpp
@@ -45,16 +45,17 @@
#include "nsINode.h"
#include "nsLiteralString.h"
#include "nsPlaintextEditor.h"
#include "nsRange.h"
#include "nsReadableUtils.h"
#include "nsString.h"
#include "nsStringFwd.h"
#include "nsTArray.h"
+#include "nsTextNode.h"
#include "nsThreadUtils.h"
#include "nsUnicharUtils.h"
#include "nsWSRunObject.h"
#include <algorithm>
// Workaround for windows headers
#ifdef SetProp
#undef SetProp
@@ -4398,17 +4399,17 @@ nsHTMLEditRules::CreateStyleForInsertTex
NS_ENSURE_STATE(offset != -1);
node = node->GetParentNode();
}
if (!mHTMLEditor->IsContainer(node)) {
return NS_OK;
}
OwningNonNull<Text> newNode = aDoc.CreateTextNode(EmptyString());
NS_ENSURE_STATE(mHTMLEditor);
- res = mHTMLEditor->InsertNode(newNode, *node, offset);
+ res = mHTMLEditor->InsertNode(*newNode, *node, offset);
NS_ENSURE_SUCCESS(res, res);
node = newNode;
offset = 0;
weDidSomething = true;
if (relFontSize) {
// dir indicated bigger versus smaller. 1 = bigger, -1 = smaller
nsHTMLEditor::FontSize dir = relFontSize > 0 ?
--- a/editor/libeditor/nsHTMLEditor.cpp
+++ b/editor/libeditor/nsHTMLEditor.cpp
@@ -9,25 +9,25 @@
#include "mozilla/EventStates.h"
#include "mozilla/TextEvents.h"
#include "nsCRT.h"
#include "nsUnicharUtils.h"
#include "HTMLEditUtils.h"
+#include "HTMLURIRefObject.h"
#include "SetDocumentTitleTransaction.h"
#include "StyleSheetTransactions.h"
#include "TextEditUtils.h"
#include "nsHTMLEditRules.h"
#include "nsHTMLEditorEventListener.h"
#include "TypeInState.h"
-#include "nsHTMLURIRefObject.h"
#include "nsIDOMText.h"
#include "nsIDOMMozNamedAttrMap.h"
#include "nsIDOMNodeList.h"
#include "nsIDOMDocument.h"
#include "nsIDOMAttr.h"
#include "nsIDocumentInlines.h"
#include "nsIDOMEventTarget.h"
--- a/editor/libeditor/nsWSRunObject.cpp
+++ b/editor/libeditor/nsWSRunObject.cpp
@@ -28,22 +28,16 @@
#include "nsString.h"
#include "nsTextFragment.h"
using namespace mozilla;
using namespace mozilla::dom;
const char16_t nbsp = 160;
-static bool IsBlockNode(nsINode* node)
-{
- return node && node->IsElement() &&
- nsHTMLEditor::NodeIsBlockStatic(node->AsElement());
-}
-
//- constructor / destructor -----------------------------------------------
nsWSRunObject::nsWSRunObject(nsHTMLEditor* aEd, nsINode* aNode, int32_t aOffset)
: mNode(aNode)
, mOffset(aOffset)
, mPRE(false)
, mStartNode()
, mStartOffset(0)
, mStartReason()
@@ -1929,8 +1923,15 @@ nsWSRunObject::Scrub()
nsresult res = DeleteChars(run->mStartNode, run->mStartOffset,
run->mEndNode, run->mEndOffset);
NS_ENSURE_SUCCESS(res, res);
}
run = run->mRight;
}
return NS_OK;
}
+
+bool
+nsWSRunObject::IsBlockNode(nsINode* aNode)
+{
+ return aNode && aNode->IsElement() &&
+ nsHTMLEditor::NodeIsBlockStatic(aNode->AsElement());
+}
--- a/editor/libeditor/nsWSRunObject.h
+++ b/editor/libeditor/nsWSRunObject.h
@@ -342,16 +342,17 @@ class MOZ_STACK_CLASS nsWSRunObject
WSPoint GetWSPointBefore(nsINode* aNode, int32_t aOffset);
nsresult CheckTrailingNBSPOfRun(WSFragment *aRun);
nsresult CheckTrailingNBSP(WSFragment* aRun, nsINode* aNode,
int32_t aOffset);
nsresult CheckLeadingNBSP(WSFragment* aRun, nsINode* aNode,
int32_t aOffset);
nsresult Scrub();
+ bool IsBlockNode(nsINode* aNode);
// member variables ---------------------------------------------------------
nsCOMPtr<nsINode> mNode; // the node passed to our constructor
int32_t mOffset; // the offset passed to our contructor
// together, the above represent the point at which we are building up ws info.
bool mPRE; // true if we are in preformatted whitespace context