style: Remove the never_matches field from attr selectors

It's an extra branch which in practice we almost never take, plus extra
checks during parsing.

Differential Revision: https://phabricator.services.mozilla.com/D180529
This commit is contained in:
Emilio Cobos Álvarez 2023-06-14 21:08:22 +00:00 committed by Martin Robinson
parent 54a783db17
commit 3da2db1c53
5 changed files with 28 additions and 57 deletions

View file

@ -99,47 +99,46 @@ impl GeckoElementSnapshot {
AttrSelectorOperation::WithValue {
operator,
case_sensitivity,
expected_value,
value,
} => {
let ignore_case = match case_sensitivity {
CaseSensitivity::CaseSensitive => false,
CaseSensitivity::AsciiCaseInsensitive => true,
};
// FIXME: case sensitivity for operators other than Equal
match operator {
AttrSelectorOperator::Equal => bindings::Gecko_SnapshotAttrEquals(
self,
ns.atom_or_null(),
local_name.as_ptr(),
expected_value.as_ptr(),
value.as_ptr(),
ignore_case,
),
AttrSelectorOperator::Includes => bindings::Gecko_SnapshotAttrIncludes(
self,
ns.atom_or_null(),
local_name.as_ptr(),
expected_value.as_ptr(),
value.as_ptr(),
ignore_case,
),
AttrSelectorOperator::DashMatch => bindings::Gecko_SnapshotAttrDashEquals(
self,
ns.atom_or_null(),
local_name.as_ptr(),
expected_value.as_ptr(),
value.as_ptr(),
ignore_case,
),
AttrSelectorOperator::Prefix => bindings::Gecko_SnapshotAttrHasPrefix(
self,
ns.atom_or_null(),
local_name.as_ptr(),
expected_value.as_ptr(),
value.as_ptr(),
ignore_case,
),
AttrSelectorOperator::Suffix => bindings::Gecko_SnapshotAttrHasSuffix(
self,
ns.atom_or_null(),
local_name.as_ptr(),
expected_value.as_ptr(),
value.as_ptr(),
ignore_case,
),
AttrSelectorOperator::Substring => {
@ -147,7 +146,7 @@ impl GeckoElementSnapshot {
self,
ns.atom_or_null(),
local_name.as_ptr(),
expected_value.as_ptr(),
value.as_ptr(),
ignore_case,
)
},

View file

@ -1866,54 +1866,53 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
AttrSelectorOperation::WithValue {
operator,
case_sensitivity,
expected_value,
value,
} => {
let ignore_case = match case_sensitivity {
CaseSensitivity::CaseSensitive => false,
CaseSensitivity::AsciiCaseInsensitive => true,
};
// FIXME: case sensitivity for operators other than Equal
match operator {
AttrSelectorOperator::Equal => bindings::Gecko_AttrEquals(
self.0,
ns.atom_or_null(),
local_name.as_ptr(),
expected_value.as_ptr(),
value.as_ptr(),
ignore_case,
),
AttrSelectorOperator::Includes => bindings::Gecko_AttrIncludes(
self.0,
ns.atom_or_null(),
local_name.as_ptr(),
expected_value.as_ptr(),
value.as_ptr(),
ignore_case,
),
AttrSelectorOperator::DashMatch => bindings::Gecko_AttrDashEquals(
self.0,
ns.atom_or_null(),
local_name.as_ptr(),
expected_value.as_ptr(),
value.as_ptr(),
ignore_case,
),
AttrSelectorOperator::Prefix => bindings::Gecko_AttrHasPrefix(
self.0,
ns.atom_or_null(),
local_name.as_ptr(),
expected_value.as_ptr(),
value.as_ptr(),
ignore_case,
),
AttrSelectorOperator::Suffix => bindings::Gecko_AttrHasSuffix(
self.0,
ns.atom_or_null(),
local_name.as_ptr(),
expected_value.as_ptr(),
value.as_ptr(),
ignore_case,
),
AttrSelectorOperator::Substring => bindings::Gecko_AttrHasSubstring(
self.0,
ns.atom_or_null(),
local_name.as_ptr(),
expected_value.as_ptr(),
value.as_ptr(),
ignore_case,
),
}