2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2006-01-19 06:34:18 +03:00
|
|
|
|
|
|
|
#ifndef nsINode_h___
|
|
|
|
#define nsINode_h___
|
|
|
|
|
2012-10-26 17:32:10 +04:00
|
|
|
#include "mozilla/Likely.h"
|
2012-08-06 16:02:08 +04:00
|
|
|
#include "nsCOMPtr.h" // for member, local
|
|
|
|
#include "nsGkAtoms.h" // for nsGkAtoms::baseURIProperty
|
2012-10-09 16:31:24 +04:00
|
|
|
#include "nsIDOMNode.h"
|
2014-06-20 06:01:40 +04:00
|
|
|
#include "mozilla/dom/NodeInfo.h" // member (in nsCOMPtr)
|
2012-08-06 16:02:08 +04: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-30 01:18:25 +04:00
|
|
|
#include "mozilla/ErrorResult.h"
|
2013-06-23 16:03:39 +04:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2012-12-07 05:39:51 +04:00
|
|
|
#include "mozilla/dom/EventTarget.h" // for base class
|
2013-08-28 06:59:14 +04:00
|
|
|
#include "js/TypeDecls.h" // for Handle, Value, JSObject, JSContext
|
2013-10-11 20:28:23 +04:00
|
|
|
#include "mozilla/dom/DOMString.h"
|
2014-03-19 20:35:45 +04:00
|
|
|
#include "mozilla/dom/BindingDeclarations.h"
|
2015-07-08 22:58:07 +03:00
|
|
|
#include <iosfwd>
|
2006-01-19 06:34:18 +03:00
|
|
|
|
2011-11-03 19:57:30 +04:00
|
|
|
// Including 'windows.h' will #define GetClassInfo to something else.
|
|
|
|
#ifdef XP_WIN
|
|
|
|
#ifdef GetClassInfo
|
|
|
|
#undef GetClassInfo
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2012-08-06 16:02:08 +04:00
|
|
|
class nsAttrAndChildArray;
|
|
|
|
class nsChildContentList;
|
2014-06-19 04:57:51 +04:00
|
|
|
struct nsCSSSelectorList;
|
2012-10-09 16:31:24 +04:00
|
|
|
class nsDOMAttributeMap;
|
2015-03-14 08:34:40 +03:00
|
|
|
class nsIAnimationObserver;
|
2006-01-19 06:34:18 +03:00
|
|
|
class nsIContent;
|
|
|
|
class nsIDocument;
|
2011-09-12 02:45:39 +04:00
|
|
|
class nsIDOMElement;
|
2009-01-02 20:00:18 +03:00
|
|
|
class nsIDOMNodeList;
|
2012-08-06 16:02:08 +04:00
|
|
|
class nsIEditor;
|
|
|
|
class nsIFrame;
|
|
|
|
class nsIMutationObserver;
|
2015-04-17 04:39:13 +03:00
|
|
|
class nsINode;
|
2015-05-19 13:33:00 +03:00
|
|
|
class nsINodeList;
|
2008-02-20 10:40:04 +03:00
|
|
|
class nsIPresShell;
|
2006-02-02 23:02:34 +03:00
|
|
|
class nsIPrincipal;
|
2012-08-06 16:02:08 +04:00
|
|
|
class nsIURI;
|
2006-11-11 04:43:11 +03:00
|
|
|
class nsNodeSupportsWeakRefTearoff;
|
2012-08-06 16:02:08 +04:00
|
|
|
class nsNodeWeakReference;
|
2013-09-11 23:43:01 +04:00
|
|
|
class nsDOMMutationObserver;
|
2006-05-15 11:03:15 +04:00
|
|
|
|
2010-04-30 17:12:05 +04:00
|
|
|
namespace mozilla {
|
2014-03-17 10:56:53 +04:00
|
|
|
class EventListenerManager;
|
2010-04-30 17:12:05 +04:00
|
|
|
namespace dom {
|
2012-11-30 20:04:11 +04:00
|
|
|
/**
|
|
|
|
* @return true if aChar is what the DOM spec defines as 'space character'.
|
|
|
|
* http://dom.spec.whatwg.org/#space-character
|
|
|
|
*/
|
2014-01-04 19:02:17 +04:00
|
|
|
inline bool IsSpaceCharacter(char16_t aChar) {
|
2012-11-30 20:04:11 +04: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';
|
|
|
|
}
|
2014-03-12 05:11:38 +04:00
|
|
|
struct BoxQuadOptions;
|
2014-03-12 05:11:39 +04:00
|
|
|
struct ConvertCoordinateOptions;
|
|
|
|
class DOMPoint;
|
2014-03-12 05:11:38 +04:00
|
|
|
class DOMQuad;
|
2014-03-12 05:11:39 +04:00
|
|
|
class DOMRectReadOnly;
|
|
|
|
class Element;
|
2012-10-16 15:51:00 +04:00
|
|
|
class EventHandlerNonNull;
|
2012-10-09 16:31:24 +04:00
|
|
|
template<typename T> class Optional;
|
2014-08-13 15:53:32 +04:00
|
|
|
class Text;
|
2014-03-12 05:11:39 +04:00
|
|
|
class TextOrElementOrDocument;
|
|
|
|
struct DOMPointInit;
|
2010-04-30 17:12:05 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2014-07-17 07:10:10 +04:00
|
|
|
#define NODE_FLAG_BIT(n_) \
|
|
|
|
(nsWrapperCache::FlagsType(1U) << (WRAPPER_CACHE_FLAGS_BITS_USED + (n_)))
|
2012-10-02 04:52:06 +04:00
|
|
|
|
2007-07-11 02:49:42 +04:00
|
|
|
enum {
|
2012-02-27 18:03:15 +04:00
|
|
|
// This bit will be set if the node has a listener manager.
|
2012-10-02 04:52:06 +04:00
|
|
|
NODE_HAS_LISTENERMANAGER = NODE_FLAG_BIT(0),
|
2006-05-15 11:03:15 +04:00
|
|
|
|
2007-07-11 02:49:42 +04:00
|
|
|
// Whether this node has had any properties set on it
|
2012-10-02 04:52:06 +04:00
|
|
|
NODE_HAS_PROPERTIES = NODE_FLAG_BIT(1),
|
2006-05-15 11:03:15 +04:00
|
|
|
|
2009-02-24 21:39:09 +03: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-11 02:49:42 +04:00
|
|
|
// NOTE: Should only be used on nsIContent nodes
|
2013-09-24 23:28:32 +04:00
|
|
|
NODE_IS_ANONYMOUS_ROOT = NODE_FLAG_BIT(2),
|
2009-02-24 21:39:09 +03: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 23:32:38 +04:00
|
|
|
NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE = NODE_FLAG_BIT(3),
|
2006-08-03 12:57:02 +04:00
|
|
|
|
2009-02-24 21:39:09 +03: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 04:52:06 +04:00
|
|
|
NODE_IS_NATIVE_ANONYMOUS_ROOT = NODE_FLAG_BIT(4),
|
2009-02-24 21:39:09 +03:00
|
|
|
|
2007-07-11 02:49:42 +04: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 04:52:06 +04:00
|
|
|
NODE_FORCE_XBL_BINDINGS = NODE_FLAG_BIT(5),
|
2007-05-11 00:21:12 +04:00
|
|
|
|
2007-07-11 02:49:42 +04:00
|
|
|
// Whether a binding manager may have a pointer to this
|
2012-10-02 04:52:06 +04:00
|
|
|
NODE_MAY_BE_IN_BINDING_MNGR = NODE_FLAG_BIT(6),
|
2007-05-11 22:34:12 +04:00
|
|
|
|
2012-10-02 04:52:06 +04:00
|
|
|
NODE_IS_EDITABLE = NODE_FLAG_BIT(7),
|
2007-06-28 06:48:16 +04:00
|
|
|
|
2008-09-11 07:22:20 +04:00
|
|
|
// For all Element nodes, NODE_MAY_HAVE_CLASS is guaranteed to be set if the
|
|
|
|
// node in fact has a class, but may be set even if it doesn't.
|
2012-10-02 04:52:06 +04:00
|
|
|
NODE_MAY_HAVE_CLASS = NODE_FLAG_BIT(8),
|
2007-09-18 12:38:24 +04:00
|
|
|
|
2013-12-02 14:26:11 +04:00
|
|
|
// Whether the node participates in a shadow tree.
|
|
|
|
NODE_IS_IN_SHADOW_TREE = NODE_FLAG_BIT(9),
|
|
|
|
|
2008-02-19 09:17:07 +03:00
|
|
|
// Node has an :empty or :-moz-only-whitespace selector
|
2012-10-02 04:52:06 +04:00
|
|
|
NODE_HAS_EMPTY_SELECTOR = NODE_FLAG_BIT(10),
|
2008-02-19 09:17:07 +03: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 04:52:06 +04:00
|
|
|
NODE_HAS_SLOW_SELECTOR = NODE_FLAG_BIT(11),
|
2008-02-19 09:17:07 +03: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 04:52:06 +04:00
|
|
|
NODE_HAS_EDGE_CHILD_SELECTOR = NODE_FLAG_BIT(12),
|
2008-02-19 09:17:07 +03:00
|
|
|
|
|
|
|
// A child of the node has a selector such that any insertion or
|
2010-05-15 09:01:46 +04: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 04:52:06 +04:00
|
|
|
NODE_HAS_SLOW_SELECTOR_LATER_SIBLINGS = NODE_FLAG_BIT(13),
|
2008-02-19 09:17:07 +03:00
|
|
|
|
2012-10-02 04:52:06 +04: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 09:17:07 +03:00
|
|
|
|
2010-01-18 12:26:28 +03:00
|
|
|
// This node needs to go through frame construction to get a frame (or
|
|
|
|
// undisplayed entry).
|
2014-07-25 08:35:33 +04:00
|
|
|
NODE_NEEDS_FRAME = NODE_FLAG_BIT(14),
|
2010-01-18 12:26:28 +03: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 08:35:33 +04:00
|
|
|
NODE_DESCENDANTS_NEED_FRAMES = NODE_FLAG_BIT(15),
|
2010-01-18 12:26:28 +03:00
|
|
|
|
2010-06-04 05:08:57 +04:00
|
|
|
// Set if the node has the accesskey attribute set.
|
2014-07-25 08:35:33 +04:00
|
|
|
NODE_HAS_ACCESSKEY = NODE_FLAG_BIT(16),
|
2010-06-04 05:09:20 +04:00
|
|
|
|
2012-04-17 08:03:10 +04:00
|
|
|
// Set if the node has right-to-left directionality
|
2014-07-25 08:35:33 +04:00
|
|
|
NODE_HAS_DIRECTION_RTL = NODE_FLAG_BIT(17),
|
2012-04-17 08:03:10 +04:00
|
|
|
|
|
|
|
// Set if the node has left-to-right directionality
|
2014-07-25 08:35:33 +04:00
|
|
|
NODE_HAS_DIRECTION_LTR = NODE_FLAG_BIT(18),
|
2012-04-17 08:03:10 +04:00
|
|
|
|
2012-10-02 04:52:06 +04:00
|
|
|
NODE_ALL_DIRECTION_FLAGS = NODE_HAS_DIRECTION_LTR |
|
|
|
|
NODE_HAS_DIRECTION_RTL,
|
2012-04-17 08:03:10 +04:00
|
|
|
|
2014-07-25 08:35:33 +04:00
|
|
|
NODE_CHROME_ONLY_ACCESS = NODE_FLAG_BIT(19),
|
2012-10-10 23:04:42 +04:00
|
|
|
|
2014-07-25 08:35:33 +04:00
|
|
|
NODE_IS_ROOT_OF_CHROME_ONLY_ACCESS = NODE_FLAG_BIT(20),
|
2012-10-10 23:04:42 +04:00
|
|
|
|
2007-07-11 02:49:42 +04:00
|
|
|
// Remaining bits are node type specific.
|
2014-07-25 08:35:33 +04:00
|
|
|
NODE_TYPE_SPECIFIC_BITS_OFFSET = 21
|
2007-07-11 02:49:42 +04:00
|
|
|
};
|
|
|
|
|
2013-06-08 12:54:59 +04:00
|
|
|
// Make sure we have space for our bits
|
2013-11-11 12:03:59 +04:00
|
|
|
#define ASSERT_NODE_FLAGS_SPACE(n) \
|
2014-06-19 04:07:26 +04:00
|
|
|
static_assert(WRAPPER_CACHE_FLAGS_BITS_USED + (n) <= \
|
|
|
|
sizeof(nsWrapperCache::FlagsType) * 8, \
|
2013-11-11 12:03:59 +04:00
|
|
|
"Not enough space for our bits")
|
2013-06-08 12:54:59 +04:00
|
|
|
ASSERT_NODE_FLAGS_SPACE(NODE_TYPE_SPECIFIC_BITS_OFFSET);
|
|
|
|
|
2009-04-10 05:36:41 +04: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 16:19:50 +04:00
|
|
|
* have occurred.
|
2009-04-10 05:36:41 +04:00
|
|
|
*/
|
|
|
|
class nsMutationGuard {
|
|
|
|
public:
|
|
|
|
nsMutationGuard()
|
|
|
|
{
|
2014-08-02 00:30:58 +04:00
|
|
|
mStartingGeneration = sGeneration;
|
2009-04-10 05:36:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2010-05-13 16:19:50 +04:00
|
|
|
* Returns true if any unexpected mutations have occurred. You can pass in
|
2009-04-10 05:36:41 +04:00
|
|
|
* an 8-bit ignore count to ignore a number of expected mutations.
|
2014-08-02 00:30:58 +04: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 05:36:41 +04:00
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
bool Mutated(uint8_t aIgnoreCount)
|
2009-04-10 05:36:41 +04:00
|
|
|
{
|
2014-08-02 00:30:58 +04:00
|
|
|
return (sGeneration - mStartingGeneration) > aIgnoreCount;
|
2009-04-10 05:36:41 +04: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-02 00:30:58 +04:00
|
|
|
sGeneration++;
|
2009-04-10 05:36:41 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2014-08-02 00:30:58 +04:00
|
|
|
// This is the value sGeneration had when the guard was constructed.
|
|
|
|
uint64_t mStartingGeneration;
|
2014-03-05 03:39:42 +04:00
|
|
|
|
2014-08-02 00:30:58 +04:00
|
|
|
// This value is incremented on every mutation, for the life of the process.
|
|
|
|
static uint64_t sGeneration;
|
2009-04-10 05:36:41 +04:00
|
|
|
};
|
2006-07-02 11:23:10 +04:00
|
|
|
|
2014-03-05 03:39:42 +04: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 19:28:04 +03:00
|
|
|
virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const override;
|
2014-03-05 03:39:42 +04:00
|
|
|
|
2010-04-23 06:41:38 +04:00
|
|
|
// Categories of node properties
|
|
|
|
// 0 is global.
|
|
|
|
#define DOM_USER_DATA 1
|
2014-09-11 14:22:30 +04:00
|
|
|
#define SMIL_MAPPED_ATTR_ANIMVAL 2
|
2010-04-23 06:41:38 +04:00
|
|
|
|
2006-01-19 06:34:18 +03:00
|
|
|
// IID for the nsINode interface
|
|
|
|
#define NS_INODE_IID \
|
2015-03-03 14:09:01 +03:00
|
|
|
{ 0xe8fdd227, 0x27da, 0x46ee, \
|
|
|
|
{ 0xbe, 0xf3, 0x1a, 0xef, 0x5a, 0x8f, 0xc5, 0xb4 } }
|
2010-01-18 12:26:28 +03:00
|
|
|
|
2006-01-19 06:34:18 +03: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 05:39:51 +04:00
|
|
|
class nsINode : public mozilla::dom::EventTarget
|
2008-11-13 19:54:52 +03:00
|
|
|
{
|
2006-01-19 06:34:18 +03:00
|
|
|
public:
|
2014-03-12 05:11:38 +04:00
|
|
|
typedef mozilla::dom::BoxQuadOptions BoxQuadOptions;
|
2014-03-12 05:11:39 +04:00
|
|
|
typedef mozilla::dom::ConvertCoordinateOptions ConvertCoordinateOptions;
|
|
|
|
typedef mozilla::dom::DOMPoint DOMPoint;
|
|
|
|
typedef mozilla::dom::DOMPointInit DOMPointInit;
|
2014-03-12 05:11:38 +04:00
|
|
|
typedef mozilla::dom::DOMQuad DOMQuad;
|
2014-03-12 05:11:39 +04:00
|
|
|
typedef mozilla::dom::DOMRectReadOnly DOMRectReadOnly;
|
|
|
|
typedef mozilla::dom::TextOrElementOrDocument TextOrElementOrDocument;
|
2014-03-12 05:11:38 +04:00
|
|
|
typedef mozilla::ErrorResult ErrorResult;
|
|
|
|
|
2008-01-04 14:24:41 +03:00
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_INODE_IID)
|
|
|
|
|
2012-02-02 01:58:01 +04: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 05:25:29 +04:00
|
|
|
// - nsGenericHTMLFrameElement: mFrameLoader (bug 672539)
|
2012-12-21 18:06:50 +04:00
|
|
|
// - HTMLBodyElement: mContentStyleRule
|
|
|
|
// - HTMLDataListElement: mOptions
|
2013-02-08 20:34:47 +04:00
|
|
|
// - HTMLFieldSetElement: mElements, mDependentElements, mFirstLegend
|
2013-06-19 18:24:37 +04:00
|
|
|
// - HTMLFormElement: many!
|
2012-12-21 18:06:50 +04:00
|
|
|
// - HTMLFrameSetElement: mRowSpecs, mColSpecs
|
2013-03-28 23:41:32 +04:00
|
|
|
// - HTMLInputElement: mInputData, mFiles, mFileList, mStaticDocfileList
|
2012-02-02 01:58:01 +04:00
|
|
|
// - nsHTMLMapElement: mAreas
|
2013-03-19 16:23:54 +04:00
|
|
|
// - HTMLMediaElement: many!
|
2012-02-02 01:58:01 +04: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 05:13:39 +03:00
|
|
|
virtual size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
2012-02-02 01:58:01 +04: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 16:03:39 +04:00
|
|
|
virtual size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const {
|
2012-02-02 01:58:01 +04:00
|
|
|
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
|
|
|
|
}
|
2011-07-11 19:23:26 +04:00
|
|
|
|
2006-07-02 11:23:10 +04:00
|
|
|
friend class nsNodeUtils;
|
2006-11-11 03:36:03 +03:00
|
|
|
friend class nsNodeWeakReference;
|
|
|
|
friend class nsNodeSupportsWeakRefTearoff;
|
2010-05-11 05:12:33 +04:00
|
|
|
friend class nsAttrAndChildArray;
|
2006-07-02 11:23:10 +04:00
|
|
|
|
2006-08-31 23:59:43 +04:00
|
|
|
#ifdef MOZILLA_INTERNAL_API
|
2014-08-05 17:19:51 +04:00
|
|
|
explicit nsINode(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
|
2010-07-23 13:49:57 +04:00
|
|
|
: mNodeInfo(aNodeInfo),
|
2012-07-30 18:20:58 +04:00
|
|
|
mParent(nullptr),
|
2012-02-20 16:54:45 +04:00
|
|
|
mBoolFlags(0),
|
2012-07-30 18:20:58 +04:00
|
|
|
mNextSibling(nullptr),
|
|
|
|
mPreviousSibling(nullptr),
|
|
|
|
mFirstChild(nullptr),
|
2015-01-07 08:39:46 +03:00
|
|
|
mSubtreeRoot(this),
|
2012-07-30 18:20:58 +04:00
|
|
|
mSlots(nullptr)
|
2006-01-19 06:34:18 +03:00
|
|
|
{
|
2012-02-15 03:13:19 +04:00
|
|
|
}
|
2006-08-31 23:59:43 +04:00
|
|
|
#endif
|
2006-05-15 11:03:15 +04:00
|
|
|
|
|
|
|
virtual ~nsINode();
|
|
|
|
|
2006-05-05 10:52:21 +04: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 17:12:06 +04:00
|
|
|
eTEXT = 1 << 3,
|
2006-05-05 10:52:21 +04:00
|
|
|
/** xml processing instructions */
|
2010-04-30 17:12:06 +04:00
|
|
|
ePROCESSING_INSTRUCTION = 1 << 4,
|
2006-05-05 10:52:21 +04:00
|
|
|
/** comment nodes */
|
2010-04-30 17:12:06 +04:00
|
|
|
eCOMMENT = 1 << 5,
|
2006-05-05 10:52:21 +04:00
|
|
|
/** form control elements */
|
2010-04-30 17:12:06 +04:00
|
|
|
eHTML_FORM_CONTROL = 1 << 6,
|
2006-05-15 23:35:12 +04:00
|
|
|
/** document fragments */
|
2011-12-08 10:32:11 +04:00
|
|
|
eDOCUMENT_FRAGMENT = 1 << 7,
|
2006-07-19 08:36:36 +04:00
|
|
|
/** data nodes (comments, PIs, text). Nodes of this type always
|
|
|
|
returns a non-null value for nsIContent::GetText() */
|
2011-12-08 10:32:11 +04:00
|
|
|
eDATA_NODE = 1 << 8,
|
2013-03-19 16:23:54 +04:00
|
|
|
/** HTMLMediaElement */
|
2011-12-08 10:32:11 +04:00
|
|
|
eMEDIA = 1 << 9,
|
2010-03-19 14:17:49 +03:00
|
|
|
/** animation elements */
|
2013-03-07 11:12:32 +04:00
|
|
|
eANIMATION = 1 << 10,
|
|
|
|
/** filter elements that implement SVGFilterPrimitiveStandardAttributes */
|
|
|
|
eFILTER = 1 << 11
|
2006-05-05 10:52:21 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2006-05-15 11:03:15 +04:00
|
|
|
* API for doing a quick check if a content is of a given
|
2009-08-25 00:02:07 +04:00
|
|
|
* type, such as Text, Document, Comment ... Use this when you can instead of
|
2006-05-05 10:52:21 +04: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 19:56:38 +04:00
|
|
|
virtual bool IsNodeOfType(uint32_t aFlags) const = 0;
|
2006-05-05 10:52:21 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual JSObject* WrapObject(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
|
2012-10-09 16:31:24 +04:00
|
|
|
|
2014-07-03 17:23:14 +04: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 16:31:24 +04: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 17:13:33 +03: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 16:31:24 +04: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 17:13:33 +03:00
|
|
|
virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) = 0;
|
2012-10-09 16:31:24 +04:00
|
|
|
|
2014-03-19 20:35:45 +04:00
|
|
|
public:
|
|
|
|
mozilla::dom::ParentObject GetParentObject() const; // Implemented in nsIDocument.h
|
|
|
|
|
2014-10-31 00:38:48 +03: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 17:12:04 +04:00
|
|
|
/**
|
|
|
|
* Return whether the node is an Element node
|
|
|
|
*/
|
2011-04-08 06:29:49 +04:00
|
|
|
bool IsElement() const {
|
|
|
|
return GetBoolFlag(NodeIsElement);
|
2010-04-30 17:12:04 +04:00
|
|
|
}
|
|
|
|
|
2010-04-30 17:12:05 +04:00
|
|
|
/**
|
|
|
|
* Return this node as an Element. Should only be used for nodes
|
2012-04-27 17:21:12 +04:00
|
|
|
* for which IsElement() is true. This is defined inline in Element.h.
|
2010-04-30 17:12:05 +04:00
|
|
|
*/
|
|
|
|
mozilla::dom::Element* AsElement();
|
2012-06-23 10:57:57 +04:00
|
|
|
const mozilla::dom::Element* AsElement() const;
|
2010-04-30 17:12:05 +04:00
|
|
|
|
2012-06-10 16:39:21 +04: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 23:32:38 +04:00
|
|
|
const nsIContent* AsContent() const
|
|
|
|
{
|
|
|
|
return const_cast<nsINode*>(this)->AsContent();
|
|
|
|
}
|
2012-06-10 16:39:21 +04:00
|
|
|
|
2014-08-13 15:53:32 +04: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 17:47:30 +04:00
|
|
|
virtual nsIDOMNode* AsDOMNode() = 0;
|
|
|
|
|
2012-01-25 11:50:07 +04:00
|
|
|
/**
|
|
|
|
* Return if this node has any children.
|
|
|
|
*/
|
|
|
|
bool HasChildren() const { return !!mFirstChild; }
|
|
|
|
|
2006-01-19 06:34:18 +03:00
|
|
|
/**
|
|
|
|
* Get the number of children
|
|
|
|
* @return the number of children
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual uint32_t GetChildCount() const = 0;
|
2006-01-19 06:34:18 +03: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 19:56:38 +04:00
|
|
|
virtual nsIContent* GetChildAt(uint32_t aIndex) const = 0;
|
2006-01-19 06:34:18 +03:00
|
|
|
|
2008-07-12 00:42:19 +04: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 17:02:03 +03:00
|
|
|
* garbage pointer. In all cases the out param will be set to the number of
|
|
|
|
* children.
|
2008-07-12 00:42:19 +04:00
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual nsIContent * const * GetChildArray(uint32_t* aChildCount) const = 0;
|
2008-07-12 00:42:19 +04:00
|
|
|
|
2006-01-19 06:34:18 +03: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 11:19:46 +04:00
|
|
|
virtual int32_t IndexOf(const nsINode* aPossibleChild) const = 0;
|
2006-01-19 06:34:18 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the "owner document" of this node. Note that this is not the same
|
|
|
|
* as the DOM ownerDocument -- that's null for Document nodes, whereas for a
|
|
|
|
* nsIDocument GetOwnerDocument returns the document itself. For nsIContent
|
|
|
|
* implementations the two are the same.
|
|
|
|
*/
|
2011-10-18 14:53:36 +04:00
|
|
|
nsIDocument *OwnerDoc() const
|
2006-01-19 06:34:18 +03:00
|
|
|
{
|
|
|
|
return mNodeInfo->GetDocument();
|
|
|
|
}
|
|
|
|
|
2012-03-15 00:14:02 +04:00
|
|
|
/**
|
|
|
|
* Return the "owner document" of this node as an nsINode*. Implemented
|
|
|
|
* in nsIDocument.h.
|
|
|
|
*/
|
2012-03-17 02:16:41 +04:00
|
|
|
nsINode *OwnerDocAsNode() const;
|
2012-03-15 00:14:02 +04:00
|
|
|
|
2006-07-08 04:30:19 +04: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 21:02:07 +04:00
|
|
|
bool IsInUncomposedDoc() const
|
2006-07-08 04:30:19 +04:00
|
|
|
{
|
2011-04-08 06:29:49 +04:00
|
|
|
return GetBoolFlag(IsInDocument);
|
2006-07-08 04:30:19 +04:00
|
|
|
}
|
|
|
|
|
2014-07-03 21:02:07 +04:00
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
*/
|
|
|
|
bool IsInDoc() const
|
|
|
|
{
|
|
|
|
return IsInUncomposedDoc();
|
|
|
|
}
|
|
|
|
|
2006-07-08 04:30:19 +04: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 21:02:07 +04:00
|
|
|
|
|
|
|
nsIDocument* GetUncomposedDoc() const
|
|
|
|
{
|
|
|
|
return IsInUncomposedDoc() ? OwnerDoc() : nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
*/
|
2006-07-08 04:30:19 +04:00
|
|
|
nsIDocument *GetCurrentDoc() const
|
|
|
|
{
|
2014-07-03 21:02:07 +04:00
|
|
|
return GetUncomposedDoc();
|
2006-07-08 04:30:19 +04:00
|
|
|
}
|
|
|
|
|
2014-06-07 12:42:53 +04:00
|
|
|
/**
|
2015-02-09 21:01:23 +03: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 12:42:53 +04:00
|
|
|
*/
|
2014-07-03 21:02:07 +04:00
|
|
|
nsIDocument* GetComposedDoc() const
|
|
|
|
{
|
|
|
|
return IsInShadowTree() ?
|
|
|
|
GetComposedDocInternal() : GetUncomposedDoc();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @deprecated
|
|
|
|
*/
|
2014-06-07 12:42:53 +04:00
|
|
|
nsIDocument* GetCrossShadowCurrentDoc() const
|
|
|
|
{
|
2014-07-03 21:02:07 +04:00
|
|
|
return GetComposedDoc();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if GetComposedDoc() would return a non-null value.
|
|
|
|
*/
|
|
|
|
bool IsInComposedDoc() const
|
|
|
|
{
|
|
|
|
return IsInUncomposedDoc() || (IsInShadowTree() && GetComposedDocInternal());
|
2014-06-07 12:42:53 +04:00
|
|
|
}
|
|
|
|
|
2011-06-14 11:56:49 +04:00
|
|
|
/**
|
|
|
|
* The values returned by this function are the ones defined for
|
|
|
|
* nsIDOMNode.nodeType
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
uint16_t NodeType() const
|
2011-06-14 11:56:49 +04:00
|
|
|
{
|
|
|
|
return mNodeInfo->NodeType();
|
|
|
|
}
|
|
|
|
const nsString& NodeName() const
|
|
|
|
{
|
|
|
|
return mNodeInfo->NodeName();
|
|
|
|
}
|
|
|
|
const nsString& LocalName() const
|
|
|
|
{
|
|
|
|
return mNodeInfo->LocalName();
|
|
|
|
}
|
2010-03-17 18:06:19 +03:00
|
|
|
|
2015-03-03 14:08:59 +03: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 22:58:07 +03: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 14:08:59 +03: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 06:34:18 +03: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 17:12:05 +04:00
|
|
|
* nsIDocument::GetRootElement() first if you're not sure. Apart from this
|
2006-01-19 06:34:18 +03: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 19:56:38 +04:00
|
|
|
virtual nsresult InsertChildAt(nsIContent* aKid, uint32_t aIndex,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aNotify) = 0;
|
2006-01-19 06:34:18 +03: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 17:12:05 +04:00
|
|
|
* nsIDocument::GetRootElement() first if you're not sure. Apart from this
|
2006-01-19 06:34:18 +03: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 10:19:26 +04:00
|
|
|
nsresult AppendChildTo(nsIContent* aKid, bool aNotify)
|
2006-08-01 02:38:07 +04:00
|
|
|
{
|
|
|
|
return InsertChildAt(aKid, GetChildCount(), aNotify);
|
|
|
|
}
|
2006-01-19 06:34:18 +03: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 19:56:38 +04:00
|
|
|
virtual void RemoveChildAt(uint32_t aIndex, bool aNotify) = 0;
|
2006-01-19 06:34:18 +03:00
|
|
|
|
2006-01-25 23:49:56 +03: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 17:28:14 +04:00
|
|
|
void* GetProperty(nsIAtom *aPropertyName,
|
2012-07-30 18:20:58 +04:00
|
|
|
nsresult *aStatus = nullptr) const
|
2006-06-02 17:28:14 +04: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).
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual void* GetProperty(uint16_t aCategory,
|
2006-06-02 17:28:14 +04:00
|
|
|
nsIAtom *aPropertyName,
|
2012-07-30 18:20:58 +04:00
|
|
|
nsresult *aStatus = nullptr) const;
|
2006-01-25 23:49:56 +03: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 18:59:28 +04:00
|
|
|
* @param aTransfer if true the property will not be deleted when the
|
|
|
|
* ownerDocument of the node changes, if false it
|
2006-09-16 21:15:38 +04:00
|
|
|
* will be deleted.
|
2006-01-25 23:49:56 +03:00
|
|
|
*
|
|
|
|
* @return NS_PROPTABLE_PROP_OVERWRITTEN (success value) if the property
|
|
|
|
* was already set
|
|
|
|
* @throws NS_ERROR_OUT_OF_MEMORY if that occurs
|
|
|
|
*/
|
2006-06-02 17:28:14 +04:00
|
|
|
nsresult SetProperty(nsIAtom *aPropertyName,
|
|
|
|
void *aValue,
|
2012-07-30 18:20:58 +04:00
|
|
|
NSPropertyDtorFunc aDtor = nullptr,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aTransfer = false)
|
2006-06-02 17:28:14 +04:00
|
|
|
{
|
2006-09-16 21:15:38 +04:00
|
|
|
return SetProperty(0, aPropertyName, aValue, aDtor, aTransfer);
|
2006-06-02 17:28:14 +04: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 18:59:28 +04:00
|
|
|
* @param aTransfer if true the property will not be deleted when the
|
|
|
|
* ownerDocument of the node changes, if false it
|
2006-09-16 21:15:38 +04:00
|
|
|
* will be deleted.
|
2006-06-02 17:28:14 +04: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
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual nsresult SetProperty(uint16_t aCategory,
|
2006-06-02 17:28:14 +04:00
|
|
|
nsIAtom *aPropertyName,
|
2006-01-25 23:49:56 +03:00
|
|
|
void *aValue,
|
2012-07-30 18:20:58 +04:00
|
|
|
NSPropertyDtorFunc aDtor = nullptr,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aTransfer = false,
|
2012-07-30 18:20:58 +04:00
|
|
|
void **aOldValue = nullptr);
|
2006-06-02 17:28:14 +04:00
|
|
|
|
2014-03-25 17:25:47 +04: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 17:28:14 +04: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 18:41:00 +04:00
|
|
|
void DeleteProperty(nsIAtom *aPropertyName)
|
2006-06-02 17:28:14 +04:00
|
|
|
{
|
2010-05-20 18:41:00 +04:00
|
|
|
DeleteProperty(0, aPropertyName);
|
2006-06-02 17:28:14 +04:00
|
|
|
}
|
2006-01-25 23:49:56 +03: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 17:28:14 +04:00
|
|
|
* @param aCategory category of property to destroy.
|
2006-01-25 23:49:56 +03:00
|
|
|
* @param aPropertyName name of property to destroy.
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual void DeleteProperty(uint16_t aCategory, nsIAtom *aPropertyName);
|
2006-06-02 17:28:14 +04: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 18:20:58 +04:00
|
|
|
nsresult *aStatus = nullptr)
|
2006-06-02 17:28:14 +04:00
|
|
|
{
|
|
|
|
return UnsetProperty(0, aPropertyName, aStatus);
|
|
|
|
}
|
2006-01-25 23:49:56 +03: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 17:28:14 +04:00
|
|
|
* destroy the value after that point.
|
2006-01-25 23:49:56 +03:00
|
|
|
*
|
2006-06-02 17:28:14 +04:00
|
|
|
* @param aCategory category of property to unset.
|
2006-01-25 23:49:56 +03: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).
|
|
|
|
*/
|
2012-08-22 19:56:38 +04:00
|
|
|
virtual void* UnsetProperty(uint16_t aCategory,
|
2006-06-02 17:28:14 +04:00
|
|
|
nsIAtom *aPropertyName,
|
2012-07-30 18:20:58 +04:00
|
|
|
nsresult *aStatus = nullptr);
|
2006-02-02 23:02:34 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool HasProperties() const
|
2006-06-02 17:28:14 +04:00
|
|
|
{
|
|
|
|
return HasFlag(NODE_HAS_PROPERTIES);
|
|
|
|
}
|
|
|
|
|
2006-02-02 23:02:34 +03:00
|
|
|
/**
|
2006-04-27 22:21:11 +04:00
|
|
|
* Return the principal of this node. This is guaranteed to never be a null
|
|
|
|
* pointer.
|
2006-02-02 23:02:34 +03:00
|
|
|
*/
|
2006-04-27 22:21:11 +04:00
|
|
|
nsIPrincipal* NodePrincipal() const {
|
|
|
|
return mNodeInfo->NodeInfoManager()->DocumentPrincipal();
|
2006-02-02 23:02:34 +03:00
|
|
|
}
|
2006-01-25 23:49:56 +03:00
|
|
|
|
2006-04-15 09:09:16 +04: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 06:29:49 +04:00
|
|
|
nsIContent* GetParent() const {
|
2012-10-26 17:32:10 +04:00
|
|
|
return MOZ_LIKELY(GetBoolFlag(ParentIsContent)) ?
|
2012-07-30 18:20:58 +04:00
|
|
|
reinterpret_cast<nsIContent*>(mParent) : nullptr;
|
2006-04-15 09:09:16 +04: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 16:31:24 +04:00
|
|
|
nsINode* GetParentNode() const
|
2006-04-15 09:09:16 +04:00
|
|
|
{
|
2011-04-08 06:29:49 +04:00
|
|
|
return mParent;
|
2006-04-15 09:09:16 +04:00
|
|
|
}
|
2011-09-12 02:45:39 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the parent nsINode for this node if it is an Element.
|
|
|
|
* @return the parent node
|
|
|
|
*/
|
2013-01-11 12:43:01 +04:00
|
|
|
mozilla::dom::Element* GetParentElement() const
|
2011-09-12 02:45:39 +04:00
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
return mParent && mParent->IsElement() ? mParent->AsElement() : nullptr;
|
2011-09-12 02:45:39 +04:00
|
|
|
}
|
2006-04-15 09:09:16 +04:00
|
|
|
|
2014-06-06 09:22:55 +04:00
|
|
|
/**
|
|
|
|
* Get the parent Element of this node, traversing over a ShadowRoot
|
|
|
|
* to its host if necessary.
|
|
|
|
*/
|
|
|
|
mozilla::dom::Element* GetParentElementCrossingShadowRoot() const;
|
|
|
|
|
2012-03-15 00:14:02 +04: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 12:42:53 +04:00
|
|
|
nsINode* SubtreeRoot() const;
|
2012-03-15 00:14:02 +04:00
|
|
|
|
2011-06-24 06:17:58 +04:00
|
|
|
/**
|
2011-06-24 06:17:59 +04:00
|
|
|
* See nsIDOMEventTarget
|
2011-06-24 06:17:58 +04:00
|
|
|
*/
|
2011-06-24 06:17:59 +04:00
|
|
|
NS_DECL_NSIDOMEVENTTARGET
|
2013-10-23 03:32:04 +04:00
|
|
|
|
2014-03-17 10:56:53 +04:00
|
|
|
virtual mozilla::EventListenerManager*
|
2015-03-21 19:28:04 +03:00
|
|
|
GetExistingListenerManager() const override;
|
2014-03-17 10:56:53 +04:00
|
|
|
virtual mozilla::EventListenerManager*
|
2015-03-21 19:28:04 +03:00
|
|
|
GetOrCreateListenerManager() override;
|
2013-10-23 03:32:04 +04:00
|
|
|
|
2013-04-17 01:16:08 +04:00
|
|
|
using mozilla::dom::EventTarget::RemoveEventListener;
|
2011-06-28 21:59:14 +04:00
|
|
|
using nsIDOMEventTarget::AddEventListener;
|
2013-04-17 01:16:08 +04:00
|
|
|
virtual void AddEventListener(const nsAString& aType,
|
2013-09-24 04:25:17 +04:00
|
|
|
mozilla::dom::EventListener* aListener,
|
2013-04-17 01:16:08 +04:00
|
|
|
bool aUseCapture,
|
|
|
|
const mozilla::dom::Nullable<bool>& aWantsUntrusted,
|
2015-03-21 19:28:04 +03:00
|
|
|
mozilla::ErrorResult& aRv) override;
|
2011-11-25 05:09:58 +04:00
|
|
|
using nsIDOMEventTarget::AddSystemEventListener;
|
2015-05-12 22:56:39 +03:00
|
|
|
virtual nsIDOMWindow* GetOwnerGlobalForBindings() override;
|
|
|
|
virtual nsIGlobalObject* GetOwnerGlobal() const override;
|
2011-06-24 06:17:58 +04:00
|
|
|
|
2006-07-02 11:23:10 +04: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 20:57:18 +03: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 22:18:03 +04: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 08:34:40 +03:00
|
|
|
*
|
|
|
|
* For mutation observers that implement nsIAnimationObserver, use
|
|
|
|
* AddAnimationObserver instead.
|
2006-07-02 11:23:10 +04:00
|
|
|
*/
|
2010-05-05 22:18:03 +04:00
|
|
|
void AddMutationObserver(nsIMutationObserver* aMutationObserver)
|
|
|
|
{
|
2012-08-11 02:27:28 +04: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 22:18:03 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Same as above, but only adds the observer if its not observing
|
|
|
|
* the node already.
|
2015-03-14 08:34:40 +03:00
|
|
|
*
|
|
|
|
* For mutation observers that implement nsIAnimationObserver, use
|
|
|
|
* AddAnimationObserverUnlessExists instead.
|
2010-05-05 22:18:03 +04:00
|
|
|
*/
|
|
|
|
void AddMutationObserverUnlessExists(nsIMutationObserver* aMutationObserver)
|
|
|
|
{
|
2012-08-11 02:27:28 +04:00
|
|
|
nsSlots* s = Slots();
|
|
|
|
s->mMutationObservers.AppendElementUnlessExists(aMutationObserver);
|
2010-05-05 22:18:03 +04:00
|
|
|
}
|
2006-07-02 11:23:10 +04:00
|
|
|
|
2015-03-14 08:34:40 +03: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 11:23:10 +04:00
|
|
|
/**
|
|
|
|
* Removes a mutation observer.
|
|
|
|
*/
|
2010-05-05 22:18:03 +04:00
|
|
|
void RemoveMutationObserver(nsIMutationObserver* aMutationObserver)
|
|
|
|
{
|
2010-05-12 03:32:17 +04:00
|
|
|
nsSlots* s = GetExistingSlots();
|
|
|
|
if (s) {
|
|
|
|
s->mMutationObservers.RemoveElement(aMutationObserver);
|
2010-05-05 22:18:03 +04:00
|
|
|
}
|
|
|
|
}
|
2006-07-02 11:23:10 +04:00
|
|
|
|
2006-09-05 14:22:54 +04: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
|
|
|
|
*/
|
2014-06-20 06:01:40 +04:00
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const = 0;
|
2006-09-05 14:22:54 +04:00
|
|
|
|
2006-07-02 11:23:10 +04:00
|
|
|
// This class can be extended by subclasses that wish to store more
|
2006-05-15 11:03:15 +04:00
|
|
|
// information in the slots.
|
|
|
|
class nsSlots
|
|
|
|
{
|
|
|
|
public:
|
2015-05-19 13:33:00 +03:00
|
|
|
nsSlots();
|
2006-01-19 06:34:18 +03:00
|
|
|
|
2006-07-02 11:23:10 +04:00
|
|
|
// If needed we could remove the vtable pointer this dtor causes by
|
|
|
|
// putting a DestroySlots function on nsINode
|
2006-11-11 03:28:20 +03:00
|
|
|
virtual ~nsSlots();
|
2006-07-02 11:23:10 +04:00
|
|
|
|
2011-08-28 18:07:24 +04:00
|
|
|
void Traverse(nsCycleCollectionTraversalCallback &cb);
|
|
|
|
void Unlink();
|
|
|
|
|
2006-07-02 11:23:10 +04:00
|
|
|
/**
|
|
|
|
* A list of mutation observers
|
|
|
|
*/
|
2007-12-20 10:30:04 +03:00
|
|
|
nsTObserverArray<nsIMutationObserver*> mMutationObservers;
|
2006-11-11 03:28:20 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* An object implementing nsIDOMNodeList for this content (childNodes)
|
|
|
|
* @see nsIDOMNodeList
|
|
|
|
* @see nsGenericHTMLElement::GetChildNodes
|
|
|
|
*/
|
2015-04-17 04:39:13 +03:00
|
|
|
nsRefPtr<nsChildContentList> mChildNodes;
|
2006-11-11 03:36:03 +03:00
|
|
|
|
|
|
|
/**
|
2015-04-17 04:32:15 +03:00
|
|
|
* Weak reference to this node. This is cleared by the destructor of
|
|
|
|
* nsNodeWeakReference.
|
2006-11-11 03:36:03 +03:00
|
|
|
*/
|
2015-04-17 04:32:15 +03:00
|
|
|
nsNodeWeakReference* MOZ_NON_OWNING_REF mWeakReference;
|
2006-05-15 11:03:15 +04:00
|
|
|
};
|
|
|
|
|
2007-02-16 02:04:33 +03:00
|
|
|
/**
|
|
|
|
* Functions for managing flags and slots
|
|
|
|
*/
|
2006-11-04 08:45:02 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
nsSlots* DebugGetSlots()
|
|
|
|
{
|
2012-08-11 02:27:28 +04:00
|
|
|
return Slots();
|
2006-11-04 08:45:02 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-06-19 04:07:26 +04:00
|
|
|
void SetFlags(FlagsType aFlagsToSet)
|
2007-02-16 02:04:33 +03:00
|
|
|
{
|
2013-09-24 23:28:32 +04:00
|
|
|
NS_ASSERTION(!(aFlagsToSet & (NODE_IS_ANONYMOUS_ROOT |
|
2009-02-24 21:39:09 +03:00
|
|
|
NODE_IS_NATIVE_ANONYMOUS_ROOT |
|
2014-04-06 23:32:38 +04:00
|
|
|
NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE |
|
2010-01-18 12:26:28 +03:00
|
|
|
NODE_DESCENDANTS_NEED_FRAMES |
|
2012-10-10 23:04:42 +04:00
|
|
|
NODE_NEEDS_FRAME |
|
|
|
|
NODE_CHROME_ONLY_ACCESS)) ||
|
2007-02-16 02:04:33 +03:00
|
|
|
IsNodeOfType(eCONTENT),
|
|
|
|
"Flag only permitted on nsIContent nodes");
|
2013-06-08 12:54:59 +04:00
|
|
|
nsWrapperCache::SetFlags(aFlagsToSet);
|
2007-02-16 02:04:33 +03:00
|
|
|
}
|
|
|
|
|
2014-06-19 04:07:26 +04:00
|
|
|
void UnsetFlags(FlagsType aFlagsToUnset)
|
2007-02-16 02:04:33 +03:00
|
|
|
{
|
2009-02-24 21:39:09 +03:00
|
|
|
NS_ASSERTION(!(aFlagsToUnset &
|
2013-09-24 23:28:32 +04:00
|
|
|
(NODE_IS_ANONYMOUS_ROOT |
|
2014-04-06 23:32:38 +04:00
|
|
|
NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE |
|
2009-02-24 21:39:09 +03:00
|
|
|
NODE_IS_NATIVE_ANONYMOUS_ROOT)),
|
|
|
|
"Trying to unset write-only flags");
|
2013-06-08 12:54:59 +04:00
|
|
|
nsWrapperCache::UnsetFlags(aFlagsToUnset);
|
2007-02-16 02:04:33 +03:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
void SetEditableFlag(bool aEditable)
|
2007-06-28 06:48:16 +04:00
|
|
|
{
|
|
|
|
if (aEditable) {
|
|
|
|
SetFlags(NODE_IS_EDITABLE);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
UnsetFlags(NODE_IS_EDITABLE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsEditable() const
|
2007-07-11 17:05:05 +04:00
|
|
|
{
|
2013-03-16 08:31:38 +04:00
|
|
|
#ifdef MOZILLA_INTERNAL_API
|
2007-07-11 17:05:05 +04:00
|
|
|
return IsEditableInternal();
|
|
|
|
#else
|
|
|
|
return IsEditableExternal();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-04-23 11:21:22 +04:00
|
|
|
/**
|
2011-10-17 18:59:28 +04:00
|
|
|
* Returns true if |this| or any of its ancestors is native anonymous.
|
2009-04-23 11:21:22 +04:00
|
|
|
*/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsInNativeAnonymousSubtree() const
|
2009-04-23 11:21:22 +04:00
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
2014-04-06 23:32:38 +04:00
|
|
|
if (HasFlag(NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2009-04-23 11:21:22 +04:00
|
|
|
}
|
|
|
|
CheckNotNativeAnonymous();
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2009-04-23 11:21:22 +04:00
|
|
|
#else
|
2014-04-06 23:32:38 +04:00
|
|
|
return HasFlag(NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE);
|
2009-04-23 11:21:22 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-04-06 23:32:38 +04:00
|
|
|
bool IsInAnonymousSubtree() const;
|
|
|
|
|
2014-04-15 07:38:54 +04:00
|
|
|
// Note: This asserts |IsInAnonymousSubtree()|.
|
|
|
|
bool IsAnonymousContentInSVGUseSubtree() const;
|
|
|
|
|
2015-02-17 03:48:41 +03:00
|
|
|
// True for native anonymous content and for XBL content if the binding
|
2012-10-10 23:04:42 +04:00
|
|
|
// has chromeOnlyContent="true".
|
|
|
|
bool ChromeOnlyAccess() const
|
|
|
|
{
|
2014-04-06 23:32:38 +04:00
|
|
|
return HasFlag(NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE | NODE_CHROME_ONLY_ACCESS);
|
2012-10-10 23:04:42 +04:00
|
|
|
}
|
|
|
|
|
2014-07-03 21:02:07 +04:00
|
|
|
bool IsInShadowTree() const
|
|
|
|
{
|
|
|
|
return HasFlag(NODE_IS_IN_SHADOW_TREE);
|
|
|
|
}
|
|
|
|
|
2011-12-20 13:15:41 +04: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 10:40:04 +03: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.
|
|
|
|
*/
|
2012-07-30 18:20:58 +04:00
|
|
|
nsIContent* GetTextEditorRootContent(nsIEditor** aEditor = nullptr);
|
2008-02-20 10:40:04 +03: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 07:25:21 +03: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 10:40:04 +03:00
|
|
|
*/
|
|
|
|
nsIContent* GetSelectionRootContent(nsIPresShell* aPresShell);
|
|
|
|
|
2012-10-09 16:31:24 +04:00
|
|
|
virtual nsINodeList* ChildNodes();
|
2010-05-11 05:12:34 +04:00
|
|
|
nsIContent* GetFirstChild() const { return mFirstChild; }
|
2009-01-02 20:00:18 +03:00
|
|
|
nsIContent* GetLastChild() const
|
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t count;
|
2009-01-02 20:00:18 +03:00
|
|
|
nsIContent* const* children = GetChildArray(&count);
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
return count > 0 ? children[count - 1] : nullptr;
|
2009-01-02 20:00:18 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implementation is in nsIDocument.h, because it needs to cast from
|
|
|
|
* nsIDocument* to nsINode*.
|
|
|
|
*/
|
|
|
|
nsIDocument* GetOwnerDocument() const;
|
|
|
|
|
2012-10-09 16:31:24 +04:00
|
|
|
void Normalize();
|
2011-06-24 23:55:14 +04:00
|
|
|
|
2010-04-19 19:40:15 +04: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-25 01:56:52 +04:00
|
|
|
virtual already_AddRefed<nsIURI> GetBaseURI(bool aTryUseXHRDocBaseURI = false) const = 0;
|
|
|
|
already_AddRefed<nsIURI> GetBaseURIObject() const;
|
2010-04-19 19:40:15 +04:00
|
|
|
|
2012-02-03 00:50:50 +04:00
|
|
|
/**
|
|
|
|
* Facility for explicitly setting a base URI on a node.
|
|
|
|
*/
|
|
|
|
nsresult SetExplicitBaseURI(nsIURI* aURI);
|
|
|
|
/**
|
|
|
|
* The explicit base URI, if set, otherwise null
|
|
|
|
*/
|
|
|
|
protected:
|
|
|
|
nsIURI* GetExplicitBaseURI() const {
|
|
|
|
if (HasExplicitBaseURI()) {
|
|
|
|
return static_cast<nsIURI*>(GetProperty(nsGkAtoms::baseURIProperty));
|
|
|
|
}
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2012-02-03 00:50:50 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2014-08-05 14:10:00 +04:00
|
|
|
void GetTextContent(nsAString& aTextContent,
|
|
|
|
mozilla::ErrorResult& aError)
|
2010-04-19 19:41:33 +04:00
|
|
|
{
|
2014-08-05 14:10:00 +04:00
|
|
|
GetTextContentInternal(aTextContent, aError);
|
2010-04-19 19:41:33 +04:00
|
|
|
}
|
2012-10-09 16:31:24 +04:00
|
|
|
void SetTextContent(const nsAString& aTextContent,
|
|
|
|
mozilla::ErrorResult& aError)
|
2010-04-19 19:41:33 +04:00
|
|
|
{
|
2012-10-09 16:31:24 +04:00
|
|
|
SetTextContentInternal(aTextContent, aError);
|
2010-04-19 19:41:33 +04:00
|
|
|
}
|
|
|
|
|
2012-11-15 02:10:07 +04:00
|
|
|
mozilla::dom::Element* QuerySelector(const nsAString& aSelector,
|
|
|
|
mozilla::ErrorResult& aResult);
|
2012-10-16 15:51:00 +04:00
|
|
|
already_AddRefed<nsINodeList> QuerySelectorAll(const nsAString& aSelector,
|
|
|
|
mozilla::ErrorResult& aResult);
|
2012-08-30 21:10:13 +04:00
|
|
|
|
2013-07-08 16:09:18 +04:00
|
|
|
nsresult QuerySelector(const nsAString& aSelector, nsIDOMElement **aReturn);
|
|
|
|
nsresult QuerySelectorAll(const nsAString& aSelector, nsIDOMNodeList **aReturn);
|
|
|
|
|
2013-11-01 23:39:24 +04: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);
|
|
|
|
|
|
|
|
public:
|
2010-04-19 19:40:15 +04:00
|
|
|
/**
|
|
|
|
* Associate an object aData to aKey on this node. If aData is null any
|
2014-09-11 14:22:30 +04:00
|
|
|
* previously registered object associated to aKey on this node will
|
|
|
|
* be removed.
|
2010-04-19 19:40:15 +04: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 14:22:30 +04:00
|
|
|
* @return whether adding the object succeeded
|
2010-04-19 19:40:15 +04:00
|
|
|
*/
|
|
|
|
nsresult SetUserData(const nsAString& aKey, nsIVariant* aData,
|
2014-09-11 14:22:30 +04:00
|
|
|
nsIVariant** aResult);
|
2010-04-19 19:40:15 +04: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-11 02:41:42 +04:00
|
|
|
nsIVariant* GetUserData(const nsAString& aKey);
|
2010-04-19 19:40:15 +04:00
|
|
|
|
2011-06-14 11:56:48 +04:00
|
|
|
nsresult GetUserData(const nsAString& aKey, nsIVariant** aResult)
|
|
|
|
{
|
|
|
|
NS_IF_ADDREF(*aResult = GetUserData(aKey));
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-10-09 16:31:24 +04:00
|
|
|
void LookupPrefix(const nsAString& aNamespace, nsAString& aResult);
|
|
|
|
bool IsDefaultNamespace(const nsAString& aNamespaceURI)
|
2010-04-19 19:40:16 +04:00
|
|
|
{
|
|
|
|
nsAutoString defaultNamespace;
|
|
|
|
LookupNamespaceURI(EmptyString(), defaultNamespace);
|
2012-10-09 16:31:24 +04:00
|
|
|
return aNamespaceURI.Equals(defaultNamespace);
|
2010-04-19 19:40:16 +04:00
|
|
|
}
|
2012-10-09 16:31:24 +04:00
|
|
|
void LookupNamespaceURI(const nsAString& aNamespacePrefix,
|
|
|
|
nsAString& aNamespaceURI);
|
2011-06-14 11:56:48 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
nsresult IsEqualNode(nsIDOMNode* aOther, bool* aReturn);
|
2010-04-19 19:40:16 +04:00
|
|
|
|
2012-02-20 16:54:45 +04:00
|
|
|
nsIContent* GetNextSibling() const { return mNextSibling; }
|
|
|
|
nsIContent* GetPreviousSibling() const { return mPreviousSibling; }
|
2010-05-11 05:12:33 +04:00
|
|
|
|
2010-05-11 05:12:34 +04: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 18:20:58 +04:00
|
|
|
nsIContent* GetNextNode(const nsINode* aRoot = nullptr) const
|
2011-07-29 15:48:04 +04:00
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
return GetNextNodeImpl(aRoot, false);
|
2011-07-29 15:48:04 +04: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 18:20:58 +04:00
|
|
|
nsIContent* GetNextNonChildNode(const nsINode* aRoot = nullptr) const
|
2011-07-29 15:48:04 +04:00
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
return GetNextNodeImpl(aRoot, true);
|
2011-07-29 15:48:04 +04:00
|
|
|
}
|
|
|
|
|
2011-09-03 00:15:53 +04: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 10:19:26 +04:00
|
|
|
bool Contains(const nsINode* aOther) const;
|
|
|
|
nsresult Contains(nsIDOMNode* aOther, bool* aReturn);
|
2011-09-03 00:15:53 +04:00
|
|
|
|
2012-06-23 10:58:04 +04:00
|
|
|
bool UnoptimizableCCNode() const;
|
|
|
|
|
2011-07-29 15:48:04 +04:00
|
|
|
private:
|
|
|
|
|
2014-07-03 21:02:07 +04:00
|
|
|
nsIDocument* GetComposedDocInternal() const;
|
2014-06-07 12:42:53 +04:00
|
|
|
|
2011-07-29 15:48:04 +04:00
|
|
|
nsIContent* GetNextNodeImpl(const nsINode* aRoot,
|
2011-09-29 10:19:26 +04:00
|
|
|
const bool aSkipChildren) const
|
2010-05-11 05:12:34 +04: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 16:31:24 +04:00
|
|
|
for (; cur; cur = cur->GetParentNode())
|
2010-05-11 05:12:34 +04:00
|
|
|
if (cur == aRoot) break;
|
|
|
|
NS_ASSERTION(cur, "aRoot not an ancestor of |this|?");
|
|
|
|
}
|
|
|
|
#endif
|
2011-07-29 15:48:04 +04:00
|
|
|
if (!aSkipChildren) {
|
|
|
|
nsIContent* kid = GetFirstChild();
|
|
|
|
if (kid) {
|
|
|
|
return kid;
|
|
|
|
}
|
2010-05-11 05:12:34 +04:00
|
|
|
}
|
|
|
|
if (this == aRoot) {
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2010-05-11 05:12:34 +04:00
|
|
|
}
|
|
|
|
const nsINode* cur = this;
|
|
|
|
while (1) {
|
|
|
|
nsIContent* next = cur->GetNextSibling();
|
|
|
|
if (next) {
|
|
|
|
return next;
|
|
|
|
}
|
2012-10-09 16:31:24 +04:00
|
|
|
nsINode* parent = cur->GetParentNode();
|
2010-05-11 05:12:34 +04:00
|
|
|
if (parent == aRoot) {
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2010-05-11 05:12:34 +04:00
|
|
|
}
|
|
|
|
cur = parent;
|
|
|
|
}
|
|
|
|
NS_NOTREACHED("How did we get here?");
|
|
|
|
}
|
|
|
|
|
2011-07-29 15:48:04 +04:00
|
|
|
public:
|
|
|
|
|
2011-04-12 06:46:59 +04: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 18:20:58 +04:00
|
|
|
nsIContent* GetPreviousContent(const nsINode* aRoot = nullptr) const
|
2011-04-12 06:46:59 +04: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 16:31:24 +04:00
|
|
|
for (; cur; cur = cur->GetParentNode())
|
2011-04-12 06:46:59 +04:00
|
|
|
if (cur == aRoot) break;
|
|
|
|
NS_ASSERTION(cur, "aRoot not an ancestor of |this|?");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (this == aRoot) {
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2011-04-12 06:46:59 +04:00
|
|
|
}
|
|
|
|
nsIContent* cur = this->GetParent();
|
|
|
|
nsIContent* iter = this->GetPreviousSibling();
|
|
|
|
while (iter) {
|
|
|
|
cur = iter;
|
|
|
|
iter = reinterpret_cast<nsINode*>(iter)->GetLastChild();
|
|
|
|
}
|
|
|
|
return cur;
|
|
|
|
}
|
|
|
|
|
2011-04-08 06:29:49 +04: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 06:29:49 +04:00
|
|
|
// Set if this node is an Element
|
|
|
|
NodeIsElement,
|
2011-04-08 06:29:50 +04: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,
|
2011-04-08 06:29:50 +04:00
|
|
|
// Set if the element might have inline style.
|
|
|
|
ElementMayHaveStyle,
|
2011-04-08 06:29:50 +04:00
|
|
|
// Set if the element has a name attribute set.
|
|
|
|
ElementHasName,
|
2011-04-08 06:29:50 +04:00
|
|
|
// Set if the element might have a contenteditable attribute set.
|
|
|
|
ElementMayHaveContentEditableAttr,
|
2011-12-20 13:15:41 +04: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-31 00:08:13 +04:00
|
|
|
// Set if CanSkipInCC check has been done for this subtree root.
|
|
|
|
NodeIsCCMarkedRoot,
|
|
|
|
// Maybe set if this node is in black subtree.
|
|
|
|
NodeIsCCBlackTree,
|
|
|
|
// Maybe set if the node is a root of a subtree
|
|
|
|
// which needs to be kept in the purple buffer.
|
|
|
|
NodeIsPurpleRoot,
|
2012-02-03 00:50:50 +04:00
|
|
|
// Set if the node has an explicit base URI stored
|
|
|
|
NodeHasExplicitBaseURI,
|
2012-02-08 22:42:38 +04:00
|
|
|
// Set if the element has some style states locked
|
|
|
|
ElementHasLockedStyleStates,
|
2012-04-12 01:55:21 +04:00
|
|
|
// Set if element has pointer locked
|
|
|
|
ElementHasPointerLock,
|
2012-03-31 20:30:13 +04:00
|
|
|
// Set if the node may have DOMMutationObserver attached to it.
|
|
|
|
NodeMayHaveDOMMutationObserver,
|
2012-06-19 07:47:35 +04:00
|
|
|
// Set if node is Content
|
|
|
|
NodeIsContent,
|
2012-07-31 21:28:21 +04:00
|
|
|
// Set if the node has animations or transitions
|
|
|
|
ElementHasAnimations,
|
2012-11-21 14:13:57 +04:00
|
|
|
// Set if node has a dir attribute with a valid value (ltr, rtl, or auto)
|
2012-04-17 08:03:10 +04:00
|
|
|
NodeHasValidDirAttribute,
|
2012-11-21 14:13:57 +04:00
|
|
|
// Set if node has a dir attribute with a fixed value (ltr or rtl, NOT auto)
|
|
|
|
NodeHasFixedDir,
|
|
|
|
// 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 the node has dir=auto.
|
|
|
|
NodeHasDirAuto,
|
|
|
|
// Set if a node in the node's parent chain has dir=auto.
|
|
|
|
NodeAncestorHasDirAuto,
|
2013-01-09 03:25:47 +04:00
|
|
|
// Set if the element is in the scope of a scoped style sheet; this flag is
|
2013-07-04 08:00:06 +04:00
|
|
|
// only accurate for elements bound to a document
|
2013-01-09 03:25:47 +04:00
|
|
|
ElementIsInStyleScope,
|
2013-01-09 03:25:47 +04:00
|
|
|
// Set if the element is a scoped style sheet root
|
|
|
|
ElementIsScopedStyleRoot,
|
2013-06-08 12:54:59 +04: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 17:58:32 +04:00
|
|
|
// Set if the element has a parser insertion mode other than "in body",
|
|
|
|
// per the HTML5 "Parse state" section.
|
|
|
|
ElementHasWeirdParserInsertionMode,
|
2014-06-17 03:01:22 +04:00
|
|
|
// Parser sets this flag if it has notified about the node.
|
|
|
|
ParserHasNotified,
|
2011-04-08 06:29:50 +04:00
|
|
|
// Guard value
|
2011-04-08 06:29:49 +04:00
|
|
|
BooleanFlagCount
|
|
|
|
};
|
|
|
|
|
|
|
|
void SetBoolFlag(BooleanFlag name, bool value) {
|
2013-11-11 12:03:59 +04:00
|
|
|
static_assert(BooleanFlagCount <= 8*sizeof(mBoolFlags),
|
|
|
|
"Too many boolean flags");
|
2011-04-08 06:29:49 +04:00
|
|
|
mBoolFlags = (mBoolFlags & ~(1 << name)) | (value << name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetBoolFlag(BooleanFlag name) {
|
2013-11-11 12:03:59 +04:00
|
|
|
static_assert(BooleanFlagCount <= 8*sizeof(mBoolFlags),
|
|
|
|
"Too many boolean flags");
|
2011-04-08 06:29:49 +04:00
|
|
|
mBoolFlags |= (1 << name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClearBoolFlag(BooleanFlag name) {
|
2013-11-11 12:03:59 +04:00
|
|
|
static_assert(BooleanFlagCount <= 8*sizeof(mBoolFlags),
|
|
|
|
"Too many boolean flags");
|
2011-04-08 06:29:49 +04:00
|
|
|
mBoolFlags &= ~(1 << name);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GetBoolFlag(BooleanFlag name) const {
|
2013-11-11 12:03:59 +04:00
|
|
|
static_assert(BooleanFlagCount <= 8*sizeof(mBoolFlags),
|
|
|
|
"Too many boolean flags");
|
2011-04-08 06:29:49 +04:00
|
|
|
return mBoolFlags & (1 << name);
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
bool HasRenderingObservers() const
|
|
|
|
{ return GetBoolFlag(NodeHasRenderingObservers); }
|
2010-08-13 17:31:31 +04:00
|
|
|
void SetHasRenderingObservers(bool aValue)
|
2011-04-08 06:29:49 +04:00
|
|
|
{ SetBoolFlag(NodeHasRenderingObservers, aValue); }
|
2012-06-19 07:47:35 +04:00
|
|
|
bool IsContent() const { return GetBoolFlag(NodeIsContent); }
|
2011-04-08 06:29:50 +04:00
|
|
|
bool HasID() const { return GetBoolFlag(ElementHasID); }
|
2011-04-08 06:29:50 +04:00
|
|
|
bool MayHaveStyle() const { return GetBoolFlag(ElementMayHaveStyle); }
|
2011-04-08 06:29:50 +04:00
|
|
|
bool HasName() const { return GetBoolFlag(ElementHasName); }
|
2011-04-08 06:29:50 +04:00
|
|
|
bool MayHaveContentEditableAttr() const
|
|
|
|
{ return GetBoolFlag(ElementMayHaveContentEditableAttr); }
|
2011-12-20 13:15:41 +04: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 06:29:49 +04:00
|
|
|
|
2012-01-31 00:08:13 +04: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 20:30:13 +04:00
|
|
|
bool MayHaveDOMMutationObserver()
|
|
|
|
{ return GetBoolFlag(NodeMayHaveDOMMutationObserver); }
|
|
|
|
void SetMayHaveDOMMutationObserver()
|
|
|
|
{ SetBoolFlag(NodeMayHaveDOMMutationObserver, true); }
|
2012-02-27 18:03:15 +04:00
|
|
|
bool HasListenerManager() { return HasFlag(NODE_HAS_LISTENERMANAGER); }
|
2012-04-12 01:55:21 +04:00
|
|
|
bool HasPointerLock() const { return GetBoolFlag(ElementHasPointerLock); }
|
|
|
|
void SetPointerLock() { SetBoolFlag(ElementHasPointerLock); }
|
|
|
|
void ClearPointerLock() { ClearBoolFlag(ElementHasPointerLock); }
|
2012-07-31 21:28:21 +04:00
|
|
|
bool MayHaveAnimations() { return GetBoolFlag(ElementHasAnimations); }
|
|
|
|
void SetMayHaveAnimations() { SetBoolFlag(ElementHasAnimations); }
|
2012-04-17 08:03:10 +04:00
|
|
|
void SetHasValidDir() { SetBoolFlag(NodeHasValidDirAttribute); }
|
|
|
|
void ClearHasValidDir() { ClearBoolFlag(NodeHasValidDirAttribute); }
|
|
|
|
bool HasValidDir() const { return GetBoolFlag(NodeHasValidDirAttribute); }
|
2012-11-21 14:13:57 +04:00
|
|
|
void SetHasFixedDir() {
|
|
|
|
MOZ_ASSERT(NodeType() != nsIDOMNode::TEXT_NODE,
|
|
|
|
"SetHasFixedDir on text node");
|
|
|
|
SetBoolFlag(NodeHasFixedDir);
|
|
|
|
}
|
|
|
|
void ClearHasFixedDir() {
|
|
|
|
MOZ_ASSERT(NodeType() != nsIDOMNode::TEXT_NODE,
|
|
|
|
"ClearHasFixedDir on text node");
|
|
|
|
ClearBoolFlag(NodeHasFixedDir);
|
|
|
|
}
|
|
|
|
bool HasFixedDir() const { return GetBoolFlag(NodeHasFixedDir); }
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
bool HasTextNodeDirectionalityMap() const
|
|
|
|
{ return GetBoolFlag(NodeHasTextNodeDirectionalityMap); }
|
|
|
|
|
|
|
|
void SetHasDirAuto() { SetBoolFlag(NodeHasDirAuto); }
|
|
|
|
void ClearHasDirAuto() { ClearBoolFlag(NodeHasDirAuto); }
|
|
|
|
bool HasDirAuto() const { return GetBoolFlag(NodeHasDirAuto); }
|
|
|
|
|
|
|
|
void SetAncestorHasDirAuto() { SetBoolFlag(NodeAncestorHasDirAuto); }
|
|
|
|
void ClearAncestorHasDirAuto() { ClearBoolFlag(NodeAncestorHasDirAuto); }
|
|
|
|
bool AncestorHasDirAuto() const { return GetBoolFlag(NodeAncestorHasDirAuto); }
|
|
|
|
|
|
|
|
bool NodeOrAncestorHasDirAuto() const
|
|
|
|
{ return HasDirAuto() || AncestorHasDirAuto(); }
|
2013-01-09 03:25:47 +04: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-09 03:25:47 +04:00
|
|
|
|
|
|
|
void SetIsScopedStyleRoot() { SetBoolFlag(ElementIsScopedStyleRoot); }
|
|
|
|
void ClearIsScopedStyleRoot() { ClearBoolFlag(ElementIsScopedStyleRoot); }
|
|
|
|
bool IsScopedStyleRoot() { return GetBoolFlag(ElementIsScopedStyleRoot); }
|
2013-06-08 12:54:59 +04:00
|
|
|
bool HasRelevantHoverRules() const { return GetBoolFlag(NodeHasRelevantHoverRules); }
|
|
|
|
void SetHasRelevantHoverRules() { SetBoolFlag(NodeHasRelevantHoverRules); }
|
2014-06-17 03:01:22 +04:00
|
|
|
void SetParserHasNotified() { SetBoolFlag(ParserHasNotified); };
|
|
|
|
bool HasParserNotified() { return GetBoolFlag(ParserHasNotified); }
|
2011-04-08 06:29:49 +04:00
|
|
|
protected:
|
|
|
|
void SetParentIsContent(bool aValue) { SetBoolFlag(ParentIsContent, aValue); }
|
|
|
|
void SetInDocument() { SetBoolFlag(IsInDocument); }
|
2012-06-19 07:47:35 +04:00
|
|
|
void SetNodeIsContent() { SetBoolFlag(NodeIsContent); }
|
2011-04-08 06:29:49 +04:00
|
|
|
void ClearInDocument() { ClearBoolFlag(IsInDocument); }
|
2011-04-08 06:29:49 +04:00
|
|
|
void SetIsElement() { SetBoolFlag(NodeIsElement); }
|
2011-04-08 06:29:50 +04:00
|
|
|
void SetHasID() { SetBoolFlag(ElementHasID); }
|
|
|
|
void ClearHasID() { ClearBoolFlag(ElementHasID); }
|
2011-04-08 06:29:50 +04:00
|
|
|
void SetMayHaveStyle() { SetBoolFlag(ElementMayHaveStyle); }
|
2011-04-08 06:29:50 +04:00
|
|
|
void SetHasName() { SetBoolFlag(ElementHasName); }
|
|
|
|
void ClearHasName() { ClearBoolFlag(ElementHasName); }
|
2011-04-08 06:29:50 +04:00
|
|
|
void SetMayHaveContentEditableAttr()
|
|
|
|
{ SetBoolFlag(ElementMayHaveContentEditableAttr); }
|
2012-02-03 00:50:50 +04:00
|
|
|
bool HasExplicitBaseURI() const { return GetBoolFlag(NodeHasExplicitBaseURI); }
|
|
|
|
void SetHasExplicitBaseURI() { SetBoolFlag(NodeHasExplicitBaseURI); }
|
2012-02-08 22:42:38 +04:00
|
|
|
void SetHasLockedStyleStates() { SetBoolFlag(ElementHasLockedStyleStates); }
|
|
|
|
void ClearHasLockedStyleStates() { ClearBoolFlag(ElementHasLockedStyleStates); }
|
|
|
|
bool HasLockedStyleStates() const
|
|
|
|
{ return GetBoolFlag(ElementHasLockedStyleStates); }
|
2013-12-17 17:58:32 +04:00
|
|
|
void SetHasWeirdParserInsertionMode() { SetBoolFlag(ElementHasWeirdParserInsertionMode); }
|
|
|
|
bool HasWeirdParserInsertionMode() const
|
|
|
|
{ return GetBoolFlag(ElementHasWeirdParserInsertionMode); }
|
2013-06-08 12:54:59 +04:00
|
|
|
bool HandlingClick() const { return GetBoolFlag(NodeHandlingClick); }
|
|
|
|
void SetHandlingClick() { SetBoolFlag(NodeHandlingClick); }
|
|
|
|
void ClearHandlingClick() { ClearBoolFlag(NodeHandlingClick); }
|
2011-04-08 06:29:49 +04:00
|
|
|
|
2013-01-09 03:25:47 +04:00
|
|
|
void SetSubtreeRootPointer(nsINode* aSubtreeRoot)
|
2012-03-15 00:14:02 +04:00
|
|
|
{
|
|
|
|
NS_ASSERTION(aSubtreeRoot, "aSubtreeRoot can never be null!");
|
2014-06-07 12:42:53 +04:00
|
|
|
NS_ASSERTION(!(IsNodeOfType(eCONTENT) && IsInDoc()) &&
|
2014-07-03 21:02:07 +04:00
|
|
|
!IsInShadowTree(), "Shouldn't be here!");
|
2012-03-15 00:14:02 +04:00
|
|
|
mSubtreeRoot = aSubtreeRoot;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClearSubtreeRootPointer()
|
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
mSubtreeRoot = nullptr;
|
2012-03-15 00:14:02 +04:00
|
|
|
}
|
|
|
|
|
2011-04-08 06:29:49 +04:00
|
|
|
public:
|
2012-03-31 20:30:13 +04: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);
|
|
|
|
|
2013-09-11 23:43:01 +04:00
|
|
|
void GetBoundMutationObservers(nsTArray<nsRefPtr<nsDOMMutationObserver> >& aResult);
|
|
|
|
|
2012-03-30 01:09:04 +04: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 19:56:38 +04:00
|
|
|
uint32_t Length() const;
|
2012-03-30 01:09:04 +04:00
|
|
|
|
2013-10-11 20:28:23 +04:00
|
|
|
void GetNodeName(mozilla::dom::DOMString& aNodeName)
|
2012-10-09 16:31:24 +04:00
|
|
|
{
|
2013-10-11 20:28:23 +04:00
|
|
|
const nsString& nodeName = NodeName();
|
|
|
|
aNodeName.SetStringBuffer(nsStringBuffer::FromString(nodeName),
|
|
|
|
nodeName.Length());
|
2012-10-09 16:31:24 +04:00
|
|
|
}
|
|
|
|
void GetBaseURI(nsAString& aBaseURI) const;
|
2013-09-25 01:56:52 +04: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.
|
|
|
|
void GetBaseURIFromJS(nsAString& aBaseURI) const;
|
2012-10-09 16:31:24 +04: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 12:41:02 +04:00
|
|
|
virtual void GetNodeValueInternal(nsAString& aNodeValue);
|
2012-10-09 16:31:24 +04: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.
|
|
|
|
}
|
|
|
|
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);
|
|
|
|
bool IsEqualNode(nsINode* aNode);
|
2013-01-30 02:53:52 +04:00
|
|
|
void GetNamespaceURI(nsAString& aNamespaceURI) const
|
2012-10-09 16:31:24 +04:00
|
|
|
{
|
2013-01-30 02:53:52 +04:00
|
|
|
mNodeInfo->GetNamespaceURI(aNamespaceURI);
|
2012-10-09 16:31:24 +04:00
|
|
|
}
|
|
|
|
#ifdef MOZILLA_INTERNAL_API
|
|
|
|
void GetPrefix(nsAString& aPrefix)
|
|
|
|
{
|
|
|
|
mNodeInfo->GetPrefix(aPrefix);
|
|
|
|
}
|
|
|
|
#endif
|
2015-07-08 22:58:07 +03:00
|
|
|
void GetLocalName(mozilla::dom::DOMString& aLocalName) const
|
2013-10-11 20:28:23 +04:00
|
|
|
{
|
|
|
|
const nsString& localName = LocalName();
|
|
|
|
if (localName.IsVoid()) {
|
|
|
|
aLocalName.SetNull();
|
|
|
|
} else {
|
|
|
|
aLocalName.SetStringBuffer(nsStringBuffer::FromString(localName),
|
|
|
|
localName.Length());
|
|
|
|
}
|
2012-10-09 16:31:24 +04:00
|
|
|
}
|
2014-10-01 12:16:00 +04:00
|
|
|
|
2012-10-09 16:31:24 +04:00
|
|
|
nsDOMAttributeMap* GetAttributes();
|
2014-06-12 00:26:52 +04: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 16:31:24 +04: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 16:18:51 +03:00
|
|
|
return rv.StealNSResult();
|
2012-10-09 16:31:24 +04:00
|
|
|
}
|
|
|
|
|
2013-07-22 16:15:43 +04:00
|
|
|
// ChildNode methods
|
|
|
|
mozilla::dom::Element* GetPreviousElementSibling() const;
|
|
|
|
mozilla::dom::Element* GetNextElementSibling() const;
|
2013-04-13 11:08:47 +04:00
|
|
|
/**
|
|
|
|
* Remove this node from its parent, if any.
|
|
|
|
*/
|
|
|
|
void Remove();
|
|
|
|
|
2013-07-22 16:15:43 +04:00
|
|
|
// ParentNode methods
|
|
|
|
mozilla::dom::Element* GetFirstElementChild() const;
|
|
|
|
mozilla::dom::Element* GetLastElementChild() const;
|
|
|
|
|
2014-03-12 05:11:38 +04:00
|
|
|
void GetBoxQuads(const BoxQuadOptions& aOptions,
|
|
|
|
nsTArray<nsRefPtr<DOMQuad> >& aResult,
|
|
|
|
mozilla::ErrorResult& aRv);
|
|
|
|
|
2014-03-12 05:11:39 +04:00
|
|
|
already_AddRefed<DOMQuad> ConvertQuadFromNode(DOMQuad& aQuad,
|
|
|
|
const TextOrElementOrDocument& aFrom,
|
|
|
|
const ConvertCoordinateOptions& aOptions,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
already_AddRefed<DOMQuad> ConvertRectFromNode(DOMRectReadOnly& aRect,
|
|
|
|
const TextOrElementOrDocument& aFrom,
|
|
|
|
const ConvertCoordinateOptions& aOptions,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
already_AddRefed<DOMPoint> ConvertPointFromNode(const DOMPointInit& aPoint,
|
|
|
|
const TextOrElementOrDocument& aFrom,
|
|
|
|
const ConvertCoordinateOptions& aOptions,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
|
2006-05-15 13:46:44 +04:00
|
|
|
protected:
|
2006-05-15 11:03:15 +04:00
|
|
|
|
2006-07-02 11:23:10 +04:00
|
|
|
// Override this function to create a custom slots class.
|
2012-08-11 02:27:28 +04:00
|
|
|
// Must not return null.
|
2006-07-02 11:23:10 +04:00
|
|
|
virtual nsINode::nsSlots* CreateSlots();
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool HasSlots() const
|
2006-05-15 11:03:15 +04:00
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
return mSlots != nullptr;
|
2006-05-15 11:03:15 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsSlots* GetExistingSlots() const
|
|
|
|
{
|
2011-04-08 06:29:49 +04:00
|
|
|
return mSlots;
|
2006-05-15 11:03:15 +04:00
|
|
|
}
|
|
|
|
|
2012-08-11 02:27:28 +04:00
|
|
|
nsSlots* Slots()
|
2006-05-15 11:03:15 +04:00
|
|
|
{
|
2011-04-08 06:29:49 +04:00
|
|
|
if (!HasSlots()) {
|
|
|
|
mSlots = CreateSlots();
|
2012-08-11 02:27:28 +04:00
|
|
|
MOZ_ASSERT(mSlots);
|
2006-07-02 11:23:10 +04:00
|
|
|
}
|
2011-04-08 06:29:49 +04:00
|
|
|
return GetExistingSlots();
|
2006-05-15 11:03:15 +04:00
|
|
|
}
|
|
|
|
|
2008-01-02 23:49:13 +03:00
|
|
|
nsTObserverArray<nsIMutationObserver*> *GetMutationObservers()
|
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
return HasSlots() ? &GetExistingSlots()->mMutationObservers : nullptr;
|
2008-01-02 23:49:13 +03:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool IsEditableInternal() const;
|
|
|
|
virtual bool IsEditableExternal() const
|
2007-07-11 17:05:05 +04:00
|
|
|
{
|
|
|
|
return IsEditableInternal();
|
|
|
|
}
|
|
|
|
|
2014-08-05 14:10:00 +04:00
|
|
|
virtual void GetTextContentInternal(nsAString& aTextContent,
|
|
|
|
mozilla::ErrorResult& aError);
|
2012-10-09 16:31:24 +04:00
|
|
|
virtual void SetTextContentInternal(const nsAString& aTextContent,
|
|
|
|
mozilla::ErrorResult& aError)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-04-23 11:21:22 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
// Note: virtual so that IsInNativeAnonymousSubtree can be called accross
|
|
|
|
// module boundaries.
|
|
|
|
virtual void CheckNotNativeAnonymous() const;
|
|
|
|
#endif
|
|
|
|
|
2012-10-09 16:31:24 +04:00
|
|
|
// These are just used to implement nsIDOMNode using
|
|
|
|
// NS_FORWARD_NSIDOMNODE_TO_NSINODE_HELPER and for quickstubs.
|
2009-01-02 20:00:18 +03:00
|
|
|
nsresult GetParentNode(nsIDOMNode** aParentNode);
|
2011-09-12 02:45:39 +04:00
|
|
|
nsresult GetParentElement(nsIDOMElement** aParentElement);
|
2009-01-02 20:00:18 +03:00
|
|
|
nsresult GetChildNodes(nsIDOMNodeList** aChildNodes);
|
|
|
|
nsresult GetFirstChild(nsIDOMNode** aFirstChild);
|
|
|
|
nsresult GetLastChild(nsIDOMNode** aLastChild);
|
|
|
|
nsresult GetPreviousSibling(nsIDOMNode** aPrevSibling);
|
|
|
|
nsresult GetNextSibling(nsIDOMNode** aNextSibling);
|
|
|
|
nsresult GetOwnerDocument(nsIDOMDocument** aOwnerDocument);
|
2012-10-09 16:31:24 +04:00
|
|
|
nsresult CompareDocumentPosition(nsIDOMNode* aOther,
|
|
|
|
uint16_t* aReturn);
|
2009-01-02 20:00:18 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
nsresult ReplaceOrInsertBefore(bool aReplace, nsIDOMNode *aNewChild,
|
2010-03-17 18:06:19 +03:00
|
|
|
nsIDOMNode *aRefChild, nsIDOMNode **aReturn);
|
2012-10-09 16:31:24 +04:00
|
|
|
nsINode* ReplaceOrInsertBefore(bool aReplace, nsINode* aNewChild,
|
|
|
|
nsINode* aRefChild,
|
|
|
|
mozilla::ErrorResult& aError);
|
2010-03-17 18:06:19 +03:00
|
|
|
nsresult RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aReturn);
|
|
|
|
|
2010-04-19 19:40:16 +04: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 05:12:34 +04: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 19:56:38 +04:00
|
|
|
void doRemoveChildAt(uint32_t aIndex, bool aNotify, nsIContent* aKid,
|
2012-03-30 01:09:06 +04:00
|
|
|
nsAttrAndChildArray& aChildArray);
|
2010-05-11 05:12:34 +04: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 19:56:38 +04:00
|
|
|
nsresult doInsertChildAt(nsIContent* aKid, uint32_t aIndex,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aNotify, nsAttrAndChildArray& aChildArray);
|
2010-05-11 05:12:34 +04:00
|
|
|
|
2013-12-16 22:06:36 +04: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 20:21:48 +04:00
|
|
|
public:
|
2011-08-24 23:49:25 +04: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 06:56:45 +04: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 17:37:39 +04:00
|
|
|
#define EVENT(name_, id_, type_, struct_) \
|
|
|
|
mozilla::dom::EventHandlerNonNull* GetOn##name_(); \
|
2013-11-16 16:31:37 +04:00
|
|
|
void SetOn##name_(mozilla::dom::EventHandlerNonNull* listener);
|
2011-08-24 23:49:25 +04:00
|
|
|
#define TOUCH_EVENT EVENT
|
2011-09-20 06:56:45 +04:00
|
|
|
#define DOCUMENT_ONLY_EVENT EVENT
|
2014-04-01 15:42:12 +04:00
|
|
|
#include "mozilla/EventNameList.h"
|
2011-09-20 06:56:45 +04:00
|
|
|
#undef DOCUMENT_ONLY_EVENT
|
2011-08-24 23:49:25 +04:00
|
|
|
#undef TOUCH_EVENT
|
2013-05-27 15:50:49 +04:00
|
|
|
#undef EVENT
|
2011-08-24 23:49:25 +04:00
|
|
|
|
2011-10-10 20:21:48 +04:00
|
|
|
protected:
|
2011-08-28 18:07:24 +04:00
|
|
|
static bool Traverse(nsINode *tmp, nsCycleCollectionTraversalCallback &cb);
|
|
|
|
static void Unlink(nsINode *tmp);
|
|
|
|
|
2014-06-20 06:01:40 +04:00
|
|
|
nsRefPtr<mozilla::dom::NodeInfo> mNodeInfo;
|
2006-04-15 09:09:16 +04:00
|
|
|
|
2015-04-18 22:50:21 +03: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 09:09:16 +04:00
|
|
|
|
2011-04-08 06:29:49 +04:00
|
|
|
private:
|
|
|
|
// Boolean flags.
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mBoolFlags;
|
2011-04-08 06:29:49 +04:00
|
|
|
|
|
|
|
protected:
|
2015-04-18 23:01:51 +03: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 22:58:15 +03: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 17:31:31 +04:00
|
|
|
|
2012-03-15 00:14:02 +04: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 23:05:55 +03: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-15 00:14:02 +04:00
|
|
|
};
|
|
|
|
|
2011-04-08 06:29:49 +04:00
|
|
|
// Storage for more members that are usually not needed; allocated lazily.
|
|
|
|
nsSlots* mSlots;
|
2006-01-19 06:34:18 +03:00
|
|
|
};
|
|
|
|
|
2014-04-25 14:34:42 +04:00
|
|
|
inline nsIDOMNode* GetAsDOMNode(nsINode* aNode)
|
|
|
|
{
|
|
|
|
return aNode ? aNode->AsDOMNode() : nullptr;
|
|
|
|
}
|
|
|
|
|
2012-08-06 16:02:08 +04: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 14:24:41 +03:00
|
|
|
NS_DEFINE_STATIC_IID_ACCESSOR(nsINode, NS_INODE_IID)
|
2006-01-19 06:34:18 +03:00
|
|
|
|
2013-09-06 10:41:42 +04:00
|
|
|
inline nsISupports*
|
|
|
|
ToSupports(nsINode* aPointer)
|
|
|
|
{
|
|
|
|
return aPointer;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline nsISupports*
|
|
|
|
ToCanonicalSupports(nsINode* aPointer)
|
|
|
|
{
|
|
|
|
return aPointer;
|
|
|
|
}
|
|
|
|
|
2013-01-02 19:55:05 +04:00
|
|
|
#define NS_FORWARD_NSIDOMNODE_TO_NSINODE_HELPER(...) \
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD GetNodeName(nsAString& aNodeName) __VA_ARGS__ override \
|
2012-10-09 16:31:24 +04:00
|
|
|
{ \
|
2013-10-11 20:28:23 +04:00
|
|
|
aNodeName = nsINode::NodeName(); \
|
2012-10-09 16:31:24 +04:00
|
|
|
return NS_OK; \
|
|
|
|
} \
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD GetNodeValue(nsAString& aNodeValue) __VA_ARGS__ override \
|
2012-10-09 16:31:24 +04:00
|
|
|
{ \
|
|
|
|
nsINode::GetNodeValue(aNodeValue); \
|
|
|
|
return NS_OK; \
|
|
|
|
} \
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD SetNodeValue(const nsAString& aNodeValue) __VA_ARGS__ override \
|
2012-10-09 16:31:24 +04:00
|
|
|
{ \
|
|
|
|
mozilla::ErrorResult rv; \
|
|
|
|
nsINode::SetNodeValue(aNodeValue, rv); \
|
2015-04-27 16:18:51 +03:00
|
|
|
return rv.StealNSResult(); \
|
2012-10-09 16:31:24 +04:00
|
|
|
} \
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD GetNodeType(uint16_t* aNodeType) __VA_ARGS__ override \
|
2012-10-09 16:31:24 +04:00
|
|
|
{ \
|
|
|
|
*aNodeType = nsINode::NodeType(); \
|
|
|
|
return NS_OK; \
|
|
|
|
} \
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD GetParentNode(nsIDOMNode** aParentNode) __VA_ARGS__ override \
|
2012-10-09 16:31:24 +04:00
|
|
|
{ \
|
|
|
|
return nsINode::GetParentNode(aParentNode); \
|
|
|
|
} \
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD GetParentElement(nsIDOMElement** aParentElement) __VA_ARGS__ override \
|
2012-10-09 16:31:24 +04:00
|
|
|
{ \
|
|
|
|
return nsINode::GetParentElement(aParentElement); \
|
|
|
|
} \
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD GetChildNodes(nsIDOMNodeList** aChildNodes) __VA_ARGS__ override \
|
2012-10-09 16:31:24 +04:00
|
|
|
{ \
|
|
|
|
return nsINode::GetChildNodes(aChildNodes); \
|
|
|
|
} \
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD GetFirstChild(nsIDOMNode** aFirstChild) __VA_ARGS__ override \
|
2012-10-09 16:31:24 +04:00
|
|
|
{ \
|
|
|
|
return nsINode::GetFirstChild(aFirstChild); \
|
|
|
|
} \
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD GetLastChild(nsIDOMNode** aLastChild) __VA_ARGS__ override \
|
2012-10-09 16:31:24 +04:00
|
|
|
{ \
|
|
|
|
return nsINode::GetLastChild(aLastChild); \
|
|
|
|
} \
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD GetPreviousSibling(nsIDOMNode** aPreviousSibling) __VA_ARGS__ override \
|
2012-10-09 16:31:24 +04:00
|
|
|
{ \
|
|
|
|
return nsINode::GetPreviousSibling(aPreviousSibling); \
|
|
|
|
} \
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD GetNextSibling(nsIDOMNode** aNextSibling) __VA_ARGS__ override \
|
2012-10-09 16:31:24 +04:00
|
|
|
{ \
|
|
|
|
return nsINode::GetNextSibling(aNextSibling); \
|
|
|
|
} \
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD GetOwnerDocument(nsIDOMDocument** aOwnerDocument) __VA_ARGS__ override \
|
2012-10-09 16:31:24 +04:00
|
|
|
{ \
|
|
|
|
return nsINode::GetOwnerDocument(aOwnerDocument); \
|
|
|
|
} \
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD InsertBefore(nsIDOMNode* aNewChild, nsIDOMNode* aRefChild, nsIDOMNode** aResult) __VA_ARGS__ override \
|
2012-10-09 16:31:24 +04:00
|
|
|
{ \
|
|
|
|
return ReplaceOrInsertBefore(false, aNewChild, aRefChild, aResult); \
|
|
|
|
} \
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD ReplaceChild(nsIDOMNode* aNewChild, nsIDOMNode* aOldChild, nsIDOMNode** aResult) __VA_ARGS__ override \
|
2012-10-09 16:31:24 +04:00
|
|
|
{ \
|
|
|
|
return ReplaceOrInsertBefore(true, aNewChild, aOldChild, aResult); \
|
|
|
|
} \
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD RemoveChild(nsIDOMNode* aOldChild, nsIDOMNode** aResult) __VA_ARGS__ override \
|
2012-10-09 16:31:24 +04:00
|
|
|
{ \
|
|
|
|
return nsINode::RemoveChild(aOldChild, aResult); \
|
|
|
|
} \
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD AppendChild(nsIDOMNode* aNewChild, nsIDOMNode** aResult) __VA_ARGS__ override \
|
2012-10-09 16:31:24 +04:00
|
|
|
{ \
|
|
|
|
return InsertBefore(aNewChild, nullptr, aResult); \
|
|
|
|
} \
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD HasChildNodes(bool* aResult) __VA_ARGS__ override \
|
2012-10-09 16:31:24 +04:00
|
|
|
{ \
|
|
|
|
*aResult = nsINode::HasChildNodes(); \
|
|
|
|
return NS_OK; \
|
|
|
|
} \
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD CloneNode(bool aDeep, uint8_t aArgc, nsIDOMNode** aResult) __VA_ARGS__ override \
|
2012-10-09 16:31:24 +04:00
|
|
|
{ \
|
|
|
|
if (aArgc == 0) { \
|
|
|
|
aDeep = true; \
|
|
|
|
} \
|
|
|
|
mozilla::ErrorResult rv; \
|
|
|
|
nsCOMPtr<nsINode> clone = nsINode::CloneNode(aDeep, rv); \
|
|
|
|
if (rv.Failed()) { \
|
2015-04-27 16:18:51 +03:00
|
|
|
return rv.StealNSResult(); \
|
2012-10-09 16:31:24 +04:00
|
|
|
} \
|
2014-03-15 23:00:15 +04:00
|
|
|
*aResult = clone.forget().take()->AsDOMNode(); \
|
2012-10-09 16:31:24 +04:00
|
|
|
return NS_OK; \
|
|
|
|
} \
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD Normalize() __VA_ARGS__ override \
|
2012-10-09 16:31:24 +04:00
|
|
|
{ \
|
|
|
|
nsINode::Normalize(); \
|
|
|
|
return NS_OK; \
|
|
|
|
} \
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD GetNamespaceURI(nsAString& aNamespaceURI) __VA_ARGS__ override \
|
2012-10-09 16:31:24 +04:00
|
|
|
{ \
|
2013-01-30 02:53:52 +04:00
|
|
|
nsINode::GetNamespaceURI(aNamespaceURI); \
|
|
|
|
return NS_OK; \
|
2012-10-09 16:31:24 +04:00
|
|
|
} \
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD GetPrefix(nsAString& aPrefix) __VA_ARGS__ override \
|
2012-10-09 16:31:24 +04:00
|
|
|
{ \
|
|
|
|
nsINode::GetPrefix(aPrefix); \
|
|
|
|
return NS_OK; \
|
|
|
|
} \
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD GetLocalName(nsAString& aLocalName) __VA_ARGS__ override \
|
2012-10-09 16:31:24 +04:00
|
|
|
{ \
|
2013-10-11 20:28:23 +04:00
|
|
|
aLocalName = nsINode::LocalName(); \
|
2012-10-09 16:31:24 +04:00
|
|
|
return NS_OK; \
|
2014-11-14 00:32:24 +03:00
|
|
|
} \
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD UnusedPlaceholder(bool* aResult) __VA_ARGS__ override \
|
2014-11-14 00:32:24 +03:00
|
|
|
{ \
|
|
|
|
*aResult = false; \
|
|
|
|
return NS_OK; \
|
2012-10-09 16:31:24 +04:00
|
|
|
} \
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD GetDOMBaseURI(nsAString& aBaseURI) __VA_ARGS__ override \
|
2012-10-09 16:31:24 +04:00
|
|
|
{ \
|
|
|
|
nsINode::GetBaseURI(aBaseURI); \
|
|
|
|
return NS_OK; \
|
|
|
|
} \
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD CompareDocumentPosition(nsIDOMNode* aOther, uint16_t* aResult) __VA_ARGS__ override \
|
2012-10-09 16:31:24 +04:00
|
|
|
{ \
|
|
|
|
return nsINode::CompareDocumentPosition(aOther, aResult); \
|
|
|
|
} \
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD GetTextContent(nsAString& aTextContent) __VA_ARGS__ override \
|
2012-10-09 16:31:24 +04:00
|
|
|
{ \
|
2014-08-05 14:10:00 +04:00
|
|
|
mozilla::ErrorResult rv; \
|
|
|
|
nsINode::GetTextContent(aTextContent, rv); \
|
2015-04-27 16:18:51 +03:00
|
|
|
return rv.StealNSResult(); \
|
2012-10-09 16:31:24 +04:00
|
|
|
} \
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD SetTextContent(const nsAString& aTextContent) __VA_ARGS__ override \
|
2012-10-09 16:31:24 +04:00
|
|
|
{ \
|
|
|
|
mozilla::ErrorResult rv; \
|
|
|
|
nsINode::SetTextContent(aTextContent, rv); \
|
2015-04-27 16:18:51 +03:00
|
|
|
return rv.StealNSResult(); \
|
2012-10-09 16:31:24 +04:00
|
|
|
} \
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD LookupPrefix(const nsAString& aNamespaceURI, nsAString& aResult) __VA_ARGS__ override \
|
2012-10-09 16:31:24 +04:00
|
|
|
{ \
|
|
|
|
nsINode::LookupPrefix(aNamespaceURI, aResult); \
|
|
|
|
return NS_OK; \
|
|
|
|
} \
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD IsDefaultNamespace(const nsAString& aNamespaceURI, bool* aResult) __VA_ARGS__ override \
|
2012-10-09 16:31:24 +04:00
|
|
|
{ \
|
|
|
|
*aResult = nsINode::IsDefaultNamespace(aNamespaceURI); \
|
|
|
|
return NS_OK; \
|
|
|
|
} \
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD LookupNamespaceURI(const nsAString& aPrefix, nsAString& aResult) __VA_ARGS__ override \
|
2012-10-09 16:31:24 +04:00
|
|
|
{ \
|
|
|
|
nsINode::LookupNamespaceURI(aPrefix, aResult); \
|
|
|
|
return NS_OK; \
|
|
|
|
} \
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD IsEqualNode(nsIDOMNode* aArg, bool* aResult) __VA_ARGS__ override \
|
2012-10-09 16:31:24 +04:00
|
|
|
{ \
|
|
|
|
return nsINode::IsEqualNode(aArg, aResult); \
|
|
|
|
} \
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD SetUserData(const nsAString& aKey, nsIVariant* aData, nsIVariant** aResult) __VA_ARGS__ override \
|
2012-10-09 16:31:24 +04:00
|
|
|
{ \
|
2014-09-11 14:22:30 +04:00
|
|
|
return nsINode::SetUserData(aKey, aData, aResult); \
|
2012-10-09 16:31:24 +04:00
|
|
|
} \
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD GetUserData(const nsAString& aKey, nsIVariant** aResult) __VA_ARGS__ override \
|
2012-10-09 16:31:24 +04:00
|
|
|
{ \
|
|
|
|
return nsINode::GetUserData(aKey, aResult); \
|
|
|
|
} \
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD Contains(nsIDOMNode* aOther, bool* aResult) __VA_ARGS__ override \
|
2012-10-09 16:31:24 +04:00
|
|
|
{ \
|
|
|
|
return nsINode::Contains(aOther, aResult); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define NS_FORWARD_NSIDOMNODE_TO_NSINODE \
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_FORWARD_NSIDOMNODE_TO_NSINODE_HELPER(final)
|
2012-10-09 16:31:24 +04:00
|
|
|
|
|
|
|
#define NS_FORWARD_NSIDOMNODE_TO_NSINODE_OVERRIDABLE \
|
|
|
|
NS_FORWARD_NSIDOMNODE_TO_NSINODE_HELPER()
|
2008-11-13 19:54:52 +03:00
|
|
|
|
2006-01-19 06:34:18 +03:00
|
|
|
#endif /* nsINode_h___ */
|