mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
script: Add a function to check whether a node is before another one in DOM order.
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
This commit is contained in:
parent
4304a1d054
commit
f6bfd44ad6
1 changed files with 11 additions and 0 deletions
|
@ -385,6 +385,17 @@ impl Node {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns true if this node is before `other` in the same connected DOM
|
||||
/// tree.
|
||||
pub fn is_before(&self, other: &Node) -> bool {
|
||||
let cmp = other.CompareDocumentPosition(self);
|
||||
if cmp & NodeConstants::DOCUMENT_POSITION_DISCONNECTED != 0 {
|
||||
return false;
|
||||
}
|
||||
|
||||
cmp & NodeConstants::DOCUMENT_POSITION_PRECEDING != 0
|
||||
}
|
||||
|
||||
/// Return all registered mutation observers for this node.
|
||||
pub fn registered_mutation_observers(&self) -> RefMut<Vec<RegisteredObserver>> {
|
||||
self.mutation_observers.borrow_mut()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue