зеркало из https://github.com/mozilla/pjs.git
[XForms] upload control fails to update filename/mediatype (1.8.0 safe version). Bug 353672, r=olli+aaronr
This commit is contained in:
Родитель
236110276d
Коммит
13c85d394f
|
@ -66,6 +66,7 @@
|
|||
#include "nsIDOMDOMImplementation.h"
|
||||
#include "nsIDOMProcessingInstruction.h"
|
||||
#include "nsIDOMParser.h"
|
||||
#include "nsIAttribute.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsStringStream.h"
|
||||
#include "nsIDocShell.h"
|
||||
|
@ -1238,12 +1239,19 @@ nsXFormsSubmissionElement::CreateAttachments(nsIModelElementPrivate *aModel,
|
|||
encType == ELEMENT_ENCTYPE_URI) {
|
||||
// ok, looks like we have a local file to upload
|
||||
|
||||
void* uploadFileProperty = nsnull;
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(currentNode);
|
||||
NS_ENSURE_STATE(content);
|
||||
if (content) {
|
||||
uploadFileProperty =
|
||||
content->GetProperty(nsXFormsAtoms::uploadFileProperty);
|
||||
} else {
|
||||
nsCOMPtr<nsIAttribute> attr = do_QueryInterface(currentNode);
|
||||
NS_ENSURE_STATE(attr);
|
||||
uploadFileProperty =
|
||||
attr->GetProperty(nsXFormsAtoms::uploadFileProperty);
|
||||
}
|
||||
|
||||
nsIFile *file =
|
||||
NS_STATIC_CAST(nsIFile *,
|
||||
content->GetProperty(nsXFormsAtoms::uploadFileProperty));
|
||||
nsIFile *file = NS_STATIC_CAST(nsIFile *, uploadFileProperty);
|
||||
// NOTE: this value may be null if a file hasn't been selected.
|
||||
|
||||
nsCString cid;
|
||||
|
@ -1757,12 +1765,19 @@ nsXFormsSubmissionElement::AppendMultipartFormData(nsIDOMNode *data,
|
|||
nsCOMPtr<nsIInputStream> fileStream;
|
||||
if (encType == ELEMENT_ENCTYPE_URI)
|
||||
{
|
||||
void* uploadFileProperty = nsnull;
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(data);
|
||||
NS_ENSURE_STATE(content);
|
||||
|
||||
nsIFile *file =
|
||||
NS_STATIC_CAST(nsIFile *,
|
||||
content->GetProperty(nsXFormsAtoms::uploadFileProperty));
|
||||
if (content) {
|
||||
uploadFileProperty =
|
||||
content->GetProperty(nsXFormsAtoms::uploadFileProperty);
|
||||
} else {
|
||||
nsCOMPtr<nsIAttribute> attr = do_QueryInterface(data);
|
||||
NS_ENSURE_STATE(attr);
|
||||
uploadFileProperty =
|
||||
attr->GetProperty(nsXFormsAtoms::uploadFileProperty);
|
||||
}
|
||||
|
||||
nsIFile *file = NS_STATIC_CAST(nsIFile *, uploadFileProperty);
|
||||
|
||||
nsAutoString leafName;
|
||||
if (file)
|
||||
|
@ -1856,9 +1871,6 @@ nsXFormsSubmissionElement::GetElementEncodingType(nsIDOMNode *node,
|
|||
{
|
||||
*encType = ELEMENT_ENCTYPE_STRING; // default
|
||||
|
||||
nsCOMPtr<nsIDOMElement> element = do_QueryInterface(node);
|
||||
NS_ENSURE_STATE(element);
|
||||
|
||||
// check for 'xsd:base64Binary', 'xsd:hexBinary', or 'xsd:anyURI'
|
||||
nsAutoString type, nsuri;
|
||||
nsresult rv;
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#include "nsIDOMDocumentView.h"
|
||||
#include "nsIDOMAbstractView.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsIAttribute.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsAutoBuffer.h"
|
||||
#include "nsIEventStateManager.h"
|
||||
|
@ -277,13 +278,21 @@ nsXFormsUploadElement::SetFile(nsILocalFile *aFile)
|
|||
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsINode> node = do_QueryInterface(mBoundNode);
|
||||
NS_ENSURE_STATE(node);
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(mBoundNode);
|
||||
nsCOMPtr<nsIAttribute> attr;
|
||||
if (!content) {
|
||||
attr = do_QueryInterface(mBoundNode);
|
||||
NS_ENSURE_STATE(attr);
|
||||
}
|
||||
|
||||
PRBool dataChanged = PR_FALSE;
|
||||
if (!aFile) {
|
||||
// clear instance data
|
||||
node->DeleteProperty(nsXFormsAtoms::uploadFileProperty);
|
||||
if (content) {
|
||||
content->DeleteProperty(nsXFormsAtoms::uploadFileProperty);
|
||||
} else {
|
||||
attr->DeleteProperty(nsXFormsAtoms::uploadFileProperty);
|
||||
}
|
||||
rv = mModel->SetNodeValue(mBoundNode, EmptyString(), PR_FALSE,
|
||||
&dataChanged);
|
||||
} else {
|
||||
|
@ -320,8 +329,13 @@ nsXFormsUploadElement::SetFile(nsILocalFile *aFile)
|
|||
nsIFile *fileCopy = nsnull;
|
||||
rv = aFile->Clone(&fileCopy);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = node->SetProperty(nsXFormsAtoms::uploadFileProperty, fileCopy,
|
||||
ReleaseObject);
|
||||
if (content) {
|
||||
rv = content->SetProperty(nsXFormsAtoms::uploadFileProperty, fileCopy,
|
||||
ReleaseObject);
|
||||
} else {
|
||||
rv = attr->SetProperty(nsXFormsAtoms::uploadFileProperty, fileCopy,
|
||||
ReleaseObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
|
Загрузка…
Ссылка в новой задаче