Bug 750062 - Assert preconditions in IsVisTextNode; r=ehsan

This commit is contained in:
Ms2ger 2012-05-05 11:00:06 +02:00
parent 9abc05b1d6
commit 4df91dc293
4 changed files with 20 additions and 6 deletions

View File

@ -3645,6 +3645,9 @@ nsEditor::IsContainer(nsIDOMNode *aNode)
bool
nsEditor::IsTextInDirtyFrameVisible(nsIContent *aNode)
{
MOZ_ASSERT(aNode);
MOZ_ASSERT(aNode->NodeType() == nsIDOMNode::TEXT_NODE);
// virtual method
//
// If this is a simple non-html editor,

View File

@ -568,6 +568,9 @@ public:
bool IsEditable(nsIDOMNode *aNode);
bool IsEditable(nsIContent *aNode);
/**
* aNode must be a non-null text node.
*/
virtual bool IsTextInDirtyFrameVisible(nsIContent *aNode);
/** returns true if aNode is a MozEditorBogus node */

View File

@ -4591,6 +4591,9 @@ nsHTMLEditor::GetLastEditableLeaf(nsIDOMNode *aNode, nsCOMPtr<nsIDOMNode> *aOutL
bool
nsHTMLEditor::IsTextInDirtyFrameVisible(nsIContent *aNode)
{
MOZ_ASSERT(aNode);
MOZ_ASSERT(aNode->NodeType() == nsIDOMNode::TEXT_NODE);
bool isEmptyTextNode;
nsresult rv = IsVisTextNode(aNode, &isEmptyTextNode, false);
if (NS_FAILED(rv)) {
@ -4611,13 +4614,11 @@ nsHTMLEditor::IsVisTextNode(nsIContent* aNode,
bool* outIsEmptyNode,
bool aSafeToAskFrames)
{
NS_ENSURE_TRUE(aNode && outIsEmptyNode, NS_ERROR_NULL_POINTER);
*outIsEmptyNode = true;
MOZ_ASSERT(aNode);
MOZ_ASSERT(aNode->NodeType() == nsIDOMNode::TEXT_NODE);
MOZ_ASSERT(outIsEmptyNode);
// callers job to only call us with text nodes
if (!aNode->IsNodeOfType(nsINode::eTEXT)) {
return NS_ERROR_NULL_POINTER;
}
*outIsEmptyNode = true;
PRUint32 length = aNode->TextLength();
if (aSafeToAskFrames)

View File

@ -388,8 +388,15 @@ public:
// aSelection is optional -- if null, we get current seletion
nsresult CollapseSelectionToDeepestNonTableFirstChild(nsISelection *aSelection, nsIDOMNode *aNode);
/**
* aNode must be a non-null text node.
*/
virtual bool IsTextInDirtyFrameVisible(nsIContent *aNode);
/**
* aNode must be a non-null text node.
* outIsEmptyNode must be non-null.
*/
nsresult IsVisTextNode(nsIContent* aNode,
bool* outIsEmptyNode,
bool aSafeToAskFrames);