mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:57:44 +00:00
LibWeb: Implement Node.getRootNode
This commit is contained in:
parent
1f4a6e7c22
commit
1ea3f34823
3 changed files with 21 additions and 0 deletions
|
@ -890,4 +890,14 @@ bool Node::in_a_document_tree() const
|
||||||
return root().is_document();
|
return root().is_document();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://dom.spec.whatwg.org/#dom-node-getrootnode
|
||||||
|
NonnullRefPtr<Node> Node::get_root_node(GetRootNodeOptions const& options)
|
||||||
|
{
|
||||||
|
// The getRootNode(options) method steps are to return this’s shadow-including root if options["composed"] is true; otherwise this’s root.
|
||||||
|
if (options.composed)
|
||||||
|
return shadow_including_root();
|
||||||
|
|
||||||
|
return root();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,10 @@ enum class NodeType : u16 {
|
||||||
NOTATION_NODE = 12
|
NOTATION_NODE = 12
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct GetRootNodeOptions {
|
||||||
|
bool composed { false };
|
||||||
|
};
|
||||||
|
|
||||||
class Node
|
class Node
|
||||||
: public TreeNode<Node>
|
: public TreeNode<Node>
|
||||||
, public EventTarget
|
, public EventTarget
|
||||||
|
@ -195,6 +199,8 @@ public:
|
||||||
bool is_same_node(Node const*) const;
|
bool is_same_node(Node const*) const;
|
||||||
bool is_equal_node(Node const*) const;
|
bool is_equal_node(Node const*) const;
|
||||||
|
|
||||||
|
NonnullRefPtr<Node> get_root_node(GetRootNodeOptions const& options = {});
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Node(Document&, NodeType);
|
Node(Document&, NodeType);
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ interface Node : EventTarget {
|
||||||
readonly attribute Element? parentElement;
|
readonly attribute Element? parentElement;
|
||||||
readonly attribute boolean isConnected;
|
readonly attribute boolean isConnected;
|
||||||
readonly attribute Document? ownerDocument;
|
readonly attribute Document? ownerDocument;
|
||||||
|
Node getRootNode(optional GetRootNodeOptions options = {});
|
||||||
|
|
||||||
// FIXME: [LegacyNullToEmptyString] is not allowed on nullable types as per the Web IDL spec.
|
// FIXME: [LegacyNullToEmptyString] is not allowed on nullable types as per the Web IDL spec.
|
||||||
// However, we only apply it to setters, so this works as a stop gap.
|
// However, we only apply it to setters, so this works as a stop gap.
|
||||||
|
@ -50,3 +51,7 @@ interface Node : EventTarget {
|
||||||
const unsigned short DOCUMENT_POSITION_CONTAINED_BY = 16;
|
const unsigned short DOCUMENT_POSITION_CONTAINED_BY = 16;
|
||||||
const unsigned short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 32;
|
const unsigned short DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 32;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
dictionary GetRootNodeOptions {
|
||||||
|
boolean composed = false;
|
||||||
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue