/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
class EventChainPostVisitor; class EventChainPreVisitor;
namespace dom {
class AfterSetFilesOrDirectoriesRunnable; class Date; class DispatchChangeEventCallback; class File; class FileList; class FileSystemEntry; class FormData; class GetFilesHelper; class InputType;
/** * 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 {
~UploadLastDir() = default;
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
/** * Fetch the last used directory for this location from the content * pref service, and display the file picker opened in that directory. * * @param aDoc current document * @param aFilePicker the file picker to open * @param aFpCallback the callback object to be run when the file is shown.
*/
nsresult FetchDirectoryAndDisplayPicker(
Document* aDoc, nsIFilePicker* aFilePicker,
nsIFilePickerShownCallback* aFpCallback);
/** * 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 aDir Parent directory of the file(s)/directory chosen by the user
*/
nsresult StoreLastUsedDirectory(Document* aDoc, nsIFile* aDir);
class ContentPrefCallback final : public nsIContentPrefCallback2 { virtual ~ContentPrefCallback() = default;
class HTMLInputElement final : public TextControlElement, public nsImageLoadingContent, public ConstraintValidation { friendclass AfterSetFilesOrDirectoriesCallback; friendclass DispatchChangeEventCallback; friendclass InputType;
public: using ConstraintValidation::GetValidationMessage; using nsGenericHTMLFormControlElementWithState::GetForm; using nsGenericHTMLFormControlElementWithState::GetFormAction; using ValueSetterOption = TextControlState::ValueSetterOption; using ValueSetterOptions = TextControlState::ValueSetterOptions;
// Note: if this returns false, then attributes may not yet be sanitized // (per SetValueInternal's dependence on mDoneCreating). bool IsDoneCreating() const { return mDoneCreating; }
// Methods for nsFormFillController so it can do selection operations on input // types the HTML spec doesn't support them on, like "email".
uint32_t GetSelectionStartIgnoringType(ErrorResult& aRv);
uint32_t GetSelectionEndIgnoringType(ErrorResult& aRv);
// This method is used for test only. Onces the data is set, a 'change' event // is dispatched. void MozSetDndFilesAndDirectories( const nsTArray<OwningFileOrDirectory>& aSequence);
// Called when a nsIFilePicker or a nsIColorPicker terminate. void PickerClosed();
/** * 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).
*/
HTMLInputElement* GetSelectedRadioButton() const;
static UploadLastDir* gUploadLastDir; // create and destroy the static UploadLastDir object for remembering // which directory was last used on a site-by-site basis staticvoid InitUploadLastDir(); staticvoid DestroyUploadLastDir();
// If the valueAsDate attribute should be enabled in webIDL staticbool ValueAsDateEnabled(JSContext* cx, JSObject* obj);
// nsIConstraintValidation bool IsTooLong(); bool IsTooShort(); bool IsValueMissing() const; bool HasTypeMismatch() const;
Maybe<bool> HasPatternMismatch() const; bool IsRangeOverflow() const; bool IsRangeUnderflow() const; bool ValueIsStepMismatch(const Decimal& aValue) const; bool HasStepMismatch() const; bool HasBadInput() const; void UpdateTooLongValidityState(); void UpdateTooShortValidityState(); void UpdateValueMissingValidityState(); void UpdateTypeMismatchValidityState(); void UpdatePatternMismatchValidityState(); void UpdateRangeOverflowValidityState(); void UpdateRangeUnderflowValidityState(); void UpdateStepMismatchValidityState(); void UpdateBadInputValidityState(); void UpdatePlaceholderShownState(); void UpdateCheckedState(bool aNotify); void UpdateIndeterminateState(bool aNotify); // Update all our validity states and then update our element state // as needed. aNotify controls whether the element state update // needs to notify. void UpdateAllValidityStates(bool aNotify); void UpdateValidityElementStates(bool aNotify);
MOZ_CAN_RUN_SCRIPT void MaybeUpdateAllValidityStates(bool aNotify) { // If you need to add new type which supports validationMessage, you should // add test cases into test_MozEditableElement_setUserInput.html. if (mType == FormControlType::InputEmail) {
UpdateAllValidityStates(aNotify);
}
}
// 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(); void UpdateBarredFromConstraintValidation();
nsresult GetValidationMessage(nsAString& aValidationMessage,
ValidityStateType aType) override;
// Override SetCustomValidity so we update our state properly when it's called // via bindings. void SetCustomValidity(const nsAString& aError);
/** * 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. * @note This method shouldn't be called if the radio element hasn't a group.
*/ void UpdateValueMissingValidityStateForRadio(bool aIgnoreSelf);
/** * 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 specified or not. * @note If more than one valid filter is found, the "All Supported Types" * filter is added, which is the concatenation of all valid filters. * @note Duplicate filters and similar filters (i.e. filters whose file * extensions already exist in another filter) are ignored. * @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.
*/ void SetFilePickerFiltersFromAccept(nsIFilePicker* filePicker);
void SetUserInteracted(bool) final;
/** * Fires change event if mFocusedValue and current value held are unequal and * if a change event may be fired on bluring. * Sets mFocusedValue to value, if a change event is fired.
*/ void FireChangeEventIfNeeded();
/** * Returns the input element's value as a Decimal. * Returns NaN if the current element's value is not a floating point number. * * @return the input element's value as a Decimal.
*/
Decimal GetValueAsDecimal() const;
/** * 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.
*/
Decimal 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.
*/
Decimal GetMaximum() const;
// Generic getter for the value that doesn't do experimental control type // sanitization. void GetValueInternal(nsAString& aValue, CallerType aCallerType) const;
void StepUp(int32_t aN, ErrorResult& aRv) { ApplyStep(aN, aRv); } void StepDown(int32_t aN, ErrorResult& aRv) { ApplyStep(-aN, aRv); }
/** * Returns the current step value. * Returns kStepAny if the current step is "any" string. * * @return the current step value.
*/
Decimal GetStep() const;
// Returns whether the given keyboard event steps up or down the value of an // <input> element. bool StepsInputValue(const WidgetKeyboardEvent&) const;
nsIControllers* GetControllers(ErrorResult& aRv);
nsIControllers* GetExtantControllers() const { return mControllers; } // XPCOM adapter function widely used throughout code, leaving it as is.
nsresult GetControllers(nsIControllers** aResult);
/* * 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);
/* * This allows chrome JavaScript to dispatch event to the inner datetimebox * anonymous or UA Widget element.
*/
Element* GetDateTimeBoxElement();
/* * 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(); void SetDateTimePickerState(bool aIsOpen);
/* * Called from datetime input box binding when inner text fields are focused * or blurred.
*/ void SetFocusState(bool aIsFocused);
/* * Called from datetime input box binding when the the user entered value * becomes valid/invalid.
*/ void UpdateValidityState();
/* * 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(); } double GetMinimumAsDouble() { return GetMinimum().toDouble(); } double GetMaximumAsDouble() { return GetMaximum().toDouble(); }
/** * The callback function used by the nsRepeatService that we use to spin the * spinner for <input type=number>.
*/
MOZ_CAN_RUN_SCRIPT_BOUNDARY staticvoid HandleNumberControlSpin(void* aData);
/** * 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.
*/ bool IsRequired() const { return State().HasState(ElementState::REQUIRED); }
/** * Returns whether the current value is the empty string. This only makes * sense for some input types; does NOT make sense for file inputs. * * @return whether the current value is the empty string.
*/ bool IsValueEmpty() const { return State().HasState(ElementState::VALUE_EMPTY);
}
// Pull IsSingleLineTextControl into our scope, otherwise it'd be hidden // by the TextControlElement version. using nsGenericHTMLFormControlElementWithState::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 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.
*/ staticbool DigitSubStringToNumber(const nsAString& aValue, uint32_t aStart,
uint32_t aLen, uint32_t* aResult);
// Helper method
/** * Setting the value. * * @param aValue String to set. * @param aOldValue Previous value before setting aValue. If previous value is unknown, aOldValue can be nullptr. * @param aOptions See TextControlState::ValueSetterOption.
*/
MOZ_CAN_RUN_SCRIPT nsresult
SetValueInternal(const nsAString& aValue, const nsAString* aOldValue, const ValueSetterOptions& aOptions);
MOZ_CAN_RUN_SCRIPT nsresult SetValueInternal( const nsAString& aValue, const ValueSetterOptions& aOptions) { return SetValueInternal(aValue, nullptr, aOptions);
}
// 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;
/** * Called when an attribute is about to be changed
*/ void BeforeSetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAttrValue* aValue, bool aNotify) override; /** * Called when an attribute has just been changed
*/
MOZ_CAN_RUN_SCRIPT_BOUNDARY void AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue,
nsIPrincipal* aSubjectPrincipal, bool aNotify) override;
/** * Visit the group of radio buttons this radio belongs to * @param aVisitor the visitor to visit with
*/
nsresult VisitGroup(nsIRadioVisitor* aVisitor);
/** * Visit the group of radio buttons this radio belongs to * @param aCallback the callback function to visit the node
*/ void VisitGroup(const RadioGroupContainer::VisitCallback& aCallback);
/** * Do all the work that |SetChecked| does (radio button handling, etc.), but * take an |aNotify| parameter.
*/ void DoSetChecked(bool aValue, bool aNotify, bool aSetValueChanged, bool aUpdateOtherElement = true);
/** * 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.
*/ void DoSetCheckedChanged(bool aCheckedChanged, bool aNotify);
/** * Actually set checked and notify the frame of the change. * @param aValue the value of checked to set
*/ void SetCheckedInternal(bool aValue, bool aNotify);
/** * MaybeSubmitForm looks for a submit input or a single text control * and submits the form if either is present.
*/
MOZ_CAN_RUN_SCRIPT void MaybeSubmitForm(nsPresContext* aPresContext);
/** * Called after calling one of the SetFilesOrDirectories() functions. * This method can explore the directory recursively if needed.
*/ void AfterSetFilesOrDirectories(bool aSetValueChanged);
/** * Recursively explore the directory and populate mFileOrDirectories correctly * for webkitdirectory.
*/ void ExploreDirectoryRecursively(bool aSetValuechanged);
/** * Determine whether the editor needs to be initialized explicitly for * a particular event.
*/ bool NeedToInitializeEditorForEvent(EventChainPreVisitor& aVisitor) const;
/** * 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: https://html.spec.whatwg.org/#concept-fe-mutable
*/ bool IsMutable() const;
/** * Returns if the min and max attributes apply for the current type.
*/ bool DoesMinMaxApply() const;
/** * Returns if the step attribute apply for the current type.
*/ bool DoesStepApply() const { return DoesMinMaxApply(); }
/** * Returns if stepDown and stepUp methods apply for the current type.
*/ bool DoStepDownStepUpApply() const { return DoesStepApply(); }
/** * Returns if valueAsNumber attribute applies for the current type.
*/ bool DoesValueAsNumberApply() const { return DoesMinMaxApply(); }
/** * Returns if autocomplete attribute applies for the current type.
*/ bool DoesAutocompleteApply() const;
/** * Manages the internal data storage across type changes.
*/
MOZ_CAN_RUN_SCRIPT void HandleTypeChange(FormControlType aNewType, bool aNotify);
/** * If the input range has a list, this function will snap the given value to * the nearest tick mark, but only if the given value is close enough to that * tick mark.
*/ void MaybeSnapToTickMark(Decimal& aValue);
/** * Returns whether the placeholder attribute applies for the current type.
*/ bool PlaceholderApplies() const;
/** * Set the current default value to the value of the input element. * @note You should not call this method if GetValueMode() doesn't return * VALUE_MODE_VALUE.
*/
MOZ_CAN_RUN_SCRIPT
nsresult SetDefaultValueAsValue();
/** * Returns the radio group container within the DOM tree that the element * is currently a member of, if one exists.
*/
RadioGroupContainer* GetCurrentRadioGroupContainer() const; /** * Returns the radio group container within the DOM tree that the element * should be added into, if one exists.
*/
RadioGroupContainer* FindTreeRadioGroupContainer() const;
/** * 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;
/** * 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 * @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;
/** * 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.
*/ bool IsValidDate(const nsAString& aValue) const;
/** * 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;
/** * 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;
/** * 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; /** * 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.
*/ bool ParseDate(const nsAString& aValue, uint32_t* aYear, uint32_t* aMonth,
uint32_t* aDay) const;
/** * 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;
/** * This methods returns the number of days since epoch for a given year and * week.
*/ double DaysSinceEpochFromWeek(uint32_t aYear, uint32_t aWeek) const;
/** * 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;
/** * 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;
/** * This methods returns the day of the week given a date. If @isoWeek is true, * 7=Sunday, otherwise, 0=Sunday.
*/
uint32_t DayOfWeek(uint32_t aYear, uint32_t aMonth, uint32_t aDay, bool isoWeek) const;
/** * 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;
/** * 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.
*/ staticbool ParseTime(const nsAString& aValue, uint32_t* aResult);
/** * Sets the value of the element to the string representation of the Decimal. * * @param aValue The Decimal that will be used to set the value.
*/ void SetValue(Decimal aValue, CallerType aCallerType);
void UpdateHasRange(bool aNotify); // Updates the :in-range / :out-of-range states. void UpdateInRange(bool aNotify);
/** * 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.
*/
Decimal GetStepBase() const;
/** * Returns the default step for the current type. * @return the default step for the current type.
*/
Decimal GetDefaultStep() const;
/** * Returns the value that this input would take if someone tries to step * aStepCount steps and this input's value would change as a result, or * Decimal::nan() otherwise (e.g., if this inputs value would not change due * to it being already at max, and asking for the next step up). * * Negative aStep means step down, positive means step up.
*/
Decimal GetValueIfStepped(int32_t aStepCount, StepCallerType, ErrorResult&);
/** * 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.
*/ void ApplyStep(int32_t aStep, ErrorResult&);
/** * Returns if the current type is an experimental mobile type.
*/ staticbool IsExperimentalMobileType(FormControlType);
/* * Returns if the current type is one of the date/time input types: date, * time, month, week and datetime-local.
*/ staticbool IsDateTimeInputType(FormControlType);
/** * Returns whether getting `.value` as a string should sanitize the value. * * See SanitizeValue.
*/ bool SanitizesOnValueGetter() const;
/** * 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.
*/ bool ShouldPreventDOMActivateDispatch(EventTarget* aOriginalTarget);
/** * 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).
*/
nsresult MaybeInitPickers(EventChainPostVisitor& aVisitor);
/** * Returns all valid colors in the <datalist> for the input with type=color.
*/
nsTArray<nsString> GetColorsFromList();
/** * nsINode::SetMayBeApzAware() will be invoked in this function if necessary * 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();
/** * A helper to get the current selection range. Will throw on the ErrorResult * if we have no editor state.
*/ void GetSelectionRange(uint32_t* aSelectionStart, uint32_t* aSelectionEnd,
ErrorResult& aRv);
/* * 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
*/
char16_t* mValue; /** * The state of the text editor associated with the text/password input
*/
TextControlState* mState;
} mInputData;
struct FileData;
UniquePtr<FileData> mFileData;
/** * 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= "date", "time", "text", "email", "search", "tel", "url" or * "password".
*/
nsString mFocusedValue;
/** * 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.
*/
Decimal mRangeThumbDragStartValue;
/** * Current value in the input box, in DateTimeValue dictionary format, see * HTMLInputElement.webidl for details.
*/
UniquePtr<DateTimeValue> mDateTimeInputBoxValue;
/** * The triggering principal for the src attribute.
*/
nsCOMPtr<nsIPrincipal> mSrcTriggeringPrincipal;
/* * InputType object created based on input type.
*/
UniquePtr<InputType, InputType::DoNotDelete> mInputType;
// Memory allocated for mInputType, reused when type changes. char mInputTypeMem[INPUT_TYPE_SIZE];
// Step scale factor values, for input types that have one. staticconst Decimal kStepScaleFactorDate; staticconst Decimal kStepScaleFactorNumberRange; staticconst Decimal kStepScaleFactorTime; staticconst Decimal kStepScaleFactorMonth; staticconst Decimal kStepScaleFactorWeek;
// Default step base value when a type do not have specific one. staticconst Decimal kDefaultStepBase; // Default step base value when type=week does not not have a specific one, // which is −259200000, the start of week 1970-W01. staticconst Decimal kDefaultStepBaseWeek;
// Default step used when there is no specified step. staticconst Decimal kDefaultStep; staticconst Decimal kDefaultStepTime;
// Float value returned by GetStep() when the step attribute is set to 'any'. staticconst Decimal kStepAny;
// Minimum year limited by HTML standard, year >= 1. staticconstdouble kMinimumYear; // Maximum year limited by ECMAScript date object range, year <= 275760. staticconstdouble kMaximumYear; // Maximum valid week is 275760-W37. staticconstdouble kMaximumWeekInMaximumYear; // Maximum valid day is 275760-09-13. staticconstdouble kMaximumDayInMaximumYear; // Maximum valid month is 275760-09. staticconstdouble kMaximumMonthInMaximumYear; // Long years in a ISO calendar have 53 weeks in them. staticconstdouble kMaximumWeekInYear; // Milliseconds in a day. staticconstdouble kMsPerDay;
/** * 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); }
/** * Returns true if selection methods can be called on element
*/ bool SupportsTextSelection() const { switch (mType) { case FormControlType::InputText: case FormControlType::InputSearch: case FormControlType::InputUrl: case FormControlType::InputTel: case FormControlType::InputPassword: returntrue; default: returnfalse;
}
}
/** * https://html.spec.whatwg.org/#auto-directionality-form-associated-elements
*/ staticbool IsAutoDirectionalityAssociated(FormControlType aType) { switch (aType) { case FormControlType::InputHidden: case FormControlType::InputText: case FormControlType::InputSearch: case FormControlType::InputTel: case FormControlType::InputUrl: case FormControlType::InputEmail: case FormControlType::InputPassword: case FormControlType::InputSubmit: case FormControlType::InputReset: case FormControlType::InputButton: returntrue; default: returnfalse;
}
}
/** * Call MaybeDispatchPasswordEvent or MaybeDispatchUsernameEvent * in order to dispatch LoginManager events.
*/ void MaybeDispatchLoginManagerEvents(HTMLFormElement* aForm);
/** * Fire an event when the password input field is removed from the DOM tree. * This is now only used by the password manager and formautofill.
*/ void MaybeFireInputPasswordRemoved();
/** * Checks if aDateTimeInputType should be supported.
*/ staticbool IsDateTimeTypeSupported(FormControlType);
/** * The radio group container containing the group the element is a part of. * This allows the element to only access a container it has been added to.
*/
RadioGroupContainer* mRadioGroupContainer;
// Filter mask, using values defined in nsIFilePicker
int32_t mFilterMask; // If mFilterMask is defined, mTitle and mFilter are useless and should be // ignored
nsString mTitle;
nsString mFilter;
};
class nsFilePickerShownCallback : public nsIFilePickerShownCallback { virtual ~nsFilePickerShownCallback() = default;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.