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: */
|
2012-05-21 15:12:37 +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/. */
|
1998-04-14 00:24:54 +04:00
|
|
|
#ifndef nsIContent_h___
|
|
|
|
#define nsIContent_h___
|
|
|
|
|
2013-05-30 00:43:41 +04:00
|
|
|
#include "mozilla/Attributes.h"
|
2016-07-23 00:11:41 +03:00
|
|
|
#include "mozilla/dom/BorrowedAttrInfo.h"
|
2012-08-06 16:02:08 +04:00
|
|
|
#include "nsCaseTreatment.h" // for enum, cannot be forward-declared
|
2013-10-02 15:40:07 +04:00
|
|
|
#include "nsINode.h"
|
2017-08-17 02:48:52 +03:00
|
|
|
#include "nsStringFwd.h"
|
2018-03-29 01:07:40 +03:00
|
|
|
#include "nsISupportsImpl.h"
|
2005-11-16 23:29:29 +03:00
|
|
|
|
1998-08-30 00:20:38 +04:00
|
|
|
// Forward declarations
|
2017-10-03 01:05:19 +03:00
|
|
|
class nsAtom;
|
2003-07-03 06:45:34 +04:00
|
|
|
class nsIURI;
|
2005-11-02 03:41:51 +03:00
|
|
|
class nsAttrValue;
|
2005-12-29 00:52:39 +03:00
|
|
|
class nsAttrName;
|
2006-07-19 08:36:36 +04:00
|
|
|
class nsTextFragment;
|
2009-12-25 00:20:05 +03:00
|
|
|
class nsIFrame;
|
2013-07-17 20:05:03 +04:00
|
|
|
class nsXBLBinding;
|
2017-09-08 16:07:22 +03:00
|
|
|
class nsITextControlElement;
|
1998-07-15 02:34:27 +04:00
|
|
|
|
2011-03-11 05:48:57 +03:00
|
|
|
namespace mozilla {
|
2014-03-18 08:48:19 +04:00
|
|
|
class EventChainPreVisitor;
|
2017-04-06 09:51:29 +03:00
|
|
|
struct URLExtraData;
|
2013-12-02 14:26:11 +04:00
|
|
|
namespace dom {
|
|
|
|
class ShadowRoot;
|
2017-10-19 09:31:36 +03:00
|
|
|
class HTMLSlotElement;
|
2013-12-02 14:26:11 +04:00
|
|
|
} // namespace dom
|
2011-11-27 15:51:53 +04:00
|
|
|
namespace widget {
|
|
|
|
struct IMEState;
|
|
|
|
} // namespace widget
|
|
|
|
} // namespace mozilla
|
2011-03-11 05:48:57 +03:00
|
|
|
|
2009-07-13 15:48:06 +04:00
|
|
|
enum nsLinkState {
|
|
|
|
eLinkState_Unvisited = 1,
|
2009-07-14 23:42:46 +04:00
|
|
|
eLinkState_Visited = 2,
|
2016-07-22 06:10:23 +03:00
|
|
|
eLinkState_NotLink = 3
|
2009-07-13 15:48:06 +04:00
|
|
|
};
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// IID for the nsIContent interface
|
2018-01-05 01:32:15 +03:00
|
|
|
// Must be kept in sync with xpcom/rust/xpcom/src/interfaces/nonidl.rs
|
2011-11-16 11:50:18 +04:00
|
|
|
#define NS_ICONTENT_IID \
|
2015-09-18 15:18:42 +03:00
|
|
|
{ 0x8e1bab9d, 0x8815, 0x4d2c, \
|
|
|
|
{ 0xa2, 0x4d, 0x7a, 0xba, 0x52, 0x39, 0xdc, 0x22 } }
|
2006-05-15 12:07:35 +04:00
|
|
|
|
2002-07-27 09:02:38 +04:00
|
|
|
/**
|
|
|
|
* A node of content in a document's content model. This interface
|
|
|
|
* is supported by all content objects.
|
|
|
|
*/
|
2008-01-04 14:24:41 +03:00
|
|
|
class nsIContent : public nsINode {
|
1998-04-14 00:24:54 +04:00
|
|
|
public:
|
2011-11-27 15:51:53 +04:00
|
|
|
typedef mozilla::widget::IMEState IMEState;
|
|
|
|
|
2018-07-07 02:52:42 +03:00
|
|
|
void ConstructUbiNode(void* storage) override;
|
|
|
|
|
2006-08-31 23:59:43 +04:00
|
|
|
#ifdef MOZILLA_INTERNAL_API
|
|
|
|
// If you're using the external API, the only thing you can know about
|
|
|
|
// nsIContent is that it exists with an IID
|
2005-11-16 23:29:29 +03:00
|
|
|
|
2018-09-21 23:45:49 +03:00
|
|
|
explicit nsIContent(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
|
|
|
|
: nsINode(std::move(aNodeInfo))
|
2005-09-24 22:43:15 +04:00
|
|
|
{
|
2014-03-15 23:00:17 +04:00
|
|
|
MOZ_ASSERT(mNodeInfo);
|
2012-06-19 07:47:35 +04:00
|
|
|
SetNodeIsContent();
|
2005-09-24 22:43:15 +04:00
|
|
|
}
|
2006-09-13 01:19:43 +04:00
|
|
|
#endif // MOZILLA_INTERNAL_API
|
2003-11-07 12:47:23 +03:00
|
|
|
|
2008-01-04 14:24:41 +03:00
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICONTENT_IID)
|
|
|
|
|
2018-03-29 01:07:40 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS(nsIContent)
|
|
|
|
|
2018-05-08 20:52:38 +03:00
|
|
|
NS_IMPL_FROMNODE_HELPER(nsIContent, IsContent())
|
|
|
|
|
2002-07-27 09:02:38 +04:00
|
|
|
/**
|
2005-04-06 03:54:35 +04:00
|
|
|
* Bind this content node to a tree. If this method throws, the caller must
|
|
|
|
* call UnbindFromTree() on the node. In the typical case of a node being
|
|
|
|
* appended to a parent, this will be called after the node has been added to
|
|
|
|
* the parent's child list and before nsIDocumentObserver notifications for
|
|
|
|
* the addition are dispatched.
|
2014-05-24 22:51:06 +04:00
|
|
|
* @param aDocument The new document for the content node. May not be null
|
|
|
|
* if aParent is null. Must match the current document of
|
|
|
|
* aParent, if aParent is not null (note that
|
2016-03-31 14:46:32 +03:00
|
|
|
* aParent->GetUncomposedDoc() can be null, in which case
|
|
|
|
* this must also be null).
|
2005-04-06 03:54:35 +04:00
|
|
|
* @param aParent The new parent for the content node. May be null if the
|
|
|
|
* node is being bound as a direct child of the document.
|
|
|
|
* @param aBindingParent The new binding parent for the content node.
|
2012-03-22 08:10:51 +04:00
|
|
|
* This is must either be non-null if a particular
|
|
|
|
* binding parent is desired or match aParent's binding
|
|
|
|
* parent.
|
2005-04-06 03:54:35 +04:00
|
|
|
* @note either aDocument or aParent must be non-null. If both are null,
|
|
|
|
* this method _will_ crash.
|
|
|
|
* @note This method must not be called by consumers of nsIContent on a node
|
|
|
|
* that is already bound to a tree. Call UnbindFromTree first.
|
|
|
|
* @note This method will handle rebinding descendants appropriately (eg
|
|
|
|
* changing their binding parent as needed).
|
|
|
|
* @note This method does not add the content node to aParent's child list
|
|
|
|
* @throws NS_ERROR_OUT_OF_MEMORY if that happens
|
2018-07-31 21:18:38 +03:00
|
|
|
*
|
|
|
|
* TODO(emilio): Should we move to nsIContent::BindToTree most of the
|
|
|
|
* FragmentOrElement / CharacterData duplicated code?
|
2005-04-06 03:54:35 +04:00
|
|
|
*/
|
2018-07-31 21:18:38 +03:00
|
|
|
virtual nsresult BindToTree(nsIDocument* aDocument,
|
|
|
|
nsIContent* aParent,
|
|
|
|
nsIContent* aBindingParent) = 0;
|
2005-04-06 03:54:35 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Unbind this content node from a tree. This will set its current document
|
|
|
|
* and binding parent to null. In the typical case of a node being removed
|
|
|
|
* from a parent, this will be called after it has been removed from the
|
|
|
|
* parent's child list and after the nsIDocumentObserver notifications for
|
2016-07-22 06:10:23 +03:00
|
|
|
* the removal have been dispatched.
|
2005-04-06 03:54:35 +04:00
|
|
|
* @param aDeep Whether to recursively unbind the entire subtree rooted at
|
2011-10-17 18:59:28 +04:00
|
|
|
* this node. The only time false should be passed is when the
|
2005-04-06 03:54:35 +04:00
|
|
|
* parent node of the content is being destroyed.
|
|
|
|
* @param aNullParent Whether to null out the parent pointer as well. This
|
|
|
|
* is usually desirable. This argument should only be false while
|
|
|
|
* recursively calling UnbindFromTree when a subtree is detached.
|
|
|
|
* @note This method is safe to call on nodes that are not bound to a tree.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
virtual void UnbindFromTree(bool aDeep = true,
|
|
|
|
bool aNullParent = true) = 0;
|
2006-05-15 16:47:53 +04:00
|
|
|
|
2010-02-11 20:34:01 +03:00
|
|
|
enum {
|
|
|
|
/**
|
2010-02-21 03:52:50 +03:00
|
|
|
* All XBL flattened tree children of the node, as well as :before and
|
|
|
|
* :after anonymous content and native anonymous children.
|
2010-02-11 20:34:01 +03:00
|
|
|
*
|
|
|
|
* @note the result children order is
|
2010-02-21 03:52:50 +03:00
|
|
|
* 1. :before generated node
|
|
|
|
* 2. XBL flattened tree children of this node
|
|
|
|
* 3. native anonymous nodes
|
|
|
|
* 4. :after generated node
|
2010-02-11 20:34:01 +03:00
|
|
|
*/
|
|
|
|
eAllChildren = 0,
|
|
|
|
|
|
|
|
/**
|
2010-02-21 03:52:50 +03:00
|
|
|
* All XBL explicit children of the node (see
|
|
|
|
* http://www.w3.org/TR/xbl/#explicit3 ), as well as :before and :after
|
|
|
|
* anonymous content and native anonymous children.
|
|
|
|
*
|
|
|
|
* @note the result children order is
|
|
|
|
* 1. :before generated node
|
|
|
|
* 2. XBL explicit children of the node
|
|
|
|
* 3. native anonymous nodes
|
|
|
|
* 4. :after generated node
|
2010-02-11 20:34:01 +03:00
|
|
|
*/
|
2010-10-15 19:34:35 +04:00
|
|
|
eAllButXBL = 1,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Skip native anonymous content created for placeholder of HTML input,
|
|
|
|
* used in conjunction with eAllChildren or eAllButXBL.
|
|
|
|
*/
|
2016-12-01 06:34:57 +03:00
|
|
|
eSkipPlaceholderContent = 2,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Skip native anonymous content created by ancestor frames of the root
|
|
|
|
* element's primary frame, such as scrollbar elements created by the root
|
|
|
|
* scroll frame.
|
|
|
|
*/
|
|
|
|
eSkipDocumentLevelNativeAnonymousContent = 4,
|
2010-02-11 20:34:01 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2010-02-21 03:52:50 +03:00
|
|
|
* Return either the XBL explicit children of the node or the XBL flattened
|
2010-10-15 19:34:35 +04:00
|
|
|
* tree children of the node, depending on the filter, as well as
|
2010-02-21 03:52:50 +03:00
|
|
|
* native anonymous children.
|
|
|
|
*
|
|
|
|
* @note calling this method with eAllButXBL will return children that are
|
|
|
|
* also in the eAllButXBL and eAllChildren child lists of other descendants
|
|
|
|
* of this node in the tree, but those other nodes cannot be reached from the
|
|
|
|
* eAllButXBL child list.
|
2010-02-11 20:34:01 +03:00
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual already_AddRefed<nsINodeList> GetChildren(uint32_t aFilter) = 0;
|
2010-02-11 20:34:01 +03:00
|
|
|
|
2006-08-03 12:57:02 +04:00
|
|
|
/**
|
2008-01-04 14:24:41 +03:00
|
|
|
* Makes this content anonymous
|
|
|
|
* @see nsIAnonymousContentCreator
|
2006-08-03 12:57:02 +04:00
|
|
|
*/
|
2013-09-25 00:29:27 +04:00
|
|
|
void SetIsNativeAnonymousRoot()
|
2006-08-03 12:57:02 +04:00
|
|
|
{
|
2014-04-06 23:32:38 +04:00
|
|
|
SetFlags(NODE_IS_ANONYMOUS_ROOT | NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE |
|
2018-05-10 19:48:08 +03:00
|
|
|
NODE_IS_NATIVE_ANONYMOUS_ROOT);
|
2006-08-03 12:57:02 +04:00
|
|
|
}
|
|
|
|
|
2008-02-26 15:40:18 +03:00
|
|
|
/**
|
2012-10-10 23:04:42 +04:00
|
|
|
* Returns |this| if it is not chrome-only/native anonymous, otherwise
|
|
|
|
* first non chrome-only/native anonymous ancestor.
|
2008-02-26 15:40:18 +03:00
|
|
|
*/
|
2018-03-07 17:09:27 +03:00
|
|
|
nsIContent* FindFirstNonChromeOnlyAccessContent() const;
|
2008-02-26 15:40:18 +03:00
|
|
|
|
2008-07-23 08:50:20 +04:00
|
|
|
/**
|
|
|
|
* Returns true if and only if this node has a parent, but is not in
|
|
|
|
* its parent's child list.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsRootOfAnonymousSubtree() const
|
2008-07-23 08:50:20 +04:00
|
|
|
{
|
|
|
|
NS_ASSERTION(!IsRootOfNativeAnonymousSubtree() ||
|
|
|
|
(GetParent() && GetBindingParent() == GetParent()),
|
|
|
|
"root of native anonymous subtree must have parent equal "
|
|
|
|
"to binding parent");
|
2009-02-24 21:39:09 +03:00
|
|
|
NS_ASSERTION(!GetParent() ||
|
|
|
|
((GetBindingParent() == GetParent()) ==
|
2013-09-24 23:28:32 +04:00
|
|
|
HasFlag(NODE_IS_ANONYMOUS_ROOT)) ||
|
2010-07-15 08:38:19 +04:00
|
|
|
// Unfortunately default content for XBL insertion points is
|
|
|
|
// anonymous content that is bound with the parent of the
|
|
|
|
// insertion point as the parent but the bound element for the
|
|
|
|
// binding as the binding parent. So we have to complicate
|
|
|
|
// the assert a bit here.
|
|
|
|
(GetBindingParent() &&
|
|
|
|
(GetBindingParent() == GetParent()->GetBindingParent()) ==
|
2013-09-24 23:28:32 +04:00
|
|
|
HasFlag(NODE_IS_ANONYMOUS_ROOT)),
|
2009-02-24 21:39:09 +03:00
|
|
|
"For nodes with parent, flag and GetBindingParent() check "
|
|
|
|
"should match");
|
2013-09-24 23:28:32 +04:00
|
|
|
return HasFlag(NODE_IS_ANONYMOUS_ROOT);
|
2008-07-23 08:50:20 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-01-21 12:15:57 +03:00
|
|
|
* Returns true if there is NOT a path through child lists
|
|
|
|
* from the top of this node's parent chain back to this node or
|
|
|
|
* if the node is in native anonymous subtree without a parent.
|
2008-07-23 08:50:20 +04:00
|
|
|
*/
|
2018-04-13 21:13:10 +03:00
|
|
|
inline bool IsInAnonymousSubtree() const;
|
2008-07-23 08:50:20 +04:00
|
|
|
|
2009-06-09 11:41:19 +04:00
|
|
|
/**
|
|
|
|
* Return true iff this node is in an HTML document (in the HTML5 sense of
|
|
|
|
* the term, i.e. not in an XHTML/XML document).
|
|
|
|
*/
|
2013-10-02 15:40:07 +04:00
|
|
|
inline bool IsInHTMLDocument() const;
|
2009-06-09 11:41:19 +04:00
|
|
|
|
2016-06-28 17:24:48 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if in a chrome document
|
|
|
|
*/
|
2018-03-08 02:59:25 +03:00
|
|
|
inline bool IsInChromeDocument() const;
|
2016-06-28 17:24:48 +03:00
|
|
|
|
2012-06-22 11:41:56 +04:00
|
|
|
/**
|
|
|
|
* Get the namespace that this element's tag is defined in
|
|
|
|
* @return the namespace
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
inline int32_t GetNameSpaceID() const
|
2012-06-22 11:41:56 +04:00
|
|
|
{
|
|
|
|
return mNodeInfo->NamespaceID();
|
|
|
|
}
|
|
|
|
|
2015-03-03 14:08:59 +03:00
|
|
|
inline bool IsHTMLElement() const
|
2012-06-22 11:41:56 +04:00
|
|
|
{
|
2015-03-03 14:08:59 +03:00
|
|
|
return IsInNamespace(kNameSpaceID_XHTML);
|
2012-06-22 11:41:56 +04:00
|
|
|
}
|
|
|
|
|
2018-11-13 15:48:21 +03:00
|
|
|
inline bool IsHTMLElement(const nsAtom* aTag) const
|
2012-06-22 11:41:56 +04:00
|
|
|
{
|
2015-03-03 14:08:59 +03:00
|
|
|
return mNodeInfo->Equals(aTag, kNameSpaceID_XHTML);
|
2012-06-22 11:41:56 +04:00
|
|
|
}
|
|
|
|
|
2015-03-03 14:08:59 +03:00
|
|
|
template<typename First, typename... Args>
|
|
|
|
inline bool IsAnyOfHTMLElements(First aFirst, Args... aArgs) const
|
2012-06-22 11:41:56 +04:00
|
|
|
{
|
2015-03-03 14:08:59 +03:00
|
|
|
return IsHTMLElement() && IsNodeInternal(aFirst, aArgs...);
|
2012-06-22 11:41:56 +04:00
|
|
|
}
|
|
|
|
|
2015-03-03 14:08:59 +03:00
|
|
|
inline bool IsSVGElement() const
|
2012-06-22 11:41:56 +04:00
|
|
|
{
|
2015-03-03 14:08:59 +03:00
|
|
|
return IsInNamespace(kNameSpaceID_SVG);
|
2012-06-22 11:41:56 +04:00
|
|
|
}
|
|
|
|
|
2018-11-13 15:48:21 +03:00
|
|
|
inline bool IsSVGElement(const nsAtom* aTag) const
|
2012-06-22 11:41:56 +04:00
|
|
|
{
|
2015-03-03 14:08:59 +03:00
|
|
|
return mNodeInfo->Equals(aTag, kNameSpaceID_SVG);
|
2012-06-22 11:41:56 +04:00
|
|
|
}
|
|
|
|
|
2015-03-03 14:08:59 +03:00
|
|
|
template<typename First, typename... Args>
|
|
|
|
inline bool IsAnyOfSVGElements(First aFirst, Args... aArgs) const
|
2012-06-22 11:41:56 +04:00
|
|
|
{
|
2015-03-03 14:08:59 +03:00
|
|
|
return IsSVGElement() && IsNodeInternal(aFirst, aArgs...);
|
2012-06-22 11:41:56 +04:00
|
|
|
}
|
|
|
|
|
2015-03-03 14:08:59 +03:00
|
|
|
inline bool IsXULElement() const
|
2012-06-22 11:41:56 +04:00
|
|
|
{
|
|
|
|
return IsInNamespace(kNameSpaceID_XUL);
|
|
|
|
}
|
|
|
|
|
2018-11-13 15:48:21 +03:00
|
|
|
inline bool IsXULElement(const nsAtom* aTag) const
|
2013-07-19 08:13:35 +04:00
|
|
|
{
|
|
|
|
return mNodeInfo->Equals(aTag, kNameSpaceID_XUL);
|
|
|
|
}
|
|
|
|
|
2015-03-03 14:08:59 +03:00
|
|
|
template<typename First, typename... Args>
|
|
|
|
inline bool IsAnyOfXULElements(First aFirst, Args... aArgs) const
|
|
|
|
{
|
|
|
|
return IsXULElement() && IsNodeInternal(aFirst, aArgs...);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool IsMathMLElement() const
|
2012-06-22 11:41:56 +04:00
|
|
|
{
|
|
|
|
return IsInNamespace(kNameSpaceID_MathML);
|
|
|
|
}
|
|
|
|
|
2018-11-13 15:48:21 +03:00
|
|
|
inline bool IsMathMLElement(const nsAtom* aTag) const
|
2012-06-22 11:41:56 +04:00
|
|
|
{
|
|
|
|
return mNodeInfo->Equals(aTag, kNameSpaceID_MathML);
|
|
|
|
}
|
|
|
|
|
2015-03-03 14:08:59 +03:00
|
|
|
template<typename First, typename... Args>
|
|
|
|
inline bool IsAnyOfMathMLElements(First aFirst, Args... aArgs) const
|
|
|
|
{
|
|
|
|
return IsMathMLElement() && IsNodeInternal(aFirst, aArgs...);
|
|
|
|
}
|
2018-04-13 17:32:50 +03:00
|
|
|
|
|
|
|
inline bool IsActiveChildrenElement() const;
|
2013-07-12 01:52:49 +04:00
|
|
|
|
2016-08-19 06:16:45 +03:00
|
|
|
bool IsGeneratedContentContainerForBefore() const
|
|
|
|
{
|
|
|
|
return IsRootOfNativeAnonymousSubtree() &&
|
|
|
|
mNodeInfo->NameAtom() == nsGkAtoms::mozgeneratedcontentbefore;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsGeneratedContentContainerForAfter() const
|
|
|
|
{
|
|
|
|
return IsRootOfNativeAnonymousSubtree() &&
|
|
|
|
mNodeInfo->NameAtom() == nsGkAtoms::mozgeneratedcontentafter;
|
|
|
|
}
|
|
|
|
|
2006-07-19 08:36:36 +04:00
|
|
|
/**
|
|
|
|
* Get direct access (but read only) to the text in the text content.
|
|
|
|
* NOTE: For elements this is *not* the concatenation of all text children,
|
|
|
|
* it is simply null;
|
|
|
|
*/
|
|
|
|
virtual const nsTextFragment *GetText() = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the length of the text content.
|
|
|
|
* NOTE: This should not be called on elements.
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual uint32_t TextLength() const = 0;
|
2006-07-19 08:36:36 +04:00
|
|
|
|
2016-07-22 06:10:23 +03:00
|
|
|
/**
|
|
|
|
* Determines if an event attribute name (such as onclick) is valid for
|
|
|
|
* a given element type.
|
|
|
|
* @note calls nsContentUtils::IsEventAttributeName with right flag
|
2017-07-04 23:54:30 +03:00
|
|
|
* @note *Internal is overridden by subclasses as needed
|
2016-07-22 06:10:23 +03:00
|
|
|
* @param aName the event name to look up
|
|
|
|
*/
|
2017-10-03 01:05:19 +03:00
|
|
|
bool IsEventAttributeName(nsAtom* aName);
|
2017-07-04 23:54:30 +03:00
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
virtual bool IsEventAttributeNameInternal(nsAtom* aName)
|
2013-01-03 00:24:07 +04:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-07-19 08:36:36 +04:00
|
|
|
/**
|
|
|
|
* Query method to see if the frame is nothing but whitespace
|
2011-10-17 18:59:28 +04:00
|
|
|
* NOTE: Always returns false for elements
|
2006-07-19 08:36:36 +04:00
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
virtual bool TextIsOnlyWhitespace() = 0;
|
2006-07-19 08:36:36 +04:00
|
|
|
|
2017-03-17 00:10:22 +03:00
|
|
|
/**
|
|
|
|
* Thread-safe version of TextIsOnlyWhitespace.
|
|
|
|
*/
|
|
|
|
virtual bool ThreadSafeTextIsOnlyWhitespace() const = 0;
|
|
|
|
|
2004-07-25 01:12:43 +04:00
|
|
|
/**
|
|
|
|
* Check if this content is focusable and in the current tab order.
|
2016-07-22 06:10:23 +03:00
|
|
|
* Note: most callers should use nsIFrame::IsFocusable() instead as it
|
2004-07-25 01:12:43 +04:00
|
|
|
* checks visibility and other layout factors as well.
|
|
|
|
* Tabbable is indicated by a nonnegative tabindex & is a subset of focusable.
|
2016-07-22 06:10:23 +03:00
|
|
|
* For example, only the selected radio button in a group is in the
|
2004-07-25 01:12:43 +04:00
|
|
|
* tab order, unless the radio group has no selection in which case
|
2016-07-22 06:10:23 +03:00
|
|
|
* all of the visible, non-disabled radio buttons in the group are
|
|
|
|
* in the tab order. On the other hand, all of the visible, non-disabled
|
2004-07-25 01:12:43 +04:00
|
|
|
* radio buttons are always focusable via clicking or script.
|
2005-01-07 02:41:52 +03:00
|
|
|
* Also, depending on either the accessibility.tabfocus pref or
|
|
|
|
* a system setting (nowadays: Full keyboard access, mac only)
|
|
|
|
* some widgets may be focusable but removed from the tab order.
|
2004-07-25 01:12:43 +04:00
|
|
|
* @param [inout, optional] aTabIndex the computed tab index
|
|
|
|
* In: default tabindex for element (-1 nonfocusable, == 0 focusable)
|
|
|
|
* Out: computed tabindex
|
|
|
|
* @param [optional] aTabIndex the computed tab index
|
|
|
|
* < 0 if not tabbable
|
|
|
|
* == 0 if in normal tab order
|
|
|
|
* > 0 can be tabbed to in the order specified by this value
|
|
|
|
* @return whether the content is focusable via mouse, kbd or script.
|
|
|
|
*/
|
2013-11-20 02:21:16 +04:00
|
|
|
bool IsFocusable(int32_t* aTabIndex = nullptr, bool aWithMouse = false);
|
|
|
|
virtual bool IsFocusableInternal(int32_t* aTabIndex, bool aWithMouse);
|
2004-07-25 01:12:43 +04:00
|
|
|
|
2007-02-13 18:02:57 +03:00
|
|
|
/**
|
|
|
|
* The method focuses (or activates) element that accesskey is bound to. It is
|
|
|
|
* called when accesskey is activated.
|
|
|
|
*
|
|
|
|
* @param aKeyCausesActivation - if true then element should be activated
|
|
|
|
* @param aIsTrustedEvent - if true then event that is cause of accesskey
|
|
|
|
* execution is trusted.
|
2015-09-18 15:18:42 +03:00
|
|
|
* @return true if the focus was changed.
|
2007-02-13 18:02:57 +03:00
|
|
|
*/
|
2015-09-18 15:18:42 +03:00
|
|
|
virtual bool PerformAccesskey(bool aKeyCausesActivation,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aIsTrustedEvent)
|
2007-02-13 18:02:57 +03:00
|
|
|
{
|
2015-09-18 15:18:42 +03:00
|
|
|
return false;
|
2007-02-13 18:02:57 +03:00
|
|
|
}
|
|
|
|
|
2005-11-15 02:55:24 +03:00
|
|
|
/*
|
|
|
|
* Get desired IME state for the content.
|
|
|
|
*
|
|
|
|
* @return The desired IME status for the content.
|
2011-11-27 15:51:53 +04:00
|
|
|
* This is a combination of an IME enabled value and
|
|
|
|
* an IME open value of widget::IMEState.
|
|
|
|
* If you return DISABLED, you should not set the OPEN and CLOSE
|
|
|
|
* value.
|
|
|
|
* PASSWORD should be returned only from password editor, this value
|
|
|
|
* has a special meaning. It is used as alternative of DISABLED.
|
|
|
|
* PLUGIN should be returned only when plug-in has focus. When a
|
|
|
|
* plug-in is focused content, we should send native events directly.
|
|
|
|
* Because we don't process some native events, but they may be needed
|
|
|
|
* by the plug-in.
|
|
|
|
*/
|
|
|
|
virtual IMEState GetDesiredIMEState();
|
2005-11-15 02:55:24 +03:00
|
|
|
|
2002-07-27 09:02:38 +04:00
|
|
|
/**
|
2008-07-23 08:50:20 +04:00
|
|
|
* Gets content node with the binding (or native code, possibly on the
|
|
|
|
* frame) responsible for our construction (and existence). Used by
|
|
|
|
* anonymous content (both XBL-generated and native-anonymous).
|
|
|
|
*
|
|
|
|
* null for all explicit content (i.e., content reachable from the top
|
|
|
|
* of its GetParent() chain via child lists).
|
2002-07-27 09:02:38 +04:00
|
|
|
*
|
2003-07-29 01:09:56 +04:00
|
|
|
* @return the binding parent
|
2002-07-27 09:02:38 +04:00
|
|
|
*/
|
2017-12-23 11:23:42 +03:00
|
|
|
virtual nsIContent* GetBindingParent() const
|
|
|
|
{
|
|
|
|
const nsExtendedContentSlots* slots = GetExistingExtendedContentSlots();
|
2018-05-22 00:11:11 +03:00
|
|
|
return slots ? slots->mBindingParent.get() : nullptr;
|
2017-12-23 11:23:42 +03:00
|
|
|
}
|
Landing the XPCDOM_20010329_BRANCH branch, changes mostly done by jband@netscape.com and jst@netscape.com, also some changes done by shaver@mozilla.org, peterv@netscape.com and markh@activestate.com. r= and sr= by vidur@netscape.com, jband@netscape.com, jst@netscpae.com, danm@netscape.com, hyatt@netscape.com, shaver@mozilla.org, dbradley@netscape.com, rpotts@netscape.com.
2001-05-08 20:46:42 +04:00
|
|
|
|
2013-07-17 20:05:03 +04:00
|
|
|
/**
|
|
|
|
* Gets the current XBL binding that is bound to this element.
|
|
|
|
*
|
|
|
|
* @return the current binding.
|
|
|
|
*/
|
2017-11-21 12:27:49 +03:00
|
|
|
nsXBLBinding* GetXBLBinding() const
|
|
|
|
{
|
|
|
|
if (!HasFlag(NODE_MAY_BE_IN_BINDING_MNGR)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return DoGetXBLBinding();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual nsXBLBinding* DoGetXBLBinding() const = 0;
|
2013-07-17 20:05:03 +04:00
|
|
|
|
2013-12-02 14:26:11 +04:00
|
|
|
/**
|
|
|
|
* Gets the ShadowRoot binding for this element.
|
|
|
|
*
|
|
|
|
* @return The ShadowRoot currently bound to this element.
|
|
|
|
*/
|
2017-12-31 22:57:32 +03:00
|
|
|
inline mozilla::dom::ShadowRoot* GetShadowRoot() const;
|
2013-12-02 14:26:11 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the root of the node tree for this content if it is in a shadow tree.
|
|
|
|
* This method is called |GetContainingShadow| instead of |GetRootShadowRoot|
|
|
|
|
* to avoid confusion with |GetShadowRoot|.
|
|
|
|
*
|
|
|
|
* @return The ShadowRoot that is the root of the node tree.
|
|
|
|
*/
|
2017-12-23 11:23:42 +03:00
|
|
|
mozilla::dom::ShadowRoot* GetContainingShadow() const
|
|
|
|
{
|
|
|
|
const nsExtendedContentSlots* slots = GetExistingExtendedContentSlots();
|
|
|
|
return slots ? slots->mContainingShadow.get() : nullptr;
|
|
|
|
}
|
2013-12-02 14:26:11 +04:00
|
|
|
|
2018-01-15 09:42:47 +03:00
|
|
|
/**
|
|
|
|
* Gets the shadow host if this content is in a shadow tree. That is, the host
|
|
|
|
* of |GetContainingShadow|, if its not null.
|
|
|
|
*
|
|
|
|
* @return The shadow host, if this is in shadow tree, or null.
|
|
|
|
*/
|
|
|
|
nsIContent* GetContainingShadowHost() const;
|
|
|
|
|
2017-10-19 09:31:36 +03:00
|
|
|
/**
|
|
|
|
* Gets the assigned slot associated with this content.
|
|
|
|
*
|
|
|
|
* @return The assigned slot element or null.
|
|
|
|
*/
|
2017-12-23 11:23:42 +03:00
|
|
|
mozilla::dom::HTMLSlotElement* GetAssignedSlot() const
|
|
|
|
{
|
|
|
|
const nsExtendedContentSlots* slots = GetExistingExtendedContentSlots();
|
|
|
|
return slots ? slots->mAssignedSlot.get() : nullptr;
|
|
|
|
}
|
2017-10-19 09:31:36 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the assigned slot associated with this content.
|
|
|
|
*
|
|
|
|
* @param aSlot The assigned slot.
|
|
|
|
*/
|
2017-12-23 11:23:42 +03:00
|
|
|
void SetAssignedSlot(mozilla::dom::HTMLSlotElement* aSlot);
|
2017-10-19 09:31:36 +03:00
|
|
|
|
2017-11-02 11:53:44 +03:00
|
|
|
/**
|
|
|
|
* Gets the assigned slot associated with this content based on parent's
|
|
|
|
* shadow root mode. Returns null if parent's shadow root is "closed".
|
|
|
|
* https://dom.spec.whatwg.org/#dom-slotable-assignedslot
|
|
|
|
*
|
|
|
|
* @return The assigned slot element or null.
|
|
|
|
*/
|
|
|
|
mozilla::dom::HTMLSlotElement* GetAssignedSlotByMode() const;
|
|
|
|
|
2017-10-23 16:52:08 +03:00
|
|
|
nsIContent* GetXBLInsertionParent() const
|
|
|
|
{
|
|
|
|
nsIContent* ip = GetXBLInsertionPoint();
|
|
|
|
return ip ? ip->GetParent() : nullptr;
|
|
|
|
}
|
|
|
|
|
2013-07-17 20:05:06 +04:00
|
|
|
/**
|
|
|
|
* Gets the insertion parent element of the XBL binding.
|
|
|
|
* The insertion parent is our one true parent in the transformed DOM.
|
|
|
|
*
|
|
|
|
* @return the insertion parent element.
|
|
|
|
*/
|
2017-12-23 11:23:42 +03:00
|
|
|
nsIContent* GetXBLInsertionPoint() const
|
|
|
|
{
|
|
|
|
const nsExtendedContentSlots* slots = GetExistingExtendedContentSlots();
|
|
|
|
return slots ? slots->mXBLInsertionPoint.get() : nullptr;
|
|
|
|
}
|
2013-07-17 20:05:06 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the insertion parent element of the XBL binding.
|
|
|
|
*
|
|
|
|
* @param aContent The insertion parent element.
|
|
|
|
*/
|
2017-12-23 11:23:42 +03:00
|
|
|
void SetXBLInsertionPoint(nsIContent* aContent);
|
2013-07-17 20:05:06 +04:00
|
|
|
|
2010-04-16 22:15:28 +04:00
|
|
|
/**
|
2016-08-19 03:03:49 +03:00
|
|
|
* Same as GetFlattenedTreeParentNode, but returns null if the parent is
|
|
|
|
* non-nsIContent.
|
|
|
|
*/
|
2017-12-31 22:57:32 +03:00
|
|
|
inline nsIContent* GetFlattenedTreeParent() const;
|
2016-08-19 03:03:49 +03:00
|
|
|
|
2007-01-04 13:53:59 +03:00
|
|
|
/**
|
|
|
|
* API to check if this is a link that's traversed in response to user input
|
|
|
|
* (e.g. a click event). Specializations for HTML/SVG/generic XML allow for
|
|
|
|
* different types of link in different types of content.
|
|
|
|
*
|
|
|
|
* @param aURI Required out param. If this content is a link, a new nsIURI
|
|
|
|
* set to this link's URI will be passed out.
|
|
|
|
*
|
|
|
|
* @note The out param, aURI, is guaranteed to be set to a non-null pointer
|
2011-10-17 18:59:28 +04:00
|
|
|
* when the return value is true.
|
2007-01-04 13:53:59 +03:00
|
|
|
*
|
|
|
|
* XXXjwatt: IMO IsInteractiveLink would be a better name.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
virtual bool IsLink(nsIURI** aURI) const = 0;
|
2007-01-04 13:53:59 +03:00
|
|
|
|
2009-07-13 15:48:06 +04:00
|
|
|
/**
|
|
|
|
* Get a pointer to the full href URI (fully resolved and canonicalized,
|
|
|
|
* since it's an nsIURI object) for link elements.
|
|
|
|
*
|
|
|
|
* @return A pointer to the URI or null if the element is not a link or it
|
|
|
|
* has no HREF attribute.
|
|
|
|
*/
|
|
|
|
virtual already_AddRefed<nsIURI> GetHrefURI() const
|
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2009-07-13 15:48:06 +04:00
|
|
|
}
|
|
|
|
|
2002-03-31 14:14:01 +04:00
|
|
|
/**
|
|
|
|
* This method is called when the parser finishes creating the element. This
|
|
|
|
* particularly means that it has done everything you would expect it to have
|
|
|
|
* done after it encounters the > at the end of the tag (for HTML or XML).
|
|
|
|
* This includes setting the attributes, setting the document / form, and
|
|
|
|
* placing the element into the tree at its proper place.
|
|
|
|
*
|
|
|
|
* For container elements, this is called *before* any of the children are
|
|
|
|
* created or added into the tree.
|
|
|
|
*
|
|
|
|
* NOTE: this is currently only called for input and button, in the HTML
|
|
|
|
* content sink. If you want to call it on your element, modify the content
|
|
|
|
* sink of your choice to do so. This is an efficiency measure.
|
|
|
|
*
|
|
|
|
* If you also need to determine whether the parser is the one creating your
|
2003-10-30 16:47:29 +03:00
|
|
|
* element (through createElement() or cloneNode() generally) then add a
|
2012-08-22 19:56:38 +04:00
|
|
|
* uint32_t aFromParser to the NS_NewXXX() constructor for your element and
|
2013-03-28 23:41:32 +04:00
|
|
|
* have the parser pass the appropriate flags. See HTMLInputElement.cpp and
|
2002-03-31 14:14:01 +04:00
|
|
|
* nsHTMLContentSink::MakeContentObject().
|
|
|
|
*
|
|
|
|
* DO NOT USE THIS METHOD to get around the fact that it's hard to deal with
|
|
|
|
* attributes dynamically. If you make attributes affect your element from
|
|
|
|
* this method, it will only happen on initialization and JavaScript will not
|
|
|
|
* be able to create elements (which requires them to first create the
|
|
|
|
* element and then call setAttribute() directly, at which point
|
|
|
|
* DoneCreatingElement() has already been called and is out of the picture).
|
|
|
|
*/
|
2004-01-10 02:54:21 +03:00
|
|
|
virtual void DoneCreatingElement()
|
|
|
|
{
|
|
|
|
}
|
2002-03-31 14:14:01 +04:00
|
|
|
|
2004-06-02 04:25:00 +04:00
|
|
|
/**
|
|
|
|
* This method is called when the parser finishes creating the element's children,
|
|
|
|
* if any are present.
|
|
|
|
*
|
2017-07-29 02:44:39 +03:00
|
|
|
* NOTE: this is currently only called for textarea, select, and object
|
|
|
|
* elements in the HTML content sink. If you want to call it on your element,
|
|
|
|
* modify the content sink of your choice to do so. This is an efficiency
|
|
|
|
* measure.
|
2004-06-02 04:25:00 +04:00
|
|
|
*
|
|
|
|
* If you also need to determine whether the parser is the one creating your
|
|
|
|
* element (through createElement() or cloneNode() generally) then add a
|
|
|
|
* boolean aFromParser to the NS_NewXXX() constructor for your element and
|
2013-03-28 23:41:32 +04:00
|
|
|
* have the parser pass true. See HTMLInputElement.cpp and
|
2004-06-02 04:25:00 +04:00
|
|
|
* nsHTMLContentSink::MakeContentObject().
|
2005-09-22 06:33:36 +04:00
|
|
|
*
|
|
|
|
* @param aHaveNotified Whether there has been a
|
|
|
|
* ContentInserted/ContentAppended notification for this content node
|
|
|
|
* yet.
|
2004-06-02 04:25:00 +04:00
|
|
|
*/
|
2011-11-16 11:50:18 +04:00
|
|
|
virtual void DoneAddingChildren(bool aHaveNotified)
|
2004-06-02 04:25:00 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-07-29 02:44:39 +03:00
|
|
|
* For HTML textarea, select, and object elements, returns true if all
|
|
|
|
* children have been added OR if the element was not created by the parser.
|
|
|
|
* Returns true for all other elements.
|
|
|
|
*
|
2011-10-17 18:59:28 +04:00
|
|
|
* @returns false if the element was created by the parser and
|
2017-07-29 02:44:39 +03:00
|
|
|
* it is an HTML textarea, select, or object
|
2006-04-05 10:04:29 +04:00
|
|
|
* element and not all children have been added.
|
2017-07-29 02:44:39 +03:00
|
|
|
*
|
2011-10-17 18:59:28 +04:00
|
|
|
* @returns true otherwise.
|
2004-06-02 04:25:00 +04:00
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
virtual bool IsDoneAddingChildren()
|
2004-06-02 04:25:00 +04:00
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2004-06-02 04:25:00 +04:00
|
|
|
}
|
|
|
|
|
2005-11-02 03:41:51 +03:00
|
|
|
/**
|
|
|
|
* Get the ID of this content node (the atom corresponding to the
|
2014-05-30 11:36:53 +04:00
|
|
|
* value of the id attribute). This may be null if there is no ID.
|
2005-11-02 03:41:51 +03:00
|
|
|
*/
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* GetID() const {
|
2011-04-08 06:29:50 +04:00
|
|
|
if (HasID()) {
|
2010-06-04 05:09:20 +04:00
|
|
|
return DoGetID();
|
|
|
|
}
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2010-06-04 05:09:20 +04:00
|
|
|
}
|
2005-11-02 03:41:51 +03:00
|
|
|
|
2007-06-28 06:48:16 +04:00
|
|
|
/**
|
|
|
|
* Should be called when the node can become editable or when it can stop
|
|
|
|
* being editable (for example when its contentEditable attribute changes,
|
2011-06-01 05:46:57 +04:00
|
|
|
* when it is moved into an editable parent, ...). If aNotify is true and
|
|
|
|
* the node is an element, this will notify the state change.
|
2007-06-28 06:48:16 +04:00
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
virtual void UpdateEditableState(bool aNotify);
|
2006-06-02 17:28:14 +04:00
|
|
|
|
2007-11-30 20:57:03 +03:00
|
|
|
/**
|
2008-04-11 02:47:01 +04:00
|
|
|
* Destroy this node and its children. Ideally this shouldn't be needed
|
2007-11-30 20:57:03 +03:00
|
|
|
* but for now we need to do it to break cycles.
|
|
|
|
*/
|
2016-03-04 19:54:10 +03:00
|
|
|
virtual void DestroyContent()
|
|
|
|
{
|
|
|
|
}
|
2007-11-30 20:57:03 +03:00
|
|
|
|
2008-04-11 02:47:01 +04:00
|
|
|
/**
|
|
|
|
* Saves the form state of this node and its children.
|
|
|
|
*/
|
|
|
|
virtual void SaveSubtreeState() = 0;
|
|
|
|
|
2009-12-25 00:20:05 +03:00
|
|
|
/**
|
|
|
|
* Getter and setter for our primary frame pointer. This is the frame that
|
|
|
|
* is most closely associated with the content. A frame is more closely
|
|
|
|
* associated with the content than another frame if the one frame contains
|
|
|
|
* directly or indirectly the other frame (e.g., when a frame is scrolled
|
|
|
|
* there is a scroll frame that contains the frame being scrolled). This
|
|
|
|
* frame is always the first continuation.
|
|
|
|
*
|
|
|
|
* In the case of absolutely positioned elements and floated elements, this
|
|
|
|
* frame is the out of flow frame, not the placeholder.
|
|
|
|
*/
|
2012-03-15 00:14:02 +04:00
|
|
|
nsIFrame* GetPrimaryFrame() const
|
|
|
|
{
|
2016-03-31 13:58:25 +03:00
|
|
|
return (IsInUncomposedDoc() || IsInShadowTree()) ? mPrimaryFrame : nullptr;
|
2012-03-15 00:14:02 +04:00
|
|
|
}
|
2017-09-17 18:21:32 +03:00
|
|
|
|
|
|
|
// Defined in nsIContentInlines.h because it needs nsIFrame.
|
|
|
|
inline void SetPrimaryFrame(nsIFrame* aFrame);
|
2009-12-25 00:20:05 +03:00
|
|
|
|
2011-12-20 18:54:14 +04:00
|
|
|
nsresult LookupNamespaceURIInternal(const nsAString& aNamespacePrefix,
|
|
|
|
nsAString& aNamespaceURI) const;
|
2010-04-19 19:40:16 +04:00
|
|
|
|
2010-07-22 20:22:44 +04:00
|
|
|
/**
|
|
|
|
* If this content has independent selection, e.g., if this is input field
|
|
|
|
* or textarea, this return TRUE. Otherwise, false.
|
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool HasIndependentSelection();
|
2010-07-22 20:22:44 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* If the content is a part of HTML editor, this returns editing
|
|
|
|
* host content. When the content is in designMode, this returns its body
|
|
|
|
* element. Also, when the content isn't editable, this returns null.
|
|
|
|
*/
|
2012-05-06 11:53:11 +04:00
|
|
|
mozilla::dom::Element* GetEditingHost();
|
2010-07-22 20:22:44 +04:00
|
|
|
|
2017-06-07 06:10:07 +03:00
|
|
|
bool SupportsLangAttr() const {
|
|
|
|
return IsHTMLElement() || IsSVGElement() || IsXULElement();
|
|
|
|
}
|
|
|
|
|
2011-08-12 23:12:45 +04:00
|
|
|
/**
|
2015-10-13 14:08:30 +03:00
|
|
|
* Determining language. Look at the nearest ancestor element that has a lang
|
2012-02-20 00:49:34 +04:00
|
|
|
* attribute in the XML namespace or is an HTML/SVG element and has a lang in
|
2017-06-15 22:48:26 +03:00
|
|
|
* no namespace attribute.
|
|
|
|
*
|
|
|
|
* Returns null if no language was specified. Can return the empty atom.
|
2011-08-12 23:12:45 +04:00
|
|
|
*/
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* GetLang() const;
|
2017-06-15 22:48:26 +03:00
|
|
|
|
2015-10-13 14:08:30 +03:00
|
|
|
bool GetLang(nsAString& aResult) const {
|
2017-06-15 22:48:26 +03:00
|
|
|
if (auto* lang = GetLang()) {
|
|
|
|
aResult.Assign(nsDependentAtomString(lang));
|
|
|
|
return true;
|
2011-08-12 23:12:45 +04:00
|
|
|
}
|
2017-06-15 22:48:26 +03:00
|
|
|
|
2015-10-13 14:08:30 +03:00
|
|
|
return false;
|
2011-08-12 23:12:45 +04:00
|
|
|
}
|
|
|
|
|
2011-02-11 10:47:00 +03:00
|
|
|
// Overloaded from nsINode
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual already_AddRefed<nsIURI> GetBaseURI(bool aTryUseXHRDocBaseURI = false) const override;
|
2011-02-11 10:47:00 +03:00
|
|
|
|
2017-03-10 10:04:34 +03:00
|
|
|
// Returns base URI for style attribute.
|
2017-10-06 07:45:33 +03:00
|
|
|
nsIURI* GetBaseURIForStyleAttr() const;
|
2017-03-10 10:04:34 +03:00
|
|
|
|
2017-04-06 09:51:29 +03:00
|
|
|
// Returns the URL data for style attribute.
|
2017-11-06 00:23:49 +03:00
|
|
|
// If aSubjectPrincipal is passed, it should be the scripted principal
|
|
|
|
// responsible for generating the URL data.
|
|
|
|
already_AddRefed<mozilla::URLExtraData>
|
|
|
|
GetURLDataForStyleAttr(nsIPrincipal* aSubjectPrincipal = nullptr) const;
|
2017-04-06 09:51:29 +03:00
|
|
|
|
2018-04-05 20:42:41 +03:00
|
|
|
void GetEventTargetParent(mozilla::EventChainPreVisitor& aVisitor) override;
|
2011-06-24 06:17:59 +04:00
|
|
|
|
2018-03-29 01:07:40 +03:00
|
|
|
bool IsPurple() const
|
|
|
|
{
|
|
|
|
return mRefCnt.IsPurple();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RemovePurple()
|
|
|
|
{
|
|
|
|
mRefCnt.RemovePurple();
|
|
|
|
}
|
2012-01-31 00:08:13 +04:00
|
|
|
|
2018-03-29 01:07:40 +03:00
|
|
|
bool OwnedOnlyByTheDOMTree()
|
|
|
|
{
|
|
|
|
uint32_t rc = mRefCnt.get();
|
|
|
|
if (GetParent()) {
|
|
|
|
--rc;
|
|
|
|
}
|
|
|
|
rc -= GetChildCount();
|
|
|
|
return rc == 0;
|
|
|
|
}
|
2017-07-19 04:04:34 +03:00
|
|
|
|
2010-06-04 05:09:20 +04:00
|
|
|
protected:
|
2017-12-23 11:23:42 +03:00
|
|
|
/**
|
|
|
|
* Lazily allocated extended slots to avoid
|
|
|
|
* that may only be instantiated when a content object is accessed
|
|
|
|
* through the DOM. Rather than burn actual slots in the content
|
|
|
|
* objects for each of these instance variables, we put them off
|
|
|
|
* in a side structure that's only allocated when the content is
|
|
|
|
* accessed through the DOM.
|
|
|
|
*/
|
|
|
|
class nsExtendedContentSlots
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsExtendedContentSlots();
|
|
|
|
virtual ~nsExtendedContentSlots();
|
|
|
|
|
2018-06-30 01:30:37 +03:00
|
|
|
virtual void TraverseExtendedSlots(nsCycleCollectionTraversalCallback&);
|
|
|
|
virtual void UnlinkExtendedSlots();
|
2017-12-23 11:23:42 +03:00
|
|
|
|
2018-08-27 22:20:53 +03:00
|
|
|
virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
|
|
|
|
2017-12-23 11:23:42 +03:00
|
|
|
/**
|
|
|
|
* The nearest enclosing content node with a binding that created us.
|
2018-04-13 17:32:50 +03:00
|
|
|
* TODO(emilio): This should be an Element*.
|
|
|
|
*
|
2017-12-23 11:23:42 +03:00
|
|
|
* @see nsIContent::GetBindingParent
|
|
|
|
*/
|
2018-05-22 00:11:11 +03:00
|
|
|
nsCOMPtr<nsIContent> mBindingParent;
|
2017-12-23 11:23:42 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @see nsIContent::GetXBLInsertionPoint
|
|
|
|
*/
|
|
|
|
nsCOMPtr<nsIContent> mXBLInsertionPoint;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see nsIContent::GetContainingShadow
|
|
|
|
*/
|
|
|
|
RefPtr<mozilla::dom::ShadowRoot> mContainingShadow;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see nsIContent::GetAssignedSlot
|
|
|
|
*/
|
|
|
|
RefPtr<mozilla::dom::HTMLSlotElement> mAssignedSlot;
|
|
|
|
};
|
|
|
|
|
|
|
|
class nsContentSlots : public nsINode::nsSlots
|
|
|
|
{
|
|
|
|
public:
|
2018-06-30 01:30:37 +03:00
|
|
|
nsContentSlots()
|
|
|
|
: nsINode::nsSlots()
|
|
|
|
, mExtendedSlots(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
~nsContentSlots()
|
|
|
|
{
|
|
|
|
if (!(mExtendedSlots & sNonOwningExtendedSlotsFlag)) {
|
|
|
|
delete GetExtendedContentSlots();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-23 11:23:42 +03:00
|
|
|
void Traverse(nsCycleCollectionTraversalCallback& aCb) override
|
|
|
|
{
|
|
|
|
nsINode::nsSlots::Traverse(aCb);
|
|
|
|
if (mExtendedSlots) {
|
2018-06-30 01:30:37 +03:00
|
|
|
GetExtendedContentSlots()->TraverseExtendedSlots(aCb);
|
2017-12-23 11:23:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Unlink() override
|
|
|
|
{
|
|
|
|
nsINode::nsSlots::Unlink();
|
|
|
|
if (mExtendedSlots) {
|
2018-06-30 01:30:37 +03:00
|
|
|
GetExtendedContentSlots()->UnlinkExtendedSlots();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetExtendedContentSlots(nsExtendedContentSlots* aSlots, bool aOwning)
|
|
|
|
{
|
|
|
|
mExtendedSlots = reinterpret_cast<uintptr_t>(aSlots);
|
|
|
|
if (!aOwning) {
|
|
|
|
mExtendedSlots |= sNonOwningExtendedSlotsFlag;
|
2017-12-23 11:23:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-27 22:20:53 +03:00
|
|
|
// OwnsExtendedSlots returns true if we have no extended slots or if we
|
|
|
|
// have extended slots and own them.
|
2018-06-30 01:30:37 +03:00
|
|
|
bool OwnsExtendedSlots() const
|
|
|
|
{
|
|
|
|
return !(mExtendedSlots & sNonOwningExtendedSlotsFlag);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsExtendedContentSlots* GetExtendedContentSlots() const
|
|
|
|
{
|
|
|
|
return reinterpret_cast<nsExtendedContentSlots*>(
|
|
|
|
mExtendedSlots & ~sNonOwningExtendedSlotsFlag);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
static const uintptr_t sNonOwningExtendedSlotsFlag = 1u;
|
|
|
|
|
|
|
|
uintptr_t mExtendedSlots;
|
2017-12-23 11:23:42 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
// Override from nsINode
|
|
|
|
nsContentSlots* CreateSlots() override
|
|
|
|
{
|
|
|
|
return new nsContentSlots();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsContentSlots* ContentSlots()
|
|
|
|
{
|
|
|
|
return static_cast<nsContentSlots*>(Slots());
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsContentSlots* GetExistingContentSlots() const
|
|
|
|
{
|
|
|
|
return static_cast<nsContentSlots*>(GetExistingSlots());
|
|
|
|
}
|
|
|
|
|
|
|
|
nsContentSlots* GetExistingContentSlots()
|
|
|
|
{
|
|
|
|
return static_cast<nsContentSlots*>(GetExistingSlots());
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual nsExtendedContentSlots* CreateExtendedSlots()
|
|
|
|
{
|
|
|
|
return new nsExtendedContentSlots();
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsExtendedContentSlots* GetExistingExtendedContentSlots() const
|
|
|
|
{
|
|
|
|
const nsContentSlots* slots = GetExistingContentSlots();
|
2018-06-30 01:30:37 +03:00
|
|
|
return slots ? slots->GetExtendedContentSlots() : nullptr;
|
2017-12-23 11:23:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsExtendedContentSlots* GetExistingExtendedContentSlots()
|
|
|
|
{
|
|
|
|
nsContentSlots* slots = GetExistingContentSlots();
|
2018-06-30 01:30:37 +03:00
|
|
|
return slots ? slots->GetExtendedContentSlots() : nullptr;
|
2017-12-23 11:23:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsExtendedContentSlots* ExtendedContentSlots()
|
|
|
|
{
|
|
|
|
nsContentSlots* slots = ContentSlots();
|
2018-06-30 01:30:37 +03:00
|
|
|
if (!slots->GetExtendedContentSlots()) {
|
|
|
|
slots->SetExtendedContentSlots(CreateExtendedSlots(), true);
|
2017-12-23 11:23:42 +03:00
|
|
|
}
|
2018-06-30 01:30:37 +03:00
|
|
|
return slots->GetExtendedContentSlots();
|
2017-12-23 11:23:42 +03:00
|
|
|
}
|
|
|
|
|
2010-06-04 05:09:20 +04:00
|
|
|
/**
|
|
|
|
* Hook for implementing GetID. This is guaranteed to only be
|
2011-04-08 06:29:50 +04:00
|
|
|
* called if HasID() is true.
|
2010-06-04 05:09:20 +04:00
|
|
|
*/
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* DoGetID() const;
|
2010-06-04 05:09:20 +04:00
|
|
|
|
2018-03-29 01:07:40 +03:00
|
|
|
~nsIContent() {}
|
|
|
|
|
2008-09-11 07:22:20 +04:00
|
|
|
public:
|
2001-10-16 09:31:36 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
/**
|
|
|
|
* List the content (and anything it contains) out to the given
|
|
|
|
* file stream. Use aIndent as the base indent during formatting.
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual void List(FILE* out = stdout, int32_t aIndent = 0) const = 0;
|
2001-10-16 09:31:36 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Dump the content (and anything it contains) out to the given
|
|
|
|
* file stream. Use aIndent as the base indent during formatting.
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual void DumpContent(FILE* out = stdout, int32_t aIndent = 0,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aDumpAll = true) const = 0;
|
2001-10-16 09:31:36 +04:00
|
|
|
#endif
|
2003-11-07 12:47:23 +03:00
|
|
|
|
2004-07-25 01:12:43 +04:00
|
|
|
enum ETabFocusType {
|
2016-10-11 21:13:36 +03:00
|
|
|
eTabFocus_textControlsMask = (1<<0), // textboxes and lists always tabbable
|
2004-07-25 01:12:43 +04:00
|
|
|
eTabFocus_formElementsMask = (1<<1), // non-text form elements
|
|
|
|
eTabFocus_linksMask = (1<<2), // links
|
|
|
|
eTabFocus_any = 1 + (1<<1) + (1<<2) // everything that can be focused
|
|
|
|
};
|
|
|
|
|
|
|
|
// Tab focus model bit field:
|
2012-08-22 19:56:38 +04:00
|
|
|
static int32_t sTabFocusModel;
|
2004-07-25 01:12:43 +04:00
|
|
|
|
2005-01-30 02:47:35 +03:00
|
|
|
// accessibility.tabfocus_applies_to_xul pref - if it is set to true,
|
|
|
|
// the tabfocus bit field applies to xul elements.
|
2011-09-29 10:19:26 +04:00
|
|
|
static bool sTabFocusModelAppliesToXUL;
|
1998-04-14 00:24:54 +04:00
|
|
|
};
|
|
|
|
|
2005-11-11 17:36:26 +03:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsIContent, NS_ICONTENT_IID)
|
|
|
|
|
2012-06-10 16:39:21 +04:00
|
|
|
inline nsIContent* nsINode::AsContent()
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(IsContent());
|
|
|
|
return static_cast<nsIContent*>(this);
|
|
|
|
}
|
|
|
|
|
2018-04-15 12:37:22 +03:00
|
|
|
inline const nsIContent* nsINode::AsContent() const
|
|
|
|
{
|
|
|
|
return const_cast<nsINode*>(this)->AsContent();
|
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
#endif /* nsIContent_h___ */
|