Source code

Revision control

Copy as Markdown

Other Tools

/* -*- 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/. */
/*
* Base class for all element classes; this provides an implementation
* of DOM Core's Element, implements nsIContent, provides
* utility methods for subclasses, and so forth.
*/
#ifndef mozilla_dom_Element_h__
#define mozilla_dom_Element_h__
#include <cstdio>
#include <cstdint>
#include <cstdlib>
#include <utility>
#include "AttrArray.h"
#include "ErrorList.h"
#include "Units.h"
#include "js/RootingAPI.h"
#include "mozilla/AlreadyAddRefed.h"
#include "mozilla/Assertions.h"
#include "mozilla/Attributes.h"
#include "mozilla/BasicEvents.h"
#include "mozilla/CORSMode.h"
#include "mozilla/FlushType.h"
#include "mozilla/Maybe.h"
#include "mozilla/PseudoStyleType.h"
#include "mozilla/RefPtr.h"
#include "mozilla/Result.h"
#include "mozilla/RustCell.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/dom/BorrowedAttrInfo.h"
#include "mozilla/dom/DOMString.h"
#include "mozilla/dom/DOMTokenListSupportedTokens.h"
#include "mozilla/dom/DirectionalityUtils.h"
#include "mozilla/dom/FragmentOrElement.h"
#include "mozilla/dom/NameSpaceConstants.h"
#include "mozilla/dom/NodeInfo.h"
#include "mozilla/dom/RustTypes.h"
#include "mozilla/dom/ShadowRootBinding.h"
#include "nsAtom.h"
#include "nsAttrValue.h"
#include "nsAttrValueInlines.h"
#include "nsCaseTreatment.h"
#include "nsChangeHint.h"
#include "nsTHashMap.h"
#include "nsDebug.h"
#include "nsError.h"
#include "nsGkAtoms.h"
#include "nsHashKeys.h"
#include "nsIContent.h"
#include "nsID.h"
#include "nsINode.h"
#include "nsLiteralString.h"
#include "nsRect.h"
#include "nsString.h"
#include "nsStringFlags.h"
#include "nsTLiteralString.h"
#include "nscore.h"
class JSObject;
class mozAutoDocUpdate;
class nsAttrName;
class nsAttrValueOrString;
class nsContentList;
class nsDOMAttributeMap;
class nsDOMCSSAttributeDeclaration;
class nsDOMStringMap;
class nsDOMTokenList;
class nsFocusManager;
class nsGenericHTMLFormControlElementWithState;
class nsGlobalWindowInner;
class nsGlobalWindowOuter;
class nsImageLoadingContent;
class nsIAutoCompletePopup;
class nsIBrowser;
class nsIDOMXULButtonElement;
class nsIDOMXULContainerElement;
class nsIDOMXULContainerItemElement;
class nsIDOMXULControlElement;
class nsIDOMXULMenuListElement;
class nsIDOMXULMultiSelectControlElement;
class nsIDOMXULRadioGroupElement;
class nsIDOMXULRelatedElement;
class nsIDOMXULSelectControlElement;
class nsIDOMXULSelectControlItemElement;
class nsIFrame;
class nsIHTMLCollection;
class nsIPrincipal;
class nsIScreen;
class nsIURI;
class nsObjectLoadingContent;
class nsPresContext;
class nsWindowSizes;
struct JSContext;
struct ServoNodeData;
template <class E>
class nsTArray;
template <class T>
class nsGetterAddRefs;
namespace mozilla {
class DeclarationBlock;
class MappedDeclarationsBuilder;
class EditorBase;
class ErrorResult;
class OOMReporter;
class ScrollContainerFrame;
class SMILAttr;
struct MutationClosureData;
class TextEditor;
namespace css {
struct URLValue;
} // namespace css
namespace dom {
struct CheckVisibilityOptions;
struct CustomElementData;
struct SetHTMLOptions;
struct GetHTMLOptions;
struct GetAnimationsOptions;
struct ScrollIntoViewOptions;
struct ScrollToOptions;
struct FocusOptions;
struct ShadowRootInit;
struct ScrollOptions;
class Attr;
class BooleanOrScrollIntoViewOptions;
class Document;
class HTMLFormElement;
class DOMIntersectionObserver;
class DOMMatrixReadOnly;
class Element;
class ElementOrCSSPseudoElement;
class PopoverData;
class Promise;
class Sanitizer;
class ShadowRoot;
class TrustedHTMLOrString;
class UnrestrictedDoubleOrKeyframeAnimationOptions;
template <typename T>
class Optional;
enum class CallerType : uint32_t;
enum class ReferrerPolicy : uint8_t;
} // namespace dom
} // namespace mozilla
using nsMapRuleToAttributesFunc = void (*)(mozilla::MappedDeclarationsBuilder&);
// Declared here because of include hell.
extern "C" bool Servo_Element_IsDisplayContents(const mozilla::dom::Element*);
already_AddRefed<nsContentList> NS_GetContentList(nsINode* aRootNode,
int32_t aMatchNameSpaceId,
const nsAString& aTagname);
#define ELEMENT_FLAG_BIT(n_) \
NODE_FLAG_BIT(NODE_TYPE_SPECIFIC_BITS_OFFSET + (n_))
// Element-specific flags
enum : uint32_t {
// Whether this node has dirty descendants for Servo's style system.
ELEMENT_HAS_DIRTY_DESCENDANTS_FOR_SERVO = ELEMENT_FLAG_BIT(0),
// Whether this node has dirty descendants for animation-only restyle for
// Servo's style system.
ELEMENT_HAS_ANIMATION_ONLY_DIRTY_DESCENDANTS_FOR_SERVO = ELEMENT_FLAG_BIT(1),
// Whether the element has been snapshotted due to attribute or state changes
// by the Servo restyle manager.
ELEMENT_HAS_SNAPSHOT = ELEMENT_FLAG_BIT(2),
// Whether the element has already handled its relevant snapshot.
//
// Used by the servo restyle process in order to accurately track whether the
// style of an element is up-to-date, even during the same restyle process.
ELEMENT_HANDLED_SNAPSHOT = ELEMENT_FLAG_BIT(3),
// If this flag is set on an element, that means that it is a HTML datalist
// element or has a HTML datalist element ancestor.
ELEMENT_IS_DATALIST_OR_HAS_DATALIST_ANCESTOR = ELEMENT_FLAG_BIT(4),
// If this flag is set on an element, that means this element
// has been considered by our LargestContentfulPaint algorithm and
// it's not going to be considered again.
ELEMENT_PROCESSED_BY_LCP_FOR_TEXT = ELEMENT_FLAG_BIT(5),
// If this flag is set on an element, this means the HTML parser encountered
// a duplicate attribute error:
// This flag is used for detecting dangling markup attacks in the CSP
ELEMENT_PARSER_HAD_DUPLICATE_ATTR_ERROR = ELEMENT_FLAG_BIT(6),
// If this flag is set, this element is in
// Document::mContentIdentifiersForLCP.
ELEMENT_IN_CONTENT_IDENTIFIER_FOR_LCP = ELEMENT_FLAG_BIT(7),
// Remaining bits are for subclasses
ELEMENT_TYPE_SPECIFIC_BITS_OFFSET = NODE_TYPE_SPECIFIC_BITS_OFFSET + 8
};
#undef ELEMENT_FLAG_BIT
// Make sure we have space for our bits
ASSERT_NODE_FLAGS_SPACE(ELEMENT_TYPE_SPECIFIC_BITS_OFFSET);
namespace mozilla {
enum class PseudoStyleType : uint8_t;
class EventChainPostVisitor;
class EventChainPreVisitor;
class EventChainVisitor;
class EventListenerManager;
class EventStateManager;
enum class ContentEditableState {
Inherit,
False,
True,
PlainTextOnly,
};
namespace dom {
struct CustomElementDefinition;
class Animation;
class CustomElementRegistry;
class Link;
class DOMRect;
class DOMRectList;
class Flex;
class Grid;
class OwningTrustedHTMLOrNullIsEmptyString;
class TrustedHTML;
class TrustedHTMLOrNullIsEmptyString;
// IID for the dom::Element interface
#define NS_ELEMENT_IID \
{ \
0xc67ed254, 0xfd3b, 0x4b10, { \
0x96, 0xa2, 0xc5, 0x8b, 0x7b, 0x64, 0x97, 0xd1 \
} \
}
#define REFLECT_NULLABLE_DOMSTRING_ATTR(method, attr) \
void Get##method(nsAString& aValue) const { \
const nsAttrValue* val = mAttrs.GetAttr(nsGkAtoms::attr); \
if (!val) { \
SetDOMStringToNull(aValue); \
return; \
} \
val->ToString(aValue); \
} \
void Set##method(const nsAString& aValue, ErrorResult& aRv) { \
SetOrRemoveNullableStringAttr(nsGkAtoms::attr, aValue, aRv); \
}
#define REFLECT_NULLABLE_ELEMENT_ATTR(method, attr) \
Element* Get##method() const { \
return GetAttrAssociatedElement(nsGkAtoms::attr); \
} \
\
void Set##method(Element* aElement) { \
ExplicitlySetAttrElement(nsGkAtoms::attr, aElement); \
}
// TODO(keithamus): Reference the spec link once merged.
enum class InvokeAction : uint8_t {
Invalid,
Custom,
Auto,
TogglePopover,
ShowPopover,
HidePopover,
ShowModal,
Toggle,
Close,
Open,
};
class Element : public FragmentOrElement {
public:
#ifdef MOZILLA_INTERNAL_API
explicit Element(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
: FragmentOrElement(std::move(aNodeInfo)),
mState(ElementState::READONLY | ElementState::DEFINED |
ElementState::LTR) {
MOZ_ASSERT(mNodeInfo->NodeType() == ELEMENT_NODE,
"Bad NodeType in aNodeInfo");
SetIsElement();
}
~Element() {
NS_ASSERTION(!HasServoData(), "expected ServoData to be cleared earlier");
}
#endif // MOZILLA_INTERNAL_API
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ELEMENT_IID)
NS_DECL_ADDSIZEOFEXCLUDINGTHIS
NS_IMPL_FROMNODE_HELPER(Element, IsElement())
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
/**
* Method to get the full state of this element. See dom/base/rust/lib.rs for
* the possible bits that could be set here.
*/
ElementState State() const { return mState; }
/**
* Returns the current disabled state of the element.
*/
bool IsDisabled() const { return State().HasState(ElementState::DISABLED); }
bool IsReadOnly() const { return State().HasState(ElementState::READONLY); }
bool IsDisabledOrReadOnly() const {
return State().HasAtLeastOneOfStates(ElementState::DISABLED |
ElementState::READONLY);
}
/**
* Return true if this element has contenteditable="plaintext-only".
*/
[[nodiscard]] inline bool IsContentEditablePlainTextOnly() const;
virtual int32_t TabIndexDefault() { return -1; }
/**
* Get tabIndex of this element. If not found, return TabIndexDefault.
*/
int32_t TabIndex();
/**
* Get the parsed value of tabindex attribute.
*/
Maybe<int32_t> GetTabIndexAttrValue();
/**
* Set tabIndex value to this element.
*/
void SetTabIndex(int32_t aTabIndex, mozilla::ErrorResult& aError);
/**
* Sets the ShadowRoot binding for this element. The contents of the
* binding is rendered in place of this node's children.
*
* @param aShadowRoot The ShadowRoot to be bound to this element.
*/
void SetShadowRoot(ShadowRoot* aShadowRoot);
void SetLastRememberedBSize(float aBSize);
void SetLastRememberedISize(float aISize);
void RemoveLastRememberedBSize();
void RemoveLastRememberedISize();
/**
* Make focus on this element.
*/
// TODO: Convert Focus() to MOZ_CAN_RUN_SCRIPT and get rid of the
// kungFuDeathGrip in it.
MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual void Focus(const FocusOptions& aOptions,
const CallerType aCallerType,
ErrorResult& aError);
/**
* Show blur and clear focus.
*/
MOZ_CAN_RUN_SCRIPT_BOUNDARY virtual void Blur(mozilla::ErrorResult& aError);
/**
* The style state of this element. This is the real state of the element
* with any style locks applied for pseudo-class inspecting.
*/
ElementState StyleState() const {
if (!HasLockedStyleStates()) {
return mState;
}
return StyleStateFromLocks();
}
/**
* StyleStateLocks is used to specify which event states should be locked,
* and whether they should be locked to on or off.
*/
struct StyleStateLocks {
// mLocks tracks which event states should be locked.
ElementState mLocks;
// mValues tracks if the locked state should be on or off.
ElementState mValues;
};
/**
* The style state locks applied to this element.
*/
StyleStateLocks LockedStyleStates() const;
/**
* Add a style state lock on this element.
* aEnabled is the value to lock the given state bits to.
*/
void LockStyleStates(ElementState aStates, bool aEnabled);
/**
* Remove a style state lock on this element.
*/
void UnlockStyleStates(ElementState aStates);
/**
* Clear all style state locks on this element.
*/
void ClearStyleStateLocks();
/**
* Accessors for the state of our dir attribute.
*/
bool HasDirAuto() const {
return State().HasState(ElementState::HAS_DIR_ATTR_LIKE_AUTO);
}
/**
* Elements with dir="rtl" or dir="ltr".
*/
bool HasFixedDir() const {
return State().HasAtLeastOneOfStates(ElementState::HAS_DIR_ATTR_LTR |
ElementState::HAS_DIR_ATTR_RTL);
}
/**
* Get the inline style declaration, if any, for this element.
*/
DeclarationBlock* GetInlineStyleDeclaration() const;
/**
* Get the mapped attributes, if any, for this element.
*/
StyleLockedDeclarationBlock* GetMappedAttributeStyle() const {
return mAttrs.GetMappedDeclarationBlock();
}
bool IsPendingMappedAttributeEvaluation() const {
return mAttrs.IsPendingMappedAttributeEvaluation();
}
void SetMappedDeclarationBlock(already_AddRefed<StyleLockedDeclarationBlock>);
/**
* InlineStyleDeclarationWillChange is called before SetInlineStyleDeclaration
* so that the element implementation can access the old style attribute
* value.
*/
virtual void InlineStyleDeclarationWillChange(MutationClosureData& aData);
/**
* Set the inline style declaration for this element.
*/
virtual nsresult SetInlineStyleDeclaration(DeclarationBlock& aDeclaration,
MutationClosureData& aData);
/**
* Get the SMIL override style declaration for this element. If the
* rule hasn't been created, this method simply returns null.
*/
DeclarationBlock* GetSMILOverrideStyleDeclaration();
/**
* Set the SMIL override style declaration for this element. This method will
* notify the document's pres context, so that the style changes will be
* noticed.
*/
void SetSMILOverrideStyleDeclaration(DeclarationBlock&);
/**
* Returns a new SMILAttr that allows the caller to animate the given
* attribute on this element.
*/
virtual UniquePtr<SMILAttr> GetAnimatedAttr(int32_t aNamespaceID,
nsAtom* aName);
/**
* Get the SMIL override style for this element. This is a style declaration
* that is applied *after* the inline style, and it can be used e.g. to store
* animated style values.
*
* Note: This method is analogous to the 'GetStyle' method in
* nsGenericHTMLElement and nsStyledElement.
*/
nsDOMCSSAttributeDeclaration* SMILOverrideStyle();
/**
* Returns if the element is labelable as per HTML specification.
*/
virtual bool IsLabelable() const;
/**
* Returns if the element is interactive content as per HTML specification.
*/
virtual bool IsInteractiveHTMLContent() const;
/**
* Is the attribute named aAttribute a mapped attribute?
*/
NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const;
nsresult BindToTree(BindContext&, nsINode& aParent) override;
void UnbindFromTree(UnbindContext&) override;
using nsIContent::UnbindFromTree;
virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
static void MapNoAttributesInto(mozilla::MappedDeclarationsBuilder&);
/**
* Get a hint that tells the style system what to do when
* an attribute on this node changes, if something needs to happen
* in response to the change *other* than the result of what is
* mapped into style data via any type of style rule.
*/
virtual nsChangeHint GetAttributeChangeHint(const nsAtom* aAttribute,
int32_t aModType) const;
inline Directionality GetDirectionality() const {
ElementState state = State();
if (state.HasState(ElementState::RTL)) {
return Directionality::Rtl;
}
if (state.HasState(ElementState::LTR)) {
return Directionality::Ltr;
}
return Directionality::Unset;
}
inline void SetDirectionality(Directionality aDir, bool aNotify) {
AutoStateChangeNotifier notifier(*this, aNotify);
RemoveStatesSilently(ElementState::DIR_STATES);
switch (aDir) {
case Directionality::Rtl:
AddStatesSilently(ElementState::RTL);
break;
case Directionality::Ltr:
AddStatesSilently(ElementState::LTR);
break;
case Directionality::Unset:
case Directionality::Auto:
MOZ_ASSERT_UNREACHABLE("Setting unresolved directionality?");
break;
}
}
Directionality GetComputedDirectionality() const;
static const uint32_t kAllServoDescendantBits =
ELEMENT_HAS_DIRTY_DESCENDANTS_FOR_SERVO |
ELEMENT_HAS_ANIMATION_ONLY_DIRTY_DESCENDANTS_FOR_SERVO |
NODE_DESCENDANTS_NEED_FRAMES;
/**
* Notes that something in the given subtree of this element needs dirtying,
* and that all the relevant dirty bits have already been propagated up to the
* element.
*
* This is important because `NoteDirtyForServo` uses the dirty bits to reason
* about the shape of the tree, so we can't just call into there.
*/
void NoteDirtySubtreeForServo();
void NoteDirtyForServo();
void NoteAnimationOnlyDirtyForServo();
void NoteDescendantsNeedFramesForServo();
bool HasDirtyDescendantsForServo() const {
return HasFlag(ELEMENT_HAS_DIRTY_DESCENDANTS_FOR_SERVO);
}
void SetHasDirtyDescendantsForServo() {
SetFlags(ELEMENT_HAS_DIRTY_DESCENDANTS_FOR_SERVO);
}
void UnsetHasDirtyDescendantsForServo() {
UnsetFlags(ELEMENT_HAS_DIRTY_DESCENDANTS_FOR_SERVO);
}
bool HasAnimationOnlyDirtyDescendantsForServo() const {
return HasFlag(ELEMENT_HAS_ANIMATION_ONLY_DIRTY_DESCENDANTS_FOR_SERVO);
}
void SetHasAnimationOnlyDirtyDescendantsForServo() {
SetFlags(ELEMENT_HAS_ANIMATION_ONLY_DIRTY_DESCENDANTS_FOR_SERVO);
}
void UnsetHasAnimationOnlyDirtyDescendantsForServo() {
UnsetFlags(ELEMENT_HAS_ANIMATION_ONLY_DIRTY_DESCENDANTS_FOR_SERVO);
}
bool HasServoData() const { return !!mServoData.Get(); }
void ClearServoData() { ClearServoData(GetComposedDoc()); }
void ClearServoData(Document* aDocument);
PopoverData* GetPopoverData() const {
const nsExtendedDOMSlots* slots = GetExistingExtendedDOMSlots();
return slots ? slots->mPopoverData.get() : nullptr;
}
PopoverData& EnsurePopoverData() {
if (auto* popoverData = GetPopoverData()) {
return *popoverData;
}
return CreatePopoverData();
}
bool IsAutoPopover() const;
bool IsPopoverOpen() const;
/**
*/
Element* GetTopmostPopoverAncestor(const Element* aInvoker,
bool isPopover) const;
ElementAnimationData* GetAnimationData() const {
if (!MayHaveAnimations()) {
return nullptr;
}
const nsExtendedDOMSlots* slots = GetExistingExtendedDOMSlots();
return slots ? slots->mAnimations.get() : nullptr;
}
ElementAnimationData& EnsureAnimationData() {
if (auto* anim = GetAnimationData()) {
return *anim;
}
return CreateAnimationData();
}
private:
ElementAnimationData& CreateAnimationData();
PopoverData& CreatePopoverData();
public:
void ClearPopoverData();
/**
* Gets the custom element data used by web components custom element.
* Custom element data is created at the first attempt to enqueue a callback.
*
* @return The custom element data or null if none.
*/
CustomElementData* GetCustomElementData() const {
if (!HasCustomElementData()) {
return nullptr;
}
const nsExtendedDOMSlots* slots = GetExistingExtendedDOMSlots();
return slots ? slots->mCustomElementData.get() : nullptr;
}
/**
* Sets the custom element data, ownership of the
* callback data is taken by this element.
*
* @param aData The custom element data.
*/
void SetCustomElementData(UniquePtr<CustomElementData> aData);
nsTArray<RefPtr<nsAtom>>& EnsureCustomStates();
/**
* Gets the custom element definition used by web components custom element.
*
* @return The custom element definition or null if element is not a custom
* element or custom element is not defined yet.
*/
CustomElementDefinition* GetCustomElementDefinition() const;
/**
* Sets the custom element definition, called when custom element is created
* or upgraded.
*
* @param aDefinition The custom element definition.
*/
virtual void SetCustomElementDefinition(CustomElementDefinition* aDefinition);
const AttrArray& GetAttrs() const { return mAttrs; }
void SetDefined(bool aSet) { SetStates(ElementState::DEFINED, aSet); }
// AccessibilityRole
REFLECT_NULLABLE_DOMSTRING_ATTR(Role, role)
// AriaAttributes
REFLECT_NULLABLE_ELEMENT_ATTR(AriaActiveDescendantElement,
aria_activedescendant)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaAtomic, aria_atomic)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaAutoComplete, aria_autocomplete)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaBrailleLabel, aria_braillelabel)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaBrailleRoleDescription,
aria_brailleroledescription)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaBusy, aria_busy)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaChecked, aria_checked)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaColCount, aria_colcount)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaColIndex, aria_colindex)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaColIndexText, aria_colindextext)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaColSpan, aria_colspan)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaCurrent, aria_current)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaDescription, aria_description)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaDisabled, aria_disabled)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaExpanded, aria_expanded)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaHasPopup, aria_haspopup)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaHidden, aria_hidden)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaInvalid, aria_invalid)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaKeyShortcuts, aria_keyshortcuts)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaLabel, aria_label)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaLevel, aria_level)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaLive, aria_live)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaModal, aria_modal)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaMultiLine, aria_multiline)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaMultiSelectable, aria_multiselectable)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaOrientation, aria_orientation)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaPlaceholder, aria_placeholder)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaPosInSet, aria_posinset)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaPressed, aria_pressed)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaReadOnly, aria_readonly)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaRelevant, aria_relevant)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaRequired, aria_required)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaRoleDescription, aria_roledescription)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaRowCount, aria_rowcount)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaRowIndex, aria_rowindex)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaRowIndexText, aria_rowindextext)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaRowSpan, aria_rowspan)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaSelected, aria_selected)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaSetSize, aria_setsize)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaSort, aria_sort)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaValueMax, aria_valuemax)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaValueMin, aria_valuemin)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaValueNow, aria_valuenow)
REFLECT_NULLABLE_DOMSTRING_ATTR(AriaValueText, aria_valuetext)
protected:
already_AddRefed<ShadowRoot> AttachShadowInternal(ShadowRootMode,
ErrorResult& aError);
public:
MOZ_CAN_RUN_SCRIPT
ScrollContainerFrame* GetScrollContainerFrame(
nsIFrame** aFrame = nullptr, FlushType aFlushType = FlushType::Layout);
private:
// Style state computed from element's state and style locks.
ElementState StyleStateFromLocks() const;
void NotifyStateChange(ElementState aStates);
void NotifyStyleStateChange(ElementState aStates);
public:
struct AutoStateChangeNotifier {
AutoStateChangeNotifier(Element& aElement, bool aNotify)
: mElement(aElement), mOldState(aElement.State()), mNotify(aNotify) {}
~AutoStateChangeNotifier() {
if (!mNotify) {
return;
}
ElementState newState = mElement.State();
if (mOldState != newState) {
mElement.NotifyStateChange(mOldState ^ newState);
}
}
private:
Element& mElement;
const ElementState mOldState;
const bool mNotify;
};
// Method to add state bits. This should be called from subclass constructors
// to set up our event state correctly at construction time, and other places
// where we don't want to notify a state change, or there's an
// AutoStateChangeNotifier on the stack.
void AddStatesSilently(ElementState aStates) { mState |= aStates; }
// Method to remove state bits. This should be called from subclass
// constructors to set up our event state correctly at construction time and
// other places where we don't want to notify a state change.
void RemoveStatesSilently(ElementState aStates) { mState &= ~aStates; }
// Methods to add state bits, potentially notifying. These will handle setting
// up script blockers when they notify, so no need to do it in the callers
// unless desired. States passed here must only be those in
// EXTERNALLY_MANAGED_STATES.
void AddStates(ElementState aStates, bool aNotify = true) {
ElementState old = mState;
AddStatesSilently(aStates);
if (aNotify && old != mState) {
NotifyStateChange(old ^ mState);
}
}
void RemoveStates(ElementState aStates, bool aNotify = true) {
ElementState old = mState;
RemoveStatesSilently(aStates);
if (aNotify && old != mState) {
NotifyStateChange(old ^ mState);
}
}
void SetStates(ElementState aStates, bool aSet, bool aNotify = true) {
if (aSet) {
AddStates(aStates, aNotify);
} else {
RemoveStates(aStates, aNotify);
}
}
void ToggleStates(ElementState aStates, bool aNotify) {
mState ^= aStates;
if (aNotify) {
NotifyStateChange(aStates);
}
}
void UpdateEditableState(bool aNotify) override;
// Makes sure that the READONLY/READWRITE flags are in sync.
void UpdateReadOnlyState(bool aNotify);
// Form controls and non-form controls should have different :read-only /
// :read-write behavior. This is what effectively controls it.
virtual bool IsReadOnlyInternal() const;
/**
* Normalizes an attribute name and returns it as a nodeinfo if an attribute
* with that name exists. This method is intended for character case
* conversion if the content object is case insensitive (e.g. HTML). Returns
* the nodeinfo of the attribute with the specified name if one exists or
* null otherwise.
*
* @param aStr the unparsed attribute string
* @return the node info. May be nullptr.
*/
already_AddRefed<mozilla::dom::NodeInfo> GetExistingAttrNameFromQName(
const nsAString& aStr) const;
/**
* Helper for SetAttr/SetParsedAttr. This method will return true if aNotify
* is true or there are mutation listeners that must be triggered, the
* attribute is currently set, and the new value that is about to be set is
* different to the current value. As a perf optimization the new and old
* values will not actually be compared if we aren't notifying and we don't
* have mutation listeners (in which case it's cheap to just return false
* and let the caller go ahead and set the value).
* @param aOldValue [out] Set to the old value of the attribute, but only if
* there are event listeners. If set, the type of aOldValue will be either
* nsAttrValue::eString or nsAttrValue::eAtom.
* @param aModType [out] Set to MutationEvent_Binding::MODIFICATION or to
* MutationEvent_Binding::ADDITION, but only if this helper returns true
* @param aHasListeners [out] Set to true if there are mutation event
* listeners listening for NS_EVENT_BITS_MUTATION_ATTRMODIFIED
* @param aOldValueSet [out] Indicates whether an old attribute value has been
* stored in aOldValue. The bool will be set to true if a value was stored.
*/
bool MaybeCheckSameAttrVal(int32_t aNamespaceID, const nsAtom* aName,
const nsAtom* aPrefix,
const nsAttrValueOrString& aValue, bool aNotify,
nsAttrValue& aOldValue, uint8_t* aModType,
bool* aHasListeners, bool* aOldValueSet);
/**
* Notifies mutation listeners if aNotify is true, there are mutation
* listeners, and the attribute value is changing.
*
* @param aNamespaceID The namespace of the attribute
* @param aName The local name of the attribute
* @param aPrefix The prefix of the attribute
* @param aValue The value that the attribute is being changed to
* @param aNotify If true, mutation listeners will be notified if they exist
* and the attribute value is changing
* @param aOldValue [out] Set to the old value of the attribute, but only if
* there are event listeners. If set, the type of aOldValue will be either
* nsAttrValue::eString or nsAttrValue::eAtom.
* @param aModType [out] Set to MutationEvent_Binding::MODIFICATION or to
* MutationEvent_Binding::ADDITION, but only if this helper returns true
* @param aHasListeners [out] Set to true if there are mutation event
* listeners listening for NS_EVENT_BITS_MUTATION_ATTRMODIFIED
* @param aOldValueSet [out] Indicates whether an old attribute value has been
* stored in aOldValue. The bool will be set to true if a value was stored.
*/
bool OnlyNotifySameValueSet(int32_t aNamespaceID, nsAtom* aName,
nsAtom* aPrefix,
const nsAttrValueOrString& aValue, bool aNotify,
nsAttrValue& aOldValue, uint8_t* aModType,
bool* aHasListeners, bool* aOldValueSet);
/**
* Sets the class attribute.
* Assumes that we are not notifying and that the attribute hasn't been
* set previously.
*/
nsresult SetClassAttrFromParser(nsAtom* aValue);
// aParsedValue receives the old value of the attribute. That's useful if
// either the input or output value of aParsedValue is StoresOwnData.
nsresult SetParsedAttr(int32_t aNameSpaceID, nsAtom* aName, nsAtom* aPrefix,
nsAttrValue& aParsedValue, bool aNotify);
/**
* Get the current value of the attribute. This returns a form that is
* suitable for passing back into SetAttr.
*
* @param aNameSpaceID the namespace of the attr (defaults to
kNameSpaceID_None in the overload that omits this arg)
* @param aName the name of the attr
* @param aResult the value (may legitimately be the empty string) [OUT]
* @returns true if the attribute was set (even when set to empty string)
* false when not set.
* GetAttr is not inlined on purpose, to keep down codesize from all the
* inlined nsAttrValue bits for C++ callers.
*/
bool GetAttr(int32_t aNameSpaceID, const nsAtom* aName,
nsAString& aResult) const;
bool GetAttr(const nsAtom* aName, nsAString& aResult) const;
/**
* Determine if an attribute has been set (empty string or otherwise).
*
* @param aNameSpaceId the namespace id of the attribute (defaults to
kNameSpaceID_None in the overload that omits this arg)
* @param aAttr the attribute name
* @return whether an attribute exists
*/
inline bool HasAttr(int32_t aNameSpaceID, const nsAtom* aName) const {
return mAttrs.HasAttr(aNameSpaceID, aName);
}
bool HasAttr(const nsAtom* aAttr) const { return mAttrs.HasAttr(aAttr); }
/**
* Determine if an attribute has been set to a non-empty string value. If the
* attribute is not set at all, this will return false.
*
* @param aNameSpaceId the namespace id of the attribute (defaults to
* kNameSpaceID_None in the overload that omits this arg)
* @param aAttr the attribute name
*/
inline bool HasNonEmptyAttr(int32_t aNameSpaceID, const nsAtom* aName) const;
bool HasNonEmptyAttr(const nsAtom* aAttr) const {
return HasNonEmptyAttr(kNameSpaceID_None, aAttr);
}
/**
* Test whether this Element's given attribute has the given value. If the
* attribute is not set at all, this will return false.
*
* @param aNameSpaceID The namespace ID of the attribute. Must not
* be kNameSpaceID_Unknown.
* @param aName The name atom of the attribute. Must not be null.
* @param aValue The value to compare to.
* @param aCaseSensitive Whether to do a case-sensitive compare on the value.
*/
inline bool AttrValueIs(int32_t aNameSpaceID, const nsAtom* aName,
const nsAString& aValue,
nsCaseTreatment aCaseSensitive) const;
/**
* Test whether this Element's given attribute has the given value. If the
* attribute is not set at all, this will return false.
*
* @param aNameSpaceID The namespace ID of the attribute. Must not
* be kNameSpaceID_Unknown.
* @param aName The name atom of the attribute. Must not be null.
* @param aValue The value to compare to. Must not be null.
* @param aCaseSensitive Whether to do a case-sensitive compare on the value.
*/
bool AttrValueIs(int32_t aNameSpaceID, const nsAtom* aName,
const nsAtom* aValue, nsCaseTreatment aCaseSensitive) const;
/**
* Check whether this Element's given attribute has one of a given list of
* values. If there is a match, we return the index in the list of the first
* matching value. If there was no attribute at all, then we return
* ATTR_MISSING. If there was an attribute but it didn't match, we return
* ATTR_VALUE_NO_MATCH. A non-negative result always indicates a match.
*
* @param aNameSpaceID The namespace ID of the attribute. Must not
* be kNameSpaceID_Unknown.
* @param aName The name atom of the attribute. Must not be null.
* @param aValues a nullptr-terminated array of pointers to atom values to
* test against.
* @param aCaseSensitive Whether to do a case-sensitive compare on the values.
* @return ATTR_MISSING, ATTR_VALUE_NO_MATCH or the non-negative index
* indicating the first value of aValues that matched
*/
using AttrValuesArray = AttrArray::AttrValuesArray;
int32_t FindAttrValueIn(int32_t aNameSpaceID, const nsAtom* aName,
AttrArray::AttrValuesArray* aValues,
nsCaseTreatment aCaseSensitive) const;
/**
* Set attribute values. All attribute values are assumed to have a
* canonical string representation that can be used for these
* methods. The SetAttr method is assumed to perform a translation
* of the canonical form into the underlying content specific
* form.
*
* @param aNameSpaceID the namespace of the attribute
* @param aName the name of the attribute
* @param aValue the value to set
* @param aNotify specifies how whether or not the document should be
* notified of the attribute change.
*/
nsresult SetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAString& aValue,
bool aNotify) {
return SetAttr(aNameSpaceID, aName, nullptr, aValue, aNotify);
}
nsresult SetAttr(int32_t aNameSpaceID, nsAtom* aName, nsAtom* aPrefix,
const nsAString& aValue, bool aNotify) {
return SetAttr(aNameSpaceID, aName, aPrefix, aValue, nullptr, aNotify);
}
nsresult SetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAString& aValue,
nsIPrincipal* aTriggeringPrincipal, bool aNotify) {
return SetAttr(aNameSpaceID, aName, nullptr, aValue, aTriggeringPrincipal,
aNotify);
}
/**
* Set attribute values. All attribute values are assumed to have a
* canonical String representation that can be used for these
* methods. The SetAttr method is assumed to perform a translation
* of the canonical form into the underlying content specific
* form.
*
* @param aNameSpaceID the namespace of the attribute
* @param aName the name of the attribute
* @param aPrefix the prefix of the attribute
* @param aValue the value to set
* @param aMaybeScriptedPrincipal the principal of the scripted caller
* responsible for setting the attribute, or null if no scripted caller can be
* determined. A null value here does not guarantee that there is no
* scripted caller, but a non-null value does guarantee that a scripted
* caller with the given principal is directly responsible for the
* attribute change.
* @param aNotify specifies how whether or not the document should be
* notified of the attribute change.
*/
nsresult SetAttr(int32_t aNameSpaceID, nsAtom* aName, nsAtom* aPrefix,
const nsAString& aValue,
nsIPrincipal* aMaybeScriptedPrincipal, bool aNotify);
/**
* Remove an attribute so that it is no longer explicitly specified.
*
* @param aNameSpaceID the namespace id of the attribute
* @param aName the name of the attribute to unset
* @param aNotify specifies whether or not the document should be
* notified of the attribute change
*/
nsresult UnsetAttr(int32_t aNameSpaceID, nsAtom* aName, bool aNotify);
/**
* Get the namespace / name / prefix of a given attribute.
*
* @param aIndex the index of the attribute name
* @returns The name at the given index, or null if the index is
* out-of-bounds.
* @note The document returned by NodeInfo()->GetDocument() (if one is
* present) is *not* necessarily the owner document of the element.
* @note The pointer returned by this function is only valid until the
* next call of either GetAttrNameAt or SetAttr on the element.
*/
const nsAttrName* GetAttrNameAt(uint32_t aIndex) const {
return mAttrs.GetSafeAttrNameAt(aIndex);
}
/**
* Same as above, but does not do out-of-bounds checks!
*/
const nsAttrName* GetUnsafeAttrNameAt(uint32_t aIndex) const {
return mAttrs.AttrNameAt(aIndex);
}
/**
* Gets the attribute info (name and value) for this element at a given index.
*/
BorrowedAttrInfo GetAttrInfoAt(uint32_t aIndex) const {
if (aIndex >= mAttrs.AttrCount()) {
return BorrowedAttrInfo(nullptr, nullptr);
}
return mAttrs.AttrInfoAt(aIndex);
}
/**
* Get the number of all specified attributes.
*
* @return the number of attributes
*/
uint32_t GetAttrCount() const { return mAttrs.AttrCount(); }
/**
* Get the class list of this element (this corresponds to the value of the
* class attribute). This may be null if there are no classes, but that's not
* guaranteed (e.g. we could have class="").
*/
const nsAttrValue* GetClasses() const {
if (!MayHaveClass()) {
return nullptr;
}
if (IsSVGElement()) {
if (const nsAttrValue* value = GetSVGAnimatedClass()) {
return value;
}
}
return GetParsedAttr(nsGkAtoms::_class);
}
#ifdef MOZ_DOM_LIST
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const override {
List(out, aIndent, ""_ns);
}
virtual void DumpContent(FILE* out, int32_t aIndent,
bool aDumpAll) const override;
void List(FILE* out, int32_t aIndent, const nsCString& aPrefix) const;
void ListAttributes(FILE* out) const;
#endif
/**
* Append to aOutDescription a string describing the element and its
* attributes.
* If aShort is true, only the id and class attributes will be listed.
*/
void Describe(nsAString& aOutDescription, bool aShort = false) const;
/*
* Attribute Mapping Helpers
*/
struct MappedAttributeEntry {
const nsStaticAtom* const attribute;
};
/**
* A common method where you can just pass in a list of maps to check
* for attribute dependence. Most implementations of
* IsAttributeMapped should use this function as a default
* handler.
*/
template <size_t N>
static bool FindAttributeDependence(
const nsAtom* aAttribute, const MappedAttributeEntry* const (&aMaps)[N]) {
return FindAttributeDependence(aAttribute, aMaps, N);
}
virtual bool IsValidInvokeAction(InvokeAction aAction) const {
return aAction == InvokeAction::Auto;
}
/**
* Elements can provide their own default behaviours for "Invoke" (see
* invoketarget/invokeaction attributes).
* If the action is not recognised, they can choose to ignore it and `return
* false`. If an action is recognised then they should `return true` to
* indicate to sub-classes that this has been handled and no further steps
* should be run.
*/
MOZ_CAN_RUN_SCRIPT virtual bool HandleInvokeInternal(Element* invoker,
InvokeAction aAction,
ErrorResult& aRv) {
return false;
}
private:
void DescribeAttribute(uint32_t index, nsAString& aOutDescription) const;
static bool FindAttributeDependence(const nsAtom* aAttribute,
const MappedAttributeEntry* const aMaps[],
uint32_t aMapCount);
protected:
inline bool GetAttr(const nsAtom* aName, DOMString& aResult) const {
MOZ_ASSERT(aResult.IsEmpty(), "Should have empty string coming in");
const nsAttrValue* val = mAttrs.GetAttr(aName);
if (!val) {
return false; // DOMString comes pre-emptied.
}
val->ToString(aResult);
return true;
}
inline bool GetAttr(int32_t aNameSpaceID, const nsAtom* aName,
DOMString& aResult) const {
MOZ_ASSERT(aResult.IsEmpty(), "Should have empty string coming in");
const nsAttrValue* val = mAttrs.GetAttr(aName, aNameSpaceID);
if (!val) {
return false; // DOMString comes pre-emptied.
}
val->ToString(aResult);
return true;
}
public:
bool HasAttrs() const { return mAttrs.HasAttrs(); }
inline bool GetAttr(const nsAString& aName, DOMString& aResult) const {
MOZ_ASSERT(aResult.IsEmpty(), "Should have empty string coming in");
const nsAttrValue* val = mAttrs.GetAttr(aName);
if (val) {
val->ToString(aResult);
return true;
}
// else DOMString comes pre-emptied.
return false;
}
// Note, this does not notify about the removal.
void ClearAttributes() { mAttrs.Clear(); }
void GetTagName(nsAString& aTagName) const { aTagName = NodeName(); }
void GetId(nsAString& aId) const { GetAttr(nsGkAtoms::id, aId); }
void GetId(DOMString& aId) const { GetAttr(nsGkAtoms::id, aId); }
void SetId(const nsAString& aId) {
SetAttr(kNameSpaceID_None, nsGkAtoms::id, aId, true);
}
void GetClassName(nsAString& aClassName) {
GetAttr(nsGkAtoms::_class, aClassName);
}
void GetClassName(DOMString& aClassName) {
GetAttr(nsGkAtoms::_class, aClassName);
}
void SetClassName(const nsAString& aClassName) {
SetAttr(kNameSpaceID_None, nsGkAtoms::_class, aClassName, true);
}
nsDOMTokenList* ClassList();
nsDOMTokenList* Part();
nsDOMAttributeMap* Attributes();
void GetAttributeNames(nsTArray<nsString>& aResult);
void GetAttribute(const nsAString& aName, nsAString& aReturn) {
DOMString str;
GetAttribute(aName, str);
str.ToString(aReturn);
}
void GetAttribute(const nsAString& aName, DOMString& aReturn);
void GetAttributeNS(const nsAString& aNamespaceURI,
const nsAString& aLocalName, nsAString& aReturn);
bool ToggleAttribute(const nsAString& aName, const Optional<bool>& aForce,
nsIPrincipal* aTriggeringPrincipal, ErrorResult& aError);
void SetAttribute(const nsAString& aName, const nsAString& aValue,
nsIPrincipal* aTriggeringPrincipal, ErrorResult& aError);
void SetAttributeNS(const nsAString& aNamespaceURI,
const nsAString& aLocalName, const nsAString& aValue,
nsIPrincipal* aTriggeringPrincipal, ErrorResult& aError);
void SetAttribute(const nsAString& aName, const nsAString& aValue,
ErrorResult& aError) {
SetAttribute(aName, aValue, nullptr, aError);
}
/**
* This method creates a principal that subsumes this element's NodePrincipal
* and which has flags set for elevated permissions that devtools needs to
* operate on this element. The principal returned by this method is used by
* various devtools methods to permit otherwise blocked operations, without
* changing any other restrictions the NodePrincipal might have.
*/
already_AddRefed<nsIPrincipal> CreateDevtoolsPrincipal();
void SetAttributeDevtools(const nsAString& aName, const nsAString& aValue,
ErrorResult& aError);
void SetAttributeDevtoolsNS(const nsAString& aNamespaceURI,
const nsAString& aLocalName,
const nsAString& aValue, ErrorResult& aError);
void RemoveAttribute(const nsAString& aName, ErrorResult& aError);
void RemoveAttributeNS(const nsAString& aNamespaceURI,
const nsAString& aLocalName, ErrorResult& aError);
bool HasAttribute(const nsAString& aName) const {
return InternalGetAttrNameFromQName(aName) != nullptr;
}
bool HasAttributeNS(const nsAString& aNamespaceURI,
const nsAString& aLocalName) const;
bool HasAttributes() const { return HasAttrs(); }
Element* Closest(const nsACString& aSelector, ErrorResult& aResult);
bool Matches(const nsACString& aSelector, ErrorResult& aError);
already_AddRefed<nsIHTMLCollection> GetElementsByTagName(
const nsAString& aQualifiedName);
already_AddRefed<nsIHTMLCollection> GetElementsByTagNameNS(
const nsAString& aNamespaceURI, const nsAString& aLocalName,
ErrorResult& aError);
already_AddRefed<nsIHTMLCollection> GetElementsByClassName(
const nsAString& aClassNames);
/**
* Returns attribute associated element for the given attribute name, see
*/
Element* GetAttrAssociatedElement(nsAtom* aAttr) const;
/**
* Sets an attribute element for the given attribute.
*/
void ExplicitlySetAttrElement(nsAtom* aAttr, Element* aElement);
void ClearExplicitlySetAttrElement(nsAtom*);
/**
* Gets the attribute element for the given attribute.
* Unlike GetAttrAssociatedElement, this returns the target even if it isn't
* a descendant of any of this element's shadow-including ancestors. It also
* doesn't attempt to retrieve an element using a string id set in the content
* attribute.
*/
Element* GetExplicitlySetAttrElement(nsAtom* aAttr) const;
PseudoStyleType GetPseudoElementType() const {
nsresult rv = NS_OK;
auto raw = GetProperty(nsGkAtoms::pseudoProperty, &rv);
if (rv == NS_PROPTABLE_PROP_NOT_THERE) {
return PseudoStyleType::NotPseudo;
}
return PseudoStyleType(reinterpret_cast<uintptr_t>(raw));
}
void SetPseudoElementType(PseudoStyleType aPseudo) {
static_assert(sizeof(PseudoStyleType) <= sizeof(uintptr_t),
"Need to be able to store this in a void*");
MOZ_ASSERT(PseudoStyle::IsPseudoElement(aPseudo));
SetProperty(nsGkAtoms::pseudoProperty, reinterpret_cast<void*>(aPseudo));
}
/**
* Return an array of all elements in the subtree rooted at this
* element that have grid container frames. This does not include
* pseudo-elements.
*/
void GetElementsWithGrid(nsTArray<RefPtr<Element>>& aElements);
/**
* Provide a direct way to determine if this Element has visible
* scrollbars. Flushes layout.
*/
MOZ_CAN_RUN_SCRIPT bool HasVisibleScrollbars();
/**
* Get an editor which handles user inputs when this element has focus.
* If this is a text control, return a TextEditor if it's already created.
* Otherwise, return nullptr.
* If this is not a text control but this is editable, return
* HTMLEditor which should've already been created.
* Otherwise, return nullptr.
*/
EditorBase* GetEditorWithoutCreation() const;
private:
/**
* Implement the algorithm specified at
* |insertAdjacentElement()| and |insertAdjacentText()| APIs.
*/
nsINode* InsertAdjacent(const nsAString& aWhere, nsINode* aNode,
ErrorResult& aError);
public:
Element* InsertAdjacentElement(const nsAString& aWhere, Element& aElement,
ErrorResult& aError);
void InsertAdjacentText(const nsAString& aWhere, const nsAString& aData,
ErrorResult& aError);
void SetPointerCapture(int32_t aPointerId, ErrorResult& aError);
void ReleasePointerCapture(int32_t aPointerId, ErrorResult& aError);
bool HasPointerCapture(long aPointerId);
void SetCapture(bool aRetargetToElement);
void SetCaptureAlways(bool aRetargetToElement);
void ReleaseCapture();