зеркало из https://github.com/mozilla/pjs.git
Fix for bug #96604: Deleting characters from some form input controls will allow altering page content
mozilla/editor/base/nsEditor.cpp mozilla/editor/base/nsEditor.h - Added IsRootNode() method. - Added calls to IsRootNode() in GetPriorNode() and GetNextNode() to prevent traversing above the root node. r=jfrancis@netscape.com sr=sfraser@netscape.com a=asa@mozilla.org
This commit is contained in:
Родитель
87430a9d12
Коммит
1be9448a33
|
@ -3250,9 +3250,9 @@ nsEditor::GetPriorNode(nsIDOMNode *aCurrentNode,
|
|||
result = node->GetParentNode(getter_AddRefs(parent));
|
||||
if ((NS_SUCCEEDED(result)) && parent)
|
||||
{
|
||||
if (bNoBlockCrossing && IsBlockNode(parent))
|
||||
if ((bNoBlockCrossing && IsBlockNode(parent)) || IsRootNode(parent))
|
||||
{
|
||||
// we are at front of block, do not step out
|
||||
// we are at front of block or root, do not step out
|
||||
*aResultNode = nsnull;
|
||||
return result;
|
||||
}
|
||||
|
@ -3341,9 +3341,9 @@ nsEditor::GetNextNode(nsIDOMNode *aCurrentNode,
|
|||
result = node->GetParentNode(getter_AddRefs(parent));
|
||||
if ((NS_SUCCEEDED(result)) && parent)
|
||||
{
|
||||
if (bNoBlockCrossing && IsBlockNode(parent))
|
||||
if ((bNoBlockCrossing && IsBlockNode(parent)) || IsRootNode(parent))
|
||||
{
|
||||
// we are at front of block, do not step out
|
||||
// we are at end of block or root, do not step out
|
||||
*aResultNode = nsnull;
|
||||
return result;
|
||||
}
|
||||
|
@ -3522,6 +3522,24 @@ nsEditor::TagCanContainTag(const nsAReadableString &aParentTag, const nsAReadabl
|
|||
return mDTD->CanContain(parentTagEnum, childTagEnum);
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsEditor::IsRootNode(nsIDOMNode *inNode)
|
||||
{
|
||||
if (!inNode)
|
||||
return PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIDOMElement> rootElement;
|
||||
|
||||
nsresult result = GetRootElement(getter_AddRefs(rootElement));
|
||||
|
||||
if (NS_FAILED(result) || !rootElement)
|
||||
return PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> rootNode = do_QueryInterface(rootElement);
|
||||
|
||||
return inNode == rootNode.get();
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsEditor::IsDescendantOfBody(nsIDOMNode *inNode)
|
||||
{
|
||||
|
|
|
@ -461,6 +461,9 @@ public:
|
|||
PRBool TagCanContain(const nsAReadableString &aParentTag, nsIDOMNode* aChild);
|
||||
virtual PRBool TagCanContainTag(const nsAReadableString &aParentTag, const nsAReadableString &aChildTag);
|
||||
|
||||
/** returns PR_TRUE if aNode is our root node */
|
||||
PRBool IsRootNode(nsIDOMNode *inNode);
|
||||
|
||||
/** returns PR_TRUE if aNode is a descendant of our root node */
|
||||
PRBool IsDescendantOfBody(nsIDOMNode *inNode);
|
||||
|
||||
|
|
|
@ -3250,9 +3250,9 @@ nsEditor::GetPriorNode(nsIDOMNode *aCurrentNode,
|
|||
result = node->GetParentNode(getter_AddRefs(parent));
|
||||
if ((NS_SUCCEEDED(result)) && parent)
|
||||
{
|
||||
if (bNoBlockCrossing && IsBlockNode(parent))
|
||||
if ((bNoBlockCrossing && IsBlockNode(parent)) || IsRootNode(parent))
|
||||
{
|
||||
// we are at front of block, do not step out
|
||||
// we are at front of block or root, do not step out
|
||||
*aResultNode = nsnull;
|
||||
return result;
|
||||
}
|
||||
|
@ -3341,9 +3341,9 @@ nsEditor::GetNextNode(nsIDOMNode *aCurrentNode,
|
|||
result = node->GetParentNode(getter_AddRefs(parent));
|
||||
if ((NS_SUCCEEDED(result)) && parent)
|
||||
{
|
||||
if (bNoBlockCrossing && IsBlockNode(parent))
|
||||
if ((bNoBlockCrossing && IsBlockNode(parent)) || IsRootNode(parent))
|
||||
{
|
||||
// we are at front of block, do not step out
|
||||
// we are at end of block or root, do not step out
|
||||
*aResultNode = nsnull;
|
||||
return result;
|
||||
}
|
||||
|
@ -3522,6 +3522,24 @@ nsEditor::TagCanContainTag(const nsAReadableString &aParentTag, const nsAReadabl
|
|||
return mDTD->CanContain(parentTagEnum, childTagEnum);
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsEditor::IsRootNode(nsIDOMNode *inNode)
|
||||
{
|
||||
if (!inNode)
|
||||
return PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIDOMElement> rootElement;
|
||||
|
||||
nsresult result = GetRootElement(getter_AddRefs(rootElement));
|
||||
|
||||
if (NS_FAILED(result) || !rootElement)
|
||||
return PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> rootNode = do_QueryInterface(rootElement);
|
||||
|
||||
return inNode == rootNode.get();
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsEditor::IsDescendantOfBody(nsIDOMNode *inNode)
|
||||
{
|
||||
|
|
|
@ -461,6 +461,9 @@ public:
|
|||
PRBool TagCanContain(const nsAReadableString &aParentTag, nsIDOMNode* aChild);
|
||||
virtual PRBool TagCanContainTag(const nsAReadableString &aParentTag, const nsAReadableString &aChildTag);
|
||||
|
||||
/** returns PR_TRUE if aNode is our root node */
|
||||
PRBool IsRootNode(nsIDOMNode *inNode);
|
||||
|
||||
/** returns PR_TRUE if aNode is a descendant of our root node */
|
||||
PRBool IsDescendantOfBody(nsIDOMNode *inNode);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче