mirror of
https://github.com/servo/servo.git
synced 2025-08-09 07:25:35 +01:00
style: Introduce TDocument::is_html_element and TDocument::quirks_mode.
This allows some code to read a bit nicer, and stop passing down quirks mode to querySelector / querySelectorAll.
This commit is contained in:
parent
bfa7cd7d9e
commit
dd5cd29a61
5 changed files with 38 additions and 26 deletions
|
@ -102,6 +102,14 @@ impl<'ld> TDocument for GeckoDocument<'ld> {
|
|||
fn as_node(&self) -> Self::ConcreteNode {
|
||||
GeckoNode(&self.0._base)
|
||||
}
|
||||
|
||||
fn is_html_document(&self) -> bool {
|
||||
self.0.mType == structs::root::nsIDocument_Type::eHTML
|
||||
}
|
||||
|
||||
fn quirks_mode(&self) -> QuirksMode {
|
||||
self.0.mCompatMode.into()
|
||||
}
|
||||
}
|
||||
|
||||
/// A simple wrapper over a non-null Gecko node (`nsINode`) pointer.
|
||||
|
@ -172,12 +180,6 @@ impl<'ln> GeckoNode<'ln> {
|
|||
(self.0).mBoolFlags
|
||||
}
|
||||
|
||||
/// Owner document quirks mode getter.
|
||||
#[inline]
|
||||
pub fn owner_document_quirks_mode(&self) -> QuirksMode {
|
||||
self.owner_doc().0.mCompatMode.into()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn get_bool_flag(&self, flag: nsINode_BooleanFlag) -> bool {
|
||||
self.bool_flags() & (1u32 << flag as u32) != 0
|
||||
|
@ -665,12 +667,6 @@ impl<'le> GeckoElement<'le> {
|
|||
unsafe { Gecko_GetDocumentLWTheme(node.owner_doc().0) }
|
||||
}
|
||||
|
||||
/// Owner document quirks mode getter.
|
||||
#[inline]
|
||||
pub fn owner_document_quirks_mode(&self) -> QuirksMode {
|
||||
self.as_node().owner_document_quirks_mode()
|
||||
}
|
||||
|
||||
/// Only safe to call on the main thread, with exclusive access to the element and
|
||||
/// its ancestors.
|
||||
/// This function is also called after display property changed for SMIL animation.
|
||||
|
@ -1614,7 +1610,7 @@ impl<'le> TElement for GeckoElement<'le> {
|
|||
if self.get_local_name().as_ptr() == atom!("th").as_ptr() {
|
||||
hints.push(TH_RULE.clone());
|
||||
} else if self.get_local_name().as_ptr() == atom!("table").as_ptr() &&
|
||||
self.as_node().owner_doc().0.mCompatMode == structs::nsCompatibility::eCompatibility_NavQuirks {
|
||||
self.as_node().owner_doc().quirks_mode() == QuirksMode::Quirks {
|
||||
hints.push(TABLE_COLOR_RULE.clone());
|
||||
}
|
||||
}
|
||||
|
@ -2061,7 +2057,7 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
|
|||
|
||||
fn is_html_element_in_html_document(&self) -> bool {
|
||||
self.is_html_element() &&
|
||||
self.as_node().owner_doc().0.mType == structs::root::nsIDocument_Type::eHTML
|
||||
self.as_node().owner_doc().is_html_document()
|
||||
}
|
||||
|
||||
fn ignores_nth_child_selectors(&self) -> bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue