Fixed two bugs, it puts the entire native file path into the text control instead of just the file name

and now it obeys the "size" attribute
b=19010 r=attintasi
This commit is contained in:
rods%netscape.com 2000-01-13 23:34:01 +00:00
Родитель b9db4ad68a
Коммит c826c2abb6
2 изменённых файлов: 32 добавлений и 12 удалений

Просмотреть файл

@ -133,6 +133,11 @@ nsFileControlFrame::CreateAnonymousContent(nsISupportsArray& aChildList)
reciever->AddEventListenerByIID(this, kIDOMMouseListenerIID); reciever->AddEventListenerByIID(this, kIDOMMouseListenerIID);
} }
nsString value;
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::size, value)) {
mTextContent->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::size, value, PR_FALSE);
}
return NS_OK; return NS_OK;
} }
@ -253,10 +258,9 @@ nsFileControlFrame::MouseClick(nsIDOMEvent* aMouseEvent)
if (result) { if (result) {
nsFileSpec fileSpec; nsFileSpec fileSpec;
fileWidget->GetFile(fileSpec); fileWidget->GetFile(fileSpec);
char* leafName = fileSpec.GetLeafName(); const char * pathName = fileSpec.GetNativePathCString();
if (leafName) { if (pathName) {
mTextFrame->SetProperty(mPresContext, nsHTMLAtoms::value,leafName); mTextFrame->SetProperty(mPresContext, nsHTMLAtoms::value, pathName);
nsCRT::free(leafName);
} }
} }
NS_RELEASE(fileWidget); NS_RELEASE(fileWidget);
@ -409,13 +413,19 @@ nsFileControlFrame::AttributeChanged(nsIPresContext* aPresContext,
{ {
// set the text control to readonly or not // set the text control to readonly or not
if (nsHTMLAtoms::disabled == aAttribute) { if (nsHTMLAtoms::disabled == aAttribute) {
//nsAutoString val(nsFormFrame::GetDisabled(this) ? "true":"false");
nsCOMPtr<nsIDOMHTMLInputElement> textControl = do_QueryInterface(mTextContent); nsCOMPtr<nsIDOMHTMLInputElement> textControl = do_QueryInterface(mTextContent);
if (textControl) if (textControl)
{ {
textControl->SetDisabled(nsFormFrame::GetDisabled(this)); textControl->SetDisabled(nsFormFrame::GetDisabled(this));
} }
//mTextContent->SetHTMLAttribute(nsHTMLAtoms::disabled, val, PR_TRUE); } else if (nsHTMLAtoms::size == aAttribute) {
nsString value;
if (nsnull != mTextContent && NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::size, value)) {
mTextContent->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::size, value, PR_TRUE);
if (aHint != NS_STYLE_HINT_REFLOW) {
nsFormFrame::StyleChangeReflow(aPresContext, this);
}
}
} }
return nsAreaFrame::AttributeChanged(aPresContext, aChild, aNameSpaceID, aAttribute, aHint); return nsAreaFrame::AttributeChanged(aPresContext, aChild, aNameSpaceID, aAttribute, aHint);

Просмотреть файл

@ -133,6 +133,11 @@ nsFileControlFrame::CreateAnonymousContent(nsISupportsArray& aChildList)
reciever->AddEventListenerByIID(this, kIDOMMouseListenerIID); reciever->AddEventListenerByIID(this, kIDOMMouseListenerIID);
} }
nsString value;
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::size, value)) {
mTextContent->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::size, value, PR_FALSE);
}
return NS_OK; return NS_OK;
} }
@ -253,10 +258,9 @@ nsFileControlFrame::MouseClick(nsIDOMEvent* aMouseEvent)
if (result) { if (result) {
nsFileSpec fileSpec; nsFileSpec fileSpec;
fileWidget->GetFile(fileSpec); fileWidget->GetFile(fileSpec);
char* leafName = fileSpec.GetLeafName(); const char * pathName = fileSpec.GetNativePathCString();
if (leafName) { if (pathName) {
mTextFrame->SetProperty(mPresContext, nsHTMLAtoms::value,leafName); mTextFrame->SetProperty(mPresContext, nsHTMLAtoms::value, pathName);
nsCRT::free(leafName);
} }
} }
NS_RELEASE(fileWidget); NS_RELEASE(fileWidget);
@ -409,13 +413,19 @@ nsFileControlFrame::AttributeChanged(nsIPresContext* aPresContext,
{ {
// set the text control to readonly or not // set the text control to readonly or not
if (nsHTMLAtoms::disabled == aAttribute) { if (nsHTMLAtoms::disabled == aAttribute) {
//nsAutoString val(nsFormFrame::GetDisabled(this) ? "true":"false");
nsCOMPtr<nsIDOMHTMLInputElement> textControl = do_QueryInterface(mTextContent); nsCOMPtr<nsIDOMHTMLInputElement> textControl = do_QueryInterface(mTextContent);
if (textControl) if (textControl)
{ {
textControl->SetDisabled(nsFormFrame::GetDisabled(this)); textControl->SetDisabled(nsFormFrame::GetDisabled(this));
} }
//mTextContent->SetHTMLAttribute(nsHTMLAtoms::disabled, val, PR_TRUE); } else if (nsHTMLAtoms::size == aAttribute) {
nsString value;
if (nsnull != mTextContent && NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::size, value)) {
mTextContent->SetAttribute(kNameSpaceID_None, nsHTMLAtoms::size, value, PR_TRUE);
if (aHint != NS_STYLE_HINT_REFLOW) {
nsFormFrame::StyleChangeReflow(aPresContext, this);
}
}
} }
return nsAreaFrame::AttributeChanged(aPresContext, aChild, aNameSpaceID, aAttribute, aHint); return nsAreaFrame::AttributeChanged(aPresContext, aChild, aNameSpaceID, aAttribute, aHint);