Bug 28691: Fix leaks, check for null, in code my implementation was based on r=harishd a=rickg

git-svn-id: svn://10.0.0.236/trunk@61508 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
pollmann%netscape.com
2000-02-23 20:58:42 +00:00
parent 624e7603a7
commit 372cfcb2c6
2 changed files with 38 additions and 26 deletions

View File

@@ -312,6 +312,8 @@ nsFileControlFrame::SetInitialChildList(nsIPresContext* aPresContext,
nsGfxTextControlFrame*
nsFileControlFrame::GetTextControlFrame(nsIPresContext* aPresContext, nsIFrame* aStart)
{
nsGfxTextControlFrame* result = nsnull;
// find the text control frame.
nsIFrame* childFrame = nsnull;
aStart->FirstChild(aPresContext, nsnull, &childFrame);
@@ -319,16 +321,20 @@ nsFileControlFrame::GetTextControlFrame(nsIPresContext* aPresContext, nsIFrame*
while (childFrame) {
// see if the child is a text control
nsCOMPtr<nsIContent> content;
childFrame->GetContent(getter_AddRefs(content));
nsIAtom* atom;
if (content->GetTag(atom) == NS_OK && atom == nsHTMLAtoms::input) {
nsString value;
nsresult res = childFrame->GetContent(getter_AddRefs(content));
if (NS_SUCCEEDED(res) && content) {
nsCOMPtr<nsIAtom> atom;
res = content->GetTag(*getter_AddRefs(atom));
if (NS_SUCCEEDED(res) && atom) {
if (atom.get() == nsHTMLAtoms::input) {
if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::type, value)) {
value.ToUpperCase();
nsString txt("TEXT");
if (value == txt) {
return (nsGfxTextControlFrame*)childFrame;
// It's an input, is it a text input?
nsAutoString value;
if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::type, value)) {
if (value.EqualsIgnoreCase("text")) {
result = (nsGfxTextControlFrame*)childFrame;
}
}
}
}
}
@@ -336,13 +342,13 @@ nsFileControlFrame::GetTextControlFrame(nsIPresContext* aPresContext, nsIFrame*
// if not continue looking
nsGfxTextControlFrame* frame = GetTextControlFrame(aPresContext, childFrame);
if (frame)
return frame;
result = frame;
nsresult rv = childFrame->GetNextSibling(&childFrame);
NS_ASSERTION(rv == NS_OK,"failed to get next child");
res = childFrame->GetNextSibling(&childFrame);
NS_ASSERTION(res == NS_OK,"failed to get next child");
}
return nsnull;
return result;
}
PRIntn