From 784ca3f4052d78d2565f2214b4580e364a1d5a48 Mon Sep 17 00:00:00 2001 From: "buster%netscape.com" Date: Mon, 30 Aug 1999 22:12:11 +0000 Subject: [PATCH] removed static constructors, since they're illegal in our system --- editor/base/CreateElementTxn.cpp | 6 +++- editor/base/nsEditor.cpp | 39 +++++++++++++++++----- editor/base/nsEditor.h | 3 +- editor/base/nsHTMLEditor.cpp | 34 +++++++++---------- editor/libeditor/base/CreateElementTxn.cpp | 6 +++- editor/libeditor/base/nsEditor.cpp | 39 +++++++++++++++++----- editor/libeditor/base/nsEditor.h | 3 +- editor/libeditor/html/nsHTMLEditor.cpp | 34 +++++++++---------- 8 files changed, 108 insertions(+), 56 deletions(-) diff --git a/editor/base/CreateElementTxn.cpp b/editor/base/CreateElementTxn.cpp index d86043e4d284..02d6cd204338 100644 --- a/editor/base/CreateElementTxn.cpp +++ b/editor/base/CreateElementTxn.cpp @@ -76,7 +76,11 @@ NS_IMETHODIMP CreateElementTxn::Do(void) if (NS_FAILED(result)) return result; if (!doc) return NS_ERROR_NULL_POINTER; - if (nsEditor::GetTextNodeTag() == mTag) + nsAutoString textNodeTag; + result = nsEditor::GetTextNodeTag(textNodeTag); + if (NS_FAILED(result)) { return result; } + + if (textNodeTag == mTag) { const nsString stringData; nsCOMPtrnewTextNode; diff --git a/editor/base/nsEditor.cpp b/editor/base/nsEditor.cpp index ed86794199de..13dd6e53723a 100644 --- a/editor/base/nsEditor.cpp +++ b/editor/base/nsEditor.cpp @@ -123,7 +123,7 @@ const char* nsEditor::kMOZEditorBogusNodeAttr="MOZ_EDITOR_BOGUS_NODE"; const char* nsEditor::kMOZEditorBogusNodeValue="TRUE"; #ifdef NS_DEBUG_EDITOR -static PRBool gNoisy = PR_FALSE; +static PRBool gNoisy = PR_TRUE; #else static const PRBool gNoisy = PR_FALSE; #endif @@ -1355,11 +1355,20 @@ NS_IMETHODIMP nsEditor::ScrollIntoView(PRBool aScrollToBegin) return NS_ERROR_NOT_IMPLEMENTED; } - -nsString& nsEditor::GetTextNodeTag() +/** static helper method */ +nsresult nsEditor::GetTextNodeTag(nsString& aOutString) { - static nsString gTextNodeTag("special text node tag"); - return gTextNodeTag; + aOutString = ""; + static nsString *gTextNodeTag=nsnull; + if (!gTextNodeTag) + { + gTextNodeTag = new nsString("special text node tag"); + if (!gTextNodeTag) { + return NS_ERROR_OUT_OF_MEMORY; + } + } + aOutString = *gTextNodeTag; + return NS_OK; } @@ -1398,7 +1407,10 @@ NS_IMETHODIMP nsEditor::InsertTextImpl(const nsString& aStringToInsert) if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(&offset)) && selectedNode) { nsCOMPtr newNode; - result = CreateNode(GetTextNodeTag(), selectedNode, offset, + nsAutoString textNodeTag; + result = GetTextNodeTag(textNodeTag); + if (NS_FAILED(result)) { return result; } + result = CreateNode(textNodeTag, selectedNode, offset, getter_AddRefs(newNode)); if (NS_SUCCEEDED(result) && newNode) { @@ -1720,7 +1732,10 @@ NS_IMETHODIMP nsEditor::DoInitialInsert(const nsString & aStringToInsert) // create transaction to insert the text node, // and create a transaction to insert the text CreateElementTxn *txn; - result = CreateTxnForCreateElement(GetTextNodeTag(), node, 0, &txn); + nsAutoString textNodeTag; + result = GetTextNodeTag(textNodeTag); + if (NS_FAILED(result)) { return result; } + result = CreateTxnForCreateElement(textNodeTag, node, 0, &txn); if ((NS_SUCCEEDED(result)) && txn) { result = Do(txn); @@ -2885,7 +2900,10 @@ nsEditor::SetInputMethodText(const nsString& aStringToInsert, nsIPrivateTextRang if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(&offset)) && selectedNode) { nsCOMPtr newNode; - result = CreateNode(GetTextNodeTag(), selectedNode, offset+1,getter_AddRefs(newNode)); + nsAutoString textNodeTag; + result = GetTextNodeTag(textNodeTag); + if (NS_FAILED(result)) { return result; } + result = CreateNode(textNodeTag, selectedNode, offset+1,getter_AddRefs(newNode)); if (NS_SUCCEEDED(result) && newNode) { nsCOMPtrnewTextNode; @@ -2933,7 +2951,10 @@ NS_IMETHODIMP nsEditor::DoInitialInputMethodInsert(const nsString & aStringToIns // create transaction to insert the text node, // and create a transaction to insert the text CreateElementTxn *txn; - result = CreateTxnForCreateElement(GetTextNodeTag(), node, 0, &txn); + nsAutoString textNodeTag; + result = GetTextNodeTag(textNodeTag); + if (NS_FAILED(result)) { return result; } + result = CreateTxnForCreateElement(textNodeTag, node, 0, &txn); if ((NS_SUCCEEDED(result)) && txn) { result = Do(txn); diff --git a/editor/base/nsEditor.h b/editor/base/nsEditor.h index 56f2c5a0e53f..255b6aef5235 100644 --- a/editor/base/nsEditor.h +++ b/editor/base/nsEditor.h @@ -360,7 +360,8 @@ protected: public: - static nsString& GetTextNodeTag(); + /** return the string that represents text nodes in the content tree */ + static nsresult GetTextNodeTag(nsString& aOutString); /** * SplitNode() creates a new node identical to an existing node, and split the contents between the two nodes diff --git a/editor/base/nsHTMLEditor.cpp b/editor/base/nsHTMLEditor.cpp index 613ddae0c0b6..8a7cd047769b 100644 --- a/editor/base/nsHTMLEditor.cpp +++ b/editor/base/nsHTMLEditor.cpp @@ -103,7 +103,7 @@ static NS_DEFINE_CID(kCClipboardCID, NS_CLIPBOARD_CID); static NS_DEFINE_CID(kCTransferableCID, NS_TRANSFERABLE_CID); #ifdef NS_DEBUG -static PRBool gNoisy = PR_FALSE; +static PRBool gNoisy = PR_TRUE; #else static const PRBool gNoisy = PR_FALSE; #endif @@ -4245,10 +4245,10 @@ nsHTMLEditor::SetCaretInTableCell(nsIDOMElement* aElement) NS_IMETHODIMP nsHTMLEditor::IsRootTag(nsString &aTag, PRBool &aIsTag) { - static nsAutoString bodyTag = "body"; - static nsAutoString tdTag = "td"; - static nsAutoString thTag = "th"; - static nsAutoString captionTag = "caption"; + static char bodyTag[] = "body"; + static char tdTag[] = "td"; + static char thTag[] = "th"; + static char captionTag[] = "caption"; if (PR_TRUE==aTag.EqualsIgnoreCase(bodyTag) || PR_TRUE==aTag.EqualsIgnoreCase(tdTag) || PR_TRUE==aTag.EqualsIgnoreCase(thTag) || @@ -4265,18 +4265,18 @@ nsHTMLEditor::IsRootTag(nsString &aTag, PRBool &aIsTag) NS_IMETHODIMP nsHTMLEditor::IsSubordinateBlock(nsString &aTag, PRBool &aIsTag) { - static nsAutoString p = "p"; - static nsAutoString h1 = "h1"; - static nsAutoString h2 = "h2"; - static nsAutoString h3 = "h3"; - static nsAutoString h4 = "h4"; - static nsAutoString h5 = "h5"; - static nsAutoString h6 = "h6"; - static nsAutoString address = "address"; - static nsAutoString pre = "pre"; - static nsAutoString li = "li"; - static nsAutoString dt = "dt"; - static nsAutoString dd = "dd"; + static char p[] = "p"; + static char h1[] = "h1"; + static char h2[] = "h2"; + static char h3[] = "h3"; + static char h4[] = "h4"; + static char h5[] = "h5"; + static char h6[] = "h6"; + static char address[] = "address"; + static char pre[] = "pre"; + static char li[] = "li"; + static char dt[] = "dt"; + static char dd[] = "dd"; if (PR_TRUE==aTag.EqualsIgnoreCase(p) || PR_TRUE==aTag.EqualsIgnoreCase(h1) || PR_TRUE==aTag.EqualsIgnoreCase(h2) || diff --git a/editor/libeditor/base/CreateElementTxn.cpp b/editor/libeditor/base/CreateElementTxn.cpp index d86043e4d284..02d6cd204338 100644 --- a/editor/libeditor/base/CreateElementTxn.cpp +++ b/editor/libeditor/base/CreateElementTxn.cpp @@ -76,7 +76,11 @@ NS_IMETHODIMP CreateElementTxn::Do(void) if (NS_FAILED(result)) return result; if (!doc) return NS_ERROR_NULL_POINTER; - if (nsEditor::GetTextNodeTag() == mTag) + nsAutoString textNodeTag; + result = nsEditor::GetTextNodeTag(textNodeTag); + if (NS_FAILED(result)) { return result; } + + if (textNodeTag == mTag) { const nsString stringData; nsCOMPtrnewTextNode; diff --git a/editor/libeditor/base/nsEditor.cpp b/editor/libeditor/base/nsEditor.cpp index ed86794199de..13dd6e53723a 100644 --- a/editor/libeditor/base/nsEditor.cpp +++ b/editor/libeditor/base/nsEditor.cpp @@ -123,7 +123,7 @@ const char* nsEditor::kMOZEditorBogusNodeAttr="MOZ_EDITOR_BOGUS_NODE"; const char* nsEditor::kMOZEditorBogusNodeValue="TRUE"; #ifdef NS_DEBUG_EDITOR -static PRBool gNoisy = PR_FALSE; +static PRBool gNoisy = PR_TRUE; #else static const PRBool gNoisy = PR_FALSE; #endif @@ -1355,11 +1355,20 @@ NS_IMETHODIMP nsEditor::ScrollIntoView(PRBool aScrollToBegin) return NS_ERROR_NOT_IMPLEMENTED; } - -nsString& nsEditor::GetTextNodeTag() +/** static helper method */ +nsresult nsEditor::GetTextNodeTag(nsString& aOutString) { - static nsString gTextNodeTag("special text node tag"); - return gTextNodeTag; + aOutString = ""; + static nsString *gTextNodeTag=nsnull; + if (!gTextNodeTag) + { + gTextNodeTag = new nsString("special text node tag"); + if (!gTextNodeTag) { + return NS_ERROR_OUT_OF_MEMORY; + } + } + aOutString = *gTextNodeTag; + return NS_OK; } @@ -1398,7 +1407,10 @@ NS_IMETHODIMP nsEditor::InsertTextImpl(const nsString& aStringToInsert) if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(&offset)) && selectedNode) { nsCOMPtr newNode; - result = CreateNode(GetTextNodeTag(), selectedNode, offset, + nsAutoString textNodeTag; + result = GetTextNodeTag(textNodeTag); + if (NS_FAILED(result)) { return result; } + result = CreateNode(textNodeTag, selectedNode, offset, getter_AddRefs(newNode)); if (NS_SUCCEEDED(result) && newNode) { @@ -1720,7 +1732,10 @@ NS_IMETHODIMP nsEditor::DoInitialInsert(const nsString & aStringToInsert) // create transaction to insert the text node, // and create a transaction to insert the text CreateElementTxn *txn; - result = CreateTxnForCreateElement(GetTextNodeTag(), node, 0, &txn); + nsAutoString textNodeTag; + result = GetTextNodeTag(textNodeTag); + if (NS_FAILED(result)) { return result; } + result = CreateTxnForCreateElement(textNodeTag, node, 0, &txn); if ((NS_SUCCEEDED(result)) && txn) { result = Do(txn); @@ -2885,7 +2900,10 @@ nsEditor::SetInputMethodText(const nsString& aStringToInsert, nsIPrivateTextRang if (NS_SUCCEEDED(result) && NS_SUCCEEDED(selection->GetAnchorOffset(&offset)) && selectedNode) { nsCOMPtr newNode; - result = CreateNode(GetTextNodeTag(), selectedNode, offset+1,getter_AddRefs(newNode)); + nsAutoString textNodeTag; + result = GetTextNodeTag(textNodeTag); + if (NS_FAILED(result)) { return result; } + result = CreateNode(textNodeTag, selectedNode, offset+1,getter_AddRefs(newNode)); if (NS_SUCCEEDED(result) && newNode) { nsCOMPtrnewTextNode; @@ -2933,7 +2951,10 @@ NS_IMETHODIMP nsEditor::DoInitialInputMethodInsert(const nsString & aStringToIns // create transaction to insert the text node, // and create a transaction to insert the text CreateElementTxn *txn; - result = CreateTxnForCreateElement(GetTextNodeTag(), node, 0, &txn); + nsAutoString textNodeTag; + result = GetTextNodeTag(textNodeTag); + if (NS_FAILED(result)) { return result; } + result = CreateTxnForCreateElement(textNodeTag, node, 0, &txn); if ((NS_SUCCEEDED(result)) && txn) { result = Do(txn); diff --git a/editor/libeditor/base/nsEditor.h b/editor/libeditor/base/nsEditor.h index 56f2c5a0e53f..255b6aef5235 100644 --- a/editor/libeditor/base/nsEditor.h +++ b/editor/libeditor/base/nsEditor.h @@ -360,7 +360,8 @@ protected: public: - static nsString& GetTextNodeTag(); + /** return the string that represents text nodes in the content tree */ + static nsresult GetTextNodeTag(nsString& aOutString); /** * SplitNode() creates a new node identical to an existing node, and split the contents between the two nodes diff --git a/editor/libeditor/html/nsHTMLEditor.cpp b/editor/libeditor/html/nsHTMLEditor.cpp index 613ddae0c0b6..8a7cd047769b 100644 --- a/editor/libeditor/html/nsHTMLEditor.cpp +++ b/editor/libeditor/html/nsHTMLEditor.cpp @@ -103,7 +103,7 @@ static NS_DEFINE_CID(kCClipboardCID, NS_CLIPBOARD_CID); static NS_DEFINE_CID(kCTransferableCID, NS_TRANSFERABLE_CID); #ifdef NS_DEBUG -static PRBool gNoisy = PR_FALSE; +static PRBool gNoisy = PR_TRUE; #else static const PRBool gNoisy = PR_FALSE; #endif @@ -4245,10 +4245,10 @@ nsHTMLEditor::SetCaretInTableCell(nsIDOMElement* aElement) NS_IMETHODIMP nsHTMLEditor::IsRootTag(nsString &aTag, PRBool &aIsTag) { - static nsAutoString bodyTag = "body"; - static nsAutoString tdTag = "td"; - static nsAutoString thTag = "th"; - static nsAutoString captionTag = "caption"; + static char bodyTag[] = "body"; + static char tdTag[] = "td"; + static char thTag[] = "th"; + static char captionTag[] = "caption"; if (PR_TRUE==aTag.EqualsIgnoreCase(bodyTag) || PR_TRUE==aTag.EqualsIgnoreCase(tdTag) || PR_TRUE==aTag.EqualsIgnoreCase(thTag) || @@ -4265,18 +4265,18 @@ nsHTMLEditor::IsRootTag(nsString &aTag, PRBool &aIsTag) NS_IMETHODIMP nsHTMLEditor::IsSubordinateBlock(nsString &aTag, PRBool &aIsTag) { - static nsAutoString p = "p"; - static nsAutoString h1 = "h1"; - static nsAutoString h2 = "h2"; - static nsAutoString h3 = "h3"; - static nsAutoString h4 = "h4"; - static nsAutoString h5 = "h5"; - static nsAutoString h6 = "h6"; - static nsAutoString address = "address"; - static nsAutoString pre = "pre"; - static nsAutoString li = "li"; - static nsAutoString dt = "dt"; - static nsAutoString dd = "dd"; + static char p[] = "p"; + static char h1[] = "h1"; + static char h2[] = "h2"; + static char h3[] = "h3"; + static char h4[] = "h4"; + static char h5[] = "h5"; + static char h6[] = "h6"; + static char address[] = "address"; + static char pre[] = "pre"; + static char li[] = "li"; + static char dt[] = "dt"; + static char dd[] = "dd"; if (PR_TRUE==aTag.EqualsIgnoreCase(p) || PR_TRUE==aTag.EqualsIgnoreCase(h1) || PR_TRUE==aTag.EqualsIgnoreCase(h2) ||