Back out bug 567323 because of consistent Mochitest-4 errors:

1530 ERROR TEST-UNEXPECTED-FAIL | /tests/layout/forms/test/test_bug411236.html | Test timed out.
1578 ERROR TEST-UNEXPECTED-FAIL | /tests/layout/forms/test/test_bug534785.html | Test timed out.
1702 ERROR TEST-UNEXPECTED-FAIL | /tests/layout/forms/test/test_bug563642.html | Test timed out.
1709 ERROR TEST-UNEXPECTED-FAIL | /tests/layout/forms/test/test_bug564115.html | Test timed out.
This commit is contained in:
Benjamin Smedberg 2010-07-23 16:16:39 -04:00
Родитель e06de39084
Коммит dc487751c4
4 изменённых файлов: 32 добавлений и 349 удалений

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

@ -52,7 +52,7 @@ MODULE = layout
LIBRARY_NAME = gkforms_s
LIBXUL_LIBRARY = 1
XPIDLSRCS = nsICapturePicker.idl
EXPORTS = \
nsIListControlFrame.h \

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

@ -93,8 +93,6 @@
#include "mozilla/Services.h"
#include "nsDirectoryServiceDefs.h"
#include "nsCharSeparatedTokenizer.h"
#include "nsICapturePicker.h"
#include "nsIFileURL.h"
#define SYNC_TEXT 0x1
#define SYNC_BUTTON 0x2
@ -159,10 +157,8 @@ nsFileControlFrame::Init(nsIContent* aContent,
nsresult rv = nsBlockFrame::Init(aContent, aParent, aPrevInFlow);
NS_ENSURE_SUCCESS(rv, rv);
mMouseListener = new BrowseMouseListener(this);
mCaptureMouseListener = new CaptureMouseListener(this);
NS_ASSERTION(mMouseListener && mCaptureMouseListener,
"What happened to infallible malloc?");
mMouseListener = new MouseListener(this);
NS_ENSURE_TRUE(mMouseListener, NS_ERROR_OUT_OF_MEMORY);
if (!gUploadLastDir)
nsFileControlFrame::InitUploadLastDir();
@ -182,11 +178,6 @@ nsFileControlFrame::DestroyFrom(nsIFrame* aDestructRoot)
nsCOMPtr<nsIDOMEventGroup> systemGroup;
mContent->GetSystemEventGroup(getter_AddRefs(systemGroup));
nsCOMPtr<nsIDOM3EventTarget> dom3Capture = do_QueryInterface(mCapture);
if (dom3Capture) {
nsContentUtils::DestroyAnonymousContent(&mCapture);
}
nsCOMPtr<nsIDOM3EventTarget> dom3Browse = do_QueryInterface(mBrowse);
if (dom3Browse) {
dom3Browse->RemoveGroupedEventListener(click, mMouseListener, PR_FALSE,
@ -201,62 +192,10 @@ nsFileControlFrame::DestroyFrom(nsIFrame* aDestructRoot)
nsContentUtils::DestroyAnonymousContent(&mTextContent);
}
mCaptureMouseListener->ForgetFrame();
mMouseListener->ForgetFrame();
nsBlockFrame::DestroyFrom(aDestructRoot);
}
struct CaptureCallbackData {
nsICapturePicker* picker;
PRUint32* mode;
};
typedef struct CaptureCallbackData CaptureCallbackData;
PRBool CapturePickerAcceptCallback(const nsAString& aAccept, void* aClosure)
{
nsresult rv;
PRBool captureEnabled;
CaptureCallbackData* closure = (CaptureCallbackData*)aClosure;
if (StringBeginsWith(aAccept,
NS_LITERAL_STRING("image/"))) {
rv = closure->picker->ModeMayBeAvailable(nsICapturePicker::MODE_STILL,
&captureEnabled);
NS_ENSURE_SUCCESS(rv, rv);
if (captureEnabled) {
*closure->mode = nsICapturePicker::MODE_STILL;
return PR_FALSE;
}
} else if (StringBeginsWith(aAccept,
NS_LITERAL_STRING("audio/"))) {
rv = closure->picker->ModeMayBeAvailable(nsICapturePicker::MODE_AUDIO_CLIP,
&captureEnabled);
NS_ENSURE_SUCCESS(rv, rv);
if (captureEnabled) {
*closure->mode = nsICapturePicker::MODE_AUDIO_CLIP;
return PR_FALSE;
}
} else if (StringBeginsWith(aAccept,
NS_LITERAL_STRING("video/"))) {
rv = closure->picker->ModeMayBeAvailable(nsICapturePicker::MODE_VIDEO_CLIP,
&captureEnabled);
NS_ENSURE_SUCCESS(rv, rv);
if (captureEnabled) {
*closure->mode = nsICapturePicker::MODE_VIDEO_CLIP;
return PR_FALSE;
}
rv = closure->picker->ModeMayBeAvailable(nsICapturePicker::MODE_VIDEO_NO_SOUND_CLIP,
&captureEnabled);
NS_ENSURE_SUCCESS(rv, rv);
if (captureEnabled) {
*closure->mode = nsICapturePicker::MODE_VIDEO_NO_SOUND_CLIP;
return PR_FALSE;;
}
}
return PR_TRUE;
}
nsresult
nsFileControlFrame::CreateAnonymousContent(nsTArray<nsIContent*>& aElements)
{
@ -319,40 +258,6 @@ nsFileControlFrame::CreateAnonymousContent(nsTArray<nsIContent*>& aElements)
mBrowse->SetAttr(kNameSpaceID_None, nsGkAtoms::type,
NS_LITERAL_STRING("button"), PR_FALSE);
// Create the capture button
nsCOMPtr<nsICapturePicker> capturePicker;
capturePicker = do_GetService("@mozilla.org/capturepicker;1");
if (capturePicker) {
PRUint32 mode = 0;
CaptureCallbackData data;
data.picker = capturePicker;
data.mode = &mode;
ParseAcceptAttribute(&CapturePickerAcceptCallback, (void*)&data);
if (mode != 0) {
mCaptureMouseListener->mMode = mode;
nodeInfo = doc->NodeInfoManager()->GetNodeInfo(nsGkAtoms::input, nsnull,
kNameSpaceID_XHTML);
NS_NewHTMLElement(getter_AddRefs(mCapture), nodeInfo.forget(), PR_FALSE);
if (!mCapture)
return NS_ERROR_OUT_OF_MEMORY;
// Mark the element to be native anonymous before setting any attributes.
mCapture->SetNativeAnonymous();
mCapture->SetAttr(kNameSpaceID_None, nsGkAtoms::type,
NS_LITERAL_STRING("button"), PR_FALSE);
mCapture->SetAttr(kNameSpaceID_None, nsGkAtoms::value,
NS_LITERAL_STRING("capture"), PR_FALSE);
nsCOMPtr<nsIDOMEventTarget> captureEventTarget =
do_QueryInterface(mCapture);
captureEventTarget->AddEventListener(click, mCaptureMouseListener, PR_FALSE);
}
}
nsCOMPtr<nsIDOMHTMLInputElement> fileContent = do_QueryInterface(mContent);
nsCOMPtr<nsIDOMHTMLInputElement> browseControl = do_QueryInterface(mBrowse);
if (fileContent && browseControl) {
@ -368,9 +273,6 @@ nsFileControlFrame::CreateAnonymousContent(nsTArray<nsIContent*>& aElements)
if (!aElements.AppendElement(mBrowse))
return NS_ERROR_OUT_OF_MEMORY;
if (mCapture && !aElements.AppendElement(mCapture))
return NS_ERROR_OUT_OF_MEMORY;
nsCOMPtr<nsIDOM3EventTarget> dom3Browse = do_QueryInterface(mBrowse);
NS_ENSURE_STATE(dom3Browse);
// Register as an event listener of the button
@ -389,7 +291,6 @@ nsFileControlFrame::AppendAnonymousContentTo(nsBaseContentList& aElements)
{
aElements.MaybeAppendElement(mTextContent);
aElements.MaybeAppendElement(mBrowse);
aElements.MaybeAppendElement(mCapture);
}
NS_QUERYFRAME_HEAD(nsFileControlFrame)
@ -402,6 +303,9 @@ nsFileControlFrame::SetFocus(PRBool aOn, PRBool aRepaint)
{
}
/**
* This is called when our browse button is clicked
*/
NS_IMETHODIMP
nsFileControlFrame::MouseListener::MouseClick(nsIDOMEvent* aMouseEvent)
{
@ -427,113 +331,7 @@ nsFileControlFrame::MouseListener::MouseClick(nsIDOMEvent* aMouseEvent)
return NS_OK;
}
return NS_OK;
}
/**
* This is called when our capture button is clicked
*/
NS_IMETHODIMP
nsFileControlFrame::CaptureMouseListener::MouseClick(nsIDOMEvent* aMouseEvent)
{
nsresult rv;
rv = nsFileControlFrame::MouseListener::MouseClick(aMouseEvent);
NS_ENSURE_SUCCESS(rv, rv);
// Get parent nsIDOMWindowInternal object.
nsIContent* content = mFrame->GetContent();
nsCOMPtr<nsIDOMNSHTMLInputElement> inputElem = do_QueryInterface(content);
nsCOMPtr<nsIFileControlElement> fileControl = do_QueryInterface(content);
if (!content || !inputElem || !fileControl)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIDocument> doc = content->GetDocument();
if (!doc)
return NS_ERROR_FAILURE;
// Get Loc title
nsXPIDLString title;
nsContentUtils::GetLocalizedString(nsContentUtils::eFORMS_PROPERTIES,
"FileUpload", title);
nsPIDOMWindow* win = doc->GetWindow();
if (!win) {
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsICapturePicker> capturePicker;
capturePicker = do_CreateInstance("@mozilla.org/capturepicker;1");
if (!capturePicker)
return NS_ERROR_FAILURE;
rv = capturePicker->Init(win, title, mMode);
NS_ENSURE_SUCCESS(rv, rv);
// Tell our textframe to remember the currently focused value
mFrame->mTextFrame->InitFocusedValue();
// Show dialog
PRUint32 result;
rv = capturePicker->Show(&result);
NS_ENSURE_SUCCESS(rv, rv);
if (result == nsICapturePicker::RETURN_CANCEL)
return NS_OK;
if (!mFrame) {
// The frame got destroyed while the filepicker was up. Don't do
// anything here.
// (This listener itself can't be destroyed because the event listener
// manager holds a strong reference to us while it fires the event.)
return NS_OK;
}
nsCOMPtr<nsIURI> uri;
rv = capturePicker->GetUri(getter_AddRefs(uri));
NS_ENSURE_SUCCESS(rv, rv);
nsTArray<nsString> newFileNames;
if (uri) {
nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(uri);
if (!fileURL)
return NS_ERROR_UNEXPECTED;
nsCAutoString spec;
rv = uri->GetSpec(spec);
NS_ENSURE_SUCCESS(rv, rv);
newFileNames.AppendElement(NS_ConvertUTF8toUTF16(spec));
} else {
return NS_ERROR_FAILURE;
}
// XXXkhuey we really should have a better UI story than the tired old
// uneditable text box with the file name inside.
// Set new selected files
if (!newFileNames.IsEmpty()) {
// Tell mTextFrame that this update of the value is a user initiated
// change. Otherwise it'll think that the value is being set by a script
// and not fire onchange when it should.
PRBool oldState = mFrame->mTextFrame->GetFireChangeEventState();
mFrame->mTextFrame->SetFireChangeEventState(PR_TRUE);
fileControl->SetFileNames(newFileNames);
mFrame->mTextFrame->SetFireChangeEventState(oldState);
// May need to fire an onchange here
mFrame->mTextFrame->CheckFireOnChange();
}
return NS_OK;
}
/**
* This is called when our browse button is clicked
*/
NS_IMETHODIMP
nsFileControlFrame::BrowseMouseListener::MouseClick(nsIDOMEvent* aMouseEvent)
{
nsresult rv;
rv = nsFileControlFrame::MouseListener::MouseClick(aMouseEvent);
NS_ENSURE_SUCCESS(rv, rv);
nsresult result;
// Get parent nsIDOMWindowInternal object.
nsIContent* content = mFrame->GetContent();
@ -561,13 +359,14 @@ nsFileControlFrame::BrowseMouseListener::MouseClick(nsIDOMEvent* aMouseEvent)
}
PRBool multi;
rv = inputElem->GetMultiple(&multi);
NS_ENSURE_SUCCESS(rv, rv);
result = inputElem->GetMultiple(&multi);
NS_ENSURE_SUCCESS(result, result);
rv = filePicker->Init(win, title, multi ?
(PRInt16)nsIFilePicker::modeOpenMultiple :
(PRInt16)nsIFilePicker::modeOpen);
NS_ENSURE_SUCCESS(rv, rv);
result = filePicker->Init(win, title, multi ?
(PRInt16)nsIFilePicker::modeOpenMultiple :
(PRInt16)nsIFilePicker::modeOpen);
if (NS_FAILED(result))
return result;
// We want to get the file filter from the accept attribute and we add the
// |filterAll| filter to be sure the user has a valid fallback.
@ -593,7 +392,7 @@ nsFileControlFrame::BrowseMouseListener::MouseClick(nsIDOMEvent* aMouseEvent)
nsCOMPtr<nsIFile> parentFile;
oldFiles[0]->GetParent(getter_AddRefs(parentFile));
if (parentFile) {
nsCOMPtr<nsILocalFile> parentLocalFile = do_QueryInterface(parentFile, &rv);
nsCOMPtr<nsILocalFile> parentLocalFile = do_QueryInterface(parentFile, &result);
if (parentLocalFile) {
filePicker->SetDisplayDirectory(parentLocalFile);
}
@ -628,8 +427,9 @@ nsFileControlFrame::BrowseMouseListener::MouseClick(nsIDOMEvent* aMouseEvent)
// Open dialog
PRInt16 mode;
rv = filePicker->Show(&mode);
NS_ENSURE_SUCCESS(rv, rv);
result = filePicker->Show(&mode);
if (NS_FAILED(result))
return result;
if (mode == nsIFilePicker::returnCancel)
return NS_OK;
@ -645,8 +445,8 @@ nsFileControlFrame::BrowseMouseListener::MouseClick(nsIDOMEvent* aMouseEvent)
nsTArray<nsString> newFileNames;
if (multi) {
nsCOMPtr<nsISimpleEnumerator> iter;
rv = filePicker->GetFiles(getter_AddRefs(iter));
NS_ENSURE_SUCCESS(rv, rv);
result = filePicker->GetFiles(getter_AddRefs(iter));
NS_ENSURE_SUCCESS(result, result);
nsCOMPtr<nsISupports> tmp;
PRBool prefSaved = PR_FALSE;
@ -654,15 +454,15 @@ nsFileControlFrame::BrowseMouseListener::MouseClick(nsIDOMEvent* aMouseEvent)
nsCOMPtr<nsILocalFile> localFile = do_QueryInterface(tmp);
if (localFile) {
nsString unicodePath;
rv = localFile->GetPath(unicodePath);
result = localFile->GetPath(unicodePath);
if (!unicodePath.IsEmpty()) {
newFileNames.AppendElement(unicodePath);
}
if (!prefSaved) {
// Store the last used directory using the content pref service
rv = gUploadLastDir->StoreLastUsedDirectory(doc->GetDocumentURI(),
localFile);
NS_ENSURE_SUCCESS(rv, rv);
result = gUploadLastDir->StoreLastUsedDirectory(doc->GetDocumentURI(),
localFile);
NS_ENSURE_SUCCESS(result, result);
prefSaved = PR_TRUE;
}
}
@ -670,17 +470,17 @@ nsFileControlFrame::BrowseMouseListener::MouseClick(nsIDOMEvent* aMouseEvent)
}
else {
nsCOMPtr<nsILocalFile> localFile;
rv = filePicker->GetFile(getter_AddRefs(localFile));
result = filePicker->GetFile(getter_AddRefs(localFile));
if (localFile) {
nsString unicodePath;
rv = localFile->GetPath(unicodePath);
result = localFile->GetPath(unicodePath);
if (!unicodePath.IsEmpty()) {
newFileNames.AppendElement(unicodePath);
}
// Store the last used directory using the content pref service
rv = gUploadLastDir->StoreLastUsedDirectory(doc->GetDocumentURI(),
localFile);
NS_ENSURE_SUCCESS(rv, rv);
result = gUploadLastDir->StoreLastUsedDirectory(doc->GetDocumentURI(),
localFile);
NS_ENSURE_SUCCESS(result, result);
}
}

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

@ -42,7 +42,6 @@
#include "nsIFormControlFrame.h"
#include "nsIDOMMouseListener.h"
#include "nsIAnonymousContentCreator.h"
#include "nsICapturePicker.h"
#include "nsCOMPtr.h"
#include "nsTextControlFrame.h"
@ -138,30 +137,16 @@ protected:
// and textfield.
NS_IMETHOD MouseDown(nsIDOMEvent* aMouseEvent) { return NS_OK; }
NS_IMETHOD MouseUp(nsIDOMEvent* aMouseEvent) { return NS_OK; }
NS_IMETHOD MouseClick(nsIDOMEvent* aMouseEvent) = 0;
NS_IMETHOD MouseClick(nsIDOMEvent* aMouseEvent);
NS_IMETHOD MouseDblClick(nsIDOMEvent* aMouseEvent) { return NS_OK; }
NS_IMETHOD MouseOver(nsIDOMEvent* aMouseEvent) { return NS_OK; }
NS_IMETHOD MouseOut(nsIDOMEvent* aMouseEvent) { return NS_OK; }
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) { return NS_OK; }
protected:
private:
nsFileControlFrame* mFrame;
};
class CaptureMouseListener: public MouseListener {
public:
CaptureMouseListener(nsFileControlFrame* aFrame) : MouseListener(aFrame),
mMode(0) {};
NS_IMETHOD MouseClick(nsIDOMEvent* aMouseEvent);
PRUint32 mMode;
};
class BrowseMouseListener: public MouseListener {
public:
BrowseMouseListener(nsFileControlFrame* aFrame) : MouseListener(aFrame) {};
NS_IMETHOD MouseClick(nsIDOMEvent* aMouseEvent);
};
virtual PRBool IsFrameOfType(PRUint32 aFlags) const
{
return nsBlockFrame::IsFrameOfType(aFlags &
@ -186,17 +171,10 @@ protected:
*/
nsCOMPtr<nsIContent> mBrowse;
/**
* The capture button input.
* @see nsFileControlFrame::CreateAnonymousContent
*/
nsCOMPtr<nsIContent> mCapture;
/**
* Our mouse listener. This makes sure we don't get used after destruction.
*/
nsRefPtr<BrowseMouseListener> mMouseListener;
nsRefPtr<CaptureMouseListener> mCaptureMouseListener;
nsRefPtr<MouseListener> mMouseListener;
private:
/**

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

@ -1,95 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla 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/MPL/
*
* 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.
*
* The Original Code is the Mozilla camera code.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Kyle Huey <me@kylehuey.com>
*
* 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 MPL, 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 MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
interface nsIDOMWindow;
interface nsIURI;
[scriptable, uuid(a4e2b2de-5712-4f80-aabb-7de3a747f227)]
interface nsICapturePicker : nsISupports
{
const long MODE_STILL = 1; // Capture a still (image)
const long MODE_AUDIO_CLIP = 2; // Capture a clip of audio
const long MODE_VIDEO_CLIP = 3; // Capture a clip of video
const long MODE_VIDEO_NO_SOUND_CLIP = 4; // Capture a clip of video (no sound)
// Return codes from the dialog
const long RETURN_OK = 0;
const long RETURN_CANCEL = 1;
/**
* Initialize the camera picker widget. The camera picker is not valid until this
* method is called.
*
* @param parent nsIDOMWindow parent. This dialog will be dependent
* on this parent. This must not be null.
* @param title The title for the file widget
* @param flags Mode and type flags for what to capture
*
*/
void init(in nsIDOMWindow parent, in AString title, in unsigned long mode);
/**
* Show file dialog. The dialog is displayed modally.
*
* @return returnOK if the user captures the requested content, returnCancel if
* the user cancels the capture process
*/
unsigned long show();
/**
* Determine if the given mode might be available. Consumers should take a
* true value to be a hint of what might be available, not a guarantee.
*
* @param mode Mode to examine
*
* @return false if the requested mode can definitely not be captured,
* true otherwise.
*/
boolean modeMayBeAvailable(in unsigned long mode);
/**
* Get the captured image/video/audio. This may be a data URI, file URI,
* or a moz-filedata reference URI.
*/
readonly attribute nsIURI uri;
// The MIME type of the captured content. Cannot be set after calling show()
attribute AString type;
};