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"
|
2016-07-21 22:47:29 +03:00
|
|
|
#include "mozilla/UniquePtr.h"
|
2012-08-06 16:02:08 +04:00
|
|
|
#include "nsCOMPtr.h" // for member, local
|
|
|
|
#include "nsGkAtoms.h" // for nsGkAtoms::baseURIProperty
|
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()
|
2018-04-07 20:41:03 +03:00
|
|
|
#include "nsIWeakReference.h"
|
2012-08-06 16:02:08 +04:00
|
|
|
#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"
|
2017-09-01 18:13:47 +03:00
|
|
|
#include "mozilla/LinkedList.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"
|
2018-01-30 07:10:53 +03:00
|
|
|
#include "mozilla/dom/NodeBinding.h"
|
2017-07-22 08:29:07 +03:00
|
|
|
#include "nsTHashtable.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
|
|
|
|
|
2018-08-07 22:07:26 +03:00
|
|
|
class AttrArray;
|
2017-08-11 05:12:17 +03:00
|
|
|
class nsAttrChildContentList;
|
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;
|
2012-08-06 16:02:08 +04:00
|
|
|
class nsIFrame;
|
2018-07-26 23:40:13 +03:00
|
|
|
class nsIHTMLCollection;
|
2012-08-06 16:02:08 +04:00
|
|
|
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;
|
2013-09-11 23:43:01 +04:00
|
|
|
class nsDOMMutationObserver;
|
2017-07-22 08:29:07 +03:00
|
|
|
class nsRange;
|
2018-03-28 02:44:49 +03:00
|
|
|
class nsWindowSizes;
|
2017-10-02 19:14:15 +03:00
|
|
|
struct RawServoSelectorList;
|
2016-07-21 22:47:29 +03:00
|
|
|
|
2010-04-30 17:12:05 +04:00
|
|
|
namespace mozilla {
|
2014-03-17 10:56:53 +04:00
|
|
|
class EventListenerManager;
|
2017-06-22 09:21:31 +03:00
|
|
|
class TextEditor;
|
2010-04-30 17:12:05 +04:00
|
|
|
namespace dom {
|
2012-11-30 20:04:11 +04:00
|
|
|
/**
|
2017-05-26 21:02:00 +03:00
|
|
|
* @return true if aChar is what the WHATWG defines as a 'ascii whitespace'.
|
|
|
|
* https://infra.spec.whatwg.org/#ascii-whitespace
|
2012-11-30 20:04:11 +04:00
|
|
|
*/
|
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';
|
|
|
|
}
|
2016-08-23 21:15:15 +03:00
|
|
|
class AccessibleNode;
|
2014-03-12 05:11:38 +04:00
|
|
|
struct BoxQuadOptions;
|
2014-03-12 05:11:39 +04:00
|
|
|
struct ConvertCoordinateOptions;
|
2017-11-27 11:10:27 +03:00
|
|
|
class DocGroup;
|
2019-01-02 16:05:23 +03:00
|
|
|
class Document;
|
2018-04-15 13:08:36 +03:00
|
|
|
class DocumentFragment;
|
2018-05-18 20:02:14 +03:00
|
|
|
class DocumentOrShadowRoot;
|
2014-03-12 05:11:39 +04:00
|
|
|
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;
|
2018-02-22 01:07:53 +03:00
|
|
|
class L10nCallback;
|
2012-10-09 16:31:24 +04:00
|
|
|
template <typename T>
|
|
|
|
class Optional;
|
2016-04-12 05:48:14 +03:00
|
|
|
class OwningNodeOrString;
|
2018-02-22 01:07:53 +03:00
|
|
|
class Promise;
|
2016-04-12 05:48:14 +03:00
|
|
|
template <typename>
|
|
|
|
class Sequence;
|
2018-07-16 17:07:58 +03:00
|
|
|
class SVGUseElement;
|
2014-08-13 15:53:32 +04:00
|
|
|
class Text;
|
2014-03-12 05:11:39 +04:00
|
|
|
class TextOrElementOrDocument;
|
|
|
|
struct DOMPointInit;
|
2017-01-15 20:46:00 +03:00
|
|
|
struct GetRootNodeOptions;
|
2017-02-01 23:43:36 +03:00
|
|
|
enum class CallerType : uint32_t;
|
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
|
|
|
// Whether a binding manager may have a pointer to this
|
2018-03-12 23:24:10 +03:00
|
|
|
NODE_MAY_BE_IN_BINDING_MNGR = NODE_FLAG_BIT(5),
|
2007-05-11 22:34:12 +04:00
|
|
|
|
2018-03-12 23:24:10 +03:00
|
|
|
NODE_IS_EDITABLE = NODE_FLAG_BIT(6),
|
2007-06-28 06:48:16 +04:00
|
|
|
|
2018-05-10 19:48:08 +03:00
|
|
|
// Free bit here.
|
2007-09-18 12:38:24 +04:00
|
|
|
|
2013-12-02 14:26:11 +04:00
|
|
|
// Whether the node participates in a shadow tree.
|
2018-03-12 23:24:10 +03:00
|
|
|
NODE_IS_IN_SHADOW_TREE = NODE_FLAG_BIT(8),
|
2013-12-02 14:26:11 +04:00
|
|
|
|
2008-02-19 09:17:07 +03:00
|
|
|
// Node has an :empty or :-moz-only-whitespace selector
|
2018-03-12 23:24:10 +03:00
|
|
|
NODE_HAS_EMPTY_SELECTOR = NODE_FLAG_BIT(9),
|
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.
|
2018-03-12 23:24:10 +03:00
|
|
|
NODE_HAS_SLOW_SELECTOR = NODE_FLAG_BIT(10),
|
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.
|
2018-03-12 23:24:10 +03:00
|
|
|
NODE_HAS_EDGE_CHILD_SELECTOR = NODE_FLAG_BIT(11),
|
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.
|
2018-03-12 23:24:10 +03:00
|
|
|
NODE_HAS_SLOW_SELECTOR_LATER_SIBLINGS = NODE_FLAG_BIT(12),
|
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).
|
2018-03-12 23:24:10 +03:00
|
|
|
NODE_NEEDS_FRAME = NODE_FLAG_BIT(13),
|
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.
|
2018-03-12 23:24:10 +03:00
|
|
|
NODE_DESCENDANTS_NEED_FRAMES = NODE_FLAG_BIT(14),
|
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.
|
2018-03-12 23:24:10 +03:00
|
|
|
NODE_HAS_ACCESSKEY = NODE_FLAG_BIT(15),
|
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
|
2018-03-12 23:24:10 +03:00
|
|
|
NODE_HAS_DIRECTION_RTL = NODE_FLAG_BIT(16),
|
2012-04-17 08:03:10 +04:00
|
|
|
|
|
|
|
// Set if the node has left-to-right directionality
|
2018-03-12 23:24:10 +03:00
|
|
|
NODE_HAS_DIRECTION_LTR = NODE_FLAG_BIT(17),
|
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
|
|
|
|
2019-02-21 21:39:28 +03:00
|
|
|
NODE_HAS_BEEN_IN_UA_WIDGET = NODE_FLAG_BIT(18),
|
2012-10-10 23:04:42 +04:00
|
|
|
|
2007-07-11 02:49:42 +04:00
|
|
|
// Remaining bits are node type specific.
|
2019-02-21 21:39:28 +03:00
|
|
|
NODE_TYPE_SPECIFIC_BITS_OFFSET = 19
|
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:
|
2014-08-02 00:30:58 +04:00
|
|
|
nsMutationGuard() { 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) {
|
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() { sGeneration++; }
|
|
|
|
|
|
|
|
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
|
|
|
|
2018-04-07 20:41:03 +03:00
|
|
|
/**
|
|
|
|
* A class that implements nsIWeakReference
|
|
|
|
*/
|
|
|
|
class nsNodeWeakReference final : public nsIWeakReference {
|
|
|
|
public:
|
|
|
|
explicit nsNodeWeakReference(nsINode* aNode);
|
|
|
|
|
|
|
|
// nsISupports
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
|
|
|
|
// nsIWeakReference
|
|
|
|
NS_DECL_NSIWEAKREFERENCE
|
|
|
|
size_t SizeOfOnlyThis(mozilla::MallocSizeOf aMallocSizeOf) const override;
|
|
|
|
|
|
|
|
void NoticeNodeDestruction() { mObject = nullptr; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
~nsNodeWeakReference();
|
|
|
|
};
|
|
|
|
|
2014-03-05 03:39:42 +04:00
|
|
|
// This should be used for any nsINode sub-class that has fields of its own
|
Bug 1387956 - Overhaul ComputedValues measurement, and add style structs measurement. r=bholley.
This patch moves measurement of ComputedValues objects from Rust to C++.
Measurement now happens (a) via DOM elements and (b) remaining elements via
the frame tree. Likewise for the style structs hanging off ComputedValues
objects.
Here is an example of the output.
> ├──27,600,448 B (26.49%) -- active/window(https://en.wikipedia.org/wiki/Barack_Obama)
> │ ├──12,772,544 B (12.26%) -- layout
> │ │ ├───4,483,744 B (04.30%) -- frames
> │ │ │ ├──1,653,552 B (01.59%) ── nsInlineFrame
> │ │ │ ├──1,415,760 B (01.36%) ── nsTextFrame
> │ │ │ ├────431,376 B (00.41%) ── nsBlockFrame
> │ │ │ ├────340,560 B (00.33%) ── nsHTMLScrollFrame
> │ │ │ ├────302,544 B (00.29%) ── nsContinuingTextFrame
> │ │ │ ├────156,408 B (00.15%) ── nsBulletFrame
> │ │ │ ├─────73,024 B (00.07%) ── nsPlaceholderFrame
> │ │ │ ├─────27,656 B (00.03%) ── sundries
> │ │ │ ├─────23,520 B (00.02%) ── nsTableCellFrame
> │ │ │ ├─────16,704 B (00.02%) ── nsImageFrame
> │ │ │ ├─────15,488 B (00.01%) ── nsTableRowFrame
> │ │ │ ├─────13,776 B (00.01%) ── nsTableColFrame
> │ │ │ └─────13,376 B (00.01%) ── nsTableFrame
> │ │ ├───3,412,192 B (03.28%) -- servo-style-structs
> │ │ │ ├──1,288,224 B (01.24%) ── Display
> │ │ │ ├────742,400 B (00.71%) ── Position
> │ │ │ ├────308,736 B (00.30%) ── Font
> │ │ │ ├────226,512 B (00.22%) ── Background
> │ │ │ ├────218,304 B (00.21%) ── TextReset
> │ │ │ ├────214,896 B (00.21%) ── Text
> │ │ │ ├────130,560 B (00.13%) ── Border
> │ │ │ ├─────81,408 B (00.08%) ── UIReset
> │ │ │ ├─────61,440 B (00.06%) ── Padding
> │ │ │ ├─────38,176 B (00.04%) ── UserInterface
> │ │ │ ├─────29,232 B (00.03%) ── Margin
> │ │ │ ├─────21,824 B (00.02%) ── sundries
> │ │ │ ├─────20,080 B (00.02%) ── Color
> │ │ │ ├─────20,080 B (00.02%) ── Column
> │ │ │ └─────10,320 B (00.01%) ── Effects
> │ │ ├───2,227,680 B (02.14%) -- computed-values
> │ │ │ ├──1,182,928 B (01.14%) ── non-dom
> │ │ │ └──1,044,752 B (01.00%) ── dom
> │ │ ├───1,500,016 B (01.44%) ── text-runs
> │ │ ├─────492,640 B (00.47%) ── line-boxes
> │ │ ├─────326,688 B (00.31%) ── frame-properties
> │ │ ├─────301,760 B (00.29%) ── pres-shell
> │ │ ├──────27,648 B (00.03%) ── pres-contexts
> │ │ └─────────176 B (00.00%) ── style-sets
The 'servo-style-structs' and 'computed-values' sub-trees are new. (Prior to
this patch, ComputedValues under DOM elements were tallied under the the
'dom/element-nodes' sub-tree, and ComputedValues not under DOM element were
ignored.) 'servo-style-structs/sundries' aggregates all the style structs that
are smaller than 8 KiB.
Other notable things done by the patch are as follows.
- It significantly changes the signatures of the methods measuring nsINode and
its subclasses, in order to handle the tallying of style structs separately
from element-nodes. Likewise for nsIFrame.
- It renames the 'layout/style-structs' sub-tree as
'layout/gecko-style-structs', to clearly distinguish it from the new
'layout/servo-style-structs' sub-tree.
- It adds some FFI functions to access various Rust-side data structures from
C++ code.
- There is a nasty hack used twice to measure Arcs, by stepping backwards from
an interior pointer to a base pointer. It works, but I want to replace it
with something better eventually. The "XXX WARNING" comments have details.
- It makes DMD print a line to the console if it sees a pointer it doesn't
recognise. This is useful for detecting when we are measuring an interior
pointer instead of a base pointer, which is bad but easy to do when Arcs are
involved.
- It removes the Rust code for measuring CVs, because it's now all done on the
C++ side.
MozReview-Commit-ID: BKebACLKtCi
--HG--
extra : rebase_source : 4d9a8c6b198a0ff025b811759a6bfa9f33a260ba
2017-08-11 09:37:33 +03:00
|
|
|
// that it needs to measure; any sub-class that doesn't use it will inherit
|
|
|
|
// AddSizeOfExcludingThis from its super-class. AddSizeOfIncludingThis() need
|
|
|
|
// not be defined, it is inherited from nsINode.
|
|
|
|
#define NS_DECL_ADDSIZEOFEXCLUDINGTHIS \
|
2017-08-25 07:47:54 +03:00
|
|
|
virtual void AddSizeOfExcludingThis(nsWindowSizes& aSizes, \
|
Bug 1387956 - Overhaul ComputedValues measurement, and add style structs measurement. r=bholley.
This patch moves measurement of ComputedValues objects from Rust to C++.
Measurement now happens (a) via DOM elements and (b) remaining elements via
the frame tree. Likewise for the style structs hanging off ComputedValues
objects.
Here is an example of the output.
> ├──27,600,448 B (26.49%) -- active/window(https://en.wikipedia.org/wiki/Barack_Obama)
> │ ├──12,772,544 B (12.26%) -- layout
> │ │ ├───4,483,744 B (04.30%) -- frames
> │ │ │ ├──1,653,552 B (01.59%) ── nsInlineFrame
> │ │ │ ├──1,415,760 B (01.36%) ── nsTextFrame
> │ │ │ ├────431,376 B (00.41%) ── nsBlockFrame
> │ │ │ ├────340,560 B (00.33%) ── nsHTMLScrollFrame
> │ │ │ ├────302,544 B (00.29%) ── nsContinuingTextFrame
> │ │ │ ├────156,408 B (00.15%) ── nsBulletFrame
> │ │ │ ├─────73,024 B (00.07%) ── nsPlaceholderFrame
> │ │ │ ├─────27,656 B (00.03%) ── sundries
> │ │ │ ├─────23,520 B (00.02%) ── nsTableCellFrame
> │ │ │ ├─────16,704 B (00.02%) ── nsImageFrame
> │ │ │ ├─────15,488 B (00.01%) ── nsTableRowFrame
> │ │ │ ├─────13,776 B (00.01%) ── nsTableColFrame
> │ │ │ └─────13,376 B (00.01%) ── nsTableFrame
> │ │ ├───3,412,192 B (03.28%) -- servo-style-structs
> │ │ │ ├──1,288,224 B (01.24%) ── Display
> │ │ │ ├────742,400 B (00.71%) ── Position
> │ │ │ ├────308,736 B (00.30%) ── Font
> │ │ │ ├────226,512 B (00.22%) ── Background
> │ │ │ ├────218,304 B (00.21%) ── TextReset
> │ │ │ ├────214,896 B (00.21%) ── Text
> │ │ │ ├────130,560 B (00.13%) ── Border
> │ │ │ ├─────81,408 B (00.08%) ── UIReset
> │ │ │ ├─────61,440 B (00.06%) ── Padding
> │ │ │ ├─────38,176 B (00.04%) ── UserInterface
> │ │ │ ├─────29,232 B (00.03%) ── Margin
> │ │ │ ├─────21,824 B (00.02%) ── sundries
> │ │ │ ├─────20,080 B (00.02%) ── Color
> │ │ │ ├─────20,080 B (00.02%) ── Column
> │ │ │ └─────10,320 B (00.01%) ── Effects
> │ │ ├───2,227,680 B (02.14%) -- computed-values
> │ │ │ ├──1,182,928 B (01.14%) ── non-dom
> │ │ │ └──1,044,752 B (01.00%) ── dom
> │ │ ├───1,500,016 B (01.44%) ── text-runs
> │ │ ├─────492,640 B (00.47%) ── line-boxes
> │ │ ├─────326,688 B (00.31%) ── frame-properties
> │ │ ├─────301,760 B (00.29%) ── pres-shell
> │ │ ├──────27,648 B (00.03%) ── pres-contexts
> │ │ └─────────176 B (00.00%) ── style-sets
The 'servo-style-structs' and 'computed-values' sub-trees are new. (Prior to
this patch, ComputedValues under DOM elements were tallied under the the
'dom/element-nodes' sub-tree, and ComputedValues not under DOM element were
ignored.) 'servo-style-structs/sundries' aggregates all the style structs that
are smaller than 8 KiB.
Other notable things done by the patch are as follows.
- It significantly changes the signatures of the methods measuring nsINode and
its subclasses, in order to handle the tallying of style structs separately
from element-nodes. Likewise for nsIFrame.
- It renames the 'layout/style-structs' sub-tree as
'layout/gecko-style-structs', to clearly distinguish it from the new
'layout/servo-style-structs' sub-tree.
- It adds some FFI functions to access various Rust-side data structures from
C++ code.
- There is a nasty hack used twice to measure Arcs, by stepping backwards from
an interior pointer to a base pointer. It works, but I want to replace it
with something better eventually. The "XXX WARNING" comments have details.
- It makes DMD print a line to the console if it sees a pointer it doesn't
recognise. This is useful for detecting when we are measuring an interior
pointer instead of a base pointer, which is bad but easy to do when Arcs are
involved.
- It removes the Rust code for measuring CVs, because it's now all done on the
C++ side.
MozReview-Commit-ID: BKebACLKtCi
--HG--
extra : rebase_source : 4d9a8c6b198a0ff025b811759a6bfa9f33a260ba
2017-08-11 09:37:33 +03:00
|
|
|
size_t* aNodeSize) const override;
|
2014-03-05 03:39:42 +04:00
|
|
|
|
2006-01-19 06:34:18 +03:00
|
|
|
// IID for the nsINode interface
|
2018-01-05 01:32:15 +03:00
|
|
|
// Must be kept in sync with xpcom/rust/xpcom/src/interfaces/nonidl.rs
|
2006-01-19 06:34:18 +03:00
|
|
|
#define NS_INODE_IID \
|
2018-11-30 13:46:48 +03:00
|
|
|
{ \
|
2015-09-17 13:16:20 +03:00
|
|
|
0x70ba4547, 0x7699, 0x44fc, { \
|
|
|
|
0xb3, 0x20, 0x52, 0xdb, 0xe3, 0xd1, 0xf9, 0x0a \
|
|
|
|
} \
|
|
|
|
}
|
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
|
2019-01-02 16:05:23 +03:00
|
|
|
* nsIContent and Document share. An instance of this interface has a list
|
2006-01-19 06:34:18 +03:00
|
|
|
* of nsIContent children and provides access to them.
|
|
|
|
*/
|
2012-12-07 05:39:51 +04:00
|
|
|
class nsINode : public mozilla::dom::EventTarget {
|
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;
|
2017-11-27 11:10:27 +03:00
|
|
|
typedef mozilla::dom::DocGroup DocGroup;
|
2019-01-02 16:05:23 +03:00
|
|
|
typedef mozilla::dom::Document Document;
|
2014-03-12 05:11:39 +04:00
|
|
|
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;
|
2016-04-12 05:48:14 +03:00
|
|
|
typedef mozilla::dom::OwningNodeOrString OwningNodeOrString;
|
2014-03-12 05:11:39 +04:00
|
|
|
typedef mozilla::dom::TextOrElementOrDocument TextOrElementOrDocument;
|
2017-02-01 23:43:36 +03:00
|
|
|
typedef mozilla::dom::CallerType CallerType;
|
2014-03-12 05:11:38 +04:00
|
|
|
typedef mozilla::ErrorResult ErrorResult;
|
|
|
|
|
2018-01-30 07:10:53 +03:00
|
|
|
// XXXbz Maybe we should codegen a class holding these constants and
|
|
|
|
// inherit from it...
|
2018-06-26 00:20:54 +03:00
|
|
|
static const auto ELEMENT_NODE = mozilla::dom::Node_Binding::ELEMENT_NODE;
|
|
|
|
static const auto ATTRIBUTE_NODE = mozilla::dom::Node_Binding::ATTRIBUTE_NODE;
|
|
|
|
static const auto TEXT_NODE = mozilla::dom::Node_Binding::TEXT_NODE;
|
2018-01-30 07:10:53 +03:00
|
|
|
static const auto CDATA_SECTION_NODE =
|
2018-06-26 00:20:54 +03:00
|
|
|
mozilla::dom::Node_Binding::CDATA_SECTION_NODE;
|
2018-01-30 07:10:53 +03:00
|
|
|
static const auto ENTITY_REFERENCE_NODE =
|
2018-06-26 00:20:54 +03:00
|
|
|
mozilla::dom::Node_Binding::ENTITY_REFERENCE_NODE;
|
|
|
|
static const auto ENTITY_NODE = mozilla::dom::Node_Binding::ENTITY_NODE;
|
2018-01-30 07:10:53 +03:00
|
|
|
static const auto PROCESSING_INSTRUCTION_NODE =
|
2018-06-26 00:20:54 +03:00
|
|
|
mozilla::dom::Node_Binding::PROCESSING_INSTRUCTION_NODE;
|
|
|
|
static const auto COMMENT_NODE = mozilla::dom::Node_Binding::COMMENT_NODE;
|
|
|
|
static const auto DOCUMENT_NODE = mozilla::dom::Node_Binding::DOCUMENT_NODE;
|
2018-01-30 07:10:53 +03:00
|
|
|
static const auto DOCUMENT_TYPE_NODE =
|
2018-06-26 00:20:54 +03:00
|
|
|
mozilla::dom::Node_Binding::DOCUMENT_TYPE_NODE;
|
2018-01-30 07:10:53 +03:00
|
|
|
static const auto DOCUMENT_FRAGMENT_NODE =
|
2018-06-26 00:20:54 +03:00
|
|
|
mozilla::dom::Node_Binding::DOCUMENT_FRAGMENT_NODE;
|
|
|
|
static const auto NOTATION_NODE = mozilla::dom::Node_Binding::NOTATION_NODE;
|
2018-01-30 07:10:53 +03:00
|
|
|
|
2016-04-12 05:48:14 +03:00
|
|
|
template <class T>
|
|
|
|
using Sequence = mozilla::dom::Sequence<T>;
|
|
|
|
|
2008-01-04 14:24:41 +03:00
|
|
|
NS_DECLARE_STATIC_IID_ACCESSOR(NS_INODE_IID)
|
|
|
|
|
Bug 1387956 - Overhaul ComputedValues measurement, and add style structs measurement. r=bholley.
This patch moves measurement of ComputedValues objects from Rust to C++.
Measurement now happens (a) via DOM elements and (b) remaining elements via
the frame tree. Likewise for the style structs hanging off ComputedValues
objects.
Here is an example of the output.
> ├──27,600,448 B (26.49%) -- active/window(https://en.wikipedia.org/wiki/Barack_Obama)
> │ ├──12,772,544 B (12.26%) -- layout
> │ │ ├───4,483,744 B (04.30%) -- frames
> │ │ │ ├──1,653,552 B (01.59%) ── nsInlineFrame
> │ │ │ ├──1,415,760 B (01.36%) ── nsTextFrame
> │ │ │ ├────431,376 B (00.41%) ── nsBlockFrame
> │ │ │ ├────340,560 B (00.33%) ── nsHTMLScrollFrame
> │ │ │ ├────302,544 B (00.29%) ── nsContinuingTextFrame
> │ │ │ ├────156,408 B (00.15%) ── nsBulletFrame
> │ │ │ ├─────73,024 B (00.07%) ── nsPlaceholderFrame
> │ │ │ ├─────27,656 B (00.03%) ── sundries
> │ │ │ ├─────23,520 B (00.02%) ── nsTableCellFrame
> │ │ │ ├─────16,704 B (00.02%) ── nsImageFrame
> │ │ │ ├─────15,488 B (00.01%) ── nsTableRowFrame
> │ │ │ ├─────13,776 B (00.01%) ── nsTableColFrame
> │ │ │ └─────13,376 B (00.01%) ── nsTableFrame
> │ │ ├───3,412,192 B (03.28%) -- servo-style-structs
> │ │ │ ├──1,288,224 B (01.24%) ── Display
> │ │ │ ├────742,400 B (00.71%) ── Position
> │ │ │ ├────308,736 B (00.30%) ── Font
> │ │ │ ├────226,512 B (00.22%) ── Background
> │ │ │ ├────218,304 B (00.21%) ── TextReset
> │ │ │ ├────214,896 B (00.21%) ── Text
> │ │ │ ├────130,560 B (00.13%) ── Border
> │ │ │ ├─────81,408 B (00.08%) ── UIReset
> │ │ │ ├─────61,440 B (00.06%) ── Padding
> │ │ │ ├─────38,176 B (00.04%) ── UserInterface
> │ │ │ ├─────29,232 B (00.03%) ── Margin
> │ │ │ ├─────21,824 B (00.02%) ── sundries
> │ │ │ ├─────20,080 B (00.02%) ── Color
> │ │ │ ├─────20,080 B (00.02%) ── Column
> │ │ │ └─────10,320 B (00.01%) ── Effects
> │ │ ├───2,227,680 B (02.14%) -- computed-values
> │ │ │ ├──1,182,928 B (01.14%) ── non-dom
> │ │ │ └──1,044,752 B (01.00%) ── dom
> │ │ ├───1,500,016 B (01.44%) ── text-runs
> │ │ ├─────492,640 B (00.47%) ── line-boxes
> │ │ ├─────326,688 B (00.31%) ── frame-properties
> │ │ ├─────301,760 B (00.29%) ── pres-shell
> │ │ ├──────27,648 B (00.03%) ── pres-contexts
> │ │ └─────────176 B (00.00%) ── style-sets
The 'servo-style-structs' and 'computed-values' sub-trees are new. (Prior to
this patch, ComputedValues under DOM elements were tallied under the the
'dom/element-nodes' sub-tree, and ComputedValues not under DOM element were
ignored.) 'servo-style-structs/sundries' aggregates all the style structs that
are smaller than 8 KiB.
Other notable things done by the patch are as follows.
- It significantly changes the signatures of the methods measuring nsINode and
its subclasses, in order to handle the tallying of style structs separately
from element-nodes. Likewise for nsIFrame.
- It renames the 'layout/style-structs' sub-tree as
'layout/gecko-style-structs', to clearly distinguish it from the new
'layout/servo-style-structs' sub-tree.
- It adds some FFI functions to access various Rust-side data structures from
C++ code.
- There is a nasty hack used twice to measure Arcs, by stepping backwards from
an interior pointer to a base pointer. It works, but I want to replace it
with something better eventually. The "XXX WARNING" comments have details.
- It makes DMD print a line to the console if it sees a pointer it doesn't
recognise. This is useful for detecting when we are measuring an interior
pointer instead of a base pointer, which is bad but easy to do when Arcs are
involved.
- It removes the Rust code for measuring CVs, because it's now all done on the
C++ side.
MozReview-Commit-ID: BKebACLKtCi
--HG--
extra : rebase_source : 4d9a8c6b198a0ff025b811759a6bfa9f33a260ba
2017-08-11 09:37:33 +03:00
|
|
|
// The |aNodeSize| outparam on this function is where the actual node size
|
|
|
|
// value is put. It gets added to the appropriate value within |aSizes| by
|
2017-08-15 04:12:40 +03:00
|
|
|
// AddSizeOfNodeTree().
|
Bug 1387956 - Overhaul ComputedValues measurement, and add style structs measurement. r=bholley.
This patch moves measurement of ComputedValues objects from Rust to C++.
Measurement now happens (a) via DOM elements and (b) remaining elements via
the frame tree. Likewise for the style structs hanging off ComputedValues
objects.
Here is an example of the output.
> ├──27,600,448 B (26.49%) -- active/window(https://en.wikipedia.org/wiki/Barack_Obama)
> │ ├──12,772,544 B (12.26%) -- layout
> │ │ ├───4,483,744 B (04.30%) -- frames
> │ │ │ ├──1,653,552 B (01.59%) ── nsInlineFrame
> │ │ │ ├──1,415,760 B (01.36%) ── nsTextFrame
> │ │ │ ├────431,376 B (00.41%) ── nsBlockFrame
> │ │ │ ├────340,560 B (00.33%) ── nsHTMLScrollFrame
> │ │ │ ├────302,544 B (00.29%) ── nsContinuingTextFrame
> │ │ │ ├────156,408 B (00.15%) ── nsBulletFrame
> │ │ │ ├─────73,024 B (00.07%) ── nsPlaceholderFrame
> │ │ │ ├─────27,656 B (00.03%) ── sundries
> │ │ │ ├─────23,520 B (00.02%) ── nsTableCellFrame
> │ │ │ ├─────16,704 B (00.02%) ── nsImageFrame
> │ │ │ ├─────15,488 B (00.01%) ── nsTableRowFrame
> │ │ │ ├─────13,776 B (00.01%) ── nsTableColFrame
> │ │ │ └─────13,376 B (00.01%) ── nsTableFrame
> │ │ ├───3,412,192 B (03.28%) -- servo-style-structs
> │ │ │ ├──1,288,224 B (01.24%) ── Display
> │ │ │ ├────742,400 B (00.71%) ── Position
> │ │ │ ├────308,736 B (00.30%) ── Font
> │ │ │ ├────226,512 B (00.22%) ── Background
> │ │ │ ├────218,304 B (00.21%) ── TextReset
> │ │ │ ├────214,896 B (00.21%) ── Text
> │ │ │ ├────130,560 B (00.13%) ── Border
> │ │ │ ├─────81,408 B (00.08%) ── UIReset
> │ │ │ ├─────61,440 B (00.06%) ── Padding
> │ │ │ ├─────38,176 B (00.04%) ── UserInterface
> │ │ │ ├─────29,232 B (00.03%) ── Margin
> │ │ │ ├─────21,824 B (00.02%) ── sundries
> │ │ │ ├─────20,080 B (00.02%) ── Color
> │ │ │ ├─────20,080 B (00.02%) ── Column
> │ │ │ └─────10,320 B (00.01%) ── Effects
> │ │ ├───2,227,680 B (02.14%) -- computed-values
> │ │ │ ├──1,182,928 B (01.14%) ── non-dom
> │ │ │ └──1,044,752 B (01.00%) ── dom
> │ │ ├───1,500,016 B (01.44%) ── text-runs
> │ │ ├─────492,640 B (00.47%) ── line-boxes
> │ │ ├─────326,688 B (00.31%) ── frame-properties
> │ │ ├─────301,760 B (00.29%) ── pres-shell
> │ │ ├──────27,648 B (00.03%) ── pres-contexts
> │ │ └─────────176 B (00.00%) ── style-sets
The 'servo-style-structs' and 'computed-values' sub-trees are new. (Prior to
this patch, ComputedValues under DOM elements were tallied under the the
'dom/element-nodes' sub-tree, and ComputedValues not under DOM element were
ignored.) 'servo-style-structs/sundries' aggregates all the style structs that
are smaller than 8 KiB.
Other notable things done by the patch are as follows.
- It significantly changes the signatures of the methods measuring nsINode and
its subclasses, in order to handle the tallying of style structs separately
from element-nodes. Likewise for nsIFrame.
- It renames the 'layout/style-structs' sub-tree as
'layout/gecko-style-structs', to clearly distinguish it from the new
'layout/servo-style-structs' sub-tree.
- It adds some FFI functions to access various Rust-side data structures from
C++ code.
- There is a nasty hack used twice to measure Arcs, by stepping backwards from
an interior pointer to a base pointer. It works, but I want to replace it
with something better eventually. The "XXX WARNING" comments have details.
- It makes DMD print a line to the console if it sees a pointer it doesn't
recognise. This is useful for detecting when we are measuring an interior
pointer instead of a base pointer, which is bad but easy to do when Arcs are
involved.
- It removes the Rust code for measuring CVs, because it's now all done on the
C++ side.
MozReview-Commit-ID: BKebACLKtCi
--HG--
extra : rebase_source : 4d9a8c6b198a0ff025b811759a6bfa9f33a260ba
2017-08-11 09:37:33 +03:00
|
|
|
//
|
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
|
|
|
|
//
|
2017-08-25 07:47:54 +03:00
|
|
|
virtual void AddSizeOfExcludingThis(nsWindowSizes& aSizes,
|
Bug 1387956 - Overhaul ComputedValues measurement, and add style structs measurement. r=bholley.
This patch moves measurement of ComputedValues objects from Rust to C++.
Measurement now happens (a) via DOM elements and (b) remaining elements via
the frame tree. Likewise for the style structs hanging off ComputedValues
objects.
Here is an example of the output.
> ├──27,600,448 B (26.49%) -- active/window(https://en.wikipedia.org/wiki/Barack_Obama)
> │ ├──12,772,544 B (12.26%) -- layout
> │ │ ├───4,483,744 B (04.30%) -- frames
> │ │ │ ├──1,653,552 B (01.59%) ── nsInlineFrame
> │ │ │ ├──1,415,760 B (01.36%) ── nsTextFrame
> │ │ │ ├────431,376 B (00.41%) ── nsBlockFrame
> │ │ │ ├────340,560 B (00.33%) ── nsHTMLScrollFrame
> │ │ │ ├────302,544 B (00.29%) ── nsContinuingTextFrame
> │ │ │ ├────156,408 B (00.15%) ── nsBulletFrame
> │ │ │ ├─────73,024 B (00.07%) ── nsPlaceholderFrame
> │ │ │ ├─────27,656 B (00.03%) ── sundries
> │ │ │ ├─────23,520 B (00.02%) ── nsTableCellFrame
> │ │ │ ├─────16,704 B (00.02%) ── nsImageFrame
> │ │ │ ├─────15,488 B (00.01%) ── nsTableRowFrame
> │ │ │ ├─────13,776 B (00.01%) ── nsTableColFrame
> │ │ │ └─────13,376 B (00.01%) ── nsTableFrame
> │ │ ├───3,412,192 B (03.28%) -- servo-style-structs
> │ │ │ ├──1,288,224 B (01.24%) ── Display
> │ │ │ ├────742,400 B (00.71%) ── Position
> │ │ │ ├────308,736 B (00.30%) ── Font
> │ │ │ ├────226,512 B (00.22%) ── Background
> │ │ │ ├────218,304 B (00.21%) ── TextReset
> │ │ │ ├────214,896 B (00.21%) ── Text
> │ │ │ ├────130,560 B (00.13%) ── Border
> │ │ │ ├─────81,408 B (00.08%) ── UIReset
> │ │ │ ├─────61,440 B (00.06%) ── Padding
> │ │ │ ├─────38,176 B (00.04%) ── UserInterface
> │ │ │ ├─────29,232 B (00.03%) ── Margin
> │ │ │ ├─────21,824 B (00.02%) ── sundries
> │ │ │ ├─────20,080 B (00.02%) ── Color
> │ │ │ ├─────20,080 B (00.02%) ── Column
> │ │ │ └─────10,320 B (00.01%) ── Effects
> │ │ ├───2,227,680 B (02.14%) -- computed-values
> │ │ │ ├──1,182,928 B (01.14%) ── non-dom
> │ │ │ └──1,044,752 B (01.00%) ── dom
> │ │ ├───1,500,016 B (01.44%) ── text-runs
> │ │ ├─────492,640 B (00.47%) ── line-boxes
> │ │ ├─────326,688 B (00.31%) ── frame-properties
> │ │ ├─────301,760 B (00.29%) ── pres-shell
> │ │ ├──────27,648 B (00.03%) ── pres-contexts
> │ │ └─────────176 B (00.00%) ── style-sets
The 'servo-style-structs' and 'computed-values' sub-trees are new. (Prior to
this patch, ComputedValues under DOM elements were tallied under the the
'dom/element-nodes' sub-tree, and ComputedValues not under DOM element were
ignored.) 'servo-style-structs/sundries' aggregates all the style structs that
are smaller than 8 KiB.
Other notable things done by the patch are as follows.
- It significantly changes the signatures of the methods measuring nsINode and
its subclasses, in order to handle the tallying of style structs separately
from element-nodes. Likewise for nsIFrame.
- It renames the 'layout/style-structs' sub-tree as
'layout/gecko-style-structs', to clearly distinguish it from the new
'layout/servo-style-structs' sub-tree.
- It adds some FFI functions to access various Rust-side data structures from
C++ code.
- There is a nasty hack used twice to measure Arcs, by stepping backwards from
an interior pointer to a base pointer. It works, but I want to replace it
with something better eventually. The "XXX WARNING" comments have details.
- It makes DMD print a line to the console if it sees a pointer it doesn't
recognise. This is useful for detecting when we are measuring an interior
pointer instead of a base pointer, which is bad but easy to do when Arcs are
involved.
- It removes the Rust code for measuring CVs, because it's now all done on the
C++ side.
MozReview-Commit-ID: BKebACLKtCi
--HG--
extra : rebase_source : 4d9a8c6b198a0ff025b811759a6bfa9f33a260ba
2017-08-11 09:37:33 +03:00
|
|
|
size_t* aNodeSize) 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
|
2017-08-25 07:47:54 +03:00
|
|
|
// methods of nsINode's sub-classes, so aSizes.mState.mMallocSizeOf(this) is
|
|
|
|
// always safe to call no matter which object it was invoked on.
|
2018-03-28 02:44:49 +03:00
|
|
|
void AddSizeOfIncludingThis(nsWindowSizes& aSizes, size_t* aNodeSize) const;
|
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;
|
2018-08-07 22:07:26 +03:00
|
|
|
friend class AttrArray;
|
2006-07-02 11:23:10 +04:00
|
|
|
|
2006-08-31 23:59:43 +04:00
|
|
|
#ifdef MOZILLA_INTERNAL_API
|
2018-09-21 23:45:49 +03:00
|
|
|
explicit nsINode(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
|
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 {
|
|
|
|
/** form control elements */
|
2010-04-30 17:12:06 +04:00
|
|
|
eHTML_FORM_CONTROL = 1 << 6,
|
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 */
|
2018-03-13 22:52:03 +03:00
|
|
|
eFILTER = 1 << 11,
|
|
|
|
/** SVGGeometryElement */
|
|
|
|
eSHAPE = 1 << 12
|
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
|
|
|
|
2018-04-15 12:39:50 +03:00
|
|
|
bool IsContainerNode() const {
|
2018-04-24 18:57:21 +03:00
|
|
|
return IsElement() || IsDocument() || IsDocumentFragment();
|
2017-08-18 01:05:40 +03:00
|
|
|
}
|
|
|
|
|
2018-04-13 01:41:00 +03:00
|
|
|
bool IsSlotable() const { return IsElement() || IsText(); }
|
2017-12-04 11:06:34 +03:00
|
|
|
|
2018-04-15 12:39:50 +03:00
|
|
|
/**
|
|
|
|
* Returns true if this is a document node.
|
|
|
|
*/
|
|
|
|
bool IsDocument() const {
|
2018-04-20 04:56:02 +03:00
|
|
|
// One less pointer-chase than checking NodeType().
|
2018-04-15 12:39:50 +03:00
|
|
|
return !GetParentNode() && IsInUncomposedDoc();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return this node as a document. Asserts IsDocument().
|
|
|
|
*
|
2019-01-02 16:05:23 +03:00
|
|
|
* This is defined inline in Document.h.
|
2018-04-15 12:39:50 +03:00
|
|
|
*/
|
2019-01-02 16:05:23 +03:00
|
|
|
inline Document* AsDocument();
|
|
|
|
inline const Document* AsDocument() const;
|
2018-04-15 12:39:50 +03:00
|
|
|
|
2018-04-15 13:08:36 +03:00
|
|
|
/**
|
|
|
|
* Returns true if this is a document fragment node.
|
|
|
|
*/
|
|
|
|
bool IsDocumentFragment() const {
|
|
|
|
return NodeType() == DOCUMENT_FRAGMENT_NODE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return this node as a document fragment. Asserts IsDocumentFragment().
|
|
|
|
*
|
|
|
|
* This is defined inline in DocumentFragment.h.
|
|
|
|
*/
|
|
|
|
inline mozilla::dom::DocumentFragment* AsDocumentFragment();
|
|
|
|
inline const mozilla::dom::DocumentFragment* AsDocumentFragment() const;
|
|
|
|
|
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
|
|
|
|
2018-07-07 02:52:42 +03:00
|
|
|
/**
|
|
|
|
* Hook for constructing JS::ubi::Concrete specializations for memory
|
|
|
|
* reporting. Specializations are defined in NodeUbiReporting.h.
|
|
|
|
*/
|
|
|
|
virtual void ConstructUbiNode(void* storage) = 0;
|
|
|
|
|
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()
|
2019-01-02 16:05:23 +03:00
|
|
|
const; // Implemented in Document.h
|
2014-03-19 20:35:45 +04:00
|
|
|
|
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;
|
|
|
|
|
2019-02-02 01:29:34 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT mozilla::dom::Element* GetParentFlexElement();
|
|
|
|
|
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
|
|
|
*/
|
2018-04-15 12:37:22 +03:00
|
|
|
inline mozilla::dom::Element* AsElement();
|
|
|
|
inline 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.
|
|
|
|
*/
|
2018-04-15 12:37:22 +03:00
|
|
|
inline nsIContent* AsContent();
|
|
|
|
inline const nsIContent* AsContent() const;
|
2012-06-10 16:39:21 +04:00
|
|
|
|
2018-03-19 22:15:37 +03:00
|
|
|
/*
|
|
|
|
* Return whether the node is a Text node (which might be an actual
|
|
|
|
* textnode, or might be a CDATA section).
|
|
|
|
*/
|
|
|
|
bool IsText() const {
|
|
|
|
uint32_t nodeType = NodeType();
|
|
|
|
return nodeType == TEXT_NODE || nodeType == CDATA_SECTION_NODE;
|
|
|
|
}
|
|
|
|
|
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.
|
|
|
|
*/
|
2018-04-15 12:37:22 +03:00
|
|
|
inline mozilla::dom::Text* GetAsText();
|
|
|
|
inline const mozilla::dom::Text* GetAsText() const;
|
2014-08-13 15:53:32 +04:00
|
|
|
|
2018-03-29 01:01:46 +03:00
|
|
|
/**
|
|
|
|
* Return this node as Text. Asserts IsText(). This is defined inline in
|
|
|
|
* Text.h.
|
|
|
|
*/
|
2018-04-15 12:37:22 +03:00
|
|
|
inline mozilla::dom::Text* AsText();
|
|
|
|
inline const mozilla::dom::Text* AsText() const;
|
2018-03-29 01:01:46 +03:00
|
|
|
|
2018-03-19 22:15:39 +03:00
|
|
|
/*
|
|
|
|
* Return whether the node is a ProcessingInstruction node.
|
|
|
|
*/
|
|
|
|
bool IsProcessingInstruction() const {
|
|
|
|
return NodeType() == PROCESSING_INSTRUCTION_NODE;
|
|
|
|
}
|
|
|
|
|
2018-03-19 22:18:07 +03:00
|
|
|
/*
|
|
|
|
* Return whether the node is a CharacterData node (text, cdata,
|
|
|
|
* comment, processing instruction)
|
|
|
|
*/
|
|
|
|
bool IsCharacterData() const {
|
|
|
|
uint32_t nodeType = NodeType();
|
|
|
|
return nodeType == TEXT_NODE || nodeType == CDATA_SECTION_NODE ||
|
|
|
|
nodeType == PROCESSING_INSTRUCTION_NODE || nodeType == COMMENT_NODE;
|
|
|
|
}
|
|
|
|
|
2018-04-15 15:58:49 +03:00
|
|
|
/**
|
|
|
|
* Return whether the node is a Comment node.
|
|
|
|
*/
|
|
|
|
bool IsComment() const { return NodeType() == COMMENT_NODE; }
|
|
|
|
|
2018-04-15 16:12:02 +03:00
|
|
|
/**
|
|
|
|
* Return whether the node is an Attr node.
|
|
|
|
*/
|
|
|
|
bool IsAttr() const { return NodeType() == ATTRIBUTE_NODE; }
|
|
|
|
|
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
|
|
|
|
*/
|
2018-08-06 22:29:27 +03:00
|
|
|
uint32_t GetChildCount() const { return mChildCount; }
|
2006-01-19 06:34:18 +03:00
|
|
|
|
|
|
|
/**
|
2018-01-03 15:59:54 +03:00
|
|
|
* NOTE: this function is going to be removed soon (hopefully!) Don't use it
|
|
|
|
* in new code.
|
|
|
|
*
|
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
|
|
|
|
*/
|
2018-08-06 22:29:27 +03:00
|
|
|
nsIContent* GetChildAt_Deprecated(uint32_t aIndex) const;
|
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
|
|
|
|
*
|
2018-01-03 15:59:54 +03:00
|
|
|
* If the return value is not -1, then calling GetChildAt_Deprecated() with
|
|
|
|
* that value will return aPossibleChild.
|
2006-01-19 06:34:18 +03:00
|
|
|
*/
|
2018-08-06 22:29:27 +03:00
|
|
|
virtual int32_t ComputeIndexOf(const nsINode* aPossibleChild) const;
|
2006-01-19 06:34:18 +03:00
|
|
|
|
|
|
|
/**
|
2015-10-02 19:16:49 +03:00
|
|
|
* Returns the "node document" of this node.
|
|
|
|
*
|
|
|
|
* https://dom.spec.whatwg.org/#concept-node-document
|
|
|
|
*
|
|
|
|
* Note that in the case that this node is a document node this method
|
|
|
|
* will return |this|. That is different to the Node.ownerDocument DOM
|
|
|
|
* attribute (implemented by nsINode::GetOwnerDocument) which is specified to
|
|
|
|
* be null in that case:
|
|
|
|
*
|
|
|
|
* https://dom.spec.whatwg.org/#dom-node-ownerdocument
|
|
|
|
*
|
2016-03-01 02:46:51 +03:00
|
|
|
* For all other cases OwnerDoc and GetOwnerDocument behave identically.
|
2006-01-19 06:34:18 +03:00
|
|
|
*/
|
2019-01-02 16:05:23 +03:00
|
|
|
Document* OwnerDoc() const { return mNodeInfo->GetDocument(); }
|
2006-01-19 06:34:18 +03:00
|
|
|
|
2012-03-15 00:14:02 +04:00
|
|
|
/**
|
|
|
|
* Return the "owner document" of this node as an nsINode*. Implemented
|
2019-01-02 16:05:23 +03:00
|
|
|
* in Document.h.
|
2012-03-15 00:14:02 +04:00
|
|
|
*/
|
Bug 1440258: Flag doc level anonymous content instead of guessing. r=bholley
Poking at the frame tree has problems: If we poke in negative (using
eSkipNativeAnonymousContent), as we were doing, we mess up the case where we're
actually _not_ doc-level, and _not_ ::before or ::after. This can't happen for
content documents, but can happen for chrome (since nsDocElementBoxFrame
implements nsIAnonymousContentCreator).
If we poke in positive, as we used to, you get that right, but mess up the
root scrollbar case.
Instead, use a node property to mark doc level anon content. This is a case rare
enough that it seems worth to not steal a node bit.
To recap the failure:
* The initial value of -moz-control-character-visiblity is different on beta
and nightly.
* XUL has a global rule setting -moz-control-character-visibility on the root,
to a value so that it's the initial one on nightly, but the non-initial one
on beta.
* Changes to this property cause a reframe.
* Reframes of a nsIAnonymousContentCreator anon content reframe the container.
* We were failing to inherit correctly for the nsIAnonymousContentCreator
content for the root XUL element on the initial styling, inheriting from the
default computed values instead, since we failed to reach the root element's
primary frame from GetFlattenedTreeParentForDocumentElementNAC ->
AppendDocumentLevelNativeAnonymousContentTo, since the primary frame is set
_after_ processing children.
This seems somewhat risky to change, and inconsistent with any other stuff
the frame constructor does, see bug 973390.
* Given that, the next restyle of the root element, in this case caused due to
the customizable UI, we _found_ the actual correct parent, recomputed the
style, saw that -moz-control-character-visiblity had changed, and reframed.
But we were reframing the whole window, not just the NAC, because of the
fourth bullet point. Reframing the whole window caused us to lose the popup
state (that's bug 1440506).
Worse than that is the fact that given we reframe and reconstruct the
anonymous countent again, we go back to the initial bogus state, just
awaiting for the next restyle to reframe the whole window.
I wish there was a bullet-proof way to test it that isn't just counting reframes
and relying on which properties reframe or not, but due to the nature of
nsIAnonymousContentCreator's NAC, it's not possible in any easy way I can think
of.
MozReview-Commit-ID: IPYB5trsN8R
2018-02-23 04:30:00 +03:00
|
|
|
inline 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
|
|
|
|
*/
|
2011-04-08 06:29:49 +04:00
|
|
|
bool IsInUncomposedDoc() const { return GetBoolFlag(IsInDocument); }
|
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
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
Document* GetUncomposedDoc() const {
|
2014-07-03 21:02:07 +04:00
|
|
|
return IsInUncomposedDoc() ? OwnerDoc() : nullptr;
|
|
|
|
}
|
|
|
|
|
2018-08-20 14:56:27 +03:00
|
|
|
/**
|
|
|
|
* Returns true if we're connected, and thus GetComposedDoc() would return a
|
|
|
|
* non-null value.
|
|
|
|
*/
|
|
|
|
bool IsInComposedDoc() const { return GetBoolFlag(IsConnected); }
|
|
|
|
|
2014-06-07 12:42:53 +04:00
|
|
|
/**
|
2018-03-28 19:51:14 +03:00
|
|
|
* This method returns the owner document if the node is connected to it
|
|
|
|
* (as defined in the DOM spec), otherwise it returns null.
|
|
|
|
* In other words, returns non-null even in the case the node is in
|
|
|
|
* Shadow DOM, if there is a possibly shadow boundary crossing path from
|
|
|
|
* the node to its owner document.
|
2014-06-07 12:42:53 +04:00
|
|
|
*/
|
2019-01-02 16:05:23 +03:00
|
|
|
Document* GetComposedDoc() const {
|
2018-08-20 14:56:27 +03:00
|
|
|
return IsInComposedDoc() ? OwnerDoc() : nullptr;
|
2014-06-07 12:42:53 +04:00
|
|
|
}
|
|
|
|
|
2018-05-18 20:02:14 +03:00
|
|
|
/**
|
|
|
|
* Returns OwnerDoc() if the node is in uncomposed document and ShadowRoot if
|
|
|
|
* the node is in Shadow DOM and is in composed document.
|
|
|
|
*/
|
2018-05-24 22:46:11 +03:00
|
|
|
mozilla::dom::DocumentOrShadowRoot* GetUncomposedDocOrConnectedShadowRoot()
|
|
|
|
const;
|
2018-05-18 20:02:14 +03:00
|
|
|
|
2011-06-14 11:56:49 +04:00
|
|
|
/**
|
|
|
|
* The values returned by this function are the ones defined for
|
2018-05-30 05:58:51 +03:00
|
|
|
* Node.nodeType
|
2011-06-14 11:56:49 +04:00
|
|
|
*/
|
|
|
|
uint16_t NodeType() const { 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;
|
|
|
|
}
|
|
|
|
|
2017-11-27 11:10:27 +03:00
|
|
|
/**
|
|
|
|
* Returns the DocGroup of the "node document" of this node.
|
|
|
|
*/
|
|
|
|
DocGroup* GetDocGroup() const;
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2018-11-13 15:48:21 +03:00
|
|
|
inline bool IsHTMLElement(const nsAtom* aTag) const {
|
2015-03-03 14:08:59 +03:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2018-11-13 15:48:21 +03:00
|
|
|
inline bool IsSVGElement(const nsAtom* aTag) const {
|
2015-03-03 14:08:59 +03:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2018-11-13 15:48:21 +03:00
|
|
|
inline bool IsXULElement(const nsAtom* aTag) const {
|
2015-03-03 14:08:59 +03:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2018-11-13 15:48:21 +03:00
|
|
|
inline bool IsMathMLElement(const nsAtom* aTag) const {
|
2015-03-03 14:08:59 +03:00
|
|
|
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...);
|
|
|
|
}
|
|
|
|
|
2017-12-31 22:57:32 +03:00
|
|
|
bool IsShadowRoot() const {
|
|
|
|
const bool isShadowRoot = IsInShadowTree() && !GetParentNode();
|
2018-04-15 13:08:36 +03:00
|
|
|
MOZ_ASSERT_IF(isShadowRoot, IsDocumentFragment());
|
2017-12-31 22:57:32 +03:00
|
|
|
return isShadowRoot;
|
|
|
|
}
|
|
|
|
|
2018-01-25 17:59:42 +03:00
|
|
|
/**
|
|
|
|
* Insert a content node before another or at the end.
|
|
|
|
* This method handles calling BindToTree on the child appropriately.
|
|
|
|
*
|
|
|
|
* @param aKid the content to insert
|
|
|
|
* @param aBeforeThis an existing node. Use nullptr if you want to
|
|
|
|
* add aKid at the end.
|
|
|
|
* @param aNotify whether to notify the document (current document for
|
2019-01-02 16:05:23 +03:00
|
|
|
* nsIContent, and |this| for Document) that the insert has occurred
|
2018-01-25 17:59:42 +03:00
|
|
|
*
|
|
|
|
* @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
|
2019-01-02 16:05:23 +03:00
|
|
|
* assert -- you shouldn't be doing it! Check with Document::GetRootElement()
|
|
|
|
* first if you're not sure. Apart from this one constraint, this doesn't do
|
|
|
|
* any checking on whether aKid is a valid child of |this|.
|
2018-01-25 17:59:42 +03:00
|
|
|
*
|
|
|
|
* @throws NS_ERROR_OUT_OF_MEMORY in some cases (from BindToTree).
|
|
|
|
*/
|
|
|
|
virtual nsresult InsertChildBefore(nsIContent* aKid, nsIContent* aBeforeThis,
|
2018-08-06 22:29:27 +03:00
|
|
|
bool aNotify);
|
2018-01-25 17:59:42 +03:00
|
|
|
|
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
|
2019-01-02 16:05:23 +03:00
|
|
|
* nsIContent, and |this| for Document) that the append has occurred
|
2006-01-19 06:34:18 +03:00
|
|
|
*
|
|
|
|
* @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
|
2019-01-02 16:05:23 +03:00
|
|
|
* assert -- you shouldn't be doing it! Check with Document::GetRootElement()
|
|
|
|
* first if you're not sure. Apart from this one constraint, this doesn't do
|
|
|
|
* any checking on whether aKid is a valid child of |this|.
|
2006-01-19 06:34:18 +03:00
|
|
|
*
|
|
|
|
* @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) {
|
2018-06-19 12:21:18 +03:00
|
|
|
return InsertChildBefore(aKid, nullptr, aNotify);
|
2006-08-01 02:38:07 +04:00
|
|
|
}
|
2016-03-25 13:23:53 +03:00
|
|
|
|
2018-01-15 19:18:38 +03:00
|
|
|
/**
|
|
|
|
* Remove a child from this node. This method handles calling UnbindFromTree
|
|
|
|
* on the child appropriately.
|
|
|
|
*
|
|
|
|
* @param aKid the content to remove
|
|
|
|
* @param aNotify whether to notify the document (current document for
|
2019-01-02 16:05:23 +03:00
|
|
|
* nsIContent, and |this| for Document) that the remove has occurred
|
2018-01-15 19:18:38 +03:00
|
|
|
*/
|
2018-08-06 22:29:27 +03:00
|
|
|
virtual void RemoveChildNode(nsIContent* aKid, bool aNotify);
|
2018-01-15 19:18:38 +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).
|
|
|
|
*/
|
2018-11-13 15:48:21 +03:00
|
|
|
void* GetProperty(const nsAtom* aPropertyName,
|
|
|
|
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
|
|
|
|
*/
|
2018-03-17 07:30:49 +03:00
|
|
|
nsresult SetProperty(nsAtom* aPropertyName, void* aValue,
|
2012-07-30 18:20:58 +04:00
|
|
|
NSPropertyDtorFunc aDtor = nullptr,
|
2018-03-17 07:30:49 +03:00
|
|
|
bool aTransfer = false);
|
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>
|
2018-03-17 07:30:49 +03:00
|
|
|
static void DeleteProperty(void*, nsAtom*, void* aPropertyValue, void*) {
|
2014-03-25 17:25:47 +04:00
|
|
|
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.
|
|
|
|
*/
|
2018-11-13 15:48:21 +03:00
|
|
|
void DeleteProperty(const nsAtom* 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).
|
|
|
|
*/
|
2018-11-13 15:48:21 +03:00
|
|
|
void* UnsetProperty(const nsAtom* aPropertyName, nsresult* aStatus = nullptr);
|
2016-03-25 13:23:53 +03:00
|
|
|
|
2006-06-02 17:28:14 +04:00
|
|
|
bool HasProperties() const { 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
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-01-02 16:05:23 +03:00
|
|
|
* Get the parent nsINode for this node. This can be either an nsIContent, a
|
|
|
|
* Document or an Attr.
|
2006-04-15 09:09:16 +04:00
|
|
|
* @return the parent node
|
|
|
|
*/
|
2012-10-09 16:31:24 +04:00
|
|
|
nsINode* GetParentNode() const { return mParent; }
|
2016-03-25 13:23:53 +03:00
|
|
|
|
2018-03-06 03:34:40 +03:00
|
|
|
/**
|
|
|
|
* This is similar to above, but in case 'this' is ShadowRoot, we return its
|
|
|
|
* host element.
|
|
|
|
*/
|
|
|
|
nsINode* GetParentOrHostNode() const;
|
|
|
|
|
2017-12-31 22:57:32 +03:00
|
|
|
enum FlattenedParentType { eNotForStyle, eForStyle };
|
|
|
|
|
2016-08-19 03:03:49 +03:00
|
|
|
/**
|
|
|
|
* Returns the node that is the parent of this node in the flattened
|
|
|
|
* tree. This differs from the normal parent if the node is filtered
|
|
|
|
* into an insertion point, or if the node is a direct child of a
|
|
|
|
* shadow root.
|
|
|
|
*
|
|
|
|
* @return the flattened tree parent
|
|
|
|
*/
|
|
|
|
inline nsINode* GetFlattenedTreeParentNode() const;
|
|
|
|
|
2018-08-02 14:54:15 +03:00
|
|
|
nsINode* GetFlattenedTreeParentNodeNonInline() const;
|
|
|
|
|
2016-12-01 09:55:09 +03:00
|
|
|
/**
|
2017-12-31 22:57:32 +03:00
|
|
|
* Like GetFlattenedTreeParentNode, but returns the document for any native
|
|
|
|
* anonymous content that was generated for ancestor frames of the document
|
|
|
|
* element's primary frame, such as scrollbar elements created by the root
|
|
|
|
* scroll frame.
|
2016-12-01 09:55:09 +03:00
|
|
|
*/
|
|
|
|
inline nsINode* GetFlattenedTreeParentNodeForStyle() const;
|
|
|
|
|
2017-07-19 04:04:34 +03:00
|
|
|
inline mozilla::dom::Element* GetFlattenedTreeParentElement() const;
|
|
|
|
inline mozilla::dom::Element* GetFlattenedTreeParentElementForStyle() const;
|
|
|
|
|
2011-09-12 02:45:39 +04:00
|
|
|
/**
|
|
|
|
* Get the parent nsINode for this node if it is an Element.
|
2018-04-15 12:37:22 +03:00
|
|
|
*
|
|
|
|
* Defined inline in Element.h
|
|
|
|
*
|
2011-09-12 02:45:39 +04:00
|
|
|
* @return the parent node
|
|
|
|
*/
|
2018-04-15 12:37:22 +03:00
|
|
|
inline mozilla::dom::Element* GetParentElement() const;
|
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
|
|
|
|
2017-01-15 20:46:00 +03:00
|
|
|
/*
|
|
|
|
* Get context object's shadow-including root if options's composed is true,
|
|
|
|
* and context object's root otherwise.
|
|
|
|
*/
|
|
|
|
nsINode* GetRootNode(const mozilla::dom::GetRootNodeOptions& aOptions);
|
2016-03-16 04:49:10 +03:00
|
|
|
|
2014-03-17 10:56:53 +04:00
|
|
|
virtual mozilla::EventListenerManager* GetExistingListenerManager()
|
2015-03-21 19:28:04 +03:00
|
|
|
const override;
|
|
|
|
virtual mozilla::EventListenerManager* GetOrCreateListenerManager() override;
|
2013-10-23 03:32:04 +04:00
|
|
|
|
2018-04-05 20:42:42 +03:00
|
|
|
bool ComputeDefaultWantsUntrusted(mozilla::ErrorResult& aRv) final;
|
2015-09-17 13:16:20 +03:00
|
|
|
|
2016-05-06 13:39:10 +03:00
|
|
|
virtual bool IsApzAware() const override;
|
2015-09-17 13:16:20 +03:00
|
|
|
|
2019-01-02 16:26:56 +03:00
|
|
|
virtual nsPIDOMWindowOuter* GetOwnerGlobalForBindingsInternal() override;
|
2015-05-12 22:56:39 +03:00
|
|
|
virtual nsIGlobalObject* GetOwnerGlobal() const override;
|
2011-06-24 06:17:58 +04:00
|
|
|
|
2018-04-05 20:42:41 +03:00
|
|
|
using mozilla::dom::EventTarget::DispatchEvent;
|
|
|
|
bool DispatchEvent(mozilla::dom::Event& aEvent,
|
|
|
|
mozilla::dom::CallerType aCallerType,
|
|
|
|
mozilla::ErrorResult& aRv) override;
|
|
|
|
|
2018-04-05 20:42:41 +03:00
|
|
|
nsresult PostHandleEvent(mozilla::EventChainPostVisitor& aVisitor) override;
|
|
|
|
|
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
|
|
|
|
*/
|
2018-08-09 02:58:44 +03:00
|
|
|
virtual nsresult Clone(mozilla::dom::NodeInfo*, 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
|
|
|
|
2017-12-23 11:23:42 +03:00
|
|
|
virtual void Traverse(nsCycleCollectionTraversalCallback&);
|
|
|
|
virtual void Unlink();
|
2011-08-28 18:07:24 +04:00
|
|
|
|
2006-07-02 11:23:10 +04:00
|
|
|
/**
|
|
|
|
* A list of mutation observers
|
|
|
|
*/
|
2017-07-29 08:07:05 +03:00
|
|
|
nsAutoTObserverArray<nsIMutationObserver*, 1> mMutationObservers;
|
2006-11-11 03:28:20 +03:00
|
|
|
|
|
|
|
/**
|
2018-04-26 00:01:30 +03:00
|
|
|
* An object implementing NodeList for this content (childNodes)
|
|
|
|
* @see NodeList
|
2006-11-11 03:28:20 +03:00
|
|
|
* @see nsGenericHTMLElement::GetChildNodes
|
|
|
|
*/
|
2017-08-11 05:12:17 +03:00
|
|
|
RefPtr<nsAttrChildContentList> 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;
|
2015-08-14 20:52:38 +03:00
|
|
|
|
2017-07-22 08:29:07 +03:00
|
|
|
/**
|
2017-09-01 18:13:47 +03:00
|
|
|
* A set of ranges which are in the selection and which have this node as
|
|
|
|
* their endpoints' common ancestor. This is a UniquePtr instead of just a
|
|
|
|
* LinkedList, because that prevents us from pushing DOMSlots up to the next
|
|
|
|
* allocation bucket size, at the cost of some complexity.
|
2017-07-22 08:29:07 +03:00
|
|
|
*/
|
2017-09-01 18:13:47 +03:00
|
|
|
mozilla::UniquePtr<mozilla::LinkedList<nsRange>> mCommonAncestorRanges;
|
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() { return Slots(); }
|
|
|
|
#endif
|
|
|
|
|
2014-06-19 04:07:26 +04:00
|
|
|
void SetFlags(FlagsType aFlagsToSet) {
|
2013-09-24 23:28:32 +04:00
|
|
|
NS_ASSERTION(
|
|
|
|
!(aFlagsToSet &
|
2009-02-24 21:39:09 +03:00
|
|
|
(NODE_IS_ANONYMOUS_ROOT | NODE_IS_NATIVE_ANONYMOUS_ROOT |
|
2014-04-06 23:32:38 +04:00
|
|
|
NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE | NODE_DESCENDANTS_NEED_FRAMES |
|
2019-02-21 21:39:28 +03:00
|
|
|
NODE_NEEDS_FRAME | NODE_HAS_BEEN_IN_UA_WIDGET)) ||
|
2017-10-25 18:19:11 +03:00
|
|
|
IsContent(),
|
2007-02-16 02:04:33 +03:00
|
|
|
"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) {
|
2009-02-24 21:39:09 +03:00
|
|
|
NS_ASSERTION(!(aFlagsToUnset & (NODE_IS_ANONYMOUS_ROOT |
|
2019-02-21 21:39:28 +03:00
|
|
|
NODE_HAS_BEEN_IN_UA_WIDGET |
|
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);
|
Bug 1506547 - Align user-select behavior more with other UAs. r=mats
There's a few subtle behavior changes here, which I'll try to break down in the
commit message.
The biggest one is the EditableDescendantCount stuff going away. This
was added in bug 1181130, to prevent clicking on the non-editable div from
selecting the editable div inside. This is problematic for multiple reasons:
* First, I don't think non-editable regions of an editable element should
be user-select: all.
* Second, it just doesn't work in Shadow DOM (the editable descendant count is
not kept up-to-date when not in the uncomposed doc), so nested
contenteditables behave differently inside vs. outside a Shadow Tree.
* Third, I think it's user hostile to just entirely disable selection if you
have a contenteditable descendant as a child of a user-select: all thing.
WebKit behaves like this patch in the following test-case (though not Blink):
https://crisal.io/tmp/user-select-all-contenteditable-descendant.html
Edge doesn't seem to support user-select: all at all (no pun intended).
But we don't allow to select anything at all which looks wrong.
* Fourth, it's not tested at all (which explains how we broke it in Shadow DOM
and not even notice...).
In any case I've verified that this doesn't regress the editor from that bug. If
this regresses anything we can fix it as outlined in the first bullet point
above, which should also make us more compatible with other UAs in that
test-case.
The other change is `all` not overriding everything else. So, something like:
<div style="-webkit-user-select: all">All <div style="-webkit-user-select: none">None</div></div>
Totally ignores the -webkit-user-select: none declaration in Firefox before this
change. This doesn't match any other UA nor the spec, and this patch aligns us
with WebKit / Blink.
This in turn makes us not need -moz-text anymore, whose only purpose was to
avoid this.
This also fixes a variety of bugs uncovered by the previous changes, like the
SetIgnoreUserModify(false) call in editor being completely useless, since
presShell->SetCaretEnabled ended in nsCaret::SetVisible, which overrode it.
This in turn uncovered even more bugs, from bugs in the caret painting code,
like not checking -moz-user-modify on the right frame if you're the last frame
of a line, to even funnier bits where before this patch you show the caret but
can't write at all...
In any case, the new setup I came up with is that when you're editing (the
selection is focused on an editable node) moving the caret forces it to end up
in an editable node, thus jumping over non-editable ones.
This has the nice effect of not completely disabling selection of
-moz-user-select: all elements that have editable descendants (which was a very
ad-hoc hack for bug 1181130, and somewhat broken per the above), and also
not needing the -moz-user-select: all for non-editable bits in contenteditable.css
at all.
This also fixes issues with br-skipping like not being able to insert content in
the following test-case:
<div contenteditable="true"><span contenteditable="false">xyz </span><br>editable</div>
If you start moving to the left from the second line, for example.
I think this yields way better behavior in all the relevant test-cases from bug
1181130 / bug 1109968 / bug 1132768, shouldn't cause any regression, and the
complexity is significantly reduced in some places.
There's still some other broken bits that this patch doesn't fix, but I'll file
follow-ups for those.
Differential Revision: https://phabricator.services.mozilla.com/D12687
--HG--
extra : moz-landing-system : lando
2018-11-26 12:21:37 +03:00
|
|
|
} else {
|
2007-06-28 06:48:16 +04:00
|
|
|
UnsetFlags(NODE_IS_EDITABLE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-08 22:57:13 +03:00
|
|
|
inline bool IsEditable() const;
|
2007-07-11 17:05:05 +04:00
|
|
|
|
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;
|
|
|
|
|
2018-07-16 17:07:58 +03:00
|
|
|
bool IsInSVGUseShadowTree() const {
|
|
|
|
return !!GetContainingSVGUseShadowHost();
|
|
|
|
}
|
|
|
|
|
|
|
|
mozilla::dom::SVGUseElement* GetContainingSVGUseShadowHost() const {
|
|
|
|
if (!IsInShadowTree()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return DoGetContainingSVGUseShadowHost();
|
|
|
|
}
|
2014-04-15 07:38:54 +04:00
|
|
|
|
2019-02-21 21:39:28 +03:00
|
|
|
// Whether this node has ever been part of a UA widget shadow tree.
|
|
|
|
bool HasBeenInUAWidget() const { return HasFlag(NODE_HAS_BEEN_IN_UA_WIDGET); }
|
2018-06-29 23:39:46 +03:00
|
|
|
|
2019-02-21 21:39:28 +03:00
|
|
|
// True for native anonymous content and for content in UA widgets.
|
2012-10-10 23:04:42 +04:00
|
|
|
bool ChromeOnlyAccess() const {
|
2014-04-06 23:32:38 +04:00
|
|
|
return HasFlag(NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE |
|
2019-02-21 21:39:28 +03:00
|
|
|
NODE_HAS_BEEN_IN_UA_WIDGET);
|
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); }
|
|
|
|
|
2018-11-16 00:28:56 +03:00
|
|
|
/**
|
|
|
|
* Get whether this node is C++-generated anonymous content
|
|
|
|
* @see nsIAnonymousContentCreator
|
|
|
|
* @return whether this content is anonymous
|
|
|
|
*/
|
|
|
|
bool IsRootOfNativeAnonymousSubtree() const {
|
|
|
|
NS_ASSERTION(!HasFlag(NODE_IS_NATIVE_ANONYMOUS_ROOT) ||
|
|
|
|
(HasFlag(NODE_IS_ANONYMOUS_ROOT) &&
|
|
|
|
HasFlag(NODE_IS_IN_NATIVE_ANONYMOUS_SUBTREE)),
|
|
|
|
"Some flags seem to be missing!");
|
|
|
|
return HasFlag(NODE_IS_NATIVE_ANONYMOUS_ROOT);
|
|
|
|
}
|
|
|
|
|
2019-02-21 21:39:28 +03:00
|
|
|
// Whether this node is a UA Widget ShadowRoot.
|
|
|
|
inline bool IsUAWidget() const;
|
|
|
|
// Whether this node is currently in a UA Widget Shadow tree.
|
|
|
|
inline bool IsInUAWidget() const;
|
|
|
|
// Whether this node is the root of a ChromeOnlyAccess DOM subtree.
|
|
|
|
inline bool IsRootOfChromeAccessOnlySubtree() const;
|
2018-11-16 00:28:56 +03:00
|
|
|
|
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.
|
|
|
|
*/
|
2017-06-22 09:21:31 +03:00
|
|
|
nsIContent* GetTextEditorRootContent(
|
|
|
|
mozilla::TextEditor** aTextEditor = 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);
|
|
|
|
|
2018-03-29 01:01:46 +03:00
|
|
|
nsINodeList* ChildNodes();
|
2009-01-02 20:00:18 +03:00
|
|
|
|
2018-08-06 22:29:27 +03:00
|
|
|
nsIContent* GetFirstChild() const { return mFirstChild; }
|
2009-01-02 20:00:18 +03:00
|
|
|
|
2018-08-06 22:29:27 +03:00
|
|
|
nsIContent* GetLastChild() const;
|
|
|
|
|
2009-01-02 20:00:18 +03:00
|
|
|
/**
|
2019-01-02 16:05:23 +03:00
|
|
|
* Implementation is in Document.h, because it needs to cast from
|
|
|
|
* Document* to nsINode*.
|
2009-01-02 20:00:18 +03:00
|
|
|
*/
|
2019-01-02 16:05:23 +03:00
|
|
|
Document* GetOwnerDocument() const;
|
2009-01-02 20:00:18 +03:00
|
|
|
|
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
|
|
|
|
2016-05-06 13:39:10 +03:00
|
|
|
/**
|
|
|
|
* Return true if the node may be apz aware. There are two cases. One is that
|
|
|
|
* the node is apz aware (such as HTMLInputElement with number type). The
|
|
|
|
* other is that the node has apz aware listeners. This is a non-virtual
|
|
|
|
* function which calls IsNodeApzAwareInternal only when the MayBeApzAware is
|
|
|
|
* set. We check the details in IsNodeApzAwareInternal which may be overriden
|
|
|
|
* by child classes
|
|
|
|
*/
|
|
|
|
bool IsNodeApzAware() const {
|
|
|
|
return NodeMayBeApzAware() ? IsNodeApzAwareInternal() : false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Override this function and set the flag MayBeApzAware in case the node has
|
|
|
|
* to let APZC be aware of it. It's used when the node may handle the apz
|
|
|
|
* aware events and may do preventDefault to stop APZC to do default actions.
|
|
|
|
*
|
|
|
|
* For example, instead of scrolling page by APZ, we handle mouse wheel event
|
|
|
|
* in HTMLInputElement with number type as increasing / decreasing its value.
|
|
|
|
*/
|
|
|
|
virtual bool IsNodeApzAwareInternal() const;
|
|
|
|
|
2017-11-08 01:01:21 +03:00
|
|
|
void GetTextContent(nsAString& aTextContent, mozilla::OOMReporter& aError) {
|
|
|
|
GetTextContentInternal(aTextContent, aError);
|
|
|
|
}
|
|
|
|
void SetTextContent(const nsAString& aTextContent,
|
2017-12-21 01:43:18 +03:00
|
|
|
nsIPrincipal* aSubjectPrincipal,
|
2017-11-08 01:01:21 +03:00
|
|
|
mozilla::ErrorResult& aError) {
|
2017-12-21 01:43:18 +03:00
|
|
|
SetTextContentInternal(aTextContent, aSubjectPrincipal, aError);
|
2017-11-08 01:01:21 +03:00
|
|
|
}
|
2012-10-09 16:31:24 +04:00
|
|
|
void SetTextContent(const nsAString& aTextContent,
|
|
|
|
mozilla::ErrorResult& aError) {
|
2017-11-08 01:01:21 +03:00
|
|
|
SetTextContentInternal(aTextContent, nullptr, 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-11-01 23:39:24 +04:00
|
|
|
protected:
|
2019-01-02 16:05:23 +03:00
|
|
|
// Document and ShadowRoot override this with its own (faster) version.
|
|
|
|
// This should really only be called for elements and document fragments.
|
2013-11-01 23:39:24 +04:00
|
|
|
mozilla::dom::Element* GetElementById(const nsAString& aId);
|
|
|
|
|
2018-08-06 22:29:27 +03:00
|
|
|
void AppendChildToChildList(nsIContent* aKid);
|
|
|
|
void InsertChildToChildList(nsIContent* aKid, nsIContent* aNextSibling);
|
|
|
|
void DisconnectChild(nsIContent* aKid);
|
|
|
|
|
2016-11-19 00:38:29 +03:00
|
|
|
public:
|
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
|
|
|
|
2012-02-20 16:54:45 +04:00
|
|
|
nsIContent* GetNextSibling() const { return mNextSibling; }
|
2018-08-06 22:29:27 +03:00
|
|
|
nsIContent* GetPreviousSibling() const;
|
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-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-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;
|
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:
|
2018-07-16 17:07:58 +03:00
|
|
|
mozilla::dom::SVGUseElement* DoGetContainingSVGUseShadowHost() const;
|
|
|
|
|
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;
|
|
|
|
}
|
2018-06-18 08:43:11 +03:00
|
|
|
MOZ_ASSERT_UNREACHABLE("How did we get here?");
|
2010-05-11 05:12:34 +04:00
|
|
|
}
|
|
|
|
|
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,
|
2018-08-20 14:56:27 +03:00
|
|
|
// Set if we're part of the composed doc.
|
|
|
|
// https://dom.spec.whatwg.org/#connected
|
|
|
|
IsConnected,
|
2011-04-08 06:29:49 +04:00
|
|
|
// 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,
|
2017-01-21 05:24:41 +03:00
|
|
|
// Set if the element might have a class.
|
|
|
|
ElementMayHaveClass,
|
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,
|
2016-03-25 13:23:53 +03:00
|
|
|
// Maybe set if the node is a root of a subtree
|
2012-01-31 00:08:13 +04:00
|
|
|
// which needs to be kept in the purple buffer.
|
|
|
|
NodeIsPurpleRoot,
|
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,
|
2017-06-20 06:24:59 +03:00
|
|
|
// Set if node has a dir attribute with a valid value (ltr, rtl, or auto).
|
|
|
|
// Note that we cannot compute this from the dir attribute event state
|
|
|
|
// flags, because we can't use those to distinguish
|
|
|
|
// <bdi dir="some-invalid-value"> and <bdi dir="auto">.
|
2012-04-17 08:03:10 +04:00
|
|
|
NodeHasValidDirAttribute,
|
2012-11-21 14:13:57 +04:00
|
|
|
// Set if the node has dir=auto and has a property pointing to the text
|
|
|
|
// node that determines its direction
|
|
|
|
NodeHasDirAutoSet,
|
|
|
|
// Set if the node is a text node descendant of a node with dir=auto
|
|
|
|
// and has a TextNodeDirectionalityMap property listing the elements whose
|
|
|
|
// direction it determines.
|
|
|
|
NodeHasTextNodeDirectionalityMap,
|
|
|
|
// Set if a node in the node's parent chain has dir=auto.
|
|
|
|
NodeAncestorHasDirAuto,
|
2013-06-08 12:54:59 +04:00
|
|
|
// Set if the node is handling a click.
|
|
|
|
NodeHandlingClick,
|
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,
|
2016-05-06 13:39:10 +03:00
|
|
|
// Sets if the node is apz aware or we have apz aware listeners.
|
|
|
|
MayBeApzAware,
|
2017-06-28 09:56:12 +03:00
|
|
|
// Set if the element might have any kind of anonymous content children,
|
|
|
|
// which would not be found through the element's children list.
|
|
|
|
ElementMayHaveAnonymousChildren,
|
2018-06-28 14:22:58 +03:00
|
|
|
// Set if element has CustomElementData.
|
|
|
|
ElementHasCustomElementData,
|
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); }
|
2017-01-21 05:24:41 +03:00
|
|
|
bool MayHaveClass() const { return GetBoolFlag(ElementMayHaveClass); }
|
|
|
|
void SetMayHaveClass() { SetBoolFlag(ElementMayHaveClass); }
|
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);
|
|
|
|
}
|
2018-11-30 13:46:48 +03: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); }
|
2017-03-10 05:53:19 +03:00
|
|
|
bool MayHaveAnimations() const { return GetBoolFlag(ElementHasAnimations); }
|
2012-07-31 21:28:21 +04:00
|
|
|
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 SetHasDirAutoSet() {
|
2018-01-30 07:10:53 +03:00
|
|
|
MOZ_ASSERT(NodeType() != TEXT_NODE, "SetHasDirAutoSet on text node");
|
2012-11-21 14:13:57 +04:00
|
|
|
SetBoolFlag(NodeHasDirAutoSet);
|
|
|
|
}
|
|
|
|
void ClearHasDirAutoSet() {
|
|
|
|
MOZ_ASSERT(NodeType() != TEXT_NODE, "ClearHasDirAutoSet on text node");
|
|
|
|
ClearBoolFlag(NodeHasDirAutoSet);
|
|
|
|
}
|
|
|
|
bool HasDirAutoSet() const { return GetBoolFlag(NodeHasDirAutoSet); }
|
|
|
|
void SetHasTextNodeDirectionalityMap() {
|
2018-01-30 07:10:53 +03:00
|
|
|
MOZ_ASSERT(NodeType() == TEXT_NODE,
|
2012-11-21 14:13:57 +04:00
|
|
|
"SetHasTextNodeDirectionalityMap on non-text node");
|
|
|
|
SetBoolFlag(NodeHasTextNodeDirectionalityMap);
|
|
|
|
}
|
|
|
|
void ClearHasTextNodeDirectionalityMap() {
|
2018-01-30 07:10:53 +03:00
|
|
|
MOZ_ASSERT(NodeType() == TEXT_NODE,
|
2012-11-21 14:13:57 +04:00
|
|
|
"ClearHasTextNodeDirectionalityMap on non-text node");
|
|
|
|
ClearBoolFlag(NodeHasTextNodeDirectionalityMap);
|
|
|
|
}
|
2016-03-19 00:21:50 +03:00
|
|
|
bool HasTextNodeDirectionalityMap() const {
|
2018-01-30 07:10:53 +03:00
|
|
|
MOZ_ASSERT(NodeType() == TEXT_NODE,
|
2016-03-19 00:21:50 +03:00
|
|
|
"HasTextNodeDirectionalityMap on non-text node");
|
|
|
|
return GetBoolFlag(NodeHasTextNodeDirectionalityMap);
|
|
|
|
}
|
2012-11-21 14:13:57 +04:00
|
|
|
|
|
|
|
void SetAncestorHasDirAuto() { SetBoolFlag(NodeAncestorHasDirAuto); }
|
|
|
|
void ClearAncestorHasDirAuto() { ClearBoolFlag(NodeAncestorHasDirAuto); }
|
|
|
|
bool AncestorHasDirAuto() const {
|
|
|
|
return GetBoolFlag(NodeAncestorHasDirAuto);
|
|
|
|
}
|
|
|
|
|
2017-06-20 06:24:59 +03:00
|
|
|
// Implemented in nsIContentInlines.h.
|
|
|
|
inline bool NodeOrAncestorHasDirAuto() const;
|
2013-01-09 03:25:47 +04:00
|
|
|
|
2014-06-17 03:01:22 +04:00
|
|
|
void SetParserHasNotified() { SetBoolFlag(ParserHasNotified); };
|
|
|
|
bool HasParserNotified() { return GetBoolFlag(ParserHasNotified); }
|
2015-09-17 13:16:20 +03:00
|
|
|
|
2016-05-06 13:39:10 +03:00
|
|
|
void SetMayBeApzAware() { SetBoolFlag(MayBeApzAware); }
|
|
|
|
bool NodeMayBeApzAware() const { return GetBoolFlag(MayBeApzAware); }
|
2017-06-28 09:56:12 +03:00
|
|
|
|
|
|
|
void SetMayHaveAnonymousChildren() {
|
|
|
|
SetBoolFlag(ElementMayHaveAnonymousChildren);
|
|
|
|
}
|
|
|
|
bool MayHaveAnonymousChildren() const {
|
|
|
|
return GetBoolFlag(ElementMayHaveAnonymousChildren);
|
|
|
|
}
|
|
|
|
|
2018-06-28 14:22:58 +03:00
|
|
|
void SetHasCustomElementData() { SetBoolFlag(ElementHasCustomElementData); }
|
|
|
|
bool HasCustomElementData() const {
|
|
|
|
return GetBoolFlag(ElementHasCustomElementData);
|
|
|
|
}
|
|
|
|
|
2011-04-08 06:29:49 +04:00
|
|
|
protected:
|
|
|
|
void SetParentIsContent(bool aValue) { SetBoolFlag(ParentIsContent, aValue); }
|
2016-08-19 23:08:56 +03:00
|
|
|
void SetIsInDocument() { SetBoolFlag(IsInDocument); }
|
2018-08-20 14:21:08 +03:00
|
|
|
void ClearInDocument() { ClearBoolFlag(IsInDocument); }
|
2018-08-20 14:56:27 +03:00
|
|
|
void SetIsConnected(bool aConnected) { SetBoolFlag(IsConnected, aConnected); }
|
|
|
|
void SetNodeIsContent() { SetBoolFlag(NodeIsContent); }
|
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-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!");
|
2017-10-25 18:19:11 +03:00
|
|
|
NS_ASSERTION(!(IsContent() && IsInUncomposedDoc()) && !IsInShadowTree(),
|
2014-07-03 21:02:07 +04:00
|
|
|
"Shouldn't be here!");
|
2012-03-15 00:14:02 +04:00
|
|
|
mSubtreeRoot = aSubtreeRoot;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ClearSubtreeRootPointer() { mSubtreeRoot = nullptr; }
|
|
|
|
|
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);
|
|
|
|
|
2017-06-15 04:49:17 +03:00
|
|
|
void GenerateXPath(nsAString& aResult);
|
2013-09-11 23:43:01 +04:00
|
|
|
|
2018-02-22 01:07:53 +03:00
|
|
|
already_AddRefed<mozilla::dom::Promise> Localize(
|
|
|
|
JSContext* aCx, mozilla::dom::L10nCallback& aCallback,
|
|
|
|
mozilla::ErrorResult& aRv);
|
|
|
|
|
2016-08-23 21:15:15 +03:00
|
|
|
already_AddRefed<mozilla::dom::AccessibleNode> GetAccessibleNode();
|
|
|
|
|
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) {
|
|
|
|
const nsString& nodeName = NodeName();
|
2017-12-22 21:02:51 +03:00
|
|
|
aNodeName.SetKnownLiveString(nodeName);
|
2012-10-09 16:31:24 +04:00
|
|
|
}
|
2016-09-20 15:02:33 +03:00
|
|
|
MOZ_MUST_USE nsresult 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.
|
2017-02-01 23:43:36 +03:00
|
|
|
void GetBaseURIFromJS(nsAString& aBaseURI, CallerType aCallerType,
|
|
|
|
ErrorResult& aRv) const;
|
2012-10-09 16:31:24 +04:00
|
|
|
bool HasChildNodes() const { return HasChildren(); }
|
2018-09-05 00:31:57 +03:00
|
|
|
|
|
|
|
// See nsContentUtils::PositionIsBefore for aThisIndex and aOtherIndex usage.
|
|
|
|
uint16_t CompareDocumentPosition(nsINode& aOther,
|
|
|
|
int32_t* aThisIndex = nullptr,
|
|
|
|
int32_t* aOtherIndex = nullptr) const;
|
2012-10-09 16:31:24 +04:00
|
|
|
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.
|
|
|
|
}
|
2015-10-07 16:07:39 +03:00
|
|
|
void EnsurePreInsertionValidity(nsINode& aNewChild, nsINode* aRefChild,
|
|
|
|
mozilla::ErrorResult& aError);
|
2012-10-09 16:31:24 +04:00
|
|
|
nsINode* InsertBefore(nsINode& aNode, nsINode* aChild,
|
|
|
|
mozilla::ErrorResult& aError) {
|
|
|
|
return ReplaceOrInsertBefore(false, &aNode, aChild, aError);
|
|
|
|
}
|
|
|
|
nsINode* AppendChild(nsINode& aNode, mozilla::ErrorResult& aError) {
|
|
|
|
return InsertBefore(aNode, nullptr, aError);
|
|
|
|
}
|
|
|
|
nsINode* ReplaceChild(nsINode& aNode, nsINode& aChild,
|
|
|
|
mozilla::ErrorResult& aError) {
|
|
|
|
return ReplaceOrInsertBefore(true, &aNode, &aChild, aError);
|
|
|
|
}
|
|
|
|
nsINode* RemoveChild(nsINode& aChild, mozilla::ErrorResult& aError);
|
|
|
|
already_AddRefed<nsINode> CloneNode(bool aDeep, mozilla::ErrorResult& aError);
|
2016-03-25 13:23:50 +03:00
|
|
|
bool IsSameNode(nsINode* aNode);
|
2012-10-09 16:31:24 +04:00
|
|
|
bool IsEqualNode(nsINode* aNode);
|
2013-01-30 02:53:52 +04:00
|
|
|
void GetNamespaceURI(nsAString& aNamespaceURI) const {
|
|
|
|
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();
|
2017-12-22 21:02:51 +03:00
|
|
|
aLocalName.SetKnownLiveString(localName);
|
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();
|
|
|
|
|
|
|
|
// 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
|
2018-09-04 13:35:16 +03:00
|
|
|
inline mozilla::dom::Element* GetPreviousElementSibling() const;
|
|
|
|
inline mozilla::dom::Element* GetNextElementSibling() const;
|
2016-04-12 05:48:14 +03:00
|
|
|
|
2018-06-02 08:26:00 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT void Before(const Sequence<OwningNodeOrString>& aNodes,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
MOZ_CAN_RUN_SCRIPT void After(const Sequence<OwningNodeOrString>& aNodes,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
MOZ_CAN_RUN_SCRIPT void ReplaceWith(
|
|
|
|
const Sequence<OwningNodeOrString>& aNodes, ErrorResult& aRv);
|
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;
|
|
|
|
|
2018-07-26 23:40:13 +03:00
|
|
|
already_AddRefed<nsIHTMLCollection> GetElementsByAttribute(
|
|
|
|
const nsAString& aAttribute, const nsAString& aValue);
|
|
|
|
already_AddRefed<nsIHTMLCollection> GetElementsByAttributeNS(
|
|
|
|
const nsAString& aNamespaceURI, const nsAString& aAttribute,
|
|
|
|
const nsAString& aValue, ErrorResult& aRv);
|
|
|
|
|
2018-06-02 08:26:00 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT void Prepend(const Sequence<OwningNodeOrString>& aNodes,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
MOZ_CAN_RUN_SCRIPT void Append(const Sequence<OwningNodeOrString>& aNodes,
|
|
|
|
ErrorResult& aRv);
|
2016-04-12 05:48:14 +03:00
|
|
|
|
2014-03-12 05:11:38 +04:00
|
|
|
void GetBoxQuads(const BoxQuadOptions& aOptions,
|
2015-10-18 08:24:48 +03:00
|
|
|
nsTArray<RefPtr<DOMQuad>>& aResult, CallerType aCallerType,
|
2017-02-01 23:43:59 +03:00
|
|
|
ErrorResult& aRv);
|
2014-03-12 05:11:38 +04:00
|
|
|
|
2014-03-12 05:11:39 +04:00
|
|
|
already_AddRefed<DOMQuad> ConvertQuadFromNode(
|
|
|
|
DOMQuad& aQuad, const TextOrElementOrDocument& aFrom,
|
|
|
|
const ConvertCoordinateOptions& aOptions, CallerType aCallerType,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
already_AddRefed<DOMQuad> ConvertRectFromNode(
|
|
|
|
DOMRectReadOnly& aRect, const TextOrElementOrDocument& aFrom,
|
|
|
|
const ConvertCoordinateOptions& aOptions, CallerType aCallerType,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
already_AddRefed<DOMPoint> ConvertPointFromNode(
|
|
|
|
const DOMPointInit& aPoint, const TextOrElementOrDocument& aFrom,
|
|
|
|
const ConvertCoordinateOptions& aOptions, CallerType aCallerType,
|
|
|
|
ErrorResult& aRv);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2017-09-01 18:13:47 +03:00
|
|
|
const mozilla::LinkedList<nsRange>* GetExistingCommonAncestorRanges() const {
|
2017-07-22 08:29:07 +03:00
|
|
|
if (!HasSlots()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2017-09-01 18:13:47 +03:00
|
|
|
return GetExistingSlots()->mCommonAncestorRanges.get();
|
2017-07-22 08:29:07 +03:00
|
|
|
}
|
|
|
|
|
2017-09-01 18:13:47 +03:00
|
|
|
mozilla::LinkedList<nsRange>* GetExistingCommonAncestorRanges() {
|
|
|
|
if (!HasSlots()) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return GetExistingSlots()->mCommonAncestorRanges.get();
|
2017-07-22 08:29:07 +03:00
|
|
|
}
|
|
|
|
|
2017-09-01 18:13:47 +03:00
|
|
|
mozilla::UniquePtr<mozilla::LinkedList<nsRange>>&
|
|
|
|
GetCommonAncestorRangesPtr() {
|
2017-07-22 08:29:07 +03:00
|
|
|
return Slots()->mCommonAncestorRanges;
|
|
|
|
}
|
|
|
|
|
2018-04-07 20:41:03 +03:00
|
|
|
nsIWeakReference* GetExistingWeakReference() {
|
|
|
|
return HasSlots() ? GetExistingSlots()->mWeakReference : nullptr;
|
|
|
|
}
|
|
|
|
|
2006-05-15 13:46:44 +04:00
|
|
|
protected:
|
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();
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
bool HasSlots() const { return mSlots != nullptr; }
|
2006-05-15 11:03:15 +04:00
|
|
|
|
|
|
|
nsSlots* GetExistingSlots() const { return mSlots; }
|
|
|
|
|
2012-08-11 02:27:28 +04:00
|
|
|
nsSlots* Slots() {
|
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
|
|
|
}
|
|
|
|
|
2017-07-29 08:07:05 +03:00
|
|
|
nsAutoTObserverArray<nsIMutationObserver*, 1>* GetMutationObservers() {
|
2012-07-30 18:20:58 +04:00
|
|
|
return HasSlots() ? &GetExistingSlots()->mMutationObservers : nullptr;
|
2008-01-02 23:49:13 +03:00
|
|
|
}
|
|
|
|
|
2017-10-23 10:04:14 +03:00
|
|
|
/**
|
|
|
|
* Invalidate cached child array inside mChildNodes
|
|
|
|
* of type nsParentNodeChildContentList.
|
|
|
|
*/
|
|
|
|
void InvalidateChildNodes();
|
|
|
|
|
2014-08-05 14:10:00 +04:00
|
|
|
virtual void GetTextContentInternal(nsAString& aTextContent,
|
2017-01-18 07:52:29 +03:00
|
|
|
mozilla::OOMReporter& aError);
|
2012-10-09 16:31:24 +04:00
|
|
|
virtual void SetTextContentInternal(const nsAString& aTextContent,
|
2017-11-08 01:01:21 +03:00
|
|
|
nsIPrincipal* aSubjectPrincipal,
|
2012-10-09 16:31:24 +04:00
|
|
|
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
|
|
|
|
|
2018-10-23 01:32:00 +03:00
|
|
|
void EnsurePreInsertionValidity1(mozilla::ErrorResult& aError);
|
2015-10-07 16:07:39 +03:00
|
|
|
void EnsurePreInsertionValidity2(bool aReplace, nsINode& aNewChild,
|
|
|
|
nsINode* aRefChild,
|
|
|
|
mozilla::ErrorResult& aError);
|
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
|
|
|
|
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;
|
|
|
|
|
2017-10-02 19:14:15 +03:00
|
|
|
/**
|
|
|
|
* Parse the given selector string into a servo SelectorList.
|
|
|
|
*
|
|
|
|
* Never returns null if aRv is not failing.
|
|
|
|
*
|
|
|
|
* Note that the selector list returned here is owned by the owner doc's
|
|
|
|
* selector cache.
|
|
|
|
*/
|
2018-03-29 16:34:05 +03:00
|
|
|
const RawServoSelectorList* ParseSelectorList(
|
|
|
|
const nsAString& aSelectorString, mozilla::ErrorResult&);
|
2017-10-02 19:14:15 +03:00
|
|
|
|
2011-10-10 20:21:48 +04:00
|
|
|
public:
|
2018-10-31 21:19:50 +03:00
|
|
|
/* Event stuff that documents and elements share.
|
2011-09-20 06:56:45 +04:00
|
|
|
|
|
|
|
Note that we include DOCUMENT_ONLY_EVENT events here so that we
|
|
|
|
can forward all the document stuff to this implementation.
|
|
|
|
*/
|
2018-10-31 21:19:50 +03:00
|
|
|
#define EVENT(name_, id_, type_, struct_) \
|
|
|
|
mozilla::dom::EventHandlerNonNull* GetOn##name_() { \
|
|
|
|
return GetEventHandler(nsGkAtoms::on##name_); \
|
|
|
|
} \
|
|
|
|
void SetOn##name_(mozilla::dom::EventHandlerNonNull* handler) { \
|
|
|
|
SetEventHandler(nsGkAtoms::on##name_, handler); \
|
|
|
|
}
|
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);
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<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:
|
2017-05-09 16:41:08 +03:00
|
|
|
#ifndef BOOL_FLAGS_ON_WRAPPER_CACHE
|
2011-04-08 06:29:49 +04:00
|
|
|
// Boolean flags.
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mBoolFlags;
|
2017-05-09 16:41:08 +03:00
|
|
|
#endif
|
|
|
|
|
2018-08-06 22:29:27 +03:00
|
|
|
// NOTE, there are 32 bits left here, at least in 64 bit builds.
|
|
|
|
|
|
|
|
uint32_t mChildCount;
|
2011-04-08 06:29:49 +04:00
|
|
|
|
|
|
|
protected:
|
2018-08-06 22:29:27 +03:00
|
|
|
// mNextSibling and mFirstChild are strong references while
|
|
|
|
// mPreviousOrLastSibling is a weak ref. |mFirstChild->mPreviousOrLastSibling|
|
|
|
|
// points to the last child node.
|
|
|
|
nsCOMPtr<nsIContent> mFirstChild;
|
|
|
|
nsCOMPtr<nsIContent> mNextSibling;
|
|
|
|
nsIContent* MOZ_NON_OWNING_REF mPreviousOrLastSibling;
|
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
|
|
|
};
|
|
|
|
|
2019-01-02 16:05:23 +03:00
|
|
|
// Useful inline function for getting a node given an nsIContent and a Document.
|
|
|
|
// 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 Document* because the actual types must be
|
2012-08-06 16:02:08 +04:00
|
|
|
// 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; }
|
|
|
|
|
2018-04-20 11:29:25 +03:00
|
|
|
// Some checks are faster to do on nsIContent or Element than on
|
|
|
|
// nsINode, so spit out FromNode versions taking those types too.
|
2018-04-20 12:10:12 +03:00
|
|
|
#define NS_IMPL_FROMNODE_GENERIC(_class, _check, _const) \
|
|
|
|
template <typename T> \
|
|
|
|
static auto FromNode(_const T& aNode) \
|
|
|
|
->decltype(static_cast<_const _class*>(&aNode)) { \
|
|
|
|
return aNode._check ? static_cast<_const _class*>(&aNode) : nullptr; \
|
|
|
|
} \
|
|
|
|
template <typename T> \
|
|
|
|
static _const _class* FromNode(_const T* aNode) { \
|
|
|
|
return FromNode(*aNode); \
|
|
|
|
} \
|
|
|
|
template <typename T> \
|
|
|
|
static _const _class* FromNodeOrNull(_const T* aNode) { \
|
|
|
|
return aNode ? FromNode(*aNode) : nullptr; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define NS_IMPL_FROMNODE_HELPER(_class, _check) \
|
|
|
|
NS_IMPL_FROMNODE_GENERIC(_class, _check, ) \
|
|
|
|
NS_IMPL_FROMNODE_GENERIC(_class, _check, const) \
|
|
|
|
\
|
|
|
|
template <typename T> \
|
|
|
|
static _class* FromNode(T&& aNode) { \
|
|
|
|
/* We need the double-cast in case aNode is a smartptr. Those */ \
|
|
|
|
/* can cast to superclasses of the type they're templated on, */ \
|
|
|
|
/* but not directly to subclasses. */ \
|
|
|
|
return aNode->_check ? static_cast<_class*>(static_cast<nsINode*>(aNode)) \
|
|
|
|
: nullptr; \
|
|
|
|
} \
|
|
|
|
template <typename T> \
|
|
|
|
static _class* FromNodeOrNull(T&& aNode) { \
|
|
|
|
return aNode ? FromNode(aNode) : nullptr; \
|
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2018-04-20 12:10:12 +03:00
|
|
|
#define NS_IMPL_FROMNODE(_class, _nsid) \
|
2018-04-20 11:29:25 +03:00
|
|
|
NS_IMPL_FROMNODE_HELPER(_class, IsInNamespace(_nsid))
|
|
|
|
|
|
|
|
#define NS_IMPL_FROMNODE_WITH_TAG(_class, _nsid, _tag) \
|
|
|
|
NS_IMPL_FROMNODE_HELPER(_class, NodeInfo()->Equals(nsGkAtoms::_tag, _nsid))
|
|
|
|
|
|
|
|
#define NS_IMPL_FROMNODE_HTML_WITH_TAG(_class, _tag) \
|
|
|
|
NS_IMPL_FROMNODE_WITH_TAG(_class, kNameSpaceID_XHTML, _tag)
|
|
|
|
|
2006-01-19 06:34:18 +03:00
|
|
|
#endif /* nsINode_h___ */
|