summaryrefslogtreecommitdiffstats
path: root/servo/components/style/queries/condition.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--servo/components/style/queries/condition.rs88
1 files changed, 1 insertions, 87 deletions
diff --git a/servo/components/style/queries/condition.rs b/servo/components/style/queries/condition.rs
index e17e6abd2e..25af4cdb01 100644
--- a/servo/components/style/queries/condition.rs
+++ b/servo/components/style/queries/condition.rs
@@ -13,6 +13,7 @@ use crate::{error_reporting::ContextualParseError, parser::ParserContext};
use cssparser::{Parser, Token};
use std::fmt::{self, Write};
use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss};
+use selectors::kleene_value::KleeneValue;
/// A binary `and` or `or` operator.
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, ToCss, ToShmem)]
@@ -29,93 +30,6 @@ enum AllowOr {
No,
}
-/// https://en.wikipedia.org/wiki/Three-valued_logic#Kleene_and_Priest_logics
-#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, PartialEq, ToCss)]
-pub enum KleeneValue {
- /// False
- False = 0,
- /// True
- True = 1,
- /// Either true or false, but we’re not sure which yet.
- Unknown,
-}
-
-impl From<bool> for KleeneValue {
- fn from(b: bool) -> Self {
- if b {
- Self::True
- } else {
- Self::False
- }
- }
-}
-
-impl KleeneValue {
- /// Turns this Kleene value to a bool, taking the unknown value as an
- /// argument.
- pub fn to_bool(self, unknown: bool) -> bool {
- match self {
- Self::True => true,
- Self::False => false,
- Self::Unknown => unknown,
- }
- }
-}
-
-impl std::ops::Not for KleeneValue {
- type Output = Self;
-
- fn not(self) -> Self {
- match self {
- Self::True => Self::False,
- Self::False => Self::True,
- Self::Unknown => Self::Unknown,
- }
- }
-}
-
-// Implements the logical and operation.
-impl std::ops::BitAnd for KleeneValue {
- type Output = Self;
-
- fn bitand(self, other: Self) -> Self {
- if self == Self::False || other == Self::False {
- return Self::False;
- }
- if self == Self::Unknown || other == Self::Unknown {
- return Self::Unknown;
- }
- Self::True
- }
-}
-
-// Implements the logical or operation.
-impl std::ops::BitOr for KleeneValue {
- type Output = Self;
-
- fn bitor(self, other: Self) -> Self {
- if self == Self::True || other == Self::True {
- return Self::True;
- }
- if self == Self::Unknown || other == Self::Unknown {
- return Self::Unknown;
- }
- Self::False
- }
-}
-
-impl std::ops::BitOrAssign for KleeneValue {
- fn bitor_assign(&mut self, other: Self) {
- *self = *self | other;
- }
-}
-
-impl std::ops::BitAndAssign for KleeneValue {
- fn bitand_assign(&mut self, other: Self) {
- *self = *self & other;
- }
-}
-
/// Represents a condition.
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToShmem)]
pub enum QueryCondition {