From: timeless@mozdev.org diff --git a/editor/libeditor/base/nsEditor.cpp b/editor/libeditor/base/nsEditor.cpp --- a/editor/libeditor/base/nsEditor.cpp +++ b/editor/libeditor/base/nsEditor.cpp @@ -1563,8 +1563,8 @@ nsresult nsEditor::ReplaceContainer(nsIDOMNode *inNode, nsCOMPtr *outNode, const nsAString &aNodeType, - const nsAString *aAttribute, - const nsAString *aValue, + const nsAString &aAttribute, + const nsAString &aValue, PRBool aCloneAttributes) { if (!inNode || !outNode) @@ -1584,9 +1584,9 @@ nsEditor::ReplaceContainer(nsIDOMNode *i *outNode = do_QueryInterface(elem); // set attribute if needed - if (aAttribute && aValue && !aAttribute->IsEmpty()) - { - res = elem->SetAttribute(*aAttribute, *aValue); + if (!aAttribute.IsEmpty()) + { + res = elem->SetAttribute(aAttribute, aValue); if (NS_FAILED(res)) return res; } if (aCloneAttributes) @@ -1677,8 +1677,8 @@ nsresult nsEditor::InsertContainerAbove( nsIDOMNode *inNode, nsCOMPtr *outNode, const nsAString &aNodeType, - const nsAString *aAttribute, - const nsAString *aValue) + const nsAString &aAttribute, + const nsAString &aValue) { if (!inNode || !outNode) return NS_ERROR_NULL_POINTER; @@ -1697,9 +1697,9 @@ nsEditor::InsertContainerAbove( nsIDOMNo *outNode = do_QueryInterface(elem); // set attribute if needed - if (aAttribute && aValue && !aAttribute->IsEmpty()) - { - res = elem->SetAttribute(*aAttribute, *aValue); + if (!aAttribute.IsEmpty()) + { + res = elem->SetAttribute(aAttribute, aValue); if (NS_FAILED(res)) return res; } diff --git a/editor/libeditor/base/nsEditor.h b/editor/libeditor/base/nsEditor.h --- a/editor/libeditor/base/nsEditor.h +++ b/editor/libeditor/base/nsEditor.h @@ -177,16 +177,16 @@ public: nsresult ReplaceContainer(nsIDOMNode *inNode, nsCOMPtr *outNode, const nsAString &aNodeType, - const nsAString *aAttribute = nsnull, - const nsAString *aValue = nsnull, + const nsAString &aAttribute, + const nsAString &aValue, PRBool aCloneAttributes = PR_FALSE); nsresult RemoveContainer(nsIDOMNode *inNode); nsresult InsertContainerAbove(nsIDOMNode *inNode, nsCOMPtr *outNode, const nsAString &aNodeType, - const nsAString *aAttribute = nsnull, - const nsAString *aValue = nsnull); + const nsAString &aAttribute, + const nsAString &aValue); nsresult MoveNode(nsIDOMNode *aNode, nsIDOMNode *aParent, PRInt32 aOffset); /* Method to replace certain CreateElementNS() calls. diff --git a/editor/libeditor/html/TypeInState.cpp b/editor/libeditor/html/TypeInState.cpp --- a/editor/libeditor/html/TypeInState.cpp +++ b/editor/libeditor/html/TypeInState.cpp @@ -150,12 +150,12 @@ nsresult TypeInState::SetProp(nsIAtom *a return SetProp(aProp,EmptyString(),EmptyString()); } -nsresult TypeInState::SetProp(nsIAtom *aProp, const nsString &aAttr) +nsresult TypeInState::SetProp(nsIAtom *aProp, const nsAString &aAttr) { return SetProp(aProp,aAttr,EmptyString()); } -nsresult TypeInState::SetProp(nsIAtom *aProp, const nsString &aAttr, const nsString &aValue) +nsresult TypeInState::SetProp(nsIAtom *aProp, const nsAString &aAttr, const nsAString &aValue) { // special case for big/small, these nest if (nsEditProperty::big == aProp) @@ -206,7 +206,7 @@ nsresult TypeInState::ClearProp(nsIAtom return ClearProp(aProp,EmptyString()); } -nsresult TypeInState::ClearProp(nsIAtom *aProp, const nsString &aAttr) +nsresult TypeInState::ClearProp(nsIAtom *aProp, const nsAString &aAttr) { // if it's already cleared we are done if (IsPropCleared(aProp,aAttr)) return NS_OK; @@ -280,7 +280,7 @@ nsresult TypeInState::GetTypingState(PRB nsresult TypeInState::GetTypingState(PRBool &isSet, PRBool &theSetting, nsIAtom *aProp, - const nsString &aAttr) + const nsAString &aAttr) { return GetTypingState(isSet, theSetting, aProp, aAttr, nsnull); } @@ -289,7 +289,7 @@ nsresult TypeInState::GetTypingState(PRB nsresult TypeInState::GetTypingState(PRBool &isSet, PRBool &theSetting, nsIAtom *aProp, - const nsString &aAttr, + const nsAString &aAttr, nsString *aValue) { if (IsPropSet(aProp, aAttr, aValue)) @@ -316,7 +316,7 @@ nsresult TypeInState::GetTypingState(PRB *******************************************************************/ nsresult TypeInState::RemovePropFromSetList(nsIAtom *aProp, - const nsString &aAttr) + const nsAString &aAttr) { PRInt32 index; if (!aProp) @@ -338,7 +338,7 @@ nsresult TypeInState::RemovePropFromSetL nsresult TypeInState::RemovePropFromClearedList(nsIAtom *aProp, - const nsString &aAttr) + const nsAString &aAttr) { PRInt32 index; if (FindPropInList(aProp, aAttr, nsnull, mClearedArray, index)) @@ -351,7 +351,7 @@ nsresult TypeInState::RemovePropFromClea PRBool TypeInState::IsPropSet(nsIAtom *aProp, - const nsString &aAttr, + const nsAString &aAttr, nsString* outValue) { PRInt32 i; @@ -360,7 +360,7 @@ PRBool TypeInState::IsPropSet(nsIAtom *a PRBool TypeInState::IsPropSet(nsIAtom *aProp, - const nsString &aAttr, + const nsAString &aAttr, nsString *outValue, PRInt32 &outIndex) { @@ -382,7 +382,7 @@ PRBool TypeInState::IsPropSet(nsIAtom *a PRBool TypeInState::IsPropCleared(nsIAtom *aProp, - const nsString &aAttr) + const nsAString &aAttr) { PRInt32 i; return IsPropCleared(aProp, aAttr, i); @@ -390,7 +390,7 @@ PRBool TypeInState::IsPropCleared(nsIAto PRBool TypeInState::IsPropCleared(nsIAtom *aProp, - const nsString &aAttr, + const nsAString &aAttr, PRInt32 &outIndex) { if (FindPropInList(aProp, aAttr, nsnull, mClearedArray, outIndex)) diff --git a/editor/libeditor/html/TypeInState.h b/editor/libeditor/html/TypeInState.h --- a/editor/libeditor/html/TypeInState.h +++ b/editor/libeditor/html/TypeInState.h @@ -73,12 +73,12 @@ public: NS_DECL_NSISELECTIONLISTENER nsresult SetProp(nsIAtom *aProp); - nsresult SetProp(nsIAtom *aProp, const nsString &aAttr); - nsresult SetProp(nsIAtom *aProp, const nsString &aAttr, const nsString &aValue); + nsresult SetProp(nsIAtom *aProp, const nsAString &aAttr); + nsresult SetProp(nsIAtom *aProp, const nsAString &aAttr, const nsAString &aValue); nsresult ClearAllProps(); nsresult ClearProp(nsIAtom *aProp); - nsresult ClearProp(nsIAtom *aProp, const nsString &aAttr); + nsresult ClearProp(nsIAtom *aProp, const nsAString &aAttr); //************************************************************************** // TakeClearProperty: hands back next property item on the clear list. @@ -97,20 +97,20 @@ public: nsresult GetTypingState(PRBool &isSet, PRBool &theSetting, nsIAtom *aProp); nsresult GetTypingState(PRBool &isSet, PRBool &theSetting, nsIAtom *aProp, - const nsString &aAttr); + const nsAString &aAttr); nsresult GetTypingState(PRBool &isSet, PRBool &theSetting, nsIAtom *aProp, - const nsString &aAttr, nsString* outValue); + const nsAString &aAttr, nsString* outValue); static PRBool FindPropInList(nsIAtom *aProp, const nsAString &aAttr, nsAString *outValue, nsTArray &aList, PRInt32 &outIndex); protected: - nsresult RemovePropFromSetList(nsIAtom *aProp, const nsString &aAttr); - nsresult RemovePropFromClearedList(nsIAtom *aProp, const nsString &aAttr); - PRBool IsPropSet(nsIAtom *aProp, const nsString &aAttr, nsString* outValue); - PRBool IsPropSet(nsIAtom *aProp, const nsString &aAttr, nsString* outValue, PRInt32 &outIndex); - PRBool IsPropCleared(nsIAtom *aProp, const nsString &aAttr); - PRBool IsPropCleared(nsIAtom *aProp, const nsString &aAttr, PRInt32 &outIndex); + nsresult RemovePropFromSetList(nsIAtom *aProp, const nsAString &aAttr); + nsresult RemovePropFromClearedList(nsIAtom *aProp, const nsAString &aAttr); + PRBool IsPropSet(nsIAtom *aProp, const nsAString &aAttr, nsString* outValue); + PRBool IsPropSet(nsIAtom *aProp, const nsAString &aAttr, nsString* outValue, PRInt32 &outIndex); + PRBool IsPropCleared(nsIAtom *aProp, const nsAString &aAttr); + PRBool IsPropCleared(nsIAtom *aProp, const nsAString &aAttr, PRInt32 &outIndex); nsTArray mSetArray; nsTArray mClearedArray; diff --git a/editor/libeditor/html/nsHTMLCSSUtils.cpp b/editor/libeditor/html/nsHTMLCSSUtils.cpp --- a/editor/libeditor/html/nsHTMLCSSUtils.cpp +++ b/editor/libeditor/html/nsHTMLCSSUtils.cpp @@ -59,11 +59,11 @@ #include "nsAutoPtr.h" static -void ProcessBValue(const nsAString * aInputString, nsAString & aOutputString, +void ProcessBValue(const nsAString & aInputString, nsAString & aOutputString, const char * aDefaultValueString, const char * aPrependString, const char* aAppendString) { - if (aInputString && aInputString->EqualsLiteral("-moz-editor-invert-value")) { + if (aInputString.EqualsLiteral("-moz-editor-invert-value")) { aOutputString.AssignLiteral("normal"); } else { @@ -72,7 +72,7 @@ void ProcessBValue(const nsAString * aIn } static -void ProcessDefaultValue(const nsAString * aInputString, nsAString & aOutputString, +void ProcessDefaultValue(const nsAString & aInputString, nsAString & aOutputString, const char * aDefaultValueString, const char * aPrependString, const char* aAppendString) { @@ -80,117 +80,103 @@ void ProcessDefaultValue(const nsAString } static -void ProcessSameValue(const nsAString * aInputString, nsAString & aOutputString, +void ProcessSameValue(const nsAString & aInputString, nsAString & aOutputString, const char * aDefaultValueString, const char * aPrependString, const char* aAppendString) { - if (aInputString) { - aOutputString.Assign(*aInputString); - } - else - aOutputString.Truncate(); + aOutputString.Assign(aInputString); } static -void ProcessExtendedValue(const nsAString * aInputString, nsAString & aOutputString, +void ProcessExtendedValue(const nsAString & aInputString, nsAString & aOutputString, const char * aDefaultValueString, const char * aPrependString, const char* aAppendString) { aOutputString.Truncate(); - if (aInputString) { - if (aPrependString) { - AppendASCIItoUTF16(aPrependString, aOutputString); - } - aOutputString.Append(*aInputString); - if (aAppendString) { - AppendASCIItoUTF16(aAppendString, aOutputString); - } + if (aPrependString) { + AppendASCIItoUTF16(aPrependString, aOutputString); + } + aOutputString.Append(aInputString); + if (aAppendString) { + AppendASCIItoUTF16(aAppendString, aOutputString); } } static -void ProcessLengthValue(const nsAString * aInputString, nsAString & aOutputString, +void ProcessLengthValue(const nsAString & aInputString, nsAString & aOutputString, const char * aDefaultValueString, const char * aPrependString, const char* aAppendString) { aOutputString.Truncate(); - if (aInputString) { - aOutputString.Append(*aInputString); - if (-1 == aOutputString.FindChar(PRUnichar('%'))) { - aOutputString.AppendLiteral("px"); - } + aOutputString.Append(aInputString); + if (-1 == aOutputString.FindChar(PRUnichar('%'))) { + aOutputString.AppendLiteral("px"); } } static -void ProcessListStyleTypeValue(const nsAString * aInputString, nsAString & aOutputString, +void ProcessListStyleTypeValue(const nsAString & aInputString, nsAString & aOutputString, const char * aDefaultValueString, const char * aPrependString, const char* aAppendString) { aOutputString.Truncate(); - if (aInputString) { - if (aInputString->EqualsLiteral("1")) { - aOutputString.AppendLiteral("decimal"); - } - else if (aInputString->EqualsLiteral("a")) { - aOutputString.AppendLiteral("lower-alpha"); - } - else if (aInputString->EqualsLiteral("A")) { - aOutputString.AppendLiteral("upper-alpha"); - } - else if (aInputString->EqualsLiteral("i")) { - aOutputString.AppendLiteral("lower-roman"); - } - else if (aInputString->EqualsLiteral("I")) { - aOutputString.AppendLiteral("upper-roman"); - } - else if (aInputString->EqualsLiteral("square") - || aInputString->EqualsLiteral("circle") - || aInputString->EqualsLiteral("disc")) { - aOutputString.Append(*aInputString); - } + if (aInputString.EqualsLiteral("1")) { + aOutputString.AppendLiteral("decimal"); + } + else if (aInputString.EqualsLiteral("a")) { + aOutputString.AppendLiteral("lower-alpha"); + } + else if (aInputString.EqualsLiteral("A")) { + aOutputString.AppendLiteral("upper-alpha"); + } + else if (aInputString.EqualsLiteral("i")) { + aOutputString.AppendLiteral("lower-roman"); + } + else if (aInputString.EqualsLiteral("I")) { + aOutputString.AppendLiteral("upper-roman"); + } + else if (aInputString.EqualsLiteral("square") + || aInputString.EqualsLiteral("circle") + || aInputString.EqualsLiteral("disc")) { + aOutputString.Append(aInputString); } } static -void ProcessMarginLeftValue(const nsAString * aInputString, nsAString & aOutputString, +void ProcessMarginLeftValue(const nsAString & aInputString, nsAString & aOutputString, const char * aDefaultValueString, const char * aPrependString, const char* aAppendString) { aOutputString.Truncate(); - if (aInputString) { - if (aInputString->EqualsLiteral("center") || - aInputString->EqualsLiteral("-moz-center")) { - aOutputString.AppendLiteral("auto"); - } - else if (aInputString->EqualsLiteral("right") || - aInputString->EqualsLiteral("-moz-right")) { - aOutputString.AppendLiteral("auto"); - } - else { - aOutputString.AppendLiteral("0px"); - } + if (aInputString.EqualsLiteral("center") || + aInputString.EqualsLiteral("-moz-center")) { + aOutputString.AppendLiteral("auto"); + } + else if (aInputString.EqualsLiteral("right") || + aInputString.EqualsLiteral("-moz-right")) { + aOutputString.AppendLiteral("auto"); + } + else { + aOutputString.AppendLiteral("0px"); } } static -void ProcessMarginRightValue(const nsAString * aInputString, nsAString & aOutputString, +void ProcessMarginRightValue(const nsAString & aInputString, nsAString & aOutputString, const char * aDefaultValueString, const char * aPrependString, const char* aAppendString) { aOutputString.Truncate(); - if (aInputString) { - if (aInputString->EqualsLiteral("center") || - aInputString->EqualsLiteral("-moz-center")) { - aOutputString.AppendLiteral("auto"); - } - else if (aInputString->EqualsLiteral("left") || - aInputString->EqualsLiteral("-moz-left")) { - aOutputString.AppendLiteral("auto"); - } - else { - aOutputString.AppendLiteral("0px"); - } + if (aInputString.EqualsLiteral("center") || + aInputString.EqualsLiteral("-moz-center")) { + aOutputString.AppendLiteral("auto"); + } + else if (aInputString.EqualsLiteral("left") || + aInputString.EqualsLiteral("-moz-left")) { + aOutputString.AppendLiteral("auto"); + } + else { + aOutputString.AppendLiteral("0px"); } } @@ -327,7 +313,7 @@ nsHTMLCSSUtils::Init(nsHTMLEditor *aEdit PRBool nsHTMLCSSUtils::IsCSSEditableProperty(nsIDOMNode * aNode, nsIAtom * aProperty, - const nsAString * aAttribute) + const nsAString & aAttribute) { NS_ASSERTION(aNode, "Shouldn't you pass aNode? - Bug 214025"); @@ -349,14 +335,14 @@ nsHTMLCSSUtils::IsCSSEditableProperty(ns || nsEditProperty::tt == aProperty || nsEditProperty::u == aProperty || nsEditProperty::strike == aProperty - || ((nsEditProperty::font == aProperty) && aAttribute && - (aAttribute->EqualsLiteral("color") || - aAttribute->EqualsLiteral("face")))) { + || ((nsEditProperty::font == aProperty) && + (aAttribute.EqualsLiteral("color") || + aAttribute.EqualsLiteral("face")))) { return PR_TRUE; } // ALIGN attribute on elements supporting it - if (aAttribute && (aAttribute->EqualsLiteral("align")) && + if (aAttribute.EqualsLiteral("align") && (nsEditProperty::div == tagName || nsEditProperty::p == tagName || nsEditProperty::h1 == tagName @@ -378,7 +364,7 @@ nsHTMLCSSUtils::IsCSSEditableProperty(ns return PR_TRUE; } - if (aAttribute && (aAttribute->EqualsLiteral("valign")) && + if (aAttribute.EqualsLiteral("valign") && (nsEditProperty::col == tagName || nsEditProperty::colgroup == tagName || nsEditProperty::tbody == tagName @@ -391,59 +377,59 @@ nsHTMLCSSUtils::IsCSSEditableProperty(ns } // attributes TEXT, BACKGROUND and BGCOLOR on BODY - if (aAttribute && (nsEditProperty::body == tagName) && - (aAttribute->EqualsLiteral("text") - || aAttribute->EqualsLiteral("background") - || aAttribute->EqualsLiteral("bgcolor"))) { + if (nsEditProperty::body == tagName && + (aAttribute.EqualsLiteral("text") + || aAttribute.EqualsLiteral("background") + || aAttribute.EqualsLiteral("bgcolor"))) { return PR_TRUE; } // attribute BGCOLOR on other elements - if (aAttribute && aAttribute->EqualsLiteral("bgcolor")) { + if (aAttribute.EqualsLiteral("bgcolor")) { return PR_TRUE; } // attributes HEIGHT, WIDTH and NOWRAP on TD and TH - if (aAttribute && ((nsEditProperty::td == tagName) - || (nsEditProperty::th == tagName)) && - (aAttribute->EqualsLiteral("height") - || aAttribute->EqualsLiteral("width") - || aAttribute->EqualsLiteral("nowrap"))) { + if ((nsEditProperty::td == tagName + || (nsEditProperty::th == tagName)) && + (aAttribute.EqualsLiteral("height") + || aAttribute.EqualsLiteral("width") + || aAttribute.EqualsLiteral("nowrap"))) { return PR_TRUE; } // attributes HEIGHT and WIDTH on TABLE - if (aAttribute && (nsEditProperty::table == tagName) && - (aAttribute->EqualsLiteral("height") - || aAttribute->EqualsLiteral("width"))) { + if (nsEditProperty::table == tagName && + (aAttribute.EqualsLiteral("height") + || aAttribute.EqualsLiteral("width"))) { return PR_TRUE; } // attributes SIZE and WIDTH on HR - if (aAttribute && (nsEditProperty::hr == tagName) && - (aAttribute->EqualsLiteral("size") - || aAttribute->EqualsLiteral("width"))) { + if (nsEditProperty::hr == tagName && + (aAttribute.EqualsLiteral("size") + || aAttribute.EqualsLiteral("width"))) { return PR_TRUE; } // attribute TYPE on OL UL LI - if (aAttribute && (nsEditProperty::ol == tagName - || nsEditProperty::ul == tagName - || nsEditProperty::li == tagName) && - aAttribute->EqualsLiteral("type")) { + if ((nsEditProperty::ol == tagName + || nsEditProperty::ul == tagName + || nsEditProperty::li == tagName) && + aAttribute.EqualsLiteral("type")) { return PR_TRUE; } - if (aAttribute && nsEditProperty::img == tagName && - (aAttribute->EqualsLiteral("border") - || aAttribute->EqualsLiteral("width") - || aAttribute->EqualsLiteral("height"))) { + if (nsEditProperty::img == tagName && + (aAttribute.EqualsLiteral("border") + || aAttribute.EqualsLiteral("width") + || aAttribute.EqualsLiteral("height"))) { return PR_TRUE; } // other elements that we can align using CSS even if they // can't carry the html ALIGN attribute - if (aAttribute && aAttribute->EqualsLiteral("align") && + if (aAttribute.EqualsLiteral("align") && (nsEditProperty::ul == tagName || nsEditProperty::ol == tagName || nsEditProperty::dl == tagName @@ -670,7 +656,7 @@ nsHTMLCSSUtils::RemoveCSSInlineStyle(nsI // Answers true is the property can be removed by setting a "none" CSS value // on a node PRBool -nsHTMLCSSUtils::IsCSSInvertable(nsIAtom *aProperty, const nsAString *aAttribute) +nsHTMLCSSUtils::IsCSSInvertable(nsIAtom *aProperty, const nsAString &aAttribute) { return PRBool(nsEditProperty::b == aProperty); } @@ -852,7 +838,7 @@ void nsHTMLCSSUtils::BuildCSSDeclarations(nsTArray & aPropertyArray, nsTArray & aValueArray, const CSSEquivTable * aEquivTable, - const nsAString * aValue, + const nsAString & aValue, PRBool aGetOrRemoveRequest) { // clear arrays @@ -861,9 +847,9 @@ nsHTMLCSSUtils::BuildCSSDeclarations(nsT // if we have an input value, let's use it nsAutoString value, lowerCasedValue; - if (aValue) { - value.Assign(*aValue); - lowerCasedValue.Assign(*aValue); + if (!aValue.IsEmpty()) { + value.Assign(aValue); + lowerCasedValue.Assign(aValue); ToLowerCase(lowerCasedValue); } @@ -875,7 +861,7 @@ nsHTMLCSSUtils::BuildCSSDeclarations(nsT nsIAtom * cssPropertyAtom; // find the equivalent css value for the index-th property in // the equivalence table - (*aEquivTable[index].processValueFunctor) ((!aGetOrRemoveRequest || aEquivTable[index].caseSensitiveValue) ? &value : &lowerCasedValue, + (*aEquivTable[index].processValueFunctor) ((!aGetOrRemoveRequest || aEquivTable[index].caseSensitiveValue) ? value : lowerCasedValue, cssValue, aEquivTable[index].defaultValue, aEquivTable[index].prependValue, @@ -894,8 +880,8 @@ nsHTMLCSSUtils::BuildCSSDeclarations(nsT void nsHTMLCSSUtils::GenerateCSSDeclarationsFromHTMLStyle(nsIDOMNode * aNode, nsIAtom *aHTMLProperty, - const nsAString * aAttribute, - const nsAString * aValue, + const nsAString & aAttribute, + const nsAString & aValue, nsTArray & cssPropertyArray, nsTArray & cssValueArray, PRBool aGetOrRemoveRequest) @@ -923,28 +909,28 @@ nsHTMLCSSUtils::GenerateCSSDeclarationsF else if (nsEditProperty::tt == aHTMLProperty) { BuildCSSDeclarations(cssPropertyArray, cssValueArray, ttEquivTable, aValue, aGetOrRemoveRequest); } - else if (aAttribute) { + else if (!aAttribute.IsEmpty()) { if (nsEditProperty::font == aHTMLProperty && - aAttribute->EqualsLiteral("color")) { + aAttribute.EqualsLiteral("color")) { BuildCSSDeclarations(cssPropertyArray, cssValueArray, fontColorEquivTable, aValue, aGetOrRemoveRequest); } else if (nsEditProperty::font == aHTMLProperty && - aAttribute->EqualsLiteral("face")) { + aAttribute.EqualsLiteral("face")) { BuildCSSDeclarations(cssPropertyArray, cssValueArray, fontFaceEquivTable, aValue, aGetOrRemoveRequest); } - else if (aAttribute->EqualsLiteral("bgcolor")) { + else if (aAttribute.EqualsLiteral("bgcolor")) { BuildCSSDeclarations(cssPropertyArray, cssValueArray, bgcolorEquivTable, aValue, aGetOrRemoveRequest); } - else if (aAttribute->EqualsLiteral("background")) { + else if (aAttribute.EqualsLiteral("background")) { BuildCSSDeclarations(cssPropertyArray, cssValueArray, backgroundImageEquivTable, aValue, aGetOrRemoveRequest); } - else if (aAttribute->EqualsLiteral("text")) { + else if (aAttribute.EqualsLiteral("text")) { BuildCSSDeclarations(cssPropertyArray, cssValueArray, textColorEquivTable, aValue, aGetOrRemoveRequest); } - else if (aAttribute->EqualsLiteral("border")) { + else if (aAttribute.EqualsLiteral("border")) { BuildCSSDeclarations(cssPropertyArray, cssValueArray, borderEquivTable, aValue, aGetOrRemoveRequest); } - else if (aAttribute->EqualsLiteral("align")) { + else if (aAttribute.EqualsLiteral("align")) { if (nsEditProperty::table == tagName) { BuildCSSDeclarations(cssPropertyArray, cssValueArray, tableAlignEquivTable, aValue, aGetOrRemoveRequest); } @@ -959,20 +945,20 @@ nsHTMLCSSUtils::GenerateCSSDeclarationsF BuildCSSDeclarations(cssPropertyArray, cssValueArray, textAlignEquivTable, aValue, aGetOrRemoveRequest); } } - else if (aAttribute->EqualsLiteral("valign")) { + else if (aAttribute.EqualsLiteral("valign")) { BuildCSSDeclarations(cssPropertyArray, cssValueArray, verticalAlignEquivTable, aValue, aGetOrRemoveRequest); } - else if (aAttribute->EqualsLiteral("nowrap")) { + else if (aAttribute.EqualsLiteral("nowrap")) { BuildCSSDeclarations(cssPropertyArray, cssValueArray, nowrapEquivTable, aValue, aGetOrRemoveRequest); } - else if (aAttribute->EqualsLiteral("width")) { + else if (aAttribute.EqualsLiteral("width")) { BuildCSSDeclarations(cssPropertyArray, cssValueArray, widthEquivTable, aValue, aGetOrRemoveRequest); } - else if (aAttribute->EqualsLiteral("height") || - (nsEditProperty::hr == tagName && aAttribute->EqualsLiteral("size"))) { + else if (aAttribute.EqualsLiteral("height") || + (nsEditProperty::hr == tagName && aAttribute.EqualsLiteral("size"))) { BuildCSSDeclarations(cssPropertyArray, cssValueArray, heightEquivTable, aValue, aGetOrRemoveRequest); } - else if (aAttribute->EqualsLiteral("type") && + else if (aAttribute.EqualsLiteral("type") && (nsEditProperty::ol == tagName || nsEditProperty::ul == tagName || nsEditProperty::li == tagName)) { @@ -986,8 +972,8 @@ nsHTMLCSSUtils::GenerateCSSDeclarationsF nsresult nsHTMLCSSUtils::SetCSSEquivalentToHTMLStyle(nsIDOMNode * aNode, nsIAtom *aHTMLProperty, - const nsAString *aAttribute, - const nsAString *aValue, + const nsAString &aAttribute, + const nsAString &aValue, PRInt32 * aCount, PRBool aSuppressTransaction) { @@ -1021,8 +1007,8 @@ nsHTMLCSSUtils::SetCSSEquivalentToHTMLSt nsresult nsHTMLCSSUtils::RemoveCSSEquivalentToHTMLStyle(nsIDOMNode * aNode, nsIAtom *aHTMLProperty, - const nsAString *aAttribute, - const nsAString *aValue, + const nsAString &aAttribute, + const nsAString &aValue, PRBool aSuppressTransaction) { nsCOMPtr theElement = do_QueryInterface(aNode); @@ -1079,7 +1065,7 @@ nsHTMLCSSUtils::HasClassOrID(nsIDOMEleme nsresult nsHTMLCSSUtils::GetCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode * aNode, nsIAtom *aHTMLProperty, - const nsAString *aAttribute, + const nsAString &aAttribute, nsAString & aValueString, PRUint8 aStyleType) { @@ -1100,7 +1086,7 @@ nsHTMLCSSUtils::GetCSSEquivalentToHTMLIn nsTArray cssValueArray; // get the CSS equivalence with last param PR_TRUE indicating we want only the // "gettable" properties - GenerateCSSDeclarationsFromHTMLStyle(theElement, aHTMLProperty, aAttribute, nsnull, + GenerateCSSDeclarationsFromHTMLStyle(theElement, aHTMLProperty, aAttribute, EmptyString(), cssPropertyArray, cssValueArray, PR_TRUE); PRInt32 count = cssPropertyArray.Length(); PRInt32 index; @@ -1126,7 +1112,7 @@ nsHTMLCSSUtils::GetCSSEquivalentToHTMLIn nsresult nsHTMLCSSUtils::IsCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode * aNode, nsIAtom *aHTMLProperty, - const nsAString * aHTMLAttribute, + const nsAString & aHTMLAttribute, PRBool & aIsSet, nsAString & valueString, PRUint8 aStyleType) @@ -1193,10 +1179,9 @@ nsHTMLCSSUtils::IsCSSEquivalentToHTMLInl aIsSet = PRBool(ChangeCSSInlineStyleTxn::ValueIncludes(valueString, val, PR_FALSE)); } - else if (aHTMLAttribute && - ( (nsEditProperty::font == aHTMLProperty && - aHTMLAttribute->EqualsLiteral("color")) || - aHTMLAttribute->EqualsLiteral("bgcolor"))) { + else if ((nsEditProperty::font == aHTMLProperty && + aHTMLAttribute.EqualsLiteral("color")) || + aHTMLAttribute.EqualsLiteral("bgcolor")) { if (htmlValueString.IsEmpty()) aIsSet = PR_TRUE; else { @@ -1235,8 +1220,8 @@ nsHTMLCSSUtils::IsCSSEquivalentToHTMLInl aIsSet = StringBeginsWith(valueString, NS_LITERAL_STRING("monospace")); } - else if ((nsEditProperty::font == aHTMLProperty) && aHTMLAttribute - && aHTMLAttribute->EqualsLiteral("face")) { + else if ((nsEditProperty::font == aHTMLProperty) + && aHTMLAttribute.EqualsLiteral("face")) { if (!htmlValueString.IsEmpty()) { const PRUnichar commaSpace[] = { PRUnichar(','), PRUnichar(' '), 0 }; const PRUnichar comma[] = { PRUnichar(','), 0 }; @@ -1255,8 +1240,7 @@ nsHTMLCSSUtils::IsCSSEquivalentToHTMLInl } return NS_OK; } - else if (aHTMLAttribute - && aHTMLAttribute->EqualsLiteral("align")) { + else if (aHTMLAttribute.EqualsLiteral("align")) { aIsSet = PR_TRUE; } else { diff --git a/editor/libeditor/html/nsHTMLCSSUtils.h b/editor/libeditor/html/nsHTMLCSSUtils.h --- a/editor/libeditor/html/nsHTMLCSSUtils.h +++ b/editor/libeditor/html/nsHTMLCSSUtils.h @@ -55,7 +55,7 @@ class nsHTMLEditor; -typedef void (*nsProcessValueFunc)(const nsAString * aInputString, nsAString & aOutputString, +typedef void (*nsProcessValueFunc)(const nsAString & aInputString, nsAString & aOutputString, const char * aDefaultValueString, const char * aPrependString, const char* aAppendString); @@ -110,7 +110,7 @@ public: * @param aProperty [IN] an atom containing a HTML tag name * @param aAttribute [IN] a string containing the name of a HTML attribute carried by the element above */ - PRBool IsCSSEditableProperty(nsIDOMNode * aNode, nsIAtom * aProperty, const nsAString * aAttribute); + PRBool IsCSSEditableProperty(nsIDOMNode * aNode, nsIAtom * aProperty, const nsAString & aAttribute); /** adds/remove a CSS declaration to the STYLE atrribute carried by a given element * @@ -173,7 +173,7 @@ public: * @param aProperty [IN] an atom containing a CSS property * @param aAttribute [IN] pointer to an attribute name or null if this information is irrelevant */ - PRBool IsCSSInvertable(nsIAtom * aProperty, const nsAString * aAttribute); + PRBool IsCSSInvertable(nsIAtom * aProperty, const nsAString & aAttribute); /** Get the default browser background color if we need it for GetCSSBackgroundColorState * @@ -206,7 +206,7 @@ public: */ nsresult GetCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode * aNode, nsIAtom * aHTMLProperty, - const nsAString * aAttribute, + const nsAString & aAttribute, nsAString & aValueString, PRUint8 aStyleType); @@ -223,7 +223,7 @@ public: */ nsresult IsCSSEquivalentToHTMLInlineStyleSet(nsIDOMNode * aNode, nsIAtom * aHTMLProperty, - const nsAString * aAttribute, + const nsAString & aAttribute, PRBool & aIsSet, nsAString & aValueString, PRUint8 aStyleType); @@ -241,8 +241,8 @@ public: */ nsresult SetCSSEquivalentToHTMLStyle(nsIDOMNode * aNode, nsIAtom * aHTMLProperty, - const nsAString * aAttribute, - const nsAString * aValue, + const nsAString & aAttribute, + const nsAString & aValue, PRInt32 * aCount, PRBool aSuppressTransaction); @@ -257,8 +257,8 @@ public: */ nsresult RemoveCSSEquivalentToHTMLStyle(nsIDOMNode * aNode, nsIAtom *aHTMLProperty, - const nsAString *aAttribute, - const nsAString *aValue, + const nsAString &aAttribute, + const nsAString &aValue, PRBool aSuppressTransaction); /** parses a "xxxx.xxxxxuuu" string where x is a digit and u an alpha char @@ -344,7 +344,7 @@ private: void BuildCSSDeclarations(nsTArray & aPropertyArray, nsTArray & cssValueArray, const CSSEquivTable * aEquivTable, - const nsAString * aValue, + const nsAString & aValue, PRBool aGetOrRemoveRequest); /** retrieves the CSS declarations equivalent to the given HTML property/attribute/value @@ -362,8 +362,8 @@ private: */ void GenerateCSSDeclarationsFromHTMLStyle(nsIDOMNode * aNode, nsIAtom * aHTMLProperty, - const nsAString *aAttribute, - const nsAString *aValue, + const nsAString &aAttribute, + const nsAString &aValue, nsTArray & aPropertyArray, nsTArray & aValueArray, PRBool aGetOrRemoveRequest); diff --git a/editor/libeditor/html/nsHTMLEditRules.cpp b/editor/libeditor/html/nsHTMLEditRules.cpp --- a/editor/libeditor/html/nsHTMLEditRules.cpp +++ b/editor/libeditor/html/nsHTMLEditRules.cpp @@ -665,7 +665,7 @@ nsHTMLEditRules::WillDoAction(nsISelecti case kDeleteSelection: return WillDeleteSelection(aSelection, info->collapsedAction, aCancel, aHandled); case kMakeList: - return WillMakeList(aSelection, info->blockType, info->entireList, info->bulletType, aCancel, aHandled); + return WillMakeList(aSelection, info->blockType, info->entireList, info->bulletType, aCancel, aHandled, EmptyString()); case kIndent: return WillIndent(aSelection, aCancel, aHandled); case kOutdent: @@ -918,14 +918,14 @@ nsHTMLEditRules::GetAlignment(PRBool *aM { nsCOMPtr blockParentContent = do_QueryInterface(blockParent); if (blockParentContent && - mHTMLEditor->mHTMLCSSUtils->IsCSSEditableProperty(blockParent, dummyProperty, &typeAttrName)) + mHTMLEditor->mHTMLCSSUtils->IsCSSEditableProperty(blockParent, dummyProperty, typeAttrName)) { // we are in CSS mode and we know how to align this element with CSS nsAutoString value; // let's get the value(s) of text-align or margin-left/margin-right mHTMLEditor->mHTMLCSSUtils->GetCSSEquivalentToHTMLInlineStyleSet(blockParent, dummyProperty, - &typeAttrName, + typeAttrName, value, COMPUTED_STYLE_TYPE); if (value.EqualsLiteral("center") || @@ -1346,15 +1346,15 @@ nsHTMLEditRules::WillInsertText(PRInt32 nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled, - const nsAString *inString, - nsAString *outString, + const nsAString &inString, + nsAString &outString, PRInt32 aMaxLength) { if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; } - if (inString->IsEmpty() && (aAction != kInsertTextIME)) + if (inString.IsEmpty() && (aAction != kInsertTextIME)) { // HACK: this is a fix for bug 19395 // I can't outlaw all empty insertions @@ -1410,14 +1410,14 @@ nsHTMLEditRules::WillInsertText(PRInt32 { // Right now the nsWSRunObject code bails on empty strings, but IME needs // the InsertTextImpl() call to still happen since empty strings are meaningful there. - if (inString->IsEmpty()) - { - res = mHTMLEditor->InsertTextImpl(*inString, address_of(selNode), &selOffset, doc); + if (inString.IsEmpty()) + { + res = mHTMLEditor->InsertTextImpl(inString, address_of(selNode), &selOffset, doc); } else { nsWSRunObject wsObj(mHTMLEditor, selNode, selOffset); - res = wsObj.InsertText(*inString, address_of(selNode), &selOffset, doc); + res = wsObj.InsertText(inString, address_of(selNode), &selOffset, doc); } if (NS_FAILED(res)) return res; } @@ -1441,7 +1441,7 @@ nsHTMLEditRules::WillInsertText(PRInt32 // don't spaz my selection in subtransactions nsAutoTxnsConserveSelection dontSpazMySelection(mHTMLEditor); - nsAutoString tString(*inString); + nsAutoString tString(inString); const PRUnichar *unicodeBuf = tString.get(); nsCOMPtr unused; PRInt32 pos = 0; @@ -1452,7 +1452,7 @@ nsHTMLEditRules::WillInsertText(PRInt32 // it is to search for both tabs and newlines. if (isPRE || bPlaintext) { - while (unicodeBuf && (pos != -1) && (pos < (PRInt32)(*inString).Length())) + while (unicodeBuf && (pos != -1) && (pos < (PRInt32)inString.Length())) { PRInt32 oldPos = pos; PRInt32 subStrLen; @@ -1491,7 +1491,7 @@ nsHTMLEditRules::WillInsertText(PRInt32 NS_NAMED_LITERAL_STRING(tabStr, "\t"); NS_NAMED_LITERAL_STRING(spacesStr, " "); char specialChars[] = {TAB, nsCRT::LF, 0}; - while (unicodeBuf && (pos != -1) && (pos < (PRInt32)inString->Length())) + while (unicodeBuf && (pos != -1) && (pos < (PRInt32)inString.Length())) { PRInt32 oldPos = pos; PRInt32 subStrLen; @@ -3005,14 +3005,14 @@ nsHTMLEditRules::DidDeleteSelection(nsIS nsresult nsHTMLEditRules::WillMakeList(nsISelection *aSelection, - const nsAString *aListType, + const nsAString &aListType, PRBool aEntireList, - const nsAString *aBulletType, + const nsAString &aBulletType, PRBool *aCancel, PRBool *aHandled, - const nsAString *aItemType) -{ - if (!aSelection || !aListType || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; } + const nsAString &aItemType) +{ + if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; } nsresult res = WillInsert(aSelection, aCancel); if (NS_FAILED(res)) return res; @@ -3024,9 +3024,9 @@ nsHTMLEditRules::WillMakeList(nsISelecti // deduce what tag to use for list items nsAutoString itemType; - if (aItemType) - itemType = *aItemType; - else if (aListType->LowerCaseEqualsLiteral("dl")) + if (!aItemType.IsEmpty()) + itemType = aItemType; + else if (aListType.LowerCaseEqualsLiteral("dl")) itemType.AssignLiteral("dd"); else itemType.AssignLiteral("li"); @@ -3085,7 +3085,7 @@ nsHTMLEditRules::WillMakeList(nsISelecti // make sure we can put a list here res = SplitAsNeeded(aListType, address_of(parent), &offset); if (NS_FAILED(res)) return res; - res = mHTMLEditor->CreateNode(*aListType, parent, offset, getter_AddRefs(theList)); + res = mHTMLEditor->CreateNode(aListType, parent, offset, getter_AddRefs(theList)); if (NS_FAILED(res)) return res; res = mHTMLEditor->CreateNode(itemType, theList, 0, getter_AddRefs(theListItem)); if (NS_FAILED(res)) return res; @@ -3164,7 +3164,7 @@ nsHTMLEditRules::WillMakeList(nsISelecti // handles converting the list item types, if needed res = mHTMLEditor->MoveNode(curNode, curList, -1); if (NS_FAILED(res)) return res; - res = ConvertListType(curNode, address_of(newBlock), *aListType, itemType); + res = ConvertListType(curNode, address_of(newBlock), aListType, itemType); if (NS_FAILED(res)) return res; res = mHTMLEditor->RemoveBlockContainer(newBlock); if (NS_FAILED(res)) return res; @@ -3172,7 +3172,7 @@ nsHTMLEditRules::WillMakeList(nsISelecti else { // replace list with new list type - res = ConvertListType(curNode, address_of(newBlock), *aListType, itemType); + res = ConvertListType(curNode, address_of(newBlock), aListType, itemType); if (NS_FAILED(res)) return res; curList = newBlock; } @@ -3185,7 +3185,7 @@ nsHTMLEditRules::WillMakeList(nsISelecti nsAutoString existingListStr; res = mHTMLEditor->GetTagString(curParent, existingListStr); ToLowerCase(existingListStr); - if ( existingListStr != *aListType ) + if ( existingListStr != aListType ) { // list item is in wrong type of list. // if we don't have a curList, split the old list @@ -3198,7 +3198,7 @@ nsHTMLEditRules::WillMakeList(nsISelecti PRInt32 o; res = nsEditor::GetNodeLocation(curParent, address_of(p), &o); if (NS_FAILED(res)) return res; - res = mHTMLEditor->CreateNode(*aListType, p, o, getter_AddRefs(curList)); + res = mHTMLEditor->CreateNode(aListType, p, o, getter_AddRefs(curList)); if (NS_FAILED(res)) return res; } // move list item to new list @@ -3207,7 +3207,7 @@ nsHTMLEditRules::WillMakeList(nsISelecti // convert list item type if needed if (!mHTMLEditor->NodeIsTypeString(curNode,itemType)) { - res = mHTMLEditor->ReplaceContainer(curNode, address_of(newBlock), itemType); + res = mHTMLEditor->ReplaceContainer(curNode, address_of(newBlock), itemType, EmptyString(), EmptyString()); if (NS_FAILED(res)) return res; } } @@ -3228,14 +3228,14 @@ nsHTMLEditRules::WillMakeList(nsISelecti } if (!mHTMLEditor->NodeIsTypeString(curNode,itemType)) { - res = mHTMLEditor->ReplaceContainer(curNode, address_of(newBlock), itemType); + res = mHTMLEditor->ReplaceContainer(curNode, address_of(newBlock), itemType, EmptyString(), EmptyString()); if (NS_FAILED(res)) return res; } } nsCOMPtr curElement = do_QueryInterface(curNode); NS_NAMED_LITERAL_STRING(typestr, "type"); - if (aBulletType && !aBulletType->IsEmpty()) { - res = mHTMLEditor->SetAttribute(curElement, typestr, *aBulletType); + if (!aBulletType.IsEmpty()) { + res = mHTMLEditor->SetAttribute(curElement, typestr, aBulletType); } else { res = mHTMLEditor->RemoveAttribute(curElement, typestr); @@ -3263,7 +3263,7 @@ nsHTMLEditRules::WillMakeList(nsISelecti { res = SplitAsNeeded(aListType, address_of(curParent), &offset); if (NS_FAILED(res)) return res; - res = mHTMLEditor->CreateNode(*aListType, curParent, offset, getter_AddRefs(curList)); + res = mHTMLEditor->CreateNode(aListType, curParent, offset, getter_AddRefs(curList)); if (NS_FAILED(res)) return res; // remember our new block for postprocessing mNewBlock = curList; @@ -3287,11 +3287,11 @@ nsHTMLEditRules::WillMakeList(nsISelecti // don't wrap li around a paragraph. instead replace paragraph with li if (nsHTMLEditUtils::IsParagraph(curNode)) { - res = mHTMLEditor->ReplaceContainer(curNode, address_of(listItem), itemType); - } - else - { - res = mHTMLEditor->InsertContainerAbove(curNode, address_of(listItem), itemType); + res = mHTMLEditor->ReplaceContainer(curNode, address_of(listItem), itemType, EmptyString(), EmptyString()); + } + else + { + res = mHTMLEditor->InsertContainerAbove(curNode, address_of(listItem), itemType, EmptyString(), EmptyString()); } if (NS_FAILED(res)) return res; if (IsInlineNode(curNode)) @@ -3387,19 +3387,19 @@ nsHTMLEditRules::WillRemoveList(nsISelec nsresult nsHTMLEditRules::WillMakeDefListItem(nsISelection *aSelection, - const nsAString *aItemType, + const nsAString &aItemType, PRBool aEntireList, PRBool *aCancel, PRBool *aHandled) { // for now we let WillMakeList handle this NS_NAMED_LITERAL_STRING(listType, "dl"); - return WillMakeList(aSelection, &listType, aEntireList, nsnull, aCancel, aHandled, aItemType); + return WillMakeList(aSelection, listType, aEntireList, EmptyString(), aCancel, aHandled, aItemType); } nsresult nsHTMLEditRules::WillMakeBasicBlock(nsISelection *aSelection, - const nsAString *aBlockType, + const nsAString &aBlockType, PRBool *aCancel, PRBool *aHandled) { @@ -3418,7 +3418,7 @@ nsHTMLEditRules::WillMakeBasicBlock(nsIS nsAutoSelectionReset selectionResetter(aSelection, mHTMLEditor); nsAutoTxnsConserveSelection dontSpazMySelection(mHTMLEditor); *aHandled = PR_TRUE; - nsString tString(*aBlockType); + nsString tString(aBlockType); // contruct a list of nodes to act on. nsCOMArray arrayOfNodes; @@ -3498,7 +3498,7 @@ nsHTMLEditRules::WillMakeBasicBlock(nsIS // make sure we can put a block here res = SplitAsNeeded(aBlockType, address_of(parent), &offset); if (NS_FAILED(res)) return res; - res = mHTMLEditor->CreateNode(*aBlockType, parent, offset, getter_AddRefs(theBlock)); + res = mHTMLEditor->CreateNode(aBlockType, parent, offset, getter_AddRefs(theBlock)); if (NS_FAILED(res)) return res; // remember our new block for postprocessing mNewBlock = theBlock; @@ -3635,7 +3635,7 @@ nsHTMLEditRules::WillCSSIndent(nsISelect res = mHTMLEditor->GetStartNodeAndOffset(aSelection, address_of(parent), &offset); if (NS_FAILED(res)) return res; // make sure we can put a block here - res = SplitAsNeeded("eType, address_of(parent), &offset); + res = SplitAsNeeded(quoteType, address_of(parent), &offset); if (NS_FAILED(res)) return res; res = mHTMLEditor->CreateNode(quoteType, parent, offset, getter_AddRefs(theBlock)); if (NS_FAILED(res)) return res; @@ -3728,7 +3728,7 @@ nsHTMLEditRules::WillCSSIndent(nsISelect nsEditor::GetTagString(curParent,listTag); ToLowerCase(listTag); // create a new nested list of correct type - res = SplitAsNeeded(&listTag, address_of(curParent), &offset); + res = SplitAsNeeded(listTag, address_of(curParent), &offset); if (NS_FAILED(res)) return res; res = mHTMLEditor->CreateNode(listTag, curParent, offset, getter_AddRefs(curList)); if (NS_FAILED(res)) return res; @@ -3754,7 +3754,7 @@ nsHTMLEditRules::WillCSSIndent(nsISelect if (!curQuote) { NS_NAMED_LITERAL_STRING(divquoteType, "div"); - res = SplitAsNeeded(&divquoteType, address_of(curParent), &offset); + res = SplitAsNeeded(divquoteType, address_of(curParent), &offset); if (NS_FAILED(res)) return res; res = mHTMLEditor->CreateNode(divquoteType, curParent, offset, getter_AddRefs(curQuote)); if (NS_FAILED(res)) return res; @@ -3818,7 +3818,7 @@ nsHTMLEditRules::WillHTMLIndent(nsISelec res = mHTMLEditor->GetStartNodeAndOffset(aSelection, address_of(parent), &offset); if (NS_FAILED(res)) return res; // make sure we can put a block here - res = SplitAsNeeded("eType, address_of(parent), &offset); + res = SplitAsNeeded(quoteType, address_of(parent), &offset); if (NS_FAILED(res)) return res; res = mHTMLEditor->CreateNode(quoteType, parent, offset, getter_AddRefs(theBlock)); if (NS_FAILED(res)) return res; @@ -3909,7 +3909,7 @@ nsHTMLEditRules::WillHTMLIndent(nsISelec nsEditor::GetTagString(curParent,listTag); ToLowerCase(listTag); // create a new nested list of correct type - res = SplitAsNeeded(&listTag, address_of(curParent), &offset); + res = SplitAsNeeded(listTag, address_of(curParent), &offset); if (NS_FAILED(res)) return res; res = mHTMLEditor->CreateNode(listTag, curParent, offset, getter_AddRefs(curList)); if (NS_FAILED(res)) return res; @@ -3952,7 +3952,7 @@ nsHTMLEditRules::WillHTMLIndent(nsISelec nsEditor::GetTagString(curParent,listTag); ToLowerCase(listTag); // create a new nested list of correct type - res = SplitAsNeeded(&listTag, address_of(curParent), &offset); + res = SplitAsNeeded(listTag, address_of(curParent), &offset); if (NS_FAILED(res)) return res; res = mHTMLEditor->CreateNode(listTag, curParent, offset, getter_AddRefs(curList)); if (NS_FAILED(res)) return res; @@ -3980,7 +3980,7 @@ nsHTMLEditRules::WillHTMLIndent(nsISelec if (!curQuote) { - res = SplitAsNeeded("eType, address_of(curParent), &offset); + res = SplitAsNeeded(quoteType, address_of(curParent), &offset); if (NS_FAILED(res)) return res; res = mHTMLEditor->CreateNode(quoteType, curParent, offset, getter_AddRefs(curQuote)); if (NS_FAILED(res)) return res; @@ -4358,7 +4358,7 @@ nsHTMLEditRules::ConvertListType(nsIDOMN { if (nsHTMLEditUtils::IsListItem(child) && !nsEditor::NodeIsTypeString(child, aItemType)) { - res = mHTMLEditor->ReplaceContainer(child, address_of(temp), aItemType); + res = mHTMLEditor->ReplaceContainer(child, address_of(temp), aItemType, EmptyString(), EmptyString()); if (NS_FAILED(res)) return res; child = temp; } @@ -4373,7 +4373,7 @@ nsHTMLEditRules::ConvertListType(nsIDOMN } if (!nsEditor::NodeIsTypeString(aList, aListType)) { - res = mHTMLEditor->ReplaceContainer(aList, outList, aListType); + res = mHTMLEditor->ReplaceContainer(aList, outList, aListType, EmptyString(), EmptyString()); } return res; } @@ -4429,7 +4429,7 @@ nsHTMLEditRules::CreateStyleForInsertTex // difference between unset and explicitly cleared, else user would never be able to // unbold, for instance. nsAutoString curValue; - res = mHTMLEditor->GetInlinePropertyBase(propItem->tag, &(propItem->attr), nsnull, + res = mHTMLEditor->GetInlinePropertyBase(propItem->tag, propItem->attr, EmptyString(), &bFirst, &bAny, &bAll, &curValue, PR_FALSE); NS_ENSURE_SUCCESS(res, res); @@ -4444,7 +4444,7 @@ nsHTMLEditRules::CreateStyleForInsertTex while (item) { nsCOMPtr leftNode, rightNode, secondSplitParent, newSelParent, savedBR; - res = mHTMLEditor->SplitStyleAbovePoint(address_of(node), &offset, item->tag, &item->attr, address_of(leftNode), address_of(rightNode)); + res = mHTMLEditor->SplitStyleAbovePoint(address_of(node), &offset, item->tag, item->attr, address_of(leftNode), address_of(rightNode)); NS_ENSURE_SUCCESS(res, res); PRBool bIsEmptyNode; if (leftNode) @@ -4471,7 +4471,7 @@ nsHTMLEditRules::CreateStyleForInsertTex secondSplitParent = tmp; } offset = 0; - res = mHTMLEditor->SplitStyleAbovePoint(address_of(secondSplitParent), &offset, item->tag, &(item->attr), address_of(leftNode), address_of(rightNode)); + res = mHTMLEditor->SplitStyleAbovePoint(address_of(secondSplitParent), &offset, item->tag, item->attr, address_of(leftNode), address_of(rightNode)); NS_ENSURE_SUCCESS(res, res); // should be impossible to not get a new leftnode here if (!leftNode) return NS_ERROR_FAILURE; @@ -4499,7 +4499,7 @@ nsHTMLEditRules::CreateStyleForInsertTex // RemoveStyleInside(). RemoveStyleInside() could remove any and all of those nodes, // so I have to use the range tracking system to find the right spot to put selection. nsAutoTrackDOMPoint tracker(mHTMLEditor->mRangeUpdater, address_of(newSelParent), &newSelOffset); - res = mHTMLEditor->RemoveStyleInside(leftNode, item->tag, &(item->attr)); + res = mHTMLEditor->RemoveStyleInside(leftNode, item->tag, item->attr); NS_ENSURE_SUCCESS(res, res); } // reset our node offset values to the resulting new sel point @@ -4555,7 +4555,7 @@ nsHTMLEditRules::CreateStyleForInsertTex while (item) { - res = mHTMLEditor->SetInlinePropertyOnNode(node, item->tag, &item->attr, &item->value); + res = mHTMLEditor->SetInlinePropertyOnNode(node, item->tag, item->attr, item->value); NS_ENSURE_SUCCESS(res, res); mHTMLEditor->mTypeInState->TakeSetProperty(getter_Transfers(item)); } @@ -4595,7 +4595,7 @@ nsHTMLEditRules::IsEmptyBlock(nsIDOMNode nsresult nsHTMLEditRules::WillAlign(nsISelection *aSelection, - const nsAString *alignType, + const nsAString &alignType, PRBool *aCancel, PRBool *aHandled) { @@ -4673,7 +4673,7 @@ nsHTMLEditRules::WillAlign(nsISelection NS_NAMED_LITERAL_STRING(divType, "div"); res = mHTMLEditor->GetStartNodeAndOffset(aSelection, address_of(parent), &offset); if (NS_FAILED(res)) return res; - res = SplitAsNeeded(&divType, address_of(parent), &offset); + res = SplitAsNeeded(divType, address_of(parent), &offset); if (NS_FAILED(res)) return res; // consume a trailing br, if any. This is to keep an alignment from // creating extra lines, if possible. @@ -4759,14 +4759,14 @@ nsHTMLEditRules::WillAlign(nsISelection if ( nsHTMLEditUtils::IsListItem(curNode) || nsHTMLEditUtils::IsList(curNode)) { - res = RemoveAlignment(curNode, *alignType, PR_TRUE); + res = RemoveAlignment(curNode, alignType, PR_TRUE); if (NS_FAILED(res)) return res; if (useCSS) { nsCOMPtr curElem = do_QueryInterface(curNode); NS_NAMED_LITERAL_STRING(attrName, "align"); PRInt32 count; mHTMLEditor->mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(curNode, nsnull, - &attrName, alignType, + attrName, alignType, &count, PR_FALSE); curDiv = 0; continue; @@ -4787,7 +4787,7 @@ nsHTMLEditRules::WillAlign(nsISelection if (!curDiv || transitionList[i]) { NS_NAMED_LITERAL_STRING(divType, "div"); - res = SplitAsNeeded(&divType, address_of(curParent), &offset); + res = SplitAsNeeded(divType, address_of(curParent), &offset); if (NS_FAILED(res)) return res; res = mHTMLEditor->CreateNode(divType, curParent, offset, getter_AddRefs(curDiv)); if (NS_FAILED(res)) return res; @@ -4797,7 +4797,7 @@ nsHTMLEditRules::WillAlign(nsISelection nsCOMPtr divElem = do_QueryInterface(curDiv); res = AlignBlock(divElem, alignType, PR_TRUE); // nsAutoString attr(NS_LITERAL_STRING("align")); -// res = mHTMLEditor->SetAttribute(divElem, attr, *alignType); +// res = mHTMLEditor->SetAttribute(divElem, attr, alignType); // if (NS_FAILED(res)) return res; // curDiv is now the correct thing to put curNode in } @@ -4815,9 +4815,9 @@ nsHTMLEditRules::WillAlign(nsISelection // AlignInnerBlocks: align inside table cells or list items // nsresult -nsHTMLEditRules::AlignInnerBlocks(nsIDOMNode *aNode, const nsAString *alignType) -{ - if (!aNode || !alignType) return NS_ERROR_NULL_POINTER; +nsHTMLEditRules::AlignInnerBlocks(nsIDOMNode *aNode, const nsAString &alignType) +{ + if (!aNode) return NS_ERROR_NULL_POINTER; nsresult res; // gather list of table cells or list items @@ -4849,9 +4849,9 @@ nsHTMLEditRules::AlignInnerBlocks(nsIDOM // AlignBlockContents: align contents of a block element // nsresult -nsHTMLEditRules::AlignBlockContents(nsIDOMNode *aNode, const nsAString *alignType) -{ - if (!aNode || !alignType) return NS_ERROR_NULL_POINTER; +nsHTMLEditRules::AlignBlockContents(nsIDOMNode *aNode, const nsAString &alignType) +{ + if (!aNode) return NS_ERROR_NULL_POINTER; nsresult res; nsCOMPtr firstChild, lastChild, divNode; @@ -4873,10 +4873,10 @@ nsHTMLEditRules::AlignBlockContents(nsID // act on this div. nsCOMPtr divElem = do_QueryInterface(firstChild); if (useCSS) { - res = mHTMLEditor->SetAttributeOrEquivalent(divElem, attr, *alignType, PR_FALSE); + res = mHTMLEditor->SetAttributeOrEquivalent(divElem, attr, alignType, PR_FALSE); } else { - res = mHTMLEditor->SetAttribute(divElem, attr, *alignType); + res = mHTMLEditor->SetAttribute(divElem, attr, alignType); } if (NS_FAILED(res)) return res; } @@ -4888,10 +4888,10 @@ nsHTMLEditRules::AlignBlockContents(nsID // set up the alignment on the div nsCOMPtr divElem = do_QueryInterface(divNode); if (useCSS) { - res = mHTMLEditor->SetAttributeOrEquivalent(divElem, attr, *alignType, PR_FALSE); + res = mHTMLEditor->SetAttributeOrEquivalent(divElem, attr, alignType, PR_FALSE); } else { - res = mHTMLEditor->SetAttribute(divElem, attr, *alignType); + res = mHTMLEditor->SetAttribute(divElem, attr, alignType); } if (NS_FAILED(res)) return res; // tuck the children into the end of the active div @@ -6910,7 +6910,7 @@ nsHTMLEditRules::MakeBlockquote(nsCOMArr if (!curBlock) { NS_NAMED_LITERAL_STRING(quoteType, "blockquote"); - res = SplitAsNeeded("eType, address_of(curParent), &offset); + res = SplitAsNeeded(quoteType, address_of(curParent), &offset); if (NS_FAILED(res)) return res; res = mHTMLEditor->CreateNode(quoteType, curParent, offset, getter_AddRefs(curBlock)); if (NS_FAILED(res)) return res; @@ -7048,19 +7048,18 @@ nsHTMLEditRules::RemoveBlockStyle(nsCOMA // one or more blocks of type blockTag. // nsresult -nsHTMLEditRules::ApplyBlockStyle(nsCOMArray& arrayOfNodes, const nsAString *aBlockTag) +nsHTMLEditRules::ApplyBlockStyle(nsCOMArray& arrayOfNodes, const nsAString &aBlockTag) { // intent of this routine is to be used for converting to/from // headers, paragraphs, pre, and address. Those blocks // that pretty much just contain inline things... - - if (!aBlockTag) return NS_ERROR_NULL_POINTER; + nsresult res = NS_OK; nsCOMPtr curNode, curParent, curBlock, newBlock; PRInt32 offset; PRInt32 listCount = arrayOfNodes.Count(); - nsString tString(*aBlockTag);////MJUDGE SCC NEED HELP + nsString tString(aBlockTag);////MJUDGE SCC NEED HELP // Remove all non-editable nodes. Leave them be. PRInt32 j; @@ -7087,7 +7086,7 @@ nsHTMLEditRules::ApplyBlockStyle(nsCOMAr ToLowerCase(curNodeTag); // is it already the right kind of block? - if (curNodeTag == *aBlockTag) + if (curNodeTag == aBlockTag) { curBlock = 0; // forget any previous block used for previous inline nodes continue; // do nothing to this block @@ -7100,8 +7099,8 @@ nsHTMLEditRules::ApplyBlockStyle(nsCOMAr nsHTMLEditUtils::IsFormatNode(curNode)) { curBlock = 0; // forget any previous block used for previous inline nodes - res = mHTMLEditor->ReplaceContainer(curNode, address_of(newBlock), *aBlockTag, - nsnull, nsnull, PR_TRUE); + res = mHTMLEditor->ReplaceContainer(curNode, address_of(newBlock), aBlockTag, + EmptyString(), EmptyString(), PR_TRUE); if (NS_FAILED(res)) return res; } else if (nsHTMLEditUtils::IsTable(curNode) || @@ -7130,7 +7129,7 @@ nsHTMLEditRules::ApplyBlockStyle(nsCOMAr res = SplitAsNeeded(aBlockTag, address_of(curParent), &offset); if (NS_FAILED(res)) return res; nsCOMPtr theBlock; - res = mHTMLEditor->CreateNode(*aBlockTag, curParent, offset, getter_AddRefs(theBlock)); + res = mHTMLEditor->CreateNode(aBlockTag, curParent, offset, getter_AddRefs(theBlock)); if (NS_FAILED(res)) return res; // remember our new block for postprocessing mNewBlock = theBlock; @@ -7152,7 +7151,7 @@ nsHTMLEditRules::ApplyBlockStyle(nsCOMAr // block for it. res = SplitAsNeeded(aBlockTag, address_of(curParent), &offset); if (NS_FAILED(res)) return res; - res = mHTMLEditor->CreateNode(*aBlockTag, curParent, offset, getter_AddRefs(curBlock)); + res = mHTMLEditor->CreateNode(aBlockTag, curParent, offset, getter_AddRefs(curBlock)); if (NS_FAILED(res)) return res; // remember our new block for postprocessing mNewBlock = curBlock; @@ -7182,7 +7181,7 @@ nsHTMLEditRules::ApplyBlockStyle(nsCOMAr { res = SplitAsNeeded(aBlockTag, address_of(curParent), &offset); if (NS_FAILED(res)) return res; - res = mHTMLEditor->CreateNode(*aBlockTag, curParent, offset, getter_AddRefs(curBlock)); + res = mHTMLEditor->CreateNode(aBlockTag, curParent, offset, getter_AddRefs(curBlock)); if (NS_FAILED(res)) return res; // remember our new block for postprocessing mNewBlock = curBlock; @@ -7207,11 +7206,11 @@ nsHTMLEditRules::ApplyBlockStyle(nsCOMAr // where we can insert the tag. Adjust inOutParent and // inOutOffset to pint to new location for tag. nsresult -nsHTMLEditRules::SplitAsNeeded(const nsAString *aTag, +nsHTMLEditRules::SplitAsNeeded(const nsAString &aTag, nsCOMPtr *inOutParent, PRInt32 *inOutOffset) { - if (!aTag || !inOutParent || !inOutOffset) return NS_ERROR_NULL_POINTER; + if (!inOutParent || !inOutOffset) return NS_ERROR_NULL_POINTER; if (!*inOutParent) return NS_ERROR_NULL_POINTER; nsCOMPtr tagParent, temp, splitNode, parent = *inOutParent; nsresult res = NS_OK; @@ -7222,7 +7221,7 @@ nsHTMLEditRules::SplitAsNeeded(const nsA // sniffing up the parent tree until we find // a legal place for the block if (!parent) break; - if (mHTMLEditor->CanContainTag(parent, *aTag)) + if (mHTMLEditor->CanContainTag(parent, aTag)) { tagParent = parent; break; @@ -7362,12 +7361,12 @@ nsHTMLEditRules::CacheInlineStyles(nsIDO nsCOMPtr resultNode; if (!useCSS) { - mHTMLEditor->IsTextPropertySetByContent(aNode, mCachedStyles[j].tag, &(mCachedStyles[j].attr), nsnull, + mHTMLEditor->IsTextPropertySetByContent(aNode, mCachedStyles[j].tag, mCachedStyles[j].attr, EmptyString(), isSet, getter_AddRefs(resultNode), &outValue); } else { - mHTMLEditor->mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(aNode, mCachedStyles[j].tag, &(mCachedStyles[j].attr), + mHTMLEditor->mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(aNode, mCachedStyles[j].tag, mCachedStyles[j].attr, isSet, outValue, COMPUTED_STYLE_TYPE); } if (isSet) @@ -7417,12 +7416,12 @@ nsHTMLEditRules::ReapplyCachedStyles() nsAutoString curValue; if (useCSS) // check computed style first in css case { - mHTMLEditor->mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(selNode, mCachedStyles[j].tag, &(mCachedStyles[j].attr), + mHTMLEditor->mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(selNode, mCachedStyles[j].tag, mCachedStyles[j].attr, bAny, curValue, COMPUTED_STYLE_TYPE); } if (!bAny) // then check typeinstate and html style { - res = mHTMLEditor->GetInlinePropertyBase(mCachedStyles[j].tag, &(mCachedStyles[j].attr), &(mCachedStyles[j].value), + res = mHTMLEditor->GetInlinePropertyBase(mCachedStyles[j].tag, mCachedStyles[j].attr, mCachedStyles[j].value, &bFirst, &bAny, &bAll, &curValue, PR_FALSE); if (NS_FAILED(res)) return res; } @@ -8773,7 +8772,7 @@ nsHTMLEditRules::MakeSureElemStartsOrEnd } nsresult -nsHTMLEditRules::AlignBlock(nsIDOMElement * aElement, const nsAString * aAlignType, PRBool aContentsOnly) +nsHTMLEditRules::AlignBlock(nsIDOMElement * aElement, const nsAString & aAlignType, PRBool aContentsOnly) { if (!aElement) return NS_ERROR_NULL_POINTER; @@ -8784,7 +8783,7 @@ nsHTMLEditRules::AlignBlock(nsIDOMElemen return NS_OK; } - nsresult res = RemoveAlignment(node, *aAlignType, aContentsOnly); + nsresult res = RemoveAlignment(node, aAlignType, aContentsOnly); if (NS_FAILED(res)) return res; NS_NAMED_LITERAL_STRING(attr, "align"); PRBool useCSS; @@ -8792,14 +8791,14 @@ nsHTMLEditRules::AlignBlock(nsIDOMElemen if (useCSS) { // let's use CSS alignment; we use margin-left and margin-right for tables // and text-align for other block-level elements - res = mHTMLEditor->SetAttributeOrEquivalent(aElement, attr, *aAlignType, PR_FALSE); + res = mHTMLEditor->SetAttributeOrEquivalent(aElement, attr, aAlignType, PR_FALSE); if (NS_FAILED(res)) return res; } else { // HTML case; this code is supposed to be called ONLY if the element // supports the align attribute but we'll never know... if (nsHTMLEditUtils::SupportsAlignAttr(node)) { - res = mHTMLEditor->SetAttribute(aElement, attr, *aAlignType); + res = mHTMLEditor->SetAttribute(aElement, attr, aAlignType); if (NS_FAILED(res)) return res; } } @@ -8946,7 +8945,7 @@ nsHTMLEditRules::WillAbsolutePosition(ns res = mHTMLEditor->GetStartNodeAndOffset(aSelection, address_of(parent), &offset); if (NS_FAILED(res)) return res; // make sure we can put a block here - res = SplitAsNeeded(&divType, address_of(parent), &offset); + res = SplitAsNeeded(divType, address_of(parent), &offset); if (NS_FAILED(res)) return res; res = mHTMLEditor->CreateNode(divType, parent, offset, getter_AddRefs(thePositionedDiv)); if (NS_FAILED(res)) return res; @@ -9002,7 +9001,7 @@ nsHTMLEditRules::WillAbsolutePosition(ns nsEditor::GetTagString(curParent,listTag); ToLowerCase(listTag); // create a new nested list of correct type - res = SplitAsNeeded(&listTag, address_of(curParent), &offset); + res = SplitAsNeeded(listTag, address_of(curParent), &offset); if (NS_FAILED(res)) return res; if (!curPositionedDiv) { PRInt32 parentOffset; @@ -9052,7 +9051,7 @@ nsHTMLEditRules::WillAbsolutePosition(ns nsEditor::GetTagString(curParent,listTag); ToLowerCase(listTag); // create a new nested list of correct type - res = SplitAsNeeded(&listTag, address_of(curParent), &offset); + res = SplitAsNeeded(listTag, address_of(curParent), &offset); if (NS_FAILED(res)) return res; if (!curPositionedDiv) { PRInt32 parentOffset; @@ -9083,7 +9082,7 @@ nsHTMLEditRules::WillAbsolutePosition(ns curList = nsnull; continue; } - res = SplitAsNeeded(&divType, address_of(curParent), &offset); + res = SplitAsNeeded(divType, address_of(curParent), &offset); if (NS_FAILED(res)) return res; res = mHTMLEditor->CreateNode(divType, curParent, offset, getter_AddRefs(curPositionedDiv)); if (NS_FAILED(res)) return res; diff --git a/editor/libeditor/html/nsHTMLEditRules.h b/editor/libeditor/html/nsHTMLEditRules.h --- a/editor/libeditor/html/nsHTMLEditRules.h +++ b/editor/libeditor/html/nsHTMLEditRules.h @@ -146,8 +146,8 @@ protected: nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled, - const nsAString *inString, - nsAString *outString, + const nsAString &inString, + nsAString &outString, PRInt32 aMaxLength); nsresult WillLoadHTML(nsISelection *aSelection, PRBool *aCancel); nsresult WillInsertBreak(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled); @@ -167,22 +167,22 @@ protected: nsresult MoveNodeSmart(nsIDOMNode *aSource, nsIDOMNode *aDest, PRInt32 *aOffset); nsresult MoveContents(nsIDOMNode *aSource, nsIDOMNode *aDest, PRInt32 *aOffset); nsresult DeleteNonTableElements(nsIDOMNode *aNode); - nsresult WillMakeList(nsISelection *aSelection, const nsAString *aListType, PRBool aEntireList, const nsAString *aBulletType, PRBool *aCancel, PRBool *aHandled, const nsAString *aItemType=nsnull); + nsresult WillMakeList(nsISelection *aSelection, const nsAString &aListType, PRBool aEntireList, const nsAString &aBulletType, PRBool *aCancel, PRBool *aHandled, const nsAString &aItemType); nsresult WillRemoveList(nsISelection *aSelection, PRBool aOrderd, PRBool *aCancel, PRBool *aHandled); nsresult WillIndent(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled); nsresult WillCSSIndent(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled); nsresult WillHTMLIndent(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled); nsresult WillOutdent(nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled); - nsresult WillAlign(nsISelection *aSelection, const nsAString *alignType, PRBool *aCancel, PRBool *aHandled); + nsresult WillAlign(nsISelection *aSelection, const nsAString &alignType, PRBool *aCancel, PRBool *aHandled); nsresult WillAbsolutePosition(nsISelection *aSelection, PRBool *aCancel, PRBool * aHandled); nsresult WillRemoveAbsolutePosition(nsISelection *aSelection, PRBool *aCancel, PRBool * aHandled); nsresult WillRelativeChangeZIndex(nsISelection *aSelection, PRInt32 aChange, PRBool *aCancel, PRBool * aHandled); - nsresult WillMakeDefListItem(nsISelection *aSelection, const nsAString *aBlockType, PRBool aEntireList, PRBool *aCancel, PRBool *aHandled); - nsresult WillMakeBasicBlock(nsISelection *aSelection, const nsAString *aBlockType, PRBool *aCancel, PRBool *aHandled); + nsresult WillMakeDefListItem(nsISelection *aSelection, const nsAString &aBlockType, PRBool aEntireList, PRBool *aCancel, PRBool *aHandled); + nsresult WillMakeBasicBlock(nsISelection *aSelection, const nsAString &aBlockType, PRBool *aCancel, PRBool *aHandled); nsresult DidMakeBasicBlock(nsISelection *aSelection, nsRulesInfo *aInfo, nsresult aResult); nsresult DidAbsolutePosition(); - nsresult AlignInnerBlocks(nsIDOMNode *aNode, const nsAString *alignType); - nsresult AlignBlockContents(nsIDOMNode *aNode, const nsAString *alignType); + nsresult AlignInnerBlocks(nsIDOMNode *aNode, const nsAString &alignType); + nsresult AlignBlockContents(nsIDOMNode *aNode, const nsAString &alignType); nsresult AppendInnerFormatNodes(nsCOMArray& aArray, nsIDOMNode *aNode); nsresult GetFormatString(nsIDOMNode *aNode, nsAString &outFormat); @@ -265,9 +265,9 @@ protected: nsresult MakeTransitionList(nsCOMArray& inArrayOfNodes, nsTArray &inTransitionArray); nsresult RemoveBlockStyle(nsCOMArray& arrayOfNodes); - nsresult ApplyBlockStyle(nsCOMArray& arrayOfNodes, const nsAString *aBlockTag); + nsresult ApplyBlockStyle(nsCOMArray& arrayOfNodes, const nsAString &aBlockTag); nsresult MakeBlockquote(nsCOMArray& arrayOfNodes); - nsresult SplitAsNeeded(const nsAString *aTag, nsCOMPtr *inOutParent, PRInt32 *inOutOffset); + nsresult SplitAsNeeded(const nsAString &aTag, nsCOMPtr *inOutParent, PRInt32 *inOutOffset); nsresult AddTerminatingBR(nsIDOMNode *aBlock); nsresult JoinNodesSmart( nsIDOMNode *aNodeLeft, nsIDOMNode *aNodeRight, @@ -298,7 +298,7 @@ protected: PRBool ListIsEmptyLine(nsCOMArray &arrayOfNodes); nsresult RemoveAlignment(nsIDOMNode * aNode, const nsAString & aAlignType, PRBool aChildrenOnly); nsresult MakeSureElemStartsOrEndsOnCR(nsIDOMNode *aNode, PRBool aStarts); - nsresult AlignBlock(nsIDOMElement * aElement, const nsAString * aAlignType, PRBool aContentsOnly); + nsresult AlignBlock(nsIDOMElement * aElement, const nsAString & aAlignType, PRBool aContentsOnly); nsresult RelativeChangeIndentationOfElementNode(nsIDOMNode *aNode, PRInt8 aRelativeChange); // data members diff --git a/editor/libeditor/html/nsHTMLEditor.cpp b/editor/libeditor/html/nsHTMLEditor.cpp --- a/editor/libeditor/html/nsHTMLEditor.cpp +++ b/editor/libeditor/html/nsHTMLEditor.cpp @@ -2411,9 +2411,9 @@ nsHTMLEditor::MakeOrChangeList(const nsA if (!selection) return NS_ERROR_NULL_POINTER; nsTextRulesInfo ruleInfo(nsTextEditRules::kMakeList); - ruleInfo.blockType = &aListType; + ruleInfo.blockType = aListType; ruleInfo.entireList = entireList; - ruleInfo.bulletType = &aBulletType; + ruleInfo.bulletType = aBulletType; res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled); if (cancel || (NS_FAILED(res))) return res; @@ -2518,7 +2518,7 @@ nsHTMLEditor::MakeDefinitionItem(const n if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; nsTextRulesInfo ruleInfo(nsTextEditRules::kMakeDefListItem); - ruleInfo.blockType = &aItemType; + ruleInfo.blockType = aItemType; res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled); if (cancel || (NS_FAILED(res))) return res; @@ -2548,7 +2548,7 @@ nsHTMLEditor::InsertBasicBlock(const nsA if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; nsTextRulesInfo ruleInfo(nsTextEditRules::kMakeBasicBlock); - ruleInfo.blockType = &aBlockType; + ruleInfo.blockType = aBlockType; res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled); if (cancel || (NS_FAILED(res))) return res; @@ -2705,7 +2705,7 @@ nsHTMLEditor::Align(const nsAString& aAl if (NS_FAILED(res)) return res; if (!selection) return NS_ERROR_NULL_POINTER; nsTextRulesInfo ruleInfo(nsTextEditRules::kAlign); - ruleInfo.alignType = &aAlignType; + ruleInfo.alignType = aAlignType; res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled); if (cancel || NS_FAILED(res)) return res; @@ -4114,9 +4114,9 @@ nsHTMLEditor::SelectAll() // this will NOT find aAttribute unless aAttribute has a non-null value // so singleton attributes like will not be matched! void nsHTMLEditor::IsTextPropertySetByContent(nsIDOMNode *aNode, - nsIAtom *aProperty, - const nsAString *aAttribute, - const nsAString *aValue, + nsIAtom *aProperty, + const nsAString &aAttribute, + const nsAString &aValue, PRBool &aIsSet, nsIDOMNode **aStyleNode, nsAString *outValue) @@ -4138,19 +4138,18 @@ void nsHTMLEditor::IsTextPropertySetByCo if (propName.Equals(tag, nsCaseInsensitiveStringComparator())) { PRBool found = PR_FALSE; - if (aAttribute && 0!=aAttribute->Length()) - { - element->GetAttribute(*aAttribute, value); + if (!aAttribute.IsEmpty()) + { + element->GetAttribute(aAttribute, value); if (outValue) *outValue = value; if (!value.IsEmpty()) { - if (!aValue) { + if (aValue.IsEmpty()) { found = PR_TRUE; } else { - nsString tString(*aValue); - if (tString.Equals(value, nsCaseInsensitiveStringComparator())) { + if (aValue.Equals(value, nsCaseInsensitiveStringComparator())) { found = PR_TRUE; } else { // we found the prop with the attribute, but the value doesn't match @@ -5068,7 +5067,7 @@ nsHTMLEditor::SetAttributeOrEquivalent(n GetIsCSSEnabled(&useCSS); if (useCSS && mHTMLCSSUtils) { PRInt32 count; - res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(aElement, nsnull, &aAttribute, &aValue, &count, + res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(aElement, nsnull, aAttribute, aValue, &count, aSuppressTransaction); if (NS_FAILED(res)) return res; if (count) { @@ -5131,7 +5130,7 @@ nsHTMLEditor::RemoveAttributeOrEquivalen nsresult res = NS_OK; GetIsCSSEnabled(&useCSS); if (useCSS && mHTMLCSSUtils) { - res = mHTMLCSSUtils->RemoveCSSEquivalentToHTMLStyle(aElement, nsnull, &aAttribute, nsnull, + res = mHTMLCSSUtils->RemoveCSSEquivalentToHTMLStyle(aElement, nsnull, aAttribute, EmptyString(), aSuppressTransaction); if (NS_FAILED(res)) return res; } @@ -5248,7 +5247,7 @@ nsHTMLEditor::SetCSSBackgroundColor(cons cachedBlockParent = blockParent; nsCOMPtr element = do_QueryInterface(blockParent); PRInt32 count; - res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(element, nsnull, &bgcolor, &aColor, &count, PR_FALSE); + res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(element, nsnull, bgcolor, aColor, &count, PR_FALSE); if (NS_FAILED(res)) return res; } } @@ -5257,7 +5256,7 @@ nsHTMLEditor::SetCSSBackgroundColor(cons // we have no block in the document, let's apply the background to the body nsCOMPtr element = do_QueryInterface(startNode); PRInt32 count; - res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(element, nsnull, &bgcolor, &aColor, &count, PR_FALSE); + res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(element, nsnull, bgcolor, aColor, &count, PR_FALSE); if (NS_FAILED(res)) return res; } else if ((startNode == endNode) && (((endOffset-startOffset) == 1) || (!startOffset && !endOffset))) @@ -5277,7 +5276,7 @@ nsHTMLEditor::SetCSSBackgroundColor(cons cachedBlockParent = blockParent; nsCOMPtr element = do_QueryInterface(blockParent); PRInt32 count; - res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(element, nsnull, &bgcolor, &aColor, &count, PR_FALSE); + res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(element, nsnull, bgcolor, aColor, &count, PR_FALSE); if (NS_FAILED(res)) return res; } } @@ -5336,7 +5335,7 @@ nsHTMLEditor::SetCSSBackgroundColor(cons cachedBlockParent = blockParent; nsCOMPtr element = do_QueryInterface(blockParent); PRInt32 count; - res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(element, nsnull, &bgcolor, &aColor, &count, PR_FALSE); + res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(element, nsnull, bgcolor, aColor, &count, PR_FALSE); if (NS_FAILED(res)) return res; } } @@ -5362,7 +5361,7 @@ nsHTMLEditor::SetCSSBackgroundColor(cons nsCOMPtr element = do_QueryInterface(blockParent); PRInt32 count; // and set the property on it - res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(element, nsnull, &bgcolor, &aColor, &count, PR_FALSE); + res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(element, nsnull, bgcolor, aColor, &count, PR_FALSE); if (NS_FAILED(res)) return res; } } @@ -5380,7 +5379,7 @@ nsHTMLEditor::SetCSSBackgroundColor(cons cachedBlockParent = blockParent; nsCOMPtr element = do_QueryInterface(blockParent); PRInt32 count; - res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(element, nsnull, &bgcolor, &aColor, &count, PR_FALSE); + res = mHTMLCSSUtils->SetCSSEquivalentToHTMLStyle(element, nsnull, bgcolor, aColor, &count, PR_FALSE); if (NS_FAILED(res)) return res; } } @@ -5483,7 +5482,7 @@ nsHTMLEditor::CopyLastEditableChildStyle ToLowerCase(domTagName); if (newStyles) { nsCOMPtr newContainer; - res = InsertContainerAbove(newStyles, address_of(newContainer), domTagName); + res = InsertContainerAbove(newStyles, address_of(newContainer), domTagName, EmptyString(), EmptyString()); if (NS_FAILED(res)) return res; newStyles = newContainer; } diff --git a/editor/libeditor/html/nsHTMLEditor.h b/editor/libeditor/html/nsHTMLEditor.h --- a/editor/libeditor/html/nsHTMLEditor.h +++ b/editor/libeditor/html/nsHTMLEditor.h @@ -545,8 +545,8 @@ protected: */ virtual void IsTextPropertySetByContent(nsIDOMNode *aNode, nsIAtom *aProperty, - const nsAString *aAttribute, - const nsAString *aValue, + const nsAString &aAttribute, + const nsAString &aValue, PRBool &aIsSet, nsIDOMNode **aStyleNode, nsAString *outValue = nsnull); @@ -669,37 +669,37 @@ protected: PRInt32 aStartOffset, PRInt32 aEndOffset, nsIAtom *aProperty, - const nsAString *aAttribute, - const nsAString *aValue); + const nsAString &aAttribute, + const nsAString &aValue); nsresult SetInlinePropertyOnNode( nsIDOMNode *aNode, nsIAtom *aProperty, - const nsAString *aAttribute, - const nsAString *aValue); + const nsAString &aAttribute, + const nsAString &aValue); nsresult PromoteInlineRange(nsIDOMRange *inRange); nsresult PromoteRangeIfStartsOrEndsInNamedAnchor(nsIDOMRange *inRange); nsresult SplitStyleAboveRange(nsIDOMRange *aRange, nsIAtom *aProperty, - const nsAString *aAttribute); + const nsAString &aAttribute); nsresult SplitStyleAbovePoint(nsCOMPtr *aNode, PRInt32 *aOffset, nsIAtom *aProperty, - const nsAString *aAttribute, + const nsAString &aAttribute, nsCOMPtr *outLeftNode = nsnull, nsCOMPtr *outRightNode = nsnull); nsresult ApplyDefaultProperties(); nsresult RemoveStyleInside(nsIDOMNode *aNode, nsIAtom *aProperty, - const nsAString *aAttribute, + const nsAString &aAttribute, PRBool aChildrenOnly = PR_FALSE); - nsresult RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsAString *aAttribute); + nsresult RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsAString &aAttribute); PRBool NodeIsProperty(nsIDOMNode *aNode); - PRBool HasAttr(nsIDOMNode *aNode, const nsAString *aAttribute); - PRBool HasAttrVal(nsIDOMNode *aNode, const nsAString *aAttribute, const nsAString *aValue); + PRBool HasAttr(nsIDOMNode *aNode, const nsAString &aAttribute); + PRBool HasAttrVal(nsIDOMNode *aNode, const nsAString &aAttribute, const nsAString &aValue); PRBool IsAtFrontOfNode(nsIDOMNode *aNode, PRInt32 aOffset); PRBool IsAtEndOfNode(nsIDOMNode *aNode, PRInt32 aOffset); - PRBool IsOnlyAttribute(nsIDOMNode *aElement, const nsAString *aAttribute); + PRBool IsOnlyAttribute(nsIDOMNode *aElement, const nsAString &aAttribute); nsresult RemoveBlockContainer(nsIDOMNode *inNode); nsresult GetPriorHTMLSibling(nsIDOMNode *inNode, nsCOMPtr *outNode); @@ -723,8 +723,8 @@ protected: PRBool mIgnoreSpuriousDragEvent; nsresult GetInlinePropertyBase(nsIAtom *aProperty, - const nsAString *aAttribute, - const nsAString *aValue, + const nsAString &aAttribute, + const nsAString &aValue, PRBool *aFirst, PRBool *aAny, PRBool *aAll, diff --git a/editor/libeditor/html/nsHTMLEditorStyle.cpp b/editor/libeditor/html/nsHTMLEditorStyle.cpp --- a/editor/libeditor/html/nsHTMLEditorStyle.cpp +++ b/editor/libeditor/html/nsHTMLEditorStyle.cpp @@ -191,7 +191,7 @@ NS_IMETHODIMP nsHTMLEditor::SetInlinePro range->GetStartOffset(&startOffset); range->GetEndOffset(&endOffset); nsCOMPtr nodeAsText = do_QueryInterface(startNode); - res = SetInlinePropertyOnTextNode(nodeAsText, startOffset, endOffset, aProperty, &aAttribute, &aValue); + res = SetInlinePropertyOnTextNode(nodeAsText, startOffset, endOffset, aProperty, aAttribute, aValue); if (NS_FAILED(res)) return res; } else @@ -247,7 +247,7 @@ NS_IMETHODIMP nsHTMLEditor::SetInlinePro PRUint32 textLen; range->GetStartOffset(&startOffset); nodeAsText->GetLength(&textLen); - res = SetInlinePropertyOnTextNode(nodeAsText, startOffset, textLen, aProperty, &aAttribute, &aValue); + res = SetInlinePropertyOnTextNode(nodeAsText, startOffset, textLen, aProperty, aAttribute, aValue); if (NS_FAILED(res)) return res; } @@ -257,7 +257,7 @@ NS_IMETHODIMP nsHTMLEditor::SetInlinePro for (j = 0; j < listCount; j++) { node = arrayOfNodes[j]; - res = SetInlinePropertyOnNode(node, aProperty, &aAttribute, &aValue); + res = SetInlinePropertyOnNode(node, aProperty, aAttribute, aValue); if (NS_FAILED(res)) return res; } arrayOfNodes.Clear(); @@ -270,7 +270,7 @@ NS_IMETHODIMP nsHTMLEditor::SetInlinePro nsCOMPtr nodeAsText = do_QueryInterface(endNode); PRInt32 endOffset; range->GetEndOffset(&endOffset); - res = SetInlinePropertyOnTextNode(nodeAsText, 0, endOffset, aProperty, &aAttribute, &aValue); + res = SetInlinePropertyOnTextNode(nodeAsText, 0, endOffset, aProperty, aAttribute, aValue); if (NS_FAILED(res)) return res; } } @@ -292,8 +292,8 @@ nsHTMLEditor::SetInlinePropertyOnTextNod PRInt32 aStartOffset, PRInt32 aEndOffset, nsIAtom *aProperty, - const nsAString *aAttribute, - const nsAString *aValue) + const nsAString &aAttribute, + const nsAString &aValue) { if (!aTextNode) return NS_ERROR_NULL_POINTER; nsCOMPtr parent; @@ -319,7 +319,7 @@ nsHTMLEditor::SetInlinePropertyOnTextNod // the HTML styles defined by aProperty/aAttribute has a CSS equivalence // in this implementation for node; let's check if it carries those css styles nsAutoString value; - if (aValue) value.Assign(*aValue); + value.Assign(aValue); mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(node, aProperty, aAttribute, bHasProp, value, COMPUTED_STYLE_TYPE); @@ -381,8 +381,8 @@ nsHTMLEditor::SetInlinePropertyOnTextNod nsresult nsHTMLEditor::SetInlinePropertyOnNode( nsIDOMNode *aNode, nsIAtom *aProperty, - const nsAString *aAttribute, - const nsAString *aValue) + const nsAString &aAttribute, + const nsAString &aValue) { if (!aNode || !aProperty) return NS_ERROR_NULL_POINTER; @@ -410,8 +410,8 @@ nsHTMLEditor::SetInlinePropertyOnNode( n InsertContainerAbove( aNode, address_of(tmp), NS_LITERAL_STRING("span"), - nsnull, - nsnull); + EmptyString(), + EmptyString()); } nsCOMPtrelement; element = do_QueryInterface(tmp); @@ -464,7 +464,7 @@ nsHTMLEditor::SetInlinePropertyOnNode( n res = RemoveStyleInside(aNode, aProperty, aAttribute, PR_TRUE); if (NS_FAILED(res)) return res; nsCOMPtr elem = do_QueryInterface(aNode); - return SetAttribute(elem, *aAttribute, *aValue); + return SetAttribute(elem, aAttribute, aValue); } // can it be put inside inline node? @@ -538,7 +538,7 @@ nsHTMLEditor::SetInlinePropertyOnNode( n nsresult nsHTMLEditor::SplitStyleAboveRange(nsIDOMRange *inRange, nsIAtom *aProperty, - const nsAString *aAttribute) + const nsAString &aAttribute) { if (!inRange) return NS_ERROR_NULL_POINTER; nsresult res; @@ -578,7 +578,7 @@ nsresult nsHTMLEditor::SplitStyleAboveRa nsresult nsHTMLEditor::SplitStyleAbovePoint(nsCOMPtr *aNode, PRInt32 *aOffset, nsIAtom *aProperty, // null here means we split all properties - const nsAString *aAttribute, + const nsAString &aAttribute, nsCOMPtr *outLeftNode, nsCOMPtr *outRightNode) { @@ -649,7 +649,7 @@ nsresult nsHTMLEditor::ApplyDefaultPrope nsresult nsHTMLEditor::RemoveStyleInside(nsIDOMNode *aNode, nsIAtom *aProperty, // null here means remove all properties - const nsAString *aAttribute, + const nsAString &aAttribute, PRBool aChildrenOnly) { if (!aNode) return NS_ERROR_NULL_POINTER; @@ -677,12 +677,12 @@ nsresult nsHTMLEditor::RemoveStyleInside { // if we weren't passed an attribute, then we want to // remove any matching inlinestyles entirely - if (!aAttribute || aAttribute->IsEmpty()) + if (aAttribute.IsEmpty()) { NS_NAMED_LITERAL_STRING(styleAttr, "style"); NS_NAMED_LITERAL_STRING(classAttr, "class"); - PRBool hasStyleAttr = HasAttr(aNode, &styleAttr); - PRBool hasClassAtrr = HasAttr(aNode, &classAttr); + PRBool hasStyleAttr = HasAttr(aNode, styleAttr); + PRBool hasClassAtrr = HasAttr(aNode, classAttr); if (aProperty && (hasStyleAttr || hasClassAtrr)) { // aNode carries inline styles or a class attribute so we can't @@ -691,7 +691,9 @@ nsresult nsHTMLEditor::RemoveStyleInside // the node. nsCOMPtr spanNode; res = InsertContainerAbove(aNode, address_of(spanNode), - NS_LITERAL_STRING("span")); + NS_LITERAL_STRING("span"), + EmptyString(), + EmptyString()); if (NS_FAILED(res)) return res; res = CloneAttribute(styleAttr, spanNode, aNode); @@ -708,7 +710,7 @@ nsresult nsHTMLEditor::RemoveStyleInside mHTMLCSSUtils->RemoveCSSEquivalentToHTMLStyle(spanNode, aProperty, aAttribute, - &propertyValue, + propertyValue, PR_FALSE); // remove the span if it's useless nsCOMPtr element = do_QueryInterface(spanNode); @@ -732,7 +734,7 @@ nsresult nsHTMLEditor::RemoveStyleInside { nsCOMPtr elem = do_QueryInterface(aNode); if (!elem) return NS_ERROR_NULL_POINTER; - res = RemoveAttribute(elem, *aAttribute); + res = RemoveAttribute(elem, aAttribute); } } } @@ -756,7 +758,7 @@ nsresult nsHTMLEditor::RemoveStyleInside mHTMLCSSUtils->RemoveCSSEquivalentToHTMLStyle(aNode, aProperty, aAttribute, - &propertyValue, + propertyValue, PR_FALSE); // remove the node if it is a span, if its style attribute is empty or absent, // and if it does not have a class nor an id @@ -767,7 +769,7 @@ nsresult nsHTMLEditor::RemoveStyleInside } if ( aProperty == nsEditProperty::font && // or node is big or small and we are setting font size (nsHTMLEditUtils::IsBig(aNode) || nsHTMLEditUtils::IsSmall(aNode)) && - aAttribute->LowerCaseEqualsLiteral("size")) + aAttribute.LowerCaseEqualsLiteral("size")) { res = RemoveContainer(aNode); // if we are setting font size, remove any nested bigs and smalls } @@ -775,9 +777,9 @@ nsresult nsHTMLEditor::RemoveStyleInside } PRBool nsHTMLEditor::IsOnlyAttribute(nsIDOMNode *aNode, - const nsAString *aAttribute) + const nsAString &aAttribute) { - if (!aNode || !aAttribute) return PR_FALSE; // ooops + if (!aNode || aAttribute.IsEmpty()) return PR_FALSE; // ooops nsCOMPtr content = do_QueryInterface(aNode); if (!content) return PR_FALSE; // ooops @@ -791,7 +793,7 @@ PRBool nsHTMLEditor::IsOnlyAttribute(nsI name->LocalName()->ToString(attrString); // if it's the attribute we know about, or a special _moz attribute, // keep looking - if (!attrString.Equals(*aAttribute, nsCaseInsensitiveStringComparator()) && + if (!attrString.Equals(aAttribute, nsCaseInsensitiveStringComparator()) && !StringBeginsWith(attrString, NS_LITERAL_STRING("_moz"))) { return PR_FALSE; } @@ -802,10 +804,10 @@ PRBool nsHTMLEditor::IsOnlyAttribute(nsI } PRBool nsHTMLEditor::HasAttr(nsIDOMNode *aNode, - const nsAString *aAttribute) + const nsAString &aAttribute) { if (!aNode) return PR_FALSE; - if (!aAttribute || aAttribute->IsEmpty()) return PR_TRUE; // everybody has the 'null' attribute + if (aAttribute.IsEmpty()) return PR_TRUE; // everybody has the 'null' attribute // get element nsCOMPtr elem = do_QueryInterface(aNode); @@ -813,18 +815,18 @@ PRBool nsHTMLEditor::HasAttr(nsIDOMNode // get attribute node nsCOMPtr attNode; - nsresult res = elem->GetAttributeNode(*aAttribute, getter_AddRefs(attNode)); + nsresult res = elem->GetAttributeNode(aAttribute, getter_AddRefs(attNode)); if ((NS_FAILED(res)) || !attNode) return PR_FALSE; return PR_TRUE; } PRBool nsHTMLEditor::HasAttrVal(nsIDOMNode *aNode, - const nsAString *aAttribute, - const nsAString *aValue) + const nsAString &aAttribute, + const nsAString &aValue) { if (!aNode) return PR_FALSE; - if (!aAttribute || aAttribute->IsEmpty()) return PR_TRUE; // everybody has the 'null' attribute + if (aAttribute.IsEmpty()) return PR_TRUE; // everybody has the 'null' attribute // get element nsCOMPtr elem = do_QueryInterface(aNode); @@ -832,21 +834,21 @@ PRBool nsHTMLEditor::HasAttrVal(nsIDOMNo // get attribute node nsCOMPtr attNode; - nsresult res = elem->GetAttributeNode(*aAttribute, getter_AddRefs(attNode)); + nsresult res = elem->GetAttributeNode(aAttribute, getter_AddRefs(attNode)); if ((NS_FAILED(res)) || !attNode) return PR_FALSE; // check if attribute has a value PRBool isSet; attNode->GetSpecified(&isSet); // if no value, and that's what we wanted, then return true - if (!isSet && (!aValue || aValue->IsEmpty())) return PR_TRUE; + if (!isSet && (aValue.IsEmpty())) return PR_TRUE; // get attribute value nsAutoString attrVal; attNode->GetValue(attrVal); // do values match? - if (attrVal.Equals(*aValue,nsCaseInsensitiveStringComparator())) return PR_TRUE; + if (attrVal.Equals(aValue, nsCaseInsensitiveStringComparator())) return PR_TRUE; return PR_FALSE; } @@ -998,8 +1000,8 @@ PRBool nsHTMLEditor::IsAtEndOfNode(nsIDO nsresult nsHTMLEditor::GetInlinePropertyBase(nsIAtom *aProperty, - const nsAString *aAttribute, - const nsAString *aValue, + const nsAString &aAttribute, + const nsAString &aValue, PRBool *aFirst, PRBool *aAny, PRBool *aAll, @@ -1047,9 +1049,9 @@ nsHTMLEditor::GetInlinePropertyBase(nsIA range->GetStartContainer(getter_AddRefs(collapsedNode)); if (!collapsedNode) return NS_ERROR_FAILURE; PRBool isSet, theSetting; - if (aAttribute) + if (!aAttribute.IsEmpty()) { - nsString tString(*aAttribute); //MJUDGE SCC NEED HELP + nsString tString(aAttribute); //MJUDGE SCC NEED HELP nsString tOutString;//MJUDGE SCC NEED HELP nsString *tPassString=nsnull; if (outValue) @@ -1076,7 +1078,7 @@ nsHTMLEditor::GetInlinePropertyBase(nsIA // style not set, but if it is a default then it will appear if // content is inserted, so we should report it as set (analogous to TypeInState). PRInt32 index; - if (TypeInState::FindPropInList(aProperty, *aAttribute, outValue, mDefaultStyles, index)) + if (TypeInState::FindPropInList(aProperty, aAttribute, outValue, mDefaultStyles, index)) { *aFirst = *aAny = *aAll = PR_TRUE; if (outValue) @@ -1155,7 +1157,7 @@ nsHTMLEditor::GetInlinePropertyBase(nsIA mHTMLCSSUtils->IsCSSEditableProperty(node, aProperty, aAttribute)) { // the HTML styles defined by aProperty/aAttribute has a CSS equivalence // in this implementation for node; let's check if it carries those css styles - if (aValue) firstValue.Assign(*aValue); + if (!aValue.IsEmpty()) firstValue.Assign(aValue); mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(node, aProperty, aAttribute, isSet, firstValue, COMPUTED_STYLE_TYPE); @@ -1174,7 +1176,7 @@ nsHTMLEditor::GetInlinePropertyBase(nsIA mHTMLCSSUtils->IsCSSEditableProperty(node, aProperty, aAttribute)) { // the HTML styles defined by aProperty/aAttribute has a CSS equivalence // in this implementation for node; let's check if it carries those css styles - if (aValue) theValue.Assign(*aValue); + if (!aValue.IsEmpty()) theValue.Assign(aValue); mHTMLCSSUtils->IsCSSEquivalentToHTMLInlineStyleSet(node, aProperty, aAttribute, isSet, theValue, COMPUTED_STYLE_TYPE); @@ -1216,13 +1218,7 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePro { if (!aProperty || !aFirst || !aAny || !aAll) return NS_ERROR_NULL_POINTER; - const nsAString *att = nsnull; - if (!aAttribute.IsEmpty()) - att = &aAttribute; - const nsAString *val = nsnull; - if (!aValue.IsEmpty()) - val = &aValue; - return GetInlinePropertyBase( aProperty, att, val, aFirst, aAny, aAll, nsnull); + return GetInlinePropertyBase( aProperty, aAttribute, aValue, aFirst, aAny, aAll, nsnull); } @@ -1236,13 +1232,7 @@ NS_IMETHODIMP nsHTMLEditor::GetInlinePro { if (!aProperty || !aFirst || !aAny || !aAll) return NS_ERROR_NULL_POINTER; - const nsAString *att = nsnull; - if (!aAttribute.IsEmpty()) - att = &aAttribute; - const nsAString *val = nsnull; - if (!aValue.IsEmpty()) - val = &aValue; - return GetInlinePropertyBase( aProperty, att, val, aFirst, aAny, aAll, &outValue); + return GetInlinePropertyBase( aProperty, aAttribute, aValue, aFirst, aAny, aAll, &outValue); } @@ -1251,17 +1241,17 @@ NS_IMETHODIMP nsHTMLEditor::RemoveAllInl nsAutoEditBatch batchIt(this); nsAutoRules beginRulesSniffing(this, kOpResetTextProperties, nsIEditor::eNext); - nsresult res = RemoveInlinePropertyImpl(nsnull, nsnull); + nsresult res = RemoveInlinePropertyImpl(nsnull, EmptyString()); if (NS_FAILED(res)) return res; return ApplyDefaultProperties(); } NS_IMETHODIMP nsHTMLEditor::RemoveInlineProperty(nsIAtom *aProperty, const nsAString &aAttribute) { - return RemoveInlinePropertyImpl(aProperty, &aAttribute); + return RemoveInlinePropertyImpl(aProperty, aAttribute); } -nsresult nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsAString *aAttribute) +nsresult nsHTMLEditor::RemoveInlinePropertyImpl(nsIAtom *aProperty, const nsAString &aAttribute) { if (!mRules) return NS_ERROR_NOT_INITIALIZED; ForceCompositionEnd(); @@ -1288,8 +1278,9 @@ nsresult nsHTMLEditor::RemoveInlinePrope aProperty == nsEditProperty::name) aProperty = nsEditProperty::a; - if (aProperty) return mTypeInState->ClearProp(aProperty, nsAutoString(*aAttribute)); - else return mTypeInState->ClearAllProps(); + if (aProperty) + return mTypeInState->ClearProp(aProperty, aAttribute); + return mTypeInState->ClearAllProps(); } nsAutoEditBatch batchIt(this); nsAutoRules beginRulesSniffing(this, kOpRemoveTextProperty, nsIEditor::eNext); @@ -1367,7 +1358,7 @@ nsresult nsHTMLEditor::RemoveInlinePrope range->GetEndOffset(&endOffset); nsCOMPtr nodeAsText = do_QueryInterface(startNode); if (mHTMLCSSUtils->IsCSSInvertable(aProperty, aAttribute)) { - SetInlinePropertyOnTextNode(nodeAsText, startOffset, endOffset, aProperty, aAttribute, &value); + SetInlinePropertyOnTextNode(nodeAsText, startOffset, endOffset, aProperty, aAttribute, value); } } } @@ -1425,7 +1416,7 @@ nsresult nsHTMLEditor::RemoveInlinePrope // insert a span "inverting" the style if (mHTMLCSSUtils->IsCSSInvertable(aProperty, aAttribute)) { nsAutoString value; value.AssignLiteral("-moz-editor-invert-value"); - SetInlinePropertyOnNode(node, aProperty, aAttribute, &value); + SetInlinePropertyOnNode(node, aProperty, aAttribute, value); } } } @@ -1683,7 +1674,7 @@ nsHTMLEditor::RelativeFontChangeOnTextNo } // else reparent the node inside font node with appropriate relative size - res = InsertContainerAbove(node, address_of(tmp), nodeType); + res = InsertContainerAbove(node, address_of(tmp), nodeType, EmptyString(), EmptyString()); return res; } @@ -1714,7 +1705,8 @@ nsHTMLEditor::RelativeFontChangeHelper( // if this is a font node with size, put big/small inside it NS_NAMED_LITERAL_STRING(attr, "size"); - if (NodeIsType(aNode, nsEditProperty::font) && HasAttr(aNode, &attr)) + if (NodeIsType(aNode, nsEditProperty::font) && + HasAttr(aNode, attr)) { // cycle through children and adjust relative font size res = aNode->GetChildNodes(getter_AddRefs(childNodes)); @@ -1808,7 +1800,7 @@ nsHTMLEditor::RelativeFontChangeOnNode( return res; } // else insert it above aNode - res = InsertContainerAbove(aNode, address_of(tmp), tag); + res = InsertContainerAbove(aNode, address_of(tmp), tag, EmptyString(), EmptyString()); return res; } // none of the above? then cycle through the children. @@ -1849,7 +1841,7 @@ nsHTMLEditor::GetFontFaceState(PRBool *a PRBool first, any, all; NS_NAMED_LITERAL_STRING(attr, "face"); - res = GetInlinePropertyBase(nsEditProperty::font, &attr, nsnull, &first, &any, &all, &outFace); + res = GetInlinePropertyBase(nsEditProperty::font, attr, EmptyString(), &first, &any, &all, &outFace); if (NS_FAILED(res)) return res; if (any && !all) return res; // mixed if (all) @@ -1859,7 +1851,7 @@ nsHTMLEditor::GetFontFaceState(PRBool *a } // if there is no font face, check for tt - res = GetInlinePropertyBase(nsEditProperty::tt, nsnull, nsnull, &first, &any, &all,nsnull); + res = GetInlinePropertyBase(nsEditProperty::tt, EmptyString(), EmptyString(), &first, &any, &all,nsnull); if (NS_FAILED(res)) return res; if (any && !all) return res; // mixed if (all) @@ -1889,7 +1881,7 @@ nsHTMLEditor::GetFontColorState(PRBool * NS_NAMED_LITERAL_STRING(colorStr, "color"); PRBool first, any, all; - res = GetInlinePropertyBase(nsEditProperty::font, &colorStr, nsnull, &first, &any, &all, &aOutColor); + res = GetInlinePropertyBase(nsEditProperty::font, colorStr, EmptyString(), &first, &any, &all, &aOutColor); if (NS_FAILED(res)) return res; if (any && !all) return res; // mixed if (all) diff --git a/editor/libeditor/html/nsTableEditor.cpp b/editor/libeditor/html/nsTableEditor.cpp --- a/editor/libeditor/html/nsTableEditor.cpp +++ b/editor/libeditor/html/nsTableEditor.cpp @@ -1994,7 +1994,7 @@ nsHTMLEditor::SwitchTableCellHeaderType( // This creates new node, moves children, copies attributes (PR_TRUE) // and manages the selection! - res = ReplaceContainer(aSourceCell, address_of(newNode), newCellType, nsnull, nsnull, PR_TRUE); + res = ReplaceContainer(aSourceCell, address_of(newNode), newCellType, EmptyString(), EmptyString(), PR_TRUE); if (NS_FAILED(res)) return res; if (!newNode) return NS_ERROR_FAILURE; diff --git a/editor/libeditor/text/nsPlaintextEditor.cpp b/editor/libeditor/text/nsPlaintextEditor.cpp --- a/editor/libeditor/text/nsPlaintextEditor.cpp +++ b/editor/libeditor/text/nsPlaintextEditor.cpp @@ -789,8 +789,8 @@ NS_IMETHODIMP nsPlaintextEditor::InsertT // XXX and ruleInfo not to refer to instring in its dtor? //nsAutoString instring(aStringToInsert); nsTextRulesInfo ruleInfo(theAction); - ruleInfo.inString = &aStringToInsert; - ruleInfo.outString = &resultString; + ruleInfo.inString = aStringToInsert; + ruleInfo.outString = resultString; ruleInfo.maxLength = mMaxTextLength; PRBool cancel, handled; @@ -1361,16 +1361,16 @@ nsPlaintextEditor::OutputToString(const { nsString resultString; nsTextRulesInfo ruleInfo(nsTextEditRules::kOutputText); - ruleInfo.outString = &resultString; + ruleInfo.outString = resultString; // XXX Struct should store a nsAReadable* nsAutoString str(aFormatType); - ruleInfo.outputFormat = &str; + ruleInfo.outputFormat = str; PRBool cancel, handled; nsresult rv = mRules->WillDoAction(nsnull, &ruleInfo, &cancel, &handled); if (cancel || NS_FAILED(rv)) { return rv; } if (handled) { // this case will get triggered by password fields - aOutputString.Assign(*(ruleInfo.outString)); + aOutputString.Assign(ruleInfo.outString); return rv; } diff --git a/editor/libeditor/text/nsTextEditRules.cpp b/editor/libeditor/text/nsTextEditRules.cpp --- a/editor/libeditor/text/nsTextEditRules.cpp +++ b/editor/libeditor/text/nsTextEditRules.cpp @@ -517,13 +517,13 @@ nsTextEditRules::WillInsertText(PRInt32 nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled, - const nsAString *inString, - nsAString *outString, + const nsAString &inString, + nsAString &outString, PRInt32 aMaxLength) { if (!aSelection || !aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; } - if (inString->IsEmpty() && (aAction != kInsertTextIME)) + if (inString.IsEmpty() && (aAction != kInsertTextIME)) { // HACK: this is a fix for bug 19395 // I can't outlaw all empty insertions @@ -594,7 +594,7 @@ nsTextEditRules::WillInsertText(PRInt32 // So find out what we're expected to do: if (nsIPlaintextEditor::eEditorSingleLineMask & mFlags) { - nsAutoString tString(*outString); + nsAutoString tString(outString); switch(mEditor->mNewlineHandling) { @@ -654,7 +654,7 @@ nsTextEditRules::WillInsertText(PRInt32 break; } - outString->Assign(tString); + outString.Assign(tString); } if (mFlags & nsIPlaintextEditor::eEditorPasswordMask) @@ -681,7 +681,7 @@ nsTextEditRules::WillInsertText(PRInt32 if (aAction == kInsertTextIME) { - res = mEditor->InsertTextImpl(*outString, address_of(selNode), &selOffset, doc); + res = mEditor->InsertTextImpl(outString, address_of(selNode), &selOffset, doc); if (NS_FAILED(res)) return res; } else // aAction == kInsertText @@ -698,7 +698,7 @@ nsTextEditRules::WillInsertText(PRInt32 // don't spaz my selection in subtransactions nsAutoTxnsConserveSelection dontSpazMySelection(mEditor); - nsString tString(*outString); + nsString tString(outString); const PRUnichar *unicodeBuf = tString.get(); nsCOMPtr unused; PRInt32 pos = 0; @@ -816,7 +816,7 @@ nsTextEditRules::WillInsertText(PRInt32 if (NS_FAILED(res)) return res; } } - outString->Assign(tString); + outString.Assign(tString); if (curNode) { @@ -1076,31 +1076,31 @@ nsTextEditRules::DidRedo(nsISelection *a nsresult nsTextEditRules::WillOutputText(nsISelection *aSelection, - const nsAString *aOutputFormat, - nsAString *aOutString, + const nsAString &aOutputFormat, + nsAString &aOutString, PRBool *aCancel, PRBool *aHandled) { // null selection ok - if (!aOutString || !aOutputFormat || !aCancel || !aHandled) + if (!aCancel || !aHandled) { return NS_ERROR_NULL_POINTER; } // initialize out param *aCancel = PR_FALSE; *aHandled = PR_FALSE; - nsAutoString outputFormat(*aOutputFormat); + nsAutoString outputFormat(aOutputFormat); ToLowerCase(outputFormat); if (outputFormat.EqualsLiteral("text/plain")) { // only use these rules for plain text output if (mFlags & nsIPlaintextEditor::eEditorPasswordMask) { - *aOutString = mPasswordText; + aOutString = mPasswordText; *aHandled = PR_TRUE; } else if (mBogusNode) { // this means there's no content, so output null string - aOutString->Truncate(); + aOutString.Truncate(); *aHandled = PR_TRUE; } } @@ -1284,15 +1284,15 @@ nsTextEditRules::CreateBogusNodeIfNeeded nsresult -nsTextEditRules::TruncateInsertionIfNeeded(nsISelection *aSelection, - const nsAString *aInString, - nsAString *aOutString, +nsTextEditRules::TruncateInsertionIfNeeded(nsISelection *aSelection, + const nsAString &aInString, + nsAString &aOutString, PRInt32 aMaxLength) { - if (!aSelection || !aInString || !aOutString) {return NS_ERROR_NULL_POINTER;} + if (!aSelection) {return NS_ERROR_NULL_POINTER;} nsresult res = NS_OK; - *aOutString = *aInString; + aOutString = aInString; if ((-1 != aMaxLength) && (mFlags & nsIPlaintextEditor::eEditorPlaintextMask) && !mEditor->IsIMEComposing() ) @@ -1325,14 +1325,14 @@ nsTextEditRules::TruncateInsertionIfNeed const PRInt32 resultingDocLength = docLength - selectionLength - oldCompStrLength; if (resultingDocLength >= aMaxLength) { - aOutString->Truncate(); + aOutString.Truncate(); } else { - PRInt32 inCount = aOutString->Length(); + PRInt32 inCount = aOutString.Length(); if (inCount + resultingDocLength > aMaxLength) { - aOutString->Truncate(aMaxLength - resultingDocLength); + aOutString.Truncate(aMaxLength - resultingDocLength); } } } @@ -1347,12 +1347,8 @@ nsTextEditRules::ResetIMETextPWBuf() } nsresult -nsTextEditRules::RemoveIMETextFromPWBuf(PRUint32 &aStart, nsAString *aIMEString) +nsTextEditRules::RemoveIMETextFromPWBuf(PRUint32 &aStart, nsAString &aIMEString) { - if (!aIMEString) { - return NS_ERROR_NULL_POINTER; - } - // initialize PasswordIME if (mPasswordIMEText.IsEmpty()) { mPasswordIMEIndex = aStart; @@ -1363,17 +1359,15 @@ nsTextEditRules::RemoveIMETextFromPWBuf( aStart = mPasswordIMEIndex; } - mPasswordIMEText.Assign(*aIMEString); + mPasswordIMEText.Assign(aIMEString); return NS_OK; } nsresult -nsTextEditRules::EchoInsertionToPWBuff(PRInt32 aStart, PRInt32 aEnd, nsAString *aOutString) +nsTextEditRules::EchoInsertionToPWBuff(PRInt32 aStart, PRInt32 aEnd, nsAString &aOutString) { - if (!aOutString) {return NS_ERROR_NULL_POINTER;} - // manage the password buffer - mPasswordText.Insert(*aOutString, aStart); + mPasswordText.Insert(aOutString, aStart); // change the output to the platform password character PRUnichar passwordChar = PRUnichar('*'); @@ -1383,12 +1377,12 @@ nsTextEditRules::EchoInsertionToPWBuff(P passwordChar = lookAndFeel->GetPasswordCharacter(); } - PRInt32 length = aOutString->Length(); + PRInt32 length = aOutString.Length(); PRInt32 i; - aOutString->Truncate(); + aOutString.Truncate(); for (i=0; iAppend(passwordChar); + aOutString.Append(passwordChar); } return NS_OK; diff --git a/editor/libeditor/text/nsTextEditRules.h b/editor/libeditor/text/nsTextEditRules.h --- a/editor/libeditor/text/nsTextEditRules.h +++ b/editor/libeditor/text/nsTextEditRules.h @@ -118,8 +118,8 @@ protected: nsISelection *aSelection, PRBool *aCancel, PRBool *aHandled, - const nsAString *inString, - nsAString *outString, + const nsAString &inString, + nsAString &outString, PRInt32 aMaxLength); nsresult DidInsertText(nsISelection *aSelection, nsresult aResult); nsresult GetTopEnclosingPre(nsIDOMNode *aNode, nsIDOMNode** aOutPreNode); @@ -158,8 +158,8 @@ protected: * and use aOutText as the result. */ nsresult WillOutputText(nsISelection *aSelection, - const nsAString *aInFormat, - nsAString *aOutText, + const nsAString &aInFormat, + nsAString &aOutText, PRBool *aOutCancel, PRBool *aHandled); @@ -180,16 +180,16 @@ protected: /** returns a truncated insertion string if insertion would place us over aMaxLength */ nsresult TruncateInsertionIfNeeded(nsISelection *aSelection, - const nsAString *aInString, - nsAString *aOutString, + const nsAString &aInString, + nsAString &aOutString, PRInt32 aMaxLength); /** Echo's the insertion text into the password buffer, and converts insertion text to '*'s */ - nsresult EchoInsertionToPWBuff(PRInt32 aStart, PRInt32 aEnd, nsAString *aOutString); + nsresult EchoInsertionToPWBuff(PRInt32 aStart, PRInt32 aEnd, nsAString &aOutString); /** Remove IME composition text from password buffer */ - nsresult RemoveIMETextFromPWBuf(PRUint32 &aStart, nsAString *aIMEString); + nsresult RemoveIMETextFromPWBuf(PRUint32 &aStart, nsAString &aIMEString); nsresult CreateMozBR(nsIDOMNode *inParent, PRInt32 inOffset, nsCOMPtr *outBRNode); @@ -229,25 +229,19 @@ class nsTextRulesInfo : public nsRulesIn nsTextRulesInfo(int aAction) : nsRulesInfo(aAction), - inString(0), - outString(0), - outputFormat(0), maxLength(-1), collapsedAction(nsIEditor::eNext), bOrdered(PR_FALSE), entireList(PR_FALSE), - bulletType(0), - alignType(0), - blockType(0), - insertElement(0) + insertElement(nsnull) {} virtual ~nsTextRulesInfo() {} // kInsertText - const nsAString *inString; - nsAString *outString; - const nsAString *outputFormat; + nsString inString; + nsString outString; + nsString outputFormat; PRInt32 maxLength; // kDeleteSelection @@ -256,13 +250,13 @@ class nsTextRulesInfo : public nsRulesIn // kMakeList PRBool bOrdered; PRBool entireList; - const nsAString *bulletType; + nsString bulletType; // kAlign - const nsAString *alignType; + nsString alignType; // kMakeBasicBlock - const nsAString *blockType; + nsString blockType; // kInsertElement const nsIDOMElement* insertElement;