diff options
author | New Tobin Paradigm <email@mattatobin.com> | 2018-04-16 08:30:27 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-16 08:30:27 -0400 |
commit | c394a5f8710e9e83e8caa3f524aca4a80309b7cb (patch) | |
tree | 4d6358da9eb9d21d0e85f4732e88c5e7c0391125 | |
parent | a557bfae78557c5134874683fc7a8121f6b5deb1 (diff) | |
parent | c55addfa6422cd6fd3886f914b71139c4dd0edcc (diff) | |
download | UXP-c394a5f8710e9e83e8caa3f524aca4a80309b7cb.tar UXP-c394a5f8710e9e83e8caa3f524aca4a80309b7cb.tar.gz UXP-c394a5f8710e9e83e8caa3f524aca4a80309b7cb.tar.lz UXP-c394a5f8710e9e83e8caa3f524aca4a80309b7cb.tar.xz UXP-c394a5f8710e9e83e8caa3f524aca4a80309b7cb.zip |
Merge pull request #180 from janekptacijarabaci/html_input_datetime_2
HTML - input - datetime - support for "dom.forms.datetime.others"
-rw-r--r-- | dom/html/HTMLInputElement.cpp | 161 | ||||
-rw-r--r-- | dom/html/HTMLInputElement.h | 21 | ||||
-rw-r--r-- | dom/html/test/forms/test_input_types_pref.html | 48 | ||||
-rw-r--r-- | dom/html/test/forms/test_valueAsDate_pref.html | 8 | ||||
-rw-r--r-- | dom/ipc/DatePickerParent.cpp | 87 | ||||
-rw-r--r-- | dom/ipc/DatePickerParent.h | 61 | ||||
-rw-r--r-- | dom/ipc/PBrowser.ipdl | 8 | ||||
-rw-r--r-- | dom/ipc/PDatePicker.ipdl | 27 | ||||
-rw-r--r-- | dom/ipc/TabChild.cpp | 16 | ||||
-rw-r--r-- | dom/ipc/TabChild.h | 4 | ||||
-rw-r--r-- | dom/ipc/TabParent.cpp | 15 | ||||
-rw-r--r-- | dom/ipc/TabParent.h | 4 | ||||
-rw-r--r-- | dom/ipc/moz.build | 2 | ||||
-rw-r--r-- | dom/locales/en-US/chrome/layout/HtmlForm.properties | 1 | ||||
-rw-r--r-- | modules/libpref/init/all.js | 7 | ||||
-rw-r--r-- | testing/profiles/prefs_general.js | 1 | ||||
-rw-r--r-- | widget/moz.build | 2 | ||||
-rw-r--r-- | widget/nsContentProcessWidgetFactory.cpp | 6 | ||||
-rw-r--r-- | widget/nsDatePickerProxy.cpp | 61 | ||||
-rw-r--r-- | widget/nsDatePickerProxy.h | 33 | ||||
-rw-r--r-- | widget/nsIDatePicker.idl | 50 | ||||
-rw-r--r-- | widget/nsWidgetsCID.h | 5 |
22 files changed, 75 insertions, 553 deletions
diff --git a/dom/html/HTMLInputElement.cpp b/dom/html/HTMLInputElement.cpp index f1a54705e..52062c4b9 100644 --- a/dom/html/HTMLInputElement.cpp +++ b/dom/html/HTMLInputElement.cpp @@ -114,15 +114,12 @@ #include <limits> #include "nsIColorPicker.h" -#include "nsIDatePicker.h" #include "nsIStringEnumerator.h" #include "HTMLSplitOnSpacesTokenizer.h" #include "nsIController.h" #include "nsIMIMEInfo.h" #include "nsFrameSelection.h" -#include "nsIConsoleService.h" - // input type=date #include "js/Date.h" @@ -543,8 +540,8 @@ GetDOMFileOrDirectoryPath(const OwningFileOrDirectory& aData, bool HTMLInputElement::ValueAsDateEnabled(JSContext* cx, JSObject* obj) { - return IsExperimentalFormsEnabled() || IsDatePickerEnabled() || - IsInputDateTimeEnabled(); + return IsExperimentalFormsEnabled() || IsInputDateTimeEnabled() || + IsInputDateTimeOthersEnabled(); } NS_IMETHODIMP @@ -746,59 +743,6 @@ nsColorPickerShownCallback::Done(const nsAString& aColor) NS_IMPL_ISUPPORTS(nsColorPickerShownCallback, nsIColorPickerShownCallback) -class DatePickerShownCallback final : public nsIDatePickerShownCallback -{ - ~DatePickerShownCallback() {} -public: - DatePickerShownCallback(HTMLInputElement* aInput, - nsIDatePicker* aDatePicker) - : mInput(aInput) - , mDatePicker(aDatePicker) - {} - - NS_DECL_ISUPPORTS - - NS_IMETHOD Done(const nsAString& aDate) override; - NS_IMETHOD Cancel() override; - -private: - RefPtr<HTMLInputElement> mInput; - nsCOMPtr<nsIDatePicker> mDatePicker; -}; - -NS_IMETHODIMP -DatePickerShownCallback::Cancel() -{ - mInput->PickerClosed(); - return NS_OK; -} - -NS_IMETHODIMP -DatePickerShownCallback::Done(const nsAString& aDate) -{ - nsAutoString oldValue; - - mInput->PickerClosed(); - mInput->GetValue(oldValue); - - if(!oldValue.Equals(aDate)){ - mInput->SetValue(aDate); - nsContentUtils::DispatchTrustedEvent(mInput->OwnerDoc(), - static_cast<nsIDOMHTMLInputElement*>(mInput.get()), - NS_LITERAL_STRING("input"), true, - false); - return nsContentUtils::DispatchTrustedEvent(mInput->OwnerDoc(), - static_cast<nsIDOMHTMLInputElement*>(mInput.get()), - NS_LITERAL_STRING("change"), true, - false); - } - - return NS_OK; -} - -NS_IMPL_ISUPPORTS(DatePickerShownCallback, nsIDatePickerShownCallback) - - bool HTMLInputElement::IsPopupBlocked() const { @@ -824,56 +768,6 @@ HTMLInputElement::IsPopupBlocked() const } nsresult -HTMLInputElement::InitDatePicker() -{ - if (!IsDatePickerEnabled()) { - return NS_OK; - } - - if (mPickerRunning) { - NS_WARNING("Just one nsIDatePicker is allowed"); - return NS_ERROR_FAILURE; - } - - nsCOMPtr<nsIDocument> doc = OwnerDoc(); - - nsCOMPtr<nsPIDOMWindowOuter> win = doc->GetWindow(); - if (!win) { - return NS_ERROR_FAILURE; - } - - if (IsPopupBlocked()) { - win->FirePopupBlockedEvent(doc, nullptr, EmptyString(), EmptyString()); - return NS_OK; - } - - // Get Loc title - nsXPIDLString title; - nsContentUtils::GetLocalizedString(nsContentUtils::eFORMS_PROPERTIES, - "DatePicker", title); - - nsresult rv; - nsCOMPtr<nsIDatePicker> datePicker = do_CreateInstance("@mozilla.org/datepicker;1", &rv); - if (!datePicker) { - return rv; - } - - nsAutoString initialValue; - GetValueInternal(initialValue); - rv = datePicker->Init(win, title, initialValue); - - nsCOMPtr<nsIDatePickerShownCallback> callback = - new DatePickerShownCallback(this, datePicker); - - rv = datePicker->Open(callback); - if (NS_SUCCEEDED(rv)) { - mPickerRunning = true; - } - - return rv; -} - -nsresult HTMLInputElement::InitColorPicker() { if (mPickerRunning) { @@ -2570,9 +2464,8 @@ HTMLInputElement::ApplyStep(int32_t aStep) bool HTMLInputElement::IsExperimentalMobileType(uint8_t aType) { - return (aType == NS_FORM_INPUT_DATE && - !IsInputDateTimeEnabled() && !IsDatePickerEnabled()) || - (aType == NS_FORM_INPUT_TIME && !IsInputDateTimeEnabled()); + return (aType == NS_FORM_INPUT_DATE || aType == NS_FORM_INPUT_TIME) && + !IsInputDateTimeEnabled(); } bool @@ -4429,9 +4322,6 @@ HTMLInputElement::MaybeInitPickers(EventChainPostVisitor& aVisitor) if (mType == NS_FORM_INPUT_COLOR) { return InitColorPicker(); } - if (mType == NS_FORM_INPUT_DATE) { - return InitDatePicker(); - } return NS_OK; } @@ -5814,15 +5704,13 @@ HTMLInputElement::ParseTime(const nsAString& aValue, uint32_t* aResult) /* static */ bool HTMLInputElement::IsDateTimeTypeSupported(uint8_t aDateTimeInputType) { - return (aDateTimeInputType == NS_FORM_INPUT_DATE && - (IsInputDateTimeEnabled() || IsExperimentalFormsEnabled() || - IsDatePickerEnabled())) || - (aDateTimeInputType == NS_FORM_INPUT_TIME && + return ((aDateTimeInputType == NS_FORM_INPUT_DATE || + aDateTimeInputType == NS_FORM_INPUT_TIME) && (IsInputDateTimeEnabled() || IsExperimentalFormsEnabled())) || ((aDateTimeInputType == NS_FORM_INPUT_MONTH || aDateTimeInputType == NS_FORM_INPUT_WEEK || aDateTimeInputType == NS_FORM_INPUT_DATETIME_LOCAL) && - IsInputDateTimeEnabled()); + IsInputDateTimeOthersEnabled()); } /* static */ bool @@ -5870,20 +5758,6 @@ HTMLInputElement::IsDirPickerEnabled() } /* static */ bool -HTMLInputElement::IsDatePickerEnabled() -{ - static bool sDatePickerEnabled = false; - static bool sDatePickerPrefCached = false; - if (!sDatePickerPrefCached) { - sDatePickerPrefCached = true; - Preferences::AddBoolVarCache(&sDatePickerEnabled, "dom.forms.datepicker", - false); - } - - return sDatePickerEnabled; -} - -/* static */ bool HTMLInputElement::IsExperimentalFormsEnabled() { static bool sExperimentalFormsEnabled = false; @@ -5913,6 +5787,20 @@ HTMLInputElement::IsInputDateTimeEnabled() } /* static */ bool +HTMLInputElement::IsInputDateTimeOthersEnabled() +{ + static bool sDateTimeOthersEnabled = false; + static bool sDateTimeOthersPrefCached = false; + if (!sDateTimeOthersPrefCached) { + sDateTimeOthersPrefCached = true; + Preferences::AddBoolVarCache(&sDateTimeOthersEnabled, + "dom.forms.datetime.others", false); + } + + return sDateTimeOthersEnabled; +} + +/* static */ bool HTMLInputElement::IsInputNumberEnabled() { static bool sInputNumberEnabled = false; @@ -5954,12 +5842,9 @@ HTMLInputElement::ParseAttribute(int32_t aNamespaceID, bool success = aResult.ParseEnumValue(aValue, kInputTypeTable, false); if (success) { newType = aResult.GetEnumValue(); - if ((IsExperimentalMobileType(newType) && - !IsExperimentalFormsEnabled()) || - (newType == NS_FORM_INPUT_NUMBER && !IsInputNumberEnabled()) || + if ((newType == NS_FORM_INPUT_NUMBER && !IsInputNumberEnabled()) || (newType == NS_FORM_INPUT_COLOR && !IsInputColorEnabled()) || - (IsDateTimeInputType(newType) && - !IsDateTimeTypeSupported(newType))) { + (IsDateTimeInputType(newType) && !IsDateTimeTypeSupported(newType))) { newType = kInputDefaultType->value; aResult.SetTo(newType, &aValue); } diff --git a/dom/html/HTMLInputElement.h b/dom/html/HTMLInputElement.h index adab663c3..98a590443 100644 --- a/dom/html/HTMLInputElement.h +++ b/dom/html/HTMLInputElement.h @@ -1451,7 +1451,6 @@ protected: }; nsresult InitFilePicker(FilePickerType aType); nsresult InitColorPicker(); - nsresult InitDatePicker(); /** * Use this function before trying to open a picker. @@ -1647,7 +1646,7 @@ private: /** * Checks if aDateTimeInputType should be supported based on "dom.forms.datetime", - * "dom.forms.datepicker" and "dom.experimental_forms". + * and "dom.experimental_forms". */ static bool IsDateTimeTypeSupported(uint8_t aDateTimeInputType); @@ -1674,13 +1673,6 @@ private: IsDirPickerEnabled(); /** - * Checks preference "dom.forms.datepicker" to determine if date picker should - * be supported. - */ - static bool - IsDatePickerEnabled(); - - /** * Checks preference "dom.experimental_forms" to determine if experimental * implementation of input element should be enabled. */ @@ -1688,13 +1680,20 @@ private: IsExperimentalFormsEnabled(); /** - * Checks preference "dom.forms.datetime" to determine if input date/time - * related types should be supported. + * Checks preference "dom.forms.datetime" to determine if input date and time + * should be supported. */ static bool IsInputDateTimeEnabled(); /** + * Checks preference "dom.forms.datetime.others" to determine if input week, + * month and datetime-local should be supported. + */ + static bool + IsInputDateTimeOthersEnabled(); + + /** * Checks preference "dom.forms.number" to determine if input type=number * should be supported. */ diff --git a/dom/html/test/forms/test_input_types_pref.html b/dom/html/test/forms/test_input_types_pref.html index 243836f34..5279d6a2a 100644 --- a/dom/html/test/forms/test_input_types_pref.html +++ b/dom/html/test/forms/test_input_types_pref.html @@ -37,47 +37,63 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=764481 inputType: "color", expectedType: "color" }, { - prefs: [["dom.experimental_forms", false], ["dom.forms.datepicker", false], - ["dom.forms.datetime", false]], + prefs: [["dom.experimental_forms", false], ["dom.forms.datetime", false]], inputType: "date", expectedType: "text" }, { - prefs: [["dom.experimental_forms", true], ["dom.forms.datepicker", false], - ["dom.forms.datetime", false]], + prefs: [["dom.experimental_forms", true], ["dom.forms.datetime", false]], inputType: "date", expectedType: "date" }, { - prefs: [["dom.experimental_forms", false], ["dom.forms.datepicker", true], - ["dom.forms.datetime", false]], + prefs: [["dom.experimental_forms", false], ["dom.forms.datetime", true]], inputType: "date", expectedType: "date" }, { - prefs: [["dom.experimental_forms", false], ["dom.forms.datepicker", false], - ["dom.forms.datetime", true]], - inputType: "date", - expectedType: "date" + prefs: [["dom.experimental_forms", false], ["dom.forms.datetime", false]], + inputType: "time", + expectedType: "text" + }, { + prefs: [["dom.experimental_forms", true], ["dom.forms.datetime", false]], + inputType: "time", + expectedType: "time" + }, { + prefs: [["dom.experimental_forms", false], ["dom.forms.datetime", true]], + inputType: "time", + expectedType: "time" + }, { + prefs: [["dom.forms.datetime", false], ["dom.forms.datetime.others", false]], + inputType: "month", + expectedType: "text" }, { - prefs: [["dom.forms.datetime", false]], + prefs: [["dom.forms.datetime", true], ["dom.forms.datetime.others", false]], inputType: "month", expectedType: "text" }, { - prefs: [["dom.forms.datetime", true]], + prefs: [["dom.forms.datetime", false], ["dom.forms.datetime.others", true]], inputType: "month", expectedType: "month" }, { - prefs: [["dom.forms.datetime", false]], + prefs: [["dom.forms.datetime", false], ["dom.forms.datetime.others", false]], + inputType: "week", + expectedType: "text" + }, { + prefs: [["dom.forms.datetime", true], ["dom.forms.datetime.others", false]], inputType: "week", expectedType: "text" }, { - prefs: [["dom.forms.datetime", true]], + prefs: [["dom.forms.datetime", false], ["dom.forms.datetime.others", true]], inputType: "week", expectedType: "week" }, { - prefs: [["dom.forms.datetime", false]], + prefs: [["dom.forms.datetime", false], ["dom.forms.datetime.others", false]], + inputType: "datetime-local", + expectedType: "text" + }, { + prefs: [["dom.forms.datetime", true], ["dom.forms.datetime.others", false]], inputType: "datetime-local", expectedType: "text" }, { - prefs: [["dom.forms.datetime", true]], + prefs: [["dom.forms.datetime", false], ["dom.forms.datetime.others", true]], inputType: "datetime-local", expectedType: "datetime-local" } diff --git a/dom/html/test/forms/test_valueAsDate_pref.html b/dom/html/test/forms/test_valueAsDate_pref.html index 8518c291b..0369980e4 100644 --- a/dom/html/test/forms/test_valueAsDate_pref.html +++ b/dom/html/test/forms/test_valueAsDate_pref.html @@ -12,8 +12,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=874640 /** Test for Bug 874640 **/ var states = [ - // dom.experimental_forms, dom.forms.datepicker, dom.forms.datetime, expectedValueAsDate - [ 'true', 'true', 'true', 'true' ], + // dom.experimental_forms, dom.forms.datetime, dom.forms.datetime.others, expectedValueAsDate + [ 'true', 'true', ,'true', 'true' ], [ 'true', 'false', 'false', 'true' ], [ 'false', 'true', 'false', 'true' ], [ 'false', 'false', 'true', 'true' ], @@ -33,8 +33,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=874640 SpecialPowers.pushPrefEnv({"set":[ ["dom.experimental_forms", state[0] === 'true'], - ["dom.forms.datepicker", state[1] === 'true'], - ["dom.forms.datetime", state[2] === 'true']]}, + ["dom.forms.datetime", state[1] === 'true'], + ["dom.forms.datetime.others", state[2] === 'true']]}, function() { iframe.src = 'data:text/html,<script>' + 'parent.is("valueAsDate" in document.createElement("input"), ' + diff --git a/dom/ipc/DatePickerParent.cpp b/dom/ipc/DatePickerParent.cpp deleted file mode 100644 index 509944ddd..000000000 --- a/dom/ipc/DatePickerParent.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* 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 "DatePickerParent.h" -#include "nsComponentManagerUtils.h" -#include "nsIDocument.h" -#include "nsIDOMWindow.h" -#include "mozilla/Unused.h" -#include "mozilla/dom/Element.h" -#include "mozilla/dom/TabParent.h" - -using mozilla::Unused; -using namespace mozilla::dom; - -NS_IMPL_ISUPPORTS(DatePickerParent::DatePickerShownCallback, - nsIDatePickerShownCallback); - -NS_IMETHODIMP -DatePickerParent::DatePickerShownCallback::Cancel() -{ - if (mDatePickerParent) { - Unused << mDatePickerParent->SendCancel(); - } - return NS_OK; -} - -NS_IMETHODIMP -DatePickerParent::DatePickerShownCallback::Done(const nsAString& aDate) -{ - if (mDatePickerParent) { - Unused << mDatePickerParent->Send__delete__(mDatePickerParent, - nsString(aDate)); - } - return NS_OK; -} - -void -DatePickerParent::DatePickerShownCallback::Destroy() -{ - mDatePickerParent = nullptr; -} - -bool -DatePickerParent::CreateDatePicker() -{ - mPicker = do_CreateInstance("@mozilla.org/datepicker;1"); - if (!mPicker) { - return false; - } - - Element* ownerElement = TabParent::GetFrom(Manager())->GetOwnerElement(); - if (!ownerElement) { - return false; - } - - nsCOMPtr<mozIDOMWindowProxy> window = do_QueryInterface(ownerElement->OwnerDoc()->GetWindow()); - if (!window) { - return false; - } - - return NS_SUCCEEDED(mPicker->Init(window, mTitle, mInitialDate)); -} - -bool -DatePickerParent::RecvOpen() -{ - if (!CreateDatePicker()) { - Unused << Send__delete__(this, mInitialDate); - return true; - } - - mCallback = new DatePickerShownCallback(this); - - mPicker->Open(mCallback); - return true; -}; - -void -DatePickerParent::ActorDestroy(ActorDestroyReason aWhy) -{ - if (mCallback) { - mCallback->Destroy(); - } -} diff --git a/dom/ipc/DatePickerParent.h b/dom/ipc/DatePickerParent.h deleted file mode 100644 index 73b66f96c..000000000 --- a/dom/ipc/DatePickerParent.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* 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/. */ - -#ifndef mozilla_dom_DatePickerParent_h -#define mozilla_dom_DatePickerParent_h - -#include "mozilla/dom/PDatePickerParent.h" -#include "nsIDatePicker.h" - -namespace mozilla { -namespace dom { - -class DatePickerParent : public PDatePickerParent -{ - public: - DatePickerParent(const nsString& aTitle, - const nsString& aInitialDate) - : mTitle(aTitle) - , mInitialDate(aInitialDate) - {} - - virtual bool RecvOpen() override; - virtual void ActorDestroy(ActorDestroyReason aWhy) override; - - class DatePickerShownCallback final - : public nsIDatePickerShownCallback - { - public: - explicit DatePickerShownCallback(DatePickerParent* aDatePickerParnet) - : mDatePickerParent(aDatePickerParnet) - {} - - NS_DECL_ISUPPORTS - NS_DECL_NSIDATEPICKERSHOWNCALLBACK - - void Destroy(); - - private: - ~DatePickerShownCallback() {} - DatePickerParent* mDatePickerParent; - }; - - private: - virtual ~DatePickerParent() {} - - bool CreateDatePicker(); - - RefPtr<DatePickerShownCallback> mCallback; - nsCOMPtr<nsIDatePicker> mPicker; - - nsString mTitle; - nsString mInitialDate; -}; - -} // namespace dom -} // namespace mozilla - -#endif // mozilla_dom_DatePickerParent_h diff --git a/dom/ipc/PBrowser.ipdl b/dom/ipc/PBrowser.ipdl index 9dfccbc5c..f09e484ee 100644 --- a/dom/ipc/PBrowser.ipdl +++ b/dom/ipc/PBrowser.ipdl @@ -9,7 +9,6 @@ include protocol PBlob; include protocol PColorPicker; include protocol PContent; include protocol PContentBridge; -include protocol PDatePicker; include protocol PDocAccessible; include protocol PFilePicker; include protocol PIndexedDBPermissionRequest; @@ -116,7 +115,6 @@ nested(upto inside_cpow) sync protocol PBrowser manager PContent or PContentBridge; manages PColorPicker; - manages PDatePicker; manages PDocAccessible; manages PFilePicker; manages PIndexedDBPermissionRequest; @@ -441,12 +439,6 @@ parent: */ async PColorPicker(nsString title, nsString initialColor); - /** - * Create an asynchronous date picker on the parent side, - * but don't open it yet. - */ - async PDatePicker(nsString title, nsString initialDate); - async PFilePicker(nsString aTitle, int16_t aMode); /** diff --git a/dom/ipc/PDatePicker.ipdl b/dom/ipc/PDatePicker.ipdl deleted file mode 100644 index 90a2654bb..000000000 --- a/dom/ipc/PDatePicker.ipdl +++ /dev/null @@ -1,27 +0,0 @@ -/* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 8 -*- */ -/* vim: set sw=4 ts=8 et tw=80 ft=cpp : */ - -/* 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 protocol PBrowser; - -namespace mozilla { -namespace dom { - -protocol PDatePicker -{ - manager PBrowser; - -parent: - async Open(); - -child: - async Cancel(); - - async __delete__(nsString color); -}; - -} // namespace dom -} // namespace mozilla diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index c8a0c6e3f..705799c54 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -96,7 +96,6 @@ #include "LayersLogging.h" #include "nsDOMClassInfoID.h" #include "nsColorPickerProxy.h" -#include "nsDatePickerProxy.h" #include "nsContentPermissionHelper.h" #include "nsPresShell.h" #include "nsIAppsService.h" @@ -2013,21 +2012,6 @@ TabChild::DeallocPColorPickerChild(PColorPickerChild* aColorPicker) return true; } -PDatePickerChild* -TabChild::AllocPDatePickerChild(const nsString&, const nsString&) -{ - NS_RUNTIMEABORT("unused"); - return nullptr; -} - -bool -TabChild::DeallocPDatePickerChild(PDatePickerChild* aDatePicker) -{ - nsDatePickerProxy* picker = static_cast<nsDatePickerProxy*>(aDatePicker); - NS_RELEASE(picker); - return true; -} - PFilePickerChild* TabChild::AllocPFilePickerChild(const nsString&, const int16_t&) { diff --git a/dom/ipc/TabChild.h b/dom/ipc/TabChild.h index 2232ffeaf..d9988a596 100644 --- a/dom/ipc/TabChild.h +++ b/dom/ipc/TabChild.h @@ -451,10 +451,6 @@ public: virtual bool DeallocPColorPickerChild(PColorPickerChild* aActor) override; - virtual PDatePickerChild* - AllocPDatePickerChild(const nsString& title, const nsString& initialDate) override; - virtual bool DeallocPDatePickerChild(PDatePickerChild* actor) override; - virtual PFilePickerChild* AllocPFilePickerChild(const nsString& aTitle, const int16_t& aMode) override; diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index 8e98de3ce..0f190708f 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -80,7 +80,6 @@ #include "PermissionMessageUtils.h" #include "StructuredCloneData.h" #include "ColorPickerParent.h" -#include "DatePickerParent.h" #include "FilePickerParent.h" #include "TabChild.h" #include "LoadContext.h" @@ -2424,20 +2423,6 @@ TabParent::DeallocPColorPickerParent(PColorPickerParent* actor) return true; } -PDatePickerParent* -TabParent::AllocPDatePickerParent(const nsString& aTitle, - const nsString& aInitialDate) -{ - return new DatePickerParent(aTitle, aInitialDate); -} - -bool -TabParent::DeallocPDatePickerParent(PDatePickerParent* actor) -{ - delete actor; - return true; -} - PRenderFrameParent* TabParent::AllocPRenderFrameParent() { diff --git a/dom/ipc/TabParent.h b/dom/ipc/TabParent.h index 09bb999f3..3624ce320 100644 --- a/dom/ipc/TabParent.h +++ b/dom/ipc/TabParent.h @@ -347,10 +347,6 @@ public: virtual bool DeallocPColorPickerParent(PColorPickerParent* aColorPicker) override; - virtual PDatePickerParent* - AllocPDatePickerParent(const nsString& aTitle, const nsString& aInitialDate) override; - virtual bool DeallocPDatePickerParent(PDatePickerParent* aDatePicker) override; - virtual PDocAccessibleParent* AllocPDocAccessibleParent(PDocAccessibleParent*, const uint64_t&, const uint32_t&, const IAccessibleHolder&) override; diff --git a/dom/ipc/moz.build b/dom/ipc/moz.build index ff3880bc2..71d193d44 100644 --- a/dom/ipc/moz.build +++ b/dom/ipc/moz.build @@ -55,7 +55,6 @@ UNIFIED_SOURCES += [ 'ContentProcess.cpp', 'ContentProcessManager.cpp', 'CrashReporterParent.cpp', - 'DatePickerParent.cpp', 'FilePickerParent.cpp', 'nsIContentChild.cpp', 'nsIContentParent.cpp', @@ -95,7 +94,6 @@ IPDL_SOURCES += [ 'PContentPermissionRequest.ipdl', 'PCrashReporter.ipdl', 'PCycleCollectWithLogs.ipdl', - 'PDatePicker.ipdl', 'PFilePicker.ipdl', 'PMemoryReportRequest.ipdl', 'PPluginWidget.ipdl', diff --git a/dom/locales/en-US/chrome/layout/HtmlForm.properties b/dom/locales/en-US/chrome/layout/HtmlForm.properties index 621a0b2b3..82274b2bc 100644 --- a/dom/locales/en-US/chrome/layout/HtmlForm.properties +++ b/dom/locales/en-US/chrome/layout/HtmlForm.properties @@ -34,7 +34,6 @@ NoDirSelected=No directory selected. # %S will be a number greater or equal to 2. XFilesSelected=%S files selected. ColorPicker=Choose a color -DatePicker=Choose a date # LOCALIZATION NOTE (AndNMoreFiles): Semi-colon list of plural forms. # See: http://developer.mozilla.org/en/docs/Localization_and_Plurals # This string is shown at the end of the tooltip text for <input type='file' diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 59f8de9ac..e3e23550a 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -1179,10 +1179,13 @@ pref("dom.forms.number", true); // platforms which don't have a color picker implemented yet. pref("dom.forms.color", true); -// Support for input type=date, time, month, week and datetime-local. By -// default, disabled. +// Support for input type=date and type=time. By default, disabled. pref("dom.forms.datetime", false); +// Support for input type=month, type=week and type=datetime-local. By default, +// disabled. +pref("dom.forms.datetime.others", false); + // Enable time picker UI. By default, disabled. pref("dom.forms.datetime.timepicker", false); diff --git a/testing/profiles/prefs_general.js b/testing/profiles/prefs_general.js index 91218b5f3..ac2c1e077 100644 --- a/testing/profiles/prefs_general.js +++ b/testing/profiles/prefs_general.js @@ -12,6 +12,7 @@ user_pref("dom.experimental_forms", true); // on for testing user_pref("dom.forms.number", true); // on for testing user_pref("dom.forms.color", true); // on for testing user_pref("dom.forms.datetime", true); // on for testing +user_pref("dom.forms.datetime.others", true); // on for testing user_pref("dom.max_script_run_time", 0); // no slow script dialogs user_pref("hangmonitor.timeout", 0); // no hang monitor user_pref("dom.max_chrome_script_run_time", 0); diff --git a/widget/moz.build b/widget/moz.build index 09192179f..f69f2d87c 100644 --- a/widget/moz.build +++ b/widget/moz.build @@ -65,7 +65,6 @@ XPIDL_SOURCES += [ 'nsIClipboardHelper.idl', 'nsIClipboardOwner.idl', 'nsIColorPicker.idl', - 'nsIDatePicker.idl', 'nsIDisplayInfo.idl', 'nsIDragService.idl', 'nsIDragSession.idl', @@ -151,7 +150,6 @@ UNIFIED_SOURCES += [ 'nsClipboardProxy.cpp', 'nsColorPickerProxy.cpp', 'nsContentProcessWidgetFactory.cpp', - 'nsDatePickerProxy.cpp', 'nsDragServiceProxy.cpp', 'nsFilePickerProxy.cpp', 'nsHTMLFormatConverter.cpp', diff --git a/widget/nsContentProcessWidgetFactory.cpp b/widget/nsContentProcessWidgetFactory.cpp index f8eaee250..2f00f1c83 100644 --- a/widget/nsContentProcessWidgetFactory.cpp +++ b/widget/nsContentProcessWidgetFactory.cpp @@ -9,7 +9,6 @@ #include "nsWidgetsCID.h" #include "nsClipboardProxy.h" #include "nsColorPickerProxy.h" -#include "nsDatePickerProxy.h" #include "nsDragServiceProxy.h" #include "nsFilePickerProxy.h" #include "nsScreenManagerProxy.h" @@ -22,7 +21,6 @@ using namespace mozilla::widget; NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardProxy) NS_GENERIC_FACTORY_CONSTRUCTOR(nsColorPickerProxy) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsDatePickerProxy) NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragServiceProxy) NS_GENERIC_FACTORY_CONSTRUCTOR(nsFilePickerProxy) NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerProxy) @@ -30,7 +28,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(PuppetBidiKeyboard) NS_DEFINE_NAMED_CID(NS_CLIPBOARD_CID); NS_DEFINE_NAMED_CID(NS_COLORPICKER_CID); -NS_DEFINE_NAMED_CID(NS_DATEPICKER_CID); NS_DEFINE_NAMED_CID(NS_DRAGSERVICE_CID); NS_DEFINE_NAMED_CID(NS_FILEPICKER_CID); NS_DEFINE_NAMED_CID(PUPPETBIDIKEYBOARD_CID); @@ -41,8 +38,6 @@ static const mozilla::Module::CIDEntry kWidgetCIDs[] = { Module::CONTENT_PROCESS_ONLY }, { &kNS_COLORPICKER_CID, false, nullptr, nsColorPickerProxyConstructor, Module::CONTENT_PROCESS_ONLY }, - { &kNS_DATEPICKER_CID, false, nullptr, nsDatePickerProxyConstructor, - Module::CONTENT_PROCESS_ONLY }, { &kNS_DRAGSERVICE_CID, false, nullptr, nsDragServiceProxyConstructor, Module::CONTENT_PROCESS_ONLY }, { &kNS_FILEPICKER_CID, false, nullptr, nsFilePickerProxyConstructor, @@ -57,7 +52,6 @@ static const mozilla::Module::CIDEntry kWidgetCIDs[] = { static const mozilla::Module::ContractIDEntry kWidgetContracts[] = { { "@mozilla.org/widget/clipboard;1", &kNS_CLIPBOARD_CID, Module::CONTENT_PROCESS_ONLY }, { "@mozilla.org/colorpicker;1", &kNS_COLORPICKER_CID, Module::CONTENT_PROCESS_ONLY }, - { "@mozilla.org/datepicker;1", &kNS_DATEPICKER_CID, Module::CONTENT_PROCESS_ONLY }, { "@mozilla.org/filepicker;1", &kNS_FILEPICKER_CID, Module::CONTENT_PROCESS_ONLY }, { "@mozilla.org/gfx/screenmanager;1", &kNS_SCREENMANAGER_CID, Module::CONTENT_PROCESS_ONLY }, { "@mozilla.org/widget/dragservice;1", &kNS_DRAGSERVICE_CID, Module::CONTENT_PROCESS_ONLY }, diff --git a/widget/nsDatePickerProxy.cpp b/widget/nsDatePickerProxy.cpp deleted file mode 100644 index e6b88f1be..000000000 --- a/widget/nsDatePickerProxy.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * 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 "nsDatePickerProxy.h" - -#include "mozilla/dom/TabChild.h" - -using namespace mozilla::dom; - -NS_IMPL_ISUPPORTS(nsDatePickerProxy, nsIDatePicker) - -/* void init (in nsIDOMWindow parent, in AString title, in short mode); */ -NS_IMETHODIMP -nsDatePickerProxy::Init(mozIDOMWindowProxy* aParent, const nsAString& aTitle, - const nsAString& aInitialDate) -{ - TabChild* tabChild = TabChild::GetFrom(aParent); - if (!tabChild) { - return NS_ERROR_FAILURE; - } - - tabChild->SendPDatePickerConstructor(this, - nsString(aTitle), - nsString(aInitialDate)); - NS_ADDREF_THIS(); //Released in DeallocPDatePickerChild - return NS_OK; -} - -/* void open (in nsIDatePickerShownCallback aDatePickerShownCallback); */ -NS_IMETHODIMP -nsDatePickerProxy::Open(nsIDatePickerShownCallback* aDatePickerShownCallback) -{ - NS_ENSURE_STATE(!mCallback); - mCallback = aDatePickerShownCallback; - - SendOpen(); - return NS_OK; -} - -bool -nsDatePickerProxy::RecvCancel() -{ - if (mCallback) { - mCallback->Cancel(); - mCallback = nullptr; - } - return true; -} - -bool -nsDatePickerProxy::Recv__delete__(const nsString& aDate) -{ - if (mCallback) { - mCallback->Done(aDate); - mCallback = nullptr; - } - return true; -} diff --git a/widget/nsDatePickerProxy.h b/widget/nsDatePickerProxy.h deleted file mode 100644 index 71475932c..000000000 --- a/widget/nsDatePickerProxy.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- Mode: C++; 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/. */ - -#ifndef nsDatePickerProxy_h -#define nsDatePickerProxy_h - -#include "nsIDatePicker.h" - -#include "mozilla/dom/PDatePickerChild.h" - -class nsDatePickerProxy final : public nsIDatePicker, - public mozilla::dom::PDatePickerChild -{ -public: - NS_DECL_ISUPPORTS - NS_DECL_NSIDATEPICKER - - nsDatePickerProxy() {} - - virtual bool RecvCancel() override; - virtual bool Recv__delete__(const nsString& aDate) override; - -private: - ~nsDatePickerProxy() {} - - nsCOMPtr<nsIDatePickerShownCallback> mCallback; - nsString mTitle; - nsString mInitialDate; -}; - -#endif // nsDatePickerProxy_h diff --git a/widget/nsIDatePicker.idl b/widget/nsIDatePicker.idl deleted file mode 100644 index d6be60c95..000000000 --- a/widget/nsIDatePicker.idl +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- Mode: C++; 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 mozIDOMWindowProxy; - -[scriptable, uuid(13388a28-1b0b-4218-a31b-588f7a4ec26c)] -interface nsIDatePickerShownCallback : nsISupports -{ - /** - * Callback called when the user selects cancel in the date picker - * This callback can not be called after done() is called. - */ - void cancel(); - - /** - * Callback called when the user has finished selecting the date - * - * @param date The new selected date value following the format "YYYY-MM-DD" - */ - void done(in AString date); -}; - -[scriptable, uuid(7becfc64-966b-4d53-87d2-9161f36bd3b3)] -interface nsIDatePicker : nsISupports -{ - /** - * Initialize the date picker widget. The date picker will not be shown until - * open() is called. - * If the initialDate parameter does not follow the format "YYYY-MM-DD" then - * the behavior will be unspecified. - * - * @param parent nsIDOMWindow parent. This dialog will be dependent - * on this parent. parent may be null. - * @param title The title for the date picker widget. - * @param initialDate The date to show when the widget is opened. The - * parameter has to follow the format "YYYY-MM-DD" - */ - void init(in mozIDOMWindowProxy parent, in AString title, in AString initialDate); - - /** - * Opens the date dialog asynchrounously. - * The results are provided via the callback object. - */ - void open(in nsIDatePickerShownCallback callback); -}; diff --git a/widget/nsWidgetsCID.h b/widget/nsWidgetsCID.h index 2589b59e0..54ebe63ab 100644 --- a/widget/nsWidgetsCID.h +++ b/widget/nsWidgetsCID.h @@ -33,11 +33,6 @@ { 0x0f872c8c, 0x3ee6, 0x46bd, \ { 0x92, 0xa2, 0x69, 0x65, 0x2c, 0x6b, 0x47, 0x4e } } -/* 0ca832f8-978a-4dc7-a57d-adb803925d39 */ -#define NS_DATEPICKER_CID \ -{ 0x0ca832f8, 0x978a, 0x4dc7, \ - { 0xa5, 0x7d, 0xad, 0xb8, 0x03, 0x92, 0x5d, 0x39 } } - /* 2d96b3df-c051-11d1-a827-0040959a28c9 */ #define NS_APPSHELL_CID \ { 0x2d96b3df, 0xc051, 0x11d1, \ |