2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
1998-09-23 21:16:51 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* The contents of this file are subject to the Netscape Public License
|
|
|
|
* Version 1.1 (the "License"); you may not use this file except in
|
|
|
|
* compliance with the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/NPL/
|
1998-09-23 21:16:51 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1998-09-23 21:16:51 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the NPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1998-09-23 21:16:51 +04:00
|
|
|
|
|
|
|
#include "nsFileControlFrame.h"
|
1998-10-14 01:31:26 +04:00
|
|
|
#include "nsFormFrame.h"
|
2000-05-02 07:40:44 +04:00
|
|
|
|
|
|
|
|
2001-02-20 00:50:04 +03:00
|
|
|
#include "nsIElementFactory.h"
|
1998-09-23 21:16:51 +04:00
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "prtypes.h"
|
|
|
|
#include "nsIAtom.h"
|
|
|
|
#include "nsIPresContext.h"
|
|
|
|
#include "nsIHTMLContent.h"
|
|
|
|
#include "nsHTMLIIDs.h"
|
|
|
|
#include "nsHTMLAtoms.h"
|
2000-01-14 12:28:54 +03:00
|
|
|
#include "nsIPresState.h"
|
1998-09-23 21:16:51 +04:00
|
|
|
#include "nsWidgetsCID.h"
|
1999-03-09 12:44:27 +03:00
|
|
|
#include "nsIComponentManager.h"
|
1998-09-23 21:16:51 +04:00
|
|
|
#include "nsIView.h"
|
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
#include "nsIDOMHTMLInputElement.h"
|
|
|
|
#include "nsIFormControl.h"
|
1998-12-20 04:21:23 +03:00
|
|
|
#include "nsINameSpaceManager.h"
|
1999-02-18 03:13:39 +03:00
|
|
|
#include "nsCOMPtr.h"
|
1999-07-01 02:17:43 +04:00
|
|
|
#include "nsISupportsArray.h"
|
|
|
|
#include "nsIDOMElement.h"
|
|
|
|
#include "nsIDOMDocument.h"
|
2000-12-30 22:22:22 +03:00
|
|
|
#include "nsIDocument.h"
|
1999-07-01 02:17:43 +04:00
|
|
|
#include "nsIDOMMouseListener.h"
|
1999-08-21 04:09:24 +04:00
|
|
|
#include "nsIPresShell.h"
|
1999-09-08 03:20:32 +04:00
|
|
|
#include "nsIDOMHTMLInputElement.h"
|
1999-09-15 09:31:31 +04:00
|
|
|
#include "nsIStatefulFrame.h"
|
|
|
|
#include "nsISupportsPrimitives.h"
|
|
|
|
#include "nsIComponentManager.h"
|
2000-09-01 05:54:35 +04:00
|
|
|
#include "nsIDOMWindowInternal.h"
|
2000-08-18 22:16:12 +04:00
|
|
|
#include "nsIFilePicker.h"
|
2000-08-25 17:25:50 +04:00
|
|
|
#include "nsIDOMMouseEvent.h"
|
2000-12-30 22:22:22 +03:00
|
|
|
#include "nsINodeInfo.h"
|
|
|
|
#include "nsIDOMEventReceiver.h"
|
|
|
|
#include "nsIScriptGlobalObject.h"
|
1998-09-23 21:16:51 +04:00
|
|
|
|
2001-02-20 00:50:04 +03:00
|
|
|
#include "nsContentCID.h"
|
|
|
|
static NS_DEFINE_CID(kHTMLElementFactoryCID, NS_HTML_ELEMENT_FACTORY_CID);
|
1998-09-23 21:16:51 +04:00
|
|
|
|
|
|
|
nsresult
|
1999-12-05 02:49:50 +03:00
|
|
|
NS_NewFileControlFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
|
1998-09-23 21:16:51 +04:00
|
|
|
{
|
1999-05-12 02:03:29 +04:00
|
|
|
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
|
|
|
if (nsnull == aNewFrame) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1999-12-05 02:49:50 +03:00
|
|
|
nsFileControlFrame* it = new (aPresShell) nsFileControlFrame();
|
1999-05-12 02:03:29 +04:00
|
|
|
if (!it) {
|
1998-09-23 21:16:51 +04:00
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1999-05-12 02:03:29 +04:00
|
|
|
*aNewFrame = it;
|
1998-09-23 21:16:51 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-19 18:03:53 +04:00
|
|
|
nsFileControlFrame::nsFileControlFrame():
|
|
|
|
mTextFrame(nsnull),
|
|
|
|
mFormFrame(nsnull),
|
1999-09-19 11:25:12 +04:00
|
|
|
mTextContent(nsnull),
|
|
|
|
mCachedState(nsnull)
|
1998-09-23 21:16:51 +04:00
|
|
|
{
|
fixed bugs #6303, #6753, #6756, #6759
Re-wrote nsComboboxFrame.
removed the obsolete nsHTMLAtoms: comboText,comoTextSelected,comTextSelectedFocus,dropDownVisible,
dropdownHidden, dropDownBtnOut, dropDownBtnPressed,
Added nsHTMLAtoms::combobox, nsLayoutAtoms::popupList
Renamed dropDownList to dropDownListPseudo
Added "arrow.gif" as to be used the background-image for the combobox button
ua.css - added rules for select to differentiate between comboboxes and listboxes.
Added style rules to more closely match the XPTOOLKIT XPWidgets look.
removed the following :-moz-combobox-text, -moz-combobox-textselected
nsIFormControlFrame.h - Added SetSuggestedSize method.
nsButtonControlFrame - Implemented SetSuggestedSize.
nsCSSFrameConstructor.cpp - Rewrote ConstructSelectFrame.
nsIWidget.h -Added GetAbsoluteBounds method.
nsWindow.cpp - Implemented GetAbsoluteBounds.
1999-07-15 02:00:24 +04:00
|
|
|
//Shrink the area around it's contents
|
|
|
|
SetFlags(NS_BLOCK_SHRINK_WRAP);
|
1999-07-01 02:17:43 +04:00
|
|
|
}
|
|
|
|
|
1999-08-19 18:03:53 +04:00
|
|
|
nsFileControlFrame::~nsFileControlFrame()
|
|
|
|
{
|
|
|
|
NS_IF_RELEASE(mTextContent);
|
2000-08-04 03:39:33 +04:00
|
|
|
|
|
|
|
// remove ourself as a listener of the button (bug 40533)
|
|
|
|
if (mBrowse) {
|
|
|
|
nsCOMPtr<nsIDOMEventReceiver> reciever(do_QueryInterface(mBrowse));
|
2001-01-04 23:44:42 +03:00
|
|
|
reciever->RemoveEventListenerByIID(this, NS_GET_IID(nsIDOMMouseListener));
|
2000-08-04 03:39:33 +04:00
|
|
|
}
|
|
|
|
|
1999-09-15 09:31:31 +04:00
|
|
|
if (mCachedState) {
|
|
|
|
delete mCachedState;
|
|
|
|
mCachedState = nsnull;
|
|
|
|
}
|
1999-11-05 02:16:47 +03:00
|
|
|
if (mFormFrame) {
|
|
|
|
mFormFrame->RemoveFormControlFrame(*this);
|
|
|
|
mFormFrame = nsnull;
|
|
|
|
}
|
1999-08-19 18:03:53 +04:00
|
|
|
}
|
|
|
|
|
1999-07-01 02:17:43 +04:00
|
|
|
NS_IMETHODIMP
|
2000-01-22 04:16:50 +03:00
|
|
|
nsFileControlFrame::CreateAnonymousContent(nsIPresContext* aPresContext,
|
|
|
|
nsISupportsArray& aChildList)
|
1999-07-01 02:17:43 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
// create text field
|
2000-05-10 17:13:39 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsIDocument> doc;
|
|
|
|
mContent->GetDocument(*getter_AddRefs(doc));
|
|
|
|
nsCOMPtr<nsINodeInfoManager> nimgr;
|
|
|
|
nsresult rv = doc->GetNodeInfoManager(*getter_AddRefs(nimgr));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
nsCOMPtr<nsINodeInfo> nodeInfo;
|
|
|
|
nimgr->GetNodeInfo(nsHTMLAtoms::input, nsnull, kNameSpaceID_None,
|
|
|
|
*getter_AddRefs(nodeInfo));
|
|
|
|
|
2001-02-20 00:50:04 +03:00
|
|
|
nsCOMPtr<nsIElementFactory> ef(do_CreateInstance(kHTMLElementFactoryCID,&rv));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> content;
|
|
|
|
rv = ef->CreateInstanceByTag(nodeInfo,getter_AddRefs(content));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
rv = content->QueryInterface(NS_GET_IID(nsIHTMLContent),(void**)&mTextContent);
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2001-08-17 12:14:14 +04:00
|
|
|
mTextContent->SetAttr(kNameSpaceID_None, nsHTMLAtoms::type, NS_LITERAL_STRING("text"), PR_FALSE);
|
1999-08-19 18:03:53 +04:00
|
|
|
if (nsFormFrame::GetDisabled(this)) {
|
1999-09-08 03:20:32 +04:00
|
|
|
nsCOMPtr<nsIDOMHTMLInputElement> textControl = do_QueryInterface(mTextContent);
|
|
|
|
if (textControl) {
|
|
|
|
textControl->SetDisabled(nsFormFrame::GetDisabled(this));
|
|
|
|
}
|
1999-08-19 18:03:53 +04:00
|
|
|
}
|
|
|
|
aChildList.AppendElement(mTextContent);
|
|
|
|
}
|
1999-07-01 02:17:43 +04:00
|
|
|
|
|
|
|
// create browse button
|
2001-02-20 00:50:04 +03:00
|
|
|
rv = ef->CreateInstanceByTag(nodeInfo,getter_AddRefs(content));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
mBrowse = do_QueryInterface(content,&rv);
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2001-08-17 12:14:14 +04:00
|
|
|
mBrowse->SetAttr(kNameSpaceID_None, nsHTMLAtoms::type, NS_LITERAL_STRING("button"), PR_FALSE);
|
|
|
|
//browse->SetAttr(kNameSpaceID_None, nsHTMLAtoms::value, nsAutoString("browse..."), PR_FALSE);
|
1999-07-01 02:17:43 +04:00
|
|
|
|
2000-08-04 03:39:33 +04:00
|
|
|
aChildList.AppendElement(mBrowse);
|
1999-08-19 18:03:53 +04:00
|
|
|
|
2000-08-04 03:39:33 +04:00
|
|
|
// register as an event listener of the button to open file dialog on mouse click
|
|
|
|
nsCOMPtr<nsIDOMEventReceiver> reciever(do_QueryInterface(mBrowse));
|
2001-01-04 23:44:42 +03:00
|
|
|
reciever->AddEventListenerByIID(this, NS_GET_IID(nsIDOMMouseListener));
|
1999-08-19 18:03:53 +04:00
|
|
|
}
|
1999-07-01 02:17:43 +04:00
|
|
|
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 21:42:36 +04:00
|
|
|
nsAutoString value;
|
2001-08-17 12:14:14 +04:00
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::size, value)) {
|
|
|
|
mTextContent->SetAttr(kNameSpaceID_None, nsHTMLAtoms::size, value, PR_FALSE);
|
2000-01-14 02:34:01 +03:00
|
|
|
}
|
|
|
|
|
1999-07-01 02:17:43 +04:00
|
|
|
return NS_OK;
|
1998-09-23 21:16:51 +04:00
|
|
|
}
|
|
|
|
|
1999-11-02 04:50:15 +03:00
|
|
|
// Frames are not refcounted, no need to AddRef
|
1999-09-15 09:31:31 +04:00
|
|
|
NS_IMETHODIMP
|
1998-09-23 21:16:51 +04:00
|
|
|
nsFileControlFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(0 != aInstancePtr, "null ptr");
|
|
|
|
if (NULL == aInstancePtr) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
2001-01-04 23:44:42 +03:00
|
|
|
} else if (aIID.Equals(NS_GET_IID(nsIAnonymousContentCreator))) {
|
1999-09-15 09:31:31 +04:00
|
|
|
*aInstancePtr = (void*)(nsIAnonymousContentCreator*) this;
|
|
|
|
return NS_OK;
|
2001-01-04 23:44:42 +03:00
|
|
|
} else if (aIID.Equals(NS_GET_IID(nsIFormControlFrame))) {
|
1998-09-23 21:16:51 +04:00
|
|
|
*aInstancePtr = (void*) ((nsIFormControlFrame*) this);
|
|
|
|
return NS_OK;
|
2001-01-04 23:44:42 +03:00
|
|
|
} else if (aIID.Equals(NS_GET_IID(nsIDOMMouseListener))) {
|
1999-09-15 09:31:31 +04:00
|
|
|
*aInstancePtr = (void*)(nsIDOMMouseListener*) this;
|
|
|
|
return NS_OK;
|
|
|
|
} else if (aIID.Equals(NS_GET_IID(nsIStatefulFrame))) {
|
|
|
|
*aInstancePtr = (void*)(nsIStatefulFrame*) this;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-09-23 21:16:51 +04:00
|
|
|
return nsHTMLContainerFrame::QueryInterface(aIID, aInstancePtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFileControlFrame::GetType(PRInt32* aType) const
|
|
|
|
{
|
|
|
|
*aType = NS_FORM_INPUT_FILE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-10-23 03:00:37 +04:00
|
|
|
void
|
|
|
|
nsFileControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
|
|
|
|
{
|
2000-12-01 00:39:28 +03:00
|
|
|
// Fix for Bug 6133
|
1998-10-23 03:00:37 +04:00
|
|
|
if (mTextFrame) {
|
2000-12-01 00:39:28 +03:00
|
|
|
nsCOMPtr<nsIContent> content;
|
|
|
|
mTextFrame->GetContent(getter_AddRefs(content));
|
|
|
|
if (content) {
|
|
|
|
content->SetFocus(mPresContext);
|
|
|
|
}
|
1998-10-23 03:00:37 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-08-21 04:09:24 +04:00
|
|
|
void
|
|
|
|
nsFileControlFrame::ScrollIntoView(nsIPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
if (aPresContext) {
|
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
aPresContext->GetShell(getter_AddRefs(presShell));
|
2000-09-08 09:53:28 +04:00
|
|
|
if (presShell) {
|
|
|
|
presShell->ScrollFrameIntoView(this,
|
2000-01-25 18:24:48 +03:00
|
|
|
NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE,NS_PRESSHELL_SCROLL_IF_NOT_VISIBLE);
|
2000-09-08 09:53:28 +04:00
|
|
|
}
|
1999-08-21 04:09:24 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-07-01 02:17:43 +04:00
|
|
|
/**
|
|
|
|
* This is called when our browse button is clicked
|
|
|
|
*/
|
|
|
|
nsresult
|
|
|
|
nsFileControlFrame::MouseClick(nsIDOMEvent* aMouseEvent)
|
1998-09-23 21:16:51 +04:00
|
|
|
{
|
2000-08-25 17:25:50 +04:00
|
|
|
// only allow the left button
|
|
|
|
nsCOMPtr<nsIDOMMouseEvent> mouseEvent = do_QueryInterface(aMouseEvent);
|
|
|
|
if (mouseEvent) {
|
|
|
|
PRUint16 whichButton;
|
|
|
|
if (NS_SUCCEEDED(mouseEvent->GetButton(&whichButton))) {
|
2001-03-02 21:39:22 +03:00
|
|
|
if (whichButton != 0) {
|
2000-08-25 17:25:50 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-08-18 22:16:12 +04:00
|
|
|
nsresult result;
|
2000-06-07 05:21:20 +04:00
|
|
|
|
2000-09-01 05:54:35 +04:00
|
|
|
// Get parent nsIDOMWindowInternal object.
|
2000-08-18 22:16:12 +04:00
|
|
|
nsCOMPtr<nsIContent> content;
|
|
|
|
result = GetContent(getter_AddRefs(content));
|
|
|
|
if (!content)
|
|
|
|
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;
|
|
|
|
|
2000-09-01 05:54:35 +04:00
|
|
|
nsCOMPtr<nsIDOMWindowInternal> parentWindow = do_QueryInterface(scriptGlobalObject);
|
2000-08-18 22:16:12 +04:00
|
|
|
if (!parentWindow)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
// Get Loc title
|
|
|
|
nsString title;
|
2001-01-27 17:09:34 +03:00
|
|
|
nsFormControlHelper::GetLocalizedString(nsFormControlHelper::GetHTMLPropertiesFileName(),
|
2001-09-26 04:36:45 +04:00
|
|
|
NS_LITERAL_STRING("FileUpload").get(), title);
|
2000-05-27 17:03:18 +04:00
|
|
|
|
2000-09-14 03:57:52 +04:00
|
|
|
nsCOMPtr<nsIFilePicker> filePicker = do_CreateInstance("@mozilla.org/filepicker;1");
|
2000-08-18 22:16:12 +04:00
|
|
|
if (!filePicker)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2001-06-30 15:02:25 +04:00
|
|
|
result = filePicker->Init(parentWindow, title.get(), nsIFilePicker::modeOpen);
|
2000-08-18 22:16:12 +04:00
|
|
|
if (NS_FAILED(result))
|
|
|
|
return result;
|
|
|
|
|
|
|
|
// Set filter "All Files"
|
|
|
|
filePicker->AppendFilters(nsIFilePicker::filterAll);
|
|
|
|
|
|
|
|
// Set default directry and filename
|
|
|
|
nsAutoString defaultName;
|
|
|
|
GetProperty(nsHTMLAtoms::value, defaultName);
|
|
|
|
|
2000-09-14 03:57:52 +04:00
|
|
|
nsCOMPtr<nsILocalFile> currentFile = do_CreateInstance("@mozilla.org/file/local;1");
|
2000-08-18 22:16:12 +04:00
|
|
|
if (currentFile && !defaultName.IsEmpty()) {
|
2001-06-30 15:02:25 +04:00
|
|
|
result = currentFile->InitWithUnicodePath(defaultName.get());
|
2000-08-18 22:16:12 +04:00
|
|
|
if (NS_SUCCEEDED(result)) {
|
|
|
|
PRUnichar *leafName = nsnull;
|
|
|
|
currentFile->GetUnicodeLeafName(&leafName);
|
|
|
|
if (leafName) {
|
|
|
|
filePicker->SetDefaultString(leafName);
|
2000-12-01 00:39:28 +03:00
|
|
|
nsMemory::Free(leafName);
|
2000-08-18 22:16:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// set directory
|
|
|
|
nsCOMPtr<nsIFile> parentFile;
|
|
|
|
currentFile->GetParent(getter_AddRefs(parentFile));
|
|
|
|
if (parentFile) {
|
|
|
|
nsCOMPtr<nsILocalFile> parentLocalFile = do_QueryInterface(parentFile, &result);
|
|
|
|
if (parentLocalFile)
|
|
|
|
filePicker->SetDisplayDirectory(parentLocalFile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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) {
|
2000-12-01 00:39:28 +03:00
|
|
|
PRUnichar *nativePath = nsnull;
|
2000-08-18 22:16:12 +04:00
|
|
|
result = localFile->GetUnicodePath(&nativePath);
|
|
|
|
if (nativePath) {
|
|
|
|
nsAutoString pathName(nativePath);
|
2000-02-11 04:08:56 +03:00
|
|
|
mTextFrame->SetProperty(mPresContext, nsHTMLAtoms::value, pathName);
|
2000-12-01 00:39:28 +03:00
|
|
|
nsMemory::Free(nativePath);
|
2000-08-18 22:16:12 +04:00
|
|
|
return NS_OK;
|
1999-09-19 11:25:12 +04:00
|
|
|
}
|
1998-09-23 21:16:51 +04:00
|
|
|
}
|
2000-08-18 22:16:12 +04:00
|
|
|
|
|
|
|
return NS_FAILED(result) ? result : NS_ERROR_FAILURE;
|
1998-09-23 21:16:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_IMETHODIMP nsFileControlFrame::Reflow(nsIPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-09-23 21:16:51 +04:00
|
|
|
{
|
2000-04-22 01:51:35 +04:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsFileControlFrame", aReflowState.reason);
|
2001-11-14 16:40:03 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
2000-04-22 01:51:35 +04:00
|
|
|
|
2000-09-10 02:13:12 +04:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
|
1999-07-01 02:17:43 +04:00
|
|
|
if (mFormFrame == nsnull && eReflowReason_Initial == aReflowState.reason) {
|
|
|
|
// add ourself as an nsIFormControlFrame
|
1999-11-24 09:03:41 +03:00
|
|
|
nsFormFrame::AddFormControlFrame(aPresContext, *NS_STATIC_CAST(nsIFrame*, this));
|
2000-01-22 04:16:50 +03:00
|
|
|
mTextFrame = GetTextControlFrame(aPresContext, this);
|
1999-09-15 09:31:31 +04:00
|
|
|
if (!mTextFrame) return NS_ERROR_UNEXPECTED;
|
|
|
|
if (mCachedState) {
|
1999-11-24 09:03:41 +03:00
|
|
|
mTextFrame->SetProperty(aPresContext, nsHTMLAtoms::value, *mCachedState);
|
1999-09-15 09:31:31 +04:00
|
|
|
delete mCachedState;
|
|
|
|
mCachedState = nsnull;
|
|
|
|
}
|
1999-05-08 00:30:16 +04:00
|
|
|
}
|
|
|
|
|
2000-03-28 02:20:06 +04:00
|
|
|
// The Areaframe takes care of all our reflow
|
|
|
|
// except for when style is used to change its size.
|
|
|
|
nsresult rv = nsAreaFrame::Reflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
2000-08-18 22:16:12 +04:00
|
|
|
if (NS_SUCCEEDED(rv) && mTextFrame != nsnull) {
|
2000-03-28 02:20:06 +04:00
|
|
|
nsIFrame * child;
|
|
|
|
FirstChild(aPresContext, nsnull, &child);
|
|
|
|
while (child == mTextFrame) {
|
|
|
|
child->GetNextSibling(&child);
|
|
|
|
}
|
|
|
|
if (child != nsnull) {
|
|
|
|
nsRect buttonRect;
|
|
|
|
nsRect txtRect;
|
|
|
|
mTextFrame->GetRect(txtRect);
|
|
|
|
child->GetRect(buttonRect);
|
|
|
|
|
|
|
|
// check to see if we must reflow just the texField
|
|
|
|
// because style width or height was set.
|
|
|
|
if (txtRect.width + buttonRect.width != aDesiredSize.width ||
|
|
|
|
txtRect.height != aDesiredSize.height) {
|
|
|
|
|
|
|
|
nsSize txtAvailSize(aDesiredSize.width - buttonRect.width, aDesiredSize.height);
|
|
|
|
nsHTMLReflowMetrics txtKidSize(&txtAvailSize);
|
|
|
|
nsHTMLReflowState txtKidReflowState(aPresContext, aReflowState, mTextFrame, txtAvailSize);
|
2000-06-07 05:21:20 +04:00
|
|
|
txtKidReflowState.reason = eReflowReason_Resize;
|
2000-03-28 02:20:06 +04:00
|
|
|
txtKidReflowState.mComputedWidth = txtAvailSize.width;
|
|
|
|
txtKidReflowState.mComputedHeight = txtAvailSize.height;
|
|
|
|
mTextFrame->WillReflow(aPresContext);
|
|
|
|
nsReflowStatus status;
|
|
|
|
rv = mTextFrame->Reflow(aPresContext, txtKidSize, txtKidReflowState, status);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
2001-12-07 17:51:12 +03:00
|
|
|
rv = mTextFrame->DidReflow(aPresContext, &txtKidReflowState, aStatus);
|
2000-03-28 02:20:06 +04:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
// now adjust the frame positions
|
|
|
|
buttonRect.x = aDesiredSize.width - buttonRect.width + aReflowState.mComputedBorderPadding.left;
|
|
|
|
child->SetRect(aPresContext, buttonRect);
|
|
|
|
txtRect.y = aReflowState.mComputedBorderPadding.top;
|
|
|
|
txtRect.height = aDesiredSize.height;
|
|
|
|
txtRect.width = aDesiredSize.width - buttonRect.width;
|
|
|
|
mTextFrame->SetRect(aPresContext, txtRect);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rv;
|
1999-07-01 02:17:43 +04:00
|
|
|
}
|
1998-09-23 21:16:51 +04:00
|
|
|
|
1999-07-01 02:17:43 +04:00
|
|
|
/*
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsFileControlFrame::SetInitialChildList(nsIPresContext* aPresContext,
|
1999-07-01 02:17:43 +04:00
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aChildList)
|
|
|
|
{
|
|
|
|
nsresult r = nsAreaFrame::SetInitialChildList(aPresContext, aListName, aChildList);
|
1998-09-23 21:16:51 +04:00
|
|
|
|
1999-07-01 02:17:43 +04:00
|
|
|
// given that the CSS frame constuctor created all our frames. We need to find the text field
|
|
|
|
// so we can get info from it.
|
|
|
|
mTextFrame = GetTextControlFrame(this);
|
|
|
|
}
|
|
|
|
*/
|
1998-09-23 21:16:51 +04:00
|
|
|
|
1999-07-01 02:17:43 +04:00
|
|
|
/**
|
|
|
|
* Given a start node. Find the given text node inside. We need to do this because the
|
|
|
|
* frame constuctor create the frame and its implementation. So we are given the text
|
|
|
|
* node from the constructor and we find it in our tree.
|
|
|
|
*/
|
2000-05-17 03:29:35 +04:00
|
|
|
|
|
|
|
nsNewFrame*
|
2000-01-22 04:16:50 +03:00
|
|
|
nsFileControlFrame::GetTextControlFrame(nsIPresContext* aPresContext, nsIFrame* aStart)
|
1999-07-01 02:17:43 +04:00
|
|
|
{
|
2000-05-17 03:29:35 +04:00
|
|
|
nsNewFrame* result = nsnull;
|
2000-08-18 22:16:12 +04:00
|
|
|
#ifndef DEBUG_NEWFRAME
|
1999-07-01 02:17:43 +04:00
|
|
|
// find the text control frame.
|
|
|
|
nsIFrame* childFrame = nsnull;
|
2000-01-22 04:16:50 +03:00
|
|
|
aStart->FirstChild(aPresContext, nsnull, &childFrame);
|
1999-07-01 02:17:43 +04:00
|
|
|
|
1999-09-15 09:31:31 +04:00
|
|
|
while (childFrame) {
|
1999-07-01 02:17:43 +04:00
|
|
|
// see if the child is a text control
|
|
|
|
nsCOMPtr<nsIContent> content;
|
2000-02-23 23:58:42 +03:00
|
|
|
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) {
|
|
|
|
|
|
|
|
// It's an input, is it a text input?
|
|
|
|
nsAutoString value;
|
2001-08-17 12:14:14 +04:00
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == content->GetAttr(kNameSpaceID_None, nsHTMLAtoms::type, value)) {
|
2000-02-23 23:58:42 +03:00
|
|
|
if (value.EqualsIgnoreCase("text")) {
|
2000-05-17 03:29:35 +04:00
|
|
|
result = (nsNewFrame*)childFrame;
|
2000-02-23 23:58:42 +03:00
|
|
|
}
|
|
|
|
}
|
1999-08-19 18:03:53 +04:00
|
|
|
}
|
1999-07-01 02:17:43 +04:00
|
|
|
}
|
1998-10-01 08:46:11 +04:00
|
|
|
}
|
1998-09-23 21:16:51 +04:00
|
|
|
|
1999-07-01 02:17:43 +04:00
|
|
|
// if not continue looking
|
2000-05-17 03:29:35 +04:00
|
|
|
nsNewFrame* frame = GetTextControlFrame(aPresContext, childFrame);
|
1999-09-15 09:31:31 +04:00
|
|
|
if (frame)
|
2000-02-23 23:58:42 +03:00
|
|
|
result = frame;
|
1999-07-01 02:17:43 +04:00
|
|
|
|
2000-02-23 23:58:42 +03:00
|
|
|
res = childFrame->GetNextSibling(&childFrame);
|
|
|
|
NS_ASSERTION(res == NS_OK,"failed to get next child");
|
1998-09-23 21:16:51 +04:00
|
|
|
}
|
|
|
|
|
2000-02-23 23:58:42 +03:00
|
|
|
return result;
|
2000-08-18 22:16:12 +04:00
|
|
|
#else
|
|
|
|
return nsnull;
|
|
|
|
#endif
|
1998-09-23 21:16:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
PRIntn
|
|
|
|
nsFileControlFrame::GetSkipSides() const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-11-02 10:40:01 +03:00
|
|
|
nsFileControlFrame::GetName(nsAString* aResult)
|
1998-09-23 21:16:51 +04:00
|
|
|
{
|
|
|
|
nsresult result = NS_FORM_NOTOK;
|
|
|
|
if (mContent) {
|
|
|
|
nsIHTMLContent* formControl = nsnull;
|
|
|
|
result = mContent->QueryInterface(kIHTMLContentIID, (void**)&formControl);
|
|
|
|
if ((NS_OK == result) && formControl) {
|
|
|
|
nsHTMLValue value;
|
1998-12-20 04:21:23 +03:00
|
|
|
result = formControl->GetHTMLAttribute(nsHTMLAtoms::name, value);
|
1998-09-23 21:16:51 +04:00
|
|
|
if (NS_CONTENT_ATTR_HAS_VALUE == result) {
|
|
|
|
if (eHTMLUnit_String == value.GetUnit()) {
|
|
|
|
value.GetStringValue(*aResult);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_RELEASE(formControl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1999-02-11 04:13:28 +03:00
|
|
|
|
1999-08-19 18:03:53 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFileControlFrame::AttributeChanged(nsIPresContext* aPresContext,
|
|
|
|
nsIContent* aChild,
|
1999-10-16 03:16:45 +04:00
|
|
|
PRInt32 aNameSpaceID,
|
1999-08-19 18:03:53 +04:00
|
|
|
nsIAtom* aAttribute,
|
2001-08-25 06:01:08 +04:00
|
|
|
PRInt32 aModType,
|
1999-08-19 18:03:53 +04:00
|
|
|
PRInt32 aHint)
|
|
|
|
{
|
|
|
|
// set the text control to readonly or not
|
|
|
|
if (nsHTMLAtoms::disabled == aAttribute) {
|
1999-09-08 03:20:32 +04:00
|
|
|
nsCOMPtr<nsIDOMHTMLInputElement> textControl = do_QueryInterface(mTextContent);
|
|
|
|
if (textControl)
|
|
|
|
{
|
|
|
|
textControl->SetDisabled(nsFormFrame::GetDisabled(this));
|
|
|
|
}
|
2000-01-14 02:34:01 +03:00
|
|
|
} else if (nsHTMLAtoms::size == aAttribute) {
|
|
|
|
nsString value;
|
2001-08-17 12:14:14 +04:00
|
|
|
if (nsnull != mTextContent && NS_CONTENT_ATTR_HAS_VALUE == mContent->GetAttr(kNameSpaceID_None, nsHTMLAtoms::size, value)) {
|
|
|
|
mTextContent->SetAttr(kNameSpaceID_None, nsHTMLAtoms::size, value, PR_TRUE);
|
2000-01-14 02:34:01 +03:00
|
|
|
if (aHint != NS_STYLE_HINT_REFLOW) {
|
|
|
|
nsFormFrame::StyleChangeReflow(aPresContext, this);
|
|
|
|
}
|
|
|
|
}
|
1999-08-19 18:03:53 +04:00
|
|
|
}
|
|
|
|
|
2001-08-25 06:01:08 +04:00
|
|
|
return nsAreaFrame::AttributeChanged(aPresContext, aChild, aNameSpaceID, aAttribute, aModType, aHint);
|
1999-08-19 18:03:53 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-10-26 08:44:41 +04:00
|
|
|
nsFileControlFrame::GetFrameForPoint(nsIPresContext* aPresContext,
|
|
|
|
const nsPoint& aPoint,
|
2000-03-22 05:43:08 +03:00
|
|
|
nsFramePaintLayer aWhichLayer,
|
1999-10-26 08:44:41 +04:00
|
|
|
nsIFrame** aFrame)
|
1999-08-19 18:03:53 +04:00
|
|
|
{
|
2000-08-18 22:16:12 +04:00
|
|
|
#ifndef DEBUG_NEWFRAME
|
2000-03-22 05:43:08 +03:00
|
|
|
if ( nsFormFrame::GetDisabled(this) && mRect.Contains(aPoint) ) {
|
2001-06-01 02:19:43 +04:00
|
|
|
const nsStyleVisibility* vis =
|
|
|
|
(const nsStyleVisibility*)mStyleContext->GetStyleData(eStyleStruct_Visibility);
|
|
|
|
|
|
|
|
if (vis->IsVisible()) {
|
2000-03-22 05:43:08 +03:00
|
|
|
*aFrame = this;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-08-19 18:03:53 +04:00
|
|
|
} else {
|
2000-03-22 05:43:08 +03:00
|
|
|
return nsAreaFrame::GetFrameForPoint(aPresContext, aPoint, aWhichLayer, aFrame);
|
1999-08-19 18:03:53 +04:00
|
|
|
}
|
2000-08-18 22:16:12 +04:00
|
|
|
#endif
|
1999-08-19 18:03:53 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef NS_DEBUG
|
1998-11-19 20:22:29 +03:00
|
|
|
NS_IMETHODIMP
|
2001-11-14 04:33:42 +03:00
|
|
|
nsFileControlFrame::GetFrameName(nsAString& aResult) const
|
1998-11-19 20:22:29 +03:00
|
|
|
{
|
2001-11-14 04:33:42 +03:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("FileControl"), aResult);
|
1998-11-19 20:22:29 +03:00
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
1999-01-22 18:32:57 +03:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFileControlFrame::GetFormContent(nsIContent*& aContent) const
|
|
|
|
{
|
1999-02-10 03:42:56 +03:00
|
|
|
nsIContent* content;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
rv = GetContent(&content);
|
|
|
|
aContent = content;
|
|
|
|
return rv;
|
1999-01-22 18:32:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2000-01-25 18:24:48 +03:00
|
|
|
nsFileControlFrame::GetFont(nsIPresContext* aPresContext,
|
|
|
|
const nsFont*& aFont)
|
1999-01-22 18:32:57 +03:00
|
|
|
{
|
2000-01-25 18:24:48 +03:00
|
|
|
return nsFormControlHelper::GetFont(this, aPresContext, mStyleContext, aFont);
|
1999-01-22 18:32:57 +03:00
|
|
|
}
|
|
|
|
nscoord
|
1999-11-24 09:03:41 +03:00
|
|
|
nsFileControlFrame::GetVerticalInsidePadding(nsIPresContext* aPresContext,
|
1999-09-30 15:30:04 +04:00
|
|
|
float aPixToTwip,
|
|
|
|
nscoord aInnerHeight) const
|
1999-01-22 18:32:57 +03:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
1999-11-24 09:03:41 +03:00
|
|
|
nsFileControlFrame::GetHorizontalInsidePadding(nsIPresContext* aPresContext,
|
1999-01-22 18:32:57 +03:00
|
|
|
float aPixToTwip,
|
|
|
|
nscoord aInnerWidth,
|
|
|
|
nscoord aCharWidth) const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
1999-01-26 01:16:27 +03:00
|
|
|
|
1999-03-06 22:43:13 +03:00
|
|
|
nsresult nsFileControlFrame::RequiresWidget(PRBool& aRequiresWidget)
|
|
|
|
{
|
|
|
|
aRequiresWidget = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-02-11 04:13:28 +03:00
|
|
|
|
1999-10-26 08:44:41 +04:00
|
|
|
NS_IMETHODIMP nsFileControlFrame::SetProperty(nsIPresContext* aPresContext,
|
|
|
|
nsIAtom* aName,
|
2000-08-23 21:27:06 +04:00
|
|
|
const nsAReadableString& aValue)
|
1999-01-26 01:16:27 +03:00
|
|
|
{
|
1999-09-19 11:25:12 +04:00
|
|
|
nsresult rv = NS_OK;
|
1999-02-11 04:13:28 +03:00
|
|
|
if (nsHTMLAtoms::value == aName) {
|
1999-09-19 11:25:12 +04:00
|
|
|
if (mTextFrame) {
|
|
|
|
mTextFrame->SetTextControlFrameState(aValue);
|
|
|
|
} else {
|
|
|
|
if (mCachedState) delete mCachedState;
|
|
|
|
mCachedState = new nsString(aValue);
|
|
|
|
if (!mCachedState) rv = NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1999-02-11 04:13:28 +03:00
|
|
|
}
|
1999-09-19 11:25:12 +04:00
|
|
|
return rv;
|
1999-02-11 04:13:28 +03:00
|
|
|
}
|
1999-01-26 01:16:27 +03:00
|
|
|
|
2000-08-23 21:27:06 +04:00
|
|
|
NS_IMETHODIMP nsFileControlFrame::GetProperty(nsIAtom* aName, nsAWritableString& aValue)
|
1999-01-26 01:16:27 +03:00
|
|
|
{
|
2001-04-24 12:33:57 +04:00
|
|
|
aValue.Truncate(); // initialize out param
|
1999-02-11 04:13:28 +03:00
|
|
|
|
|
|
|
if (nsHTMLAtoms::value == aName) {
|
2001-04-24 12:33:57 +04:00
|
|
|
if (mTextFrame) {
|
2000-05-13 03:11:04 +04:00
|
|
|
mTextFrame->GetTextControlFrameState(aValue);
|
2001-04-24 12:33:57 +04:00
|
|
|
}
|
|
|
|
else if (mCachedState) {
|
|
|
|
aValue.Assign(*mCachedState);
|
|
|
|
}
|
1999-02-11 04:13:28 +03:00
|
|
|
}
|
1999-01-26 01:16:27 +03:00
|
|
|
return NS_OK;
|
1999-02-18 03:13:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-02-11 04:13:28 +03:00
|
|
|
|
|
|
|
|
|
|
|
NS_METHOD
|
2001-09-19 16:35:19 +04:00
|
|
|
nsFileControlFrame::Paint(nsIPresContext* aPresContext,
|
1999-02-11 04:13:28 +03:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
2001-09-19 16:35:19 +04:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
PRUint32 aFlags)
|
1999-02-11 04:13:28 +03:00
|
|
|
{
|
2001-01-27 17:09:34 +03:00
|
|
|
PRBool isVisible;
|
|
|
|
if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_TRUE, &isVisible)) && !isVisible) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-04-13 04:30:37 +04:00
|
|
|
nsresult rv = nsAreaFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
return nsFrame::Paint(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
|
1999-01-26 01:16:27 +03:00
|
|
|
}
|
1999-09-15 09:31:31 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// nsIStatefulFrame
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
NS_IMETHODIMP
|
2000-01-14 12:28:54 +03:00
|
|
|
nsFileControlFrame::SaveState(nsIPresContext* aPresContext, nsIPresState** aState)
|
1999-09-15 09:31:31 +04:00
|
|
|
{
|
2001-02-06 04:59:59 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(aState);
|
|
|
|
|
2001-04-24 12:33:57 +04:00
|
|
|
// Don't save state before we are initialized
|
|
|
|
if (!mTextFrame && !mCachedState) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-02-06 04:59:59 +03:00
|
|
|
// Get the value string
|
2000-01-14 12:28:54 +03:00
|
|
|
nsAutoString stateString;
|
2001-02-06 04:59:59 +03:00
|
|
|
nsresult res = GetProperty(nsHTMLAtoms::value, stateString);
|
|
|
|
NS_ENSURE_SUCCESS(res, res);
|
|
|
|
|
|
|
|
// Compare to default value, and only save if needed (Bug 62713)
|
|
|
|
nsAutoString defaultStateString;
|
|
|
|
nsCOMPtr<nsIDOMHTMLInputElement> formControl(do_QueryInterface(mContent));
|
|
|
|
if (formControl) {
|
|
|
|
formControl->GetDefaultValue(defaultStateString);
|
|
|
|
}
|
2000-01-14 12:28:54 +03:00
|
|
|
|
2001-02-06 04:59:59 +03:00
|
|
|
if (! stateString.Equals(defaultStateString)) {
|
|
|
|
|
|
|
|
// Construct a pres state and store value in it.
|
|
|
|
res = NS_NewPresState(aState);
|
|
|
|
NS_ENSURE_SUCCESS(res, res);
|
|
|
|
res = (*aState)->SetStateProperty(NS_LITERAL_STRING("value"), stateString);
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
1999-09-15 09:31:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2000-01-14 12:28:54 +03:00
|
|
|
nsFileControlFrame::RestoreState(nsIPresContext* aPresContext, nsIPresState* aState)
|
|
|
|
{
|
2001-02-06 04:59:59 +03:00
|
|
|
NS_ENSURE_ARG_POINTER(aState);
|
|
|
|
|
2000-01-14 12:28:54 +03:00
|
|
|
nsAutoString string;
|
2001-02-06 04:59:59 +03:00
|
|
|
aState->GetStateProperty(NS_LITERAL_STRING("value"), string);
|
2000-01-14 12:28:54 +03:00
|
|
|
SetProperty(aPresContext, nsHTMLAtoms::value, string);
|
|
|
|
|
2001-02-06 04:59:59 +03:00
|
|
|
return NS_OK;
|
1999-09-15 09:31:31 +04:00
|
|
|
}
|
2001-11-02 10:40:01 +03:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsFileControlFrame::OnContentReset()
|
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|