1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsIContent_h___
7 #define nsIContent_h___
9 #include "mozilla/FlushType.h"
11 #include "nsStringFwd.h"
13 // Forward declarations
19 class EventChainPreVisitor
;
25 class HTMLSlotElement
;
28 enum class IMEEnabled
;
31 } // namespace mozilla
33 // IID for the nsIContent interface
34 // Must be kept in sync with xpcom/rust/xpcom/src/interfaces/nonidl.rs
35 #define NS_ICONTENT_IID \
37 0x8e1bab9d, 0x8815, 0x4d2c, { \
38 0xa2, 0x4d, 0x7a, 0xba, 0x52, 0x39, 0xdc, 0x22 \
43 * A node of content in a document's content model. This interface
44 * is supported by all content objects.
46 class nsIContent
: public nsINode
{
48 using IMEEnabled
= mozilla::widget::IMEEnabled
;
49 using IMEState
= mozilla::widget::IMEState
;
50 using BindContext
= mozilla::dom::BindContext
;
52 void ConstructUbiNode(void* storage
) override
;
54 #ifdef MOZILLA_INTERNAL_API
55 // If you're using the external API, the only thing you can know about
56 // nsIContent is that it exists with an IID
58 explicit nsIContent(already_AddRefed
<mozilla::dom::NodeInfo
>&& aNodeInfo
)
59 : nsINode(std::move(aNodeInfo
)) {
60 MOZ_ASSERT(mNodeInfo
);
61 MOZ_ASSERT(static_cast<nsINode
*>(this) == reinterpret_cast<nsINode
*>(this));
64 #endif // MOZILLA_INTERNAL_API
66 NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICONTENT_IID
)
68 NS_DECL_ISUPPORTS_INHERITED
69 NS_IMETHOD_(void) DeleteCycleCollectable(void) final
;
71 NS_DECL_CYCLE_COLLECTION_CLASS(nsIContent
)
73 NS_DECL_DOMARENA_DESTROY
75 NS_IMPL_FROMNODE_HELPER(nsIContent
, IsContent())
78 * Bind this content node to a tree. If this method throws, the caller must
79 * call UnbindFromTree() on the node. In the typical case of a node being
80 * appended to a parent, this will be called after the node has been added to
81 * the parent's child list and before nsIDocumentObserver notifications for
82 * the addition are dispatched.
83 * BindContext propagates various information down the subtree; see its
84 * documentation to know how to set it up.
85 * @param aParent The new parent node for the content node. May be a document.
86 * @note This method must not be called by consumers of nsIContent on a node
87 * that is already bound to a tree. Call UnbindFromTree first.
88 * @note This method will handle rebinding descendants appropriately (eg
89 * changing their binding parent as needed).
90 * @note This method does not add the content node to aParent's child list
91 * @throws NS_ERROR_OUT_OF_MEMORY if that happens
93 * TODO(emilio): Should we move to nsIContent::BindToTree most of the
94 * FragmentOrElement / CharacterData duplicated code?
96 virtual nsresult
BindToTree(BindContext
&, nsINode
& aParent
) = 0;
99 * Unbind this content node from a tree. This will set its current document
100 * and binding parent to null. In the typical case of a node being removed
101 * from a parent, this will be called after it has been removed from the
102 * parent's child list and after the nsIDocumentObserver notifications for
103 * the removal have been dispatched.
104 * @param aDeep Whether to recursively unbind the entire subtree rooted at
105 * this node. The only time false should be passed is when the
106 * parent node of the content is being destroyed.
107 * @param aNullParent Whether to null out the parent pointer as well. This
108 * is usually desirable. This argument should only be false while
109 * recursively calling UnbindFromTree when a subtree is detached.
110 * @note This method is safe to call on nodes that are not bound to a tree.
112 virtual void UnbindFromTree(bool aNullParent
= true) = 0;
116 * All XBL flattened tree children of the node, as well as :before and
117 * :after anonymous content and native anonymous children.
119 * @note the result children order is
120 * 1. :before generated node
121 * 2. Shadow DOM flattened tree children of this node
122 * 3. native anonymous nodes
123 * 4. :after generated node
128 * Skip native anonymous content created for placeholder of HTML input.
130 eSkipPlaceholderContent
= 1 << 0,
133 * Skip native anonymous content created by ancestor frames of the root
134 * element's primary frame, such as scrollbar elements created by the root
137 eSkipDocumentLevelNativeAnonymousContent
= 1 << 1,
141 * Makes this content anonymous
142 * @see nsIAnonymousContentCreator
144 void SetIsNativeAnonymousRoot() {
145 SetFlags(NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE
|
146 NODE_IS_NATIVE_ANONYMOUS_ROOT
);
150 * Returns |this| if it is not chrome-only/native anonymous, otherwise
151 * first non chrome-only/native anonymous ancestor.
153 nsIContent
* FindFirstNonChromeOnlyAccessContent() const;
156 * Return true iff this node is in an HTML document (in the HTML5 sense of
157 * the term, i.e. not in an XHTML/XML document).
159 inline bool IsInHTMLDocument() const;
162 * Returns true if in a chrome document
164 inline bool IsInChromeDocument() const;
167 * Get the namespace that this element's tag is defined in
168 * @return the namespace
170 inline int32_t GetNameSpaceID() const { return mNodeInfo
->NamespaceID(); }
172 inline bool IsHTMLElement() const {
173 return IsInNamespace(kNameSpaceID_XHTML
);
176 inline bool IsHTMLElement(const nsAtom
* aTag
) const {
177 return mNodeInfo
->Equals(aTag
, kNameSpaceID_XHTML
);
180 template <typename First
, typename
... Args
>
181 inline bool IsAnyOfHTMLElements(First aFirst
, Args
... aArgs
) const {
182 return IsHTMLElement() && IsNodeInternal(aFirst
, aArgs
...);
185 inline bool IsSVGElement() const { return IsInNamespace(kNameSpaceID_SVG
); }
187 inline bool IsSVGElement(const nsAtom
* aTag
) const {
188 return mNodeInfo
->Equals(aTag
, kNameSpaceID_SVG
);
191 template <typename First
, typename
... Args
>
192 inline bool IsAnyOfSVGElements(First aFirst
, Args
... aArgs
) const {
193 return IsSVGElement() && IsNodeInternal(aFirst
, aArgs
...);
196 inline bool IsXULElement() const { return IsInNamespace(kNameSpaceID_XUL
); }
198 inline bool IsXULElement(const nsAtom
* aTag
) const {
199 return mNodeInfo
->Equals(aTag
, kNameSpaceID_XUL
);
202 template <typename First
, typename
... Args
>
203 inline bool IsAnyOfXULElements(First aFirst
, Args
... aArgs
) const {
204 return IsXULElement() && IsNodeInternal(aFirst
, aArgs
...);
207 inline bool IsMathMLElement() const {
208 return IsInNamespace(kNameSpaceID_MathML
);
211 inline bool IsMathMLElement(const nsAtom
* aTag
) const {
212 return mNodeInfo
->Equals(aTag
, kNameSpaceID_MathML
);
215 template <typename First
, typename
... Args
>
216 inline bool IsAnyOfMathMLElements(First aFirst
, Args
... aArgs
) const {
217 return IsMathMLElement() && IsNodeInternal(aFirst
, aArgs
...);
220 bool IsGeneratedContentContainerForBefore() const {
221 return IsRootOfNativeAnonymousSubtree() &&
222 mNodeInfo
->NameAtom() == nsGkAtoms::mozgeneratedcontentbefore
;
225 bool IsGeneratedContentContainerForAfter() const {
226 return IsRootOfNativeAnonymousSubtree() &&
227 mNodeInfo
->NameAtom() == nsGkAtoms::mozgeneratedcontentafter
;
230 bool IsGeneratedContentContainerForMarker() const {
231 return IsRootOfNativeAnonymousSubtree() &&
232 mNodeInfo
->NameAtom() == nsGkAtoms::mozgeneratedcontentmarker
;
236 * Get direct access (but read only) to the text in the text content.
237 * NOTE: For elements this is *not* the concatenation of all text children,
240 virtual const nsTextFragment
* GetText() = 0;
243 * Get the length of the text content.
244 * NOTE: This should not be called on elements.
246 virtual uint32_t TextLength() const = 0;
249 * Determines if an event attribute name (such as onclick) is valid for
250 * a given element type.
251 * @note calls nsContentUtils::IsEventAttributeName with right flag
252 * @note *Internal is overridden by subclasses as needed
253 * @param aName the event name to look up
255 bool IsEventAttributeName(nsAtom
* aName
);
257 virtual bool IsEventAttributeNameInternal(nsAtom
* aName
) { return false; }
260 * Query method to see if the frame is nothing but whitespace
261 * NOTE: Always returns false for elements
263 virtual bool TextIsOnlyWhitespace() = 0;
266 * Thread-safe version of TextIsOnlyWhitespace.
268 virtual bool ThreadSafeTextIsOnlyWhitespace() const = 0;
271 * Check if this content is focusable and in the current tab order.
272 * Note: most callers should use nsIFrame::IsFocusable() instead as it
273 * checks visibility and other layout factors as well.
274 * Tabbable is indicated by a nonnegative tabindex & is a subset of focusable.
275 * For example, only the selected radio button in a group is in the
276 * tab order, unless the radio group has no selection in which case
277 * all of the visible, non-disabled radio buttons in the group are
278 * in the tab order. On the other hand, all of the visible, non-disabled
279 * radio buttons are always focusable via clicking or script.
280 * Also, depending on either the accessibility.tabfocus pref or
281 * a system setting (nowadays: Full keyboard access, mac only)
282 * some widgets may be focusable but removed from the tab order.
283 * @param [inout, optional] aTabIndex the computed tab index
284 * In: default tabindex for element (-1 nonfocusable, == 0 focusable)
285 * Out: computed tabindex
286 * @param [optional] aTabIndex the computed tab index
287 * < 0 if not tabbable
288 * == 0 if in normal tab order
289 * > 0 can be tabbed to in the order specified by this value
290 * @return whether the content is focusable via mouse, kbd or script.
292 bool IsFocusable(int32_t* aTabIndex
= nullptr, bool aWithMouse
= false);
293 virtual bool IsFocusableInternal(int32_t* aTabIndex
, bool aWithMouse
);
295 // https://html.spec.whatwg.org/multipage/interaction.html#focus-delegate
296 mozilla::dom::Element
* GetFocusDelegate(bool aWithMouse
) const;
298 // https://html.spec.whatwg.org/multipage/interaction.html#autofocus-delegate
299 mozilla::dom::Element
* GetAutofocusDelegate(bool aWithMouse
) const;
302 * Get desired IME state for the content.
304 * @return The desired IME status for the content.
305 * This is a combination of an IME enabled value and
306 * an IME open value of widget::IMEState.
307 * If you return IMEEnabled::Disabled, you should not set the OPEN
309 * IMEEnabled::Password should be returned only from password editor,
310 * this value has a special meaning. It is used as alternative of
311 * IMEEnabled::Disabled. IMEENabled::Plugin should be returned only
312 * when plug-in has focus. When a plug-in is focused content, we
313 * should send native events directly. Because we don't process some
314 * native events, but they may be needed by the plug-in.
316 virtual IMEState
GetDesiredIMEState();
319 * Gets the ShadowRoot binding for this element.
321 * @return The ShadowRoot currently bound to this element.
323 inline mozilla::dom::ShadowRoot
* GetShadowRoot() const;
326 * Gets the root of the node tree for this content if it is in a shadow tree.
328 * @return The ShadowRoot that is the root of the node tree.
330 mozilla::dom::ShadowRoot
* GetContainingShadow() const {
331 const nsExtendedContentSlots
* slots
= GetExistingExtendedContentSlots();
332 return slots
? slots
->mContainingShadow
.get() : nullptr;
336 * Gets the assigned slot associated with this content.
338 * @return The assigned slot element or null.
340 mozilla::dom::HTMLSlotElement
* GetAssignedSlot() const {
341 const nsExtendedContentSlots
* slots
= GetExistingExtendedContentSlots();
342 return slots
? slots
->mAssignedSlot
.get() : nullptr;
346 * Sets the assigned slot associated with this content.
348 * @param aSlot The assigned slot.
350 void SetAssignedSlot(mozilla::dom::HTMLSlotElement
* aSlot
);
353 * Gets the assigned slot associated with this content based on parent's
354 * shadow root mode. Returns null if parent's shadow root is "closed".
355 * https://dom.spec.whatwg.org/#dom-slotable-assignedslot
357 * @return The assigned slot element or null.
359 mozilla::dom::HTMLSlotElement
* GetAssignedSlotByMode() const;
361 mozilla::dom::HTMLSlotElement
* GetManualSlotAssignment() const {
362 const nsExtendedContentSlots
* slots
= GetExistingExtendedContentSlots();
363 return slots
? slots
->mManualSlotAssignment
: nullptr;
366 void SetManualSlotAssignment(mozilla::dom::HTMLSlotElement
* aSlot
) {
367 MOZ_ASSERT(aSlot
|| GetExistingExtendedContentSlots());
368 ExtendedContentSlots()->mManualSlotAssignment
= aSlot
;
372 * Same as GetFlattenedTreeParentNode, but returns null if the parent is
375 inline nsIContent
* GetFlattenedTreeParent() const;
378 * Get the index of a child within this content's flat tree children.
380 * @param aPossibleChild the child to get the index of.
381 * @return the index of the child, or Nothing if not a child. Be aware that
382 * anonymous children (e.g. a <div> child of an <input> element) will
385 mozilla::Maybe
<uint32_t> ComputeFlatTreeIndexOf(
386 const nsINode
* aPossibleChild
) const;
389 // Handles getting inserted or removed directly under a <slot> element.
390 // This is meant to only be called from the two functions below.
391 inline void HandleInsertionToOrRemovalFromSlot();
393 // Handles Shadow-DOM-related state tracking. Meant to be called near the
394 // end of BindToTree(), only if the tree we're in actually changed, that is,
395 // after the subtree has been bound to the new parent.
396 inline void HandleShadowDOMRelatedInsertionSteps(bool aHadParent
);
398 // Handles Shadow-DOM related state tracking. Meant to be called near the
399 // beginning of UnbindFromTree(), before the node has lost the reference to
401 inline void HandleShadowDOMRelatedRemovalSteps(bool aNullParent
);
405 * This method is called when the parser finishes creating the element. This
406 * particularly means that it has done everything you would expect it to have
407 * done after it encounters the > at the end of the tag (for HTML or XML).
408 * This includes setting the attributes, setting the document / form, and
409 * placing the element into the tree at its proper place.
411 * For container elements, this is called *before* any of the children are
412 * created or added into the tree.
414 * NOTE: this is only called for elements listed in
415 * RequiresDoneCreatingElement. This is an efficiency measure.
417 * If you also need to determine whether the parser is the one creating your
418 * element (through createElement() or cloneNode() generally) then add a
419 * uint32_t aFromParser to the NS_NewXXX() constructor for your element and
420 * have the parser pass the appropriate flags. See HTMLInputElement.cpp and
421 * nsHTMLContentSink::MakeContentObject().
423 * DO NOT USE THIS METHOD to get around the fact that it's hard to deal with
424 * attributes dynamically. If you make attributes affect your element from
425 * this method, it will only happen on initialization and JavaScript will not
426 * be able to create elements (which requires them to first create the
427 * element and then call setAttribute() directly, at which point
428 * DoneCreatingElement() has already been called and is out of the picture).
430 virtual void DoneCreatingElement() {}
433 * This method is called when the parser finishes creating the element's
434 * children, if any are present.
436 * NOTE: this is only called for elements listed in
437 * RequiresDoneAddingChildren. This is an efficiency measure.
439 * If you also need to determine whether the parser is the one creating your
440 * element (through createElement() or cloneNode() generally) then add a
441 * boolean aFromParser to the NS_NewXXX() constructor for your element and
442 * have the parser pass true. See HTMLInputElement.cpp and
443 * nsHTMLContentSink::MakeContentObject().
445 * @param aHaveNotified Whether there has been a
446 * ContentInserted/ContentAppended notification for this content node
449 virtual void DoneAddingChildren(bool aHaveNotified
) {}
452 * Returns true if an element needs its DoneCreatingElement method to be
453 * called after it has been created.
454 * @see nsIContent::DoneCreatingElement
456 * @param aNamespaceID the node's namespace ID
457 * @param aName the node's tag name
459 static inline bool RequiresDoneCreatingElement(int32_t aNamespace
,
461 if (aNamespace
== kNameSpaceID_XHTML
) {
462 if (aName
== nsGkAtoms::input
|| aName
== nsGkAtoms::button
||
463 aName
== nsGkAtoms::audio
|| aName
== nsGkAtoms::video
) {
464 MOZ_ASSERT(!RequiresDoneAddingChildren(aNamespace
, aName
),
465 "Both DoneCreatingElement and DoneAddingChildren on a "
466 "same element isn't supported.");
469 if (aName
->IsDynamic()) {
470 // This could be a form-associated custom element, so check if its
471 // name includes a -.
472 nsDependentString
name(aName
->GetUTF16String());
473 return name
.Contains('-');
480 * Returns true if an element needs its DoneAddingChildren method to be
481 * called after all of its children have been added.
482 * @see nsIContent::DoneAddingChildren
484 * @param aNamespace the node's namespace ID
485 * @param aName the node's tag name
487 static inline bool RequiresDoneAddingChildren(int32_t aNamespace
,
489 return (aNamespace
== kNameSpaceID_XHTML
&&
490 (aName
== nsGkAtoms::select
|| aName
== nsGkAtoms::textarea
||
491 aName
== nsGkAtoms::head
|| aName
== nsGkAtoms::title
||
492 aName
== nsGkAtoms::object
|| aName
== nsGkAtoms::output
)) ||
493 (aNamespace
== kNameSpaceID_SVG
&& aName
== nsGkAtoms::title
) ||
494 (aNamespace
== kNameSpaceID_XUL
&& aName
== nsGkAtoms::linkset
);
498 * Get the ID of this content node (the atom corresponding to the
499 * value of the id attribute). This may be null if there is no ID.
501 nsAtom
* GetID() const {
509 * Should be called when the node can become editable or when it can stop
510 * being editable (for example when its contentEditable attribute changes,
511 * when it is moved into an editable parent, ...). If aNotify is true and
512 * the node is an element, this will notify the state change.
514 virtual void UpdateEditableState(bool aNotify
);
517 * Destroy this node and its children. Ideally this shouldn't be needed
518 * but for now we need to do it to break cycles.
520 virtual void DestroyContent() {}
523 * Saves the form state of this node and its children.
525 virtual void SaveSubtreeState() = 0;
528 * Getter and setter for our primary frame pointer. This is the frame that
529 * is most closely associated with the content. A frame is more closely
530 * associated with the content than another frame if the one frame contains
531 * directly or indirectly the other frame (e.g., when a frame is scrolled
532 * there is a scroll frame that contains the frame being scrolled). This
533 * frame is always the first continuation.
535 * In the case of absolutely positioned elements and floated elements, this
536 * frame is the out of flow frame, not the placeholder.
538 nsIFrame
* GetPrimaryFrame() const {
539 return (IsInUncomposedDoc() || IsInShadowTree()) ? mPrimaryFrame
: nullptr;
543 * Get the primary frame for this content with flushing
545 * @param aType the kind of flush to do, typically FlushType::Frames or
547 * @return the primary frame
549 nsIFrame
* GetPrimaryFrame(mozilla::FlushType aType
);
551 // Defined in nsIContentInlines.h because it needs nsIFrame.
552 inline void SetPrimaryFrame(nsIFrame
* aFrame
);
554 nsresult
LookupNamespaceURIInternal(const nsAString
& aNamespacePrefix
,
555 nsAString
& aNamespaceURI
) const;
558 * If this content has independent selection, e.g., if this is input field
559 * or textarea, this return TRUE. Otherwise, false.
561 bool HasIndependentSelection() const;
564 * If the content is a part of HTML editor, this returns editing
565 * host content. When the content is in designMode, this returns its body
566 * element. Also, when the content isn't editable, this returns null.
568 mozilla::dom::Element
* GetEditingHost();
570 bool SupportsLangAttr() const {
571 return IsHTMLElement() || IsSVGElement() || IsXULElement();
575 * Determining language. Look at the nearest ancestor element that has a lang
576 * attribute in the XML namespace or is an HTML/SVG element and has a lang in
577 * no namespace attribute.
579 * Returns null if no language was specified. Can return the empty atom.
581 nsAtom
* GetLang() const;
583 bool GetLang(nsAString
& aResult
) const {
584 if (auto* lang
= GetLang()) {
585 aResult
.Assign(nsDependentAtomString(lang
));
592 // Overloaded from nsINode
593 nsIURI
* GetBaseURI(bool aTryUseXHRDocBaseURI
= false) const override
;
595 // Returns base URI for style attribute.
596 nsIURI
* GetBaseURIForStyleAttr() const;
598 // Returns the URL data for style attribute.
599 // If aSubjectPrincipal is passed, it should be the scripted principal
600 // responsible for generating the URL data.
601 already_AddRefed
<mozilla::URLExtraData
> GetURLDataForStyleAttr(
602 nsIPrincipal
* aSubjectPrincipal
= nullptr) const;
604 void GetEventTargetParent(mozilla::EventChainPreVisitor
& aVisitor
) override
;
606 bool IsPurple() const { return mRefCnt
.IsPurple(); }
608 void RemovePurple() { mRefCnt
.RemovePurple(); }
610 // Note, currently this doesn't handle the case when frame tree has multiple
611 // references to the nsIContent object.
612 bool OwnedOnlyByTheDOMAndFrameTrees() {
613 return OwnedOnlyByTheDOMTree(GetPrimaryFrame() ? 1 : 0);
616 bool OwnedOnlyByTheDOMTree(uint32_t aExpectedRefs
= 0) {
617 uint32_t rc
= mRefCnt
.get();
621 rc
-= GetChildCount();
622 return rc
== aExpectedRefs
;
626 * Use this method with designMode and contentEditable to check if the
627 * node may need spellchecking.
629 bool InclusiveDescendantMayNeedSpellchecking(mozilla::HTMLEditor
* aEditor
);
633 * Lazily allocated extended slots to avoid
634 * that may only be instantiated when a content object is accessed
635 * through the DOM. Rather than burn actual slots in the content
636 * objects for each of these instance variables, we put them off
637 * in a side structure that's only allocated when the content is
638 * accessed through the DOM.
640 class nsExtendedContentSlots
{
642 nsExtendedContentSlots();
643 virtual ~nsExtendedContentSlots();
645 virtual void TraverseExtendedSlots(nsCycleCollectionTraversalCallback
&);
646 virtual void UnlinkExtendedSlots(nsIContent
&);
648 virtual size_t SizeOfExcludingThis(
649 mozilla::MallocSizeOf aMallocSizeOf
) const;
652 * @see nsIContent::GetContainingShadow
654 RefPtr
<mozilla::dom::ShadowRoot
> mContainingShadow
;
657 * @see nsIContent::GetAssignedSlot
659 RefPtr
<mozilla::dom::HTMLSlotElement
> mAssignedSlot
;
661 mozilla::dom::HTMLSlotElement
* mManualSlotAssignment
= nullptr;
664 class nsContentSlots
: public nsINode::nsSlots
{
666 nsContentSlots() : mExtendedSlots(0) {}
669 if (!(mExtendedSlots
& sNonOwningExtendedSlotsFlag
)) {
670 delete GetExtendedContentSlots();
674 void Traverse(nsCycleCollectionTraversalCallback
& aCb
) override
{
675 nsINode::nsSlots::Traverse(aCb
);
676 if (mExtendedSlots
) {
677 GetExtendedContentSlots()->TraverseExtendedSlots(aCb
);
681 void Unlink(nsINode
& aNode
) override
{
682 nsINode::nsSlots::Unlink(aNode
);
683 if (mExtendedSlots
) {
684 GetExtendedContentSlots()->UnlinkExtendedSlots(*aNode
.AsContent());
688 void SetExtendedContentSlots(nsExtendedContentSlots
* aSlots
, bool aOwning
) {
689 mExtendedSlots
= reinterpret_cast<uintptr_t>(aSlots
);
691 mExtendedSlots
|= sNonOwningExtendedSlotsFlag
;
695 // OwnsExtendedSlots returns true if we have no extended slots or if we
696 // have extended slots and own them.
697 bool OwnsExtendedSlots() const {
698 return !(mExtendedSlots
& sNonOwningExtendedSlotsFlag
);
701 nsExtendedContentSlots
* GetExtendedContentSlots() const {
702 return reinterpret_cast<nsExtendedContentSlots
*>(
703 mExtendedSlots
& ~sNonOwningExtendedSlotsFlag
);
707 static const uintptr_t sNonOwningExtendedSlotsFlag
= 1u;
709 uintptr_t mExtendedSlots
;
712 // Override from nsINode
713 nsContentSlots
* CreateSlots() override
{ return new nsContentSlots(); }
715 nsContentSlots
* ContentSlots() {
716 return static_cast<nsContentSlots
*>(Slots());
719 const nsContentSlots
* GetExistingContentSlots() const {
720 return static_cast<nsContentSlots
*>(GetExistingSlots());
723 nsContentSlots
* GetExistingContentSlots() {
724 return static_cast<nsContentSlots
*>(GetExistingSlots());
727 virtual nsExtendedContentSlots
* CreateExtendedSlots() {
728 return new nsExtendedContentSlots();
731 const nsExtendedContentSlots
* GetExistingExtendedContentSlots() const {
732 const nsContentSlots
* slots
= GetExistingContentSlots();
733 return slots
? slots
->GetExtendedContentSlots() : nullptr;
736 nsExtendedContentSlots
* GetExistingExtendedContentSlots() {
737 nsContentSlots
* slots
= GetExistingContentSlots();
738 return slots
? slots
->GetExtendedContentSlots() : nullptr;
741 nsExtendedContentSlots
* ExtendedContentSlots() {
742 nsContentSlots
* slots
= ContentSlots();
743 if (!slots
->GetExtendedContentSlots()) {
744 slots
->SetExtendedContentSlots(CreateExtendedSlots(), true);
746 return slots
->GetExtendedContentSlots();
750 * Hook for implementing GetID. This is guaranteed to only be
751 * called if HasID() is true.
753 nsAtom
* DoGetID() const;
755 ~nsIContent() = default;
758 #if defined(DEBUG) || defined(MOZ_DUMP_PAINTING)
759 # define MOZ_DOM_LIST
764 * An alias for List() with default arguments. Since some debuggers can't
765 * figure the default arguments easily, having an out-of-line, non-static
766 * function helps quite a lot.
771 * List the content (and anything it contains) out to the given
772 * file stream. Use aIndent as the base indent during formatting.
774 virtual void List(FILE* out
= stdout
, int32_t aIndent
= 0) const = 0;
777 * Dump the content (and anything it contains) out to the given
778 * file stream. Use aIndent as the base indent during formatting.
780 virtual void DumpContent(FILE* out
= stdout
, int32_t aIndent
= 0,
781 bool aDumpAll
= true) const = 0;
785 eTabFocus_textControlsMask
=
786 (1 << 0), // textboxes and lists always tabbable
787 eTabFocus_formElementsMask
= (1 << 1), // non-text form elements
788 eTabFocus_linksMask
= (1 << 2), // links
789 eTabFocus_any
= 1 + (1 << 1) + (1 << 2) // everything that can be focused
792 // Tab focus model bit field:
793 static int32_t sTabFocusModel
;
795 // accessibility.tabfocus_applies_to_xul pref - if it is set to true,
796 // the tabfocus bit field applies to xul elements.
797 static bool sTabFocusModelAppliesToXUL
;
800 NON_VIRTUAL_ADDREF_RELEASE(nsIContent
)
802 NS_DEFINE_STATIC_IID_ACCESSOR(nsIContent
, NS_ICONTENT_IID
)
804 #endif /* nsIContent_h___ */