зеркало из https://github.com/mozilla/pjs.git
patch from web converting it over to use the FilePicker
it also now uses the default directory b=40976,47552 r=rods,kmcclusk
This commit is contained in:
Родитель
7649d422f7
Коммит
a0e23d0ff2
|
@ -33,7 +33,6 @@
|
||||||
#include "nsHTMLIIDs.h"
|
#include "nsHTMLIIDs.h"
|
||||||
#include "nsHTMLAtoms.h"
|
#include "nsHTMLAtoms.h"
|
||||||
#include "nsIPresState.h"
|
#include "nsIPresState.h"
|
||||||
#include "nsIFileWidget.h"
|
|
||||||
#include "nsWidgetsCID.h"
|
#include "nsWidgetsCID.h"
|
||||||
#include "nsIComponentManager.h"
|
#include "nsIComponentManager.h"
|
||||||
#include "nsIView.h"
|
#include "nsIView.h"
|
||||||
|
@ -42,7 +41,6 @@
|
||||||
#include "nsIFormControl.h"
|
#include "nsIFormControl.h"
|
||||||
#include "nsINameSpaceManager.h"
|
#include "nsINameSpaceManager.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsFileSpec.h"
|
|
||||||
#include "nsISupportsArray.h"
|
#include "nsISupportsArray.h"
|
||||||
#include "nsIDOMElement.h"
|
#include "nsIDOMElement.h"
|
||||||
#include "nsIDOMDocument.h"
|
#include "nsIDOMDocument.h"
|
||||||
|
@ -53,10 +51,10 @@
|
||||||
#include "nsIStatefulFrame.h"
|
#include "nsIStatefulFrame.h"
|
||||||
#include "nsISupportsPrimitives.h"
|
#include "nsISupportsPrimitives.h"
|
||||||
#include "nsIComponentManager.h"
|
#include "nsIComponentManager.h"
|
||||||
|
#include "nsIDOMWindow.h"
|
||||||
|
#include "nsIFilePicker.h"
|
||||||
|
|
||||||
|
|
||||||
static NS_DEFINE_IID(kCFileWidgetCID, NS_FILEWIDGET_CID);
|
|
||||||
static NS_DEFINE_IID(kIFileWidgetIID, NS_IFILEWIDGET_IID);
|
|
||||||
static NS_DEFINE_IID(kIFormControlFrameIID, NS_IFORMCONTROLFRAME_IID);
|
static NS_DEFINE_IID(kIFormControlFrameIID, NS_IFORMCONTROLFRAME_IID);
|
||||||
static NS_DEFINE_IID(kIDOMHTMLInputElementIID, NS_IDOMHTMLINPUTELEMENT_IID);
|
static NS_DEFINE_IID(kIDOMHTMLInputElementIID, NS_IDOMHTMLINPUTELEMENT_IID);
|
||||||
static NS_DEFINE_IID(kIDOMMouseListenerIID, NS_IDOMMOUSELISTENER_IID);
|
static NS_DEFINE_IID(kIDOMMouseListenerIID, NS_IDOMMOUSELISTENER_IID);
|
||||||
|
@ -211,24 +209,6 @@ nsFileControlFrame::GetType(PRInt32* aType) const
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX this should be removed when nsView exposes it
|
|
||||||
nsIWidget* GetWindowTemp(nsIView *aView);
|
|
||||||
nsIWidget*
|
|
||||||
nsFileControlFrame::GetWindowTemp(nsIView *aView)
|
|
||||||
{
|
|
||||||
nsIWidget *window = nsnull;
|
|
||||||
|
|
||||||
nsIView *ancestor = aView;
|
|
||||||
while (nsnull != ancestor) {
|
|
||||||
ancestor->GetWidget(window);
|
|
||||||
if (nsnull != window) {
|
|
||||||
return window;
|
|
||||||
}
|
|
||||||
ancestor->GetParent(ancestor);
|
|
||||||
}
|
|
||||||
return nsnull;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
nsFileControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
|
nsFileControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
|
||||||
|
@ -256,44 +236,92 @@ nsFileControlFrame::ScrollIntoView(nsIPresContext* aPresContext)
|
||||||
nsresult
|
nsresult
|
||||||
nsFileControlFrame::MouseClick(nsIDOMEvent* aMouseEvent)
|
nsFileControlFrame::MouseClick(nsIDOMEvent* aMouseEvent)
|
||||||
{
|
{
|
||||||
nsIView* parentView;
|
nsresult result;
|
||||||
nsresult result = NS_OK;
|
|
||||||
nsIFrame *parentWithView;
|
|
||||||
if (NS_SUCCEEDED(mTextFrame->GetParentWithView(mPresContext, &parentWithView)) && parentWithView)
|
|
||||||
{
|
|
||||||
parentWithView->GetView(mPresContext,&parentView);
|
|
||||||
}
|
|
||||||
|
|
||||||
nsIWidget* parentWidget = GetWindowTemp(parentView);
|
// Get parent nsIDOMWindow object.
|
||||||
|
nsCOMPtr<nsIContent> content;
|
||||||
nsIFileWidget *fileWidget = nsnull;
|
result = GetContent(getter_AddRefs(content));
|
||||||
|
if (!content)
|
||||||
nsString title;
|
return NS_FAILED(result) ? result : NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
nsCOMPtr<nsIDocument> doc;
|
||||||
|
result = content->GetDocument(*getter_AddRefs(doc));
|
||||||
|
if (!doc)
|
||||||
|
return NS_FAILED(result) ? result : NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject;
|
||||||
|
result = doc->GetScriptGlobalObject(getter_AddRefs(scriptGlobalObject));
|
||||||
|
if (!scriptGlobalObject)
|
||||||
|
return NS_FAILED(result) ? result : NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
nsCOMPtr<nsIDOMWindow> parentWindow = do_QueryInterface(scriptGlobalObject);
|
||||||
|
if (!parentWindow)
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
// Get Loc title
|
||||||
|
nsString title;
|
||||||
nsFormControlHelper::GetLocalizedString("FileUpload", title);
|
nsFormControlHelper::GetLocalizedString("FileUpload", title);
|
||||||
|
|
||||||
nsComponentManager::CreateInstance(kCFileWidgetCID, nsnull, kIFileWidgetIID, (void**)&fileWidget);
|
nsCOMPtr<nsIFilePicker> filePicker = do_CreateInstance("component://mozilla/filepicker");
|
||||||
|
if (!filePicker)
|
||||||
if (fileWidget) {
|
return NS_ERROR_FAILURE;
|
||||||
nsString titles[1];
|
|
||||||
nsString filters[1];
|
|
||||||
nsFormControlHelper::GetLocalizedString("AllFilesTitle", titles[0]);
|
|
||||||
nsFormControlHelper::GetLocalizedString("AllFilesFilter", filters[0]);
|
|
||||||
fileWidget->SetFilterList(1, titles, filters);
|
|
||||||
|
|
||||||
fileWidget->Create(parentWidget, title, eMode_load, nsnull, nsnull);
|
result = filePicker->Init(parentWindow, title.GetUnicode(), nsIFilePicker::modeOpen);
|
||||||
result = fileWidget->Show();
|
if (NS_FAILED(result))
|
||||||
|
return result;
|
||||||
|
|
||||||
if (result) {
|
// Set filter "All Files"
|
||||||
nsFileSpec fileSpec;
|
filePicker->AppendFilters(nsIFilePicker::filterAll);
|
||||||
fileWidget->GetFile(fileSpec);
|
|
||||||
nsAutoString pathName;
|
// Set default directry and filename
|
||||||
fileSpec.GetNativePathString(pathName);
|
nsAutoString defaultName;
|
||||||
mTextFrame->SetProperty(mPresContext, nsHTMLAtoms::value, pathName);
|
GetProperty(nsHTMLAtoms::value, defaultName);
|
||||||
|
|
||||||
|
nsCOMPtr<nsILocalFile> currentFile = do_CreateInstance("component://mozilla/file/local");
|
||||||
|
if (currentFile && !defaultName.IsEmpty()) {
|
||||||
|
result = currentFile->InitWithUnicodePath(defaultName.GetUnicode());
|
||||||
|
if (NS_SUCCEEDED(result)) {
|
||||||
|
PRUnichar *leafName = nsnull;
|
||||||
|
currentFile->GetUnicodeLeafName(&leafName);
|
||||||
|
if (leafName) {
|
||||||
|
filePicker->SetDefaultString(leafName);
|
||||||
|
//nsAllocator::Free(leafName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// set directory
|
||||||
|
nsCOMPtr<nsIFile> parentFile;
|
||||||
|
currentFile->GetParent(getter_AddRefs(parentFile));
|
||||||
|
if (parentFile) {
|
||||||
|
nsCOMPtr<nsILocalFile> parentLocalFile = do_QueryInterface(parentFile, &result);
|
||||||
|
if (parentLocalFile)
|
||||||
|
filePicker->SetDisplayDirectory(parentLocalFile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
NS_RELEASE(fileWidget);
|
|
||||||
}
|
}
|
||||||
NS_RELEASE(parentWidget);
|
|
||||||
return NS_OK;
|
// Open dialog
|
||||||
|
PRInt16 mode;
|
||||||
|
result = filePicker->Show(&mode);
|
||||||
|
if (NS_FAILED(result))
|
||||||
|
return result;
|
||||||
|
if (mode == nsIFilePicker::returnCancel)
|
||||||
|
return NS_OK;
|
||||||
|
|
||||||
|
// Set property
|
||||||
|
nsCOMPtr<nsILocalFile> localFile;
|
||||||
|
result = filePicker->GetFile(getter_AddRefs(localFile));
|
||||||
|
if (localFile) {
|
||||||
|
PRUnichar *nativePath;
|
||||||
|
result = localFile->GetUnicodePath(&nativePath);
|
||||||
|
if (nativePath) {
|
||||||
|
nsAutoString pathName(nativePath);
|
||||||
|
mTextFrame->SetProperty(mPresContext, nsHTMLAtoms::value, pathName);
|
||||||
|
//nsAllocator::Free(nativePath);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NS_FAILED(result) ? result : NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -319,7 +347,7 @@ NS_IMETHODIMP nsFileControlFrame::Reflow(nsIPresContext* aPresContext,
|
||||||
// The Areaframe takes care of all our reflow
|
// The Areaframe takes care of all our reflow
|
||||||
// except for when style is used to change its size.
|
// except for when style is used to change its size.
|
||||||
nsresult rv = nsAreaFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
nsresult rv = nsAreaFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv) && mTextFrame != nsnull) {
|
||||||
nsIFrame * child;
|
nsIFrame * child;
|
||||||
FirstChild(aPresContext, nsnull, &child);
|
FirstChild(aPresContext, nsnull, &child);
|
||||||
while (child == mTextFrame) {
|
while (child == mTextFrame) {
|
||||||
|
@ -386,6 +414,7 @@ nsNewFrame*
|
||||||
nsFileControlFrame::GetTextControlFrame(nsIPresContext* aPresContext, nsIFrame* aStart)
|
nsFileControlFrame::GetTextControlFrame(nsIPresContext* aPresContext, nsIFrame* aStart)
|
||||||
{
|
{
|
||||||
nsNewFrame* result = nsnull;
|
nsNewFrame* result = nsnull;
|
||||||
|
#ifndef DEBUG_NEWFRAME
|
||||||
// find the text control frame.
|
// find the text control frame.
|
||||||
nsIFrame* childFrame = nsnull;
|
nsIFrame* childFrame = nsnull;
|
||||||
aStart->FirstChild(aPresContext, nsnull, &childFrame);
|
aStart->FirstChild(aPresContext, nsnull, &childFrame);
|
||||||
|
@ -421,6 +450,9 @@ nsFileControlFrame::GetTextControlFrame(nsIPresContext* aPresContext, nsIFrame*
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
#else
|
||||||
|
return nsnull;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
PRIntn
|
PRIntn
|
||||||
|
@ -513,6 +545,7 @@ nsFileControlFrame::GetFrameForPoint(nsIPresContext* aPresContext,
|
||||||
nsFramePaintLayer aWhichLayer,
|
nsFramePaintLayer aWhichLayer,
|
||||||
nsIFrame** aFrame)
|
nsIFrame** aFrame)
|
||||||
{
|
{
|
||||||
|
#ifndef DEBUG_NEWFRAME
|
||||||
if ( nsFormFrame::GetDisabled(this) && mRect.Contains(aPoint) ) {
|
if ( nsFormFrame::GetDisabled(this) && mRect.Contains(aPoint) ) {
|
||||||
const nsStyleDisplay* disp = (const nsStyleDisplay*)
|
const nsStyleDisplay* disp = (const nsStyleDisplay*)
|
||||||
mStyleContext->GetStyleData(eStyleStruct_Display);
|
mStyleContext->GetStyleData(eStyleStruct_Display);
|
||||||
|
@ -523,6 +556,7 @@ nsFileControlFrame::GetFrameForPoint(nsIPresContext* aPresContext,
|
||||||
} else {
|
} else {
|
||||||
return nsAreaFrame::GetFrameForPoint(aPresContext, aPoint, aWhichLayer, aFrame);
|
return nsAreaFrame::GetFrameForPoint(aPresContext, aPoint, aWhichLayer, aFrame);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -186,8 +186,6 @@ public:
|
||||||
NS_IMETHOD RestoreState(nsIPresContext* aPresContext, nsIPresState* aState);
|
NS_IMETHOD RestoreState(nsIPresContext* aPresContext, nsIPresState* aState);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
nsIWidget* GetWindowTemp(nsIView *aView); // XXX temporary
|
|
||||||
|
|
||||||
virtual PRIntn GetSkipSides() const;
|
virtual PRIntn GetSkipSides() const;
|
||||||
|
|
||||||
nsNewFrame* mTextFrame;
|
nsNewFrame* mTextFrame;
|
||||||
|
|
|
@ -20,7 +20,5 @@
|
||||||
Reset=Reset
|
Reset=Reset
|
||||||
Submit=Submit Query
|
Submit=Submit Query
|
||||||
Browse=Browse...
|
Browse=Browse...
|
||||||
AllFilesTitle=All Files
|
|
||||||
AllFilesFilter=*.*
|
|
||||||
FileUpload=File Upload
|
FileUpload=File Upload
|
||||||
IsIndexPrompt=This is a searchable index. Enter search keywords:
|
IsIndexPrompt=This is a searchable index. Enter search keywords:
|
||||||
|
|
|
@ -33,7 +33,6 @@
|
||||||
#include "nsHTMLIIDs.h"
|
#include "nsHTMLIIDs.h"
|
||||||
#include "nsHTMLAtoms.h"
|
#include "nsHTMLAtoms.h"
|
||||||
#include "nsIPresState.h"
|
#include "nsIPresState.h"
|
||||||
#include "nsIFileWidget.h"
|
|
||||||
#include "nsWidgetsCID.h"
|
#include "nsWidgetsCID.h"
|
||||||
#include "nsIComponentManager.h"
|
#include "nsIComponentManager.h"
|
||||||
#include "nsIView.h"
|
#include "nsIView.h"
|
||||||
|
@ -42,7 +41,6 @@
|
||||||
#include "nsIFormControl.h"
|
#include "nsIFormControl.h"
|
||||||
#include "nsINameSpaceManager.h"
|
#include "nsINameSpaceManager.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsFileSpec.h"
|
|
||||||
#include "nsISupportsArray.h"
|
#include "nsISupportsArray.h"
|
||||||
#include "nsIDOMElement.h"
|
#include "nsIDOMElement.h"
|
||||||
#include "nsIDOMDocument.h"
|
#include "nsIDOMDocument.h"
|
||||||
|
@ -53,10 +51,10 @@
|
||||||
#include "nsIStatefulFrame.h"
|
#include "nsIStatefulFrame.h"
|
||||||
#include "nsISupportsPrimitives.h"
|
#include "nsISupportsPrimitives.h"
|
||||||
#include "nsIComponentManager.h"
|
#include "nsIComponentManager.h"
|
||||||
|
#include "nsIDOMWindow.h"
|
||||||
|
#include "nsIFilePicker.h"
|
||||||
|
|
||||||
|
|
||||||
static NS_DEFINE_IID(kCFileWidgetCID, NS_FILEWIDGET_CID);
|
|
||||||
static NS_DEFINE_IID(kIFileWidgetIID, NS_IFILEWIDGET_IID);
|
|
||||||
static NS_DEFINE_IID(kIFormControlFrameIID, NS_IFORMCONTROLFRAME_IID);
|
static NS_DEFINE_IID(kIFormControlFrameIID, NS_IFORMCONTROLFRAME_IID);
|
||||||
static NS_DEFINE_IID(kIDOMHTMLInputElementIID, NS_IDOMHTMLINPUTELEMENT_IID);
|
static NS_DEFINE_IID(kIDOMHTMLInputElementIID, NS_IDOMHTMLINPUTELEMENT_IID);
|
||||||
static NS_DEFINE_IID(kIDOMMouseListenerIID, NS_IDOMMOUSELISTENER_IID);
|
static NS_DEFINE_IID(kIDOMMouseListenerIID, NS_IDOMMOUSELISTENER_IID);
|
||||||
|
@ -211,24 +209,6 @@ nsFileControlFrame::GetType(PRInt32* aType) const
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX this should be removed when nsView exposes it
|
|
||||||
nsIWidget* GetWindowTemp(nsIView *aView);
|
|
||||||
nsIWidget*
|
|
||||||
nsFileControlFrame::GetWindowTemp(nsIView *aView)
|
|
||||||
{
|
|
||||||
nsIWidget *window = nsnull;
|
|
||||||
|
|
||||||
nsIView *ancestor = aView;
|
|
||||||
while (nsnull != ancestor) {
|
|
||||||
ancestor->GetWidget(window);
|
|
||||||
if (nsnull != window) {
|
|
||||||
return window;
|
|
||||||
}
|
|
||||||
ancestor->GetParent(ancestor);
|
|
||||||
}
|
|
||||||
return nsnull;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
nsFileControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
|
nsFileControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
|
||||||
|
@ -256,44 +236,92 @@ nsFileControlFrame::ScrollIntoView(nsIPresContext* aPresContext)
|
||||||
nsresult
|
nsresult
|
||||||
nsFileControlFrame::MouseClick(nsIDOMEvent* aMouseEvent)
|
nsFileControlFrame::MouseClick(nsIDOMEvent* aMouseEvent)
|
||||||
{
|
{
|
||||||
nsIView* parentView;
|
nsresult result;
|
||||||
nsresult result = NS_OK;
|
|
||||||
nsIFrame *parentWithView;
|
|
||||||
if (NS_SUCCEEDED(mTextFrame->GetParentWithView(mPresContext, &parentWithView)) && parentWithView)
|
|
||||||
{
|
|
||||||
parentWithView->GetView(mPresContext,&parentView);
|
|
||||||
}
|
|
||||||
|
|
||||||
nsIWidget* parentWidget = GetWindowTemp(parentView);
|
// Get parent nsIDOMWindow object.
|
||||||
|
nsCOMPtr<nsIContent> content;
|
||||||
nsIFileWidget *fileWidget = nsnull;
|
result = GetContent(getter_AddRefs(content));
|
||||||
|
if (!content)
|
||||||
nsString title;
|
return NS_FAILED(result) ? result : NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
nsCOMPtr<nsIDocument> doc;
|
||||||
|
result = content->GetDocument(*getter_AddRefs(doc));
|
||||||
|
if (!doc)
|
||||||
|
return NS_FAILED(result) ? result : NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject;
|
||||||
|
result = doc->GetScriptGlobalObject(getter_AddRefs(scriptGlobalObject));
|
||||||
|
if (!scriptGlobalObject)
|
||||||
|
return NS_FAILED(result) ? result : NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
nsCOMPtr<nsIDOMWindow> parentWindow = do_QueryInterface(scriptGlobalObject);
|
||||||
|
if (!parentWindow)
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
// Get Loc title
|
||||||
|
nsString title;
|
||||||
nsFormControlHelper::GetLocalizedString("FileUpload", title);
|
nsFormControlHelper::GetLocalizedString("FileUpload", title);
|
||||||
|
|
||||||
nsComponentManager::CreateInstance(kCFileWidgetCID, nsnull, kIFileWidgetIID, (void**)&fileWidget);
|
nsCOMPtr<nsIFilePicker> filePicker = do_CreateInstance("component://mozilla/filepicker");
|
||||||
|
if (!filePicker)
|
||||||
if (fileWidget) {
|
return NS_ERROR_FAILURE;
|
||||||
nsString titles[1];
|
|
||||||
nsString filters[1];
|
|
||||||
nsFormControlHelper::GetLocalizedString("AllFilesTitle", titles[0]);
|
|
||||||
nsFormControlHelper::GetLocalizedString("AllFilesFilter", filters[0]);
|
|
||||||
fileWidget->SetFilterList(1, titles, filters);
|
|
||||||
|
|
||||||
fileWidget->Create(parentWidget, title, eMode_load, nsnull, nsnull);
|
result = filePicker->Init(parentWindow, title.GetUnicode(), nsIFilePicker::modeOpen);
|
||||||
result = fileWidget->Show();
|
if (NS_FAILED(result))
|
||||||
|
return result;
|
||||||
|
|
||||||
if (result) {
|
// Set filter "All Files"
|
||||||
nsFileSpec fileSpec;
|
filePicker->AppendFilters(nsIFilePicker::filterAll);
|
||||||
fileWidget->GetFile(fileSpec);
|
|
||||||
nsAutoString pathName;
|
// Set default directry and filename
|
||||||
fileSpec.GetNativePathString(pathName);
|
nsAutoString defaultName;
|
||||||
mTextFrame->SetProperty(mPresContext, nsHTMLAtoms::value, pathName);
|
GetProperty(nsHTMLAtoms::value, defaultName);
|
||||||
|
|
||||||
|
nsCOMPtr<nsILocalFile> currentFile = do_CreateInstance("component://mozilla/file/local");
|
||||||
|
if (currentFile && !defaultName.IsEmpty()) {
|
||||||
|
result = currentFile->InitWithUnicodePath(defaultName.GetUnicode());
|
||||||
|
if (NS_SUCCEEDED(result)) {
|
||||||
|
PRUnichar *leafName = nsnull;
|
||||||
|
currentFile->GetUnicodeLeafName(&leafName);
|
||||||
|
if (leafName) {
|
||||||
|
filePicker->SetDefaultString(leafName);
|
||||||
|
//nsAllocator::Free(leafName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// set directory
|
||||||
|
nsCOMPtr<nsIFile> parentFile;
|
||||||
|
currentFile->GetParent(getter_AddRefs(parentFile));
|
||||||
|
if (parentFile) {
|
||||||
|
nsCOMPtr<nsILocalFile> parentLocalFile = do_QueryInterface(parentFile, &result);
|
||||||
|
if (parentLocalFile)
|
||||||
|
filePicker->SetDisplayDirectory(parentLocalFile);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
NS_RELEASE(fileWidget);
|
|
||||||
}
|
}
|
||||||
NS_RELEASE(parentWidget);
|
|
||||||
return NS_OK;
|
// Open dialog
|
||||||
|
PRInt16 mode;
|
||||||
|
result = filePicker->Show(&mode);
|
||||||
|
if (NS_FAILED(result))
|
||||||
|
return result;
|
||||||
|
if (mode == nsIFilePicker::returnCancel)
|
||||||
|
return NS_OK;
|
||||||
|
|
||||||
|
// Set property
|
||||||
|
nsCOMPtr<nsILocalFile> localFile;
|
||||||
|
result = filePicker->GetFile(getter_AddRefs(localFile));
|
||||||
|
if (localFile) {
|
||||||
|
PRUnichar *nativePath;
|
||||||
|
result = localFile->GetUnicodePath(&nativePath);
|
||||||
|
if (nativePath) {
|
||||||
|
nsAutoString pathName(nativePath);
|
||||||
|
mTextFrame->SetProperty(mPresContext, nsHTMLAtoms::value, pathName);
|
||||||
|
//nsAllocator::Free(nativePath);
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return NS_FAILED(result) ? result : NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -319,7 +347,7 @@ NS_IMETHODIMP nsFileControlFrame::Reflow(nsIPresContext* aPresContext,
|
||||||
// The Areaframe takes care of all our reflow
|
// The Areaframe takes care of all our reflow
|
||||||
// except for when style is used to change its size.
|
// except for when style is used to change its size.
|
||||||
nsresult rv = nsAreaFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
nsresult rv = nsAreaFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv) && mTextFrame != nsnull) {
|
||||||
nsIFrame * child;
|
nsIFrame * child;
|
||||||
FirstChild(aPresContext, nsnull, &child);
|
FirstChild(aPresContext, nsnull, &child);
|
||||||
while (child == mTextFrame) {
|
while (child == mTextFrame) {
|
||||||
|
@ -386,6 +414,7 @@ nsNewFrame*
|
||||||
nsFileControlFrame::GetTextControlFrame(nsIPresContext* aPresContext, nsIFrame* aStart)
|
nsFileControlFrame::GetTextControlFrame(nsIPresContext* aPresContext, nsIFrame* aStart)
|
||||||
{
|
{
|
||||||
nsNewFrame* result = nsnull;
|
nsNewFrame* result = nsnull;
|
||||||
|
#ifndef DEBUG_NEWFRAME
|
||||||
// find the text control frame.
|
// find the text control frame.
|
||||||
nsIFrame* childFrame = nsnull;
|
nsIFrame* childFrame = nsnull;
|
||||||
aStart->FirstChild(aPresContext, nsnull, &childFrame);
|
aStart->FirstChild(aPresContext, nsnull, &childFrame);
|
||||||
|
@ -421,6 +450,9 @@ nsFileControlFrame::GetTextControlFrame(nsIPresContext* aPresContext, nsIFrame*
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
#else
|
||||||
|
return nsnull;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
PRIntn
|
PRIntn
|
||||||
|
@ -513,6 +545,7 @@ nsFileControlFrame::GetFrameForPoint(nsIPresContext* aPresContext,
|
||||||
nsFramePaintLayer aWhichLayer,
|
nsFramePaintLayer aWhichLayer,
|
||||||
nsIFrame** aFrame)
|
nsIFrame** aFrame)
|
||||||
{
|
{
|
||||||
|
#ifndef DEBUG_NEWFRAME
|
||||||
if ( nsFormFrame::GetDisabled(this) && mRect.Contains(aPoint) ) {
|
if ( nsFormFrame::GetDisabled(this) && mRect.Contains(aPoint) ) {
|
||||||
const nsStyleDisplay* disp = (const nsStyleDisplay*)
|
const nsStyleDisplay* disp = (const nsStyleDisplay*)
|
||||||
mStyleContext->GetStyleData(eStyleStruct_Display);
|
mStyleContext->GetStyleData(eStyleStruct_Display);
|
||||||
|
@ -523,6 +556,7 @@ nsFileControlFrame::GetFrameForPoint(nsIPresContext* aPresContext,
|
||||||
} else {
|
} else {
|
||||||
return nsAreaFrame::GetFrameForPoint(aPresContext, aPoint, aWhichLayer, aFrame);
|
return nsAreaFrame::GetFrameForPoint(aPresContext, aPoint, aWhichLayer, aFrame);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -186,8 +186,6 @@ public:
|
||||||
NS_IMETHOD RestoreState(nsIPresContext* aPresContext, nsIPresState* aState);
|
NS_IMETHOD RestoreState(nsIPresContext* aPresContext, nsIPresState* aState);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
nsIWidget* GetWindowTemp(nsIView *aView); // XXX temporary
|
|
||||||
|
|
||||||
virtual PRIntn GetSkipSides() const;
|
virtual PRIntn GetSkipSides() const;
|
||||||
|
|
||||||
nsNewFrame* mTextFrame;
|
nsNewFrame* mTextFrame;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче