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: */
|
2013-02-19 01:18:40 +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/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_HTMLTextAreaElement_h
|
|
|
|
#define mozilla_dom_HTMLTextAreaElement_h
|
|
|
|
|
2013-05-30 00:43:41 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2013-02-19 01:18:40 +04:00
|
|
|
#include "nsITextControlElement.h"
|
2016-08-16 02:04:36 +03:00
|
|
|
#include "nsIControllers.h"
|
2013-02-19 01:18:40 +04:00
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsGenericHTMLElement.h"
|
|
|
|
#include "nsStubMutationObserver.h"
|
|
|
|
#include "nsIConstraintValidation.h"
|
2013-06-19 18:24:37 +04:00
|
|
|
#include "mozilla/dom/HTMLFormElement.h"
|
2013-10-04 19:30:07 +04:00
|
|
|
#include "mozilla/dom/HTMLInputElementBinding.h"
|
2013-02-19 09:54:23 +04:00
|
|
|
#include "nsGkAtoms.h"
|
2013-02-19 01:18:40 +04:00
|
|
|
|
2017-06-22 09:21:31 +03:00
|
|
|
#include "mozilla/TextEditor.h"
|
2013-02-19 01:18:40 +04:00
|
|
|
#include "nsTextEditorState.h"
|
|
|
|
|
|
|
|
class nsIControllers;
|
|
|
|
class nsPresContext;
|
|
|
|
|
|
|
|
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;
|
2014-04-03 08:18:36 +04:00
|
|
|
class EventStates;
|
2018-03-02 21:18:35 +03:00
|
|
|
class PresState;
|
2014-03-18 08:48:19 +04:00
|
|
|
|
2013-02-19 01:18:40 +04:00
|
|
|
namespace dom {
|
|
|
|
|
2016-06-16 10:24:16 +03:00
|
|
|
class HTMLFormSubmission;
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class HTMLTextAreaElement final : public nsGenericHTMLFormElementWithState,
|
2015-03-27 21:52:19 +03:00
|
|
|
public nsITextControlElement,
|
|
|
|
public nsStubMutationObserver,
|
|
|
|
public nsIConstraintValidation {
|
2013-02-19 01:18:40 +04:00
|
|
|
public:
|
|
|
|
using nsIConstraintValidation::GetValidationMessage;
|
|
|
|
|
2018-09-21 23:45:49 +03:00
|
|
|
explicit HTMLTextAreaElement(
|
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
|
2014-09-02 04:49:25 +04:00
|
|
|
FromParser aFromParser = NOT_FROM_PARSER);
|
2013-02-19 01:18:40 +04:00
|
|
|
|
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
|
2018-03-22 00:39:04 +03:00
|
|
|
NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLTextAreaElement, textarea)
|
2017-10-31 02:14:51 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual int32_t TabIndexDefault() override;
|
2013-02-19 01:18:40 +04:00
|
|
|
|
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
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-02-19 01:18:40 +04:00
|
|
|
// nsIFormControl
|
2018-11-21 01:06:37 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
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;
|
2018-03-02 21:18:35 +03:00
|
|
|
virtual bool RestoreState(PresState* aState) override;
|
2018-10-31 11:55:33 +03:00
|
|
|
virtual bool IsDisabledForEvents(WidgetEvent* aEvent) override;
|
2013-02-19 01:18:40 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void FieldSetDisabledChanged(bool aNotify) override;
|
2013-02-19 01:18:40 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual EventStates IntrinsicState() const override;
|
2013-02-19 01:18:40 +04:00
|
|
|
|
|
|
|
// nsITextControlElemet
|
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;
|
2018-11-21 06:59:02 +03:00
|
|
|
NS_IMETHOD_(mozilla::TextEditor*) GetTextEditorWithoutCreation() 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;
|
2018-11-21 01:06:37 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD_(void) UnbindFromFrame(nsTextControlFrame* aFrame) override;
|
2018-11-21 01:06:37 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD CreateEditor() override;
|
2017-03-30 12:38:59 +03:00
|
|
|
NS_IMETHOD_(void) UpdateOverlayTextVisibility(bool aNotify) 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;
|
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_(void) InitializeKeyboardEventListeners() override;
|
2019-02-19 12:25:55 +03:00
|
|
|
NS_IMETHOD_(void) OnValueChanged(bool aNotify, ValueChangeKind) override;
|
2017-03-09 22:44:06 +03:00
|
|
|
virtual void GetValueFromSetRangeText(nsAString& aValue) override;
|
2018-11-21 01:06:37 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
2017-03-09 22:44:06 +03:00
|
|
|
virtual nsresult SetValueFromSetRangeText(const nsAString& aValue) override;
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD_(bool) HasCachedSelection() override;
|
2017-02-28 20:41:37 +03:00
|
|
|
|
2013-02-19 01:18:40 +04:00
|
|
|
// nsIContent
|
Bug 1555216 - Change the signature of BindToTree to be (BindContext&, nsINode& aParentNode). r=bzbarsky
BindContext was going to have way more information at first, but then I realized
that most of the things I wanted to know were basically a flag away using the
parent node.
Still I think it's worth it, now experimenting with BindToTree will only mean
adding a field to a struct that's included from a couple cpp files, instead of a
massive pain.
I also think this is clearer, and doing this highlights quite a few
inconsistencies in our code which I've left untouched, but commented with
FIXMEs.
Steps are:
$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsresult BindToTree(Document\* aDocument, nsIContent\* aParent,#nsresult BindToTree(BindContext\&, nsINode\& aParent)#g' $file; done
$ for file in $(rg 'nsresult BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's# nsIContent\* aBindingParent) override#override#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(Document\* aDocument, nsIContent\* aParent,#::BindToTree(BindContext\& aContext, nsINode\& aParent)#g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#nsIContent\* aBindingParent)##g' $file; done
$ for file in $(rg '::BindToTree\(' | cut -d : -f 1 | sort | uniq); do sed -i 's#::BindToTree(aDocument, aParent, aBindingParent)#::BindToTree(aContext, aParent)#g' $file; done
$ ./mach clang-format
Then manual fixups.
Depends on D32948
Differential Revision: https://phabricator.services.mozilla.com/D32949
2019-05-29 07:27:04 +03:00
|
|
|
virtual nsresult BindToTree(BindContext&, nsINode& aParent) override;
|
2019-05-29 01:47:08 +03:00
|
|
|
virtual void UnbindFromTree(bool aNullParent = true) override;
|
2013-02-19 01:18:40 +04:00
|
|
|
virtual bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
|
|
|
|
const nsAString& aValue,
|
2017-11-02 06:35:52 +03:00
|
|
|
nsIPrincipal* aMaybeScriptedPrincipal,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsAttrValue& aResult) override;
|
|
|
|
virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction()
|
|
|
|
const 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;
|
2013-02-19 01:18:40 +04:00
|
|
|
|
2018-04-05 20:42:41 +03:00
|
|
|
void GetEventTargetParent(EventChainPreVisitor& aVisitor) override;
|
2016-10-21 12:33:41 +03:00
|
|
|
virtual nsresult PreHandleEvent(EventChainVisitor& aVisitor) override;
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual nsresult PostHandleEvent(EventChainPostVisitor& aVisitor) override;
|
2013-02-19 01:18:40 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual bool IsHTMLFocusable(bool aWithMouse, bool* aIsFocusable,
|
|
|
|
int32_t* aTabIndex) override;
|
2013-02-19 01:18:40 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void DoneAddingChildren(bool aHaveNotified) override;
|
|
|
|
virtual bool IsDoneAddingChildren() override;
|
2013-02-19 01:18:40 +04:00
|
|
|
|
2018-11-21 01:06:37 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
2018-08-09 02:58:44 +03:00
|
|
|
virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
|
2013-02-19 01:18:40 +04:00
|
|
|
|
2018-08-09 02:58:44 +03:00
|
|
|
nsresult CopyInnerTo(Element* aDest);
|
2013-02-19 01:18:40 +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;
|
2013-02-19 01:18:40 +04:00
|
|
|
|
|
|
|
// nsIMutationObserver
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
|
|
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
|
|
|
|
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLTextAreaElement,
|
2013-08-02 05:21:31 +04:00
|
|
|
nsGenericHTMLFormElementWithState)
|
2013-02-19 01:18:40 +04:00
|
|
|
|
|
|
|
// nsIConstraintValidation
|
|
|
|
bool IsTooLong();
|
2016-08-17 07:11:24 +03:00
|
|
|
bool IsTooShort();
|
2013-02-19 01:18:40 +04:00
|
|
|
bool IsValueMissing() const;
|
|
|
|
void UpdateTooLongValidityState();
|
2016-08-17 07:11:24 +03:00
|
|
|
void UpdateTooShortValidityState();
|
2013-02-19 01:18:40 +04:00
|
|
|
void UpdateValueMissingValidityState();
|
|
|
|
void UpdateBarredFromConstraintValidation();
|
|
|
|
nsresult GetValidationMessage(nsAString& aValidationMessage,
|
2015-03-21 19:28:04 +03:00
|
|
|
ValidityStateType aType) override;
|
2013-02-19 01:18:40 +04:00
|
|
|
|
2013-02-19 09:54:23 +04:00
|
|
|
// Web IDL binding methods
|
2017-11-09 08:35:04 +03:00
|
|
|
void GetAutocomplete(DOMString& aValue);
|
|
|
|
void SetAutocomplete(const nsAString& aValue, ErrorResult& aRv) {
|
|
|
|
SetHTMLAttr(nsGkAtoms::autocomplete, aValue, aRv);
|
|
|
|
}
|
2013-02-19 09:54:23 +04:00
|
|
|
bool Autofocus() { return GetBoolAttr(nsGkAtoms::autofocus); }
|
|
|
|
void SetAutofocus(bool aAutoFocus, ErrorResult& aError) {
|
|
|
|
SetHTMLBoolAttr(nsGkAtoms::autofocus, aAutoFocus, aError);
|
|
|
|
}
|
2019-06-28 23:57:44 +03:00
|
|
|
uint32_t Cols() { return GetUnsignedIntAttr(nsGkAtoms::cols, DEFAULT_COLS); }
|
2013-02-19 09:54:23 +04:00
|
|
|
void SetCols(uint32_t aCols, ErrorResult& aError) {
|
2016-08-21 18:09:20 +03:00
|
|
|
uint32_t cols = aCols ? aCols : DEFAULT_COLS;
|
|
|
|
SetUnsignedIntAttr(nsGkAtoms::cols, cols, DEFAULT_COLS, aError);
|
2013-02-19 09:54:23 +04:00
|
|
|
}
|
|
|
|
bool Disabled() { return GetBoolAttr(nsGkAtoms::disabled); }
|
|
|
|
void SetDisabled(bool aDisabled, ErrorResult& aError) {
|
|
|
|
SetHTMLBoolAttr(nsGkAtoms::disabled, aDisabled, aError);
|
|
|
|
}
|
2013-08-02 05:21:31 +04:00
|
|
|
// nsGenericHTMLFormElementWithState::GetForm is fine
|
|
|
|
using nsGenericHTMLFormElementWithState::GetForm;
|
2013-02-19 09:54:23 +04:00
|
|
|
int32_t MaxLength() { return GetIntAttr(nsGkAtoms::maxlength, -1); }
|
|
|
|
void SetMaxLength(int32_t aMaxLength, ErrorResult& aError) {
|
2016-08-17 07:11:24 +03:00
|
|
|
int32_t minLength = MinLength();
|
|
|
|
if (aMaxLength < 0 || (minLength >= 0 && aMaxLength < minLength)) {
|
2013-02-19 09:54:23 +04:00
|
|
|
aError.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
|
|
|
|
} else {
|
|
|
|
SetHTMLIntAttr(nsGkAtoms::maxlength, aMaxLength, aError);
|
|
|
|
}
|
|
|
|
}
|
2016-08-17 07:11:24 +03:00
|
|
|
int32_t MinLength() { return GetIntAttr(nsGkAtoms::minlength, -1); }
|
|
|
|
void SetMinLength(int32_t aMinLength, ErrorResult& aError) {
|
|
|
|
int32_t maxLength = MaxLength();
|
|
|
|
if (aMinLength < 0 || (maxLength >= 0 && aMinLength > maxLength)) {
|
|
|
|
aError.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
|
|
|
|
} else {
|
|
|
|
SetHTMLIntAttr(nsGkAtoms::minlength, aMinLength, aError);
|
|
|
|
}
|
|
|
|
}
|
2017-10-31 02:14:51 +03:00
|
|
|
void GetName(nsAString& aName) { GetHTMLAttr(nsGkAtoms::name, aName); }
|
2013-02-19 09:54:23 +04:00
|
|
|
void SetName(const nsAString& aName, ErrorResult& aError) {
|
|
|
|
SetHTMLAttr(nsGkAtoms::name, aName, aError);
|
|
|
|
}
|
2017-10-31 02:14:51 +03:00
|
|
|
void GetPlaceholder(nsAString& aPlaceholder) {
|
|
|
|
GetHTMLAttr(nsGkAtoms::placeholder, aPlaceholder);
|
|
|
|
}
|
2013-02-19 09:54:23 +04:00
|
|
|
void SetPlaceholder(const nsAString& aPlaceholder, ErrorResult& aError) {
|
|
|
|
SetHTMLAttr(nsGkAtoms::placeholder, aPlaceholder, aError);
|
|
|
|
}
|
|
|
|
bool ReadOnly() { return GetBoolAttr(nsGkAtoms::readonly); }
|
|
|
|
void SetReadOnly(bool aReadOnly, ErrorResult& aError) {
|
|
|
|
SetHTMLBoolAttr(nsGkAtoms::readonly, aReadOnly, aError);
|
|
|
|
}
|
2017-08-03 08:27:00 +03:00
|
|
|
bool Required() const { return State().HasState(NS_EVENT_STATE_REQUIRED); }
|
2013-10-04 19:30:07 +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-10-04 19:30:07 +04:00
|
|
|
|
2013-02-19 09:54:23 +04:00
|
|
|
void SetRequired(bool aRequired, ErrorResult& aError) {
|
|
|
|
SetHTMLBoolAttr(nsGkAtoms::required, aRequired, aError);
|
|
|
|
}
|
2019-06-28 23:57:44 +03:00
|
|
|
uint32_t Rows() {
|
|
|
|
return GetUnsignedIntAttr(nsGkAtoms::rows, DEFAULT_ROWS_TEXTAREA);
|
|
|
|
}
|
2013-02-19 09:54:23 +04:00
|
|
|
void SetRows(uint32_t aRows, ErrorResult& aError) {
|
2016-08-21 18:09:20 +03:00
|
|
|
uint32_t rows = aRows ? aRows : DEFAULT_ROWS_TEXTAREA;
|
|
|
|
SetUnsignedIntAttr(nsGkAtoms::rows, rows, DEFAULT_ROWS_TEXTAREA, aError);
|
2013-02-19 09:54:23 +04:00
|
|
|
}
|
2017-10-31 02:14:51 +03:00
|
|
|
void GetWrap(nsAString& aWrap) { GetHTMLAttr(nsGkAtoms::wrap, aWrap); }
|
2013-02-19 09:54:23 +04:00
|
|
|
void SetWrap(const nsAString& aWrap, ErrorResult& aError) {
|
|
|
|
SetHTMLAttr(nsGkAtoms::wrap, aWrap, aError);
|
|
|
|
}
|
2017-10-31 02:14:51 +03:00
|
|
|
void GetType(nsAString& aType);
|
|
|
|
void GetDefaultValue(nsAString& aDefaultValue, ErrorResult& aError);
|
2013-02-19 09:54:23 +04:00
|
|
|
void SetDefaultValue(const nsAString& aDefaultValue, ErrorResult& aError);
|
2017-10-31 02:14:51 +03:00
|
|
|
void GetValue(nsAString& aValue);
|
2018-11-21 01:06:37 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
2017-10-31 02:14:51 +03:00
|
|
|
void SetValue(const nsAString& aValue, ErrorResult& aError);
|
|
|
|
|
2013-02-19 09:54:23 +04:00
|
|
|
uint32_t GetTextLength();
|
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);
|
|
|
|
|
2017-10-31 02:14:51 +03:00
|
|
|
void Select();
|
2016-08-09 00:19:00 +03:00
|
|
|
Nullable<uint32_t> GetSelectionStart(ErrorResult& aError);
|
|
|
|
void SetSelectionStart(const Nullable<uint32_t>& aSelectionStart,
|
|
|
|
ErrorResult& aError);
|
|
|
|
Nullable<uint32_t> GetSelectionEnd(ErrorResult& aError);
|
|
|
|
void SetSelectionEnd(const Nullable<uint32_t>& aSelectionEnd,
|
|
|
|
ErrorResult& aError);
|
2013-02-19 09:54:23 +04:00
|
|
|
void GetSelectionDirection(nsAString& aDirection, ErrorResult& aError);
|
|
|
|
void SetSelectionDirection(const nsAString& aDirection, ErrorResult& aError);
|
|
|
|
void SetSelectionRange(uint32_t aSelectionStart, uint32_t aSelectionEnd,
|
|
|
|
const Optional<nsAString>& aDirecton,
|
|
|
|
ErrorResult& aError);
|
|
|
|
nsIControllers* GetControllers(ErrorResult& aError);
|
2017-10-31 02:14:51 +03:00
|
|
|
// XPCOM adapter function widely used throughout code, leaving it as is.
|
|
|
|
nsresult GetControllers(nsIControllers** aResult);
|
|
|
|
|
2017-06-20 16:57:08 +03:00
|
|
|
nsIEditor* GetEditor() { return mState.GetTextEditor(); }
|
2013-02-19 09:54:23 +04:00
|
|
|
|
2018-11-20 17:35:38 +03:00
|
|
|
bool IsInputEventTarget() const { return true; }
|
|
|
|
|
2018-11-21 01:06:37 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT_BOUNDARY
|
2018-06-02 05:35:23 +03:00
|
|
|
void SetUserInput(const nsAString& aValue, nsIPrincipal& aSubjectPrincipal);
|
|
|
|
|
2013-02-19 01:18:40 +04:00
|
|
|
protected:
|
2014-07-09 01:23:16 +04:00
|
|
|
virtual ~HTMLTextAreaElement() {}
|
|
|
|
|
2013-08-02 05:21:31 +04:00
|
|
|
// get rid of the compiler warning
|
|
|
|
using nsGenericHTMLFormElementWithState::IsSingleLineTextControl;
|
2013-02-19 01:18:40 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual JSObject* WrapNode(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
2013-02-19 09:54:23 +04:00
|
|
|
|
2013-02-19 01:18:40 +04:00
|
|
|
nsCOMPtr<nsIControllers> mControllers;
|
|
|
|
/** Whether or not the value has changed since its default value was given. */
|
|
|
|
bool mValueChanged;
|
2016-08-06 18:59:08 +03:00
|
|
|
/** Whether or not the last change to the value was made interactively by the
|
|
|
|
* user. */
|
|
|
|
bool mLastValueChangeWasInteractive;
|
2013-02-19 01:18:40 +04:00
|
|
|
/** Whether or not we are already handling select event. */
|
|
|
|
bool mHandlingSelect;
|
|
|
|
/** Whether or not we are done adding children (always true if not
|
|
|
|
created by a parser */
|
|
|
|
bool mDoneAddingChildren;
|
|
|
|
/** Whether state restoration should be inhibited in DoneAddingChildren. */
|
|
|
|
bool mInhibitStateRestoration;
|
|
|
|
/** Whether our disabled state has changed from the default **/
|
|
|
|
bool mDisabledChanged;
|
|
|
|
/** Whether we should make :-moz-ui-invalid apply on the element. **/
|
|
|
|
bool mCanShowInvalidUI;
|
|
|
|
/** Whether we should make :-moz-ui-valid apply on the element. **/
|
|
|
|
bool mCanShowValidUI;
|
2017-03-22 11:55:56 +03:00
|
|
|
bool mIsPreviewEnabled;
|
2016-04-12 14:02:42 +03:00
|
|
|
|
2017-11-09 08:35:04 +03:00
|
|
|
nsContentUtils::AutocompleteAttrState mAutocompleteAttrState;
|
|
|
|
|
2013-02-19 01:18:40 +04:00
|
|
|
void FireChangeEventIfNeeded();
|
2016-04-12 14:02:42 +03:00
|
|
|
|
2013-02-19 01:18:40 +04:00
|
|
|
nsString mFocusedValue;
|
|
|
|
|
|
|
|
/** The state of the text editor (selection controller and the editor) **/
|
|
|
|
nsTextEditorState mState;
|
|
|
|
|
|
|
|
NS_IMETHOD SelectAll(nsPresContext* aPresContext);
|
|
|
|
/**
|
|
|
|
* Get the value, whether it is from the content or the frame.
|
|
|
|
* @param aValue the value [out]
|
|
|
|
* @param aIgnoreWrap whether to ignore the wrap attribute when getting the
|
|
|
|
* value. If this is true, linebreaks will not be inserted even if
|
|
|
|
* wrap=hard.
|
|
|
|
*/
|
|
|
|
void GetValueInternal(nsAString& aValue, bool aIgnoreWrap) const;
|
|
|
|
|
2015-06-18 17:56:20 +03:00
|
|
|
/**
|
|
|
|
* Setting the value.
|
|
|
|
*
|
|
|
|
* @param aValue String to set.
|
|
|
|
* @param aFlags See nsTextEditorState::SetValueFlags.
|
|
|
|
*/
|
2018-11-21 01:06:37 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2015-06-18 17:56:20 +03:00
|
|
|
nsresult SetValueInternal(const nsAString& aValue, uint32_t aFlags);
|
|
|
|
|
2013-02-19 01:18:40 +04:00
|
|
|
/**
|
|
|
|
* Common method to call from the various mutation observer methods.
|
|
|
|
* aContent is a content node that's either the one that changed or its
|
|
|
|
* parent; we should only respond to the change if aContent is non-anonymous.
|
|
|
|
*/
|
|
|
|
void ContentChanged(nsIContent* aContent);
|
|
|
|
|
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;
|
2013-02-19 01:18:40 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return if an element should have a specific validity UI
|
|
|
|
* (with :-moz-ui-invalid and :-moz-ui-valid pseudo-classes).
|
|
|
|
*
|
|
|
|
* @return Whether the element should have a validity UI.
|
|
|
|
*/
|
|
|
|
bool ShouldShowValidityUI() const {
|
|
|
|
/**
|
|
|
|
* Always show the validity UI if the form has already tried to be submitted
|
|
|
|
* but was invalid.
|
|
|
|
*
|
|
|
|
* Otherwise, show the validity UI if the element's value has been changed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
if (mForm && mForm->HasEverTriedInvalidSubmit()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return mValueChanged;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the mutable state of the element.
|
|
|
|
*/
|
|
|
|
bool IsMutable() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns whether the current value is the empty string.
|
|
|
|
*
|
|
|
|
* @return whether the current value is the empty string.
|
|
|
|
*/
|
|
|
|
bool IsValueEmpty() const;
|
2013-11-19 23:21:29 +04:00
|
|
|
|
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-08-03 08:27:00 +03:00
|
|
|
|
2013-11-19 23:21:29 +04:00
|
|
|
private:
|
|
|
|
static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
2018-06-22 19:48:42 +03:00
|
|
|
MappedDeclarations&);
|
2013-02-19 01:18:40 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif
|