2015-05-03 19:32:37 +00: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 11:12:37 +00: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/. */
|
2006-01-19 03:34:18 +00:00
|
|
|
|
|
|
|
#ifndef nsINode_h___
|
|
|
|
#define nsINode_h___
|
|
|
|
|
2012-10-26 13:32:10 +00:00
|
|
|
#include "mozilla/Likely.h"
|
2016-07-21 19:47:29 +00:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2012-08-06 12:02:08 +00:00
|
|
|
#include "nsCOMPtr.h" // for member, local
|
|
|
|
#include "nsGkAtoms.h" // for nsGkAtoms::baseURIProperty
|
2012-10-09 12:31:24 +00:00
|
|
|
#include "nsIDOMNode.h"
|
2014-06-20 02:01:40 +00:00
|
|
|
#include "mozilla/dom/NodeInfo.h" // member (in nsCOMPtr)
|
2012-08-06 12:02:08 +00:00
|
|
|
#include "nsIVariant.h" // for use in GetUserData()
|
|
|
|
#include "nsNodeInfoManager.h" // for use in NodePrincipal()
|
|
|
|
#include "nsPropertyTable.h" // for typedefs
|
|
|
|
#include "nsTObserverArray.h" // for member
|
2013-08-29 21:18:25 +00:00
|
|
|
#include "mozilla/ErrorResult.h"
|
2013-06-23 12:03:39 +00:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2012-12-07 01:39:51 +00:00
|
|
|
#include "mozilla/dom/EventTarget.h" // for base class
|
2013-08-28 02:59:14 +00:00
|
|
|
#include "js/TypeDecls.h" // for Handle, Value, JSObject, JSContext
|
2013-10-11 16:28:23 +00:00
|
|
|
#include "mozilla/dom/DOMString.h"
|
2014-03-19 16:35:45 +00:00
|
|
|
#include "mozilla/dom/BindingDeclarations.h"
|
2015-07-08 19:58:07 +00:00
|
|
|
#include <iosfwd>
|
2006-01-19 03:34:18 +00:00
|
|
|
|
2011-11-03 15:57:30 +00:00
|
|
|
// Including 'windows.h' will #define GetClassInfo to something else.
|
|
|
|
#ifdef XP_WIN
|
|
|
|
#ifdef GetClassInfo
|
|
|
|
#undef GetClassInfo
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2012-08-06 12:02:08 +00:00
|
|
|
class nsAttrAndChildArray;
|
|
|
|
class nsChildContentList;
|
2014-06-19 00:57:51 +00:00
|
|
|
struct nsCSSSelectorList;
|
2012-10-09 12:31:24 +00:00
|
|
|
class nsDOMAttributeMap;
|
2015-03-14 05:34:40 +00:00
|
|
|
class nsIAnimationObserver;
|
2006-01-19 03:34:18 +00:00
|
|
|
class nsIContent;
|
|
|
|
class nsIDocument;
|
2011-09-11 22:45:39 +00:00
|
|
|
class nsIDOMElement;
|
2009-01-02 17:00:18 +00:00
|
|
|
class nsIDOMNodeList;
|
2012-08-06 12:02:08 +00:00
|
|
|
class nsIFrame;
|
|
|
|
class nsIMutationObserver;
|
2015-04-17 01:39:13 +00:00
|
|
|
class nsINode;
|
2015-05-19 10:33:00 +00:00
|
|
|
class nsINodeList;
|
2008-02-20 07:40:04 +00:00
|
|
|
class nsIPresShell;
|
2006-02-02 20:02:34 +00:00
|
|
|
class nsIPrincipal;
|
2012-08-06 12:02:08 +00:00
|
|
|
class nsIURI;
|
2006-11-11 01:43:11 +00:00
|
|
|
class nsNodeSupportsWeakRefTearoff;
|
2012-08-06 12:02:08 +00:00
|
|
|
class nsNodeWeakReference;
|
2013-09-11 19:43:01 +00:00
|
|
|
class nsDOMMutationObserver;
|
2016-07-21 19:47:29 +00:00
|
|
|
|
2010-04-30 13:12:05 +00:00
|
|
|
namespace mozilla {
|
2014-03-17 06:56:53 +00:00
|
|
|
class EventListenerManager;
|
2017-06-22 06:21:31 +00:00
|
|
|
class TextEditor;
|
2010-04-30 13:12:05 +00:00
|
|
|
namespace dom {
|
2012-11-30 16:04:11 +00:00
|
|
|
/**
|
2017-05-26 18:02:00 +00:00
|
|
|
* @return true if aChar is what the WHATWG defines as a 'ascii whitespace'.
|
|
|
|
* https://infra.spec.whatwg.org/#ascii-whitespace
|
2012-11-30 16:04:11 +00:00
|
|
|
*/
|
2014-01-04 15:02:17 +00:00
|
|
|
inline bool IsSpaceCharacter(char16_t aChar) {
|
2012-11-30 16:04:11 +00:00
|
|
|
return aChar == ' ' || aChar == '\t' || aChar == '\n' || aChar == '\r' ||
|
|
|
|
aChar == '\f';
|
|
|
|
}
|
|
|
|
inline bool IsSpaceCharacter(char aChar) {
|
|
|
|
return aChar == ' ' || aChar == '\t' || aChar == '\n' || aChar == '\r' ||
|
|
|
|
aChar == '\f';
|
|
|
|
}
|
2016-08-23 18:15:15 +00:00
|
|
|
class AccessibleNode;
|
2014-03-12 01:11:38 +00:00
|
|
|
struct BoxQuadOptions;
|
2014-03-12 01:11:39 +00:00
|
|
|
struct ConvertCoordinateOptions;
|
|
|
|
class DOMPoint;
|
2014-03-12 01:11:38 +00:00
|
|
|
class DOMQuad;
|
2014-03-12 01:11:39 +00:00
|
|
|
class DOMRectReadOnly;
|
|
|
|
class Element;
|
2012-10-16 11:51:00 +00:00
|
|
|
class EventHandlerNonNull;
|
2012-10-09 12:31:24 +00:00
|
|
|
template<typename T> class Optional;
|
2016-04-12 02:48:14 +00:00
|
|
|
class OwningNodeOrString;
|
|
|
|
template<typename> class Sequence;
|
2014-08-13 11:53:32 +00:00
|
|
|
class Text;
|
2014-03-12 01:11:39 +00:00
|
|
|
class TextOrElementOrDocument;
|
|
|
|
struct DOMPointInit;
|
2017-01-15 17:46:00 +00:00
|
|
|
struct GetRootNodeOptions;
|
2017-02-01 20:43:36 +00:00
|
|
|
enum class CallerType : uint32_t;
|
2010-04-30 13:12:05 +00:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2014-07-17 03:10:10 +00:00
|
|
|
#define NODE_FLAG_BIT(n_) \
|
|
|
|
(nsWrapperCache::FlagsType(1U) << (WRAPPER_CACHE_FLAGS_BITS_USED + (n_)))
|
2012-10-02 00:52:06 +00:00
|
|
|
|
2007-07-10 22:49:42 +00:00
|
|
|
enum {
|
2012-02-27 14:03:15 +00:00
|
|
|
// This bit will be set if the node has a listener manager.
|
2012-10-02 00:52:06 +00:00
|
|
|
NODE_HAS_LISTENERMANAGER = NODE_FLAG_BIT(0),
|
2006-05-15 07:03:15 +00:00
|
|
|
|
2007-07-10 22:49:42 +00:00
|
|
|
// Whether this node has had any properties set on it
|
2012-10-02 00:52:06 +00:00
|
|
|
NODE_HAS_PROPERTIES = NODE_FLAG_BIT(1),
|
2006-05-15 07:03:15 +00:00
|
|
|
|
2009-02-24 18:39:09 +00:00
|
|
|
// Whether this node is the root of an anonymous subtree. Note that this
|
|
|
|
// need not be a native anonymous subtree. Any anonymous subtree, including
|
|
|
|
// XBL-generated ones, will do. This flag is set-once: once a node has it,
|
|
|
|
// it must not be removed.
|
2007-07-10 22:49:42 +00:00
|
|
|
// NOTE: Should only be used on nsIContent nodes
|
2013-09-24 19:28:32 +00:00
|
|
|
NODE_IS_ANONYMOUS_ROOT = NODE_FLAG_BIT(2),
|
2009-02-24 18:39:09 +00:00
|
|
|
|
|
|
|
// Whether the node has some ancestor, possibly itself, that is native
|
|
|
|
// anonymous. This includes ancestors crossing XBL scopes, in cases when an
|
|
|
|
// XBL binding is attached to an element which has a native anonymous
|
|
|
|
// ancestor. This flag is set-once: once a node has it, it must not be
|
|
|
|
// removed.
|
|
|
|
// NOTE: Should only be used on nsIContent nodes
|
2014-04-06 19:32:38 +00:00
|
|
|
NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE = NODE_FLAG_BIT(3),
|
2006-08-03 08:57:02 +00:00
|
|
|
|
2009-02-24 18:39:09 +00:00
|
|
|
// Whether this node is the root of a native anonymous (from the perspective
|
|
|
|
// of its parent) subtree. This flag is set-once: once a node has it, it
|
|
|
|
// must not be removed.
|
|
|
|
// NOTE: Should only be used on nsIContent nodes
|
2012-10-02 00:52:06 +00:00
|
|
|
NODE_IS_NATIVE_ANONYMOUS_ROOT = NODE_FLAG_BIT(4),
|
2009-02-24 18:39:09 +00:00
|
|
|
|
2007-07-10 22:49:42 +00:00
|
|
|
// Forces the XBL code to treat this node as if it were
|
|
|
|
// in the document and therefore should get bindings attached.
|
2012-10-02 00:52:06 +00:00
|
|
|
NODE_FORCE_XBL_BINDINGS = NODE_FLAG_BIT(5),
|
2007-05-10 20:21:12 +00:00
|
|
|
|
2007-07-10 22:49:42 +00:00
|
|
|
// Whether a binding manager may have a pointer to this
|
2012-10-02 00:52:06 +00:00
|
|
|
NODE_MAY_BE_IN_BINDING_MNGR = NODE_FLAG_BIT(6),
|
2007-05-11 18:34:12 +00:00
|
|
|
|
2012-10-02 00:52:06 +00:00
|
|
|
NODE_IS_EDITABLE = NODE_FLAG_BIT(7),
|
2007-06-28 02:48:16 +00:00
|
|
|
|
2017-01-21 02:28:46 +00:00
|
|
|
// This node was created by layout as native anonymous content. This
|
|
|
|
// generally corresponds to things created by nsIAnonymousContentCreator,
|
|
|
|
// though there are exceptions (svg:use content does not have this flag
|
|
|
|
// set, and any non-nsIAnonymousContentCreator callers of
|
|
|
|
// SetIsNativeAnonymousRoot also get this flag).
|
|
|
|
//
|
|
|
|
// One very important aspect here is that this node is not transitive over
|
|
|
|
// the subtree (if you want that, use NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE).
|
|
|
|
// If Gecko code somewhere attaches children to a node with this bit set,
|
|
|
|
// the children will not have the bit themselves unless the calling code sets
|
|
|
|
// it explicitly. This means that XBL content bound to NAC doesn't get this
|
|
|
|
// bit, nor do nodes inserted by editor.
|
|
|
|
//
|
|
|
|
// For now, this bit exists primarily to control style inheritance behavior,
|
|
|
|
// since the nodes for which we set it are often used to implement pseudo-
|
|
|
|
// elements, which need to inherit style from a script-visible element.
|
|
|
|
//
|
|
|
|
// A more general principle for this bit might be this: If the node is entirely
|
|
|
|
// a detail of layout, is not script-observable in any way, and other engines
|
|
|
|
// might accomplish the same task with a nodeless layout frame, then the node
|
|
|
|
// should have this bit set.
|
|
|
|
NODE_IS_NATIVE_ANONYMOUS = NODE_FLAG_BIT(8),
|
2007-09-18 08:38:24 +00:00
|
|
|
|
2013-12-02 10:26:11 +00:00
|
|
|
// Whether the node participates in a shadow tree.
|
|
|
|
NODE_IS_IN_SHADOW_TREE = NODE_FLAG_BIT(9),
|
|
|
|
|
2008-02-19 06:17:07 +00:00
|
|
|
// Node has an :empty or :-moz-only-whitespace selector
|
2012-10-02 00:52:06 +00:00
|
|
|
NODE_HAS_EMPTY_SELECTOR = NODE_FLAG_BIT(10),
|
2008-02-19 06:17:07 +00:00
|
|
|
|
|
|
|
// A child of the node has a selector such that any insertion,
|
|
|
|
// removal, or appending of children requires restyling the parent.
|
2012-10-02 00:52:06 +00:00
|
|
|
NODE_HAS_SLOW_SELECTOR = NODE_FLAG_BIT(11),
|
2008-02-19 06:17:07 +00:00
|
|
|
|
|
|
|
// A child of the node has a :first-child, :-moz-first-node,
|
|
|
|
// :only-child, :last-child or :-moz-last-node selector.
|
2012-10-02 00:52:06 +00:00
|
|
|
NODE_HAS_EDGE_CHILD_SELECTOR = NODE_FLAG_BIT(12),
|
2008-02-19 06:17:07 +00:00
|
|
|
|
|
|
|
// A child of the node has a selector such that any insertion or
|
2010-05-15 05:01:46 +00:00
|
|
|
// removal of children requires restyling later siblings of that
|
|
|
|
// element. Additionally (in this manner it is stronger than
|
|
|
|
// NODE_HAS_SLOW_SELECTOR), if a child's style changes due to any
|
|
|
|
// other content tree changes (e.g., the child changes to or from
|
|
|
|
// matching :empty due to a grandchild insertion or removal), the
|
|
|
|
// child's later siblings must also be restyled.
|
2012-10-02 00:52:06 +00:00
|
|
|
NODE_HAS_SLOW_SELECTOR_LATER_SIBLINGS = NODE_FLAG_BIT(13),
|
2008-02-19 06:17:07 +00:00
|
|
|
|
2012-10-02 00:52:06 +00:00
|
|
|
NODE_ALL_SELECTOR_FLAGS = NODE_HAS_EMPTY_SELECTOR |
|
|
|
|
NODE_HAS_SLOW_SELECTOR |
|
|
|
|
NODE_HAS_EDGE_CHILD_SELECTOR |
|
|
|
|
NODE_HAS_SLOW_SELECTOR_LATER_SIBLINGS,
|
2008-02-19 06:17:07 +00:00
|
|
|
|
2010-01-18 09:26:28 +00:00
|
|
|
// This node needs to go through frame construction to get a frame (or
|
|
|
|
// undisplayed entry).
|
2014-07-25 04:35:33 +00:00
|
|
|
NODE_NEEDS_FRAME = NODE_FLAG_BIT(14),
|
2010-01-18 09:26:28 +00:00
|
|
|
|
|
|
|
// At least one descendant in the flattened tree has NODE_NEEDS_FRAME set.
|
|
|
|
// This should be set on every node on the flattened tree path between the
|
|
|
|
// node(s) with NODE_NEEDS_FRAME and the root content.
|
2014-07-25 04:35:33 +00:00
|
|
|
NODE_DESCENDANTS_NEED_FRAMES = NODE_FLAG_BIT(15),
|
2010-01-18 09:26:28 +00:00
|
|
|
|
2010-06-04 01:08:57 +00:00
|
|
|
// Set if the node has the accesskey attribute set.
|
2014-07-25 04:35:33 +00:00
|
|
|
NODE_HAS_ACCESSKEY = NODE_FLAG_BIT(16),
|
2010-06-04 01:09:20 +00:00
|
|
|
|
2012-04-17 04:03:10 +00:00
|
|
|
// Set if the node has right-to-left directionality
|
2014-07-25 04:35:33 +00:00
|
|
|
NODE_HAS_DIRECTION_RTL = NODE_FLAG_BIT(17),
|
2012-04-17 04:03:10 +00:00
|
|
|
|
|
|
|
// Set if the node has left-to-right directionality
|
2014-07-25 04:35:33 +00:00
|
|
|
NODE_HAS_DIRECTION_LTR = NODE_FLAG_BIT(18),
|
2012-04-17 04:03:10 +00:00
|
|
|
|
2012-10-02 00:52:06 +00:00
|
|
|
NODE_ALL_DIRECTION_FLAGS = NODE_HAS_DIRECTION_LTR |
|
|
|
|
NODE_HAS_DIRECTION_RTL,
|
2012-04-17 04:03:10 +00:00
|
|
|
|
2014-07-25 04:35:33 +00:00
|
|
|
NODE_CHROME_ONLY_ACCESS = NODE_FLAG_BIT(19),
|
2012-10-10 19:04:42 +00:00
|
|
|
|
2014-07-25 04:35:33 +00:00
|
|
|
NODE_IS_ROOT_OF_CHROME_ONLY_ACCESS = NODE_FLAG_BIT(20),
|
2012-10-10 19:04:42 +00:00
|
|
|
|
2007-07-10 22:49:42 +00:00
|
|
|
// Remaining bits are node type specific.
|
2017-04-16 06:16:24 +00:00
|
|
|
NODE_TYPE_SPECIFIC_BITS_OFFSET = 21
|
2007-07-10 22:49:42 +00:00
|
|
|
};
|
|
|
|
|
2013-06-08 08:54:59 +00:00
|
|
|
// Make sure we have space for our bits
|
2013-11-11 08:03:59 +00:00
|
|
|
#define ASSERT_NODE_FLAGS_SPACE(n) \
|
2014-06-19 00:07:26 +00:00
|
|
|
static_assert(WRAPPER_CACHE_FLAGS_BITS_USED + (n) <= \
|
|
|
|
sizeof(nsWrapperCache::FlagsType) * 8, \
|
2013-11-11 08:03:59 +00:00
|
|
|
"Not enough space for our bits")
|
2013-06-08 08:54:59 +00:00
|
|
|
ASSERT_NODE_FLAGS_SPACE(NODE_TYPE_SPECIFIC_BITS_OFFSET);
|
|
|
|
|
2009-04-10 01:36:41 +00:00
|
|
|
/**
|
|
|
|
* Class used to detect unexpected mutations. To use the class create an
|
|
|
|
* nsMutationGuard on the stack before unexpected mutations could occur.
|
|
|
|
* You can then at any time call Mutated to check if any unexpected mutations
|
2010-05-13 12:19:50 +00:00
|
|
|
* have occurred.
|
2009-04-10 01:36:41 +00:00
|
|
|
*/
|
|
|
|
class nsMutationGuard {
|
|
|
|
public:
|
|
|
|
nsMutationGuard()
|
|
|
|
{
|
2014-08-01 20:30:58 +00:00
|
|
|
mStartingGeneration = sGeneration;
|
2009-04-10 01:36:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-05-13 12:19:50 +00:00
|
|
|
* Returns true if any unexpected mutations have occurred. You can pass in
|
2009-04-10 01:36:41 +00:00
|
|
|
* an 8-bit ignore count to ignore a number of expected mutations.
|
2014-08-01 20:30:58 +00:00
|
|
|
*
|
|
|
|
* We don't need to care about overflow because subtraction of uint64_t's is
|
|
|
|
* finding the difference between two elements of the group Z < 2^64. Once
|
|
|
|
* we know the difference between two elements we only need to check that is
|
|
|
|
* less than the given number of mutations to know less than that many
|
|
|
|
* mutations occured. Assuming constant 1ns mutations it would take 584
|
|
|
|
* years for sGeneration to fully wrap around so we can ignore a guard living
|
|
|
|
* through a full wrap around.
|
2009-04-10 01:36:41 +00:00
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
bool Mutated(uint8_t aIgnoreCount)
|
2009-04-10 01:36:41 +00:00
|
|
|
{
|
2014-08-01 20:30:58 +00:00
|
|
|
return (sGeneration - mStartingGeneration) > aIgnoreCount;
|
2009-04-10 01:36:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// This function should be called whenever a mutation that we want to keep
|
|
|
|
// track of happen. For now this is only done when children are added or
|
|
|
|
// removed, but we might do it for attribute changes too in the future.
|
|
|
|
static void DidMutate()
|
|
|
|
{
|
2014-08-01 20:30:58 +00:00
|
|
|
sGeneration++;
|
2009-04-10 01:36:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2014-08-01 20:30:58 +00:00
|
|
|
// This is the value sGeneration had when the guard was constructed.
|
|
|
|
uint64_t mStartingGeneration;
|
2014-03-04 23:39:42 +00:00
|
|
|
|
2014-08-01 20:30:58 +00:00
|
|
|
// This value is incremented on every mutation, for the life of the process.
|
|
|
|
static uint64_t sGeneration;
|
2009-04-10 01:36:41 +00:00
|
|
|
};
|
2006-07-02 07:23:10 +00:00
|
|
|
|
2014-03-04 23:39:42 +00:00
|
|
|
// This should be used for any nsINode sub-class that has fields of its own
|
|
|
|
// that it needs to measure; any sub-class that doesn't use it will inherit
|
|
|
|
// SizeOfExcludingThis from its super-class. SizeOfIncludingThis() need not be
|
|
|
|
// defined, it is inherited from nsINode.
|
|
|
|
// This macro isn't actually specific to nodes, and bug 956400 will move it into MFBT.
|
|
|
|
#define NS_DECL_SIZEOF_EXCLUDING_THIS \
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const override;
|
2014-03-04 23:39:42 +00:00
|
|
|
|
2010-04-23 02:41:38 +00:00
|
|
|
// Categories of node properties
|
|
|
|
// 0 is global.
|
|
|
|
#define DOM_USER_DATA 1
|
|
|
|
|
2006-01-19 03:34:18 +00:00
|
|
|
// IID for the nsINode interface
|
|
|
|
#define NS_INODE_IID \
|
2015-09-17 10:16:20 +00:00
|
|
|
{ 0x70ba4547, 0x7699, 0x44fc, \
|
|
|
|
{ 0xb3, 0x20, 0x52, 0xdb, 0xe3, 0xd1, 0xf9, 0x0a } }
|
2010-01-18 09:26:28 +00:00
|
|
|
|
2006-01-19 03:34:18 +00:00
|
|
|
/**
|
|
|
|
* An internal interface that abstracts some DOMNode-related parts that both
|
|
|
|
* nsIContent and nsIDocument share. An instance of this interface has a list
|
|
|
|
* of nsIContent children and provides access to them.
|
|
|
|
*/
|
2012-12-07 01:39:51 +00:00
|
|
|
class nsINode : public mozilla::dom::EventTarget
|
2008-11-13 16:54:52 +00:00
|
|
|
{
|
2006-01-19 03:34:18 +00:00
|
|
|
public:
|
2014-03-12 01:11:38 +00:00
|
|
|
typedef mozilla::dom::BoxQuadOptions BoxQuadOptions;
|
2014-03-12 01:11:39 +00:00
|
|
|
typedef mozilla::dom::ConvertCoordinateOptions ConvertCoordinateOptions;
|
|
|
|
typedef mozilla::dom::DOMPoint DOMPoint;
|
|
|
|
typedef mozilla::dom::DOMPointInit DOMPointInit;
|
2014-03-12 01:11:38 +00:00
|
|
|
typedef mozilla::dom::DOMQuad DOMQuad;
|
2014-03-12 01:11:39 +00:00
|
|
|
typedef mozilla::dom::DOMRectReadOnly DOMRectReadOnly;
|
2016-04-12 02:48:14 +00:00
|
|
|
typedef mozilla::dom::OwningNodeOrString OwningNodeOrString;
|
2014-03-12 01:11:39 +00:00
|
|
|
typedef mozilla::dom::TextOrElementOrDocument TextOrElementOrDocument;
|
2017-02-01 20:43:36 +00:00
|
|
|
typedef mozilla::dom::CallerType CallerType;
|
2014-03-12 01:11:38 +00:00
|
|
|
typedef mozilla::ErrorResult ErrorResult;
|
|
|
|
|
2016-04-12 02:48:14 +00:00
|
|
|
template<class T>
|
|
|
|
using Sequence = mozilla::dom::Sequence<T>;
|
|
|
|
|
2008-01-04 11:24:41 +00:00
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_INODE_IID)
|
|
|
|
|
2012-02-01 21:58:01 +00:00
|
|
|
// Among the sub-classes that inherit (directly or indirectly) from nsINode,
|
|
|
|
// measurement of the following members may be added later if DMD finds it is
|
|
|
|
// worthwhile:
|
|
|
|
// - nsGenericHTMLElement: mForm, mFieldSet
|
2013-04-22 01:25:29 +00:00
|
|
|
// - nsGenericHTMLFrameElement: mFrameLoader (bug 672539)
|
2012-12-21 14:06:50 +00:00
|
|
|
// - HTMLBodyElement: mContentStyleRule
|
|
|
|
// - HTMLDataListElement: mOptions
|
2013-02-08 16:34:47 +00:00
|
|
|
// - HTMLFieldSetElement: mElements, mDependentElements, mFirstLegend
|
2013-06-19 14:24:37 +00:00
|
|
|
// - HTMLFormElement: many!
|
2012-12-21 14:06:50 +00:00
|
|
|
// - HTMLFrameSetElement: mRowSpecs, mColSpecs
|
2013-03-28 19:41:32 +00:00
|
|
|
// - HTMLInputElement: mInputData, mFiles, mFileList, mStaticDocfileList
|
2012-02-01 21:58:01 +00:00
|
|
|
// - nsHTMLMapElement: mAreas
|
2013-03-19 12:23:54 +00:00
|
|
|
// - HTMLMediaElement: many!
|
2012-02-01 21:58:01 +00:00
|
|
|
// - nsHTMLOutputElement: mDefaultValue, mTokenList
|
|
|
|
// - nsHTMLRowElement: mCells
|
|
|
|
// - nsHTMLSelectElement: mOptions, mRestoreState
|
|
|
|
// - nsHTMLTableElement: mTBodies, mRows, mTableInheritedAttributes
|
|
|
|
// - nsHTMLTableSectionElement: mRows
|
|
|
|
// - nsHTMLTextAreaElement: mControllers, mState
|
|
|
|
//
|
|
|
|
// The following members don't need to be measured:
|
|
|
|
// - nsIContent: mPrimaryFrame, because it's non-owning and measured elsewhere
|
|
|
|
//
|
2015-01-03 02:13:39 +00:00
|
|
|
virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
2012-02-01 21:58:01 +00:00
|
|
|
|
|
|
|
// SizeOfIncludingThis doesn't need to be overridden by sub-classes because
|
|
|
|
// sub-classes of nsINode are guaranteed to be laid out in memory in such a
|
|
|
|
// way that |this| points to the start of the allocated object, even in
|
|
|
|
// methods of nsINode's sub-classes, and so |aMallocSizeOf(this)| is always
|
|
|
|
// safe to call no matter which object it was invoked on.
|
2013-06-23 12:03:39 +00:00
|
|
|
virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const {
|
2012-02-01 21:58:01 +00:00
|
|
|
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
|
|
|
|
}
|
2011-07-11 15:23:26 +00:00
|
|
|
|
2006-07-02 07:23:10 +00:00
|
|
|
friend class nsNodeUtils;
|
2006-11-11 00:36:03 +00:00
|
|
|
friend class nsNodeWeakReference;
|
|
|
|
friend class nsNodeSupportsWeakRefTearoff;
|
2010-05-11 01:12:33 +00:00
|
|
|
friend class nsAttrAndChildArray;
|
2006-07-02 07:23:10 +00:00
|
|
|
|
2006-08-31 19:59:43 +00:00
|
|
|
#ifdef MOZILLA_INTERNAL_API
|
2014-08-05 13:19:51 +00:00
|
|
|
explicit nsINode(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
2016-02-24 01:28:50 +00:00
|
|
|
: mNodeInfo(aNodeInfo)
|
|
|
|
, mParent(nullptr)
|
2017-05-09 13:41:08 +00:00
|
|
|
#ifndef BOOL_FLAGS_ON_WRAPPER_CACHE
|
2016-02-24 01:28:50 +00:00
|
|
|
, mBoolFlags(0)
|
2017-05-09 13:41:08 +00:00
|
|
|
#endif
|
2016-02-24 01:28:50 +00:00
|
|
|
, mNextSibling(nullptr)
|
|
|
|
, mPreviousSibling(nullptr)
|
|
|
|
, mFirstChild(nullptr)
|
|
|
|
, mSubtreeRoot(this)
|
|
|
|
, mSlots(nullptr)
|
2006-01-19 03:34:18 +00:00
|
|
|
{
|
2012-02-14 23:13:19 +00:00
|
|
|
}
|
2006-08-31 19:59:43 +00:00
|
|
|
#endif
|
2006-05-15 07:03:15 +00:00
|
|
|
|
|
|
|
virtual ~nsINode();
|
|
|
|
|
2006-05-05 06:52:21 +00:00
|
|
|
/**
|
|
|
|
* Bit-flags to pass (or'ed together) to IsNodeOfType()
|
|
|
|
*/
|
|
|
|
enum {
|
|
|
|
/** nsIContent nodes */
|
|
|
|
eCONTENT = 1 << 0,
|
|
|
|
/** nsIDocument nodes */
|
|
|
|
eDOCUMENT = 1 << 1,
|
|
|
|
/** nsIAttribute nodes */
|
|
|
|
eATTRIBUTE = 1 << 2,
|
|
|
|
/** text nodes */
|
2010-04-30 13:12:06 +00:00
|
|
|
eTEXT = 1 << 3,
|
2006-05-05 06:52:21 +00:00
|
|
|
/** xml processing instructions */
|
2010-04-30 13:12:06 +00:00
|
|
|
ePROCESSING_INSTRUCTION = 1 << 4,
|
2006-05-05 06:52:21 +00:00
|
|
|
/** comment nodes */
|
2010-04-30 13:12:06 +00:00
|
|
|
eCOMMENT = 1 << 5,
|
2006-05-05 06:52:21 +00:00
|
|
|
/** form control elements */
|
2010-04-30 13:12:06 +00:00
|
|
|
eHTML_FORM_CONTROL = 1 << 6,
|
2006-05-15 19:35:12 +00:00
|
|
|
/** document fragments */
|
2011-12-08 06:32:11 +00:00
|
|
|
eDOCUMENT_FRAGMENT = 1 << 7,
|
2006-07-19 04:36:36 +00:00
|
|
|
/** data nodes (comments, PIs, text). Nodes of this type always
|
|
|
|
returns a non-null value for nsIContent::GetText() */
|
2011-12-08 06:32:11 +00:00
|
|
|
eDATA_NODE = 1 << 8,
|
2013-03-19 12:23:54 +00:00
|
|
|
/** HTMLMediaElement */
|
2011-12-08 06:32:11 +00:00
|
|
|
eMEDIA = 1 << 9,
|
2010-03-19 11:17:49 +00:00
|
|
|
/** animation elements */
|
2013-03-07 07:12:32 +00:00
|
|
|
eANIMATION = 1 << 10,
|
|
|
|
/** filter elements that implement SVGFilterPrimitiveStandardAttributes */
|
|
|
|
eFILTER = 1 << 11
|
2006-05-05 06:52:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2006-05-15 07:03:15 +00:00
|
|
|
* API for doing a quick check if a content is of a given
|
2009-08-24 20:02:07 +00:00
|
|
|
* type, such as Text, Document, Comment ... Use this when you can instead of
|
2006-05-05 06:52:21 +00:00
|
|
|
* checking the tag.
|
|
|
|
*
|
|
|
|
* @param aFlags what types you want to test for (see above)
|
|
|
|
* @return whether the content matches ALL flags passed in
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual bool IsNodeOfType(uint32_t aFlags) const = 0;
|
2006-05-05 06:52:21 +00:00
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
virtual JSObject* WrapObject(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2012-10-09 12:31:24 +00:00
|
|
|
|
2014-07-03 13:23:14 +00:00
|
|
|
/**
|
|
|
|
* returns true if we are in priviliged code or
|
|
|
|
* layout.css.getBoxQuads.enabled == true.
|
|
|
|
*/
|
|
|
|
static bool HasBoxQuadsSupport(JSContext* aCx, JSObject* /* unused */);
|
|
|
|
|
2012-10-09 12:31:24 +00:00
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* WrapNode is called from WrapObject to actually wrap this node, WrapObject
|
|
|
|
* does some additional checks and fix-up that's common to all nodes. WrapNode
|
|
|
|
* should just call the DOM binding's Wrap function.
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 14:13:33 +00:00
|
|
|
*
|
|
|
|
* aGivenProto is the prototype to use (or null if the default one should be
|
|
|
|
* used) and should just be passed directly on to the DOM binding's Wrap
|
|
|
|
* function.
|
2012-10-09 12:31:24 +00:00
|
|
|
*/
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 14:13:33 +00:00
|
|
|
virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) = 0;
|
2012-10-09 12:31:24 +00:00
|
|
|
|
2014-03-19 16:35:45 +00:00
|
|
|
public:
|
|
|
|
mozilla::dom::ParentObject GetParentObject() const; // Implemented in nsIDocument.h
|
|
|
|
|
2014-10-30 21:38:48 +00:00
|
|
|
/**
|
|
|
|
* Return the scope chain parent for this node, for use in things
|
|
|
|
* like event handler compilation. Returning null means to use the
|
|
|
|
* global object as the scope chain parent.
|
|
|
|
*/
|
|
|
|
virtual nsINode* GetScopeChainParent() const;
|
|
|
|
|
2010-04-30 13:12:04 +00:00
|
|
|
/**
|
|
|
|
* Return whether the node is an Element node
|
|
|
|
*/
|
2011-04-08 02:29:49 +00:00
|
|
|
bool IsElement() const {
|
|
|
|
return GetBoolFlag(NodeIsElement);
|
2010-04-30 13:12:04 +00:00
|
|
|
}
|
|
|
|
|
2010-04-30 13:12:05 +00:00
|
|
|
/**
|
|
|
|
* Return this node as an Element. Should only be used for nodes
|
2012-04-27 13:21:12 +00:00
|
|
|
* for which IsElement() is true. This is defined inline in Element.h.
|
2010-04-30 13:12:05 +00:00
|
|
|
*/
|
|
|
|
mozilla::dom::Element* AsElement();
|
2012-06-23 06:57:57 +00:00
|
|
|
const mozilla::dom::Element* AsElement() const;
|
2010-04-30 13:12:05 +00:00
|
|
|
|
2012-06-10 12:39:21 +00:00
|
|
|
/**
|
|
|
|
* Return this node as nsIContent. Should only be used for nodes for which
|
|
|
|
* IsContent() is true. This is defined inline in nsIContent.h.
|
|
|
|
*/
|
|
|
|
nsIContent* AsContent();
|
2014-04-06 19:32:38 +00:00
|
|
|
const nsIContent* AsContent() const
|
|
|
|
{
|
|
|
|
return const_cast<nsINode*>(this)->AsContent();
|
|
|
|
}
|
2012-06-10 12:39:21 +00:00
|
|
|
|
2014-08-13 11:53:32 +00:00
|
|
|
/**
|
|
|
|
* Return this node as Text if it is one, otherwise null. This is defined
|
|
|
|
* inline in Text.h.
|
|
|
|
*/
|
|
|
|
mozilla::dom::Text* GetAsText();
|
|
|
|
const mozilla::dom::Text* GetAsText() const;
|
|
|
|
|
2012-04-25 13:47:30 +00:00
|
|
|
virtual nsIDOMNode* AsDOMNode() = 0;
|
|
|
|
|
2012-01-25 07:50:07 +00:00
|
|
|
/**
|
|
|
|
* Return if this node has any children.
|
|
|
|
*/
|
|
|
|
bool HasChildren() const { return !!mFirstChild; }
|
|
|
|
|
2006-01-19 03:34:18 +00:00
|
|
|
/**
|
|
|
|
* Get the number of children
|
|
|
|
* @return the number of children
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual uint32_t GetChildCount() const = 0;
|
2006-01-19 03:34:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a child by index
|
|
|
|
* @param aIndex the index of the child to get
|
|
|
|
* @return the child, or null if index out of bounds
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual nsIContent* GetChildAt(uint32_t aIndex) const = 0;
|
2006-01-19 03:34:18 +00:00
|
|
|
|
2008-07-11 20:42:19 +00:00
|
|
|
/**
|
|
|
|
* Get a raw pointer to the child array. This should only be used if you
|
|
|
|
* plan to walk a bunch of the kids, promise to make sure that nothing ever
|
|
|
|
* mutates (no attribute changes, not DOM tree changes, no script execution,
|
|
|
|
* NOTHING), and will never ever peform an out-of-bounds access here. This
|
|
|
|
* method may return null if there are no children, or it may return a
|
2008-12-03 14:02:03 +00:00
|
|
|
* garbage pointer. In all cases the out param will be set to the number of
|
|
|
|
* children.
|
2008-07-11 20:42:19 +00:00
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual nsIContent * const * GetChildArray(uint32_t* aChildCount) const = 0;
|
2008-07-11 20:42:19 +00:00
|
|
|
|
2006-01-19 03:34:18 +00:00
|
|
|
/**
|
|
|
|
* Get the index of a child within this content
|
|
|
|
* @param aPossibleChild the child to get the index of.
|
|
|
|
* @return the index of the child, or -1 if not a child
|
|
|
|
*
|
|
|
|
* If the return value is not -1, then calling GetChildAt() with that value
|
|
|
|
* will return aPossibleChild.
|
|
|
|
*/
|
2012-10-06 07:19:46 +00:00
|
|
|
virtual int32_t IndexOf(const nsINode* aPossibleChild) const = 0;
|
2006-01-19 03:34:18 +00:00
|
|
|
|
|
|
|
/**
|
2015-10-02 16:16:49 +00:00
|
|
|
* Returns the "node document" of this node.
|
|
|
|
*
|
|
|
|
* https://dom.spec.whatwg.org/#concept-node-document
|
|
|
|
*
|
|
|
|
* Note that in the case that this node is a document node this method
|
|
|
|
* will return |this|. That is different to the Node.ownerDocument DOM
|
|
|
|
* attribute (implemented by nsINode::GetOwnerDocument) which is specified to
|
|
|
|
* be null in that case:
|
|
|
|
*
|
|
|
|
* https://dom.spec.whatwg.org/#dom-node-ownerdocument
|
|
|
|
*
|
2016-02-29 23:46:51 +00:00
|
|
|
* For all other cases OwnerDoc and GetOwnerDocument behave identically.
|
2006-01-19 03:34:18 +00:00
|
|
|
*/
|
2011-10-18 10:53:36 +00:00
|
|
|
nsIDocument *OwnerDoc() const
|
2006-01-19 03:34:18 +00:00
|
|
|
{
|
|
|
|
return mNodeInfo->GetDocument();
|
|
|
|
}
|
|
|
|
|
2012-03-14 20:14:02 +00:00
|
|
|
/**
|
|
|
|
* Return the "owner document" of this node as an nsINode*. Implemented
|
|
|
|
* in nsIDocument.h.
|
|
|
|
*/
|
2012-03-16 22:16:41 +00:00
|
|
|
nsINode *OwnerDocAsNode() const;
|
2012-03-14 20:14:02 +00:00
|
|
|
|
2006-07-08 00:30:19 +00:00
|
|
|
/**
|
|
|
|
* Returns true if the content has an ancestor that is a document.
|
|
|
|
*
|
|
|
|
* @return whether this content is in a document tree
|
|
|
|
*/
|
2014-07-03 17:02:07 +00:00
|
|
|
bool IsInUncomposedDoc() const
|
2006-07-08 00:30:19 +00:00
|
|
|
{
|
2011-04-08 02:29:49 +00:00
|
|
|
return GetBoolFlag(IsInDocument);
|
2006-07-08 00:30:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the document that this content is currently in, if any. This will be
|
|
|
|
* null if the content has no ancestor that is a document.
|
|
|
|
*
|
|
|
|
* @return the current document
|
|
|
|
*/
|
2014-07-03 17:02:07 +00:00
|
|
|
|
|
|
|
nsIDocument* GetUncomposedDoc() const
|
|
|
|
{
|
|
|
|
return IsInUncomposedDoc() ? OwnerDoc() : nullptr;
|
|
|
|
}
|
|
|
|
|
2014-06-07 08:42:53 +00:00
|
|
|
/**
|
2015-02-09 18:01:23 +00:00
|
|
|
* This method returns the owner doc if the node is in the
|
|
|
|
* composed document (as defined in the Shadow DOM spec), otherwise
|
|
|
|
* it returns null.
|
2014-06-07 08:42:53 +00:00
|
|
|
*/
|
2014-07-03 17:02:07 +00:00
|
|
|
nsIDocument* GetComposedDoc() const
|
|
|
|
{
|
|
|
|
return IsInShadowTree() ?
|
|
|
|
GetComposedDocInternal() : GetUncomposedDoc();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if GetComposedDoc() would return a non-null value.
|
|
|
|
*/
|
|
|
|
bool IsInComposedDoc() const
|
|
|
|
{
|
|
|
|
return IsInUncomposedDoc() || (IsInShadowTree() && GetComposedDocInternal());
|
2014-06-07 08:42:53 +00:00
|
|
|
}
|
|
|
|
|
2011-06-14 07:56:49 +00:00
|
|
|
/**
|
|
|
|
* The values returned by this function are the ones defined for
|
|
|
|
* nsIDOMNode.nodeType
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
uint16_t NodeType() const
|
2011-06-14 07:56:49 +00:00
|
|
|
{
|
|
|
|
return mNodeInfo->NodeType();
|
|
|
|
}
|
|
|
|
const nsString& NodeName() const
|
|
|
|
{
|
|
|
|
return mNodeInfo->NodeName();
|
|
|
|
}
|
|
|
|
const nsString& LocalName() const
|
|
|
|
{
|
|
|
|
return mNodeInfo->LocalName();
|
|
|
|
}
|
2010-03-17 15:06:19 +00:00
|
|
|
|
2015-03-03 11:08:59 +00:00
|
|
|
/**
|
|
|
|
* Get the NodeInfo for this element
|
|
|
|
* @return the nodes node info
|
|
|
|
*/
|
|
|
|
inline mozilla::dom::NodeInfo* NodeInfo() const
|
|
|
|
{
|
|
|
|
return mNodeInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool IsInNamespace(int32_t aNamespace) const
|
|
|
|
{
|
|
|
|
return mNodeInfo->NamespaceID() == aNamespace;
|
|
|
|
}
|
|
|
|
|
2015-07-08 19:58:07 +00:00
|
|
|
/**
|
|
|
|
* Print a debugger friendly descriptor of this element. This will describe
|
|
|
|
* the position of this element in the document.
|
|
|
|
*/
|
|
|
|
friend std::ostream& operator<<(std::ostream& aStream, const nsINode& aNode);
|
|
|
|
|
2015-03-03 11:08:59 +00:00
|
|
|
protected:
|
|
|
|
// These 2 methods are useful for the recursive templates IsHTMLElement,
|
|
|
|
// IsSVGElement, etc.
|
|
|
|
inline bool IsNodeInternal() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename First, typename... Args>
|
|
|
|
inline bool IsNodeInternal(First aFirst, Args... aArgs) const
|
|
|
|
{
|
|
|
|
return mNodeInfo->Equals(aFirst) || IsNodeInternal(aArgs...);
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
inline bool IsHTMLElement() const
|
|
|
|
{
|
|
|
|
return IsElement() && IsInNamespace(kNameSpaceID_XHTML);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool IsHTMLElement(nsIAtom* aTag) const
|
|
|
|
{
|
|
|
|
return IsElement() && mNodeInfo->Equals(aTag, kNameSpaceID_XHTML);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename First, typename... Args>
|
|
|
|
inline bool IsAnyOfHTMLElements(First aFirst, Args... aArgs) const
|
|
|
|
{
|
|
|
|
return IsHTMLElement() && IsNodeInternal(aFirst, aArgs...);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool IsSVGElement() const
|
|
|
|
{
|
|
|
|
return IsElement() && IsInNamespace(kNameSpaceID_SVG);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool IsSVGElement(nsIAtom* aTag) const
|
|
|
|
{
|
|
|
|
return IsElement() && mNodeInfo->Equals(aTag, kNameSpaceID_SVG);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename First, typename... Args>
|
|
|
|
inline bool IsAnyOfSVGElements(First aFirst, Args... aArgs) const
|
|
|
|
{
|
|
|
|
return IsSVGElement() && IsNodeInternal(aFirst, aArgs...);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool IsXULElement() const
|
|
|
|
{
|
|
|
|
return IsElement() && IsInNamespace(kNameSpaceID_XUL);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool IsXULElement(nsIAtom* aTag) const
|
|
|
|
{
|
|
|
|
return IsElement() && mNodeInfo->Equals(aTag, kNameSpaceID_XUL);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename First, typename... Args>
|
|
|
|
inline bool IsAnyOfXULElements(First aFirst, Args... aArgs) const
|
|
|
|
{
|
|
|
|
return IsXULElement() && IsNodeInternal(aFirst, aArgs...);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool IsMathMLElement() const
|
|
|
|
{
|
|
|
|
return IsElement() && IsInNamespace(kNameSpaceID_MathML);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline bool IsMathMLElement(nsIAtom* aTag) const
|
|
|
|
{
|
|
|
|
return IsElement() && mNodeInfo->Equals(aTag, kNameSpaceID_MathML);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename First, typename... Args>
|
|
|
|
inline bool IsAnyOfMathMLElements(First aFirst, Args... aArgs) const
|
|
|
|
{
|
|
|
|
return IsMathMLElement() && IsNodeInternal(aFirst, aArgs...);
|
|
|
|
}
|
|
|
|
|
2006-01-19 03:34:18 +00:00
|
|
|
/**
|
|
|
|
* Insert a content node at a particular index. This method handles calling
|
|
|
|
* BindToTree on the child appropriately.
|
|
|
|
*
|
|
|
|
* @param aKid the content to insert
|
|
|
|
* @param aIndex the index it is being inserted at (the index it will have
|
|
|
|
* after it is inserted)
|
|
|
|
* @param aNotify whether to notify the document (current document for
|
|
|
|
* nsIContent, and |this| for nsIDocument) that the insert has
|
|
|
|
* occurred
|
|
|
|
*
|
|
|
|
* @throws NS_ERROR_DOM_HIERARCHY_REQUEST_ERR if one attempts to have more
|
|
|
|
* than one element node as a child of a document. Doing this will also
|
|
|
|
* assert -- you shouldn't be doing it! Check with
|
2010-04-30 13:12:05 +00:00
|
|
|
* nsIDocument::GetRootElement() first if you're not sure. Apart from this
|
2006-01-19 03:34:18 +00:00
|
|
|
* one constraint, this doesn't do any checking on whether aKid is a valid
|
|
|
|
* child of |this|.
|
|
|
|
*
|
|
|
|
* @throws NS_ERROR_OUT_OF_MEMORY in some cases (from BindToTree).
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aNotify) = 0;
|
2006-01-19 03:34:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Append a content node to the end of the child list. This method handles
|
|
|
|
* calling BindToTree on the child appropriately.
|
|
|
|
*
|
|
|
|
* @param aKid the content to append
|
|
|
|
* @param aNotify whether to notify the document (current document for
|
|
|
|
* nsIContent, and |this| for nsIDocument) that the append has
|
|
|
|
* occurred
|
|
|
|
*
|
|
|
|
* @throws NS_ERROR_DOM_HIERARCHY_REQUEST_ERR if one attempts to have more
|
|
|
|
* than one element node as a child of a document. Doing this will also
|
|
|
|
* assert -- you shouldn't be doing it! Check with
|
2010-04-30 13:12:05 +00:00
|
|
|
* nsIDocument::GetRootElement() first if you're not sure. Apart from this
|
2006-01-19 03:34:18 +00:00
|
|
|
* one constraint, this doesn't do any checking on whether aKid is a valid
|
|
|
|
* child of |this|.
|
|
|
|
*
|
|
|
|
* @throws NS_ERROR_OUT_OF_MEMORY in some cases (from BindToTree).
|
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
nsresult AppendChildTo(nsIContent* aKid, bool aNotify)
|
2006-07-31 22:38:07 +00:00
|
|
|
{
|
|
|
|
return InsertChildAt(aKid, GetChildCount(), aNotify);
|
|
|
|
}
|
2016-03-25 10:23:53 +00:00
|
|
|
|
2006-01-19 03:34:18 +00:00
|
|
|
/**
|
|
|
|
* Remove a child from this node. This method handles calling UnbindFromTree
|
|
|
|
* on the child appropriately.
|
|
|
|
*
|
|
|
|
* @param aIndex the index of the child to remove
|
|
|
|
* @param aNotify whether to notify the document (current document for
|
|
|
|
* nsIContent, and |this| for nsIDocument) that the remove has
|
|
|
|
* occurred
|
|
|
|
*
|
|
|
|
* Note: If there is no child at aIndex, this method will simply do nothing.
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) = 0;
|
2006-01-19 03:34:18 +00:00
|
|
|
|
2006-01-25 20:49:56 +00:00
|
|
|
/**
|
|
|
|
* Get a property associated with this node.
|
|
|
|
*
|
|
|
|
* @param aPropertyName name of property to get.
|
|
|
|
* @param aStatus out parameter for storing resulting status.
|
|
|
|
* Set to NS_PROPTABLE_PROP_NOT_THERE if the property
|
|
|
|
* is not set.
|
|
|
|
* @return the property. Null if the property is not set
|
|
|
|
* (though a null return value does not imply the
|
|
|
|
* property was not set, i.e. it can be set to null).
|
|
|
|
*/
|
2006-06-02 13:28:14 +00:00
|
|
|
void* GetProperty(nsIAtom *aPropertyName,
|
2012-07-30 14:20:58 +00:00
|
|
|
nsresult *aStatus = nullptr) const
|
2006-06-02 13:28:14 +00:00
|
|
|
{
|
|
|
|
return GetProperty(0, aPropertyName, aStatus);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a property associated with this node.
|
|
|
|
*
|
|
|
|
* @param aCategory category of property to get.
|
|
|
|
* @param aPropertyName name of property to get.
|
|
|
|
* @param aStatus out parameter for storing resulting status.
|
|
|
|
* Set to NS_PROPTABLE_PROP_NOT_THERE if the property
|
|
|
|
* is not set.
|
|
|
|
* @return the property. Null if the property is not set
|
|
|
|
* (though a null return value does not imply the
|
|
|
|
* property was not set, i.e. it can be set to null).
|
|
|
|
*/
|
2016-10-27 01:40:34 +00:00
|
|
|
void* GetProperty(uint16_t aCategory, nsIAtom *aPropertyName,
|
|
|
|
nsresult *aStatus = nullptr) const;
|
2006-01-25 20:49:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a property to be associated with this node. This will overwrite an
|
|
|
|
* existing value if one exists. The existing value is destroyed using the
|
|
|
|
* destructor function given when that value was set.
|
|
|
|
*
|
|
|
|
* @param aPropertyName name of property to set.
|
|
|
|
* @param aValue new value of property.
|
|
|
|
* @param aDtor destructor function to be used when this property
|
|
|
|
* is destroyed.
|
2011-10-17 14:59:28 +00:00
|
|
|
* @param aTransfer if true the property will not be deleted when the
|
|
|
|
* ownerDocument of the node changes, if false it
|
2006-09-16 17:15:38 +00:00
|
|
|
* will be deleted.
|
2006-01-25 20:49:56 +00:00
|
|
|
*
|
|
|
|
* @return NS_PROPTABLE_PROP_OVERWRITTEN (success value) if the property
|
|
|
|
* was already set
|
|
|
|
* @throws NS_ERROR_OUT_OF_MEMORY if that occurs
|
|
|
|
*/
|
2016-10-27 01:40:34 +00:00
|
|
|
nsresult SetProperty(nsIAtom *aPropertyName, void *aValue,
|
2012-07-30 14:20:58 +00:00
|
|
|
NSPropertyDtorFunc aDtor = nullptr,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aTransfer = false)
|
2006-06-02 13:28:14 +00:00
|
|
|
{
|
2006-09-16 17:15:38 +00:00
|
|
|
return SetProperty(0, aPropertyName, aValue, aDtor, aTransfer);
|
2006-06-02 13:28:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set a property to be associated with this node. This will overwrite an
|
|
|
|
* existing value if one exists. The existing value is destroyed using the
|
|
|
|
* destructor function given when that value was set.
|
|
|
|
*
|
|
|
|
* @param aCategory category of property to set.
|
|
|
|
* @param aPropertyName name of property to set.
|
|
|
|
* @param aValue new value of property.
|
|
|
|
* @param aDtor destructor function to be used when this property
|
|
|
|
* is destroyed.
|
2011-10-17 14:59:28 +00:00
|
|
|
* @param aTransfer if true the property will not be deleted when the
|
|
|
|
* ownerDocument of the node changes, if false it
|
2006-09-16 17:15:38 +00:00
|
|
|
* will be deleted.
|
2006-06-02 13:28:14 +00:00
|
|
|
* @param aOldValue [out] previous value of property.
|
|
|
|
*
|
|
|
|
* @return NS_PROPTABLE_PROP_OVERWRITTEN (success value) if the property
|
|
|
|
* was already set
|
|
|
|
* @throws NS_ERROR_OUT_OF_MEMORY if that occurs
|
|
|
|
*/
|
2016-10-27 01:40:34 +00:00
|
|
|
nsresult SetProperty(uint16_t aCategory,
|
|
|
|
nsIAtom *aPropertyName, void *aValue,
|
|
|
|
NSPropertyDtorFunc aDtor = nullptr,
|
|
|
|
bool aTransfer = false,
|
|
|
|
void **aOldValue = nullptr);
|
2006-06-02 13:28:14 +00:00
|
|
|
|
2014-03-25 13:25:47 +00:00
|
|
|
/**
|
|
|
|
* A generic destructor for property values allocated with new.
|
|
|
|
*/
|
|
|
|
template<class T>
|
|
|
|
static void DeleteProperty(void *, nsIAtom *, void *aPropertyValue, void *)
|
|
|
|
{
|
|
|
|
delete static_cast<T *>(aPropertyValue);
|
|
|
|
}
|
|
|
|
|
2006-06-02 13:28:14 +00:00
|
|
|
/**
|
|
|
|
* Destroys a property associated with this node. The value is destroyed
|
|
|
|
* using the destruction function given when that value was set.
|
|
|
|
*
|
|
|
|
* @param aPropertyName name of property to destroy.
|
|
|
|
*/
|
2010-05-20 14:41:00 +00:00
|
|
|
void DeleteProperty(nsIAtom *aPropertyName)
|
2006-06-02 13:28:14 +00:00
|
|
|
{
|
2010-05-20 14:41:00 +00:00
|
|
|
DeleteProperty(0, aPropertyName);
|
2006-06-02 13:28:14 +00:00
|
|
|
}
|
2006-01-25 20:49:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Destroys a property associated with this node. The value is destroyed
|
|
|
|
* using the destruction function given when that value was set.
|
|
|
|
*
|
2006-06-02 13:28:14 +00:00
|
|
|
* @param aCategory category of property to destroy.
|
2006-01-25 20:49:56 +00:00
|
|
|
* @param aPropertyName name of property to destroy.
|
|
|
|
*/
|
2016-10-27 01:40:34 +00:00
|
|
|
void DeleteProperty(uint16_t aCategory, nsIAtom *aPropertyName);
|
2006-06-02 13:28:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Unset a property associated with this node. The value will not be
|
|
|
|
* destroyed but rather returned. It is the caller's responsibility to
|
|
|
|
* destroy the value after that point.
|
|
|
|
*
|
|
|
|
* @param aPropertyName name of property to unset.
|
|
|
|
* @param aStatus out parameter for storing resulting status.
|
|
|
|
* Set to NS_PROPTABLE_PROP_NOT_THERE if the property
|
|
|
|
* is not set.
|
|
|
|
* @return the property. Null if the property is not set
|
|
|
|
* (though a null return value does not imply the
|
|
|
|
* property was not set, i.e. it can be set to null).
|
|
|
|
*/
|
|
|
|
void* UnsetProperty(nsIAtom *aPropertyName,
|
2012-07-30 14:20:58 +00:00
|
|
|
nsresult *aStatus = nullptr)
|
2006-06-02 13:28:14 +00:00
|
|
|
{
|
|
|
|
return UnsetProperty(0, aPropertyName, aStatus);
|
|
|
|
}
|
2006-01-25 20:49:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Unset a property associated with this node. The value will not be
|
|
|
|
* destroyed but rather returned. It is the caller's responsibility to
|
2006-06-02 13:28:14 +00:00
|
|
|
* destroy the value after that point.
|
2006-01-25 20:49:56 +00:00
|
|
|
*
|
2006-06-02 13:28:14 +00:00
|
|
|
* @param aCategory category of property to unset.
|
2006-01-25 20:49:56 +00:00
|
|
|
* @param aPropertyName name of property to unset.
|
|
|
|
* @param aStatus out parameter for storing resulting status.
|
|
|
|
* Set to NS_PROPTABLE_PROP_NOT_THERE if the property
|
|
|
|
* is not set.
|
|
|
|
* @return the property. Null if the property is not set
|
|
|
|
* (though a null return value does not imply the
|
|
|
|
* property was not set, i.e. it can be set to null).
|
|
|
|
*/
|
2016-10-27 01:40:34 +00:00
|
|
|
void* UnsetProperty(uint16_t aCategory, nsIAtom *aPropertyName,
|
|
|
|
nsresult *aStatus = nullptr);
|
2016-03-25 10:23:53 +00:00
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool HasProperties() const
|
2006-06-02 13:28:14 +00:00
|
|
|
{
|
|
|
|
return HasFlag(NODE_HAS_PROPERTIES);
|
|
|
|
}
|
|
|
|
|
2006-02-02 20:02:34 +00:00
|
|
|
/**
|
2006-04-27 18:21:11 +00:00
|
|
|
* Return the principal of this node. This is guaranteed to never be a null
|
|
|
|
* pointer.
|
2006-02-02 20:02:34 +00:00
|
|
|
*/
|
2006-04-27 18:21:11 +00:00
|
|
|
nsIPrincipal* NodePrincipal() const {
|
|
|
|
return mNodeInfo->NodeInfoManager()->DocumentPrincipal();
|
2006-02-02 20:02:34 +00:00
|
|
|
}
|
2006-01-25 20:49:56 +00:00
|
|
|
|
2006-04-15 05:09:16 +00:00
|
|
|
/**
|
|
|
|
* Get the parent nsIContent for this node.
|
|
|
|
* @return the parent, or null if no parent or the parent is not an nsIContent
|
|
|
|
*/
|
2011-04-08 02:29:49 +00:00
|
|
|
nsIContent* GetParent() const {
|
2012-10-26 13:32:10 +00:00
|
|
|
return MOZ_LIKELY(GetBoolFlag(ParentIsContent)) ?
|
2012-07-30 14:20:58 +00:00
|
|
|
reinterpret_cast<nsIContent*>(mParent) : nullptr;
|
2006-04-15 05:09:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the parent nsINode for this node. This can be either an nsIContent,
|
|
|
|
* an nsIDocument or an nsIAttribute.
|
|
|
|
* @return the parent node
|
|
|
|
*/
|
2012-10-09 12:31:24 +00:00
|
|
|
nsINode* GetParentNode() const
|
2006-04-15 05:09:16 +00:00
|
|
|
{
|
2011-04-08 02:29:49 +00:00
|
|
|
return mParent;
|
2006-04-15 05:09:16 +00:00
|
|
|
}
|
2016-03-25 10:23:53 +00:00
|
|
|
|
2016-08-19 00:03:49 +00:00
|
|
|
/**
|
|
|
|
* Returns the node that is the parent of this node in the flattened
|
|
|
|
* tree. This differs from the normal parent if the node is filtered
|
|
|
|
* into an insertion point, or if the node is a direct child of a
|
|
|
|
* shadow root.
|
|
|
|
*
|
|
|
|
* @return the flattened tree parent
|
|
|
|
*/
|
|
|
|
inline nsINode* GetFlattenedTreeParentNode() const;
|
|
|
|
|
2016-12-01 06:55:09 +00:00
|
|
|
/**
|
|
|
|
* Like GetFlattenedTreeParentNode, but returns null for any native
|
|
|
|
* anonymous content that was generated for ancestor frames of the
|
|
|
|
* root element's primary frame, such as scrollbar elements created
|
|
|
|
* by the root scroll frame.
|
|
|
|
*/
|
|
|
|
inline nsINode* GetFlattenedTreeParentNodeForStyle() const;
|
|
|
|
|
2011-09-11 22:45:39 +00:00
|
|
|
/**
|
|
|
|
* Get the parent nsINode for this node if it is an Element.
|
|
|
|
* @return the parent node
|
|
|
|
*/
|
2013-01-11 08:43:01 +00:00
|
|
|
mozilla::dom::Element* GetParentElement() const
|
2011-09-11 22:45:39 +00:00
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
return mParent && mParent->IsElement() ? mParent->AsElement() : nullptr;
|
2011-09-11 22:45:39 +00:00
|
|
|
}
|
2006-04-15 05:09:16 +00:00
|
|
|
|
2014-06-06 05:22:55 +00:00
|
|
|
/**
|
|
|
|
* Get the parent Element of this node, traversing over a ShadowRoot
|
|
|
|
* to its host if necessary.
|
|
|
|
*/
|
|
|
|
mozilla::dom::Element* GetParentElementCrossingShadowRoot() const;
|
|
|
|
|
2012-03-14 20:14:02 +00:00
|
|
|
/**
|
|
|
|
* Get the root of the subtree this node belongs to. This never returns
|
|
|
|
* null. It may return 'this' (e.g. for document nodes, and nodes that
|
|
|
|
* are the roots of disconnected subtrees).
|
|
|
|
*/
|
2014-06-07 08:42:53 +00:00
|
|
|
nsINode* SubtreeRoot() const;
|
2012-03-14 20:14:02 +00:00
|
|
|
|
2017-01-15 17:46:00 +00:00
|
|
|
/*
|
|
|
|
* Get context object's shadow-including root if options's composed is true,
|
|
|
|
* and context object's root otherwise.
|
|
|
|
*/
|
|
|
|
nsINode* GetRootNode(const mozilla::dom::GetRootNodeOptions& aOptions);
|
2016-03-16 01:49:10 +00:00
|
|
|
|
2011-06-24 02:17:58 +00:00
|
|
|
/**
|
2011-06-24 02:17:59 +00:00
|
|
|
* See nsIDOMEventTarget
|
2011-06-24 02:17:58 +00:00
|
|
|
*/
|
2011-06-24 02:17:59 +00:00
|
|
|
NS_DECL_NSIDOMEVENTTARGET
|
2013-10-22 23:32:04 +00:00
|
|
|
|
2014-03-17 06:56:53 +00:00
|
|
|
virtual mozilla::EventListenerManager*
|
2015-03-21 16:28:04 +00:00
|
|
|
GetExistingListenerManager() const override;
|
2014-03-17 06:56:53 +00:00
|
|
|
virtual mozilla::EventListenerManager*
|
2015-03-21 16:28:04 +00:00
|
|
|
GetOrCreateListenerManager() override;
|
2013-10-22 23:32:04 +00:00
|
|
|
|
2013-04-16 21:16:08 +00:00
|
|
|
using mozilla::dom::EventTarget::RemoveEventListener;
|
2011-06-28 17:59:14 +00:00
|
|
|
using nsIDOMEventTarget::AddEventListener;
|
2013-04-16 21:16:08 +00:00
|
|
|
virtual void AddEventListener(const nsAString& aType,
|
2013-09-24 00:25:17 +00:00
|
|
|
mozilla::dom::EventListener* aListener,
|
2016-04-26 08:23:17 +00:00
|
|
|
const mozilla::dom::AddEventListenerOptionsOrBoolean& aOptions,
|
2013-04-16 21:16:08 +00:00
|
|
|
const mozilla::dom::Nullable<bool>& aWantsUntrusted,
|
2015-03-21 16:28:04 +00:00
|
|
|
mozilla::ErrorResult& aRv) override;
|
2011-11-25 01:09:58 +00:00
|
|
|
using nsIDOMEventTarget::AddSystemEventListener;
|
2015-09-17 10:16:20 +00:00
|
|
|
|
2016-05-06 10:39:10 +00:00
|
|
|
virtual bool IsApzAware() const override;
|
2015-09-17 10:16:20 +00:00
|
|
|
|
2016-01-30 17:05:36 +00:00
|
|
|
virtual nsPIDOMWindowOuter* GetOwnerGlobalForBindings() override;
|
2015-05-12 19:56:39 +00:00
|
|
|
virtual nsIGlobalObject* GetOwnerGlobal() const override;
|
2011-06-24 02:17:58 +00:00
|
|
|
|
2016-07-08 07:02:56 +00:00
|
|
|
/**
|
|
|
|
* Returns true if this is a node belonging to a document that uses the Servo
|
|
|
|
* style system.
|
|
|
|
*/
|
|
|
|
#ifdef MOZ_STYLO
|
|
|
|
bool IsStyledByServo() const;
|
|
|
|
#else
|
|
|
|
bool IsStyledByServo() const { return false; }
|
|
|
|
#endif
|
|
|
|
|
2016-07-08 07:07:06 +00:00
|
|
|
inline void UnsetRestyleFlagsIfGecko();
|
2016-07-08 07:02:56 +00:00
|
|
|
|
2006-07-02 07:23:10 +00:00
|
|
|
/**
|
|
|
|
* Adds a mutation observer to be notified when this node, or any of its
|
|
|
|
* descendants, are modified. The node will hold a weak reference to the
|
|
|
|
* observer, which means that it is the responsibility of the observer to
|
2006-11-16 17:57:18 +00:00
|
|
|
* remove itself in case it dies before the node. If an observer is added
|
|
|
|
* while observers are being notified, it may also be notified. In general,
|
2010-05-05 18:18:03 +00:00
|
|
|
* adding observers while inside a notification is not a good idea. An
|
|
|
|
* observer that is already observing the node must not be added without
|
|
|
|
* being removed first.
|
2015-03-14 05:34:40 +00:00
|
|
|
*
|
|
|
|
* For mutation observers that implement nsIAnimationObserver, use
|
|
|
|
* AddAnimationObserver instead.
|
2006-07-02 07:23:10 +00:00
|
|
|
*/
|
2010-05-05 18:18:03 +00:00
|
|
|
void AddMutationObserver(nsIMutationObserver* aMutationObserver)
|
|
|
|
{
|
2012-08-10 22:27:28 +00:00
|
|
|
nsSlots* s = Slots();
|
|
|
|
NS_ASSERTION(s->mMutationObservers.IndexOf(aMutationObserver) ==
|
|
|
|
nsTArray<int>::NoIndex,
|
|
|
|
"Observer already in the list");
|
|
|
|
s->mMutationObservers.AppendElement(aMutationObserver);
|
2010-05-05 18:18:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Same as above, but only adds the observer if its not observing
|
|
|
|
* the node already.
|
2015-03-14 05:34:40 +00:00
|
|
|
*
|
|
|
|
* For mutation observers that implement nsIAnimationObserver, use
|
|
|
|
* AddAnimationObserverUnlessExists instead.
|
2010-05-05 18:18:03 +00:00
|
|
|
*/
|
|
|
|
void AddMutationObserverUnlessExists(nsIMutationObserver* aMutationObserver)
|
|
|
|
{
|
2012-08-10 22:27:28 +00:00
|
|
|
nsSlots* s = Slots();
|
|
|
|
s->mMutationObservers.AppendElementUnlessExists(aMutationObserver);
|
2010-05-05 18:18:03 +00:00
|
|
|
}
|
2006-07-02 07:23:10 +00:00
|
|
|
|
2015-03-14 05:34:40 +00:00
|
|
|
/**
|
|
|
|
* Same as AddMutationObserver, but for nsIAnimationObservers. This
|
|
|
|
* additionally records on the document that animation observers have
|
|
|
|
* been registered, which is used to determine whether notifications
|
|
|
|
* must be fired when animations are added, removed or changed.
|
|
|
|
*/
|
|
|
|
void AddAnimationObserver(nsIAnimationObserver* aAnimationObserver);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Same as above, but only adds the observer if its not observing
|
|
|
|
* the node already.
|
|
|
|
*/
|
|
|
|
void AddAnimationObserverUnlessExists(nsIAnimationObserver* aAnimationObserver);
|
|
|
|
|
2006-07-02 07:23:10 +00:00
|
|
|
/**
|
|
|
|
* Removes a mutation observer.
|
|
|
|
*/
|
2010-05-05 18:18:03 +00:00
|
|
|
void RemoveMutationObserver(nsIMutationObserver* aMutationObserver)
|
|
|
|
{
|
2010-05-11 23:32:17 +00:00
|
|
|
nsSlots* s = GetExistingSlots();
|
|
|
|
if (s) {
|
|
|
|
s->mMutationObservers.RemoveElement(aMutationObserver);
|
2010-05-05 18:18:03 +00:00
|
|
|
}
|
|
|
|
}
|
2006-07-02 07:23:10 +00:00
|
|
|
|
2006-09-05 10:22:54 +00:00
|
|
|
/**
|
|
|
|
* Clones this node. This needs to be overriden by all node classes. aNodeInfo
|
|
|
|
* should be identical to this node's nodeInfo, except for the document which
|
|
|
|
* may be different. When cloning an element, all attributes of the element
|
|
|
|
* will be cloned. The children of the node will not be cloned.
|
|
|
|
*
|
|
|
|
* @param aNodeInfo the nodeinfo to use for the clone
|
|
|
|
* @param aResult the clone
|
2017-04-20 19:57:48 +00:00
|
|
|
* @param aPreallocateChildren If true, the array of children will be
|
|
|
|
* preallocated in preparation for a deep copy.
|
2006-09-05 10:22:54 +00:00
|
|
|
*/
|
2017-04-20 19:57:48 +00:00
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
|
|
|
|
bool aPreallocateChildren) const = 0;
|
2006-09-05 10:22:54 +00:00
|
|
|
|
2006-07-02 07:23:10 +00:00
|
|
|
// This class can be extended by subclasses that wish to store more
|
2006-05-15 07:03:15 +00:00
|
|
|
// information in the slots.
|
|
|
|
class nsSlots
|
|
|
|
{
|
|
|
|
public:
|
2015-05-19 10:33:00 +00:00
|
|
|
nsSlots();
|
2006-01-19 03:34:18 +00:00
|
|
|
|
2006-07-02 07:23:10 +00:00
|
|
|
// If needed we could remove the vtable pointer this dtor causes by
|
|
|
|
// putting a DestroySlots function on nsINode
|
2006-11-11 00:28:20 +00:00
|
|
|
virtual ~nsSlots();
|
2006-07-02 07:23:10 +00:00
|
|
|
|
2011-08-28 14:07:24 +00:00
|
|
|
void Traverse(nsCycleCollectionTraversalCallback &cb);
|
|
|
|
void Unlink();
|
|
|
|
|
2006-07-02 07:23:10 +00:00
|
|
|
/**
|
|
|
|
* A list of mutation observers
|
|
|
|
*/
|
2007-12-20 07:30:04 +00:00
|
|
|
nsTObserverArray<nsIMutationObserver*> mMutationObservers;
|
2006-11-11 00:28:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* An object implementing nsIDOMNodeList for this content (childNodes)
|
|
|
|
* @see nsIDOMNodeList
|
|
|
|
* @see nsGenericHTMLElement::GetChildNodes
|
|
|
|
*/
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<nsChildContentList> mChildNodes;
|
2006-11-11 00:36:03 +00:00
|
|
|
|
|
|
|
/**
|
2015-04-17 01:32:15 +00:00
|
|
|
* Weak reference to this node. This is cleared by the destructor of
|
|
|
|
* nsNodeWeakReference.
|
2006-11-11 00:36:03 +00:00
|
|
|
*/
|
2015-04-17 01:32:15 +00:00
|
|
|
nsNodeWeakReference* MOZ_NON_OWNING_REF mWeakReference;
|
2015-08-14 17:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Number of descendant nodes in the uncomposed document that have been
|
|
|
|
* explicitly set as editable.
|
|
|
|
*/
|
|
|
|
uint32_t mEditableDescendantCount;
|
2006-05-15 07:03:15 +00:00
|
|
|
};
|
|
|
|
|
2007-02-15 23:04:33 +00:00
|
|
|
/**
|
|
|
|
* Functions for managing flags and slots
|
|
|
|
*/
|
2006-11-04 05:45:02 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
nsSlots* DebugGetSlots()
|
|
|
|
{
|
2012-08-10 22:27:28 +00:00
|
|
|
return Slots();
|
2006-11-04 05:45:02 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-06-19 00:07:26 +00:00
|
|
|
void SetFlags(FlagsType aFlagsToSet)
|
2007-02-15 23:04:33 +00:00
|
|
|
{
|
2013-09-24 19:28:32 +00:00
|
|
|
NS_ASSERTION(!(aFlagsToSet & (NODE_IS_ANONYMOUS_ROOT |
|
2009-02-24 18:39:09 +00:00
|
|
|
NODE_IS_NATIVE_ANONYMOUS_ROOT |
|
2014-04-06 19:32:38 +00:00
|
|
|
NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE |
|
2010-01-18 09:26:28 +00:00
|
|
|
NODE_DESCENDANTS_NEED_FRAMES |
|
2012-10-10 19:04:42 +00:00
|
|
|
NODE_NEEDS_FRAME |
|
|
|
|
NODE_CHROME_ONLY_ACCESS)) ||
|
2007-02-15 23:04:33 +00:00
|
|
|
IsNodeOfType(eCONTENT),
|
|
|
|
"Flag only permitted on nsIContent nodes");
|
2013-06-08 08:54:59 +00:00
|
|
|
nsWrapperCache::SetFlags(aFlagsToSet);
|
2007-02-15 23:04:33 +00:00
|
|
|
}
|
|
|
|
|
2014-06-19 00:07:26 +00:00
|
|
|
void UnsetFlags(FlagsType aFlagsToUnset)
|
2007-02-15 23:04:33 +00:00
|
|
|
{
|
2009-02-24 18:39:09 +00:00
|
|
|
NS_ASSERTION(!(aFlagsToUnset &
|
2013-09-24 19:28:32 +00:00
|
|
|
(NODE_IS_ANONYMOUS_ROOT |
|
2014-04-06 19:32:38 +00:00
|
|
|
NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE |
|
2009-02-24 18:39:09 +00:00
|
|
|
NODE_IS_NATIVE_ANONYMOUS_ROOT)),
|
|
|
|
"Trying to unset write-only flags");
|
2013-06-08 08:54:59 +00:00
|
|
|
nsWrapperCache::UnsetFlags(aFlagsToUnset);
|
2007-02-15 23:04:33 +00:00
|
|
|
}
|
|
|
|
|
2015-08-14 17:52:38 +00:00
|
|
|
void ChangeEditableDescendantCount(int32_t aDelta);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the count of descendant nodes in the uncomposed
|
|
|
|
* document that are explicitly set as editable.
|
|
|
|
*/
|
|
|
|
uint32_t EditableDescendantCount();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the editable descendant count to 0. The editable
|
|
|
|
* descendant count only counts explicitly editable nodes
|
|
|
|
* that are in the uncomposed document so this method
|
|
|
|
* should be called when nodes are are removed from it.
|
|
|
|
*/
|
|
|
|
void ResetEditableDescendantCount();
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
void SetEditableFlag(bool aEditable)
|
2007-06-28 02:48:16 +00:00
|
|
|
{
|
|
|
|
if (aEditable) {
|
|
|
|
SetFlags(NODE_IS_EDITABLE);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
UnsetFlags(NODE_IS_EDITABLE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsEditable() const
|
2007-07-11 13:05:05 +00:00
|
|
|
{
|
2013-03-16 04:31:38 +00:00
|
|
|
#ifdef MOZILLA_INTERNAL_API
|
2007-07-11 13:05:05 +00:00
|
|
|
return IsEditableInternal();
|
|
|
|
#else
|
|
|
|
return IsEditableExternal();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2017-01-21 02:28:46 +00:00
|
|
|
/**
|
|
|
|
* Returns true if |this| is native anonymous (i.e. created by
|
|
|
|
* nsIAnonymousContentCreator);
|
|
|
|
*/
|
|
|
|
bool IsNativeAnonymous() const
|
|
|
|
{
|
|
|
|
return HasFlag(NODE_IS_NATIVE_ANONYMOUS);
|
|
|
|
}
|
|
|
|
|
2009-04-23 07:21:22 +00:00
|
|
|
/**
|
2011-10-17 14:59:28 +00:00
|
|
|
* Returns true if |this| or any of its ancestors is native anonymous.
|
2009-04-23 07:21:22 +00:00
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsInNativeAnonymousSubtree() const
|
2009-04-23 07:21:22 +00:00
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
2014-04-06 19:32:38 +00:00
|
|
|
if (HasFlag(NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE)) {
|
2011-10-17 14:59:28 +00:00
|
|
|
return true;
|
2009-04-23 07:21:22 +00:00
|
|
|
}
|
|
|
|
CheckNotNativeAnonymous();
|
2011-10-17 14:59:28 +00:00
|
|
|
return false;
|
2009-04-23 07:21:22 +00:00
|
|
|
#else
|
2014-04-06 19:32:38 +00:00
|
|
|
return HasFlag(NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE);
|
2009-04-23 07:21:22 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-04-06 19:32:38 +00:00
|
|
|
bool IsInAnonymousSubtree() const;
|
|
|
|
|
2014-04-15 03:38:54 +00:00
|
|
|
// Note: This asserts |IsInAnonymousSubtree()|.
|
|
|
|
bool IsAnonymousContentInSVGUseSubtree() const;
|
|
|
|
|
2015-02-17 00:48:41 +00:00
|
|
|
// True for native anonymous content and for XBL content if the binding
|
2012-10-10 19:04:42 +00:00
|
|
|
// has chromeOnlyContent="true".
|
|
|
|
bool ChromeOnlyAccess() const
|
|
|
|
{
|
2014-04-06 19:32:38 +00:00
|
|
|
return HasFlag(NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE | NODE_CHROME_ONLY_ACCESS);
|
2012-10-10 19:04:42 +00:00
|
|
|
}
|
|
|
|
|
2014-07-03 17:02:07 +00:00
|
|
|
bool IsInShadowTree() const
|
|
|
|
{
|
|
|
|
return HasFlag(NODE_IS_IN_SHADOW_TREE);
|
|
|
|
}
|
|
|
|
|
2011-12-20 09:15:41 +00:00
|
|
|
/**
|
|
|
|
* Returns true if |this| node is the common ancestor of the start/end
|
|
|
|
* nodes of a Range in a Selection or a descendant of such a common ancestor.
|
|
|
|
* This node is definitely not selected when |false| is returned, but it may
|
|
|
|
* or may not be selected when |true| is returned.
|
|
|
|
*/
|
|
|
|
bool IsSelectionDescendant() const
|
|
|
|
{
|
|
|
|
return IsDescendantOfCommonAncestorForRangeInSelection() ||
|
|
|
|
IsCommonAncestorForRangeInSelection();
|
|
|
|
}
|
|
|
|
|
2008-02-20 07:40:04 +00:00
|
|
|
/**
|
|
|
|
* Get the root content of an editor. So, this node must be a descendant of
|
|
|
|
* an editor. Note that this should be only used for getting input or textarea
|
|
|
|
* editor's root content. This method doesn't support HTML editors.
|
|
|
|
*/
|
2017-06-22 06:21:31 +00:00
|
|
|
nsIContent* GetTextEditorRootContent(
|
|
|
|
mozilla::TextEditor** aTextEditor = nullptr);
|
2008-02-20 07:40:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the nearest selection root, ie. the node that will be selected if the
|
|
|
|
* user does "Select All" while the focus is in this node. Note that if this
|
|
|
|
* node is not in an editor, the result comes from the nsFrameSelection that
|
|
|
|
* is related to aPresShell, so the result might not be the ancestor of this
|
2009-12-12 04:25:21 +00:00
|
|
|
* node. Be aware that if this node and the computed selection limiter are
|
|
|
|
* not in same subtree, this returns the root content of the closeset subtree.
|
2008-02-20 07:40:04 +00:00
|
|
|
*/
|
|
|
|
nsIContent* GetSelectionRootContent(nsIPresShell* aPresShell);
|
|
|
|
|
2012-10-09 12:31:24 +00:00
|
|
|
virtual nsINodeList* ChildNodes();
|
2010-05-11 01:12:34 +00:00
|
|
|
nsIContent* GetFirstChild() const { return mFirstChild; }
|
2009-01-02 17:00:18 +00:00
|
|
|
nsIContent* GetLastChild() const
|
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t count;
|
2009-01-02 17:00:18 +00:00
|
|
|
nsIContent* const* children = GetChildArray(&count);
|
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
return count > 0 ? children[count - 1] : nullptr;
|
2009-01-02 17:00:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implementation is in nsIDocument.h, because it needs to cast from
|
|
|
|
* nsIDocument* to nsINode*.
|
|
|
|
*/
|
|
|
|
nsIDocument* GetOwnerDocument() const;
|
|
|
|
|
2012-10-09 12:31:24 +00:00
|
|
|
void Normalize();
|
2011-06-24 19:55:14 +00:00
|
|
|
|
2010-04-19 15:40:15 +00:00
|
|
|
/**
|
|
|
|
* Get the base URI for any relative URIs within this piece of
|
|
|
|
* content. Generally, this is the document's base URI, but certain
|
|
|
|
* content carries a local base for backward compatibility, and XML
|
|
|
|
* supports setting a per-node base URI.
|
|
|
|
*
|
|
|
|
* @return the base URI
|
|
|
|
*/
|
2013-09-24 21:56:52 +00:00
|
|
|
virtual already_AddRefed<nsIURI> GetBaseURI(bool aTryUseXHRDocBaseURI = false) const = 0;
|
|
|
|
already_AddRefed<nsIURI> GetBaseURIObject() const;
|
2010-04-19 15:40:15 +00:00
|
|
|
|
2016-05-06 10:39:10 +00:00
|
|
|
/**
|
|
|
|
* Return true if the node may be apz aware. There are two cases. One is that
|
|
|
|
* the node is apz aware (such as HTMLInputElement with number type). The
|
|
|
|
* other is that the node has apz aware listeners. This is a non-virtual
|
|
|
|
* function which calls IsNodeApzAwareInternal only when the MayBeApzAware is
|
|
|
|
* set. We check the details in IsNodeApzAwareInternal which may be overriden
|
|
|
|
* by child classes
|
|
|
|
*/
|
|
|
|
bool IsNodeApzAware() const
|
|
|
|
{
|
|
|
|
return NodeMayBeApzAware() ? IsNodeApzAwareInternal() : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Override this function and set the flag MayBeApzAware in case the node has
|
|
|
|
* to let APZC be aware of it. It's used when the node may handle the apz
|
|
|
|
* aware events and may do preventDefault to stop APZC to do default actions.
|
|
|
|
*
|
|
|
|
* For example, instead of scrolling page by APZ, we handle mouse wheel event
|
|
|
|
* in HTMLInputElement with number type as increasing / decreasing its value.
|
|
|
|
*/
|
|
|
|
virtual bool IsNodeApzAwareInternal() const;
|
|
|
|
|
2016-11-23 03:41:51 +00:00
|
|
|
// HTML elements named <shadow> may or may not be HTMLShadowElement. This is
|
|
|
|
// a way to ask an element whether it's an HTMLShadowElement.
|
|
|
|
virtual bool IsHTMLShadowElement() const { return false; }
|
|
|
|
|
2016-11-23 03:41:51 +00:00
|
|
|
// Elements named <content> may or may not be HTMLContentElement. This is a
|
|
|
|
// way to ask an element whether it's an HTMLContentElement.
|
|
|
|
virtual bool IsHTMLContentElement() const { return false; }
|
|
|
|
|
2014-08-05 10:10:00 +00:00
|
|
|
void GetTextContent(nsAString& aTextContent,
|
2017-01-18 04:52:29 +00:00
|
|
|
mozilla::OOMReporter& aError)
|
2010-04-19 15:41:33 +00:00
|
|
|
{
|
2014-08-05 10:10:00 +00:00
|
|
|
GetTextContentInternal(aTextContent, aError);
|
2010-04-19 15:41:33 +00:00
|
|
|
}
|
2012-10-09 12:31:24 +00:00
|
|
|
void SetTextContent(const nsAString& aTextContent,
|
|
|
|
mozilla::ErrorResult& aError)
|
2010-04-19 15:41:33 +00:00
|
|
|
{
|
2012-10-09 12:31:24 +00:00
|
|
|
SetTextContentInternal(aTextContent, aError);
|
2010-04-19 15:41:33 +00:00
|
|
|
}
|
|
|
|
|
2012-11-14 22:10:07 +00:00
|
|
|
mozilla::dom::Element* QuerySelector(const nsAString& aSelector,
|
|
|
|
mozilla::ErrorResult& aResult);
|
2012-10-16 11:51:00 +00:00
|
|
|
already_AddRefed<nsINodeList> QuerySelectorAll(const nsAString& aSelector,
|
|
|
|
mozilla::ErrorResult& aResult);
|
2012-08-30 17:10:13 +00:00
|
|
|
|
2013-11-01 19:39:24 +00:00
|
|
|
protected:
|
|
|
|
// nsIDocument overrides this with its own (faster) version. This
|
|
|
|
// should really only be called for elements and document fragments.
|
|
|
|
mozilla::dom::Element* GetElementById(const nsAString& aId);
|
|
|
|
|
2010-04-19 15:40:15 +00:00
|
|
|
/**
|
|
|
|
* Associate an object aData to aKey on this node. If aData is null any
|
2014-09-11 10:22:30 +00:00
|
|
|
* previously registered object associated to aKey on this node will
|
|
|
|
* be removed.
|
2010-04-19 15:40:15 +00:00
|
|
|
* Should only be used to implement the DOM Level 3 UserData API.
|
|
|
|
*
|
|
|
|
* @param aKey the key to associate the object to
|
|
|
|
* @param aData the object to associate to aKey on this node (may be null)
|
|
|
|
* @param aResult [out] the previously registered object for aKey on this
|
|
|
|
* node, if any
|
2014-09-11 10:22:30 +00:00
|
|
|
* @return whether adding the object succeeded
|
2010-04-19 15:40:15 +00:00
|
|
|
*/
|
|
|
|
nsresult SetUserData(const nsAString& aKey, nsIVariant* aData,
|
2014-09-11 10:22:30 +00:00
|
|
|
nsIVariant** aResult);
|
2010-04-19 15:40:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the UserData object registered for a Key on this node, if any.
|
|
|
|
* Should only be used to implement the DOM Level 3 UserData API.
|
|
|
|
*
|
|
|
|
* @param aKey the key to get UserData for
|
|
|
|
* @return aResult the previously registered object for aKey on this node, if
|
|
|
|
* any
|
|
|
|
*/
|
2013-06-10 22:41:42 +00:00
|
|
|
nsIVariant* GetUserData(const nsAString& aKey);
|
2010-04-19 15:40:15 +00:00
|
|
|
|
2016-11-18 21:38:29 +00:00
|
|
|
public:
|
2012-10-09 12:31:24 +00:00
|
|
|
void LookupPrefix(const nsAString& aNamespace, nsAString& aResult);
|
|
|
|
bool IsDefaultNamespace(const nsAString& aNamespaceURI)
|
2010-04-19 15:40:16 +00:00
|
|
|
{
|
|
|
|
nsAutoString defaultNamespace;
|
|
|
|
LookupNamespaceURI(EmptyString(), defaultNamespace);
|
2012-10-09 12:31:24 +00:00
|
|
|
return aNamespaceURI.Equals(defaultNamespace);
|
2010-04-19 15:40:16 +00:00
|
|
|
}
|
2012-10-09 12:31:24 +00:00
|
|
|
void LookupNamespaceURI(const nsAString& aNamespacePrefix,
|
|
|
|
nsAString& aNamespaceURI);
|
2011-06-14 07:56:48 +00:00
|
|
|
|
2012-02-20 12:54:45 +00:00
|
|
|
nsIContent* GetNextSibling() const { return mNextSibling; }
|
|
|
|
nsIContent* GetPreviousSibling() const { return mPreviousSibling; }
|
2010-05-11 01:12:33 +00:00
|
|
|
|
2010-05-11 01:12:34 +00:00
|
|
|
/**
|
|
|
|
* Get the next node in the pre-order tree traversal of the DOM. If
|
|
|
|
* aRoot is non-null, then it must be an ancestor of |this|
|
|
|
|
* (possibly equal to |this|) and only nodes that are descendants of
|
|
|
|
* aRoot, not including aRoot itself, will be returned. Returns
|
|
|
|
* null if there are no more nodes to traverse.
|
|
|
|
*/
|
2012-07-30 14:20:58 +00:00
|
|
|
nsIContent* GetNextNode(const nsINode* aRoot = nullptr) const
|
2011-07-29 11:48:04 +00:00
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
return GetNextNodeImpl(aRoot, false);
|
2011-07-29 11:48:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the next node in the pre-order tree traversal of the DOM but ignoring
|
|
|
|
* the children of this node. If aRoot is non-null, then it must be an
|
|
|
|
* ancestor of |this| (possibly equal to |this|) and only nodes that are
|
|
|
|
* descendants of aRoot, not including aRoot itself, will be returned.
|
|
|
|
* Returns null if there are no more nodes to traverse.
|
|
|
|
*/
|
2012-07-30 14:20:58 +00:00
|
|
|
nsIContent* GetNextNonChildNode(const nsINode* aRoot = nullptr) const
|
2011-07-29 11:48:04 +00:00
|
|
|
{
|
2011-10-17 14:59:28 +00:00
|
|
|
return GetNextNodeImpl(aRoot, true);
|
2011-07-29 11:48:04 +00:00
|
|
|
}
|
|
|
|
|
2011-09-02 20:15:53 +00:00
|
|
|
/**
|
|
|
|
* Returns true if 'this' is either document or element or
|
|
|
|
* document fragment and aOther is a descendant in the same
|
|
|
|
* anonymous tree.
|
|
|
|
*/
|
2011-09-29 06:19:26 +00:00
|
|
|
bool Contains(const nsINode* aOther) const;
|
2011-09-02 20:15:53 +00:00
|
|
|
|
2012-06-23 06:58:04 +00:00
|
|
|
bool UnoptimizableCCNode() const;
|
|
|
|
|
2011-07-29 11:48:04 +00:00
|
|
|
private:
|
|
|
|
|
2014-07-03 17:02:07 +00:00
|
|
|
nsIDocument* GetComposedDocInternal() const;
|
2014-06-07 08:42:53 +00:00
|
|
|
|
2011-07-29 11:48:04 +00:00
|
|
|
nsIContent* GetNextNodeImpl(const nsINode* aRoot,
|
2011-09-29 06:19:26 +00:00
|
|
|
const bool aSkipChildren) const
|
2010-05-11 01:12:34 +00:00
|
|
|
{
|
|
|
|
// Can't use nsContentUtils::ContentIsDescendantOf here, since we
|
|
|
|
// can't include it here.
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (aRoot) {
|
|
|
|
const nsINode* cur = this;
|
2012-10-09 12:31:24 +00:00
|
|
|
for (; cur; cur = cur->GetParentNode())
|
2010-05-11 01:12:34 +00:00
|
|
|
if (cur == aRoot) break;
|
|
|
|
NS_ASSERTION(cur, "aRoot not an ancestor of |this|?");
|
|
|
|
}
|
|
|
|
#endif
|
2011-07-29 11:48:04 +00:00
|
|
|
if (!aSkipChildren) {
|
|
|
|
nsIContent* kid = GetFirstChild();
|
|
|
|
if (kid) {
|
|
|
|
return kid;
|
|
|
|
}
|
2010-05-11 01:12:34 +00:00
|
|
|
}
|
|
|
|
if (this == aRoot) {
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2010-05-11 01:12:34 +00:00
|
|
|
}
|
|
|
|
const nsINode* cur = this;
|
|
|
|
while (1) {
|
|
|
|
nsIContent* next = cur->GetNextSibling();
|
|
|
|
if (next) {
|
|
|
|
return next;
|
|
|
|
}
|
2012-10-09 12:31:24 +00:00
|
|
|
nsINode* parent = cur->GetParentNode();
|
2010-05-11 01:12:34 +00:00
|
|
|
if (parent == aRoot) {
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2010-05-11 01:12:34 +00:00
|
|
|
}
|
|
|
|
cur = parent;
|
|
|
|
}
|
|
|
|
NS_NOTREACHED("How did we get here?");
|
|
|
|
}
|
|
|
|
|
2011-07-29 11:48:04 +00:00
|
|
|
public:
|
|
|
|
|
2011-04-12 02:46:59 +00:00
|
|
|
/**
|
|
|
|
* Get the previous nsIContent in the pre-order tree traversal of the DOM. If
|
|
|
|
* aRoot is non-null, then it must be an ancestor of |this|
|
|
|
|
* (possibly equal to |this|) and only nsIContents that are descendants of
|
|
|
|
* aRoot, including aRoot itself, will be returned. Returns
|
|
|
|
* null if there are no more nsIContents to traverse.
|
|
|
|
*/
|
2012-07-30 14:20:58 +00:00
|
|
|
nsIContent* GetPreviousContent(const nsINode* aRoot = nullptr) const
|
2011-04-12 02:46:59 +00:00
|
|
|
{
|
|
|
|
// Can't use nsContentUtils::ContentIsDescendantOf here, since we
|
|
|
|
// can't include it here.
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (aRoot) {
|
|
|
|
const nsINode* cur = this;
|
2012-10-09 12:31:24 +00:00
|
|
|
for (; cur; cur = cur->GetParentNode())
|
2011-04-12 02:46:59 +00:00
|
|
|
if (cur == aRoot) break;
|
|
|
|
NS_ASSERTION(cur, "aRoot not an ancestor of |this|?");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (this == aRoot) {
|
2012-07-30 14:20:58 +00:00
|
|
|
return nullptr;
|
2011-04-12 02:46:59 +00:00
|
|
|
}
|
|
|
|
nsIContent* cur = this->GetParent();
|
|
|
|
nsIContent* iter = this->GetPreviousSibling();
|
|
|
|
while (iter) {
|
|
|
|
cur = iter;
|
|
|
|
iter = reinterpret_cast<nsINode*>(iter)->GetLastChild();
|
|
|
|
}
|
|
|
|
return cur;
|
|
|
|
}
|
|
|
|
|
2011-04-08 02:29:49 +00:00
|
|
|
/**
|
|
|
|
* Boolean flags
|
|
|
|
*/
|
|
|
|
private:
|
|
|
|
enum BooleanFlag {
|
|
|
|
// Set if we're being used from -moz-element
|
|
|
|
NodeHasRenderingObservers,
|
|
|
|
// Set if our parent chain (including this node itself) terminates
|
|
|
|
// in a document
|
|
|
|
IsInDocument,
|
|
|
|
// Set if mParent is an nsIContent
|
|
|
|
ParentIsContent,
|
2011-04-08 02:29:49 +00:00
|
|
|
// Set if this node is an Element
|
|
|
|
NodeIsElement,
|
2011-04-08 02:29:50 +00:00
|
|
|
// Set if the element has a non-empty id attribute. This can in rare
|
|
|
|
// cases lie for nsXMLElement, such as when the node has been moved between
|
|
|
|
// documents with different id mappings.
|
|
|
|
ElementHasID,
|
2017-01-21 02:24:41 +00:00
|
|
|
// Set if the element might have a class.
|
|
|
|
ElementMayHaveClass,
|
2011-04-08 02:29:50 +00:00
|
|
|
// Set if the element might have inline style.
|
|
|
|
ElementMayHaveStyle,
|
2011-04-08 02:29:50 +00:00
|
|
|
// Set if the element has a name attribute set.
|
|
|
|
ElementHasName,
|
2011-04-08 02:29:50 +00:00
|
|
|
// Set if the element might have a contenteditable attribute set.
|
|
|
|
ElementMayHaveContentEditableAttr,
|
2011-12-20 09:15:41 +00:00
|
|
|
// Set if the node is the common ancestor of the start/end nodes of a Range
|
|
|
|
// that is in a Selection.
|
|
|
|
NodeIsCommonAncestorForRangeInSelection,
|
|
|
|
// Set if the node is a descendant of a node with the above bit set.
|
|
|
|
NodeIsDescendantOfCommonAncestorForRangeInSelection,
|
2012-01-30 20:08:13 +00:00
|
|
|
// Set if CanSkipInCC check has been done for this subtree root.
|
|
|
|
NodeIsCCMarkedRoot,
|
|
|
|
// Maybe set if this node is in black subtree.
|
|
|
|
NodeIsCCBlackTree,
|
2016-03-25 10:23:53 +00:00
|
|
|
// Maybe set if the node is a root of a subtree
|
2012-01-30 20:08:13 +00:00
|
|
|
// which needs to be kept in the purple buffer.
|
|
|
|
NodeIsPurpleRoot,
|
2012-02-08 18:42:38 +00:00
|
|
|
// Set if the element has some style states locked
|
|
|
|
ElementHasLockedStyleStates,
|
2012-04-11 21:55:21 +00:00
|
|
|
// Set if element has pointer locked
|
|
|
|
ElementHasPointerLock,
|
2012-03-31 16:30:13 +00:00
|
|
|
// Set if the node may have DOMMutationObserver attached to it.
|
|
|
|
NodeMayHaveDOMMutationObserver,
|
2012-06-19 03:47:35 +00:00
|
|
|
// Set if node is Content
|
|
|
|
NodeIsContent,
|
2012-07-31 17:28:21 +00:00
|
|
|
// Set if the node has animations or transitions
|
|
|
|
ElementHasAnimations,
|
2017-06-20 03:24:59 +00:00
|
|
|
// Set if node has a dir attribute with a valid value (ltr, rtl, or auto).
|
|
|
|
// Note that we cannot compute this from the dir attribute event state
|
|
|
|
// flags, because we can't use those to distinguish
|
|
|
|
// <bdi dir="some-invalid-value"> and <bdi dir="auto">.
|
2012-04-17 04:03:10 +00:00
|
|
|
NodeHasValidDirAttribute,
|
2012-11-21 10:13:57 +00:00
|
|
|
// Set if the node has dir=auto and has a property pointing to the text
|
|
|
|
// node that determines its direction
|
|
|
|
NodeHasDirAutoSet,
|
|
|
|
// Set if the node is a text node descendant of a node with dir=auto
|
|
|
|
// and has a TextNodeDirectionalityMap property listing the elements whose
|
|
|
|
// direction it determines.
|
|
|
|
NodeHasTextNodeDirectionalityMap,
|
|
|
|
// Set if a node in the node's parent chain has dir=auto.
|
|
|
|
NodeAncestorHasDirAuto,
|
2013-01-08 23:25:47 +00:00
|
|
|
// Set if the element is in the scope of a scoped style sheet; this flag is
|
2013-07-04 04:00:06 +00:00
|
|
|
// only accurate for elements bound to a document
|
2013-01-08 23:25:47 +00:00
|
|
|
ElementIsInStyleScope,
|
2013-01-08 23:25:47 +00:00
|
|
|
// Set if the element is a scoped style sheet root
|
|
|
|
ElementIsScopedStyleRoot,
|
2013-06-08 08:54:59 +00:00
|
|
|
// Set if the node is handling a click.
|
|
|
|
NodeHandlingClick,
|
|
|
|
// Set if the node has had :hover selectors matched against it
|
|
|
|
NodeHasRelevantHoverRules,
|
2013-12-17 13:58:32 +00:00
|
|
|
// Set if the element has a parser insertion mode other than "in body",
|
|
|
|
// per the HTML5 "Parse state" section.
|
|
|
|
ElementHasWeirdParserInsertionMode,
|
2014-06-16 23:01:22 +00:00
|
|
|
// Parser sets this flag if it has notified about the node.
|
|
|
|
ParserHasNotified,
|
2016-05-06 10:39:10 +00:00
|
|
|
// Sets if the node is apz aware or we have apz aware listeners.
|
|
|
|
MayBeApzAware,
|
2017-06-28 06:56:12 +00:00
|
|
|
// Set if the element might have any kind of anonymous content children,
|
|
|
|
// which would not be found through the element's children list.
|
|
|
|
ElementMayHaveAnonymousChildren,
|
2011-04-08 02:29:50 +00:00
|
|
|
// Guard value
|
2011-04-08 02:29:49 +00:00
|
|
|
BooleanFlagCount
|
|
|
|
};
|
|
|
|
|
|
|
|
void SetBoolFlag(BooleanFlag name, bool value) {
|
2013-11-11 08:03:59 +00:00
|
|
|
static_assert(BooleanFlagCount <= 8*sizeof(mBoolFlags),
|
|
|
|
"Too many boolean flags");
|
2011-04-08 02:29:49 +00:00
|
|
|
mBoolFlags = (mBoolFlags & ~(1 << name)) | (value << name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetBoolFlag(BooleanFlag name) {
|
2013-11-11 08:03:59 +00:00
|
|
|
static_assert(BooleanFlagCount <= 8*sizeof(mBoolFlags),
|
|
|
|
"Too many boolean flags");
|
2011-04-08 02:29:49 +00:00
|
|
|
mBoolFlags |= (1 << name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClearBoolFlag(BooleanFlag name) {
|
2013-11-11 08:03:59 +00:00
|
|
|
static_assert(BooleanFlagCount <= 8*sizeof(mBoolFlags),
|
|
|
|
"Too many boolean flags");
|
2011-04-08 02:29:49 +00:00
|
|
|
mBoolFlags &= ~(1 << name);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GetBoolFlag(BooleanFlag name) const {
|
2013-11-11 08:03:59 +00:00
|
|
|
static_assert(BooleanFlagCount <= 8*sizeof(mBoolFlags),
|
|
|
|
"Too many boolean flags");
|
2011-04-08 02:29:49 +00:00
|
|
|
return mBoolFlags & (1 << name);
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
bool HasRenderingObservers() const
|
|
|
|
{ return GetBoolFlag(NodeHasRenderingObservers); }
|
2010-08-13 13:31:31 +00:00
|
|
|
void SetHasRenderingObservers(bool aValue)
|
2011-04-08 02:29:49 +00:00
|
|
|
{ SetBoolFlag(NodeHasRenderingObservers, aValue); }
|
2012-06-19 03:47:35 +00:00
|
|
|
bool IsContent() const { return GetBoolFlag(NodeIsContent); }
|
2011-04-08 02:29:50 +00:00
|
|
|
bool HasID() const { return GetBoolFlag(ElementHasID); }
|
2017-01-21 02:24:41 +00:00
|
|
|
bool MayHaveClass() const { return GetBoolFlag(ElementMayHaveClass); }
|
|
|
|
void SetMayHaveClass() { SetBoolFlag(ElementMayHaveClass); }
|
2011-04-08 02:29:50 +00:00
|
|
|
bool MayHaveStyle() const { return GetBoolFlag(ElementMayHaveStyle); }
|
2011-04-08 02:29:50 +00:00
|
|
|
bool HasName() const { return GetBoolFlag(ElementHasName); }
|
2011-04-08 02:29:50 +00:00
|
|
|
bool MayHaveContentEditableAttr() const
|
|
|
|
{ return GetBoolFlag(ElementMayHaveContentEditableAttr); }
|
2011-12-20 09:15:41 +00:00
|
|
|
bool IsCommonAncestorForRangeInSelection() const
|
|
|
|
{ return GetBoolFlag(NodeIsCommonAncestorForRangeInSelection); }
|
|
|
|
void SetCommonAncestorForRangeInSelection()
|
|
|
|
{ SetBoolFlag(NodeIsCommonAncestorForRangeInSelection); }
|
|
|
|
void ClearCommonAncestorForRangeInSelection()
|
|
|
|
{ ClearBoolFlag(NodeIsCommonAncestorForRangeInSelection); }
|
|
|
|
bool IsDescendantOfCommonAncestorForRangeInSelection() const
|
|
|
|
{ return GetBoolFlag(NodeIsDescendantOfCommonAncestorForRangeInSelection); }
|
|
|
|
void SetDescendantOfCommonAncestorForRangeInSelection()
|
|
|
|
{ SetBoolFlag(NodeIsDescendantOfCommonAncestorForRangeInSelection); }
|
|
|
|
void ClearDescendantOfCommonAncestorForRangeInSelection()
|
|
|
|
{ ClearBoolFlag(NodeIsDescendantOfCommonAncestorForRangeInSelection); }
|
2011-04-08 02:29:49 +00:00
|
|
|
|
2012-01-30 20:08:13 +00:00
|
|
|
void SetCCMarkedRoot(bool aValue)
|
|
|
|
{ SetBoolFlag(NodeIsCCMarkedRoot, aValue); }
|
|
|
|
bool CCMarkedRoot() const { return GetBoolFlag(NodeIsCCMarkedRoot); }
|
|
|
|
void SetInCCBlackTree(bool aValue)
|
|
|
|
{ SetBoolFlag(NodeIsCCBlackTree, aValue); }
|
|
|
|
bool InCCBlackTree() const { return GetBoolFlag(NodeIsCCBlackTree); }
|
|
|
|
void SetIsPurpleRoot(bool aValue)
|
|
|
|
{ SetBoolFlag(NodeIsPurpleRoot, aValue); }
|
|
|
|
bool IsPurpleRoot() const { return GetBoolFlag(NodeIsPurpleRoot); }
|
2012-03-31 16:30:13 +00:00
|
|
|
bool MayHaveDOMMutationObserver()
|
|
|
|
{ return GetBoolFlag(NodeMayHaveDOMMutationObserver); }
|
|
|
|
void SetMayHaveDOMMutationObserver()
|
|
|
|
{ SetBoolFlag(NodeMayHaveDOMMutationObserver, true); }
|
2012-02-27 14:03:15 +00:00
|
|
|
bool HasListenerManager() { return HasFlag(NODE_HAS_LISTENERMANAGER); }
|
2012-04-11 21:55:21 +00:00
|
|
|
bool HasPointerLock() const { return GetBoolFlag(ElementHasPointerLock); }
|
|
|
|
void SetPointerLock() { SetBoolFlag(ElementHasPointerLock); }
|
|
|
|
void ClearPointerLock() { ClearBoolFlag(ElementHasPointerLock); }
|
2017-03-10 02:53:19 +00:00
|
|
|
bool MayHaveAnimations() const { return GetBoolFlag(ElementHasAnimations); }
|
2012-07-31 17:28:21 +00:00
|
|
|
void SetMayHaveAnimations() { SetBoolFlag(ElementHasAnimations); }
|
2012-04-17 04:03:10 +00:00
|
|
|
void SetHasValidDir() { SetBoolFlag(NodeHasValidDirAttribute); }
|
|
|
|
void ClearHasValidDir() { ClearBoolFlag(NodeHasValidDirAttribute); }
|
|
|
|
bool HasValidDir() const { return GetBoolFlag(NodeHasValidDirAttribute); }
|
2012-11-21 10:13:57 +00:00
|
|
|
void SetHasDirAutoSet() {
|
|
|
|
MOZ_ASSERT(NodeType() != nsIDOMNode::TEXT_NODE,
|
|
|
|
"SetHasDirAutoSet on text node");
|
|
|
|
SetBoolFlag(NodeHasDirAutoSet);
|
|
|
|
}
|
|
|
|
void ClearHasDirAutoSet() {
|
|
|
|
MOZ_ASSERT(NodeType() != nsIDOMNode::TEXT_NODE,
|
|
|
|
"ClearHasDirAutoSet on text node");
|
|
|
|
ClearBoolFlag(NodeHasDirAutoSet);
|
|
|
|
}
|
|
|
|
bool HasDirAutoSet() const
|
|
|
|
{ return GetBoolFlag(NodeHasDirAutoSet); }
|
|
|
|
void SetHasTextNodeDirectionalityMap() {
|
|
|
|
MOZ_ASSERT(NodeType() == nsIDOMNode::TEXT_NODE,
|
|
|
|
"SetHasTextNodeDirectionalityMap on non-text node");
|
|
|
|
SetBoolFlag(NodeHasTextNodeDirectionalityMap);
|
|
|
|
}
|
|
|
|
void ClearHasTextNodeDirectionalityMap() {
|
|
|
|
MOZ_ASSERT(NodeType() == nsIDOMNode::TEXT_NODE,
|
|
|
|
"ClearHasTextNodeDirectionalityMap on non-text node");
|
|
|
|
ClearBoolFlag(NodeHasTextNodeDirectionalityMap);
|
|
|
|
}
|
2016-03-18 21:21:50 +00:00
|
|
|
bool HasTextNodeDirectionalityMap() const {
|
|
|
|
MOZ_ASSERT(NodeType() == nsIDOMNode::TEXT_NODE,
|
|
|
|
"HasTextNodeDirectionalityMap on non-text node");
|
|
|
|
return GetBoolFlag(NodeHasTextNodeDirectionalityMap);
|
|
|
|
}
|
2012-11-21 10:13:57 +00:00
|
|
|
|
|
|
|
void SetAncestorHasDirAuto() { SetBoolFlag(NodeAncestorHasDirAuto); }
|
|
|
|
void ClearAncestorHasDirAuto() { ClearBoolFlag(NodeAncestorHasDirAuto); }
|
|
|
|
bool AncestorHasDirAuto() const { return GetBoolFlag(NodeAncestorHasDirAuto); }
|
|
|
|
|
2017-06-20 03:24:59 +00:00
|
|
|
// Implemented in nsIContentInlines.h.
|
|
|
|
inline bool NodeOrAncestorHasDirAuto() const;
|
2013-01-08 23:25:47 +00:00
|
|
|
|
|
|
|
void SetIsElementInStyleScope(bool aValue) {
|
|
|
|
MOZ_ASSERT(IsElement(), "SetIsInStyleScope on a non-Element node");
|
|
|
|
SetBoolFlag(ElementIsInStyleScope, aValue);
|
|
|
|
}
|
|
|
|
void SetIsElementInStyleScope() {
|
|
|
|
MOZ_ASSERT(IsElement(), "SetIsInStyleScope on a non-Element node");
|
|
|
|
SetBoolFlag(ElementIsInStyleScope);
|
|
|
|
}
|
|
|
|
void ClearIsElementInStyleScope() {
|
|
|
|
MOZ_ASSERT(IsElement(), "ClearIsInStyleScope on a non-Element node");
|
|
|
|
ClearBoolFlag(ElementIsInStyleScope);
|
|
|
|
}
|
|
|
|
bool IsElementInStyleScope() const { return GetBoolFlag(ElementIsInStyleScope); }
|
2013-01-08 23:25:47 +00:00
|
|
|
|
|
|
|
void SetIsScopedStyleRoot() { SetBoolFlag(ElementIsScopedStyleRoot); }
|
|
|
|
void ClearIsScopedStyleRoot() { ClearBoolFlag(ElementIsScopedStyleRoot); }
|
|
|
|
bool IsScopedStyleRoot() { return GetBoolFlag(ElementIsScopedStyleRoot); }
|
2013-06-08 08:54:59 +00:00
|
|
|
bool HasRelevantHoverRules() const { return GetBoolFlag(NodeHasRelevantHoverRules); }
|
|
|
|
void SetHasRelevantHoverRules() { SetBoolFlag(NodeHasRelevantHoverRules); }
|
2014-06-16 23:01:22 +00:00
|
|
|
void SetParserHasNotified() { SetBoolFlag(ParserHasNotified); };
|
|
|
|
bool HasParserNotified() { return GetBoolFlag(ParserHasNotified); }
|
2015-09-17 10:16:20 +00:00
|
|
|
|
2016-05-06 10:39:10 +00:00
|
|
|
void SetMayBeApzAware() { SetBoolFlag(MayBeApzAware); }
|
|
|
|
bool NodeMayBeApzAware() const
|
2015-09-17 10:16:20 +00:00
|
|
|
{
|
2016-05-06 10:39:10 +00:00
|
|
|
return GetBoolFlag(MayBeApzAware);
|
2015-09-17 10:16:20 +00:00
|
|
|
}
|
2017-06-28 06:56:12 +00:00
|
|
|
|
|
|
|
void SetMayHaveAnonymousChildren() { SetBoolFlag(ElementMayHaveAnonymousChildren); }
|
|
|
|
bool MayHaveAnonymousChildren() const { return GetBoolFlag(ElementMayHaveAnonymousChildren); }
|
|
|
|
|
2011-04-08 02:29:49 +00:00
|
|
|
protected:
|
|
|
|
void SetParentIsContent(bool aValue) { SetBoolFlag(ParentIsContent, aValue); }
|
2016-08-19 20:08:56 +00:00
|
|
|
void SetIsInDocument() { SetBoolFlag(IsInDocument); }
|
2012-06-19 03:47:35 +00:00
|
|
|
void SetNodeIsContent() { SetBoolFlag(NodeIsContent); }
|
2011-04-08 02:29:49 +00:00
|
|
|
void ClearInDocument() { ClearBoolFlag(IsInDocument); }
|
2011-04-08 02:29:49 +00:00
|
|
|
void SetIsElement() { SetBoolFlag(NodeIsElement); }
|
2011-04-08 02:29:50 +00:00
|
|
|
void SetHasID() { SetBoolFlag(ElementHasID); }
|
|
|
|
void ClearHasID() { ClearBoolFlag(ElementHasID); }
|
2011-04-08 02:29:50 +00:00
|
|
|
void SetMayHaveStyle() { SetBoolFlag(ElementMayHaveStyle); }
|
2011-04-08 02:29:50 +00:00
|
|
|
void SetHasName() { SetBoolFlag(ElementHasName); }
|
|
|
|
void ClearHasName() { ClearBoolFlag(ElementHasName); }
|
2011-04-08 02:29:50 +00:00
|
|
|
void SetMayHaveContentEditableAttr()
|
|
|
|
{ SetBoolFlag(ElementMayHaveContentEditableAttr); }
|
2012-02-08 18:42:38 +00:00
|
|
|
void SetHasLockedStyleStates() { SetBoolFlag(ElementHasLockedStyleStates); }
|
|
|
|
void ClearHasLockedStyleStates() { ClearBoolFlag(ElementHasLockedStyleStates); }
|
|
|
|
bool HasLockedStyleStates() const
|
|
|
|
{ return GetBoolFlag(ElementHasLockedStyleStates); }
|
2013-12-17 13:58:32 +00:00
|
|
|
void SetHasWeirdParserInsertionMode() { SetBoolFlag(ElementHasWeirdParserInsertionMode); }
|
|
|
|
bool HasWeirdParserInsertionMode() const
|
|
|
|
{ return GetBoolFlag(ElementHasWeirdParserInsertionMode); }
|
2013-06-08 08:54:59 +00:00
|
|
|
bool HandlingClick() const { return GetBoolFlag(NodeHandlingClick); }
|
|
|
|
void SetHandlingClick() { SetBoolFlag(NodeHandlingClick); }
|
|
|
|
void ClearHandlingClick() { ClearBoolFlag(NodeHandlingClick); }
|
2011-04-08 02:29:49 +00:00
|
|
|
|
2013-01-08 23:25:47 +00:00
|
|
|
void SetSubtreeRootPointer(nsINode* aSubtreeRoot)
|
2012-03-14 20:14:02 +00:00
|
|
|
{
|
|
|
|
NS_ASSERTION(aSubtreeRoot, "aSubtreeRoot can never be null!");
|
2016-03-31 10:58:25 +00:00
|
|
|
NS_ASSERTION(!(IsNodeOfType(eCONTENT) && IsInUncomposedDoc()) &&
|
2014-07-03 17:02:07 +00:00
|
|
|
!IsInShadowTree(), "Shouldn't be here!");
|
2012-03-14 20:14:02 +00:00
|
|
|
mSubtreeRoot = aSubtreeRoot;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClearSubtreeRootPointer()
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
mSubtreeRoot = nullptr;
|
2012-03-14 20:14:02 +00:00
|
|
|
}
|
|
|
|
|
2011-04-08 02:29:49 +00:00
|
|
|
public:
|
2012-03-31 16:30:13 +00:00
|
|
|
// Makes nsINode object to keep aObject alive.
|
|
|
|
void BindObject(nsISupports* aObject);
|
|
|
|
// After calling UnbindObject nsINode object doesn't keep
|
|
|
|
// aObject alive anymore.
|
|
|
|
void UnbindObject(nsISupports* aObject);
|
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
void GetBoundMutationObservers(nsTArray<RefPtr<nsDOMMutationObserver> >& aResult);
|
2017-06-15 01:49:17 +00:00
|
|
|
void GenerateXPath(nsAString& aResult);
|
2013-09-11 19:43:01 +00:00
|
|
|
|
2016-08-23 18:15:15 +00:00
|
|
|
already_AddRefed<mozilla::dom::AccessibleNode> GetAccessibleNode();
|
|
|
|
|
2012-03-29 21:09:04 +00:00
|
|
|
/**
|
|
|
|
* Returns the length of this node, as specified at
|
|
|
|
* <http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#concept-node-length>
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t Length() const;
|
2012-03-29 21:09:04 +00:00
|
|
|
|
2013-10-11 16:28:23 +00:00
|
|
|
void GetNodeName(mozilla::dom::DOMString& aNodeName)
|
2012-10-09 12:31:24 +00:00
|
|
|
{
|
2013-10-11 16:28:23 +00:00
|
|
|
const nsString& nodeName = NodeName();
|
|
|
|
aNodeName.SetStringBuffer(nsStringBuffer::FromString(nodeName),
|
|
|
|
nodeName.Length());
|
2012-10-09 12:31:24 +00:00
|
|
|
}
|
2016-09-20 12:02:33 +00:00
|
|
|
MOZ_MUST_USE nsresult GetBaseURI(nsAString& aBaseURI) const;
|
2013-09-24 21:56:52 +00:00
|
|
|
// Return the base URI for the document.
|
|
|
|
// The returned value may differ if the document is loaded via XHR, and
|
|
|
|
// when accessed from chrome privileged script and
|
|
|
|
// from content privileged script for compatibility.
|
2017-02-01 20:43:36 +00:00
|
|
|
void GetBaseURIFromJS(nsAString& aBaseURI,
|
|
|
|
CallerType aCallerType,
|
|
|
|
ErrorResult& aRv) const;
|
2012-10-09 12:31:24 +00:00
|
|
|
bool HasChildNodes() const
|
|
|
|
{
|
|
|
|
return HasChildren();
|
|
|
|
}
|
|
|
|
uint16_t CompareDocumentPosition(nsINode& aOther) const;
|
|
|
|
void GetNodeValue(nsAString& aNodeValue)
|
|
|
|
{
|
|
|
|
GetNodeValueInternal(aNodeValue);
|
|
|
|
}
|
|
|
|
void SetNodeValue(const nsAString& aNodeValue,
|
|
|
|
mozilla::ErrorResult& aError)
|
|
|
|
{
|
|
|
|
SetNodeValueInternal(aNodeValue, aError);
|
|
|
|
}
|
2012-11-27 08:41:02 +00:00
|
|
|
virtual void GetNodeValueInternal(nsAString& aNodeValue);
|
2012-10-09 12:31:24 +00:00
|
|
|
virtual void SetNodeValueInternal(const nsAString& aNodeValue,
|
|
|
|
mozilla::ErrorResult& aError)
|
|
|
|
{
|
|
|
|
// The DOM spec says that when nodeValue is defined to be null "setting it
|
|
|
|
// has no effect", so we don't throw an exception.
|
|
|
|
}
|
2015-10-07 13:07:39 +00:00
|
|
|
void EnsurePreInsertionValidity(nsINode& aNewChild, nsINode* aRefChild,
|
|
|
|
mozilla::ErrorResult& aError);
|
2012-10-09 12:31:24 +00:00
|
|
|
nsINode* InsertBefore(nsINode& aNode, nsINode* aChild,
|
|
|
|
mozilla::ErrorResult& aError)
|
|
|
|
{
|
|
|
|
return ReplaceOrInsertBefore(false, &aNode, aChild, aError);
|
|
|
|
}
|
|
|
|
nsINode* AppendChild(nsINode& aNode, mozilla::ErrorResult& aError)
|
|
|
|
{
|
|
|
|
return InsertBefore(aNode, nullptr, aError);
|
|
|
|
}
|
|
|
|
nsINode* ReplaceChild(nsINode& aNode, nsINode& aChild,
|
|
|
|
mozilla::ErrorResult& aError)
|
|
|
|
{
|
|
|
|
return ReplaceOrInsertBefore(true, &aNode, &aChild, aError);
|
|
|
|
}
|
|
|
|
nsINode* RemoveChild(nsINode& aChild, mozilla::ErrorResult& aError);
|
|
|
|
already_AddRefed<nsINode> CloneNode(bool aDeep, mozilla::ErrorResult& aError);
|
2016-03-25 10:23:50 +00:00
|
|
|
bool IsSameNode(nsINode* aNode);
|
2012-10-09 12:31:24 +00:00
|
|
|
bool IsEqualNode(nsINode* aNode);
|
2013-01-29 22:53:52 +00:00
|
|
|
void GetNamespaceURI(nsAString& aNamespaceURI) const
|
2012-10-09 12:31:24 +00:00
|
|
|
{
|
2013-01-29 22:53:52 +00:00
|
|
|
mNodeInfo->GetNamespaceURI(aNamespaceURI);
|
2012-10-09 12:31:24 +00:00
|
|
|
}
|
|
|
|
#ifdef MOZILLA_INTERNAL_API
|
|
|
|
void GetPrefix(nsAString& aPrefix)
|
|
|
|
{
|
|
|
|
mNodeInfo->GetPrefix(aPrefix);
|
|
|
|
}
|
|
|
|
#endif
|
2015-07-08 19:58:07 +00:00
|
|
|
void GetLocalName(mozilla::dom::DOMString& aLocalName) const
|
2013-10-11 16:28:23 +00:00
|
|
|
{
|
|
|
|
const nsString& localName = LocalName();
|
|
|
|
if (localName.IsVoid()) {
|
|
|
|
aLocalName.SetNull();
|
|
|
|
} else {
|
|
|
|
aLocalName.SetStringBuffer(nsStringBuffer::FromString(localName),
|
|
|
|
localName.Length());
|
|
|
|
}
|
2012-10-09 12:31:24 +00:00
|
|
|
}
|
2014-10-01 08:16:00 +00:00
|
|
|
|
2012-10-09 12:31:24 +00:00
|
|
|
nsDOMAttributeMap* GetAttributes();
|
2014-06-11 20:26:52 +00:00
|
|
|
void SetUserData(JSContext* aCx, const nsAString& aKey,
|
|
|
|
JS::Handle<JS::Value> aData,
|
|
|
|
JS::MutableHandle<JS::Value> aRetval,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void GetUserData(JSContext* aCx, const nsAString& aKey,
|
|
|
|
JS::MutableHandle<JS::Value> aRetval,
|
|
|
|
mozilla::ErrorResult& aError);
|
2012-10-09 12:31:24 +00:00
|
|
|
|
|
|
|
// Helper method to remove this node from its parent. This is not exposed
|
|
|
|
// through WebIDL.
|
|
|
|
// Only call this if the node has a parent node.
|
|
|
|
nsresult RemoveFromParent()
|
|
|
|
{
|
|
|
|
nsINode* parent = GetParentNode();
|
|
|
|
mozilla::ErrorResult rv;
|
|
|
|
parent->RemoveChild(*this, rv);
|
2015-04-27 13:18:51 +00:00
|
|
|
return rv.StealNSResult();
|
2012-10-09 12:31:24 +00:00
|
|
|
}
|
|
|
|
|
2013-07-22 12:15:43 +00:00
|
|
|
// ChildNode methods
|
|
|
|
mozilla::dom::Element* GetPreviousElementSibling() const;
|
|
|
|
mozilla::dom::Element* GetNextElementSibling() const;
|
2016-04-12 02:48:14 +00:00
|
|
|
|
|
|
|
void Before(const Sequence<OwningNodeOrString>& aNodes, ErrorResult& aRv);
|
|
|
|
void After(const Sequence<OwningNodeOrString>& aNodes, ErrorResult& aRv);
|
|
|
|
void ReplaceWith(const Sequence<OwningNodeOrString>& aNodes,
|
|
|
|
ErrorResult& aRv);
|
2013-04-13 07:08:47 +00:00
|
|
|
/**
|
|
|
|
* Remove this node from its parent, if any.
|
|
|
|
*/
|
|
|
|
void Remove();
|
|
|
|
|
2013-07-22 12:15:43 +00:00
|
|
|
// ParentNode methods
|
|
|
|
mozilla::dom::Element* GetFirstElementChild() const;
|
|
|
|
mozilla::dom::Element* GetLastElementChild() const;
|
|
|
|
|
2016-04-12 02:48:14 +00:00
|
|
|
void Prepend(const Sequence<OwningNodeOrString>& aNodes, ErrorResult& aRv);
|
|
|
|
void Append(const Sequence<OwningNodeOrString>& aNodes, ErrorResult& aRv);
|
|
|
|
|
2014-03-12 01:11:38 +00:00
|
|
|
void GetBoxQuads(const BoxQuadOptions& aOptions,
|
2015-10-18 05:24:48 +00:00
|
|
|
nsTArray<RefPtr<DOMQuad> >& aResult,
|
2017-02-01 20:43:59 +00:00
|
|
|
CallerType aCallerType,
|
|
|
|
ErrorResult& aRv);
|
2014-03-12 01:11:38 +00:00
|
|
|
|
2014-03-12 01:11:39 +00:00
|
|
|
already_AddRefed<DOMQuad> ConvertQuadFromNode(DOMQuad& aQuad,
|
|
|
|
const TextOrElementOrDocument& aFrom,
|
|
|
|
const ConvertCoordinateOptions& aOptions,
|
2017-02-01 20:43:59 +00:00
|
|
|
CallerType aCallerType,
|
2014-03-12 01:11:39 +00:00
|
|
|
ErrorResult& aRv);
|
|
|
|
already_AddRefed<DOMQuad> ConvertRectFromNode(DOMRectReadOnly& aRect,
|
|
|
|
const TextOrElementOrDocument& aFrom,
|
|
|
|
const ConvertCoordinateOptions& aOptions,
|
2017-02-01 20:43:59 +00:00
|
|
|
CallerType aCallerType,
|
2014-03-12 01:11:39 +00:00
|
|
|
ErrorResult& aRv);
|
|
|
|
already_AddRefed<DOMPoint> ConvertPointFromNode(const DOMPointInit& aPoint,
|
|
|
|
const TextOrElementOrDocument& aFrom,
|
|
|
|
const ConvertCoordinateOptions& aOptions,
|
2017-02-01 20:43:59 +00:00
|
|
|
CallerType aCallerType,
|
2014-03-12 01:11:39 +00:00
|
|
|
ErrorResult& aRv);
|
|
|
|
|
2006-05-15 09:46:44 +00:00
|
|
|
protected:
|
2006-05-15 07:03:15 +00:00
|
|
|
|
2006-07-02 07:23:10 +00:00
|
|
|
// Override this function to create a custom slots class.
|
2012-08-10 22:27:28 +00:00
|
|
|
// Must not return null.
|
2006-07-02 07:23:10 +00:00
|
|
|
virtual nsINode::nsSlots* CreateSlots();
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool HasSlots() const
|
2006-05-15 07:03:15 +00:00
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
return mSlots != nullptr;
|
2006-05-15 07:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsSlots* GetExistingSlots() const
|
|
|
|
{
|
2011-04-08 02:29:49 +00:00
|
|
|
return mSlots;
|
2006-05-15 07:03:15 +00:00
|
|
|
}
|
|
|
|
|
2012-08-10 22:27:28 +00:00
|
|
|
nsSlots* Slots()
|
2006-05-15 07:03:15 +00:00
|
|
|
{
|
2011-04-08 02:29:49 +00:00
|
|
|
if (!HasSlots()) {
|
|
|
|
mSlots = CreateSlots();
|
2012-08-10 22:27:28 +00:00
|
|
|
MOZ_ASSERT(mSlots);
|
2006-07-02 07:23:10 +00:00
|
|
|
}
|
2011-04-08 02:29:49 +00:00
|
|
|
return GetExistingSlots();
|
2006-05-15 07:03:15 +00:00
|
|
|
}
|
|
|
|
|
2008-01-02 20:49:13 +00:00
|
|
|
nsTObserverArray<nsIMutationObserver*> *GetMutationObservers()
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
return HasSlots() ? &GetExistingSlots()->mMutationObservers : nullptr;
|
2008-01-02 20:49:13 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool IsEditableInternal() const;
|
|
|
|
virtual bool IsEditableExternal() const
|
2007-07-11 13:05:05 +00:00
|
|
|
{
|
|
|
|
return IsEditableInternal();
|
|
|
|
}
|
|
|
|
|
2014-08-05 10:10:00 +00:00
|
|
|
virtual void GetTextContentInternal(nsAString& aTextContent,
|
2017-01-18 04:52:29 +00:00
|
|
|
mozilla::OOMReporter& aError);
|
2012-10-09 12:31:24 +00:00
|
|
|
virtual void SetTextContentInternal(const nsAString& aTextContent,
|
|
|
|
mozilla::ErrorResult& aError)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-04-23 07:21:22 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
// Note: virtual so that IsInNativeAnonymousSubtree can be called accross
|
|
|
|
// module boundaries.
|
|
|
|
virtual void CheckNotNativeAnonymous() const;
|
|
|
|
#endif
|
|
|
|
|
2012-10-09 12:31:24 +00:00
|
|
|
// These are just used to implement nsIDOMNode using
|
|
|
|
// NS_FORWARD_NSIDOMNODE_TO_NSINODE_HELPER and for quickstubs.
|
2009-01-02 17:00:18 +00:00
|
|
|
nsresult GetParentNode(nsIDOMNode** aParentNode);
|
|
|
|
nsresult GetChildNodes(nsIDOMNodeList** aChildNodes);
|
|
|
|
nsresult GetFirstChild(nsIDOMNode** aFirstChild);
|
|
|
|
nsresult GetLastChild(nsIDOMNode** aLastChild);
|
|
|
|
nsresult GetPreviousSibling(nsIDOMNode** aPrevSibling);
|
|
|
|
nsresult GetNextSibling(nsIDOMNode** aNextSibling);
|
|
|
|
nsresult GetOwnerDocument(nsIDOMDocument** aOwnerDocument);
|
|
|
|
|
2015-10-07 13:07:39 +00:00
|
|
|
void EnsurePreInsertionValidity1(nsINode& aNewChild, nsINode* aRefChild,
|
|
|
|
mozilla::ErrorResult& aError);
|
|
|
|
void EnsurePreInsertionValidity2(bool aReplace, nsINode& aNewChild,
|
|
|
|
nsINode* aRefChild,
|
|
|
|
mozilla::ErrorResult& aError);
|
2012-10-09 12:31:24 +00:00
|
|
|
nsINode* ReplaceOrInsertBefore(bool aReplace, nsINode* aNewChild,
|
|
|
|
nsINode* aRefChild,
|
|
|
|
mozilla::ErrorResult& aError);
|
2010-03-17 15:06:19 +00:00
|
|
|
nsresult RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn);
|
|
|
|
|
2010-04-19 15:40:16 +00:00
|
|
|
/**
|
|
|
|
* Returns the Element that should be used for resolving namespaces
|
|
|
|
* on this node (ie the ownerElement for attributes, the documentElement for
|
|
|
|
* documents, the node itself for elements and for other nodes the parentNode
|
|
|
|
* if it is an element).
|
|
|
|
*/
|
|
|
|
virtual mozilla::dom::Element* GetNameSpaceElement() = 0;
|
|
|
|
|
2010-05-11 01:12:34 +00:00
|
|
|
/**
|
|
|
|
* Most of the implementation of the nsINode RemoveChildAt method.
|
|
|
|
* Should only be called on document, element, and document fragment
|
|
|
|
* nodes. The aChildArray passed in should be the one for |this|.
|
|
|
|
*
|
|
|
|
* @param aIndex The index to remove at.
|
|
|
|
* @param aNotify Whether to notify.
|
|
|
|
* @param aKid The kid at aIndex. Must not be null.
|
|
|
|
* @param aChildArray The child array to work with.
|
|
|
|
* @param aMutationEvent whether to fire a mutation event for this removal.
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
void doRemoveChildAt(uint32_t aIndex, bool aNotify, nsIContent* aKid,
|
2012-03-29 21:09:06 +00:00
|
|
|
nsAttrAndChildArray& aChildArray);
|
2010-05-11 01:12:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Most of the implementation of the nsINode InsertChildAt method.
|
|
|
|
* Should only be called on document, element, and document fragment
|
|
|
|
* nodes. The aChildArray passed in should be the one for |this|.
|
|
|
|
*
|
|
|
|
* @param aKid The child to insert.
|
|
|
|
* @param aIndex The index to insert at.
|
|
|
|
* @param aNotify Whether to notify.
|
|
|
|
* @param aChildArray The child array to work with
|
|
|
|
*/
|
2012-08-22 15:56:38 +00:00
|
|
|
nsresult doInsertChildAt(nsIContent* aKid, uint32_t aIndex,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aNotify, nsAttrAndChildArray& aChildArray);
|
2010-05-11 01:12:34 +00:00
|
|
|
|
2013-12-16 18:06:36 +00:00
|
|
|
/**
|
|
|
|
* Parse the given selector string into an nsCSSSelectorList.
|
|
|
|
*
|
|
|
|
* A null return value with a non-failing aRv means the string only
|
|
|
|
* contained pseudo-element selectors.
|
|
|
|
*
|
|
|
|
* A failing aRv means the string was not a valid selector.
|
|
|
|
*/
|
|
|
|
nsCSSSelectorList* ParseSelectorList(const nsAString& aSelectorString,
|
|
|
|
mozilla::ErrorResult& aRv);
|
|
|
|
|
2011-10-10 16:21:48 +00:00
|
|
|
public:
|
2011-08-24 19:49:25 +00:00
|
|
|
/* Event stuff that documents and elements share. This needs to be
|
|
|
|
NS_IMETHOD because some subclasses implement DOM methods with
|
|
|
|
this exact name and signature and then the calling convention
|
2011-09-20 02:56:45 +00:00
|
|
|
needs to match.
|
|
|
|
|
|
|
|
Note that we include DOCUMENT_ONLY_EVENT events here so that we
|
|
|
|
can forward all the document stuff to this implementation.
|
|
|
|
*/
|
2012-11-13 13:37:39 +00:00
|
|
|
#define EVENT(name_, id_, type_, struct_) \
|
|
|
|
mozilla::dom::EventHandlerNonNull* GetOn##name_(); \
|
2013-11-16 12:31:37 +00:00
|
|
|
void SetOn##name_(mozilla::dom::EventHandlerNonNull* listener);
|
2011-08-24 19:49:25 +00:00
|
|
|
#define TOUCH_EVENT EVENT
|
2011-09-20 02:56:45 +00:00
|
|
|
#define DOCUMENT_ONLY_EVENT EVENT
|
2014-04-01 11:42:12 +00:00
|
|
|
#include "mozilla/EventNameList.h"
|
2011-09-20 02:56:45 +00:00
|
|
|
#undef DOCUMENT_ONLY_EVENT
|
2011-08-24 19:49:25 +00:00
|
|
|
#undef TOUCH_EVENT
|
2013-05-27 11:50:49 +00:00
|
|
|
#undef EVENT
|
2011-08-24 19:49:25 +00:00
|
|
|
|
2011-10-10 16:21:48 +00:00
|
|
|
protected:
|
2011-08-28 14:07:24 +00:00
|
|
|
static bool Traverse(nsINode *tmp, nsCycleCollectionTraversalCallback &cb);
|
|
|
|
static void Unlink(nsINode *tmp);
|
|
|
|
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<mozilla::dom::NodeInfo> mNodeInfo;
|
2006-04-15 05:09:16 +00:00
|
|
|
|
2015-04-18 19:50:21 +00:00
|
|
|
// mParent is an owning ref most of the time, except for the case of document
|
|
|
|
// nodes, so it cannot be represented by nsCOMPtr, so mark is as
|
|
|
|
// MOZ_OWNING_REF.
|
|
|
|
nsINode* MOZ_OWNING_REF mParent;
|
2006-04-15 05:09:16 +00:00
|
|
|
|
2011-04-08 02:29:49 +00:00
|
|
|
private:
|
2017-05-09 13:41:08 +00:00
|
|
|
#ifndef BOOL_FLAGS_ON_WRAPPER_CACHE
|
2011-04-08 02:29:49 +00:00
|
|
|
// Boolean flags.
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mBoolFlags;
|
2017-05-09 13:41:08 +00:00
|
|
|
#endif
|
|
|
|
|
2011-04-08 02:29:49 +00:00
|
|
|
|
|
|
|
protected:
|
2015-04-18 20:01:51 +00:00
|
|
|
// These references are non-owning and safe, as they are managed by
|
|
|
|
// nsAttrAndChildArray.
|
|
|
|
nsIContent* MOZ_NON_OWNING_REF mNextSibling;
|
|
|
|
nsIContent* MOZ_NON_OWNING_REF mPreviousSibling;
|
2015-04-18 19:58:15 +00:00
|
|
|
// This reference is non-owning and safe, since in the case of documents,
|
|
|
|
// it is set to null when the document gets destroyed, and in the case of
|
|
|
|
// other nodes, the children keep the parents alive.
|
|
|
|
nsIContent* MOZ_NON_OWNING_REF mFirstChild;
|
2010-08-13 13:31:31 +00:00
|
|
|
|
2012-03-14 20:14:02 +00:00
|
|
|
union {
|
|
|
|
// Pointer to our primary frame. Might be null.
|
|
|
|
nsIFrame* mPrimaryFrame;
|
|
|
|
|
|
|
|
// Pointer to the root of our subtree. Might be null.
|
2015-04-18 20:05:55 +00:00
|
|
|
// This reference is non-owning and safe, since it either points to the
|
|
|
|
// object itself, or is reset by ClearSubtreeRootPointer.
|
|
|
|
nsINode* MOZ_NON_OWNING_REF mSubtreeRoot;
|
2012-03-14 20:14:02 +00:00
|
|
|
};
|
|
|
|
|
2011-04-08 02:29:49 +00:00
|
|
|
// Storage for more members that are usually not needed; allocated lazily.
|
|
|
|
nsSlots* mSlots;
|
2006-01-19 03:34:18 +00:00
|
|
|
};
|
|
|
|
|
2014-04-25 10:34:42 +00:00
|
|
|
inline nsIDOMNode* GetAsDOMNode(nsINode* aNode)
|
|
|
|
{
|
|
|
|
return aNode ? aNode->AsDOMNode() : nullptr;
|
|
|
|
}
|
|
|
|
|
2012-08-06 12:02:08 +00:00
|
|
|
// Useful inline function for getting a node given an nsIContent and an
|
|
|
|
// nsIDocument. Returns the first argument cast to nsINode if it is non-null,
|
|
|
|
// otherwise returns the second (which may be null). We use type variables
|
|
|
|
// instead of nsIContent* and nsIDocument* because the actual types must be
|
|
|
|
// known for the cast to work.
|
|
|
|
template<class C, class D>
|
|
|
|
inline nsINode* NODE_FROM(C& aContent, D& aDocument)
|
|
|
|
{
|
|
|
|
if (aContent)
|
|
|
|
return static_cast<nsINode*>(aContent);
|
|
|
|
return static_cast<nsINode*>(aDocument);
|
|
|
|
}
|
|
|
|
|
2008-01-04 11:24:41 +00:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsINode, NS_INODE_IID)
|
2006-01-19 03:34:18 +00:00
|
|
|
|
2013-09-06 06:41:42 +00:00
|
|
|
inline nsISupports*
|
|
|
|
ToSupports(nsINode* aPointer)
|
|
|
|
{
|
|
|
|
return aPointer;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline nsISupports*
|
|
|
|
ToCanonicalSupports(nsINode* aPointer)
|
|
|
|
{
|
|
|
|
return aPointer;
|
|
|
|
}
|
|
|
|
|
2013-01-02 15:55:05 +00:00
|
|
|
#define NS_FORWARD_NSIDOMNODE_TO_NSINODE_HELPER(...) \
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD GetNodeName(nsAString& aNodeName) __VA_ARGS__ override \
|
2012-10-09 12:31:24 +00:00
|
|
|
{ \
|
2013-10-11 16:28:23 +00:00
|
|
|
aNodeName = nsINode::NodeName(); \
|
2012-10-09 12:31:24 +00:00
|
|
|
return NS_OK; \
|
|
|
|
} \
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD GetNodeValue(nsAString& aNodeValue) __VA_ARGS__ override \
|
2012-10-09 12:31:24 +00:00
|
|
|
{ \
|
|
|
|
nsINode::GetNodeValue(aNodeValue); \
|
|
|
|
return NS_OK; \
|
|
|
|
} \
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD SetNodeValue(const nsAString& aNodeValue) __VA_ARGS__ override \
|
2012-10-09 12:31:24 +00:00
|
|
|
{ \
|
|
|
|
mozilla::ErrorResult rv; \
|
|
|
|
nsINode::SetNodeValue(aNodeValue, rv); \
|
2015-04-27 13:18:51 +00:00
|
|
|
return rv.StealNSResult(); \
|
2012-10-09 12:31:24 +00:00
|
|
|
} \
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD GetNodeType(uint16_t* aNodeType) __VA_ARGS__ override \
|
2012-10-09 12:31:24 +00:00
|
|
|
{ \
|
|
|
|
*aNodeType = nsINode::NodeType(); \
|
|
|
|
return NS_OK; \
|
|
|
|
} \
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD GetParentNode(nsIDOMNode** aParentNode) __VA_ARGS__ override \
|
2012-10-09 12:31:24 +00:00
|
|
|
{ \
|
|
|
|
return nsINode::GetParentNode(aParentNode); \
|
|
|
|
} \
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD GetChildNodes(nsIDOMNodeList** aChildNodes) __VA_ARGS__ override \
|
2012-10-09 12:31:24 +00:00
|
|
|
{ \
|
|
|
|
return nsINode::GetChildNodes(aChildNodes); \
|
|
|
|
} \
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD GetFirstChild(nsIDOMNode** aFirstChild) __VA_ARGS__ override \
|
2012-10-09 12:31:24 +00:00
|
|
|
{ \
|
|
|
|
return nsINode::GetFirstChild(aFirstChild); \
|
|
|
|
} \
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD GetLastChild(nsIDOMNode** aLastChild) __VA_ARGS__ override \
|
2012-10-09 12:31:24 +00:00
|
|
|
{ \
|
|
|
|
return nsINode::GetLastChild(aLastChild); \
|
|
|
|
} \
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD GetPreviousSibling(nsIDOMNode** aPreviousSibling) __VA_ARGS__ override \
|
2012-10-09 12:31:24 +00:00
|
|
|
{ \
|
|
|
|
return nsINode::GetPreviousSibling(aPreviousSibling); \
|
|
|
|
} \
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD GetNextSibling(nsIDOMNode** aNextSibling) __VA_ARGS__ override \
|
2012-10-09 12:31:24 +00:00
|
|
|
{ \
|
|
|
|
return nsINode::GetNextSibling(aNextSibling); \
|
|
|
|
} \
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD GetOwnerDocument(nsIDOMDocument** aOwnerDocument) __VA_ARGS__ override \
|
2012-10-09 12:31:24 +00:00
|
|
|
{ \
|
|
|
|
return nsINode::GetOwnerDocument(aOwnerDocument); \
|
|
|
|
} \
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aResult) __VA_ARGS__ override \
|
2012-10-09 12:31:24 +00:00
|
|
|
{ \
|
|
|
|
return nsINode::RemoveChild(aOldChild, aResult); \
|
|
|
|
} \
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD HasChildNodes(bool* aResult) __VA_ARGS__ override \
|
2012-10-09 12:31:24 +00:00
|
|
|
{ \
|
|
|
|
*aResult = nsINode::HasChildNodes(); \
|
|
|
|
return NS_OK; \
|
|
|
|
} \
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD CloneNode(bool aDeep, uint8_t aArgc, nsIDOMNode** aResult) __VA_ARGS__ override \
|
2012-10-09 12:31:24 +00:00
|
|
|
{ \
|
|
|
|
if (aArgc == 0) { \
|
|
|
|
aDeep = true; \
|
|
|
|
} \
|
|
|
|
mozilla::ErrorResult rv; \
|
|
|
|
nsCOMPtr<nsINode> clone = nsINode::CloneNode(aDeep, rv); \
|
|
|
|
if (rv.Failed()) { \
|
2015-04-27 13:18:51 +00:00
|
|
|
return rv.StealNSResult(); \
|
2012-10-09 12:31:24 +00:00
|
|
|
} \
|
2014-03-15 19:00:15 +00:00
|
|
|
*aResult = clone.forget().take()->AsDOMNode(); \
|
2012-10-09 12:31:24 +00:00
|
|
|
return NS_OK; \
|
|
|
|
} \
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD GetNamespaceURI(nsAString& aNamespaceURI) __VA_ARGS__ override \
|
2012-10-09 12:31:24 +00:00
|
|
|
{ \
|
2013-01-29 22:53:52 +00:00
|
|
|
nsINode::GetNamespaceURI(aNamespaceURI); \
|
|
|
|
return NS_OK; \
|
2012-10-09 12:31:24 +00:00
|
|
|
} \
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD GetPrefix(nsAString& aPrefix) __VA_ARGS__ override \
|
2012-10-09 12:31:24 +00:00
|
|
|
{ \
|
|
|
|
nsINode::GetPrefix(aPrefix); \
|
|
|
|
return NS_OK; \
|
|
|
|
} \
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD GetLocalName(nsAString& aLocalName) __VA_ARGS__ override \
|
2012-10-09 12:31:24 +00:00
|
|
|
{ \
|
2013-10-11 16:28:23 +00:00
|
|
|
aLocalName = nsINode::LocalName(); \
|
2012-10-09 12:31:24 +00:00
|
|
|
return NS_OK; \
|
2014-11-13 21:32:24 +00:00
|
|
|
} \
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD GetTextContent(nsAString& aTextContent) __VA_ARGS__ override \
|
2012-10-09 12:31:24 +00:00
|
|
|
{ \
|
2014-08-05 10:10:00 +00:00
|
|
|
mozilla::ErrorResult rv; \
|
|
|
|
nsINode::GetTextContent(aTextContent, rv); \
|
2015-04-27 13:18:51 +00:00
|
|
|
return rv.StealNSResult(); \
|
2012-10-09 12:31:24 +00:00
|
|
|
} \
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD SetTextContent(const nsAString& aTextContent) __VA_ARGS__ override \
|
2012-10-09 12:31:24 +00:00
|
|
|
{ \
|
|
|
|
mozilla::ErrorResult rv; \
|
|
|
|
nsINode::SetTextContent(aTextContent, rv); \
|
2015-04-27 13:18:51 +00:00
|
|
|
return rv.StealNSResult(); \
|
2012-10-09 12:31:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define NS_FORWARD_NSIDOMNODE_TO_NSINODE \
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_FORWARD_NSIDOMNODE_TO_NSINODE_HELPER(final)
|
2012-10-09 12:31:24 +00:00
|
|
|
|
|
|
|
#define NS_FORWARD_NSIDOMNODE_TO_NSINODE_OVERRIDABLE \
|
|
|
|
NS_FORWARD_NSIDOMNODE_TO_NSINODE_HELPER()
|
2008-11-13 16:54:52 +00:00
|
|
|
|
2006-01-19 03:34:18 +00:00
|
|
|
#endif /* nsINode_h___ */
|