From 85bcfaecd741ff9953b8678280bb94b1fc8a1e64 Mon Sep 17 00:00:00 2001 From: kipp Date: Sat, 6 Jun 1998 20:25:11 +0000 Subject: [PATCH] Made option code more robust git-svn-id: svn://10.0.0.236/trunk@3433 18797224-902f-48f8-a5cc-f745e15eee43 --- .../html/document/src/nsHTMLContentSink.cpp | 44 ++++++++++--------- .../html/document/src/nsHTMLContentSink.cpp | 44 ++++++++++--------- 2 files changed, 46 insertions(+), 42 deletions(-) diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp index 233a8cf8f08..3717059a67c 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -1274,32 +1274,34 @@ nsresult HTMLContentSink::ProcessOPTIONTagContent(const nsIParserNode& aNode) { if ((nsnull != mCurrentSelect) && (nsnull != mCurrentOption)) { - nsIFormControl* control; - nsresult rv = mCurrentOption->QueryInterface(kIFormControlIID, (void **)&control); - nsAutoString currentText; - control->GetContent(currentText); // why do we need to do this + nsIFormControl* control = nsnull; + mCurrentOption->QueryInterface(kIFormControlIID, (void **)&control); + if (nsnull != control) { + // Get current content and append on the new content + nsAutoString currentText; + control->GetContent(currentText); - switch (aNode.GetTokenType()) { - case eToken_text: - case eToken_whitespace: - case eToken_newline: - currentText.Append(aNode.GetText()); - break; + switch (aNode.GetTokenType()) { + case eToken_text: + case eToken_whitespace: + case eToken_newline: + currentText.Append(aNode.GetText()); + break; - case eToken_entity: - { - nsAutoString tmp2(""); - PRInt32 unicode = aNode.TranslateToUnicodeStr(tmp2); - if (unicode < 0) { - currentText.Append(aNode.GetText()); - } else { - currentText.Append(tmp2); + case eToken_entity: + { + nsAutoString tmp2(""); + PRInt32 unicode = aNode.TranslateToUnicodeStr(tmp2); + if (unicode < 0) { + currentText.Append(aNode.GetText()); + } else { + currentText.Append(tmp2); + } } + break; } - break; + control->SetContent(currentText); } - - control->SetContent(currentText); } return NS_OK; } diff --git a/mozilla/layout/html/document/src/nsHTMLContentSink.cpp b/mozilla/layout/html/document/src/nsHTMLContentSink.cpp index 233a8cf8f08..3717059a67c 100644 --- a/mozilla/layout/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/layout/html/document/src/nsHTMLContentSink.cpp @@ -1274,32 +1274,34 @@ nsresult HTMLContentSink::ProcessOPTIONTagContent(const nsIParserNode& aNode) { if ((nsnull != mCurrentSelect) && (nsnull != mCurrentOption)) { - nsIFormControl* control; - nsresult rv = mCurrentOption->QueryInterface(kIFormControlIID, (void **)&control); - nsAutoString currentText; - control->GetContent(currentText); // why do we need to do this + nsIFormControl* control = nsnull; + mCurrentOption->QueryInterface(kIFormControlIID, (void **)&control); + if (nsnull != control) { + // Get current content and append on the new content + nsAutoString currentText; + control->GetContent(currentText); - switch (aNode.GetTokenType()) { - case eToken_text: - case eToken_whitespace: - case eToken_newline: - currentText.Append(aNode.GetText()); - break; + switch (aNode.GetTokenType()) { + case eToken_text: + case eToken_whitespace: + case eToken_newline: + currentText.Append(aNode.GetText()); + break; - case eToken_entity: - { - nsAutoString tmp2(""); - PRInt32 unicode = aNode.TranslateToUnicodeStr(tmp2); - if (unicode < 0) { - currentText.Append(aNode.GetText()); - } else { - currentText.Append(tmp2); + case eToken_entity: + { + nsAutoString tmp2(""); + PRInt32 unicode = aNode.TranslateToUnicodeStr(tmp2); + if (unicode < 0) { + currentText.Append(aNode.GetText()); + } else { + currentText.Append(tmp2); + } } + break; } - break; + control->SetContent(currentText); } - - control->SetContent(currentText); } return NS_OK; }