2015-05-03 22:32:37 +03:00
|
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
|
/* 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/. */
|
2010-09-05 22:00:05 +04:00
|
|
|
|
|
2013-03-28 23:41:32 +04:00
|
|
|
|
#ifndef mozilla_dom_HTMLInputElement_h
|
|
|
|
|
#define mozilla_dom_HTMLInputElement_h
|
2010-09-05 22:00:05 +04:00
|
|
|
|
|
2013-05-30 00:43:41 +04:00
|
|
|
|
#include "mozilla/Attributes.h"
|
2010-09-05 22:00:05 +04:00
|
|
|
|
#include "nsGenericHTMLElement.h"
|
|
|
|
|
#include "nsImageLoadingContent.h"
|
|
|
|
|
#include "nsIDOMHTMLInputElement.h"
|
|
|
|
|
#include "nsITextControlElement.h"
|
2013-09-04 18:21:32 +04:00
|
|
|
|
#include "nsITimer.h"
|
2010-09-05 22:00:05 +04:00
|
|
|
|
#include "nsIDOMNSEditableElement.h"
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
|
#include "nsIConstraintValidation.h"
|
2017-05-04 06:43:46 +03:00
|
|
|
|
#include "mozilla/UniquePtr.h"
|
2016-11-15 20:46:31 +03:00
|
|
|
|
#include "mozilla/dom/BindingDeclarations.h"
|
2013-09-06 10:40:45 +04:00
|
|
|
|
#include "mozilla/dom/HTMLFormElement.h" // for HasEverTriedInvalidSubmit()
|
2013-09-18 09:29:04 +04:00
|
|
|
|
#include "mozilla/dom/HTMLInputElementBinding.h"
|
2015-07-10 20:55:52 +03:00
|
|
|
|
#include "mozilla/dom/Promise.h"
|
2016-03-20 13:56:10 +03:00
|
|
|
|
#include "mozilla/dom/UnionTypes.h"
|
2012-08-17 19:35:01 +04:00
|
|
|
|
#include "nsIFilePicker.h"
|
2013-03-30 06:08:57 +04:00
|
|
|
|
#include "nsIContentPrefService2.h"
|
2013-05-06 03:23:18 +04:00
|
|
|
|
#include "mozilla/Decimal.h"
|
2014-06-06 11:25:02 +04:00
|
|
|
|
#include "nsContentUtils.h"
|
2014-08-01 04:25:31 +04:00
|
|
|
|
#include "nsTextEditorState.h"
|
2017-05-04 06:43:46 +03:00
|
|
|
|
#include "mozilla/Variant.h"
|
|
|
|
|
#include "SingleLineTextInputTypes.h"
|
|
|
|
|
#include "NumericInputTypes.h"
|
|
|
|
|
#include "CheckableInputTypes.h"
|
|
|
|
|
#include "ButtonInputTypes.h"
|
|
|
|
|
#include "DateTimeInputTypes.h"
|
|
|
|
|
#include "ColorInputType.h"
|
|
|
|
|
#include "FileInputType.h"
|
|
|
|
|
#include "HiddenInputType.h"
|
|
|
|
|
|
|
|
|
|
static constexpr size_t INPUT_TYPE_SIZE = sizeof(
|
|
|
|
|
mozilla::Variant<TextInputType, SearchInputType, TelInputType, URLInputType,
|
|
|
|
|
EmailInputType, PasswordInputType, NumberInputType,
|
|
|
|
|
RangeInputType, RadioInputType, CheckboxInputType,
|
|
|
|
|
ButtonInputType, ImageInputType, ResetInputType,
|
|
|
|
|
SubmitInputType, DateInputType, TimeInputType, WeekInputType,
|
|
|
|
|
MonthInputType, DateTimeLocalInputType, FileInputType,
|
|
|
|
|
ColorInputType, HiddenInputType> );
|
|
|
|
|
|
|
|
|
|
class InputType;
|
|
|
|
|
struct DoNotDelete;
|
2010-09-05 22:00:05 +04:00
|
|
|
|
class nsIRadioGroupContainer;
|
|
|
|
|
class nsIRadioVisitor;
|
|
|
|
|
|
2013-03-28 23:41:32 +04:00
|
|
|
|
namespace mozilla {
|
2014-03-18 08:48:19 +04:00
|
|
|
|
|
2014-03-18 08:48:20 +04:00
|
|
|
|
class EventChainPostVisitor;
|
2014-03-18 08:48:19 +04:00
|
|
|
|
class EventChainPreVisitor;
|
|
|
|
|
|
2013-03-28 23:41:32 +04:00
|
|
|
|
namespace dom {
|
|
|
|
|
|
2016-06-01 13:29:00 +03:00
|
|
|
|
class AfterSetFilesOrDirectoriesRunnable;
|
2013-08-22 10:30:38 +04:00
|
|
|
|
class Date;
|
2016-06-01 13:29:00 +03:00
|
|
|
|
class DispatchChangeEventCallback;
|
2014-10-08 20:15:23 +04:00
|
|
|
|
class File;
|
2014-10-08 20:15:23 +04:00
|
|
|
|
class FileList;
|
2016-08-18 10:17:25 +03:00
|
|
|
|
class FileSystemEntry;
|
2016-05-31 13:54:24 +03:00
|
|
|
|
class GetFilesHelper;
|
2013-08-22 10:30:38 +04:00
|
|
|
|
|
2015-06-08 16:01:01 +03:00
|
|
|
|
/**
|
|
|
|
|
* A class we use to create a singleton object that is used to keep track of
|
|
|
|
|
* the last directory from which the user has picked files (via
|
|
|
|
|
* <input type=file>) on a per-domain basis. The implementation uses
|
|
|
|
|
* nsIContentPrefService2/NS_CONTENT_PREF_SERVICE_CONTRACTID to store the last
|
|
|
|
|
* directory per-domain, and to ensure that whether the directories are
|
|
|
|
|
* persistently saved (saved across sessions) or not honors whether or not the
|
|
|
|
|
* page is being viewed in private browsing.
|
|
|
|
|
*/
|
|
|
|
|
class UploadLastDir final : public nsIObserver, public nsSupportsWeakReference
|
|
|
|
|
{
|
2014-06-25 06:09:15 +04:00
|
|
|
|
~UploadLastDir() {}
|
|
|
|
|
|
2010-08-27 19:49:06 +04:00
|
|
|
|
public:
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Fetch the last used directory for this location from the content
|
2013-03-30 06:08:57 +04:00
|
|
|
|
* pref service, and display the file picker opened in that directory.
|
2010-08-27 19:49:06 +04:00
|
|
|
|
*
|
2013-03-30 06:08:57 +04:00
|
|
|
|
* @param aDoc current document
|
|
|
|
|
* @param aFilePicker the file picker to open
|
|
|
|
|
* @param aFpCallback the callback object to be run when the file is shown.
|
2010-08-27 19:49:06 +04:00
|
|
|
|
*/
|
2013-03-30 06:08:57 +04:00
|
|
|
|
nsresult FetchDirectoryAndDisplayPicker(nsIDocument* aDoc,
|
|
|
|
|
nsIFilePicker* aFilePicker,
|
|
|
|
|
nsIFilePickerShownCallback* aFpCallback);
|
2010-08-27 19:49:06 +04:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Store the last used directory for this location using the
|
|
|
|
|
* content pref service, if it is available
|
|
|
|
|
* @param aURI URI of the current page
|
2013-08-22 13:43:26 +04:00
|
|
|
|
* @param aDir Parent directory of the file(s)/directory chosen by the user
|
2010-08-27 19:49:06 +04:00
|
|
|
|
*/
|
2013-08-22 13:43:26 +04:00
|
|
|
|
nsresult StoreLastUsedDirectory(nsIDocument* aDoc, nsIFile* aDir);
|
2013-03-30 06:08:57 +04:00
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
|
class ContentPrefCallback final : public nsIContentPrefCallback2
|
2013-03-30 06:08:57 +04:00
|
|
|
|
{
|
2014-06-25 06:09:15 +04:00
|
|
|
|
virtual ~ContentPrefCallback()
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
public:
|
2013-03-30 06:08:57 +04:00
|
|
|
|
ContentPrefCallback(nsIFilePicker* aFilePicker, nsIFilePickerShownCallback* aFpCallback)
|
|
|
|
|
: mFilePicker(aFilePicker)
|
|
|
|
|
, mFpCallback(aFpCallback)
|
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
NS_DECL_NSICONTENTPREFCALLBACK2
|
|
|
|
|
|
|
|
|
|
nsCOMPtr<nsIFilePicker> mFilePicker;
|
|
|
|
|
nsCOMPtr<nsIFilePickerShownCallback> mFpCallback;
|
|
|
|
|
nsCOMPtr<nsIContentPref> mResult;
|
|
|
|
|
};
|
2010-09-05 22:00:05 +04:00
|
|
|
|
};
|
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
|
class HTMLInputElement final : public nsGenericHTMLFormElementWithState,
|
2015-03-27 21:52:19 +03:00
|
|
|
|
public nsImageLoadingContent,
|
|
|
|
|
public nsIDOMHTMLInputElement,
|
|
|
|
|
public nsITextControlElement,
|
|
|
|
|
public nsIDOMNSEditableElement,
|
|
|
|
|
public nsIConstraintValidation
|
2010-09-05 22:00:05 +04:00
|
|
|
|
{
|
2016-06-01 13:29:00 +03:00
|
|
|
|
friend class AfterSetFilesOrDirectoriesCallback;
|
|
|
|
|
friend class DispatchChangeEventCallback;
|
2017-05-04 09:47:08 +03:00
|
|
|
|
friend class ::InputType;
|
2016-06-01 13:29:00 +03:00
|
|
|
|
|
2010-09-05 22:00:05 +04:00
|
|
|
|
public:
|
2010-09-03 00:12:47 +04:00
|
|
|
|
using nsIConstraintValidation::GetValidationMessage;
|
2013-08-02 05:21:31 +04:00
|
|
|
|
using nsGenericHTMLFormElementWithState::GetForm;
|
2017-07-17 09:17:19 +03:00
|
|
|
|
using nsGenericHTMLFormElementWithState::GetFormAction;
|
2010-09-03 00:12:47 +04:00
|
|
|
|
|
2016-10-27 17:17:04 +03:00
|
|
|
|
enum class FromClone { no, yes };
|
|
|
|
|
|
2014-06-20 06:01:40 +04:00
|
|
|
|
HTMLInputElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
|
2016-10-27 17:17:04 +03:00
|
|
|
|
mozilla::dom::FromParser aFromParser,
|
|
|
|
|
FromClone aFromClone = FromClone::no);
|
2010-09-05 22:00:05 +04:00
|
|
|
|
|
2013-03-28 23:41:32 +04:00
|
|
|
|
NS_IMPL_FROMCONTENT_HTML_WITH_TAG(HTMLInputElement, input)
|
2012-09-26 18:17:51 +04:00
|
|
|
|
|
2010-09-05 22:00:05 +04:00
|
|
|
|
// nsISupports
|
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
|
virtual int32_t TabIndexDefault() override;
|
2013-08-08 00:23:08 +04:00
|
|
|
|
using nsGenericHTMLElement::Focus;
|
2015-03-21 19:28:04 +03:00
|
|
|
|
virtual void Blur(ErrorResult& aError) override;
|
|
|
|
|
virtual void Focus(ErrorResult& aError) override;
|
2011-10-30 00:03:55 +04:00
|
|
|
|
|
2016-05-06 13:39:10 +03:00
|
|
|
|
// nsINode
|
2016-08-17 07:55:36 +03:00
|
|
|
|
#if !defined(ANDROID) && !defined(XP_MACOSX)
|
2016-05-06 13:39:10 +03:00
|
|
|
|
virtual bool IsNodeApzAwareInternal() const override;
|
|
|
|
|
#endif
|
|
|
|
|
|
2015-01-20 23:39:28 +03:00
|
|
|
|
// Element
|
2015-03-21 19:28:04 +03:00
|
|
|
|
virtual bool IsInteractiveHTMLContent(bool aIgnoreTabindex) const override;
|
2015-01-20 23:39:28 +03:00
|
|
|
|
|
2016-10-06 07:30:35 +03:00
|
|
|
|
// EventTarget
|
|
|
|
|
virtual void AsyncEventRunning(AsyncEventDispatcher* aEvent) override;
|
|
|
|
|
|
2010-09-05 22:00:05 +04:00
|
|
|
|
// nsIDOMHTMLInputElement
|
|
|
|
|
NS_DECL_NSIDOMHTMLINPUTELEMENT
|
|
|
|
|
|
|
|
|
|
// nsIDOMNSEditableElement
|
2015-03-21 19:28:04 +03:00
|
|
|
|
NS_IMETHOD GetEditor(nsIEditor** aEditor) override
|
2010-09-05 22:00:05 +04:00
|
|
|
|
{
|
2017-06-22 09:21:31 +03:00
|
|
|
|
nsCOMPtr<nsIEditor> editor = GetEditor();
|
|
|
|
|
editor.forget(aEditor);
|
|
|
|
|
return NS_OK;
|
2010-09-05 22:00:05 +04:00
|
|
|
|
}
|
2011-06-01 10:06:38 +04:00
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
|
NS_IMETHOD SetUserInput(const nsAString& aInput) override;
|
2010-09-05 22:00:05 +04:00
|
|
|
|
|
|
|
|
|
// Overriden nsIFormControl methods
|
2015-03-21 19:28:04 +03:00
|
|
|
|
NS_IMETHOD Reset() override;
|
2016-06-16 10:24:16 +03:00
|
|
|
|
NS_IMETHOD SubmitNamesValues(HTMLFormSubmission* aFormSubmission) override;
|
2015-03-21 19:28:04 +03:00
|
|
|
|
NS_IMETHOD SaveState() override;
|
|
|
|
|
virtual bool RestoreState(nsPresState* aState) override;
|
|
|
|
|
virtual bool AllowDrop() override;
|
2015-08-26 15:56:59 +03:00
|
|
|
|
virtual bool IsDisabledForEvents(EventMessage aMessage) override;
|
2010-09-05 22:00:05 +04:00
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
|
virtual void FieldSetDisabledChanged(bool aNotify) override;
|
2010-09-19 01:33:16 +04:00
|
|
|
|
|
2010-09-05 22:00:05 +04:00
|
|
|
|
// nsIContent
|
2015-03-21 19:28:04 +03:00
|
|
|
|
virtual bool IsHTMLFocusable(bool aWithMouse, bool *aIsFocusable, int32_t *aTabIndex) override;
|
2010-09-05 22:00:05 +04:00
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
|
virtual bool ParseAttribute(int32_t aNamespaceID,
|
2017-10-03 01:05:19 +03:00
|
|
|
|
nsAtom* aAttribute,
|
2010-09-05 22:00:05 +04:00
|
|
|
|
const nsAString& aValue,
|
2017-11-02 06:35:52 +03:00
|
|
|
|
nsIPrincipal* aMaybeScriptedPrincipal,
|
2015-03-21 19:28:04 +03:00
|
|
|
|
nsAttrValue& aResult) override;
|
2017-10-03 01:05:19 +03:00
|
|
|
|
virtual nsChangeHint GetAttributeChangeHint(const nsAtom* aAttribute,
|
2015-03-21 19:28:04 +03:00
|
|
|
|
int32_t aModType) const override;
|
2017-10-03 01:05:19 +03:00
|
|
|
|
NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override;
|
2015-03-21 19:28:04 +03:00
|
|
|
|
virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const override;
|
2010-09-05 22:00:05 +04:00
|
|
|
|
|
2016-10-21 05:11:07 +03:00
|
|
|
|
virtual nsresult GetEventTargetParent(
|
|
|
|
|
EventChainPreVisitor& aVisitor) override;
|
2016-10-21 14:04:29 +03:00
|
|
|
|
virtual nsresult PreHandleEvent(EventChainVisitor& aVisitor) override;
|
2014-03-18 08:48:20 +04:00
|
|
|
|
virtual nsresult PostHandleEvent(
|
2015-03-21 19:28:04 +03:00
|
|
|
|
EventChainPostVisitor& aVisitor) override;
|
2014-03-18 08:48:20 +04:00
|
|
|
|
void PostHandleEventForRangeThumb(EventChainPostVisitor& aVisitor);
|
2013-10-02 07:46:03 +04:00
|
|
|
|
void StartRangeThumbDrag(WidgetGUIEvent* aEvent);
|
|
|
|
|
void FinishRangeThumbDrag(WidgetGUIEvent* aEvent = nullptr);
|
2013-03-16 09:49:41 +04:00
|
|
|
|
void CancelRangeThumbDrag(bool aIsForUserEvent = true);
|
2013-05-06 03:23:18 +04:00
|
|
|
|
void SetValueOfRangeForUserEvent(Decimal aValue);
|
2010-09-05 22:00:05 +04:00
|
|
|
|
|
|
|
|
|
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|
|
|
|
nsIContent* aBindingParent,
|
2015-03-21 19:28:04 +03:00
|
|
|
|
bool aCompileEventHandlers) override;
|
2011-09-29 10:19:26 +04:00
|
|
|
|
virtual void UnbindFromTree(bool aDeep = true,
|
2015-03-21 19:28:04 +03:00
|
|
|
|
bool aNullParent = true) override;
|
2010-09-05 22:00:05 +04:00
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
|
virtual void DoneCreatingElement() override;
|
2010-09-05 22:00:05 +04:00
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
|
virtual EventStates IntrinsicState() const override;
|
2010-09-05 22:00:05 +04:00
|
|
|
|
|
2013-12-09 01:26:42 +04:00
|
|
|
|
// Element
|
|
|
|
|
private:
|
2015-03-21 19:28:04 +03:00
|
|
|
|
virtual void AddStates(EventStates aStates) override;
|
|
|
|
|
virtual void RemoveStates(EventStates aStates) override;
|
2014-04-03 08:18:36 +04:00
|
|
|
|
|
2013-12-09 01:26:42 +04:00
|
|
|
|
public:
|
|
|
|
|
|
2010-09-05 22:00:05 +04:00
|
|
|
|
// nsITextControlElement
|
2015-03-21 19:28:04 +03:00
|
|
|
|
NS_IMETHOD SetValueChanged(bool aValueChanged) override;
|
|
|
|
|
NS_IMETHOD_(bool) IsSingleLineTextControl() const override;
|
|
|
|
|
NS_IMETHOD_(bool) IsTextArea() const override;
|
|
|
|
|
NS_IMETHOD_(bool) IsPasswordTextControl() const override;
|
|
|
|
|
NS_IMETHOD_(int32_t) GetCols() override;
|
|
|
|
|
NS_IMETHOD_(int32_t) GetWrapCols() override;
|
|
|
|
|
NS_IMETHOD_(int32_t) GetRows() override;
|
|
|
|
|
NS_IMETHOD_(void) GetDefaultValueFromContent(nsAString& aValue) override;
|
|
|
|
|
NS_IMETHOD_(bool) ValueChanged() const override;
|
|
|
|
|
NS_IMETHOD_(void) GetTextEditorValue(nsAString& aValue, bool aIgnoreWrap) const override;
|
2017-06-22 09:21:31 +03:00
|
|
|
|
NS_IMETHOD_(mozilla::TextEditor*) GetTextEditor() override;
|
2015-03-21 19:28:04 +03:00
|
|
|
|
NS_IMETHOD_(nsISelectionController*) GetSelectionController() override;
|
|
|
|
|
NS_IMETHOD_(nsFrameSelection*) GetConstFrameSelection() override;
|
|
|
|
|
NS_IMETHOD BindToFrame(nsTextControlFrame* aFrame) override;
|
|
|
|
|
NS_IMETHOD_(void) UnbindFromFrame(nsTextControlFrame* aFrame) override;
|
|
|
|
|
NS_IMETHOD CreateEditor() override;
|
2017-02-28 20:41:37 +03:00
|
|
|
|
NS_IMETHOD_(Element*) GetRootEditorNode() override;
|
2015-03-21 19:28:04 +03:00
|
|
|
|
NS_IMETHOD_(Element*) GetPlaceholderNode() override;
|
2017-03-20 06:53:40 +03:00
|
|
|
|
NS_IMETHOD_(Element*) GetPreviewNode() override;
|
2017-03-30 12:38:59 +03:00
|
|
|
|
NS_IMETHOD_(void) UpdateOverlayTextVisibility(bool aNotify) override;
|
2017-03-20 19:08:01 +03:00
|
|
|
|
NS_IMETHOD_(void) SetPreviewValue(const nsAString& aValue) override;
|
|
|
|
|
NS_IMETHOD_(void) GetPreviewValue(nsAString& aValue) override;
|
2017-03-22 11:55:56 +03:00
|
|
|
|
NS_IMETHOD_(void) EnablePreview() override;
|
|
|
|
|
NS_IMETHOD_(bool) IsPreviewEnabled() override;
|
2015-03-21 19:28:04 +03:00
|
|
|
|
NS_IMETHOD_(bool) GetPlaceholderVisibility() override;
|
2017-03-30 12:38:59 +03:00
|
|
|
|
NS_IMETHOD_(bool) GetPreviewVisibility() override;
|
2015-03-21 19:28:04 +03:00
|
|
|
|
NS_IMETHOD_(void) InitializeKeyboardEventListeners() override;
|
2016-08-06 18:59:08 +03:00
|
|
|
|
NS_IMETHOD_(void) OnValueChanged(bool aNotify, bool aWasInteractiveUserChange) override;
|
2017-03-09 22:44:06 +03:00
|
|
|
|
virtual void GetValueFromSetRangeText(nsAString& aValue) override;
|
|
|
|
|
virtual nsresult SetValueFromSetRangeText(const nsAString& aValue) override;
|
2015-03-21 19:28:04 +03:00
|
|
|
|
NS_IMETHOD_(bool) HasCachedSelection() override;
|
2010-09-05 22:00:05 +04:00
|
|
|
|
|
2017-03-09 22:44:03 +03:00
|
|
|
|
// Methods for nsFormFillController so it can do selection operations on input
|
|
|
|
|
// types the HTML spec doesn't support them on, like "email".
|
2017-03-09 22:44:05 +03:00
|
|
|
|
uint32_t GetSelectionStartIgnoringType(ErrorResult& aRv);
|
2017-03-09 22:44:05 +03:00
|
|
|
|
uint32_t GetSelectionEndIgnoringType(ErrorResult& aRv);
|
2017-03-09 22:44:03 +03:00
|
|
|
|
|
2010-09-05 22:00:05 +04:00
|
|
|
|
void GetDisplayFileName(nsAString& aFileName) const;
|
2013-03-28 23:41:32 +04:00
|
|
|
|
|
2017-04-26 09:36:00 +03:00
|
|
|
|
const nsTArray<OwningFileOrDirectory>& GetFilesOrDirectoriesInternal() const;
|
2013-03-28 23:41:32 +04:00
|
|
|
|
|
2016-03-20 13:56:10 +03:00
|
|
|
|
void SetFilesOrDirectories(const nsTArray<OwningFileOrDirectory>& aFilesOrDirectories,
|
|
|
|
|
bool aSetValueChanged);
|
2018-03-16 22:55:32 +03:00
|
|
|
|
void SetFiles(FileList* aFiles, bool aSetValueChanged);
|
2010-09-05 22:00:05 +04:00
|
|
|
|
|
2016-07-14 10:02:30 +03:00
|
|
|
|
// This method is used for test only. Onces the data is set, a 'change' event
|
|
|
|
|
// is dispatched.
|
2016-06-07 01:55:16 +03:00
|
|
|
|
void MozSetDndFilesAndDirectories(const nsTArray<OwningFileOrDirectory>& aSequence);
|
|
|
|
|
|
2013-12-07 16:09:14 +04:00
|
|
|
|
// Called when a nsIFilePicker or a nsIColorPicker terminate.
|
|
|
|
|
void PickerClosed();
|
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
|
void SetCheckedChangedInternal(bool aCheckedChanged);
|
|
|
|
|
bool GetCheckedChanged() const {
|
2011-11-16 11:50:19 +04:00
|
|
|
|
return mCheckedChanged;
|
2010-11-24 02:53:06 +03:00
|
|
|
|
}
|
2010-11-24 02:53:39 +03:00
|
|
|
|
void AddedToRadioGroup();
|
2010-11-11 15:34:27 +03:00
|
|
|
|
void WillRemoveFromRadioGroup();
|
2010-09-05 22:00:05 +04:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Helper function returning the currently selected button in the radio group.
|
|
|
|
|
* Returning null if the element is not a button or if there is no selectied
|
|
|
|
|
* button in the group.
|
|
|
|
|
*
|
|
|
|
|
* @return the selected button (or null).
|
|
|
|
|
*/
|
2018-02-21 01:11:27 +03:00
|
|
|
|
HTMLInputElement* GetSelectedRadioButton() const;
|
2010-09-05 22:00:05 +04:00
|
|
|
|
|
2017-04-20 22:57:48 +03:00
|
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
|
|
|
|
|
bool aPreallocateChildren) const override;
|
2010-09-05 22:00:05 +04:00
|
|
|
|
|
2013-03-28 23:41:32 +04:00
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLInputElement,
|
2013-08-02 05:21:31 +04:00
|
|
|
|
nsGenericHTMLFormElementWithState)
|
2010-09-05 22:00:05 +04:00
|
|
|
|
|
|
|
|
|
static UploadLastDir* gUploadLastDir;
|
2010-08-27 19:49:06 +04:00
|
|
|
|
// create and destroy the static UploadLastDir object for remembering
|
|
|
|
|
// which directory was last used on a site-by-site basis
|
|
|
|
|
static void InitUploadLastDir();
|
2010-09-05 22:00:05 +04:00
|
|
|
|
static void DestroyUploadLastDir();
|
|
|
|
|
|
2016-06-20 16:55:00 +03:00
|
|
|
|
//If the valueAsDate attribute should be enabled in webIDL
|
|
|
|
|
static bool ValueAsDateEnabled(JSContext* cx, JSObject* obj);
|
|
|
|
|
|
2010-09-05 22:00:05 +04:00
|
|
|
|
void MaybeLoadImage();
|
|
|
|
|
|
2017-03-09 22:44:04 +03:00
|
|
|
|
void SetSelectionCached()
|
2014-08-01 04:25:31 +04:00
|
|
|
|
{
|
|
|
|
|
MOZ_ASSERT(mType == NS_FORM_INPUT_NUMBER);
|
|
|
|
|
mSelectionCached = true;
|
|
|
|
|
}
|
|
|
|
|
bool IsSelectionCached() const
|
|
|
|
|
{
|
|
|
|
|
MOZ_ASSERT(mType == NS_FORM_INPUT_NUMBER);
|
|
|
|
|
return mSelectionCached;
|
|
|
|
|
}
|
|
|
|
|
void ClearSelectionCached()
|
|
|
|
|
{
|
|
|
|
|
MOZ_ASSERT(mType == NS_FORM_INPUT_NUMBER);
|
|
|
|
|
mSelectionCached = false;
|
|
|
|
|
}
|
|
|
|
|
nsTextEditorState::SelectionProperties& GetSelectionProperties()
|
|
|
|
|
{
|
|
|
|
|
MOZ_ASSERT(mType == NS_FORM_INPUT_NUMBER);
|
|
|
|
|
return mSelectionProperties;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-18 06:57:00 +03:00
|
|
|
|
bool HasPatternAttribute() const
|
|
|
|
|
{
|
|
|
|
|
return mHasPatternAttribute;
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-08 16:07:22 +03:00
|
|
|
|
virtual already_AddRefed<nsITextControlElement> GetAsTextControlElement() override
|
|
|
|
|
{
|
|
|
|
|
nsCOMPtr<nsITextControlElement> txt = this;
|
|
|
|
|
return txt.forget();
|
|
|
|
|
}
|
|
|
|
|
|
2010-09-05 22:00:05 +04:00
|
|
|
|
// nsIConstraintValidation
|
2011-09-29 10:19:26 +04:00
|
|
|
|
bool IsTooLong();
|
2016-08-17 07:11:24 +03:00
|
|
|
|
bool IsTooShort();
|
2011-09-29 10:19:26 +04:00
|
|
|
|
bool IsValueMissing() const;
|
|
|
|
|
bool HasTypeMismatch() const;
|
|
|
|
|
bool HasPatternMismatch() const;
|
2012-06-22 13:36:24 +04:00
|
|
|
|
bool IsRangeOverflow() const;
|
2012-06-22 13:38:20 +04:00
|
|
|
|
bool IsRangeUnderflow() const;
|
2014-02-27 03:04:31 +04:00
|
|
|
|
bool HasStepMismatch(bool aUseZeroIfValueNaN = false) const;
|
2014-01-30 16:54:12 +04:00
|
|
|
|
bool HasBadInput() const;
|
2010-09-05 22:00:05 +04:00
|
|
|
|
void UpdateTooLongValidityState();
|
2016-08-17 07:11:24 +03:00
|
|
|
|
void UpdateTooShortValidityState();
|
2010-09-05 22:00:05 +04:00
|
|
|
|
void UpdateValueMissingValidityState();
|
|
|
|
|
void UpdateTypeMismatchValidityState();
|
|
|
|
|
void UpdatePatternMismatchValidityState();
|
2012-06-22 13:36:24 +04:00
|
|
|
|
void UpdateRangeOverflowValidityState();
|
2012-06-22 13:38:20 +04:00
|
|
|
|
void UpdateRangeUnderflowValidityState();
|
2012-06-22 23:02:20 +04:00
|
|
|
|
void UpdateStepMismatchValidityState();
|
2014-01-30 16:54:12 +04:00
|
|
|
|
void UpdateBadInputValidityState();
|
2017-09-22 22:47:16 +03:00
|
|
|
|
// Update all our validity states and then update our element state
|
|
|
|
|
// as needed. aNotify controls whether the element state update
|
|
|
|
|
// needs to notify.
|
2011-09-29 10:19:26 +04:00
|
|
|
|
void UpdateAllValidityStates(bool aNotify);
|
2017-09-22 22:47:16 +03:00
|
|
|
|
// Update all our validity states without updating element state.
|
|
|
|
|
// This should be called instead of UpdateAllValidityStates any time
|
|
|
|
|
// we're guaranteed that element state will be updated anyway.
|
|
|
|
|
void UpdateAllValidityStatesButNotElementState();
|
2010-09-10 09:08:56 +04:00
|
|
|
|
void UpdateBarredFromConstraintValidation();
|
2010-09-05 22:00:05 +04:00
|
|
|
|
nsresult GetValidationMessage(nsAString& aValidationMessage,
|
2015-03-21 19:28:04 +03:00
|
|
|
|
ValidityStateType aType) override;
|
2017-07-14 06:46:28 +03:00
|
|
|
|
|
|
|
|
|
// Override SetCustomValidity so we update our state properly when it's called
|
|
|
|
|
// via bindings.
|
|
|
|
|
void SetCustomValidity(const nsAString& aError);
|
|
|
|
|
|
2010-12-16 22:51:59 +03:00
|
|
|
|
/**
|
|
|
|
|
* Update the value missing validity state for radio elements when they have
|
|
|
|
|
* a group.
|
|
|
|
|
*
|
|
|
|
|
* @param aIgnoreSelf Whether the required attribute and the checked state
|
|
|
|
|
* of the current radio should be ignored.
|
2012-11-28 07:15:36 +04:00
|
|
|
|
* @note This method shouldn't be called if the radio element hasn't a group.
|
2010-12-16 22:51:59 +03:00
|
|
|
|
*/
|
|
|
|
|
void UpdateValueMissingValidityStateForRadio(bool aIgnoreSelf);
|
2010-09-05 22:00:05 +04:00
|
|
|
|
|
2012-06-06 16:16:58 +04:00
|
|
|
|
/**
|
|
|
|
|
* Set filters to the filePicker according to the accept attribute value.
|
|
|
|
|
*
|
|
|
|
|
* See:
|
|
|
|
|
* http://dev.w3.org/html5/spec/forms.html#attr-input-accept
|
|
|
|
|
*
|
|
|
|
|
* @note You should not call this function if the element has no @accept.
|
|
|
|
|
* @note "All Files" filter is always set, no matter if there is a valid
|
2014-11-29 14:22:30 +03:00
|
|
|
|
* filter specified or not.
|
2012-06-06 16:16:58 +04:00
|
|
|
|
* @note If more than one valid filter is found, the "All Supported Types"
|
|
|
|
|
* filter is added, which is the concatenation of all valid filters.
|
2014-12-19 02:30:11 +03:00
|
|
|
|
* @note Duplicate filters and similar filters (i.e. filters whose file
|
|
|
|
|
* extensions already exist in another filter) are ignored.
|
2014-11-29 14:22:30 +03:00
|
|
|
|
* @note "All Files" filter will be selected by default if unknown mime types
|
|
|
|
|
* have been specified and no file extension filter has been specified.
|
|
|
|
|
* Otherwise, specified filter or "All Supported Types" filter will be
|
|
|
|
|
* selected by default.
|
|
|
|
|
* The logic behind is that having unknown mime type means we might restrict
|
|
|
|
|
* user's input too much, as some filters will be missing.
|
|
|
|
|
* However, if author has also specified some file extension filters, it's
|
|
|
|
|
* likely those are fallback for the unusual mime type we haven't been able
|
|
|
|
|
* to resolve; so it's better to select author specified filters in that case.
|
2012-06-06 16:16:58 +04:00
|
|
|
|
*/
|
|
|
|
|
void SetFilePickerFiltersFromAccept(nsIFilePicker* filePicker);
|
|
|
|
|
|
2011-01-20 14:02:37 +03:00
|
|
|
|
/**
|
|
|
|
|
* The form might need to request an update of the UI bits
|
|
|
|
|
* (BF_CAN_SHOW_INVALID_UI and BF_CAN_SHOW_VALID_UI) when an invalid form
|
|
|
|
|
* submission is tried.
|
|
|
|
|
*
|
|
|
|
|
* @param aIsFocused Whether the element is currently focused.
|
|
|
|
|
*
|
|
|
|
|
* @note The caller is responsible to call ContentStatesChanged.
|
|
|
|
|
*/
|
|
|
|
|
void UpdateValidityUIBits(bool aIsFocused);
|
|
|
|
|
|
2012-06-03 15:36:51 +04:00
|
|
|
|
/**
|
|
|
|
|
* Fires change event if mFocusedValue and current value held are unequal.
|
2012-05-07 20:27:24 +04:00
|
|
|
|
*/
|
|
|
|
|
void FireChangeEventIfNeeded();
|
2011-11-16 11:50:19 +04:00
|
|
|
|
|
2013-02-16 21:57:21 +04:00
|
|
|
|
/**
|
2013-05-06 03:23:18 +04:00
|
|
|
|
* Returns the input element's value as a Decimal.
|
2013-02-16 21:57:21 +04:00
|
|
|
|
* Returns NaN if the current element's value is not a floating point number.
|
|
|
|
|
*
|
2013-05-06 03:23:18 +04:00
|
|
|
|
* @return the input element's value as a Decimal.
|
2013-02-16 21:57:21 +04:00
|
|
|
|
*/
|
2013-05-06 03:23:18 +04:00
|
|
|
|
Decimal GetValueAsDecimal() const;
|
2013-02-16 21:57:21 +04:00
|
|
|
|
|
2013-02-16 21:57:21 +04:00
|
|
|
|
/**
|
|
|
|
|
* Returns the input's "minimum" (as defined by the HTML5 spec) as a double.
|
|
|
|
|
* Note this takes account of any default minimum that the type may have.
|
|
|
|
|
* Returns NaN if the min attribute isn't a valid floating point number and
|
|
|
|
|
* the input's type does not have a default minimum.
|
|
|
|
|
*
|
|
|
|
|
* NOTE: Only call this if you know DoesMinMaxApply() returns true.
|
|
|
|
|
*/
|
2013-05-06 03:23:18 +04:00
|
|
|
|
Decimal GetMinimum() const;
|
2013-02-16 21:57:21 +04:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the input's "maximum" (as defined by the HTML5 spec) as a double.
|
|
|
|
|
* Note this takes account of any default maximum that the type may have.
|
|
|
|
|
* Returns NaN if the max attribute isn't a valid floating point number and
|
|
|
|
|
* the input's type does not have a default maximum.
|
|
|
|
|
*
|
|
|
|
|
* NOTE:Only call this if you know DoesMinMaxApply() returns true.
|
|
|
|
|
*/
|
2013-05-06 03:23:18 +04:00
|
|
|
|
Decimal GetMaximum() const;
|
2013-02-16 21:57:21 +04:00
|
|
|
|
|
2013-03-28 23:41:32 +04:00
|
|
|
|
// WebIDL
|
|
|
|
|
|
2017-07-14 06:46:13 +03:00
|
|
|
|
void GetAccept(nsAString& aValue)
|
|
|
|
|
{
|
|
|
|
|
GetHTMLAttr(nsGkAtoms::accept, aValue);
|
|
|
|
|
}
|
2013-03-28 23:41:32 +04:00
|
|
|
|
void SetAccept(const nsAString& aValue, ErrorResult& aRv)
|
|
|
|
|
{
|
|
|
|
|
SetHTMLAttr(nsGkAtoms::accept, aValue, aRv);
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-14 06:46:13 +03:00
|
|
|
|
void GetAlt(nsAString& aValue)
|
|
|
|
|
{
|
|
|
|
|
GetHTMLAttr(nsGkAtoms::alt, aValue);
|
|
|
|
|
}
|
2013-03-28 23:41:32 +04:00
|
|
|
|
void SetAlt(const nsAString& aValue, ErrorResult& aRv)
|
|
|
|
|
{
|
|
|
|
|
SetHTMLAttr(nsGkAtoms::alt, aValue, aRv);
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-21 01:10:44 +03:00
|
|
|
|
void GetAutocomplete(nsAString& aValue);
|
2013-03-28 23:41:32 +04:00
|
|
|
|
void SetAutocomplete(const nsAString& aValue, ErrorResult& aRv)
|
|
|
|
|
{
|
|
|
|
|
SetHTMLAttr(nsGkAtoms::autocomplete, aValue, aRv);
|
|
|
|
|
}
|
2014-07-09 11:01:00 +04:00
|
|
|
|
|
2014-09-16 04:56:00 +04:00
|
|
|
|
void GetAutocompleteInfo(Nullable<AutocompleteInfo>& aInfo);
|
2013-03-28 23:41:32 +04:00
|
|
|
|
|
|
|
|
|
bool Autofocus() const
|
|
|
|
|
{
|
|
|
|
|
return GetBoolAttr(nsGkAtoms::autofocus);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetAutofocus(bool aValue, ErrorResult& aRv)
|
|
|
|
|
{
|
|
|
|
|
SetHTMLBoolAttr(nsGkAtoms::autofocus, aValue, aRv);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool DefaultChecked() const
|
|
|
|
|
{
|
|
|
|
|
return HasAttr(kNameSpaceID_None, nsGkAtoms::checked);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetDefaultChecked(bool aValue, ErrorResult& aRv)
|
|
|
|
|
{
|
|
|
|
|
SetHTMLBoolAttr(nsGkAtoms::checked, aValue, aRv);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Checked() const
|
|
|
|
|
{
|
|
|
|
|
return mChecked;
|
|
|
|
|
}
|
2018-02-21 01:10:44 +03:00
|
|
|
|
void SetChecked(bool aChecked);
|
2013-03-28 23:41:32 +04:00
|
|
|
|
|
|
|
|
|
bool Disabled() const
|
|
|
|
|
{
|
|
|
|
|
return GetBoolAttr(nsGkAtoms::disabled);
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-14 06:46:13 +03:00
|
|
|
|
void SetDisabled(bool aValue, ErrorResult& aRv)
|
2013-03-28 23:41:32 +04:00
|
|
|
|
{
|
|
|
|
|
SetHTMLBoolAttr(nsGkAtoms::disabled, aValue, aRv);
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-08 20:15:23 +04:00
|
|
|
|
FileList* GetFiles();
|
2017-08-08 12:49:48 +03:00
|
|
|
|
void SetFiles(FileList* aFiles);
|
2013-03-28 23:41:32 +04:00
|
|
|
|
|
|
|
|
|
void SetFormAction(const nsAString& aValue, ErrorResult& aRv)
|
|
|
|
|
{
|
|
|
|
|
SetHTMLAttr(nsGkAtoms::formaction, aValue, aRv);
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-14 06:46:13 +03:00
|
|
|
|
void GetFormEnctype(nsAString& aValue);
|
2013-03-28 23:41:32 +04:00
|
|
|
|
void SetFormEnctype(const nsAString& aValue, ErrorResult& aRv)
|
|
|
|
|
{
|
|
|
|
|
SetHTMLAttr(nsGkAtoms::formenctype, aValue, aRv);
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-14 06:46:13 +03:00
|
|
|
|
void GetFormMethod(nsAString& aValue);
|
2013-03-28 23:41:32 +04:00
|
|
|
|
void SetFormMethod(const nsAString& aValue, ErrorResult& aRv)
|
|
|
|
|
{
|
|
|
|
|
SetHTMLAttr(nsGkAtoms::formmethod, aValue, aRv);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FormNoValidate() const
|
|
|
|
|
{
|
|
|
|
|
return GetBoolAttr(nsGkAtoms::formnovalidate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetFormNoValidate(bool aValue, ErrorResult& aRv)
|
|
|
|
|
{
|
|
|
|
|
SetHTMLBoolAttr(nsGkAtoms::formnovalidate, aValue, aRv);
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-14 06:46:13 +03:00
|
|
|
|
void GetFormTarget(nsAString& aValue)
|
|
|
|
|
{
|
|
|
|
|
GetHTMLAttr(nsGkAtoms::formtarget, aValue);
|
|
|
|
|
}
|
2013-03-28 23:41:32 +04:00
|
|
|
|
void SetFormTarget(const nsAString& aValue, ErrorResult& aRv)
|
|
|
|
|
{
|
|
|
|
|
SetHTMLAttr(nsGkAtoms::formtarget, aValue, aRv);
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-05 19:18:16 +03:00
|
|
|
|
MOZ_CAN_RUN_SCRIPT uint32_t Height();
|
2013-03-28 23:41:32 +04:00
|
|
|
|
|
|
|
|
|
void SetHeight(uint32_t aValue, ErrorResult& aRv)
|
|
|
|
|
{
|
2016-05-05 21:29:54 +03:00
|
|
|
|
SetUnsignedIntAttr(nsGkAtoms::height, aValue, 0, aRv);
|
2013-03-28 23:41:32 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Indeterminate() const
|
|
|
|
|
{
|
|
|
|
|
return mIndeterminate;
|
|
|
|
|
}
|
2017-11-17 06:07:12 +03:00
|
|
|
|
|
|
|
|
|
bool IsDraggingRange() const
|
|
|
|
|
{
|
|
|
|
|
return mIsDraggingRange;
|
|
|
|
|
}
|
2018-02-21 01:10:44 +03:00
|
|
|
|
void SetIndeterminate(bool aValue);
|
2013-03-28 23:41:32 +04:00
|
|
|
|
|
2017-07-14 06:46:13 +03:00
|
|
|
|
void GetInputMode(nsAString& aValue);
|
2013-03-28 23:41:32 +04:00
|
|
|
|
void SetInputMode(const nsAString& aValue, ErrorResult& aRv)
|
|
|
|
|
{
|
|
|
|
|
SetHTMLAttr(nsGkAtoms::inputmode, aValue, aRv);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nsGenericHTMLElement* GetList() const;
|
|
|
|
|
|
2017-07-14 06:46:13 +03:00
|
|
|
|
void GetMax(nsAString& aValue)
|
|
|
|
|
{
|
|
|
|
|
GetHTMLAttr(nsGkAtoms::max, aValue);
|
|
|
|
|
}
|
2013-03-28 23:41:32 +04:00
|
|
|
|
void SetMax(const nsAString& aValue, ErrorResult& aRv)
|
|
|
|
|
{
|
|
|
|
|
SetHTMLAttr(nsGkAtoms::max, aValue, aRv);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32_t MaxLength() const
|
|
|
|
|
{
|
|
|
|
|
return GetIntAttr(nsGkAtoms::maxlength, -1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetMaxLength(int32_t aValue, ErrorResult& aRv)
|
|
|
|
|
{
|
2016-08-17 07:11:24 +03:00
|
|
|
|
int32_t minLength = MinLength();
|
|
|
|
|
if (aValue < 0 || (minLength >= 0 && aValue < minLength)) {
|
2013-03-28 23:41:32 +04:00
|
|
|
|
aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SetHTMLIntAttr(nsGkAtoms::maxlength, aValue, aRv);
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-17 07:11:24 +03:00
|
|
|
|
int32_t MinLength() const
|
|
|
|
|
{
|
|
|
|
|
return GetIntAttr(nsGkAtoms::minlength, -1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetMinLength(int32_t aValue, ErrorResult& aRv)
|
|
|
|
|
{
|
|
|
|
|
int32_t maxLength = MaxLength();
|
|
|
|
|
if (aValue < 0 || (maxLength >= 0 && aValue > maxLength)) {
|
|
|
|
|
aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SetHTMLIntAttr(nsGkAtoms::minlength, aValue, aRv);
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-14 06:46:13 +03:00
|
|
|
|
void GetMin(nsAString& aValue)
|
|
|
|
|
{
|
|
|
|
|
GetHTMLAttr(nsGkAtoms::min, aValue);
|
|
|
|
|
}
|
2013-03-28 23:41:32 +04:00
|
|
|
|
void SetMin(const nsAString& aValue, ErrorResult& aRv)
|
|
|
|
|
{
|
|
|
|
|
SetHTMLAttr(nsGkAtoms::min, aValue, aRv);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Multiple() const
|
|
|
|
|
{
|
|
|
|
|
return GetBoolAttr(nsGkAtoms::multiple);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetMultiple(bool aValue, ErrorResult& aRv)
|
|
|
|
|
{
|
|
|
|
|
SetHTMLBoolAttr(nsGkAtoms::multiple, aValue, aRv);
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-21 01:10:44 +03:00
|
|
|
|
void GetName(nsAString& aValue)
|
|
|
|
|
{
|
|
|
|
|
GetHTMLAttr(nsGkAtoms::name, aValue);
|
|
|
|
|
}
|
2013-03-28 23:41:32 +04:00
|
|
|
|
void SetName(const nsAString& aValue, ErrorResult& aRv)
|
|
|
|
|
{
|
|
|
|
|
SetHTMLAttr(nsGkAtoms::name, aValue, aRv);
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-14 06:46:13 +03:00
|
|
|
|
void GetPattern(nsAString& aValue)
|
|
|
|
|
{
|
|
|
|
|
GetHTMLAttr(nsGkAtoms::pattern, aValue);
|
|
|
|
|
}
|
2013-03-28 23:41:32 +04:00
|
|
|
|
void SetPattern(const nsAString& aValue, ErrorResult& aRv)
|
|
|
|
|
{
|
|
|
|
|
SetHTMLAttr(nsGkAtoms::pattern, aValue, aRv);
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-14 06:46:13 +03:00
|
|
|
|
void GetPlaceholder(nsAString& aValue)
|
|
|
|
|
{
|
|
|
|
|
GetHTMLAttr(nsGkAtoms::placeholder, aValue);
|
|
|
|
|
}
|
2013-03-28 23:41:32 +04:00
|
|
|
|
void SetPlaceholder(const nsAString& aValue, ErrorResult& aRv)
|
|
|
|
|
{
|
|
|
|
|
SetHTMLAttr(nsGkAtoms::placeholder, aValue, aRv);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ReadOnly() const
|
|
|
|
|
{
|
|
|
|
|
return GetBoolAttr(nsGkAtoms::readonly);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetReadOnly(bool aValue, ErrorResult& aRv)
|
|
|
|
|
{
|
|
|
|
|
SetHTMLBoolAttr(nsGkAtoms::readonly, aValue, aRv);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Required() const
|
|
|
|
|
{
|
|
|
|
|
return GetBoolAttr(nsGkAtoms::required);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetRequired(bool aValue, ErrorResult& aRv)
|
|
|
|
|
{
|
|
|
|
|
SetHTMLBoolAttr(nsGkAtoms::required, aValue, aRv);
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-04 11:03:50 +04:00
|
|
|
|
uint32_t Size() const
|
2013-03-28 23:41:32 +04:00
|
|
|
|
{
|
2013-04-04 11:03:50 +04:00
|
|
|
|
return GetUnsignedIntAttr(nsGkAtoms::size, DEFAULT_COLS);
|
2013-03-28 23:41:32 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetSize(uint32_t aValue, ErrorResult& aRv)
|
|
|
|
|
{
|
|
|
|
|
if (aValue == 0) {
|
|
|
|
|
aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-05 21:29:54 +03:00
|
|
|
|
SetUnsignedIntAttr(nsGkAtoms::size, aValue, DEFAULT_COLS, aRv);
|
2013-03-28 23:41:32 +04:00
|
|
|
|
}
|
|
|
|
|
|
2017-12-06 00:03:18 +03:00
|
|
|
|
void GetSrc(nsAString& aValue)
|
2017-07-14 06:46:13 +03:00
|
|
|
|
{
|
|
|
|
|
GetURIAttr(nsGkAtoms::src, nullptr, aValue);
|
|
|
|
|
}
|
2017-12-21 01:43:18 +03:00
|
|
|
|
void SetSrc(const nsAString& aValue, nsIPrincipal* aTriggeringPrincipal, ErrorResult& aRv)
|
2013-03-28 23:41:32 +04:00
|
|
|
|
{
|
2017-10-06 02:19:19 +03:00
|
|
|
|
SetHTMLAttr(nsGkAtoms::src, aValue, aTriggeringPrincipal, aRv);
|
2013-03-28 23:41:32 +04:00
|
|
|
|
}
|
|
|
|
|
|
2017-07-14 06:46:13 +03:00
|
|
|
|
void GetStep(nsAString& aValue)
|
|
|
|
|
{
|
|
|
|
|
GetHTMLAttr(nsGkAtoms::step, aValue);
|
|
|
|
|
}
|
2013-03-28 23:41:32 +04:00
|
|
|
|
void SetStep(const nsAString& aValue, ErrorResult& aRv)
|
|
|
|
|
{
|
|
|
|
|
SetHTMLAttr(nsGkAtoms::step, aValue, aRv);
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-14 06:46:13 +03:00
|
|
|
|
void GetType(nsAString& aValue);
|
2013-03-28 23:41:32 +04:00
|
|
|
|
void SetType(const nsAString& aValue, ErrorResult& aRv)
|
|
|
|
|
{
|
|
|
|
|
SetHTMLAttr(nsGkAtoms::type, aValue, aRv);
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-14 06:46:13 +03:00
|
|
|
|
void GetDefaultValue(nsAString& aValue)
|
|
|
|
|
{
|
|
|
|
|
GetHTMLAttr(nsGkAtoms::value, aValue);
|
|
|
|
|
}
|
2013-03-28 23:41:32 +04:00
|
|
|
|
void SetDefaultValue(const nsAString& aValue, ErrorResult& aRv)
|
|
|
|
|
{
|
|
|
|
|
SetHTMLAttr(nsGkAtoms::value, aValue, aRv);
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-15 20:46:31 +03:00
|
|
|
|
void SetValue(const nsAString& aValue, CallerType aCallerType,
|
|
|
|
|
ErrorResult& aRv);
|
2016-11-15 20:46:32 +03:00
|
|
|
|
void GetValue(nsAString& aValue, CallerType aCallerType);
|
2013-03-28 23:41:32 +04:00
|
|
|
|
|
2013-05-02 22:38:20 +04:00
|
|
|
|
Nullable<Date> GetValueAsDate(ErrorResult& aRv);
|
2013-03-28 23:41:32 +04:00
|
|
|
|
|
2017-02-13 20:07:40 +03:00
|
|
|
|
void SetValueAsDate(const Nullable<Date>& aDate, ErrorResult& aRv);
|
2013-03-28 23:41:32 +04:00
|
|
|
|
|
|
|
|
|
double ValueAsNumber() const
|
|
|
|
|
{
|
2013-05-06 03:23:18 +04:00
|
|
|
|
return DoesValueAsNumberApply() ? GetValueAsDecimal().toDouble()
|
2014-02-27 19:23:16 +04:00
|
|
|
|
: UnspecifiedNaN<double>();
|
2013-03-28 23:41:32 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetValueAsNumber(double aValue, ErrorResult& aRv);
|
|
|
|
|
|
2017-11-13 18:36:53 +03:00
|
|
|
|
MOZ_CAN_RUN_SCRIPT uint32_t Width();
|
2013-03-28 23:41:32 +04:00
|
|
|
|
|
|
|
|
|
void SetWidth(uint32_t aValue, ErrorResult& aRv)
|
|
|
|
|
{
|
2016-05-05 21:29:54 +03:00
|
|
|
|
SetUnsignedIntAttr(nsGkAtoms::width, aValue, 0, aRv);
|
2013-03-28 23:41:32 +04:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-04 11:04:45 +04:00
|
|
|
|
void StepUp(int32_t aN, ErrorResult& aRv)
|
2013-03-28 23:41:32 +04:00
|
|
|
|
{
|
2013-04-04 11:04:45 +04:00
|
|
|
|
aRv = ApplyStep(aN);
|
2013-03-28 23:41:32 +04:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-04 11:04:45 +04:00
|
|
|
|
void StepDown(int32_t aN, ErrorResult& aRv)
|
2013-03-28 23:41:32 +04:00
|
|
|
|
{
|
2013-04-04 11:04:45 +04:00
|
|
|
|
aRv = ApplyStep(-aN);
|
2013-03-28 23:41:32 +04:00
|
|
|
|
}
|
|
|
|
|
|
2013-04-28 04:54:54 +04:00
|
|
|
|
/**
|
|
|
|
|
* Returns the current step value.
|
|
|
|
|
* Returns kStepAny if the current step is "any" string.
|
|
|
|
|
*
|
|
|
|
|
* @return the current step value.
|
|
|
|
|
*/
|
2013-05-06 03:23:18 +04:00
|
|
|
|
Decimal GetStep() const;
|
2013-04-28 04:54:54 +04:00
|
|
|
|
|
2017-06-16 03:04:00 +03:00
|
|
|
|
already_AddRefed<nsINodeList> GetLabels();
|
|
|
|
|
|
2017-07-14 06:46:13 +03:00
|
|
|
|
void Select();
|
2013-03-28 23:41:32 +04:00
|
|
|
|
|
2017-03-09 22:44:05 +03:00
|
|
|
|
Nullable<uint32_t> GetSelectionStart(ErrorResult& aRv);
|
|
|
|
|
void SetSelectionStart(const Nullable<uint32_t>& aValue, ErrorResult& aRv);
|
2013-03-28 23:41:32 +04:00
|
|
|
|
|
2017-03-09 22:44:05 +03:00
|
|
|
|
Nullable<uint32_t> GetSelectionEnd(ErrorResult& aRv);
|
|
|
|
|
void SetSelectionEnd(const Nullable<uint32_t>& aValue, ErrorResult& aRv);
|
2013-03-28 23:41:32 +04:00
|
|
|
|
|
|
|
|
|
void GetSelectionDirection(nsAString& aValue, ErrorResult& aRv);
|
|
|
|
|
void SetSelectionDirection(const nsAString& aValue, ErrorResult& aRv);
|
|
|
|
|
|
2017-03-09 22:44:06 +03:00
|
|
|
|
void SetSelectionRange(uint32_t aStart, uint32_t aEnd,
|
2013-03-28 23:41:32 +04:00
|
|
|
|
const Optional< nsAString >& direction,
|
|
|
|
|
ErrorResult& aRv);
|
|
|
|
|
|
2013-09-18 09:29:04 +04:00
|
|
|
|
void SetRangeText(const nsAString& aReplacement, ErrorResult& aRv);
|
|
|
|
|
|
|
|
|
|
void SetRangeText(const nsAString& aReplacement, uint32_t aStart,
|
2017-03-09 22:44:06 +03:00
|
|
|
|
uint32_t aEnd, SelectionMode aSelectMode,
|
|
|
|
|
ErrorResult& aRv);
|
2013-09-18 09:29:04 +04:00
|
|
|
|
|
2016-07-23 11:20:15 +03:00
|
|
|
|
bool Allowdirs() const
|
2015-07-10 20:55:52 +03:00
|
|
|
|
{
|
2016-07-23 11:20:15 +03:00
|
|
|
|
return HasAttr(kNameSpaceID_None, nsGkAtoms::allowdirs);
|
2015-07-10 20:55:52 +03:00
|
|
|
|
}
|
|
|
|
|
|
2016-07-23 11:20:15 +03:00
|
|
|
|
void SetAllowdirs(bool aValue, ErrorResult& aRv)
|
2015-07-10 20:55:52 +03:00
|
|
|
|
{
|
2016-07-23 11:20:15 +03:00
|
|
|
|
SetHTMLBoolAttr(nsGkAtoms::allowdirs, aValue, aRv);
|
2015-07-10 20:55:52 +03:00
|
|
|
|
}
|
|
|
|
|
|
2016-06-01 13:29:00 +03:00
|
|
|
|
bool WebkitDirectoryAttr() const
|
|
|
|
|
{
|
|
|
|
|
return HasAttr(kNameSpaceID_None, nsGkAtoms::webkitdirectory);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetWebkitDirectoryAttr(bool aValue, ErrorResult& aRv)
|
|
|
|
|
{
|
|
|
|
|
SetHTMLBoolAttr(nsGkAtoms::webkitdirectory, aValue, aRv);
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-18 10:17:25 +03:00
|
|
|
|
void GetWebkitEntries(nsTArray<RefPtr<FileSystemEntry>>& aSequence);
|
2016-06-07 01:55:16 +03:00
|
|
|
|
|
2015-07-10 20:55:52 +03:00
|
|
|
|
bool IsFilesAndDirectoriesSupported() const;
|
|
|
|
|
|
|
|
|
|
already_AddRefed<Promise> GetFilesAndDirectories(ErrorResult& aRv);
|
|
|
|
|
|
2016-05-31 13:54:24 +03:00
|
|
|
|
already_AddRefed<Promise> GetFiles(bool aRecursiveFlag, ErrorResult& aRv);
|
|
|
|
|
|
2015-07-10 20:55:52 +03:00
|
|
|
|
void ChooseDirectory(ErrorResult& aRv);
|
|
|
|
|
|
2017-07-14 06:46:13 +03:00
|
|
|
|
void GetAlign(nsAString& aValue)
|
|
|
|
|
{
|
|
|
|
|
GetHTMLAttr(nsGkAtoms::align, aValue);
|
|
|
|
|
}
|
2013-03-28 23:41:32 +04:00
|
|
|
|
void SetAlign(const nsAString& aValue, ErrorResult& aRv)
|
|
|
|
|
{
|
|
|
|
|
SetHTMLAttr(nsGkAtoms::align, aValue, aRv);
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-14 06:46:13 +03:00
|
|
|
|
void GetUseMap(nsAString& aValue)
|
|
|
|
|
{
|
|
|
|
|
GetHTMLAttr(nsGkAtoms::usemap, aValue);
|
|
|
|
|
}
|
2013-03-28 23:41:32 +04:00
|
|
|
|
void SetUseMap(const nsAString& aValue, ErrorResult& aRv)
|
|
|
|
|
{
|
|
|
|
|
SetHTMLAttr(nsGkAtoms::usemap, aValue, aRv);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nsIControllers* GetControllers(ErrorResult& aRv);
|
2018-02-21 01:10:44 +03:00
|
|
|
|
// XPCOM adapter function widely used throughout code, leaving it as is.
|
|
|
|
|
nsresult GetControllers(nsIControllers** aResult);
|
2013-03-28 23:41:32 +04:00
|
|
|
|
|
2016-11-15 20:46:32 +03:00
|
|
|
|
int32_t InputTextLength(CallerType aCallerType);
|
2013-03-28 23:41:32 +04:00
|
|
|
|
|
2015-05-18 16:51:54 +03:00
|
|
|
|
void MozGetFileNameArray(nsTArray<nsString>& aFileNames, ErrorResult& aRv);
|
2013-03-28 23:41:32 +04:00
|
|
|
|
|
2015-04-01 03:47:00 +03:00
|
|
|
|
void MozSetFileNameArray(const Sequence< nsString >& aFileNames, ErrorResult& aRv);
|
2015-01-27 03:22:59 +03:00
|
|
|
|
void MozSetFileArray(const Sequence<OwningNonNull<File>>& aFiles);
|
2016-03-20 13:56:11 +03:00
|
|
|
|
void MozSetDirectory(const nsAString& aDirectoryPath, ErrorResult& aRv);
|
2013-03-28 23:41:32 +04:00
|
|
|
|
|
2016-10-06 07:17:00 +03:00
|
|
|
|
/*
|
|
|
|
|
* The following functions are called from datetime picker to let input box
|
|
|
|
|
* know the current state of the picker or to update the input box on changes.
|
|
|
|
|
*/
|
|
|
|
|
void GetDateTimeInputBoxValue(DateTimeValue& aValue);
|
|
|
|
|
void UpdateDateTimeInputBox(const DateTimeValue& aValue);
|
|
|
|
|
void SetDateTimePickerState(bool aOpen);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* The following functions are called from datetime input box XBL to control
|
|
|
|
|
* and update the picker.
|
|
|
|
|
*/
|
|
|
|
|
void OpenDateTimePicker(const DateTimeValue& aInitialValue);
|
|
|
|
|
void UpdateDateTimePicker(const DateTimeValue& aValue);
|
|
|
|
|
void CloseDateTimePicker();
|
|
|
|
|
|
2017-04-05 10:02:30 +03:00
|
|
|
|
/*
|
|
|
|
|
* Called from datetime input box binding when inner text fields are focused
|
|
|
|
|
* or blurred.
|
|
|
|
|
*/
|
|
|
|
|
void SetFocusState(bool aIsFocused);
|
|
|
|
|
|
2017-06-19 08:13:00 +03:00
|
|
|
|
/*
|
|
|
|
|
* Called from datetime input box binding when the the user entered value
|
|
|
|
|
* becomes valid/invalid.
|
|
|
|
|
*/
|
|
|
|
|
void UpdateValidityState();
|
|
|
|
|
|
2017-06-29 18:47:00 +03:00
|
|
|
|
/*
|
|
|
|
|
* The following are called from datetime input box binding to get the
|
|
|
|
|
* corresponding computed values.
|
|
|
|
|
*/
|
|
|
|
|
double GetStepAsDouble() { return GetStep().toDouble(); }
|
|
|
|
|
double GetStepBaseAsDouble() { return GetStepBase().toDouble(); }
|
2017-07-14 09:16:36 +03:00
|
|
|
|
double GetMinimumAsDouble() { return GetMinimum().toDouble(); }
|
|
|
|
|
double GetMaximumAsDouble() { return GetMaximum().toDouble(); }
|
2017-06-29 18:47:00 +03:00
|
|
|
|
|
2013-11-20 13:32:45 +04:00
|
|
|
|
HTMLInputElement* GetOwnerNumberControl();
|
|
|
|
|
|
2013-12-01 17:49:10 +04:00
|
|
|
|
void StartNumberControlSpinnerSpin();
|
2016-05-16 21:42:24 +03:00
|
|
|
|
enum SpinnerStopState {
|
|
|
|
|
eAllowDispatchingEvents,
|
|
|
|
|
eDisallowDispatchingEvents
|
|
|
|
|
};
|
|
|
|
|
void StopNumberControlSpinnerSpin(SpinnerStopState aState =
|
|
|
|
|
eAllowDispatchingEvents);
|
2013-12-05 20:20:33 +04:00
|
|
|
|
void StepNumberControlForUserEvent(int32_t aDirection);
|
2013-12-01 17:49:10 +04:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The callback function used by the nsRepeatService that we use to spin the
|
|
|
|
|
* spinner for <input type=number>.
|
|
|
|
|
*/
|
|
|
|
|
static void HandleNumberControlSpin(void* aData);
|
|
|
|
|
|
2013-12-05 20:20:34 +04:00
|
|
|
|
bool NumberSpinnerUpButtonIsDepressed() const
|
|
|
|
|
{
|
|
|
|
|
return mNumberControlSpinnerIsSpinning && mNumberControlSpinnerSpinsUp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool NumberSpinnerDownButtonIsDepressed() const
|
|
|
|
|
{
|
|
|
|
|
return mNumberControlSpinnerIsSpinning && !mNumberControlSpinnerSpinsUp;
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-28 23:41:32 +04:00
|
|
|
|
bool MozIsTextField(bool aExcludePassword);
|
|
|
|
|
|
2017-06-22 09:21:31 +03:00
|
|
|
|
/**
|
|
|
|
|
* GetEditor() is for webidl bindings.
|
|
|
|
|
*/
|
2013-03-28 23:41:32 +04:00
|
|
|
|
nsIEditor* GetEditor();
|
|
|
|
|
|
2016-10-06 07:17:00 +03:00
|
|
|
|
void SetUserInput(const nsAString& aInput,
|
2016-10-11 04:07:48 +03:00
|
|
|
|
nsIPrincipal& aSubjectPrincipal);
|
2013-03-28 23:41:32 +04:00
|
|
|
|
|
2014-01-23 19:43:12 +04:00
|
|
|
|
/**
|
|
|
|
|
* If aValue contains a valid floating-point number in the format specified
|
|
|
|
|
* by the HTML 5 spec:
|
|
|
|
|
*
|
|
|
|
|
* http://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#floating-point-numbers
|
|
|
|
|
*
|
|
|
|
|
* then this function will return the number parsed as a Decimal, otherwise
|
|
|
|
|
* it will return a Decimal for which Decimal::isFinite() will return false.
|
|
|
|
|
*/
|
|
|
|
|
static Decimal StringToDecimal(const nsAString& aValue);
|
|
|
|
|
|
2016-07-29 14:41:38 +03:00
|
|
|
|
void UpdateEntries(const nsTArray<OwningFileOrDirectory>& aFilesOrDirectories);
|
|
|
|
|
|
2017-04-03 20:40:48 +03:00
|
|
|
|
static void Shutdown();
|
|
|
|
|
|
2017-08-03 08:23:00 +03:00
|
|
|
|
/**
|
2017-08-03 08:27:00 +03:00
|
|
|
|
* Returns if the required attribute applies for the current type.
|
|
|
|
|
*/
|
|
|
|
|
bool DoesRequiredApply() const;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the current required state of the element. This function differs
|
|
|
|
|
* from Required() in that this function only returns true for input types
|
|
|
|
|
* that @required attribute applies and the attribute is set; in contrast,
|
|
|
|
|
* Required() returns true whenever @required attribute is set.
|
2017-08-03 08:23:00 +03:00
|
|
|
|
*/
|
|
|
|
|
bool IsRequired() const
|
|
|
|
|
{
|
2017-08-03 08:27:00 +03:00
|
|
|
|
return State().HasState(NS_EVENT_STATE_REQUIRED);
|
2017-08-03 08:23:00 +03:00
|
|
|
|
}
|
|
|
|
|
|
2010-09-05 22:00:05 +04:00
|
|
|
|
protected:
|
2014-07-09 01:23:16 +04:00
|
|
|
|
virtual ~HTMLInputElement();
|
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
|
virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2013-03-28 23:41:32 +04:00
|
|
|
|
|
2010-09-05 22:00:05 +04:00
|
|
|
|
// Pull IsSingleLineTextControl into our scope, otherwise it'd be hidden
|
|
|
|
|
// by the nsITextControlElement version.
|
2013-08-02 05:21:31 +04:00
|
|
|
|
using nsGenericHTMLFormElementWithState::IsSingleLineTextControl;
|
2010-09-05 22:00:05 +04:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The ValueModeType specifies how the value IDL attribute should behave.
|
|
|
|
|
*
|
|
|
|
|
* See: http://dev.w3.org/html5/spec/forms.html#dom-input-value
|
|
|
|
|
*/
|
|
|
|
|
enum ValueModeType
|
|
|
|
|
{
|
|
|
|
|
// On getting, returns the value.
|
|
|
|
|
// On setting, sets value.
|
|
|
|
|
VALUE_MODE_VALUE,
|
|
|
|
|
// On getting, returns the value if present or the empty string.
|
|
|
|
|
// On setting, sets the value.
|
|
|
|
|
VALUE_MODE_DEFAULT,
|
|
|
|
|
// On getting, returns the value if present or "on".
|
|
|
|
|
// On setting, sets the value.
|
|
|
|
|
VALUE_MODE_DEFAULT_ON,
|
|
|
|
|
// On getting, returns "C:\fakepath\" followed by the file name of the
|
|
|
|
|
// first file of the selected files if any.
|
|
|
|
|
// On setting the empty string, empties the selected files list, otherwise
|
|
|
|
|
// throw the INVALID_STATE_ERR exception.
|
|
|
|
|
VALUE_MODE_FILENAME
|
|
|
|
|
};
|
|
|
|
|
|
2013-01-11 19:00:52 +04:00
|
|
|
|
/**
|
|
|
|
|
* This helper method convert a sub-string that contains only digits to a
|
|
|
|
|
* number (unsigned int given that it can't contain a minus sign).
|
|
|
|
|
* This method will return whether the sub-string is correctly formatted
|
|
|
|
|
* (ie. contains only digit) and it can be successfuly parsed to generate a
|
|
|
|
|
* number).
|
|
|
|
|
* If the method returns true, |aResult| will contained the parsed number.
|
|
|
|
|
*
|
|
|
|
|
* @param aValue the string on which the sub-string will be extracted and parsed.
|
|
|
|
|
* @param aStart the beginning of the sub-string in aValue.
|
|
|
|
|
* @param aLen the length of the sub-string.
|
|
|
|
|
* @param aResult the parsed number.
|
|
|
|
|
* @return whether the sub-string has been parsed successfully.
|
|
|
|
|
*/
|
|
|
|
|
static bool DigitSubStringToNumber(const nsAString& aValue, uint32_t aStart,
|
|
|
|
|
uint32_t aLen, uint32_t* aResult);
|
|
|
|
|
|
2010-09-05 22:00:05 +04:00
|
|
|
|
// Helper method
|
2015-06-18 17:56:20 +03:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Setting the value.
|
|
|
|
|
*
|
|
|
|
|
* @param aValue String to set.
|
2017-06-14 12:21:01 +03:00
|
|
|
|
* @param aOldValue Previous value before setting aValue.
|
|
|
|
|
If previous value is unknown, aOldValue can be nullptr.
|
2015-06-18 17:56:20 +03:00
|
|
|
|
* @param aFlags See nsTextEditorState::SetValueFlags.
|
|
|
|
|
*/
|
2017-06-14 12:21:01 +03:00
|
|
|
|
nsresult SetValueInternal(const nsAString& aValue,
|
|
|
|
|
const nsAString* aOldValue,
|
|
|
|
|
uint32_t aFlags);
|
|
|
|
|
|
|
|
|
|
nsresult SetValueInternal(const nsAString& aValue,
|
|
|
|
|
uint32_t aFlags)
|
|
|
|
|
{
|
|
|
|
|
return SetValueInternal(aValue, nullptr, aFlags);
|
|
|
|
|
}
|
2010-09-05 22:00:05 +04:00
|
|
|
|
|
2016-11-15 20:46:32 +03:00
|
|
|
|
// Generic getter for the value that doesn't do experimental control type
|
|
|
|
|
// sanitization.
|
|
|
|
|
void GetValueInternal(nsAString& aValue, CallerType aCallerType) const;
|
|
|
|
|
|
|
|
|
|
// A getter for callers that know we're not dealing with a file input, so they
|
|
|
|
|
// don't have to think about the caller type.
|
|
|
|
|
void GetNonFileValueInternal(nsAString& aValue) const;
|
2011-03-09 21:25:20 +03:00
|
|
|
|
|
2011-03-12 04:07:34 +03:00
|
|
|
|
/**
|
2016-11-15 20:46:32 +03:00
|
|
|
|
* Returns whether the current value is the empty string. This only makes
|
|
|
|
|
* sense for some input types; does NOT make sense for file inputs.
|
2011-03-12 04:07:34 +03:00
|
|
|
|
*
|
|
|
|
|
* @return whether the current value is the empty string.
|
|
|
|
|
*/
|
|
|
|
|
bool IsValueEmpty() const;
|
|
|
|
|
|
2018-01-17 20:30:59 +03:00
|
|
|
|
/**
|
|
|
|
|
* Returns whether the current placeholder value should be shown.
|
|
|
|
|
*/
|
|
|
|
|
bool ShouldShowPlaceholder() const;
|
|
|
|
|
|
2013-09-06 10:40:45 +04:00
|
|
|
|
void ClearFiles(bool aSetValueChanged);
|
2010-09-05 22:00:05 +04:00
|
|
|
|
|
2013-03-28 23:41:32 +04:00
|
|
|
|
void SetIndeterminateInternal(bool aValue,
|
|
|
|
|
bool aShouldInvalidate);
|
2010-09-05 22:00:05 +04:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Called when an attribute is about to be changed
|
|
|
|
|
*/
|
2017-10-03 01:05:19 +03:00
|
|
|
|
virtual nsresult BeforeSetAttr(int32_t aNameSpaceID, nsAtom* aName,
|
2017-03-16 21:50:41 +03:00
|
|
|
|
const nsAttrValueOrString* aValue,
|
2015-03-21 19:28:04 +03:00
|
|
|
|
bool aNotify) override;
|
2010-09-05 22:00:05 +04:00
|
|
|
|
/**
|
|
|
|
|
* Called when an attribute has just been changed
|
|
|
|
|
*/
|
2017-10-03 01:05:19 +03:00
|
|
|
|
virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
|
2017-05-19 00:09:01 +03:00
|
|
|
|
const nsAttrValue* aValue,
|
|
|
|
|
const nsAttrValue* aOldValue,
|
2017-10-10 00:33:38 +03:00
|
|
|
|
nsIPrincipal* aSubjectPrincipal,
|
2017-05-19 00:09:01 +03:00
|
|
|
|
bool aNotify) override;
|
2010-09-05 22:00:05 +04:00
|
|
|
|
|
2017-05-02 00:10:00 +03:00
|
|
|
|
virtual void BeforeSetForm(bool aBindToTree) override;
|
|
|
|
|
|
|
|
|
|
virtual void AfterClearForm(bool aUnbindOrDelete) override;
|
|
|
|
|
|
2010-09-05 22:00:05 +04:00
|
|
|
|
/**
|
|
|
|
|
* Dispatch a select event. Returns true if the event was not cancelled.
|
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
|
bool DispatchSelectEvent(nsPresContext* aPresContext);
|
2010-09-05 22:00:05 +04:00
|
|
|
|
|
|
|
|
|
void SelectAll(nsPresContext* aPresContext);
|
2011-09-29 10:19:26 +04:00
|
|
|
|
bool IsImage() const
|
2010-09-05 22:00:05 +04:00
|
|
|
|
{
|
|
|
|
|
return AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
|
|
|
|
nsGkAtoms::image, eIgnoreCase);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-10-23 02:55:04 +04:00
|
|
|
|
* Visit the group of radio buttons this radio belongs to
|
2010-09-05 22:00:05 +04:00
|
|
|
|
* @param aVisitor the visitor to visit with
|
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
|
nsresult VisitGroup(nsIRadioVisitor* aVisitor, bool aFlushContent);
|
2010-09-05 22:00:05 +04:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Do all the work that |SetChecked| does (radio button handling, etc.), but
|
|
|
|
|
* take an |aNotify| parameter.
|
|
|
|
|
*/
|
2012-08-03 14:38:52 +04:00
|
|
|
|
void DoSetChecked(bool aValue, bool aNotify, bool aSetValueChanged);
|
2010-09-05 22:00:05 +04:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Do all the work that |SetCheckedChanged| does (radio button handling,
|
|
|
|
|
* etc.), but take an |aNotify| parameter that lets it avoid flushing content
|
|
|
|
|
* when it can.
|
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
|
void DoSetCheckedChanged(bool aCheckedChanged, bool aNotify);
|
2010-09-05 22:00:05 +04:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Actually set checked and notify the frame of the change.
|
|
|
|
|
* @param aValue the value of checked to set
|
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
|
void SetCheckedInternal(bool aValue, bool aNotify);
|
2010-09-05 22:00:05 +04:00
|
|
|
|
|
2012-08-03 14:38:52 +04:00
|
|
|
|
void RadioSetChecked(bool aNotify);
|
2011-09-29 10:19:26 +04:00
|
|
|
|
void SetCheckedChanged(bool aCheckedChanged);
|
2010-09-05 22:00:05 +04:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* MaybeSubmitForm looks for a submit input or a single text control
|
|
|
|
|
* and submits the form if either is present.
|
|
|
|
|
*/
|
|
|
|
|
nsresult MaybeSubmitForm(nsPresContext* aPresContext);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Update mFileList with the currently selected file.
|
|
|
|
|
*/
|
2016-03-20 13:56:10 +03:00
|
|
|
|
void UpdateFileList();
|
2010-09-05 22:00:05 +04:00
|
|
|
|
|
2011-06-01 10:06:38 +04:00
|
|
|
|
/**
|
2016-03-20 13:56:10 +03:00
|
|
|
|
* Called after calling one of the SetFilesOrDirectories() functions.
|
2016-06-01 13:29:00 +03:00
|
|
|
|
* This method can explore the directory recursively if needed.
|
2011-06-01 10:06:38 +04:00
|
|
|
|
*/
|
2016-03-20 13:56:10 +03:00
|
|
|
|
void AfterSetFilesOrDirectories(bool aSetValueChanged);
|
2016-06-01 13:29:00 +03:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Recursively explore the directory and populate mFileOrDirectories correctly
|
|
|
|
|
* for webkitdirectory.
|
|
|
|
|
*/
|
|
|
|
|
void ExploreDirectoryRecursively(bool aSetValuechanged);
|
2011-06-01 10:06:38 +04:00
|
|
|
|
|
2010-09-05 22:00:05 +04:00
|
|
|
|
/**
|
|
|
|
|
* Determine whether the editor needs to be initialized explicitly for
|
|
|
|
|
* a particular event.
|
|
|
|
|
*/
|
2014-03-18 08:48:19 +04:00
|
|
|
|
bool NeedToInitializeEditorForEvent(EventChainPreVisitor& aVisitor) const;
|
2010-09-05 22:00:05 +04:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the value mode of the element, depending of the type.
|
|
|
|
|
*/
|
|
|
|
|
ValueModeType GetValueMode() const;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the mutable state of the element.
|
|
|
|
|
* When the element isn't mutable (immutable), the value or checkedness
|
|
|
|
|
* should not be changed by the user.
|
|
|
|
|
*
|
|
|
|
|
* See: http://dev.w3.org/html5/spec/forms.html#concept-input-mutable
|
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
|
bool IsMutable() const;
|
2010-09-05 22:00:05 +04:00
|
|
|
|
|
2012-06-22 13:36:24 +04:00
|
|
|
|
/**
|
|
|
|
|
* Returns if the min and max attributes apply for the current type.
|
|
|
|
|
*/
|
|
|
|
|
bool DoesMinMaxApply() const;
|
|
|
|
|
|
2012-06-22 23:02:20 +04:00
|
|
|
|
/**
|
|
|
|
|
* Returns if the step attribute apply for the current type.
|
|
|
|
|
*/
|
2017-02-07 17:03:00 +03:00
|
|
|
|
bool DoesStepApply() const { return DoesMinMaxApply(); }
|
2012-06-22 23:02:20 +04:00
|
|
|
|
|
2012-07-05 18:33:47 +04:00
|
|
|
|
/**
|
|
|
|
|
* Returns if stepDown and stepUp methods apply for the current type.
|
|
|
|
|
*/
|
|
|
|
|
bool DoStepDownStepUpApply() const { return DoesStepApply(); }
|
|
|
|
|
|
2012-07-05 14:13:41 +04:00
|
|
|
|
/**
|
|
|
|
|
* Returns if valueAsNumber attribute applies for the current type.
|
|
|
|
|
*/
|
2017-01-04 00:33:00 +03:00
|
|
|
|
bool DoesValueAsNumberApply() const { return DoesMinMaxApply(); }
|
2012-07-05 14:13:41 +04:00
|
|
|
|
|
2014-09-16 04:56:00 +04:00
|
|
|
|
/**
|
|
|
|
|
* Returns if autocomplete attribute applies for the current type.
|
|
|
|
|
*/
|
|
|
|
|
bool DoesAutocompleteApply() const;
|
|
|
|
|
|
2010-09-05 22:00:05 +04:00
|
|
|
|
void FreeData();
|
|
|
|
|
nsTextEditorState *GetEditorState() const;
|
|
|
|
|
|
2017-06-22 09:21:31 +03:00
|
|
|
|
mozilla::TextEditor* GetTextEditorFromState();
|
|
|
|
|
|
2010-09-05 22:00:05 +04:00
|
|
|
|
/**
|
|
|
|
|
* Manages the internal data storage across type changes.
|
|
|
|
|
*/
|
2017-03-16 21:50:42 +03:00
|
|
|
|
void HandleTypeChange(uint8_t aNewType, bool aNotify);
|
2010-09-05 22:00:05 +04:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sanitize the value of the element depending of its current type.
|
|
|
|
|
* See: http://www.whatwg.org/specs/web-apps/current-work/#value-sanitization-algorithm
|
|
|
|
|
*/
|
|
|
|
|
void SanitizeValue(nsAString& aValue);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns whether the placeholder attribute applies for the current type.
|
|
|
|
|
*/
|
2012-12-27 20:06:53 +04:00
|
|
|
|
bool PlaceholderApplies() const;
|
2010-09-05 22:00:05 +04:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set the current default value to the value of the input element.
|
2010-09-08 21:42:35 +04:00
|
|
|
|
* @note You should not call this method if GetValueMode() doesn't return
|
|
|
|
|
* VALUE_MODE_VALUE.
|
2010-09-05 22:00:05 +04:00
|
|
|
|
*/
|
|
|
|
|
nsresult SetDefaultValueAsValue();
|
|
|
|
|
|
2017-06-20 06:24:59 +03:00
|
|
|
|
void SetDirectionFromValue(bool aNotify);
|
2012-11-21 14:13:57 +04:00
|
|
|
|
|
2010-11-24 02:50:53 +03:00
|
|
|
|
/**
|
2011-01-20 14:05:29 +03:00
|
|
|
|
* Return if an element should have a specific validity UI
|
|
|
|
|
* (with :-moz-ui-invalid and :-moz-ui-valid pseudo-classes).
|
2010-11-24 02:50:53 +03:00
|
|
|
|
*
|
2012-11-28 07:15:36 +04:00
|
|
|
|
* @return Whether the element should have a validity UI.
|
2010-11-24 02:50:53 +03:00
|
|
|
|
*/
|
2011-01-20 14:05:29 +03:00
|
|
|
|
bool ShouldShowValidityUI() const {
|
2010-11-24 02:50:53 +03:00
|
|
|
|
/**
|
2011-01-20 14:05:29 +03:00
|
|
|
|
* Always show the validity UI if the form has already tried to be submitted
|
|
|
|
|
* but was invalid.
|
2010-11-24 02:50:53 +03:00
|
|
|
|
*
|
2011-01-20 14:05:29 +03:00
|
|
|
|
* Otherwise, show the validity UI if the element's value has been changed.
|
2010-11-24 02:50:53 +03:00
|
|
|
|
*/
|
2011-01-27 16:51:45 +03:00
|
|
|
|
if (mForm && mForm->HasEverTriedInvalidSubmit()) {
|
|
|
|
|
return true;
|
2010-12-18 02:26:24 +03:00
|
|
|
|
}
|
|
|
|
|
|
2010-11-24 02:56:24 +03:00
|
|
|
|
switch (GetValueMode()) {
|
|
|
|
|
case VALUE_MODE_DEFAULT:
|
2010-11-24 02:50:53 +03:00
|
|
|
|
return true;
|
|
|
|
|
case VALUE_MODE_DEFAULT_ON:
|
|
|
|
|
return GetCheckedChanged();
|
|
|
|
|
case VALUE_MODE_VALUE:
|
|
|
|
|
case VALUE_MODE_FILENAME:
|
2011-11-16 11:50:19 +04:00
|
|
|
|
return mValueChanged;
|
2010-11-24 02:50:53 +03:00
|
|
|
|
default:
|
|
|
|
|
NS_NOTREACHED("We should not be there: there are no other modes.");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-04 16:49:59 +04:00
|
|
|
|
/**
|
|
|
|
|
* Returns the radio group container if the element has one, null otherwise.
|
|
|
|
|
* The radio group container will be the form owner if there is one.
|
|
|
|
|
* The current document otherwise.
|
|
|
|
|
* @return the radio group container if the element has one, null otherwise.
|
|
|
|
|
*/
|
|
|
|
|
nsIRadioGroupContainer* GetRadioGroupContainer() const;
|
|
|
|
|
|
2013-05-23 17:02:23 +04:00
|
|
|
|
/**
|
|
|
|
|
* Parse a color string of the form #XXXXXX where X should be hexa characters
|
|
|
|
|
* @param the string to be parsed.
|
|
|
|
|
* @return whether the string is a valid simple color.
|
|
|
|
|
* Note : this function does not consider the empty string as valid.
|
|
|
|
|
*/
|
|
|
|
|
bool IsValidSimpleColor(const nsAString& aValue) const;
|
|
|
|
|
|
2016-07-06 02:59:00 +03:00
|
|
|
|
/**
|
2016-09-09 01:39:01 +03:00
|
|
|
|
* Parse a week string of the form yyyy-Www
|
|
|
|
|
* @param the string to be parsed.
|
|
|
|
|
* @return whether the string is a valid week.
|
|
|
|
|
* Note : this function does not consider the empty string as valid.
|
|
|
|
|
*/
|
|
|
|
|
bool IsValidWeek(const nsAString& aValue) const;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Parse a month string of the form yyyy-mm
|
2016-07-06 02:59:00 +03:00
|
|
|
|
* @param the string to be parsed.
|
|
|
|
|
* @return whether the string is a valid month.
|
|
|
|
|
* Note : this function does not consider the empty string as valid.
|
|
|
|
|
*/
|
|
|
|
|
bool IsValidMonth(const nsAString& aValue) const;
|
|
|
|
|
|
2012-12-27 22:48:13 +04:00
|
|
|
|
/**
|
|
|
|
|
* Parse a date string of the form yyyy-mm-dd
|
|
|
|
|
* @param the string to be parsed.
|
|
|
|
|
* @return whether the string is a valid date.
|
|
|
|
|
* Note : this function does not consider the empty string as valid.
|
|
|
|
|
*/
|
2013-01-11 19:02:58 +04:00
|
|
|
|
bool IsValidDate(const nsAString& aValue) const;
|
2012-12-27 22:48:13 +04:00
|
|
|
|
|
2016-11-10 07:48:00 +03:00
|
|
|
|
/**
|
|
|
|
|
* Parse a datetime-local string of the form yyyy-mm-ddThh:mm[:ss.s] or
|
|
|
|
|
* yyyy-mm-dd hh:mm[:ss.s], where fractions of seconds can be 1 to 3 digits.
|
|
|
|
|
*
|
|
|
|
|
* @param the string to be parsed.
|
|
|
|
|
* @return whether the string is a valid datetime-local string.
|
|
|
|
|
* Note : this function does not consider the empty string as valid.
|
|
|
|
|
*/
|
|
|
|
|
bool IsValidDateTimeLocal(const nsAString& aValue) const;
|
|
|
|
|
|
2016-07-06 02:59:00 +03:00
|
|
|
|
/**
|
|
|
|
|
* Parse a year string of the form yyyy
|
|
|
|
|
*
|
|
|
|
|
* @param the string to be parsed.
|
|
|
|
|
*
|
|
|
|
|
* @return the year in aYear.
|
|
|
|
|
* @return whether the parsing was successful.
|
|
|
|
|
*/
|
|
|
|
|
bool ParseYear(const nsAString& aValue, uint32_t* aYear) const;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Parse a month string of the form yyyy-mm
|
|
|
|
|
*
|
|
|
|
|
* @param the string to be parsed.
|
|
|
|
|
* @return the year and month in aYear and aMonth.
|
|
|
|
|
* @return whether the parsing was successful.
|
|
|
|
|
*/
|
|
|
|
|
bool ParseMonth(const nsAString& aValue,
|
|
|
|
|
uint32_t* aYear,
|
|
|
|
|
uint32_t* aMonth) const;
|
|
|
|
|
|
2016-09-09 01:39:01 +03:00
|
|
|
|
/**
|
|
|
|
|
* Parse a week string of the form yyyy-Www
|
|
|
|
|
*
|
|
|
|
|
* @param the string to be parsed.
|
|
|
|
|
* @return the year and week in aYear and aWeek.
|
|
|
|
|
* @return whether the parsing was successful.
|
|
|
|
|
*/
|
|
|
|
|
bool ParseWeek(const nsAString& aValue,
|
|
|
|
|
uint32_t* aYear,
|
|
|
|
|
uint32_t* aWeek) const;
|
2012-12-27 22:55:31 +04:00
|
|
|
|
/**
|
|
|
|
|
* Parse a date string of the form yyyy-mm-dd
|
2016-07-06 02:59:00 +03:00
|
|
|
|
*
|
2012-12-27 22:55:31 +04:00
|
|
|
|
* @param the string to be parsed.
|
|
|
|
|
* @return the date in aYear, aMonth, aDay.
|
|
|
|
|
* @return whether the parsing was successful.
|
|
|
|
|
*/
|
2016-07-06 02:59:00 +03:00
|
|
|
|
bool ParseDate(const nsAString& aValue,
|
|
|
|
|
uint32_t* aYear,
|
|
|
|
|
uint32_t* aMonth,
|
|
|
|
|
uint32_t* aDay) const;
|
2012-12-27 22:55:31 +04:00
|
|
|
|
|
2016-11-10 07:48:00 +03:00
|
|
|
|
/**
|
|
|
|
|
* Parse a datetime-local string of the form yyyy-mm-ddThh:mm[:ss.s] or
|
|
|
|
|
* yyyy-mm-dd hh:mm[:ss.s], where fractions of seconds can be 1 to 3 digits.
|
|
|
|
|
*
|
|
|
|
|
* @param the string to be parsed.
|
|
|
|
|
* @return the date in aYear, aMonth, aDay and time expressed in milliseconds
|
|
|
|
|
* in aTime.
|
|
|
|
|
* @return whether the parsing was successful.
|
|
|
|
|
*/
|
|
|
|
|
bool ParseDateTimeLocal(const nsAString& aValue,
|
|
|
|
|
uint32_t* aYear,
|
|
|
|
|
uint32_t* aMonth,
|
|
|
|
|
uint32_t* aDay,
|
|
|
|
|
uint32_t* aTime) const;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Normalize the datetime-local string following the HTML specifications:
|
|
|
|
|
* https://html.spec.whatwg.org/multipage/infrastructure.html#valid-normalised-local-date-and-time-string
|
|
|
|
|
*/
|
|
|
|
|
void NormalizeDateTimeLocal(nsAString& aValue) const;
|
2017-01-04 00:33:00 +03:00
|
|
|
|
|
2016-09-29 02:08:00 +03:00
|
|
|
|
/**
|
|
|
|
|
* This methods returns the number of days since epoch for a given year and
|
|
|
|
|
* week.
|
|
|
|
|
*/
|
|
|
|
|
double DaysSinceEpochFromWeek(uint32_t aYear, uint32_t aWeek) const;
|
|
|
|
|
|
2012-12-27 22:48:13 +04:00
|
|
|
|
/**
|
|
|
|
|
* This methods returns the number of days in a given month, for a given year.
|
|
|
|
|
*/
|
|
|
|
|
uint32_t NumberOfDaysInMonth(uint32_t aMonth, uint32_t aYear) const;
|
|
|
|
|
|
2016-07-11 02:00:00 +03:00
|
|
|
|
/**
|
|
|
|
|
* This methods returns the number of months between January 1970 and the
|
|
|
|
|
* given year and month.
|
|
|
|
|
*/
|
|
|
|
|
int32_t MonthsSinceJan1970(uint32_t aYear, uint32_t aMonth) const;
|
|
|
|
|
|
2016-09-09 01:39:01 +03:00
|
|
|
|
/**
|
2016-09-29 02:08:00 +03:00
|
|
|
|
* This methods returns the day of the week given a date. If @isoWeek is true,
|
|
|
|
|
* 7=Sunday, otherwise, 0=Sunday.
|
2016-09-09 01:39:01 +03:00
|
|
|
|
*/
|
2016-09-29 02:08:00 +03:00
|
|
|
|
uint32_t DayOfWeek(uint32_t aYear, uint32_t aMonth, uint32_t aDay,
|
|
|
|
|
bool isoWeek) const;
|
2016-09-09 01:39:01 +03:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This methods returns the maximum number of week in a given year, the
|
|
|
|
|
* result is either 52 or 53.
|
|
|
|
|
*/
|
|
|
|
|
uint32_t MaximumWeekInYear(uint32_t aYear) const;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This methods returns true if it's a leap year.
|
|
|
|
|
*/
|
|
|
|
|
bool IsLeapYear(uint32_t aYear) const;
|
|
|
|
|
|
2013-01-11 19:00:52 +04:00
|
|
|
|
/**
|
|
|
|
|
* Returns whether aValue is a valid time as described by HTML specifications:
|
|
|
|
|
* http://www.whatwg.org/specs/web-apps/current-work/multipage/common-microsyntaxes.html#valid-time-string
|
|
|
|
|
*
|
|
|
|
|
* @param aValue the string to be tested.
|
|
|
|
|
* @return Whether the string is a valid time per HTML specifications.
|
|
|
|
|
*/
|
|
|
|
|
bool IsValidTime(const nsAString& aValue) const;
|
|
|
|
|
|
2013-01-22 22:22:33 +04:00
|
|
|
|
/**
|
|
|
|
|
* Returns the time expressed in milliseconds of |aValue| being parsed as a
|
|
|
|
|
* time following the HTML specifications:
|
|
|
|
|
* http://www.whatwg.org/specs/web-apps/current-work/#parse-a-time-string
|
|
|
|
|
*
|
|
|
|
|
* Note: |aResult| can be null.
|
|
|
|
|
*
|
|
|
|
|
* @param aValue the string to be parsed.
|
|
|
|
|
* @param aResult the time expressed in milliseconds representing the time [out]
|
|
|
|
|
* @return Whether the parsing was successful.
|
|
|
|
|
*/
|
|
|
|
|
static bool ParseTime(const nsAString& aValue, uint32_t* aResult);
|
|
|
|
|
|
2012-07-05 18:33:47 +04:00
|
|
|
|
/**
|
2013-05-06 03:23:18 +04:00
|
|
|
|
* Sets the value of the element to the string representation of the Decimal.
|
2012-07-05 18:33:47 +04:00
|
|
|
|
*
|
2013-05-06 03:23:18 +04:00
|
|
|
|
* @param aValue The Decimal that will be used to set the value.
|
2012-07-05 18:33:47 +04:00
|
|
|
|
*/
|
2016-11-15 20:46:31 +03:00
|
|
|
|
void SetValue(Decimal aValue, CallerType aCallerType);
|
2012-07-05 18:33:47 +04:00
|
|
|
|
|
2012-06-22 13:41:32 +04:00
|
|
|
|
/**
|
|
|
|
|
* Update the HAS_RANGE bit field value.
|
|
|
|
|
*/
|
|
|
|
|
void UpdateHasRange();
|
|
|
|
|
|
2012-12-22 18:46:19 +04:00
|
|
|
|
/**
|
|
|
|
|
* Get the step scale value for the current type.
|
|
|
|
|
* See:
|
|
|
|
|
* http://www.whatwg.org/specs/web-apps/current-work/multipage/common-input-element-attributes.html#concept-input-step-scale
|
|
|
|
|
*/
|
2013-05-06 03:23:18 +04:00
|
|
|
|
Decimal GetStepScaleFactor() const;
|
2012-12-22 18:46:19 +04:00
|
|
|
|
|
2012-07-05 18:33:47 +04:00
|
|
|
|
/**
|
|
|
|
|
* Return the base used to compute if a value matches step.
|
|
|
|
|
* Basically, it's the min attribute if present and a default value otherwise.
|
|
|
|
|
*
|
|
|
|
|
* @return The step base.
|
|
|
|
|
*/
|
2013-05-06 03:23:18 +04:00
|
|
|
|
Decimal GetStepBase() const;
|
2012-07-05 18:33:47 +04:00
|
|
|
|
|
2013-02-07 02:56:49 +04:00
|
|
|
|
/**
|
|
|
|
|
* Returns the default step for the current type.
|
|
|
|
|
* @return the default step for the current type.
|
|
|
|
|
*/
|
2013-05-06 03:23:18 +04:00
|
|
|
|
Decimal GetDefaultStep() const;
|
2013-02-07 02:56:49 +04:00
|
|
|
|
|
2014-01-15 21:22:16 +04:00
|
|
|
|
enum StepCallerType {
|
|
|
|
|
CALLED_FOR_USER_EVENT,
|
|
|
|
|
CALLED_FOR_SCRIPT
|
|
|
|
|
};
|
|
|
|
|
|
2013-12-05 20:20:33 +04:00
|
|
|
|
/**
|
|
|
|
|
* Sets the aValue outparam to the value that this input would take if
|
|
|
|
|
* someone tries to step aStep steps and this input's value would change as
|
|
|
|
|
* a result. Leaves aValue untouched if this inputs value would not change
|
|
|
|
|
* (e.g. already at max, and asking for the next step up).
|
|
|
|
|
*
|
|
|
|
|
* Negative aStep means step down, positive means step up.
|
|
|
|
|
*
|
|
|
|
|
* Returns NS_OK or else the error values that should be thrown if this call
|
|
|
|
|
* was initiated by a stepUp()/stepDown() call from script under conditions
|
|
|
|
|
* that such a call should throw.
|
|
|
|
|
*/
|
2014-01-15 21:22:16 +04:00
|
|
|
|
nsresult GetValueIfStepped(int32_t aStepCount,
|
|
|
|
|
StepCallerType aCallerType,
|
|
|
|
|
Decimal* aNextStep);
|
2013-12-05 20:20:33 +04:00
|
|
|
|
|
2012-07-05 18:33:47 +04:00
|
|
|
|
/**
|
|
|
|
|
* Apply a step change from stepUp or stepDown by multiplying aStep by the
|
|
|
|
|
* current step value.
|
|
|
|
|
*
|
|
|
|
|
* @param aStep The value used to be multiplied against the step value.
|
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
|
nsresult ApplyStep(int32_t aStep);
|
2012-07-05 18:33:47 +04:00
|
|
|
|
|
2013-02-01 03:01:50 +04:00
|
|
|
|
/**
|
|
|
|
|
* Returns if the current type is an experimental mobile type.
|
|
|
|
|
*/
|
2016-06-20 16:55:00 +03:00
|
|
|
|
static bool IsExperimentalMobileType(uint8_t aType);
|
2013-02-01 03:01:50 +04:00
|
|
|
|
|
2016-07-04 00:19:00 +03:00
|
|
|
|
/*
|
|
|
|
|
* Returns if the current type is one of the date/time input types: date,
|
|
|
|
|
* time and month. TODO: week and datetime-local.
|
|
|
|
|
*/
|
|
|
|
|
static bool IsDateTimeInputType(uint8_t aType);
|
|
|
|
|
|
2013-09-04 14:30:36 +04:00
|
|
|
|
/**
|
|
|
|
|
* Flushes the layout frame tree to make sure we have up-to-date frames.
|
|
|
|
|
*/
|
|
|
|
|
void FlushFrames();
|
|
|
|
|
|
2013-03-27 15:32:00 +04:00
|
|
|
|
/**
|
|
|
|
|
* Returns true if the element should prevent dispatching another DOMActivate.
|
|
|
|
|
* This is used in situations where the anonymous subtree should already have
|
|
|
|
|
* sent a DOMActivate and prevents firing more than once.
|
|
|
|
|
*/
|
2013-04-20 02:18:33 +04:00
|
|
|
|
bool ShouldPreventDOMActivateDispatch(EventTarget* aOriginalTarget);
|
2013-03-27 15:32:00 +04:00
|
|
|
|
|
2013-08-02 15:40:49 +04:00
|
|
|
|
/**
|
|
|
|
|
* Some input type (color and file) let user choose a value using a picker:
|
|
|
|
|
* this function checks if it is needed, and if so, open the corresponding
|
|
|
|
|
* picker (color picker or file picker).
|
|
|
|
|
*/
|
2014-03-18 08:48:20 +04:00
|
|
|
|
nsresult MaybeInitPickers(EventChainPostVisitor& aVisitor);
|
2013-08-02 15:40:49 +04:00
|
|
|
|
|
2013-08-22 13:43:26 +04:00
|
|
|
|
enum FilePickerType {
|
|
|
|
|
FILE_PICKER_FILE,
|
|
|
|
|
FILE_PICKER_DIRECTORY
|
|
|
|
|
};
|
|
|
|
|
nsresult InitFilePicker(FilePickerType aType);
|
2013-08-02 15:40:49 +04:00
|
|
|
|
nsresult InitColorPicker();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Use this function before trying to open a picker.
|
|
|
|
|
* It checks if the page is allowed to open a new pop-up.
|
|
|
|
|
* If it returns true, you should not create the picker.
|
|
|
|
|
*
|
|
|
|
|
* @return true if popup should be blocked, false otherwise
|
|
|
|
|
*/
|
|
|
|
|
bool IsPopupBlocked() const;
|
|
|
|
|
|
2016-06-01 13:29:00 +03:00
|
|
|
|
GetFilesHelper* GetOrCreateGetFilesHelper(bool aRecursiveFlag,
|
|
|
|
|
ErrorResult& aRv);
|
|
|
|
|
|
2016-05-31 13:54:24 +03:00
|
|
|
|
void ClearGetFilesHelpers();
|
|
|
|
|
|
2016-05-06 13:39:10 +03:00
|
|
|
|
/**
|
2017-11-17 06:07:12 +03:00
|
|
|
|
* nsINode::SetMayBeApzAware() will be invoked in this function if necessary
|
2016-05-06 13:39:10 +03:00
|
|
|
|
* to prevent default action of APZC so that we can increase/decrease the
|
|
|
|
|
* value of this InputElement when mouse wheel event comes without scrolling
|
|
|
|
|
* the page.
|
|
|
|
|
*
|
|
|
|
|
* SetMayBeApzAware() will set flag MayBeApzAware which is checked by apzc to
|
|
|
|
|
* decide whether to add this element into its dispatch-to-content region.
|
|
|
|
|
*/
|
|
|
|
|
void UpdateApzAwareFlag();
|
|
|
|
|
|
2017-03-09 22:44:06 +03:00
|
|
|
|
/**
|
|
|
|
|
* A helper to get the current selection range. Will throw on the ErrorResult
|
|
|
|
|
* if we have no editor state.
|
|
|
|
|
*/
|
2017-03-09 22:44:45 +03:00
|
|
|
|
void GetSelectionRange(uint32_t* aSelectionStart,
|
|
|
|
|
uint32_t* aSelectionEnd,
|
2017-03-09 22:44:06 +03:00
|
|
|
|
ErrorResult& aRv);
|
|
|
|
|
|
2017-03-17 00:43:34 +03:00
|
|
|
|
/**
|
|
|
|
|
* Override for nsImageLoadingContent.
|
|
|
|
|
*/
|
|
|
|
|
nsIContent* AsContent() override { return this; }
|
|
|
|
|
|
2010-09-05 22:00:05 +04:00
|
|
|
|
nsCOMPtr<nsIControllers> mControllers;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* In mInputData, the mState field is used if IsSingleLineTextControl returns
|
|
|
|
|
* true and mValue is used otherwise. We have to be careful when handling it
|
|
|
|
|
* on a type change.
|
|
|
|
|
*
|
|
|
|
|
* Accessing the mState member should be done using the GetEditorState function,
|
|
|
|
|
* which returns null if the state is not present.
|
|
|
|
|
*/
|
|
|
|
|
union InputData {
|
|
|
|
|
/**
|
|
|
|
|
* The current value of the input if it has been changed from the default
|
|
|
|
|
*/
|
2014-01-04 19:02:17 +04:00
|
|
|
|
char16_t* mValue;
|
2010-09-05 22:00:05 +04:00
|
|
|
|
/**
|
|
|
|
|
* The state of the text editor associated with the text/password input
|
|
|
|
|
*/
|
|
|
|
|
nsTextEditorState* mState;
|
|
|
|
|
} mInputData;
|
2015-03-27 23:12:37 +03:00
|
|
|
|
|
2017-04-26 09:36:00 +03:00
|
|
|
|
struct FileData;
|
|
|
|
|
UniquePtr<FileData> mFileData;
|
2016-04-12 14:02:42 +03:00
|
|
|
|
|
|
|
|
|
/**
|
2012-05-07 20:27:24 +04:00
|
|
|
|
* The value of the input element when first initialized and it is updated
|
2016-04-12 14:02:42 +03:00
|
|
|
|
* when the element is either changed through a script, focused or dispatches
|
2012-05-07 20:27:24 +04:00
|
|
|
|
* a change event. This is to ensure correct future change event firing.
|
|
|
|
|
* NB: This is ONLY applicable where the element is a text control. ie,
|
|
|
|
|
* where type= "text", "email", "search", "tel", "url" or "password".
|
|
|
|
|
*/
|
2016-04-12 14:02:42 +03:00
|
|
|
|
nsString mFocusedValue;
|
2011-11-16 11:50:19 +04:00
|
|
|
|
|
2013-03-08 13:40:12 +04:00
|
|
|
|
/**
|
|
|
|
|
* If mIsDraggingRange is true, this is the value that the input had before
|
|
|
|
|
* the drag started. Used to reset the input to its old value if the drag is
|
|
|
|
|
* canceled.
|
|
|
|
|
*/
|
2013-05-06 03:23:18 +04:00
|
|
|
|
Decimal mRangeThumbDragStartValue;
|
2013-03-08 13:40:12 +04:00
|
|
|
|
|
2016-10-06 07:17:00 +03:00
|
|
|
|
/**
|
|
|
|
|
* Current value in the input box, in DateTimeValue dictionary format, see
|
|
|
|
|
* HTMLInputElement.webidl for details.
|
|
|
|
|
*/
|
|
|
|
|
nsAutoPtr<DateTimeValue> mDateTimeInputBoxValue;
|
|
|
|
|
|
2014-08-01 04:25:31 +04:00
|
|
|
|
/**
|
|
|
|
|
* The selection properties cache for number controls. This is needed because
|
|
|
|
|
* the number controls don't recycle their text field, so the normal cache in
|
|
|
|
|
* nsTextEditorState cannot do its job.
|
|
|
|
|
*/
|
|
|
|
|
nsTextEditorState::SelectionProperties mSelectionProperties;
|
|
|
|
|
|
2017-10-06 02:19:19 +03:00
|
|
|
|
/**
|
|
|
|
|
* The triggering principal for the src attribute.
|
|
|
|
|
*/
|
|
|
|
|
nsCOMPtr<nsIPrincipal> mSrcTriggeringPrincipal;
|
|
|
|
|
|
2017-05-04 06:43:46 +03:00
|
|
|
|
/*
|
|
|
|
|
* InputType object created based on input type.
|
|
|
|
|
*/
|
|
|
|
|
UniquePtr<InputType, DoNotDelete> mInputType;
|
|
|
|
|
|
|
|
|
|
// Memory allocated for mInputType, reused when type changes.
|
|
|
|
|
char mInputTypeMem[INPUT_TYPE_SIZE];
|
|
|
|
|
|
2012-12-22 18:46:19 +04:00
|
|
|
|
// Step scale factor values, for input types that have one.
|
2013-05-06 03:23:18 +04:00
|
|
|
|
static const Decimal kStepScaleFactorDate;
|
|
|
|
|
static const Decimal kStepScaleFactorNumberRange;
|
|
|
|
|
static const Decimal kStepScaleFactorTime;
|
2016-08-03 03:54:00 +03:00
|
|
|
|
static const Decimal kStepScaleFactorMonth;
|
2016-10-07 10:04:54 +03:00
|
|
|
|
static const Decimal kStepScaleFactorWeek;
|
2012-12-22 18:46:19 +04:00
|
|
|
|
|
2012-06-22 23:02:20 +04:00
|
|
|
|
// Default step base value when a type do not have specific one.
|
2013-05-06 03:23:18 +04:00
|
|
|
|
static const Decimal kDefaultStepBase;
|
2016-10-07 10:04:54 +03:00
|
|
|
|
// Default step base value when type=week does not not have a specific one,
|
|
|
|
|
// which is −259200000, the start of week 1970-W01.
|
|
|
|
|
static const Decimal kDefaultStepBaseWeek;
|
2013-02-07 02:56:49 +04:00
|
|
|
|
|
|
|
|
|
// Default step used when there is no specified step.
|
2013-05-06 03:23:18 +04:00
|
|
|
|
static const Decimal kDefaultStep;
|
|
|
|
|
static const Decimal kDefaultStepTime;
|
2013-02-07 02:56:49 +04:00
|
|
|
|
|
|
|
|
|
// Float value returned by GetStep() when the step attribute is set to 'any'.
|
2013-05-06 03:23:18 +04:00
|
|
|
|
static const Decimal kStepAny;
|
2012-06-22 23:02:20 +04:00
|
|
|
|
|
2016-07-11 02:00:00 +03:00
|
|
|
|
// Minimum year limited by HTML standard, year >= 1.
|
|
|
|
|
static const double kMinimumYear;
|
2016-09-29 02:08:00 +03:00
|
|
|
|
// Maximum year limited by ECMAScript date object range, year <= 275760.
|
|
|
|
|
static const double kMaximumYear;
|
|
|
|
|
// Maximum valid week is 275760-W37.
|
|
|
|
|
static const double kMaximumWeekInMaximumYear;
|
|
|
|
|
// Maximum valid day is 275760-09-13.
|
|
|
|
|
static const double kMaximumDayInMaximumYear;
|
|
|
|
|
// Maximum valid month is 275760-09.
|
|
|
|
|
static const double kMaximumMonthInMaximumYear;
|
2016-09-09 01:39:01 +03:00
|
|
|
|
// Long years in a ISO calendar have 53 weeks in them.
|
|
|
|
|
static const double kMaximumWeekInYear;
|
2016-09-29 02:08:00 +03:00
|
|
|
|
// Milliseconds in a day.
|
|
|
|
|
static const double kMsPerDay;
|
|
|
|
|
|
2014-06-06 11:25:02 +04:00
|
|
|
|
nsContentUtils::AutocompleteAttrState mAutocompleteAttrState;
|
2017-05-10 05:57:00 +03:00
|
|
|
|
nsContentUtils::AutocompleteAttrState mAutocompleteInfoState;
|
2011-11-16 11:50:19 +04:00
|
|
|
|
bool mDisabledChanged : 1;
|
|
|
|
|
bool mValueChanged : 1;
|
2016-08-06 18:59:08 +03:00
|
|
|
|
bool mLastValueChangeWasInteractive : 1;
|
2011-11-16 11:50:19 +04:00
|
|
|
|
bool mCheckedChanged : 1;
|
|
|
|
|
bool mChecked : 1;
|
|
|
|
|
bool mHandlingSelectEvent : 1;
|
|
|
|
|
bool mShouldInitChecked : 1;
|
2016-10-27 17:17:04 +03:00
|
|
|
|
bool mDoneCreating : 1;
|
2011-11-16 11:50:19 +04:00
|
|
|
|
bool mInInternalActivate : 1;
|
|
|
|
|
bool mCheckedIsToggled : 1;
|
|
|
|
|
bool mIndeterminate : 1;
|
|
|
|
|
bool mInhibitRestoration : 1;
|
|
|
|
|
bool mCanShowValidUI : 1;
|
|
|
|
|
bool mCanShowInvalidUI : 1;
|
2012-06-22 13:41:32 +04:00
|
|
|
|
bool mHasRange : 1;
|
2013-03-08 13:40:12 +04:00
|
|
|
|
bool mIsDraggingRange : 1;
|
2013-12-01 17:49:10 +04:00
|
|
|
|
bool mNumberControlSpinnerIsSpinning : 1;
|
|
|
|
|
bool mNumberControlSpinnerSpinsUp : 1;
|
2013-12-07 16:09:14 +04:00
|
|
|
|
bool mPickerRunning : 1;
|
2014-08-01 04:25:31 +04:00
|
|
|
|
bool mSelectionCached : 1;
|
2017-03-22 11:55:56 +03:00
|
|
|
|
bool mIsPreviewEnabled : 1;
|
2017-08-18 06:57:00 +03:00
|
|
|
|
bool mHasPatternAttribute : 1;
|
2012-06-06 16:16:58 +04:00
|
|
|
|
|
|
|
|
|
private:
|
2013-11-19 23:21:29 +04:00
|
|
|
|
static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
2017-01-27 00:39:13 +03:00
|
|
|
|
GenericSpecifiedValues* aGenericData);
|
2013-03-16 09:49:41 +04:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns true if this input's type will fire a DOM "change" event when it
|
|
|
|
|
* loses focus if its value has changed since it gained focus.
|
|
|
|
|
*/
|
|
|
|
|
bool MayFireChangeOnBlur() const {
|
|
|
|
|
return MayFireChangeOnBlur(mType);
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-18 09:29:04 +04:00
|
|
|
|
/**
|
2016-08-09 00:19:00 +03:00
|
|
|
|
* Returns true if selection methods can be called on element
|
2013-09-18 09:29:04 +04:00
|
|
|
|
*/
|
2016-08-09 00:19:00 +03:00
|
|
|
|
bool SupportsTextSelection() const {
|
2013-09-18 09:29:04 +04:00
|
|
|
|
return mType == NS_FORM_INPUT_TEXT || mType == NS_FORM_INPUT_SEARCH ||
|
|
|
|
|
mType == NS_FORM_INPUT_URL || mType == NS_FORM_INPUT_TEL ||
|
2016-08-10 21:29:00 +03:00
|
|
|
|
mType == NS_FORM_INPUT_PASSWORD;
|
2013-09-18 09:29:04 +04:00
|
|
|
|
}
|
|
|
|
|
|
2013-03-16 09:49:41 +04:00
|
|
|
|
static bool MayFireChangeOnBlur(uint8_t aType) {
|
|
|
|
|
return IsSingleLineTextControl(false, aType) ||
|
2013-09-04 14:30:36 +04:00
|
|
|
|
aType == NS_FORM_INPUT_RANGE ||
|
2016-10-06 07:17:00 +03:00
|
|
|
|
aType == NS_FORM_INPUT_NUMBER ||
|
2017-06-12 03:21:00 +03:00
|
|
|
|
aType == NS_FORM_INPUT_TIME ||
|
|
|
|
|
aType == NS_FORM_INPUT_DATE;
|
2013-03-16 09:49:41 +04:00
|
|
|
|
}
|
|
|
|
|
|
2017-02-23 08:27:00 +03:00
|
|
|
|
/**
|
|
|
|
|
* Checks if aDateTimeInputType should be supported based on "dom.forms.datetime",
|
2017-03-17 06:01:57 +03:00
|
|
|
|
* and "dom.experimental_forms".
|
2017-02-23 08:27:00 +03:00
|
|
|
|
*/
|
|
|
|
|
static bool
|
|
|
|
|
IsDateTimeTypeSupported(uint8_t aDateTimeInputType);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Checks preference "dom.webkitBlink.filesystem.enabled" to determine if
|
|
|
|
|
* webkitEntries should be supported.
|
|
|
|
|
*/
|
|
|
|
|
static bool
|
|
|
|
|
IsWebkitFileSystemEnabled();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Checks preference "dom.input.dirpicker" to determine if file and directory
|
|
|
|
|
* entries API should be supported.
|
|
|
|
|
*/
|
|
|
|
|
static bool
|
|
|
|
|
IsDirPickerEnabled();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Checks preference "dom.experimental_forms" to determine if experimental
|
|
|
|
|
* implementation of input element should be enabled.
|
|
|
|
|
*/
|
|
|
|
|
static bool
|
|
|
|
|
IsExperimentalFormsEnabled();
|
|
|
|
|
|
|
|
|
|
/**
|
2017-03-17 06:01:59 +03:00
|
|
|
|
* Checks preference "dom.forms.datetime" to determine if input date and time
|
|
|
|
|
* should be supported.
|
2017-02-23 08:27:00 +03:00
|
|
|
|
*/
|
|
|
|
|
static bool
|
|
|
|
|
IsInputDateTimeEnabled();
|
|
|
|
|
|
2017-03-17 06:01:59 +03:00
|
|
|
|
/**
|
|
|
|
|
* Checks preference "dom.forms.datetime.others" to determine if input week,
|
|
|
|
|
* month and datetime-local should be supported.
|
|
|
|
|
*/
|
|
|
|
|
static bool
|
|
|
|
|
IsInputDateTimeOthersEnabled();
|
|
|
|
|
|
2017-02-23 08:27:00 +03:00
|
|
|
|
/**
|
|
|
|
|
* Checks preference "dom.forms.number" to determine if input type=number
|
|
|
|
|
* should be supported.
|
|
|
|
|
*/
|
|
|
|
|
static bool
|
|
|
|
|
IsInputNumberEnabled();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Checks preference "dom.forms.color" to determine if date/time related
|
|
|
|
|
* types should be supported.
|
|
|
|
|
*/
|
|
|
|
|
static bool
|
|
|
|
|
IsInputColorEnabled();
|
|
|
|
|
|
2012-06-06 16:16:58 +04:00
|
|
|
|
struct nsFilePickerFilter {
|
|
|
|
|
nsFilePickerFilter()
|
2014-10-29 02:32:28 +03:00
|
|
|
|
: mFilterMask(0) {}
|
2012-06-06 16:16:58 +04:00
|
|
|
|
|
2014-09-02 04:49:25 +04:00
|
|
|
|
explicit nsFilePickerFilter(int32_t aFilterMask)
|
2014-10-29 02:32:28 +03:00
|
|
|
|
: mFilterMask(aFilterMask) {}
|
2012-06-06 16:16:58 +04:00
|
|
|
|
|
|
|
|
|
nsFilePickerFilter(const nsString& aTitle,
|
2014-10-29 02:32:28 +03:00
|
|
|
|
const nsString& aFilter)
|
|
|
|
|
: mFilterMask(0), mTitle(aTitle), mFilter(aFilter) {}
|
2012-06-06 16:16:58 +04:00
|
|
|
|
|
|
|
|
|
nsFilePickerFilter(const nsFilePickerFilter& other) {
|
|
|
|
|
mFilterMask = other.mFilterMask;
|
|
|
|
|
mTitle = other.mTitle;
|
|
|
|
|
mFilter = other.mFilter;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool operator== (const nsFilePickerFilter& other) const {
|
|
|
|
|
if ((mFilter == other.mFilter) && (mFilterMask == other.mFilterMask)) {
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-04-12 14:02:42 +03:00
|
|
|
|
|
2012-06-06 16:16:58 +04:00
|
|
|
|
// Filter mask, using values defined in nsIFilePicker
|
2012-08-22 19:56:38 +04:00
|
|
|
|
int32_t mFilterMask;
|
2012-06-06 16:16:58 +04:00
|
|
|
|
// If mFilterMask is defined, mTitle and mFilter are useless and should be
|
|
|
|
|
// ignored
|
|
|
|
|
nsString mTitle;
|
|
|
|
|
nsString mFilter;
|
|
|
|
|
};
|
2012-08-17 19:35:01 +04:00
|
|
|
|
|
|
|
|
|
class nsFilePickerShownCallback
|
|
|
|
|
: public nsIFilePickerShownCallback
|
|
|
|
|
{
|
|
|
|
|
virtual ~nsFilePickerShownCallback()
|
|
|
|
|
{ }
|
|
|
|
|
|
2014-06-25 06:09:15 +04:00
|
|
|
|
public:
|
|
|
|
|
nsFilePickerShownCallback(HTMLInputElement* aInput,
|
|
|
|
|
nsIFilePicker* aFilePicker);
|
2012-08-17 19:35:01 +04:00
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
|
NS_IMETHOD Done(int16_t aResult) override;
|
2012-08-17 19:35:01 +04:00
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
nsCOMPtr<nsIFilePicker> mFilePicker;
|
2015-10-18 08:24:48 +03:00
|
|
|
|
RefPtr<HTMLInputElement> mInput;
|
2012-08-17 19:35:01 +04:00
|
|
|
|
};
|
2017-04-03 20:40:48 +03:00
|
|
|
|
|
|
|
|
|
static void ReleaseTextEditorState(nsTextEditorState* aState);
|
|
|
|
|
|
|
|
|
|
static nsTextEditorState* sCachedTextEditorState;
|
|
|
|
|
static bool sShutdown;
|
2010-09-05 22:00:05 +04:00
|
|
|
|
};
|
|
|
|
|
|
2013-03-28 23:41:32 +04:00
|
|
|
|
} // namespace dom
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
2010-09-05 22:00:05 +04:00
|
|
|
|
#endif
|