mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 23:35:18 +00:00
886c0a2723
- Bug 1215411 - Define MOZ_FALLTHROUGH annotation to suppress clang's -Wimplicit-fallthrough warnings. r=botond (5549d55e8b)
- Bug 1202794 - Explicitly clear array in SortChildrenBy3DZOrder to satisfy the move analysis, r=mattwoodrow (0c53a3db36)
- Bug 1217168 - Respect layer clip rects during plugin visibility computation. r=jimm (6289d35ff1)
- Bug 1220693 - Make mozilla::Atomic<enum class> work even on compilers that don't have <atomic>. r=froydnj (ef1b490ffd)
- Bug 947062 - Make background-position inline-style changes and CSS animations trigger layer activity. r=roc (44bc576960)
- Bug 1201330 - Refactor LayerActivity property management. r=roc (92528b8765)
- Bug 1201330 - Keep scroll handler induced layer activity active until the scroll frame becomes inactive. r=roc (08670902ec)
- Bug 1147707 - Intersect correctly in DisplayItemClip::ApplyNonRoundedIntersection. r=roc (66991b6be6)
- better attempt at 10.5 compaitbility, avoiding out-of-bounds array access (18f481ff6b)
- Bug 1217662 - part 1 - make LayerManagerUserDataDestroy a static function of LayerManager; r=mattwoodrow (f2d34451e0)
- Bug 1217662 - part 2 - move mozilla::layers::LayerUserData to a separate header; r=mattwoodrow (036d7327fa)
- Bug 1217662 - part 3 - move nsDisplayBlendContainer::GetLayerState out-of-line; r=mattwoodrow (fb2bd6bd20)
- Bug 1217662 - part 4 - move {LayerManager,Layer}::RemoveUserData out-of-line; r=mattwoodrow (86836f2a9b)
- Bug 1217662 - part 5 - move FrameLayerBuilder and helper classes's ctors/dtors out-of-line; r=mattwoodrow (e838bde0ec)
- Bug 1217662 - part 6 - remove Layers.h #include from FrameListBuilder.h; r=mattwoodrow (8aea4cb842)
- Bug 1216288 - Disable warning when we don't build an active layer for RenderFrameParent within an opacity:0 subtree. r=roc (2c5e70760a)
- Bug 1169996 - Don't lose eEditorMailMask; r=ehsan (b4647557bb)
- Bug 1211654 - Force opacity layers that were only created for APZ hit-testing information to always be inactive. r=mstange (4c56d440cf)
- Bug 1154336 - Convert nsTextEditorState::mRestoringSelection into a strong reference; r=baku (3e24a6ad18)
- Bug 549674 part.1 Commit composition string at setting value of <input> or <textarea> r=smaug (e6a6471370)
- Bug 1109410 Resolve CSS transform in ContentEventHandler::ConvertToRootViewRelativeOffset() r=roc (5ff3388f28)
- Bug 1180589 part 3 - Rename shadowed variable name; r=bholley (7194cda020)
- Bug 1222145 - Bump maximum video size to 8k. r=jya (056778dda9)
- Bug 1180589 part 1 - Add simulator code for TV Manager API; r=seanlin (dd78a38a27)
- Bug 1180589 part 2 - Add code to create a simulated mediastream; r=se# (c255e0dd07)
- spacing (856ee42504)
- missing bit of Bug 1136827 - Stop synchronously (befed33dbe)
- bit of Bug 1204401 (c1f98ed982)
- bits of 1142527 (dc39662797)
- Bug 1212220 - cache pref values so they are safe to access off the main thread. r=roc. (adb186836b)
- Bug 1194918 - Add VideoSink which contains either AudioSinkWrapper or DecodedStreamSink as a default operating MediaSink in MDSM. r=jwwang. (7ccda9b055)
- Bug 1194918 - Move av-sync and video frame rendering logic from MDSM to VideoSink. r=jwwang. (ba56ae120b)
- Bug 1202533 - Fix naming convention of MediaSink::PlaybackParams. (eed5ed3839)
- Bug 1194918 - Override function SetVolume/SetPreservesPitch in VideoSink for the contained AudioSink. r=jwwang. (0d96e6a395)
- Bug 1198663. Skip null Images in VideoSink::RenderVideoFrames instead of treating them as valid. r=jwwang (aaac235c1f)
- Bug 1207198: P2. Defer dormant request while ReadMetadata is pending in MDSM. r=sotaro (0a8e1f4bb0)
- Bug 1209850: Only attempt to initialize decoders as they are required. r=alfredo (615e41b66b)
- Bug 1192733: fix the MediaFormatReader can not back from dormant state. r=jya (c266107d33)
- Bug 1207198: P1. Do not initialize decoders during ReadMetadata. r=cpearce (4174dbc409)
- missing bit of 1196696 (7b1c0fbe95)
- Bug 1208922. Part 6 - IsWaitingOnCDMResource() is not used by MDSM anymore. Remove it from MediaDecoderReader and make it private in MediaFormatReader. r=cpearce. (db67939710)
- adapted of Bug 1208922. Part 3 - forward the CDMProxy from MediaDecoder (a5dca2f89d)
388 lines
14 KiB
C++
388 lines
14 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#ifndef mozilla_dom_HTMLTextAreaElement_h
|
|
#define mozilla_dom_HTMLTextAreaElement_h
|
|
|
|
#include "mozilla/Attributes.h"
|
|
#include "nsIDOMHTMLTextAreaElement.h"
|
|
#include "nsITextControlElement.h"
|
|
#include "nsIDOMNSEditableElement.h"
|
|
#include "nsCOMPtr.h"
|
|
#include "nsGenericHTMLElement.h"
|
|
#include "nsStubMutationObserver.h"
|
|
#include "nsIConstraintValidation.h"
|
|
#include "mozilla/dom/HTMLFormElement.h"
|
|
#include "mozilla/dom/HTMLInputElementBinding.h"
|
|
#include "nsGkAtoms.h"
|
|
|
|
#include "nsTextEditorState.h"
|
|
|
|
class nsFormSubmission;
|
|
class nsIControllers;
|
|
class nsIDocument;
|
|
class nsPresContext;
|
|
class nsPresState;
|
|
|
|
namespace mozilla {
|
|
|
|
class EventChainPostVisitor;
|
|
class EventChainPreVisitor;
|
|
class EventStates;
|
|
|
|
namespace dom {
|
|
|
|
class HTMLTextAreaElement final : public nsGenericHTMLFormElementWithState,
|
|
public nsIDOMHTMLTextAreaElement,
|
|
public nsITextControlElement,
|
|
public nsIDOMNSEditableElement,
|
|
public nsStubMutationObserver,
|
|
public nsIConstraintValidation
|
|
{
|
|
public:
|
|
using nsIConstraintValidation::GetValidationMessage;
|
|
|
|
explicit HTMLTextAreaElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
|
|
FromParser aFromParser = NOT_FROM_PARSER);
|
|
|
|
// nsISupports
|
|
NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
virtual int32_t TabIndexDefault() override;
|
|
|
|
// Element
|
|
virtual bool IsInteractiveHTMLContent(bool aIgnoreTabindex) const override
|
|
{
|
|
return true;
|
|
}
|
|
|
|
// nsIDOMHTMLTextAreaElement
|
|
NS_DECL_NSIDOMHTMLTEXTAREAELEMENT
|
|
|
|
// nsIDOMNSEditableElement
|
|
NS_IMETHOD GetEditor(nsIEditor** aEditor) override
|
|
{
|
|
return nsGenericHTMLElement::GetEditor(aEditor);
|
|
}
|
|
NS_IMETHOD SetUserInput(const nsAString& aInput) override;
|
|
|
|
// nsIFormControl
|
|
NS_IMETHOD_(uint32_t) GetType() const override { return NS_FORM_TEXTAREA; }
|
|
NS_IMETHOD Reset() override;
|
|
NS_IMETHOD SubmitNamesValues(nsFormSubmission* aFormSubmission) override;
|
|
NS_IMETHOD SaveState() override;
|
|
virtual bool RestoreState(nsPresState* aState) override;
|
|
virtual bool IsDisabledForEvents(EventMessage aMessage) override;
|
|
|
|
virtual void FieldSetDisabledChanged(bool aNotify) override;
|
|
|
|
virtual EventStates IntrinsicState() const override;
|
|
|
|
// nsITextControlElemet
|
|
NS_IMETHOD SetValueChanged(bool aValueChanged) override;
|
|
NS_IMETHOD_(bool) IsSingleLineTextControl() const override;
|
|
NS_IMETHOD_(bool) IsTextArea() const override;
|
|
NS_IMETHOD_(bool) IsPlainTextControl() 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;
|
|
NS_IMETHOD_(nsIEditor*) GetTextEditor() override;
|
|
NS_IMETHOD_(nsISelectionController*) GetSelectionController() override;
|
|
NS_IMETHOD_(nsFrameSelection*) GetConstFrameSelection() override;
|
|
NS_IMETHOD BindToFrame(nsTextControlFrame* aFrame) override;
|
|
NS_IMETHOD_(void) UnbindFromFrame(nsTextControlFrame* aFrame) override;
|
|
NS_IMETHOD CreateEditor() override;
|
|
NS_IMETHOD_(nsIContent*) GetRootEditorNode() override;
|
|
NS_IMETHOD_(Element*) CreatePlaceholderNode() override;
|
|
NS_IMETHOD_(Element*) GetPlaceholderNode() override;
|
|
NS_IMETHOD_(void) UpdatePlaceholderVisibility(bool aNotify) override;
|
|
NS_IMETHOD_(bool) GetPlaceholderVisibility() override;
|
|
NS_IMETHOD_(void) InitializeKeyboardEventListeners() override;
|
|
NS_IMETHOD_(void) OnValueChanged(bool aNotify) override;
|
|
NS_IMETHOD_(bool) HasCachedSelection() override;
|
|
|
|
// nsIContent
|
|
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
|
|
nsIContent* aBindingParent,
|
|
bool aCompileEventHandlers) override;
|
|
virtual void UnbindFromTree(bool aDeep = true,
|
|
bool aNullParent = true) override;
|
|
virtual bool ParseAttribute(int32_t aNamespaceID,
|
|
nsIAtom* aAttribute,
|
|
const nsAString& aValue,
|
|
nsAttrValue& aResult) override;
|
|
virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const override;
|
|
virtual nsChangeHint GetAttributeChangeHint(const nsIAtom* aAttribute,
|
|
int32_t aModType) const override;
|
|
NS_IMETHOD_(bool) IsAttributeMapped(const nsIAtom* aAttribute) const override;
|
|
|
|
virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) override;
|
|
virtual nsresult PostHandleEvent(
|
|
EventChainPostVisitor& aVisitor) override;
|
|
|
|
virtual bool IsHTMLFocusable(bool aWithMouse, bool *aIsFocusable, int32_t *aTabIndex) override;
|
|
|
|
virtual void DoneAddingChildren(bool aHaveNotified) override;
|
|
virtual bool IsDoneAddingChildren() override;
|
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override;
|
|
|
|
nsresult CopyInnerTo(Element* aDest);
|
|
|
|
/**
|
|
* Called when an attribute is about to be changed
|
|
*/
|
|
virtual nsresult BeforeSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
|
|
nsAttrValueOrString* aValue,
|
|
bool aNotify) override;
|
|
|
|
// nsIMutationObserver
|
|
NS_DECL_NSIMUTATIONOBSERVER_CHARACTERDATACHANGED
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
|
|
NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLTextAreaElement,
|
|
nsGenericHTMLFormElementWithState)
|
|
|
|
// nsIConstraintValidation
|
|
bool IsTooLong();
|
|
bool IsValueMissing() const;
|
|
void UpdateTooLongValidityState();
|
|
void UpdateValueMissingValidityState();
|
|
void UpdateBarredFromConstraintValidation();
|
|
nsresult GetValidationMessage(nsAString& aValidationMessage,
|
|
ValidityStateType aType) override;
|
|
|
|
// Web IDL binding methods
|
|
bool Autofocus()
|
|
{
|
|
return GetBoolAttr(nsGkAtoms::autofocus);
|
|
}
|
|
void SetAutofocus(bool aAutoFocus, ErrorResult& aError)
|
|
{
|
|
SetHTMLBoolAttr(nsGkAtoms::autofocus, aAutoFocus, aError);
|
|
}
|
|
uint32_t Cols()
|
|
{
|
|
return GetIntAttr(nsGkAtoms::cols, DEFAULT_COLS);
|
|
}
|
|
void SetCols(uint32_t aCols, ErrorResult& aError)
|
|
{
|
|
if (aCols == 0) {
|
|
aError.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
|
|
} else {
|
|
SetUnsignedIntAttr(nsGkAtoms::cols, aCols, aError);
|
|
}
|
|
}
|
|
bool Disabled()
|
|
{
|
|
return GetBoolAttr(nsGkAtoms::disabled);
|
|
}
|
|
void SetDisabled(bool aDisabled, ErrorResult& aError)
|
|
{
|
|
SetHTMLBoolAttr(nsGkAtoms::disabled, aDisabled, aError);
|
|
}
|
|
// nsGenericHTMLFormElementWithState::GetForm is fine
|
|
using nsGenericHTMLFormElementWithState::GetForm;
|
|
int32_t MaxLength()
|
|
{
|
|
return GetIntAttr(nsGkAtoms::maxlength, -1);
|
|
}
|
|
void SetMaxLength(int32_t aMaxLength, ErrorResult& aError)
|
|
{
|
|
if (aMaxLength < 0) {
|
|
aError.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
|
|
} else {
|
|
SetHTMLIntAttr(nsGkAtoms::maxlength, aMaxLength, aError);
|
|
}
|
|
}
|
|
// XPCOM GetName is fine
|
|
void SetName(const nsAString& aName, ErrorResult& aError)
|
|
{
|
|
SetHTMLAttr(nsGkAtoms::name, aName, aError);
|
|
}
|
|
// XPCOM GetPlaceholder is fine
|
|
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);
|
|
}
|
|
bool Required()
|
|
{
|
|
return GetBoolAttr(nsGkAtoms::required);
|
|
}
|
|
|
|
void SetRangeText(const nsAString& aReplacement, ErrorResult& aRv);
|
|
|
|
void SetRangeText(const nsAString& aReplacement, uint32_t aStart,
|
|
uint32_t aEnd, const SelectionMode& aSelectMode,
|
|
ErrorResult& aRv, int32_t aSelectionStart = -1,
|
|
int32_t aSelectionEnd = -1);
|
|
|
|
void SetRequired(bool aRequired, ErrorResult& aError)
|
|
{
|
|
SetHTMLBoolAttr(nsGkAtoms::required, aRequired, aError);
|
|
}
|
|
uint32_t Rows()
|
|
{
|
|
return GetIntAttr(nsGkAtoms::rows, DEFAULT_ROWS_TEXTAREA);
|
|
}
|
|
void SetRows(uint32_t aRows, ErrorResult& aError)
|
|
{
|
|
if (aRows == 0) {
|
|
aError.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
|
|
} else {
|
|
SetUnsignedIntAttr(nsGkAtoms::rows, aRows, aError);
|
|
}
|
|
}
|
|
// XPCOM GetWrap is fine
|
|
void SetWrap(const nsAString& aWrap, ErrorResult& aError)
|
|
{
|
|
SetHTMLAttr(nsGkAtoms::wrap, aWrap, aError);
|
|
}
|
|
// XPCOM GetType is fine
|
|
// XPCOM GetDefaultValue is fine
|
|
void SetDefaultValue(const nsAString& aDefaultValue, ErrorResult& aError);
|
|
// XPCOM GetValue/SetValue are fine
|
|
uint32_t GetTextLength();
|
|
// nsIConstraintValidation::WillValidate is fine.
|
|
// nsIConstraintValidation::Validity() is fine.
|
|
// nsIConstraintValidation::GetValidationMessage() is fine.
|
|
// nsIConstraintValidation::CheckValidity() is fine.
|
|
using nsIConstraintValidation::CheckValidity;
|
|
// nsIConstraintValidation::SetCustomValidity() is fine.
|
|
// XPCOM Select is fine
|
|
uint32_t GetSelectionStart(ErrorResult& aError);
|
|
void SetSelectionStart(uint32_t aSelectionStart, ErrorResult& aError);
|
|
uint32_t GetSelectionEnd(ErrorResult& aError);
|
|
void SetSelectionEnd(uint32_t aSelectionEnd, ErrorResult& aError);
|
|
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);
|
|
nsIEditor* GetEditor()
|
|
{
|
|
return mState.GetEditor();
|
|
}
|
|
|
|
protected:
|
|
virtual ~HTMLTextAreaElement() {}
|
|
|
|
// get rid of the compiler warning
|
|
using nsGenericHTMLFormElementWithState::IsSingleLineTextControl;
|
|
|
|
virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
|
|
|
|
nsCOMPtr<nsIControllers> mControllers;
|
|
/** Whether or not the value has changed since its default value was given. */
|
|
bool mValueChanged;
|
|
/** 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;
|
|
|
|
void FireChangeEventIfNeeded();
|
|
|
|
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;
|
|
|
|
/**
|
|
* Setting the value.
|
|
*
|
|
* @param aValue String to set.
|
|
* @param aFlags See nsTextEditorState::SetValueFlags.
|
|
*/
|
|
nsresult SetValueInternal(const nsAString& aValue, uint32_t aFlags);
|
|
|
|
nsresult GetSelectionRange(int32_t* aSelectionStart, int32_t* aSelectionEnd);
|
|
|
|
/**
|
|
* 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);
|
|
|
|
virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsIAtom *aName,
|
|
const nsAttrValue* aValue, bool aNotify) override;
|
|
|
|
/**
|
|
* 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;
|
|
|
|
private:
|
|
static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
|
nsRuleData* aData);
|
|
};
|
|
|
|
} // namespace dom
|
|
} // namespace mozilla
|
|
|
|
#endif
|
|
|