From 68c0f2cae5a21b91c7ce96c9e669cf5a9cb4f721 Mon Sep 17 00:00:00 2001 From: Mounir Lamouri Date: Fri, 22 Mar 2013 17:10:13 +0000 Subject: [PATCH] Bug 838354 - Remove all capture button references from nsFileControlFrame. r=bz --- b2g/installer/package-manifest.in | 1 - browser/installer/package-manifest.in | 1 - .../en-US/chrome/layout/HtmlForm.properties | 1 - layout/forms/moz.build | 6 - layout/forms/nsFileControlFrame.cpp | 169 ------------------ layout/forms/nsFileControlFrame.h | 40 +---- layout/forms/nsICapturePicker.idl | 62 ------- mobile/android/installer/package-manifest.in | 1 - 8 files changed, 7 insertions(+), 274 deletions(-) delete mode 100644 layout/forms/nsICapturePicker.idl diff --git a/b2g/installer/package-manifest.in b/b2g/installer/package-manifest.in index 782cb35f93a8..d023639fe7ec 100644 --- a/b2g/installer/package-manifest.in +++ b/b2g/installer/package-manifest.in @@ -243,7 +243,6 @@ @BINPATH@/components/jsdservice.xpt @BINPATH@/components/jsinspector.xpt @BINPATH@/components/layout_base.xpt -@BINPATH@/components/layout_forms.xpt #ifdef NS_PRINTING @BINPATH@/components/layout_printing.xpt #endif diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in index d6b630861a17..8e7b7b67602a 100644 --- a/browser/installer/package-manifest.in +++ b/browser/installer/package-manifest.in @@ -245,7 +245,6 @@ @BINPATH@/components/jsdebugger.xpt @BINPATH@/components/jsinspector.xpt @BINPATH@/components/layout_base.xpt -@BINPATH@/components/layout_forms.xpt #ifdef NS_PRINTING @BINPATH@/components/layout_printing.xpt #endif diff --git a/dom/locales/en-US/chrome/layout/HtmlForm.properties b/dom/locales/en-US/chrome/layout/HtmlForm.properties index 2bfbb960896c..e7d48bc78a43 100644 --- a/dom/locales/en-US/chrome/layout/HtmlForm.properties +++ b/dom/locales/en-US/chrome/layout/HtmlForm.properties @@ -6,7 +6,6 @@ Reset=Reset Submit=Submit Query Browse=Browse… FileUpload=File Upload -MediaUpload=Media Upload # LOCALIZATION NOTE (IsIndexPromptWithSpace): The last character of the string # should be a space (U+0020) in most locales. The prompt is followed by an # input field. The space needs be escaped in the property file to avoid diff --git a/layout/forms/moz.build b/layout/forms/moz.build index 9ebb809aa1ca..2f69f45524dd 100644 --- a/layout/forms/moz.build +++ b/layout/forms/moz.build @@ -5,11 +5,5 @@ TEST_DIRS += ['test'] -XPIDL_SOURCES += [ - 'nsICapturePicker.idl', -] - -XPIDL_MODULE = 'layout_forms' - MODULE = 'layout' diff --git a/layout/forms/nsFileControlFrame.cpp b/layout/forms/nsFileControlFrame.cpp index d42756581639..e02156d4222f 100644 --- a/layout/forms/nsFileControlFrame.cpp +++ b/layout/forms/nsFileControlFrame.cpp @@ -41,8 +41,6 @@ #include "nsIVariant.h" #include "mozilla/Services.h" #include "nsDirectoryServiceDefs.h" -#include "nsICapturePicker.h" -#include "nsIFileURL.h" #include "nsDOMFile.h" #include "nsEventStates.h" #include "nsTextControlFrame.h" @@ -79,7 +77,6 @@ nsFileControlFrame::Init(nsIContent* aContent, nsBlockFrame::Init(aContent, aParent, aPrevInFlow); mMouseListener = new BrowseMouseListener(this); - mCaptureMouseListener = new CaptureMouseListener(this); } void @@ -96,7 +93,6 @@ nsFileControlFrame::DestroyFrom(nsIFrame* aDestructRoot) } // remove mMouseListener as a mouse event listener (bug 40533, bug 355931) - nsContentUtils::DestroyAnonymousContent(&mCapture); if (mBrowse) { mBrowse->RemoveSystemEventListener(NS_LITERAL_STRING("click"), @@ -110,7 +106,6 @@ nsFileControlFrame::DestroyFrom(nsIFrame* aDestructRoot) } nsContentUtils::DestroyAnonymousContent(&mTextContent); - mCaptureMouseListener->ForgetFrame(); mMouseListener->ForgetFrame(); nsBlockFrame::DestroyFrom(aDestructRoot); } @@ -183,37 +178,6 @@ nsFileControlFrame::CreateAnonymousContent(nsTArray& aElements) mBrowse->SetAttr(kNameSpaceID_None, nsGkAtoms::type, NS_LITERAL_STRING("button"), false); - // Create the capture button - nsCOMPtr capturePicker; - capturePicker = do_GetService("@mozilla.org/capturepicker;1"); - if (capturePicker) { - CaptureCallbackData data; - data.picker = capturePicker; - data.mode = GetCaptureMode(data); - - if (data.mode != 0) { - mCaptureMouseListener->mMode = data.mode; - nodeInfo = doc->NodeInfoManager()->GetNodeInfo(nsGkAtoms::input, nullptr, - kNameSpaceID_XHTML, - nsIDOMNode::ELEMENT_NODE); - NS_NewHTMLElement(getter_AddRefs(mCapture), nodeInfo.forget(), - dom::NOT_FROM_PARSER); - 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"), false); - - mCapture->SetAttr(kNameSpaceID_None, nsGkAtoms::value, - NS_LITERAL_STRING("capture"), false); - - mCapture->AddSystemEventListener(NS_LITERAL_STRING("click"), - mCaptureMouseListener, false); - } - } nsCOMPtr fileContent = do_QueryInterface(mContent); nsCOMPtr browseControl = do_QueryInterface(mBrowse); if (fileContent && browseControl) { @@ -229,9 +193,6 @@ nsFileControlFrame::CreateAnonymousContent(nsTArray& aElements) if (!aElements.AppendElement(mBrowse)) return NS_ERROR_OUT_OF_MEMORY; - if (mCapture && !aElements.AppendElement(mCapture)) - return NS_ERROR_OUT_OF_MEMORY; - // Register as an event listener of the button // to open file dialog on mouse click mBrowse->AddSystemEventListener(NS_LITERAL_STRING("click"), @@ -249,7 +210,6 @@ nsFileControlFrame::AppendAnonymousContentTo(nsBaseContentList& aElements, { aElements.MaybeAppendElement(mTextContent); aElements.MaybeAppendElement(mBrowse); - aElements.MaybeAppendElement(mCapture); } NS_QUERYFRAME_HEAD(nsFileControlFrame) @@ -286,90 +246,6 @@ bool ShouldProcessMouseClick(nsIDOMEvent* aMouseEvent) return true; } -/** - * This is called when our capture button is clicked - */ -NS_IMETHODIMP -nsFileControlFrame::CaptureMouseListener::HandleEvent(nsIDOMEvent* aMouseEvent) -{ - nsresult rv; - - NS_ASSERTION(mFrame, "We should have been unregistered"); - if (!ShouldProcessMouseClick(aMouseEvent)) - return NS_OK; - - // Get parent nsPIDOMWindow object. - nsIContent* content = mFrame->GetContent(); - nsHTMLInputElement* inputElement = - nsHTMLInputElement::FromContentOrNull(content); - if (!inputElement) - return NS_ERROR_FAILURE; - - nsCOMPtr doc = content->GetDocument(); - if (!doc) - return NS_ERROR_FAILURE; - - // Get Loc title - nsXPIDLString title; - nsContentUtils::GetLocalizedString(nsContentUtils::eFORMS_PROPERTIES, - "MediaUpload", title); - - nsPIDOMWindow* win = doc->GetWindow(); - if (!win) { - return NS_ERROR_FAILURE; - } - - nsCOMPtr 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); - - // Show dialog - uint32_t 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 domFile; - rv = capturePicker->GetFile(getter_AddRefs(domFile)); - NS_ENSURE_SUCCESS(rv, rv); - - nsCOMArray newFiles; - if (domFile) { - newFiles.AppendObject(domFile); - } 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 (newFiles.Count()) { - // Tell our input element 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. - - inputElement->SetFiles(newFiles, true); - nsContentUtils::DispatchTrustedEvent(content->OwnerDoc(), content, - NS_LITERAL_STRING("change"), true, - false); - } - - return NS_OK; -} - /** * This is called when we receive any registered events on the control. * We've only registered for drop, dragover and click events. @@ -618,51 +494,6 @@ nsFileControlFrame::AccessibleType() } #endif -uint32_t -nsFileControlFrame::GetCaptureMode(const CaptureCallbackData& aData) -{ - int32_t filters = nsHTMLInputElement::FromContent(mContent)->GetFilterFromAccept(); - nsresult rv; - bool captureEnabled; - - if (filters == nsIFilePicker::filterImages) { - rv = aData.picker->ModeMayBeAvailable(nsICapturePicker::MODE_STILL, - &captureEnabled); - NS_ENSURE_SUCCESS(rv, 0); - if (captureEnabled) { - return nsICapturePicker::MODE_STILL; - } - return 0; - } - - if (filters == nsIFilePicker::filterAudio) { - rv = aData.picker->ModeMayBeAvailable(nsICapturePicker::MODE_AUDIO_CLIP, - &captureEnabled); - NS_ENSURE_SUCCESS(rv, 0); - if (captureEnabled) { - return nsICapturePicker::MODE_AUDIO_CLIP; - } - return 0; - } - - if (filters == nsIFilePicker::filterVideo) { - rv = aData.picker->ModeMayBeAvailable(nsICapturePicker::MODE_VIDEO_CLIP, - &captureEnabled); - NS_ENSURE_SUCCESS(rv, 0); - if (captureEnabled) { - return nsICapturePicker::MODE_VIDEO_CLIP; - } - rv = aData.picker->ModeMayBeAvailable(nsICapturePicker::MODE_VIDEO_NO_SOUND_CLIP, - &captureEnabled); - NS_ENSURE_SUCCESS(rv, 0); - if (captureEnabled) { - return nsICapturePicker::MODE_VIDEO_NO_SOUND_CLIP; - } - return 0; - } - - return 0; -} //////////////////////////////////////////////////////////// // Mouse listener implementation diff --git a/layout/forms/nsFileControlFrame.h b/layout/forms/nsFileControlFrame.h index cd11ae42fc05..481a1bdcb8c2 100644 --- a/layout/forms/nsFileControlFrame.h +++ b/layout/forms/nsFileControlFrame.h @@ -11,7 +11,6 @@ #include "nsIFormControlFrame.h" #include "nsIDOMEventListener.h" #include "nsIAnonymousContentCreator.h" -#include "nsICapturePicker.h" #include "nsCOMPtr.h" class nsTextControlFrame; @@ -41,7 +40,7 @@ public: virtual void SetFocus(bool aOn, bool aRepaint); virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext) MOZ_OVERRIDE; - + virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE; #ifdef DEBUG @@ -63,27 +62,20 @@ public: #ifdef ACCESSIBILITY virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE; -#endif +#endif typedef bool (*AcceptAttrCallback)(const nsAString&, void*); protected: - - struct CaptureCallbackData { - nsICapturePicker* picker; - uint32_t mode; - }; - - uint32_t GetCaptureMode(const CaptureCallbackData& aData); - + class MouseListener; friend class MouseListener; class MouseListener : public nsIDOMEventListener { public: NS_DECL_ISUPPORTS - + MouseListener(nsFileControlFrame* aFrame) - : mFrame(aFrame) + : mFrame(aFrame) {} virtual ~MouseListener() {} @@ -116,21 +108,10 @@ protected: nsWeakFrame mFrame; }; - class CaptureMouseListener: public MouseListener { - public: - CaptureMouseListener(nsFileControlFrame* aFrame) - : MouseListener(aFrame) - , mMode(0) - {} - - NS_DECL_NSIDOMEVENTLISTENER - uint32_t mMode; - }; - class BrowseMouseListener: public MouseListener { public: - BrowseMouseListener(nsFileControlFrame* aFrame) - : MouseListener(aFrame) + BrowseMouseListener(nsFileControlFrame* aFrame) + : MouseListener(aFrame) {} NS_DECL_NSIDOMEVENTLISTENER @@ -155,17 +136,10 @@ protected: */ nsCOMPtr mBrowse; - /** - * The capture button input. - * @see nsFileControlFrame::CreateAnonymousContent - */ - nsCOMPtr mCapture; - /** * Our mouse listener. This makes sure we don't get used after destruction. */ nsRefPtr mMouseListener; - nsRefPtr mCaptureMouseListener; protected: /** diff --git a/layout/forms/nsICapturePicker.idl b/layout/forms/nsICapturePicker.idl deleted file mode 100644 index f344f4b644bd..000000000000 --- a/layout/forms/nsICapturePicker.idl +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsISupports.idl" - -interface nsIDOMWindow; -interface nsIDOMFile; - -[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 blob reference URI. - */ - readonly attribute nsIDOMFile file; - - // The MIME type of the captured content. Cannot be set after calling show() - attribute AString type; -}; diff --git a/mobile/android/installer/package-manifest.in b/mobile/android/installer/package-manifest.in index e35c69795ccf..6579c7a91048 100644 --- a/mobile/android/installer/package-manifest.in +++ b/mobile/android/installer/package-manifest.in @@ -169,7 +169,6 @@ @BINPATH@/components/jsdebugger.xpt @BINPATH@/components/jsinspector.xpt @BINPATH@/components/layout_base.xpt -@BINPATH@/components/layout_forms.xpt #ifdef NS_PRINTING @BINPATH@/components/layout_printing.xpt #endif