improvement: body element check (#37442)

Created a new method `HTMLElement::is_body_element` that replaces
`HTMLBodyElement::is_the_html_body_element`.

Testing: Existing WPT tests should pass.
Fixes: https://github.com/servo/servo/issues/37429

---------

Signed-off-by: iamlockon <xdddxyyyxzzz123@gmail.com>
This commit is contained in:
Jay Wang 2025-06-15 13:11:32 +09:00 committed by GitHub
parent c74a422e4c
commit 96adb1e959
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 24 additions and 28 deletions

View file

@ -92,7 +92,6 @@ use crate::dom::element::{CustomElementCreationMode, Element, ElementCreator, Se
use crate::dom::event::{Event, EventBubbles, EventCancelable};
use crate::dom::eventtarget::EventTarget;
use crate::dom::globalscope::GlobalScope;
use crate::dom::htmlbodyelement::HTMLBodyElement;
use crate::dom::htmlcanvaselement::{HTMLCanvasElement, LayoutHTMLCanvasElementHelpers};
use crate::dom::htmlcollection::HTMLCollection;
use crate::dom::htmlelement::HTMLElement;
@ -958,8 +957,8 @@ impl Node {
let in_quirks_mode = document.quirks_mode() == QuirksMode::Quirks;
let is_root = self.downcast::<Element>().is_some_and(|e| e.is_root());
let is_body_element = self
.downcast::<HTMLBodyElement>()
.is_some_and(|e| e.is_the_html_body_element());
.downcast::<HTMLElement>()
.is_some_and(|e| e.is_body_element());
// "4. If the element is the root element and document is not in quirks mode
// return max(viewport scrolling area width/height, viewport width/height)."