mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
style: Speed up selector matching with already-lowercase local name selectors
This makes relatively simple changes so that we check lowercase-ness of local-name selectors first. If so, we don't need to check whether we're an HTML element in an HTML document, which requires a fair bit of pointer-chasing. Differential Revision: https://phabricator.services.mozilla.com/D163627
This commit is contained in:
parent
dbba87d73e
commit
b6d9b77a15
3 changed files with 47 additions and 46 deletions
|
@ -145,35 +145,16 @@ pub static SELECTOR_WHITESPACE: &[char] = &[' ', '\t', '\n', '\r', '\x0C'];
|
|||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
#[cfg_attr(feature = "shmem", derive(ToShmem))]
|
||||
pub enum ParsedCaseSensitivity {
|
||||
// 's' was specified.
|
||||
/// 's' was specified.
|
||||
ExplicitCaseSensitive,
|
||||
// 'i' was specified.
|
||||
/// 'i' was specified.
|
||||
AsciiCaseInsensitive,
|
||||
// No flags were specified and HTML says this is a case-sensitive attribute.
|
||||
/// No flags were specified and HTML says this is a case-sensitive attribute.
|
||||
CaseSensitive,
|
||||
// No flags were specified and HTML says this is a case-insensitive attribute.
|
||||
/// No flags were specified and HTML says this is a case-insensitive attribute.
|
||||
AsciiCaseInsensitiveIfInHtmlElementInHtmlDocument,
|
||||
}
|
||||
|
||||
impl ParsedCaseSensitivity {
|
||||
pub fn to_unconditional(self, is_html_element_in_html_document: bool) -> CaseSensitivity {
|
||||
match self {
|
||||
ParsedCaseSensitivity::AsciiCaseInsensitiveIfInHtmlElementInHtmlDocument
|
||||
if is_html_element_in_html_document =>
|
||||
{
|
||||
CaseSensitivity::AsciiCaseInsensitive
|
||||
},
|
||||
ParsedCaseSensitivity::AsciiCaseInsensitiveIfInHtmlElementInHtmlDocument => {
|
||||
CaseSensitivity::CaseSensitive
|
||||
},
|
||||
ParsedCaseSensitivity::CaseSensitive | ParsedCaseSensitivity::ExplicitCaseSensitive => {
|
||||
CaseSensitivity::CaseSensitive
|
||||
},
|
||||
ParsedCaseSensitivity::AsciiCaseInsensitive => CaseSensitivity::AsciiCaseInsensitive,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum CaseSensitivity {
|
||||
CaseSensitive,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue