13669: password data wrong if user types with 1 or more chars selec...

my bad, I make the assumption everywhere that start>=end at the end of
  GetTextSelectionOffsets().  Now I enforce that restriction before returning.

14430: partial fix for misbehaving inline attribute code
This commit is contained in:
buster%netscape.com 1999-09-23 04:01:10 +00:00
Родитель 6512bae35c
Коммит e453f8e46f
4 изменённых файлов: 52 добавлений и 4 удалений

Просмотреть файл

@ -3895,6 +3895,16 @@ nsresult nsHTMLEditor::GetAbsoluteOffsetsForPoints(nsIDOMNode *aInStartNode,
if (-1==aOutEndOffset) {
aOutEndOffset = totalLength;
}
// guarantee that aOutStartOffset <= aOutEndOffset
if (aOutEndOffset<aOutStartOffset)
{
PRInt32 temp;
temp = aOutStartOffset;
aOutStartOffset= aOutEndOffset;
aOutEndOffset = temp;
}
NS_POSTCONDITION(aOutStartOffset <= aOutEndOffset, "start > end");
return result;
}
@ -5419,6 +5429,15 @@ nsHTMLEditor::MoveContiguousContentIntoNewParent(nsIDOMNode *aStartNode,
return result;
}
NS_IMETHODIMP nsHTMLEditor::IsLeafThatTakesInlineStyle(const nsString *aTag,
PRBool &aResult)
{
if (!aTag) { return NS_ERROR_NULL_POINTER; }
aResult = (PRBool)((PR_FALSE==aTag->EqualsIgnoreCase("br")) &&
(PR_FALSE==aTag->EqualsIgnoreCase("hr")) );
return NS_OK;
}
/* this wraps every selected text node in a new inline style node if needed
the text nodes are treated as being unique -- each needs it's own style node
@ -5521,8 +5540,11 @@ nsHTMLEditor::SetTextPropertiesForNodeWithDifferentParents(nsIDOMRange *aRange,
if (PR_FALSE==canContainChildren)
{
nsEditor::GetTagString(node,tag);
if (tag != "br") // skip <BR>, even though it's a leaf
{ // only want to wrap the text node in a new style node if it doesn't already have that style
PRBool processLeaf;
IsLeafThatTakesInlineStyle(&tag, processLeaf);
if (processLeaf) // skip leaf tags that don't take inline style
{
// only want to wrap the node in a new style node if it doesn't already have that style
if (gNoisy) { printf("node %p is an editable leaf.\n", node.get()); }
PRBool textPropertySet;
nsCOMPtr<nsIDOMNode>resultNode;

Просмотреть файл

@ -292,6 +292,8 @@ protected:
NS_IMETHOD IsRootTag(nsString &aTag, PRBool &aIsTag);
NS_IMETHOD IsLeafThatTakesInlineStyle(const nsString *aTag, PRBool &aResult);
NS_IMETHOD IsSubordinateBlock(nsString &aTag, PRBool &aIsTag);
static PRBool IsTable(nsIDOMNode *aNode);

Просмотреть файл

@ -3895,6 +3895,16 @@ nsresult nsHTMLEditor::GetAbsoluteOffsetsForPoints(nsIDOMNode *aInStartNode,
if (-1==aOutEndOffset) {
aOutEndOffset = totalLength;
}
// guarantee that aOutStartOffset <= aOutEndOffset
if (aOutEndOffset<aOutStartOffset)
{
PRInt32 temp;
temp = aOutStartOffset;
aOutStartOffset= aOutEndOffset;
aOutEndOffset = temp;
}
NS_POSTCONDITION(aOutStartOffset <= aOutEndOffset, "start > end");
return result;
}
@ -5419,6 +5429,15 @@ nsHTMLEditor::MoveContiguousContentIntoNewParent(nsIDOMNode *aStartNode,
return result;
}
NS_IMETHODIMP nsHTMLEditor::IsLeafThatTakesInlineStyle(const nsString *aTag,
PRBool &aResult)
{
if (!aTag) { return NS_ERROR_NULL_POINTER; }
aResult = (PRBool)((PR_FALSE==aTag->EqualsIgnoreCase("br")) &&
(PR_FALSE==aTag->EqualsIgnoreCase("hr")) );
return NS_OK;
}
/* this wraps every selected text node in a new inline style node if needed
the text nodes are treated as being unique -- each needs it's own style node
@ -5521,8 +5540,11 @@ nsHTMLEditor::SetTextPropertiesForNodeWithDifferentParents(nsIDOMRange *aRange,
if (PR_FALSE==canContainChildren)
{
nsEditor::GetTagString(node,tag);
if (tag != "br") // skip <BR>, even though it's a leaf
{ // only want to wrap the text node in a new style node if it doesn't already have that style
PRBool processLeaf;
IsLeafThatTakesInlineStyle(&tag, processLeaf);
if (processLeaf) // skip leaf tags that don't take inline style
{
// only want to wrap the node in a new style node if it doesn't already have that style
if (gNoisy) { printf("node %p is an editable leaf.\n", node.get()); }
PRBool textPropertySet;
nsCOMPtr<nsIDOMNode>resultNode;

Просмотреть файл

@ -292,6 +292,8 @@ protected:
NS_IMETHOD IsRootTag(nsString &aTag, PRBool &aIsTag);
NS_IMETHOD IsLeafThatTakesInlineStyle(const nsString *aTag, PRBool &aResult);
NS_IMETHOD IsSubordinateBlock(nsString &aTag, PRBool &aIsTag);
static PRBool IsTable(nsIDOMNode *aNode);