2010-09-05 11:00:05 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07: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 11:00:05 -07:00
|
|
|
|
|
|
|
#ifndef nsHTMLInputElement_h__
|
|
|
|
#define nsHTMLInputElement_h__
|
|
|
|
|
|
|
|
#include "nsGenericHTMLElement.h"
|
|
|
|
#include "nsImageLoadingContent.h"
|
|
|
|
#include "nsIDOMHTMLInputElement.h"
|
|
|
|
#include "nsITextControlElement.h"
|
|
|
|
#include "nsIPhonetic.h"
|
|
|
|
#include "nsIDOMNSEditableElement.h"
|
|
|
|
#include "nsTextEditorState.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIConstraintValidation.h"
|
|
|
|
#include "nsDOMFile.h"
|
2010-11-23 15:50:53 -08:00
|
|
|
#include "nsHTMLFormElement.h" // for ShouldShowInvalidUI()
|
2011-04-11 11:31:00 -07:00
|
|
|
#include "nsIFile.h"
|
2012-08-17 08:35:01 -07:00
|
|
|
#include "nsIFilePicker.h"
|
2010-09-05 11:00:05 -07:00
|
|
|
|
|
|
|
class nsDOMFileList;
|
2012-06-06 05:16:58 -07:00
|
|
|
class nsIFilePicker;
|
2010-09-05 11:00:05 -07:00
|
|
|
class nsIRadioGroupContainer;
|
|
|
|
class nsIRadioGroupVisitor;
|
|
|
|
class nsIRadioVisitor;
|
|
|
|
|
2012-02-15 07:42:34 -08:00
|
|
|
class UploadLastDir MOZ_FINAL : public nsIObserver, public nsSupportsWeakReference {
|
2010-08-27 08:49:06 -07:00
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIOBSERVER
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fetch the last used directory for this location from the content
|
|
|
|
* pref service, if it is available.
|
|
|
|
*
|
2012-06-30 07:50:07 -07:00
|
|
|
* @param aDoc current document
|
2010-08-27 08:49:06 -07:00
|
|
|
* @param aFile path to the last used directory
|
|
|
|
*/
|
2012-06-30 07:50:07 -07:00
|
|
|
nsresult FetchLastUsedDirectory(nsIDocument* aDoc, nsIFile** aFile);
|
2010-08-27 08:49:06 -07: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
|
|
|
|
* @param aFile file chosen by the user - the path to the parent of this
|
|
|
|
* file will be stored
|
|
|
|
*/
|
2012-06-30 07:50:07 -07:00
|
|
|
nsresult StoreLastUsedDirectory(nsIDocument* aDoc, nsIFile* aFile);
|
2010-09-05 11:00:05 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
class nsHTMLInputElement : public nsGenericHTMLFormElement,
|
|
|
|
public nsImageLoadingContent,
|
|
|
|
public nsIDOMHTMLInputElement,
|
|
|
|
public nsITextControlElement,
|
|
|
|
public nsIPhonetic,
|
|
|
|
public nsIDOMNSEditableElement,
|
|
|
|
public nsIConstraintValidation
|
|
|
|
{
|
|
|
|
public:
|
2010-09-02 13:12:47 -07:00
|
|
|
using nsIConstraintValidation::GetValidationMessage;
|
|
|
|
|
2010-09-05 11:00:05 -07:00
|
|
|
nsHTMLInputElement(already_AddRefed<nsINodeInfo> aNodeInfo,
|
2010-10-25 05:17:38 -07:00
|
|
|
mozilla::dom::FromParser aFromParser);
|
2010-09-05 11:00:05 -07:00
|
|
|
virtual ~nsHTMLInputElement();
|
|
|
|
|
2012-09-26 07:17:51 -07:00
|
|
|
NS_IMPL_FROMCONTENT_HTML_WITH_TAG(nsHTMLInputElement, input)
|
|
|
|
|
2010-09-05 11:00:05 -07:00
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
|
|
|
// nsIDOMNode
|
2012-10-09 05:31:24 -07:00
|
|
|
NS_FORWARD_NSIDOMNODE_TO_NSINODE
|
2010-09-05 11:00:05 -07:00
|
|
|
|
|
|
|
// nsIDOMElement
|
2012-10-16 04:51:00 -07:00
|
|
|
NS_FORWARD_NSIDOMELEMENT_TO_GENERIC
|
2010-09-05 11:00:05 -07:00
|
|
|
|
2011-10-29 13:03:55 -07:00
|
|
|
// nsIDOMHTMLElement
|
2012-11-10 15:30:15 -08:00
|
|
|
NS_FORWARD_NSIDOMHTMLELEMENT_TO_GENERIC
|
|
|
|
|
2012-10-06 00:19:52 -07:00
|
|
|
virtual void Click() MOZ_OVERRIDE;
|
2012-10-06 00:19:51 -07:00
|
|
|
virtual int32_t TabIndexDefault() MOZ_OVERRIDE;
|
2012-10-06 00:19:52 -07:00
|
|
|
virtual void Focus(mozilla::ErrorResult& aError) MOZ_OVERRIDE;
|
2011-10-29 13:03:55 -07:00
|
|
|
|
2010-09-05 11:00:05 -07:00
|
|
|
// nsIDOMHTMLInputElement
|
|
|
|
NS_DECL_NSIDOMHTMLINPUTELEMENT
|
|
|
|
|
|
|
|
// nsIPhonetic
|
|
|
|
NS_DECL_NSIPHONETIC
|
|
|
|
|
|
|
|
// nsIDOMNSEditableElement
|
|
|
|
NS_IMETHOD GetEditor(nsIEditor** aEditor)
|
|
|
|
{
|
|
|
|
return nsGenericHTMLElement::GetEditor(aEditor);
|
|
|
|
}
|
2011-05-31 23:06:38 -07:00
|
|
|
|
2010-09-05 11:00:05 -07:00
|
|
|
NS_IMETHOD SetUserInput(const nsAString& aInput);
|
|
|
|
|
|
|
|
// Overriden nsIFormControl methods
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD_(uint32_t) GetType() const { return mType; }
|
2010-09-05 11:00:05 -07:00
|
|
|
NS_IMETHOD Reset();
|
|
|
|
NS_IMETHOD SubmitNamesValues(nsFormSubmission* aFormSubmission);
|
|
|
|
NS_IMETHOD SaveState();
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual bool RestoreState(nsPresState* aState);
|
|
|
|
virtual bool AllowDrop();
|
2013-01-03 07:17:36 -08:00
|
|
|
virtual bool IsDisabledForEvents(uint32_t aMessage);
|
2010-09-05 11:00:05 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
virtual void FieldSetDisabledChanged(bool aNotify);
|
2010-09-18 14:33:16 -07:00
|
|
|
|
2010-09-05 11:00:05 -07:00
|
|
|
// nsIContent
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual bool IsHTMLFocusable(bool aWithMouse, bool *aIsFocusable, int32_t *aTabIndex);
|
2010-09-05 11:00:05 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual bool ParseAttribute(int32_t aNamespaceID,
|
2010-09-05 11:00:05 -07:00
|
|
|
nsIAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
|
|
|
nsAttrValue& aResult);
|
|
|
|
virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aModType) const;
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const;
|
2010-09-05 11:00:05 -07:00
|
|
|
virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
|
|
|
|
|
|
|
|
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
|
|
|
|
virtual nsresult PostHandleEvent(nsEventChainPostVisitor& aVisitor);
|
2013-03-08 01:40:12 -08:00
|
|
|
void PostHandleEventForRangeThumb(nsEventChainPostVisitor& aVisitor);
|
|
|
|
void StartRangeThumbDrag(nsGUIEvent* aEvent);
|
|
|
|
void FinishRangeThumbDrag(nsGUIEvent* aEvent = nullptr);
|
|
|
|
void CancelRangeThumbDrag();
|
|
|
|
void SetValueOfRangeForUserEvent(double aValue);
|
2010-09-05 11:00:05 -07:00
|
|
|
|
|
|
|
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|
|
|
nsIContent* aBindingParent,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aCompileEventHandlers);
|
|
|
|
virtual void UnbindFromTree(bool aDeep = true,
|
|
|
|
bool aNullParent = true);
|
2010-09-05 11:00:05 -07:00
|
|
|
|
|
|
|
virtual void DoneCreatingElement();
|
|
|
|
|
2010-10-20 04:26:32 -07:00
|
|
|
virtual nsEventStates IntrinsicState() const;
|
2010-09-05 11:00:05 -07:00
|
|
|
|
|
|
|
// nsITextControlElement
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD SetValueChanged(bool aValueChanged);
|
|
|
|
NS_IMETHOD_(bool) IsSingleLineTextControl() const;
|
|
|
|
NS_IMETHOD_(bool) IsTextArea() const;
|
|
|
|
NS_IMETHOD_(bool) IsPlainTextControl() const;
|
|
|
|
NS_IMETHOD_(bool) IsPasswordTextControl() const;
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD_(int32_t) GetCols();
|
|
|
|
NS_IMETHOD_(int32_t) GetWrapCols();
|
|
|
|
NS_IMETHOD_(int32_t) GetRows();
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD_(bool) ValueChanged() const;
|
|
|
|
NS_IMETHOD_(void) GetTextEditorValue(nsAString& aValue, bool aIgnoreWrap) const;
|
2010-09-05 11:00:05 -07:00
|
|
|
NS_IMETHOD_(nsIEditor*) GetTextEditor();
|
|
|
|
NS_IMETHOD_(nsISelectionController*) GetSelectionController();
|
|
|
|
NS_IMETHOD_(nsFrameSelection*) GetConstFrameSelection();
|
|
|
|
NS_IMETHOD BindToFrame(nsTextControlFrame* aFrame);
|
|
|
|
NS_IMETHOD_(void) UnbindFromFrame(nsTextControlFrame* aFrame);
|
|
|
|
NS_IMETHOD CreateEditor();
|
|
|
|
NS_IMETHOD_(nsIContent*) GetRootEditorNode();
|
2010-10-19 06:11:07 -07:00
|
|
|
NS_IMETHOD_(nsIContent*) CreatePlaceholderNode();
|
2010-09-05 11:00:05 -07:00
|
|
|
NS_IMETHOD_(nsIContent*) GetPlaceholderNode();
|
2012-11-09 02:31:34 -08:00
|
|
|
NS_IMETHOD_(void) UpdatePlaceholderVisibility(bool aNotify);
|
2012-11-09 02:22:29 -08:00
|
|
|
NS_IMETHOD_(bool) GetPlaceholderVisibility();
|
2010-09-05 11:00:05 -07:00
|
|
|
NS_IMETHOD_(void) InitializeKeyboardEventListeners();
|
2011-09-28 23:19:26 -07:00
|
|
|
NS_IMETHOD_(void) OnValueChanged(bool aNotify);
|
|
|
|
NS_IMETHOD_(bool) HasCachedSelection();
|
2010-09-05 11:00:05 -07:00
|
|
|
|
|
|
|
void GetDisplayFileName(nsAString& aFileName) const;
|
2011-03-09 10:25:20 -08:00
|
|
|
const nsCOMArray<nsIDOMFile>& GetFiles() const;
|
2010-11-23 15:45:53 -08:00
|
|
|
void SetFiles(const nsCOMArray<nsIDOMFile>& aFiles, bool aSetValueChanged);
|
2011-05-31 23:06:38 -07:00
|
|
|
void SetFiles(nsIDOMFileList* aFiles, bool aSetValueChanged);
|
2010-09-05 11:00:05 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
void SetCheckedChangedInternal(bool aCheckedChanged);
|
|
|
|
bool GetCheckedChanged() const {
|
2011-11-15 23:50:19 -08:00
|
|
|
return mCheckedChanged;
|
2010-11-23 15:53:06 -08:00
|
|
|
}
|
2010-11-23 15:53:39 -08:00
|
|
|
void AddedToRadioGroup();
|
2010-11-11 04:34:27 -08:00
|
|
|
void WillRemoveFromRadioGroup();
|
2010-09-05 11:00:05 -07: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).
|
|
|
|
*/
|
|
|
|
already_AddRefed<nsIDOMHTMLInputElement> GetSelectedRadioButton();
|
|
|
|
|
|
|
|
virtual nsresult Clone(nsINodeInfo *aNodeInfo, nsINode **aResult) const;
|
|
|
|
|
|
|
|
NS_IMETHOD FireAsyncClickHandler();
|
2011-10-25 19:32:55 -07:00
|
|
|
|
2011-06-21 14:12:50 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsHTMLInputElement,
|
|
|
|
nsGenericHTMLFormElement)
|
2010-09-05 11:00:05 -07:00
|
|
|
|
|
|
|
static UploadLastDir* gUploadLastDir;
|
2010-08-27 08:49:06 -07: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 11:00:05 -07:00
|
|
|
static void DestroyUploadLastDir();
|
|
|
|
|
|
|
|
void MaybeLoadImage();
|
|
|
|
|
|
|
|
virtual nsXPCClassInfo* GetClassInfo();
|
|
|
|
|
2012-04-25 06:47:30 -07:00
|
|
|
virtual nsIDOMNode* AsDOMNode() { return this; }
|
|
|
|
|
2010-09-05 11:00:05 -07:00
|
|
|
// nsIConstraintValidation
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsTooLong();
|
|
|
|
bool IsValueMissing() const;
|
|
|
|
bool HasTypeMismatch() const;
|
|
|
|
bool HasPatternMismatch() const;
|
2012-06-22 02:36:24 -07:00
|
|
|
bool IsRangeOverflow() const;
|
2012-06-22 02:38:20 -07:00
|
|
|
bool IsRangeUnderflow() const;
|
2012-06-22 12:02:20 -07:00
|
|
|
bool HasStepMismatch() const;
|
2010-09-05 11:00:05 -07:00
|
|
|
void UpdateTooLongValidityState();
|
|
|
|
void UpdateValueMissingValidityState();
|
|
|
|
void UpdateTypeMismatchValidityState();
|
|
|
|
void UpdatePatternMismatchValidityState();
|
2012-06-22 02:36:24 -07:00
|
|
|
void UpdateRangeOverflowValidityState();
|
2012-06-22 02:38:20 -07:00
|
|
|
void UpdateRangeUnderflowValidityState();
|
2012-06-22 12:02:20 -07:00
|
|
|
void UpdateStepMismatchValidityState();
|
2011-09-28 23:19:26 -07:00
|
|
|
void UpdateAllValidityStates(bool aNotify);
|
2010-09-09 22:08:56 -07:00
|
|
|
void UpdateBarredFromConstraintValidation();
|
2010-09-05 11:00:05 -07:00
|
|
|
nsresult GetValidationMessage(nsAString& aValidationMessage,
|
|
|
|
ValidityStateType aType);
|
2010-12-16 11:51:59 -08: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-27 19:15:36 -08:00
|
|
|
* @note This method shouldn't be called if the radio element hasn't a group.
|
2010-12-16 11:51:59 -08:00
|
|
|
*/
|
|
|
|
void UpdateValueMissingValidityStateForRadio(bool aIgnoreSelf);
|
2010-09-05 11:00:05 -07:00
|
|
|
|
2012-06-06 05:16:58 -07: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
|
|
|
|
* filter specifed or not.
|
|
|
|
* @note If there is only one valid filter that is audio or video or image,
|
|
|
|
* it will be selected as the default filter. Otherwise "All files" remains
|
|
|
|
* the default filter.
|
|
|
|
* @note If more than one valid filter is found, the "All Supported Types"
|
|
|
|
* filter is added, which is the concatenation of all valid filters.
|
|
|
|
*/
|
|
|
|
void SetFilePickerFiltersFromAccept(nsIFilePicker* filePicker);
|
|
|
|
|
2010-10-08 03:07:20 -07:00
|
|
|
/**
|
|
|
|
* Returns the filter which should be used for the file picker according to
|
|
|
|
* the accept attribute value.
|
|
|
|
*
|
|
|
|
* See:
|
|
|
|
* http://dev.w3.org/html5/spec/forms.html#attr-input-accept
|
|
|
|
*
|
2010-10-08 03:13:08 -07:00
|
|
|
* @return Filter to use on the file picker with AppendFilters, 0 if none.
|
2010-10-08 03:07:20 -07:00
|
|
|
*
|
|
|
|
* @note You should not call this function if the element has no @accept.
|
2010-10-08 03:13:08 -07:00
|
|
|
* @note This will only filter for one type of file. If more than one filter
|
|
|
|
* is specified by the accept attribute they will *all* be ignored.
|
2010-10-08 03:07:20 -07:00
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t GetFilterFromAccept();
|
2010-10-08 03:07:20 -07:00
|
|
|
|
2011-01-20 03:02:37 -08: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);
|
|
|
|
|
2011-11-15 23:50:19 -08:00
|
|
|
bool DefaultChecked() const {
|
|
|
|
return HasAttr(kNameSpaceID_None, nsGkAtoms::checked);
|
2012-06-03 04:36:51 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Indeterminate() const { return mIndeterminate; }
|
|
|
|
bool Checked() const { return mChecked; }
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Fires change event if mFocusedValue and current value held are unequal.
|
2012-05-07 09:27:24 -07:00
|
|
|
*/
|
|
|
|
void FireChangeEventIfNeeded();
|
2011-11-15 23:50:19 -08:00
|
|
|
|
2013-02-16 09:57:21 -08:00
|
|
|
/**
|
|
|
|
* Returns the input element's value as a double-precision float.
|
|
|
|
* Returns NaN if the current element's value is not a floating point number.
|
|
|
|
*
|
|
|
|
* @return the input element's value as a double-precision float.
|
|
|
|
*/
|
|
|
|
double GetValueAsDouble() const;
|
|
|
|
|
2013-02-16 09:57:21 -08: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.
|
|
|
|
*/
|
|
|
|
double GetMinimum() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
double GetMaximum() const;
|
|
|
|
|
2010-09-05 11:00:05 -07:00
|
|
|
protected:
|
|
|
|
// Pull IsSingleLineTextControl into our scope, otherwise it'd be hidden
|
|
|
|
// by the nsITextControlElement version.
|
|
|
|
using nsGenericHTMLFormElement::IsSingleLineTextControl;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This helper method returns true if aValue is a valid email address.
|
|
|
|
* This is following the HTML5 specification:
|
|
|
|
* http://dev.w3.org/html5/spec/forms.html#valid-e-mail-address
|
|
|
|
*
|
|
|
|
* @param aValue the email address to check.
|
|
|
|
* @result whether the given string is a valid email address.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool IsValidEmailAddress(const nsAString& aValue);
|
2010-09-05 11:00:05 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This helper method returns true if aValue is a valid email address list.
|
|
|
|
* Email address list is a list of email address separated by comas (,) which
|
|
|
|
* can be surrounded by space charecters.
|
|
|
|
* This is following the HTML5 specification:
|
|
|
|
* http://dev.w3.org/html5/spec/forms.html#valid-e-mail-address-list
|
|
|
|
*
|
|
|
|
* @param aValue the email address list to check.
|
|
|
|
* @result whether the given string is a valid email address list.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
static bool IsValidEmailAddressList(const nsAString& aValue);
|
2010-09-05 11:00:05 -07:00
|
|
|
|
2013-01-11 07:00:52 -08: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 11:00:05 -07:00
|
|
|
// Helper method
|
|
|
|
nsresult SetValueInternal(const nsAString& aValue,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aUserInput,
|
|
|
|
bool aSetValueChanged);
|
2010-09-05 11:00:05 -07:00
|
|
|
|
2011-03-09 10:25:20 -08:00
|
|
|
nsresult GetValueInternal(nsAString& aValue) const;
|
|
|
|
|
2011-03-11 17:07:34 -08:00
|
|
|
/**
|
|
|
|
* Returns whether the current value is the empty string.
|
|
|
|
*
|
|
|
|
* @return whether the current value is the empty string.
|
|
|
|
*/
|
|
|
|
bool IsValueEmpty() const;
|
|
|
|
|
2010-11-23 15:45:53 -08:00
|
|
|
void ClearFiles(bool aSetValueChanged) {
|
2010-09-05 11:00:05 -07:00
|
|
|
nsCOMArray<nsIDOMFile> files;
|
2010-11-23 15:45:53 -08:00
|
|
|
SetFiles(files, aSetValueChanged);
|
2010-09-05 11:00:05 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
nsresult SetIndeterminateInternal(bool aValue,
|
|
|
|
bool aShouldInvalidate);
|
2010-09-05 11:00:05 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
nsresult GetSelectionRange(int32_t* aSelectionStart, int32_t* aSelectionEnd);
|
2010-09-05 11:00:05 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when an attribute is about to be changed
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual nsresult BeforeSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
2012-02-13 18:00:56 -08:00
|
|
|
const nsAttrValueOrString* aValue,
|
|
|
|
bool aNotify);
|
2010-09-05 11:00:05 -07:00
|
|
|
/**
|
|
|
|
* Called when an attribute has just been changed
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
2012-02-13 18:00:56 -08:00
|
|
|
const nsAttrValue* aValue, bool aNotify);
|
2010-09-05 11:00:05 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Dispatch a select event. Returns true if the event was not cancelled.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool DispatchSelectEvent(nsPresContext* aPresContext);
|
2010-09-05 11:00:05 -07:00
|
|
|
|
|
|
|
void SelectAll(nsPresContext* aPresContext);
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsImage() const
|
2010-09-05 11:00:05 -07:00
|
|
|
{
|
|
|
|
return AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
|
|
|
nsGkAtoms::image, eIgnoreCase);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-10-22 15:55:04 -07:00
|
|
|
* Visit the group of radio buttons this radio belongs to
|
2010-09-05 11:00:05 -07:00
|
|
|
* @param aVisitor the visitor to visit with
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
nsresult VisitGroup(nsIRadioVisitor* aVisitor, bool aFlushContent);
|
2010-09-05 11:00:05 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Do all the work that |SetChecked| does (radio button handling, etc.), but
|
|
|
|
* take an |aNotify| parameter.
|
|
|
|
*/
|
2012-08-03 03:38:52 -07:00
|
|
|
void DoSetChecked(bool aValue, bool aNotify, bool aSetValueChanged);
|
2010-09-05 11:00:05 -07: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-28 23:19:26 -07:00
|
|
|
void DoSetCheckedChanged(bool aCheckedChanged, bool aNotify);
|
2010-09-05 11:00:05 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Actually set checked and notify the frame of the change.
|
|
|
|
* @param aValue the value of checked to set
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
void SetCheckedInternal(bool aValue, bool aNotify);
|
2010-09-05 11:00:05 -07:00
|
|
|
|
2012-08-03 03:38:52 -07:00
|
|
|
void RadioSetChecked(bool aNotify);
|
2011-09-28 23:19:26 -07:00
|
|
|
void SetCheckedChanged(bool aCheckedChanged);
|
2010-09-05 11:00:05 -07: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.
|
|
|
|
*/
|
|
|
|
nsresult UpdateFileList();
|
|
|
|
|
2011-05-31 23:06:38 -07:00
|
|
|
/**
|
|
|
|
* Called after calling one of the SetFiles() functions.
|
|
|
|
*/
|
|
|
|
void AfterSetFiles(bool aSetValueChanged);
|
|
|
|
|
2010-09-05 11:00:05 -07:00
|
|
|
/**
|
|
|
|
* Determine whether the editor needs to be initialized explicitly for
|
|
|
|
* a particular event.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool NeedToInitializeEditorForEvent(nsEventChainPreVisitor& aVisitor) const;
|
2010-09-05 11:00:05 -07: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-28 23:19:26 -07:00
|
|
|
bool IsMutable() const;
|
2010-09-05 11:00:05 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns if the readonly attribute applies for the current type.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool DoesReadOnlyApply() const;
|
2010-09-05 11:00:05 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns if the required attribute applies for the current type.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool DoesRequiredApply() const;
|
2010-09-05 11:00:05 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns if the pattern attribute applies for the current type.
|
|
|
|
*/
|
2011-09-28 23:19:26 -07:00
|
|
|
bool DoesPatternApply() const;
|
2010-09-05 11:00:05 -07:00
|
|
|
|
2012-06-22 02:36:24 -07:00
|
|
|
/**
|
|
|
|
* Returns if the min and max attributes apply for the current type.
|
|
|
|
*/
|
|
|
|
bool DoesMinMaxApply() const;
|
|
|
|
|
2012-06-22 12:02:20 -07:00
|
|
|
/**
|
|
|
|
* Returns if the step attribute apply for the current type.
|
|
|
|
*/
|
2013-02-06 14:56:49 -08:00
|
|
|
bool DoesStepApply() const { return DoesMinMaxApply(); }
|
2012-06-22 12:02:20 -07:00
|
|
|
|
2012-07-05 07:33:47 -07:00
|
|
|
/**
|
|
|
|
* Returns if stepDown and stepUp methods apply for the current type.
|
|
|
|
*/
|
|
|
|
bool DoStepDownStepUpApply() const { return DoesStepApply(); }
|
|
|
|
|
2012-07-05 03:13:41 -07:00
|
|
|
/**
|
|
|
|
* Returns if valueAsNumber attribute applies for the current type.
|
|
|
|
*/
|
2013-01-31 15:00:08 -08:00
|
|
|
bool DoesValueAsNumberApply() const { return DoesMinMaxApply(); }
|
2012-07-05 03:13:41 -07:00
|
|
|
|
2010-10-07 03:01:53 -07:00
|
|
|
/**
|
|
|
|
* Returns if the maxlength attribute applies for the current type.
|
|
|
|
*/
|
2011-03-24 09:06:58 -07:00
|
|
|
bool MaxLengthApplies() const { return IsSingleLineTextControl(false, mType); }
|
2010-10-07 03:01:53 -07:00
|
|
|
|
2010-09-05 11:00:05 -07:00
|
|
|
void FreeData();
|
|
|
|
nsTextEditorState *GetEditorState() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Manages the internal data storage across type changes.
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
void HandleTypeChange(uint8_t aNewType);
|
2010-09-05 11:00:05 -07: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 08:06:53 -08:00
|
|
|
bool PlaceholderApplies() const;
|
2010-09-05 11:00:05 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the current default value to the value of the input element.
|
2010-09-08 10:42:35 -07:00
|
|
|
* @note You should not call this method if GetValueMode() doesn't return
|
|
|
|
* VALUE_MODE_VALUE.
|
2010-09-05 11:00:05 -07:00
|
|
|
*/
|
|
|
|
nsresult SetDefaultValueAsValue();
|
|
|
|
|
2012-11-21 02:13:57 -08:00
|
|
|
virtual void SetDirectionIfAuto(bool aAuto, bool aNotify);
|
|
|
|
|
2010-11-23 15:50:53 -08:00
|
|
|
/**
|
2011-01-20 03:05:29 -08:00
|
|
|
* Return if an element should have a specific validity UI
|
|
|
|
* (with :-moz-ui-invalid and :-moz-ui-valid pseudo-classes).
|
2010-11-23 15:50:53 -08:00
|
|
|
*
|
2012-11-27 19:15:36 -08:00
|
|
|
* @return Whether the element should have a validity UI.
|
2010-11-23 15:50:53 -08:00
|
|
|
*/
|
2011-01-20 03:05:29 -08:00
|
|
|
bool ShouldShowValidityUI() const {
|
2010-11-23 15:50:53 -08:00
|
|
|
/**
|
2011-01-20 03:05:29 -08:00
|
|
|
* Always show the validity UI if the form has already tried to be submitted
|
|
|
|
* but was invalid.
|
2010-11-23 15:50:53 -08:00
|
|
|
*
|
2011-01-20 03:05:29 -08:00
|
|
|
* Otherwise, show the validity UI if the element's value has been changed.
|
2010-11-23 15:50:53 -08:00
|
|
|
*/
|
2011-01-27 05:51:45 -08:00
|
|
|
if (mForm && mForm->HasEverTriedInvalidSubmit()) {
|
|
|
|
return true;
|
2010-12-17 15:26:24 -08:00
|
|
|
}
|
|
|
|
|
2010-11-23 15:56:24 -08:00
|
|
|
switch (GetValueMode()) {
|
|
|
|
case VALUE_MODE_DEFAULT:
|
2010-11-23 15:50:53 -08:00
|
|
|
return true;
|
|
|
|
case VALUE_MODE_DEFAULT_ON:
|
|
|
|
return GetCheckedChanged();
|
|
|
|
case VALUE_MODE_VALUE:
|
|
|
|
case VALUE_MODE_FILENAME:
|
2011-11-15 23:50:19 -08:00
|
|
|
return mValueChanged;
|
2010-11-23 15:50:53 -08:00
|
|
|
default:
|
|
|
|
NS_NOTREACHED("We should not be there: there are no other modes.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-05-04 05:49:59 -07: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;
|
|
|
|
|
2012-12-27 10:55:31 -08:00
|
|
|
/**
|
|
|
|
* Convert a string to a number in a type specific way,
|
|
|
|
* http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#concept-input-value-string-number
|
|
|
|
* ie parse a date string to a timestamp if type=date,
|
|
|
|
* or parse a number string to its value if type=number.
|
|
|
|
* @param aValue the string to be parsed.
|
|
|
|
* @param aResultValue the timestamp as a double.
|
|
|
|
* @result whether the parsing was successful.
|
|
|
|
*/
|
|
|
|
bool ConvertStringToNumber(nsAString& aValue, double& aResultValue) const;
|
|
|
|
|
2012-12-22 06:46:19 -08:00
|
|
|
/**
|
|
|
|
* Convert a double to a string in a type specific way, ie convert a timestamp
|
|
|
|
* to a date string if type=date or append the number string representing the
|
|
|
|
* value if type=number.
|
|
|
|
*
|
|
|
|
* @param aValue the double to be converted
|
|
|
|
* @param aResultString [out] the string representing the double
|
|
|
|
* @return whether the function succeded, it will fail if the current input's
|
|
|
|
* type is not supported or the number can't be converted to a string
|
|
|
|
* as expected by the type.
|
|
|
|
*/
|
|
|
|
bool ConvertNumberToString(double aValue, nsAString& aResultString) const;
|
|
|
|
|
2012-12-27 10:48:13 -08: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 07:02:58 -08:00
|
|
|
bool IsValidDate(const nsAString& aValue) const;
|
2012-12-27 10:48:13 -08:00
|
|
|
|
2012-12-27 10:55:31 -08:00
|
|
|
/**
|
|
|
|
* Parse a date string of the form yyyy-mm-dd
|
|
|
|
* @param the string to be parsed.
|
|
|
|
* @return the date in aYear, aMonth, aDay.
|
|
|
|
* @return whether the parsing was successful.
|
|
|
|
*/
|
2013-01-11 07:02:58 -08:00
|
|
|
bool GetValueAsDate(const nsAString& aValue,
|
|
|
|
uint32_t* aYear,
|
|
|
|
uint32_t* aMonth,
|
|
|
|
uint32_t* aDay) const;
|
2012-12-27 10:55:31 -08:00
|
|
|
|
2012-12-27 10:48:13 -08: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;
|
|
|
|
|
2013-01-11 07:00:52 -08: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 10:22:33 -08: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 07:33:47 -07:00
|
|
|
/**
|
|
|
|
* Sets the value of the element to the string representation of the double.
|
|
|
|
*
|
|
|
|
* @param aValue The double that will be used to set the value.
|
|
|
|
*/
|
|
|
|
void SetValue(double aValue);
|
|
|
|
|
2012-06-22 02:41:32 -07:00
|
|
|
/**
|
|
|
|
* Update the HAS_RANGE bit field value.
|
|
|
|
*/
|
|
|
|
void UpdateHasRange();
|
|
|
|
|
2012-12-22 06:46:19 -08: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
|
|
|
|
*/
|
|
|
|
double GetStepScaleFactor() const;
|
|
|
|
|
2012-06-22 12:02:20 -07:00
|
|
|
/**
|
|
|
|
* Returns the current step value.
|
|
|
|
* Returns kStepAny if the current step is "any" string.
|
|
|
|
*
|
|
|
|
* @return the current step value.
|
|
|
|
*/
|
|
|
|
double GetStep() const;
|
|
|
|
|
2012-07-05 07:33:47 -07: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.
|
|
|
|
*/
|
|
|
|
double GetStepBase() const;
|
|
|
|
|
2013-02-06 14:56:49 -08:00
|
|
|
/**
|
|
|
|
* Returns the default step for the current type.
|
|
|
|
* @return the default step for the current type.
|
|
|
|
*/
|
|
|
|
double GetDefaultStep() const;
|
|
|
|
|
2012-07-05 07:33:47 -07: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 08:56:38 -07:00
|
|
|
nsresult ApplyStep(int32_t aStep);
|
2012-07-05 07:33:47 -07:00
|
|
|
|
2013-01-31 15:01:50 -08:00
|
|
|
/**
|
|
|
|
* Returns if the current type is an experimental mobile type.
|
|
|
|
*/
|
|
|
|
static bool IsExperimentalMobileType(uint8_t aType)
|
|
|
|
{
|
|
|
|
return aType == NS_FORM_INPUT_NUMBER || aType == NS_FORM_INPUT_DATE ||
|
|
|
|
aType == NS_FORM_INPUT_TIME;
|
|
|
|
}
|
|
|
|
|
2010-09-05 11:00:05 -07: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
|
|
|
|
*/
|
2013-02-12 12:16:58 -08:00
|
|
|
PRUnichar* mValue;
|
2010-09-05 11:00:05 -07:00
|
|
|
/**
|
|
|
|
* The state of the text editor associated with the text/password input
|
|
|
|
*/
|
|
|
|
nsTextEditorState* mState;
|
|
|
|
} mInputData;
|
|
|
|
/**
|
|
|
|
* The value of the input if it is a file input. This is the list of filenames
|
|
|
|
* used when uploading a file. It is vital that this is kept separate from
|
|
|
|
* mValue so that it won't be possible to 'leak' the value from a text-input
|
|
|
|
* to a file-input. Additionally, the logic for this value is kept as simple
|
|
|
|
* as possible to avoid accidental errors where the wrong filename is used.
|
|
|
|
* Therefor the list of filenames is always owned by this member, never by
|
|
|
|
* the frame. Whenever the frame wants to change the filename it has to call
|
|
|
|
* SetFileNames to update this member.
|
|
|
|
*/
|
|
|
|
nsCOMArray<nsIDOMFile> mFiles;
|
|
|
|
|
|
|
|
nsRefPtr<nsDOMFileList> mFileList;
|
|
|
|
|
|
|
|
nsString mStaticDocFileList;
|
2012-05-07 09:27:24 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The value of the input element when first initialized and it is updated
|
|
|
|
* when the element is either changed through a script, focused or dispatches
|
|
|
|
* 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".
|
|
|
|
*/
|
|
|
|
nsString mFocusedValue;
|
2011-11-15 23:50:19 -08:00
|
|
|
|
2013-03-08 01:40:12 -08: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.
|
|
|
|
*/
|
|
|
|
double mRangeThumbDragStartValue;
|
|
|
|
|
2012-12-22 06:46:19 -08:00
|
|
|
// Step scale factor values, for input types that have one.
|
|
|
|
static const double kStepScaleFactorDate;
|
2013-02-16 04:35:57 -08:00
|
|
|
static const double kStepScaleFactorNumberRange;
|
2013-02-06 14:56:49 -08:00
|
|
|
static const double kStepScaleFactorTime;
|
2012-12-22 06:46:19 -08:00
|
|
|
|
2012-06-22 12:02:20 -07:00
|
|
|
// Default step base value when a type do not have specific one.
|
|
|
|
static const double kDefaultStepBase;
|
2013-02-06 14:56:49 -08:00
|
|
|
|
|
|
|
// Default step used when there is no specified step.
|
|
|
|
static const double kDefaultStep;
|
|
|
|
static const double kDefaultStepTime;
|
|
|
|
|
|
|
|
// Float value returned by GetStep() when the step attribute is set to 'any'.
|
2012-06-22 12:02:20 -07:00
|
|
|
static const double kStepAny;
|
|
|
|
|
2011-11-15 23:50:19 -08:00
|
|
|
/**
|
|
|
|
* The type of this input (<input type=...>) as an integer.
|
|
|
|
* @see nsIFormControl.h (specifically NS_FORM_INPUT_*)
|
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t mType;
|
2011-11-15 23:50:19 -08:00
|
|
|
bool mDisabledChanged : 1;
|
|
|
|
bool mValueChanged : 1;
|
|
|
|
bool mCheckedChanged : 1;
|
|
|
|
bool mChecked : 1;
|
|
|
|
bool mHandlingSelectEvent : 1;
|
|
|
|
bool mShouldInitChecked : 1;
|
|
|
|
bool mParserCreating : 1;
|
|
|
|
bool mInInternalActivate : 1;
|
|
|
|
bool mCheckedIsToggled : 1;
|
|
|
|
bool mIndeterminate : 1;
|
|
|
|
bool mInhibitRestoration : 1;
|
|
|
|
bool mCanShowValidUI : 1;
|
|
|
|
bool mCanShowInvalidUI : 1;
|
2012-06-22 02:41:32 -07:00
|
|
|
bool mHasRange : 1;
|
2013-03-08 01:40:12 -08:00
|
|
|
bool mIsDraggingRange : 1;
|
2012-06-06 05:16:58 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
struct nsFilePickerFilter {
|
|
|
|
nsFilePickerFilter()
|
|
|
|
: mFilterMask(0), mIsTrusted(false) {}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
nsFilePickerFilter(int32_t aFilterMask)
|
2012-06-06 05:16:58 -07:00
|
|
|
: mFilterMask(aFilterMask), mIsTrusted(true) {}
|
|
|
|
|
|
|
|
nsFilePickerFilter(const nsString& aTitle,
|
|
|
|
const nsString& aFilter,
|
|
|
|
const bool aIsTrusted = false)
|
|
|
|
: mFilterMask(0), mTitle(aTitle), mFilter(aFilter), mIsTrusted(aIsTrusted) {}
|
|
|
|
|
|
|
|
nsFilePickerFilter(const nsFilePickerFilter& other) {
|
|
|
|
mFilterMask = other.mFilterMask;
|
|
|
|
mTitle = other.mTitle;
|
|
|
|
mFilter = other.mFilter;
|
|
|
|
mIsTrusted = other.mIsTrusted;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator== (const nsFilePickerFilter& other) const {
|
|
|
|
if ((mFilter == other.mFilter) && (mFilterMask == other.mFilterMask)) {
|
|
|
|
NS_ASSERTION(mIsTrusted == other.mIsTrusted,
|
|
|
|
"Filter with similar list of extensions and mask should"
|
|
|
|
" have the same trusted flag value");
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Filter mask, using values defined in nsIFilePicker
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t mFilterMask;
|
2012-06-06 05:16:58 -07:00
|
|
|
// If mFilterMask is defined, mTitle and mFilter are useless and should be
|
|
|
|
// ignored
|
|
|
|
nsString mTitle;
|
|
|
|
nsString mFilter;
|
|
|
|
// mIsTrusted is true if mime type comes from a "trusted" source (e.g. our
|
|
|
|
// hard-coded set).
|
|
|
|
// false means it may come from an "untrusted" source (e.g. OS mime types
|
|
|
|
// mapping, which can be different accross OS, user's personal configuration, ...)
|
|
|
|
// For now, only mask filters are considered to be "trusted".
|
|
|
|
bool mIsTrusted;
|
|
|
|
};
|
2012-08-17 08:35:01 -07:00
|
|
|
|
|
|
|
class AsyncClickHandler
|
|
|
|
: public nsRunnable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
AsyncClickHandler(nsHTMLInputElement* aInput);
|
|
|
|
NS_IMETHOD Run();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
nsRefPtr<nsHTMLInputElement> mInput;
|
|
|
|
PopupControlState mPopupControlState;
|
|
|
|
};
|
|
|
|
|
|
|
|
class nsFilePickerShownCallback
|
|
|
|
: public nsIFilePickerShownCallback
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsFilePickerShownCallback(nsHTMLInputElement* aInput,
|
|
|
|
nsIFilePicker* aFilePicker,
|
|
|
|
bool aMulti);
|
|
|
|
virtual ~nsFilePickerShownCallback()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_IMETHOD Done(int16_t aResult);
|
2012-08-17 08:35:01 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
nsCOMPtr<nsIFilePicker> mFilePicker;
|
|
|
|
nsRefPtr<nsHTMLInputElement> mInput;
|
|
|
|
bool mMulti;
|
|
|
|
};
|
2010-09-05 11:00:05 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|