mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Auto merge of #19453 - emilio:is-root-is-slow, r=upsuper
style: Add a fast-path for GeckoElement::is_root. <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19453) <!-- Reviewable:end -->
This commit is contained in:
commit
bca8951182
1 changed files with 9 additions and 0 deletions
|
@ -1917,6 +1917,15 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
|
|||
|
||||
#[inline]
|
||||
fn is_root(&self) -> bool {
|
||||
let parent_node = match self.as_node().parent_node() {
|
||||
Some(parent_node) => parent_node,
|
||||
None => return false,
|
||||
};
|
||||
|
||||
if !parent_node.is_document() {
|
||||
return false;
|
||||
}
|
||||
|
||||
unsafe {
|
||||
Gecko_IsRootElement(self.0)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue