зеркало из https://github.com/mozilla/pjs.git
76442 sr= scc r= anthonyd. last minute fixes to editor to not do stupid copies and instead to use new case insensitive string compares.
This commit is contained in:
Родитель
39003ffb2a
Коммит
9692e7d349
|
@ -24,6 +24,7 @@
|
||||||
#include "nsAOLCiter.h"
|
#include "nsAOLCiter.h"
|
||||||
|
|
||||||
#include "nsWrapUtils.h"
|
#include "nsWrapUtils.h"
|
||||||
|
#include "nsReadableUtils.h"
|
||||||
|
|
||||||
/** Mail citations using the AOL style >> This is a citation <<
|
/** Mail citations using the AOL style >> This is a citation <<
|
||||||
*/
|
*/
|
||||||
|
@ -86,17 +87,19 @@ NS_IMETHODIMP
|
||||||
nsAOLCiter::StripCites(const nsAReadableString& aInString, nsAWritableString& aOutString)
|
nsAOLCiter::StripCites(const nsAReadableString& aInString, nsAWritableString& aOutString)
|
||||||
{
|
{
|
||||||
// Remove the beginning cites, if any:
|
// Remove the beginning cites, if any:
|
||||||
nsAutoString tInputString(aInString);//MJUDGE SCC NEED HELP
|
|
||||||
nsAutoString tOutputString;
|
nsAutoString tOutputString;
|
||||||
if (tInputString.EqualsWithConversion(">>", PR_FALSE, 2))
|
nsReadingIterator <PRUnichar> iter,enditer;
|
||||||
|
aInString.BeginReading(iter);
|
||||||
|
aInString.EndReading(enditer);
|
||||||
|
if (!Compare(Substring(aInString,0,2),NS_LITERAL_STRING(">>")))
|
||||||
{
|
{
|
||||||
PRInt32 i = 3;
|
iter.advance(2);
|
||||||
while (nsCRT::IsAsciiSpace(tInputString[i]))
|
while (nsCRT::IsAsciiSpace(*iter))
|
||||||
++i;
|
++iter;
|
||||||
tOutputString.Append(tInputString.GetUnicode(), i);
|
AppendUnicodeTo(iter,enditer,tOutputString);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
tOutputString = tInputString;
|
CopyUnicodeTo(iter,enditer,tOutputString);
|
||||||
|
|
||||||
// Remove the end cites, if any:
|
// Remove the end cites, if any:
|
||||||
tOutputString.Trim("<", PR_FALSE, PR_TRUE, PR_FALSE);
|
tOutputString.Trim("<", PR_FALSE, PR_TRUE, PR_FALSE);
|
||||||
|
|
|
@ -1931,10 +1931,9 @@ nsHTMLEditRules::WillMakeList(nsISelection *aSelection,
|
||||||
|
|
||||||
// deduce what tag to use for list items
|
// deduce what tag to use for list items
|
||||||
nsAutoString itemType;
|
nsAutoString itemType;
|
||||||
nsString tString(*aListType);//MJUDGE SCC NEED HELP
|
|
||||||
if (aItemType)
|
if (aItemType)
|
||||||
itemType = *aItemType;
|
itemType = *aItemType;
|
||||||
else if (tString.EqualsWithConversion("dl"))
|
else if (!Compare(*aListType,NS_LITERAL_STRING("dl"),nsCaseInsensitiveStringComparator()))
|
||||||
itemType.AssignWithConversion("dd");
|
itemType.AssignWithConversion("dd");
|
||||||
else
|
else
|
||||||
itemType.AssignWithConversion("li");
|
itemType.AssignWithConversion("li");
|
||||||
|
@ -4598,7 +4597,9 @@ nsHTMLEditRules::ApplyBlockStyle(nsISupportsArray *arrayOfNodes, const nsAReadab
|
||||||
// we special case an empty tag name to mean "remove block parents".
|
// we special case an empty tag name to mean "remove block parents".
|
||||||
// This is used for the "normal" paragraph style in mail-compose
|
// This is used for the "normal" paragraph style in mail-compose
|
||||||
nsString tString(*aBlockTag);////MJUDGE SCC NEED HELP
|
nsString tString(*aBlockTag);////MJUDGE SCC NEED HELP
|
||||||
if (tString.IsEmpty() || tString.EqualsWithConversion("normal")) bNoParent = PR_TRUE;
|
if (tString.IsEmpty() ||
|
||||||
|
!Compare(tString,NS_LITERAL_STRING("normal"),nsCaseInsensitiveStringComparator()))
|
||||||
|
bNoParent = PR_TRUE;
|
||||||
|
|
||||||
arrayOfNodes->Count(&listCount);
|
arrayOfNodes->Count(&listCount);
|
||||||
|
|
||||||
|
@ -4690,8 +4691,8 @@ nsHTMLEditRules::ApplyBlockStyle(nsISupportsArray *arrayOfNodes, const nsAReadab
|
||||||
else if (IsInlineNode(curNode) && !bNoParent)
|
else if (IsInlineNode(curNode) && !bNoParent)
|
||||||
{
|
{
|
||||||
// if curNode is a non editable, drop it if we are going to <pre>
|
// if curNode is a non editable, drop it if we are going to <pre>
|
||||||
nsString tString(*aBlockTag); ////MJUDGE SCC NEED HELP
|
if (!Compare(tString,NS_LITERAL_STRING("pre"),nsCaseInsensitiveStringComparator())
|
||||||
if ((tString.EqualsWithConversion("pre")) && (!mHTMLEditor->IsEditable(curNode)))
|
&& (!mHTMLEditor->IsEditable(curNode)))
|
||||||
continue; // do nothing to this block
|
continue; // do nothing to this block
|
||||||
|
|
||||||
// if no curBlock, make one
|
// if no curBlock, make one
|
||||||
|
@ -5490,14 +5491,15 @@ nsresult
|
||||||
nsHTMLEditRules::ConvertWhitespace(const nsAReadableString & inString, nsAWritableString & outString)
|
nsHTMLEditRules::ConvertWhitespace(const nsAReadableString & inString, nsAWritableString & outString)
|
||||||
{
|
{
|
||||||
PRUint32 j,len = inString.Length();
|
PRUint32 j,len = inString.Length();
|
||||||
nsString tString(inString);////MJUDGE SCC NEED HELP
|
nsReadingIterator <PRUnichar> iter;
|
||||||
|
inString.BeginReading(iter);
|
||||||
switch (len)
|
switch (len)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
outString.SetLength(0);
|
outString.SetLength(0);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
case 1:
|
case 1:
|
||||||
if (tString.EqualsWithConversion("\n")) // a bit of a hack: don't convert single newlines that
|
if (*iter == '\n') // a bit of a hack: don't convert single newlines that
|
||||||
outString.Assign(NS_LITERAL_STRING("\n")); // dont have whitespace adjacent. This is to preserve
|
outString.Assign(NS_LITERAL_STRING("\n")); // dont have whitespace adjacent. This is to preserve
|
||||||
else // html source formatting to some degree.
|
else // html source formatting to some degree.
|
||||||
outString.Assign(NS_LITERAL_STRING(" "));
|
outString.Assign(NS_LITERAL_STRING(" "));
|
||||||
|
|
|
@ -2226,8 +2226,8 @@ nsHTMLEditor::RemoveList(const nsAReadableString& aListType)
|
||||||
if (!selection) return NS_ERROR_NULL_POINTER;
|
if (!selection) return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
nsTextRulesInfo ruleInfo(nsTextEditRules::kRemoveList);
|
nsTextRulesInfo ruleInfo(nsTextEditRules::kRemoveList);
|
||||||
nsString tString(aListType);//MJUDGE SCC NEED HELP
|
if (!Compare(aListType,NS_LITERAL_STRING("ol"),nsCaseInsensitiveStringComparator()))
|
||||||
if (tString.EqualsWithConversion("ol")) ruleInfo.bOrdered = PR_TRUE;
|
ruleInfo.bOrdered = PR_TRUE;
|
||||||
else ruleInfo.bOrdered = PR_FALSE;
|
else ruleInfo.bOrdered = PR_FALSE;
|
||||||
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||||
if (cancel || (NS_FAILED(res))) return res;
|
if (cancel || (NS_FAILED(res))) return res;
|
||||||
|
@ -2349,8 +2349,7 @@ nsHTMLEditor::Indent(const nsAReadableString& aIndent)
|
||||||
PRBool cancel, handled;
|
PRBool cancel, handled;
|
||||||
PRInt32 theAction = nsTextEditRules::kIndent;
|
PRInt32 theAction = nsTextEditRules::kIndent;
|
||||||
PRInt32 opID = kOpIndent;
|
PRInt32 opID = kOpIndent;
|
||||||
nsString tString(aIndent);//MJUDGE SCC NEED HELP
|
if (!Compare(aIndent,NS_LITERAL_STRING("outdent"),nsCaseInsensitiveStringComparator()))
|
||||||
if (tString.EqualsWithConversion("outdent"))
|
|
||||||
{
|
{
|
||||||
theAction = nsTextEditRules::kOutdent;
|
theAction = nsTextEditRules::kOutdent;
|
||||||
opID = kOpOutdent;
|
opID = kOpOutdent;
|
||||||
|
@ -3536,26 +3535,20 @@ PRBool
|
||||||
nsHTMLEditor::TagCanContainTag(const nsAReadableString& aParentTag, const nsAReadableString& aChildTag)
|
nsHTMLEditor::TagCanContainTag(const nsAReadableString& aParentTag, const nsAReadableString& aChildTag)
|
||||||
{
|
{
|
||||||
// COtherDTD gives some unwanted results. We override them here.
|
// COtherDTD gives some unwanted results. We override them here.
|
||||||
nsAutoString olStr, ulStr, liStr;
|
if (!Compare(aParentTag,NS_LITERAL_STRING("ol"),nsCaseInsensitiveStringComparator()) ||
|
||||||
olStr = NS_LITERAL_STRING("ol");
|
!Compare(aParentTag,NS_LITERAL_STRING("ul"),nsCaseInsensitiveStringComparator()))
|
||||||
ulStr = NS_LITERAL_STRING("ul");
|
|
||||||
liStr = NS_LITERAL_STRING("li");
|
|
||||||
nsString tParent(aParentTag);//MJUDGE SCC NEED HELP
|
|
||||||
nsString tChild(aChildTag);//MJUDGE SCC NEED HELP
|
|
||||||
if ( tParent.EqualsIgnoreCase(olStr) ||
|
|
||||||
tParent.EqualsIgnoreCase(ulStr) )
|
|
||||||
{
|
{
|
||||||
// if parent is a list and tag is also a list, say "yes".
|
// if parent is a list and tag is also a list, say "yes".
|
||||||
// This is because the editor does sublists illegally for now.
|
// This is because the editor does sublists illegally for now.
|
||||||
if (tChild.EqualsIgnoreCase(olStr) ||
|
if (!Compare(aChildTag,NS_LITERAL_STRING("ol"),nsCaseInsensitiveStringComparator()) ||
|
||||||
tChild.EqualsIgnoreCase(ulStr) )
|
!Compare(aChildTag,NS_LITERAL_STRING("ul"),nsCaseInsensitiveStringComparator()))
|
||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( tParent.EqualsIgnoreCase(liStr) )
|
if (!Compare(aParentTag,NS_LITERAL_STRING("li"),nsCaseInsensitiveStringComparator()))
|
||||||
{
|
{
|
||||||
// list items cant contain list items
|
// list items cant contain list items
|
||||||
if (tChild.EqualsIgnoreCase(liStr) )
|
if (!Compare(aChildTag,NS_LITERAL_STRING("li"),nsCaseInsensitiveStringComparator()))
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -582,7 +582,6 @@ PRBool nsHTMLEditor::IsOnlyAttribute(nsIDOMNode *aNode,
|
||||||
nsCOMPtr<nsIAtom> attrName, prefix;
|
nsCOMPtr<nsIAtom> attrName, prefix;
|
||||||
content->GetAttributeCount(attrCount);
|
content->GetAttributeCount(attrCount);
|
||||||
|
|
||||||
nsString tString(*aAttribute);//MJUDGE SCC NEED HELP
|
|
||||||
for (i=0; i<attrCount; i++)
|
for (i=0; i<attrCount; i++)
|
||||||
{
|
{
|
||||||
content->GetAttributeNameAt(i, nameSpaceID, *getter_AddRefs(attrName),
|
content->GetAttributeNameAt(i, nameSpaceID, *getter_AddRefs(attrName),
|
||||||
|
@ -591,10 +590,10 @@ PRBool nsHTMLEditor::IsOnlyAttribute(nsIDOMNode *aNode,
|
||||||
if (!attrName) continue; // ooops
|
if (!attrName) continue; // ooops
|
||||||
attrName->ToString(attrString);
|
attrName->ToString(attrString);
|
||||||
// if it's the attribute we know about, keep looking
|
// if it's the attribute we know about, keep looking
|
||||||
if (attrString.EqualsIgnoreCase(tString)) continue;
|
if (!Compare(attrString,*aAttribute,nsCaseInsensitiveStringComparator())) continue;
|
||||||
// if it's a special _moz... attribute, keep looking
|
// if it's a special _moz... attribute, keep looking
|
||||||
attrString.Left(tmp,4);
|
attrString.Left(tmp,4);
|
||||||
if (tmp.EqualsWithConversion("_moz")) continue;
|
if (!Compare(attrString,NS_LITERAL_STRING("_moz"),nsCaseInsensitiveStringComparator())) continue;
|
||||||
// otherwise, it's another attribute, so return false
|
// otherwise, it's another attribute, so return false
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
@ -702,8 +701,7 @@ PRBool nsHTMLEditor::HasAttrVal(nsIDOMNode *aNode,
|
||||||
attNode->GetValue(attrVal);
|
attNode->GetValue(attrVal);
|
||||||
|
|
||||||
// do values match?
|
// do values match?
|
||||||
nsString tString(*aValue);//MJUDGE SCC NEED HELP
|
if (!Compare(attrVal,*aValue,nsCaseInsensitiveStringComparator())) return PR_TRUE;
|
||||||
if (attrVal.EqualsIgnoreCase(tString)) return PR_TRUE;
|
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -126,39 +126,34 @@ nsInternetCiter::StripCitesAndLinebreaks(const nsAReadableString& aInString,
|
||||||
*aCiteLevel = 0;
|
*aCiteLevel = 0;
|
||||||
|
|
||||||
aOutString.SetLength(0);
|
aOutString.SetLength(0);
|
||||||
|
nsReadingIterator <PRUnichar> beginIter,endIter;
|
||||||
nsString tString(aInString);//CRAPCRAP
|
aInString.BeginReading(beginIter);
|
||||||
PRInt32 length = tString.Length();
|
aInString.EndReading(endIter);
|
||||||
|
PRInt32 length = aInString.Length();
|
||||||
PRInt32 i = 0;
|
PRInt32 i = 0;
|
||||||
while (i < length) // loop over lines
|
while (beginIter!= endIter) // loop over lines
|
||||||
{
|
{
|
||||||
// Clear out cites first, at the beginning of the line:
|
// Clear out cites first, at the beginning of the line:
|
||||||
PRInt32 thisLineCiteLevel = 0;
|
PRInt32 thisLineCiteLevel = 0;
|
||||||
while (tString[i] == gt || nsCRT::IsAsciiSpace(tString[i]))
|
while (beginIter!= endIter && (*beginIter == gt || nsCRT::IsAsciiSpace(*beginIter)))
|
||||||
{
|
{
|
||||||
if (tString[i] == gt) ++thisLineCiteLevel;
|
if (*beginIter == gt) ++thisLineCiteLevel;
|
||||||
++i;
|
++beginIter;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now copy characters until line end:
|
// Now copy characters until line end:
|
||||||
PRInt32 nextNewline = tString.FindCharInSet("\r\n", i);
|
while (beginIter != endIter && (*beginIter != '\r' && *beginIter != '\n'))
|
||||||
if (nextNewline > i)
|
|
||||||
{
|
{
|
||||||
while (i < nextNewline)
|
aOutString.Append(*beginIter);
|
||||||
aOutString.Append(tString[i++]);
|
++beginIter;
|
||||||
|
}
|
||||||
if (aLinebreaksToo)
|
if (aLinebreaksToo)
|
||||||
aOutString.Append(PRUnichar(' '));
|
aOutString.Append(PRUnichar(' '));
|
||||||
else
|
else
|
||||||
aOutString.Append(PRUnichar('\n')); // DOM linebreaks, not NS_LINEBREAK
|
aOutString.Append(PRUnichar('\n')); // DOM linebreaks, not NS_LINEBREAK
|
||||||
// Skip over any more consecutive linebreak-like characters:
|
// Skip over any more consecutive linebreak-like characters:
|
||||||
while (i < length && (tString[i] == '\r' || tString[i] == '\n'))
|
while (beginIter != endIter && (*beginIter == '\r' || *beginIter == '\n'))
|
||||||
++i;
|
++beginIter;
|
||||||
}
|
|
||||||
else // no more newlines
|
|
||||||
{
|
|
||||||
while (i < length)
|
|
||||||
aOutString.Append(tString[i++]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Done with this line -- update cite level
|
// Done with this line -- update cite level
|
||||||
if (aCiteLevel && (thisLineCiteLevel > *aCiteLevel))
|
if (aCiteLevel && (thisLineCiteLevel > *aCiteLevel))
|
||||||
|
|
|
@ -1931,10 +1931,9 @@ nsHTMLEditRules::WillMakeList(nsISelection *aSelection,
|
||||||
|
|
||||||
// deduce what tag to use for list items
|
// deduce what tag to use for list items
|
||||||
nsAutoString itemType;
|
nsAutoString itemType;
|
||||||
nsString tString(*aListType);//MJUDGE SCC NEED HELP
|
|
||||||
if (aItemType)
|
if (aItemType)
|
||||||
itemType = *aItemType;
|
itemType = *aItemType;
|
||||||
else if (tString.EqualsWithConversion("dl"))
|
else if (!Compare(*aListType,NS_LITERAL_STRING("dl"),nsCaseInsensitiveStringComparator()))
|
||||||
itemType.AssignWithConversion("dd");
|
itemType.AssignWithConversion("dd");
|
||||||
else
|
else
|
||||||
itemType.AssignWithConversion("li");
|
itemType.AssignWithConversion("li");
|
||||||
|
@ -4598,7 +4597,9 @@ nsHTMLEditRules::ApplyBlockStyle(nsISupportsArray *arrayOfNodes, const nsAReadab
|
||||||
// we special case an empty tag name to mean "remove block parents".
|
// we special case an empty tag name to mean "remove block parents".
|
||||||
// This is used for the "normal" paragraph style in mail-compose
|
// This is used for the "normal" paragraph style in mail-compose
|
||||||
nsString tString(*aBlockTag);////MJUDGE SCC NEED HELP
|
nsString tString(*aBlockTag);////MJUDGE SCC NEED HELP
|
||||||
if (tString.IsEmpty() || tString.EqualsWithConversion("normal")) bNoParent = PR_TRUE;
|
if (tString.IsEmpty() ||
|
||||||
|
!Compare(tString,NS_LITERAL_STRING("normal"),nsCaseInsensitiveStringComparator()))
|
||||||
|
bNoParent = PR_TRUE;
|
||||||
|
|
||||||
arrayOfNodes->Count(&listCount);
|
arrayOfNodes->Count(&listCount);
|
||||||
|
|
||||||
|
@ -4690,8 +4691,8 @@ nsHTMLEditRules::ApplyBlockStyle(nsISupportsArray *arrayOfNodes, const nsAReadab
|
||||||
else if (IsInlineNode(curNode) && !bNoParent)
|
else if (IsInlineNode(curNode) && !bNoParent)
|
||||||
{
|
{
|
||||||
// if curNode is a non editable, drop it if we are going to <pre>
|
// if curNode is a non editable, drop it if we are going to <pre>
|
||||||
nsString tString(*aBlockTag); ////MJUDGE SCC NEED HELP
|
if (!Compare(tString,NS_LITERAL_STRING("pre"),nsCaseInsensitiveStringComparator())
|
||||||
if ((tString.EqualsWithConversion("pre")) && (!mHTMLEditor->IsEditable(curNode)))
|
&& (!mHTMLEditor->IsEditable(curNode)))
|
||||||
continue; // do nothing to this block
|
continue; // do nothing to this block
|
||||||
|
|
||||||
// if no curBlock, make one
|
// if no curBlock, make one
|
||||||
|
@ -5490,14 +5491,15 @@ nsresult
|
||||||
nsHTMLEditRules::ConvertWhitespace(const nsAReadableString & inString, nsAWritableString & outString)
|
nsHTMLEditRules::ConvertWhitespace(const nsAReadableString & inString, nsAWritableString & outString)
|
||||||
{
|
{
|
||||||
PRUint32 j,len = inString.Length();
|
PRUint32 j,len = inString.Length();
|
||||||
nsString tString(inString);////MJUDGE SCC NEED HELP
|
nsReadingIterator <PRUnichar> iter;
|
||||||
|
inString.BeginReading(iter);
|
||||||
switch (len)
|
switch (len)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
outString.SetLength(0);
|
outString.SetLength(0);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
case 1:
|
case 1:
|
||||||
if (tString.EqualsWithConversion("\n")) // a bit of a hack: don't convert single newlines that
|
if (*iter == '\n') // a bit of a hack: don't convert single newlines that
|
||||||
outString.Assign(NS_LITERAL_STRING("\n")); // dont have whitespace adjacent. This is to preserve
|
outString.Assign(NS_LITERAL_STRING("\n")); // dont have whitespace adjacent. This is to preserve
|
||||||
else // html source formatting to some degree.
|
else // html source formatting to some degree.
|
||||||
outString.Assign(NS_LITERAL_STRING(" "));
|
outString.Assign(NS_LITERAL_STRING(" "));
|
||||||
|
|
|
@ -2226,8 +2226,8 @@ nsHTMLEditor::RemoveList(const nsAReadableString& aListType)
|
||||||
if (!selection) return NS_ERROR_NULL_POINTER;
|
if (!selection) return NS_ERROR_NULL_POINTER;
|
||||||
|
|
||||||
nsTextRulesInfo ruleInfo(nsTextEditRules::kRemoveList);
|
nsTextRulesInfo ruleInfo(nsTextEditRules::kRemoveList);
|
||||||
nsString tString(aListType);//MJUDGE SCC NEED HELP
|
if (!Compare(aListType,NS_LITERAL_STRING("ol"),nsCaseInsensitiveStringComparator()))
|
||||||
if (tString.EqualsWithConversion("ol")) ruleInfo.bOrdered = PR_TRUE;
|
ruleInfo.bOrdered = PR_TRUE;
|
||||||
else ruleInfo.bOrdered = PR_FALSE;
|
else ruleInfo.bOrdered = PR_FALSE;
|
||||||
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
res = mRules->WillDoAction(selection, &ruleInfo, &cancel, &handled);
|
||||||
if (cancel || (NS_FAILED(res))) return res;
|
if (cancel || (NS_FAILED(res))) return res;
|
||||||
|
@ -2349,8 +2349,7 @@ nsHTMLEditor::Indent(const nsAReadableString& aIndent)
|
||||||
PRBool cancel, handled;
|
PRBool cancel, handled;
|
||||||
PRInt32 theAction = nsTextEditRules::kIndent;
|
PRInt32 theAction = nsTextEditRules::kIndent;
|
||||||
PRInt32 opID = kOpIndent;
|
PRInt32 opID = kOpIndent;
|
||||||
nsString tString(aIndent);//MJUDGE SCC NEED HELP
|
if (!Compare(aIndent,NS_LITERAL_STRING("outdent"),nsCaseInsensitiveStringComparator()))
|
||||||
if (tString.EqualsWithConversion("outdent"))
|
|
||||||
{
|
{
|
||||||
theAction = nsTextEditRules::kOutdent;
|
theAction = nsTextEditRules::kOutdent;
|
||||||
opID = kOpOutdent;
|
opID = kOpOutdent;
|
||||||
|
@ -3536,26 +3535,20 @@ PRBool
|
||||||
nsHTMLEditor::TagCanContainTag(const nsAReadableString& aParentTag, const nsAReadableString& aChildTag)
|
nsHTMLEditor::TagCanContainTag(const nsAReadableString& aParentTag, const nsAReadableString& aChildTag)
|
||||||
{
|
{
|
||||||
// COtherDTD gives some unwanted results. We override them here.
|
// COtherDTD gives some unwanted results. We override them here.
|
||||||
nsAutoString olStr, ulStr, liStr;
|
if (!Compare(aParentTag,NS_LITERAL_STRING("ol"),nsCaseInsensitiveStringComparator()) ||
|
||||||
olStr = NS_LITERAL_STRING("ol");
|
!Compare(aParentTag,NS_LITERAL_STRING("ul"),nsCaseInsensitiveStringComparator()))
|
||||||
ulStr = NS_LITERAL_STRING("ul");
|
|
||||||
liStr = NS_LITERAL_STRING("li");
|
|
||||||
nsString tParent(aParentTag);//MJUDGE SCC NEED HELP
|
|
||||||
nsString tChild(aChildTag);//MJUDGE SCC NEED HELP
|
|
||||||
if ( tParent.EqualsIgnoreCase(olStr) ||
|
|
||||||
tParent.EqualsIgnoreCase(ulStr) )
|
|
||||||
{
|
{
|
||||||
// if parent is a list and tag is also a list, say "yes".
|
// if parent is a list and tag is also a list, say "yes".
|
||||||
// This is because the editor does sublists illegally for now.
|
// This is because the editor does sublists illegally for now.
|
||||||
if (tChild.EqualsIgnoreCase(olStr) ||
|
if (!Compare(aChildTag,NS_LITERAL_STRING("ol"),nsCaseInsensitiveStringComparator()) ||
|
||||||
tChild.EqualsIgnoreCase(ulStr) )
|
!Compare(aChildTag,NS_LITERAL_STRING("ul"),nsCaseInsensitiveStringComparator()))
|
||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( tParent.EqualsIgnoreCase(liStr) )
|
if (!Compare(aParentTag,NS_LITERAL_STRING("li"),nsCaseInsensitiveStringComparator()))
|
||||||
{
|
{
|
||||||
// list items cant contain list items
|
// list items cant contain list items
|
||||||
if (tChild.EqualsIgnoreCase(liStr) )
|
if (!Compare(aChildTag,NS_LITERAL_STRING("li"),nsCaseInsensitiveStringComparator()))
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -582,7 +582,6 @@ PRBool nsHTMLEditor::IsOnlyAttribute(nsIDOMNode *aNode,
|
||||||
nsCOMPtr<nsIAtom> attrName, prefix;
|
nsCOMPtr<nsIAtom> attrName, prefix;
|
||||||
content->GetAttributeCount(attrCount);
|
content->GetAttributeCount(attrCount);
|
||||||
|
|
||||||
nsString tString(*aAttribute);//MJUDGE SCC NEED HELP
|
|
||||||
for (i=0; i<attrCount; i++)
|
for (i=0; i<attrCount; i++)
|
||||||
{
|
{
|
||||||
content->GetAttributeNameAt(i, nameSpaceID, *getter_AddRefs(attrName),
|
content->GetAttributeNameAt(i, nameSpaceID, *getter_AddRefs(attrName),
|
||||||
|
@ -591,10 +590,10 @@ PRBool nsHTMLEditor::IsOnlyAttribute(nsIDOMNode *aNode,
|
||||||
if (!attrName) continue; // ooops
|
if (!attrName) continue; // ooops
|
||||||
attrName->ToString(attrString);
|
attrName->ToString(attrString);
|
||||||
// if it's the attribute we know about, keep looking
|
// if it's the attribute we know about, keep looking
|
||||||
if (attrString.EqualsIgnoreCase(tString)) continue;
|
if (!Compare(attrString,*aAttribute,nsCaseInsensitiveStringComparator())) continue;
|
||||||
// if it's a special _moz... attribute, keep looking
|
// if it's a special _moz... attribute, keep looking
|
||||||
attrString.Left(tmp,4);
|
attrString.Left(tmp,4);
|
||||||
if (tmp.EqualsWithConversion("_moz")) continue;
|
if (!Compare(attrString,NS_LITERAL_STRING("_moz"),nsCaseInsensitiveStringComparator())) continue;
|
||||||
// otherwise, it's another attribute, so return false
|
// otherwise, it's another attribute, so return false
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
@ -702,8 +701,7 @@ PRBool nsHTMLEditor::HasAttrVal(nsIDOMNode *aNode,
|
||||||
attNode->GetValue(attrVal);
|
attNode->GetValue(attrVal);
|
||||||
|
|
||||||
// do values match?
|
// do values match?
|
||||||
nsString tString(*aValue);//MJUDGE SCC NEED HELP
|
if (!Compare(attrVal,*aValue,nsCaseInsensitiveStringComparator())) return PR_TRUE;
|
||||||
if (attrVal.EqualsIgnoreCase(tString)) return PR_TRUE;
|
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "nsAOLCiter.h"
|
#include "nsAOLCiter.h"
|
||||||
|
|
||||||
#include "nsWrapUtils.h"
|
#include "nsWrapUtils.h"
|
||||||
|
#include "nsReadableUtils.h"
|
||||||
|
|
||||||
/** Mail citations using the AOL style >> This is a citation <<
|
/** Mail citations using the AOL style >> This is a citation <<
|
||||||
*/
|
*/
|
||||||
|
@ -86,17 +87,19 @@ NS_IMETHODIMP
|
||||||
nsAOLCiter::StripCites(const nsAReadableString& aInString, nsAWritableString& aOutString)
|
nsAOLCiter::StripCites(const nsAReadableString& aInString, nsAWritableString& aOutString)
|
||||||
{
|
{
|
||||||
// Remove the beginning cites, if any:
|
// Remove the beginning cites, if any:
|
||||||
nsAutoString tInputString(aInString);//MJUDGE SCC NEED HELP
|
|
||||||
nsAutoString tOutputString;
|
nsAutoString tOutputString;
|
||||||
if (tInputString.EqualsWithConversion(">>", PR_FALSE, 2))
|
nsReadingIterator <PRUnichar> iter,enditer;
|
||||||
|
aInString.BeginReading(iter);
|
||||||
|
aInString.EndReading(enditer);
|
||||||
|
if (!Compare(Substring(aInString,0,2),NS_LITERAL_STRING(">>")))
|
||||||
{
|
{
|
||||||
PRInt32 i = 3;
|
iter.advance(2);
|
||||||
while (nsCRT::IsAsciiSpace(tInputString[i]))
|
while (nsCRT::IsAsciiSpace(*iter))
|
||||||
++i;
|
++iter;
|
||||||
tOutputString.Append(tInputString.GetUnicode(), i);
|
AppendUnicodeTo(iter,enditer,tOutputString);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
tOutputString = tInputString;
|
CopyUnicodeTo(iter,enditer,tOutputString);
|
||||||
|
|
||||||
// Remove the end cites, if any:
|
// Remove the end cites, if any:
|
||||||
tOutputString.Trim("<", PR_FALSE, PR_TRUE, PR_FALSE);
|
tOutputString.Trim("<", PR_FALSE, PR_TRUE, PR_FALSE);
|
||||||
|
|
|
@ -126,39 +126,34 @@ nsInternetCiter::StripCitesAndLinebreaks(const nsAReadableString& aInString,
|
||||||
*aCiteLevel = 0;
|
*aCiteLevel = 0;
|
||||||
|
|
||||||
aOutString.SetLength(0);
|
aOutString.SetLength(0);
|
||||||
|
nsReadingIterator <PRUnichar> beginIter,endIter;
|
||||||
nsString tString(aInString);//CRAPCRAP
|
aInString.BeginReading(beginIter);
|
||||||
PRInt32 length = tString.Length();
|
aInString.EndReading(endIter);
|
||||||
|
PRInt32 length = aInString.Length();
|
||||||
PRInt32 i = 0;
|
PRInt32 i = 0;
|
||||||
while (i < length) // loop over lines
|
while (beginIter!= endIter) // loop over lines
|
||||||
{
|
{
|
||||||
// Clear out cites first, at the beginning of the line:
|
// Clear out cites first, at the beginning of the line:
|
||||||
PRInt32 thisLineCiteLevel = 0;
|
PRInt32 thisLineCiteLevel = 0;
|
||||||
while (tString[i] == gt || nsCRT::IsAsciiSpace(tString[i]))
|
while (beginIter!= endIter && (*beginIter == gt || nsCRT::IsAsciiSpace(*beginIter)))
|
||||||
{
|
{
|
||||||
if (tString[i] == gt) ++thisLineCiteLevel;
|
if (*beginIter == gt) ++thisLineCiteLevel;
|
||||||
++i;
|
++beginIter;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now copy characters until line end:
|
// Now copy characters until line end:
|
||||||
PRInt32 nextNewline = tString.FindCharInSet("\r\n", i);
|
while (beginIter != endIter && (*beginIter != '\r' && *beginIter != '\n'))
|
||||||
if (nextNewline > i)
|
|
||||||
{
|
{
|
||||||
while (i < nextNewline)
|
aOutString.Append(*beginIter);
|
||||||
aOutString.Append(tString[i++]);
|
++beginIter;
|
||||||
|
}
|
||||||
if (aLinebreaksToo)
|
if (aLinebreaksToo)
|
||||||
aOutString.Append(PRUnichar(' '));
|
aOutString.Append(PRUnichar(' '));
|
||||||
else
|
else
|
||||||
aOutString.Append(PRUnichar('\n')); // DOM linebreaks, not NS_LINEBREAK
|
aOutString.Append(PRUnichar('\n')); // DOM linebreaks, not NS_LINEBREAK
|
||||||
// Skip over any more consecutive linebreak-like characters:
|
// Skip over any more consecutive linebreak-like characters:
|
||||||
while (i < length && (tString[i] == '\r' || tString[i] == '\n'))
|
while (beginIter != endIter && (*beginIter == '\r' || *beginIter == '\n'))
|
||||||
++i;
|
++beginIter;
|
||||||
}
|
|
||||||
else // no more newlines
|
|
||||||
{
|
|
||||||
while (i < length)
|
|
||||||
aOutString.Append(tString[i++]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Done with this line -- update cite level
|
// Done with this line -- update cite level
|
||||||
if (aCiteLevel && (thisLineCiteLevel > *aCiteLevel))
|
if (aCiteLevel && (thisLineCiteLevel > *aCiteLevel))
|
||||||
|
|
Загрузка…
Ссылка в новой задаче