Bug 751200 - Don't fall in infinite loops if the content iterator has gone bad; r=bzbarsky

This commit is contained in:
Ehsan Akhgari 2012-05-22 22:05:27 -04:00
parent abfc1cc082
commit c9fd386a7e

View File

@ -302,7 +302,9 @@ static nsresult GenerateFlatTextContent(nsRange* aRange,
nsAutoString tmpStr;
for (; !iter->IsDone(); iter->Next()) {
nsINode* node = iter->GetCurrentNode();
if (!node || !node->IsNodeOfType(nsINode::eCONTENT))
if (!node)
break;
if (!node->IsNodeOfType(nsINode::eCONTENT))
continue;
nsIContent* content = static_cast<nsIContent*>(node);
@ -384,7 +386,9 @@ nsContentEventHandler::SetRangeFromFlatTextOffset(
nsCOMPtr<nsIContent> content;
for (; !iter->IsDone(); iter->Next()) {
nsINode* node = iter->GetCurrentNode();
if (!node || !node->IsNodeOfType(nsINode::eCONTENT))
if (!node)
break;
if (!node->IsNodeOfType(nsINode::eCONTENT))
continue;
nsIContent* content = static_cast<nsIContent*>(node);
@ -616,7 +620,9 @@ nsContentEventHandler::OnQueryTextRect(nsQueryContentEvent* aEvent)
do {
iter->Next();
node = iter->GetCurrentNode();
if (!node || !node->IsNodeOfType(nsINode::eCONTENT))
if (!node)
break;
if (!node->IsNodeOfType(nsINode::eCONTENT))
continue;
frame = static_cast<nsIContent*>(node)->GetPrimaryFrame();
} while (!frame && !iter->IsDone());
@ -921,7 +927,9 @@ nsContentEventHandler::GetFlatTextOffsetOfRange(nsIContent* aRootContent,
*aNativeOffset = 0;
for (; !iter->IsDone(); iter->Next()) {
nsINode* node = iter->GetCurrentNode();
if (!node || !node->IsNodeOfType(nsINode::eCONTENT))
if (!node)
break;
if (!node->IsNodeOfType(nsINode::eCONTENT))
continue;
nsIContent* content = static_cast<nsIContent*>(node);