diff --git a/components/malloc_size_of/Cargo.toml b/components/malloc_size_of/Cargo.toml index feb219f3c83..4908dbf16bb 100644 --- a/components/malloc_size_of/Cargo.toml +++ b/components/malloc_size_of/Cargo.toml @@ -33,6 +33,7 @@ app_units = { workspace = true } content-security-policy = { workspace = true, optional = true } crossbeam-channel = { workspace = true, optional = true } cssparser = { workspace = true } +dom = { path = "../../../dom/base/rust" } euclid = { workspace = true } http = { workspace = true, optional = true } hyper_serde = { workspace = true, optional = true } diff --git a/components/malloc_size_of/lib.rs b/components/malloc_size_of/lib.rs index 9a7be7423e6..ed82e596a4c 100644 --- a/components/malloc_size_of/lib.rs +++ b/components/malloc_size_of/lib.rs @@ -792,6 +792,8 @@ malloc_size_of_is_0!(app_units::Au); malloc_size_of_is_0!(cssparser::RGBA, cssparser::TokenSerializationType); +malloc_size_of_is_0!(dom::ElementState, dom::DocumentState); + #[cfg(feature = "servo")] malloc_size_of_is_0!(csp::Destination); diff --git a/components/style/Cargo.toml b/components/style/Cargo.toml index e5b9640b430..103271d4b46 100644 --- a/components/style/Cargo.toml +++ b/components/style/Cargo.toml @@ -43,6 +43,7 @@ bitflags = "1.0" byteorder = "1.0" cssparser = "0.29" derive_more = "0.99" +dom = { path = "../../../dom/base/rust" } encoding_rs = { version = "0.8", optional = true } euclid = "0.22" fxhash = "0.2" diff --git a/components/style/dom.rs b/components/style/dom.rs index 83466eb21e6..74afca8c977 100644 --- a/components/style/dom.rs +++ b/components/style/dom.rs @@ -12,7 +12,6 @@ use crate::context::SharedStyleContext; #[cfg(feature = "gecko")] use crate::context::{PostAnimationTasks, UpdateAnimationsTasks}; use crate::data::ElementData; -use crate::element_state::ElementState; use crate::media_queries::Device; use crate::properties::{AnimationDeclarations, ComputedValues, PropertyDeclarationBlock}; use crate::selector_parser::{AttrValue, Lang, PseudoElement, SelectorImpl}; @@ -22,6 +21,7 @@ use crate::traversal_flags::TraversalFlags; use crate::values::AtomIdent; use crate::{LocalName, Namespace, WeakAtom}; use atomic_refcell::{AtomicRef, AtomicRefMut}; +use dom::ElementState; use selectors::matching::{QuirksMode, VisitedHandlingMode}; use selectors::sink::Push; use selectors::Element as SelectorsElement; diff --git a/components/style/element_state.rs b/components/style/element_state.rs deleted file mode 100644 index f8f4629ef9b..00000000000 --- a/components/style/element_state.rs +++ /dev/null @@ -1,152 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -//! States elements can be in. - -bitflags! { - /// Event-based element states. - /// - /// NB: Is important for this to remain in sync with Gecko's - /// dom/events/EventStates.h. - /// - /// Please keep in that order in order for this to be easily auditable. - /// - /// TODO(emilio): We really really want to use the NS_EVENT_STATE bindings - /// for this. - #[derive(MallocSizeOf)] - pub struct ElementState: u64 { - /// The mouse is down on this element. - /// - /// FIXME(#7333): set/unset this when appropriate - const IN_ACTIVE_STATE = 1 << 0; - /// This element has focus. - /// - const IN_FOCUS_STATE = 1 << 1; - /// The mouse is hovering over this element. - /// - const IN_HOVER_STATE = 1 << 2; - /// Content is enabled (and can be disabled). - /// - const IN_ENABLED_STATE = 1 << 3; - /// Content is disabled. - /// - const IN_DISABLED_STATE = 1 << 4; - /// Content is checked. - /// - const IN_CHECKED_STATE = 1 << 5; - /// - const IN_INDETERMINATE_STATE = 1 << 6; - /// - const IN_PLACEHOLDER_SHOWN_STATE = 1 << 7; - /// - const IN_TARGET_STATE = 1 << 8; - /// - const IN_FULLSCREEN_STATE = 1 << 9; - /// - const IN_VALID_STATE = 1 << 10; - /// - const IN_INVALID_STATE = 1 << 11; - /// Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-ui-valid - const IN_MOZ_UI_VALID_STATE = 1 << 12; - /// Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-ui-invalid - const IN_MOZ_UI_INVALID_STATE = 1 << 13; - /// Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-broken - const IN_BROKEN_STATE = 1 << 14; - /// Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-loading - const IN_LOADING_STATE = 1 << 15; - /// - const IN_REQUIRED_STATE = 1 << 16; - /// - const IN_OPTIONAL_STATE = 1 << 17; - /// - const IN_DEFINED_STATE = 1 << 18; - /// - const IN_VISITED_STATE = 1 << 19; - /// - const IN_UNVISITED_STATE = 1 << 20; - /// - const IN_VISITED_OR_UNVISITED_STATE = ElementState::IN_VISITED_STATE.bits | - ElementState::IN_UNVISITED_STATE.bits; - /// Non-standard: https://developer.mozilla.org/en-US/docs/Web/CSS/:-moz-drag-over - const IN_DRAGOVER_STATE = 1 << 21; - /// - const IN_INRANGE_STATE = 1 << 22; - /// - const IN_OUTOFRANGE_STATE = 1 << 23; - /// - const IN_READONLY_STATE = 1 << 24; - /// - const IN_READWRITE_STATE = 1 << 25; - /// - const IN_DEFAULT_STATE = 1 << 26; - /// Non-standard & undocumented. - const IN_OPTIMUM_STATE = 1 << 28; - /// Non-standard & undocumented. - const IN_SUB_OPTIMUM_STATE = 1 << 29; - /// Non-standard & undocumented. - const IN_SUB_SUB_OPTIMUM_STATE = 1 << 30; - /// Non-standard & undocumented. - const IN_INCREMENT_SCRIPT_LEVEL_STATE = 1 << 31; - /// - const IN_FOCUSRING_STATE = 1 << 32; - /// - const IN_FOCUS_WITHIN_STATE = 1 << 33; - /// :dir matching; the states are used for dynamic change detection. - /// State that elements that match :dir(ltr) are in. - const IN_LTR_STATE = 1 << 34; - /// State that elements that match :dir(rtl) are in. - const IN_RTL_STATE = 1 << 35; - /// State that HTML elements that have a "dir" attr are in. - const IN_HAS_DIR_ATTR_STATE = 1 << 36; - /// State that HTML elements with dir="ltr" (or something - /// case-insensitively equal to "ltr") are in. - const IN_HAS_DIR_ATTR_LTR_STATE = 1 << 37; - /// State that HTML elements with dir="rtl" (or something - /// case-insensitively equal to "rtl") are in. - const IN_HAS_DIR_ATTR_RTL_STATE = 1 << 38; - /// State that HTML elements without a valid-valued "dir" attr or - /// any HTML elements (including ) with dir="auto" (or something - /// case-insensitively equal to "auto") are in. - const IN_HAS_DIR_ATTR_LIKE_AUTO_STATE = 1 << 39; - /// Non-standard & undocumented. - const IN_AUTOFILL_STATE = 1 << 40; - /// Non-standard & undocumented. - const IN_AUTOFILL_PREVIEW_STATE = 1 << 41; - /// State that dialog element is modal, for centered alignment - /// - const IN_MODAL_DIALOG_STATE = 1 << 42; - /// - const IN_MOZINERT_STATE = 1 << 43; - /// State for the topmost modal element in top layer - const IN_TOPMOST_MODAL_TOP_LAYER_STATE = 1 << 44; - /// Initially used for the devtools highlighter, but now somehow only - /// used for the devtools accessibility inspector. - const IN_DEVTOOLS_HIGHLIGHTED_STATE = 1 << 45; - /// Used for the devtools style editor. Probably should go away. - const IN_STYLEEDITOR_TRANSITIONING_STATE = 1 << 46; - /// For :-moz-value-empty (to show widgets like the reveal password - /// button or the clear button). - const IN_VALUE_EMPTY_STATE = 1 << 47; - /// For :-moz-revealed. - const IN_REVEALED_STATE = 1 << 48; - } -} - -bitflags! { - /// Event-based document states. - /// - /// NB: Is important for this to remain in sync with Gecko's - /// dom/base/Document.h. - #[derive(MallocSizeOf)] - pub struct DocumentState: u64 { - /// Window activation status - const WINDOW_INACTIVE = 1 << 0; - /// RTL locale: specific to the XUL localedir attribute - const RTL_LOCALE = 1 << 1; - /// LTR locale: specific to the XUL localedir attribute - const LTR_LOCALE = 1 << 2; - /// LWTheme status - const LWTHEME = 1 << 3; - } -} diff --git a/components/style/gecko/non_ts_pseudo_class_list.rs b/components/style/gecko/non_ts_pseudo_class_list.rs index 672e8104fe7..d93fc95a509 100644 --- a/components/style/gecko/non_ts_pseudo_class_list.rs +++ b/components/style/gecko/non_ts_pseudo_class_list.rs @@ -33,56 +33,56 @@ macro_rules! apply_non_ts_list { ("-moz-table-border-nonzero", MozTableBorderNonzero, _, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS), ("-moz-browser-frame", MozBrowserFrame, _, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS_AND_CHROME), ("-moz-select-list-box", MozSelectListBox, _, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS), - ("link", Link, IN_UNVISITED_STATE, _), - ("any-link", AnyLink, IN_VISITED_OR_UNVISITED_STATE, _), - ("visited", Visited, IN_VISITED_STATE, _), - ("active", Active, IN_ACTIVE_STATE, _), - ("autofill", Autofill, IN_AUTOFILL_STATE, _), - ("checked", Checked, IN_CHECKED_STATE, _), - ("defined", Defined, IN_DEFINED_STATE, _), - ("disabled", Disabled, IN_DISABLED_STATE, _), - ("enabled", Enabled, IN_ENABLED_STATE, _), - ("focus", Focus, IN_FOCUS_STATE, _), - ("focus-within", FocusWithin, IN_FOCUS_WITHIN_STATE, _), - ("focus-visible", FocusVisible, IN_FOCUSRING_STATE, _), - ("hover", Hover, IN_HOVER_STATE, _), - ("-moz-drag-over", MozDragOver, IN_DRAGOVER_STATE, _), - ("target", Target, IN_TARGET_STATE, _), - ("indeterminate", Indeterminate, IN_INDETERMINATE_STATE, _), - ("-moz-inert", MozInert, IN_MOZINERT_STATE, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS), - ("-moz-devtools-highlighted", MozDevtoolsHighlighted, IN_DEVTOOLS_HIGHLIGHTED_STATE, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS), - ("-moz-styleeditor-transitioning", MozStyleeditorTransitioning, IN_STYLEEDITOR_TRANSITIONING_STATE, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS), - ("fullscreen", Fullscreen, IN_FULLSCREEN_STATE, _), - ("-moz-modal-dialog", MozModalDialog, IN_MODAL_DIALOG_STATE, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS), - ("-moz-topmost-modal", MozTopmostModal, IN_TOPMOST_MODAL_TOP_LAYER_STATE, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS), - ("-moz-broken", MozBroken, IN_BROKEN_STATE, _), - ("-moz-loading", MozLoading, IN_LOADING_STATE, _), - ("-moz-has-dir-attr", MozHasDirAttr, IN_HAS_DIR_ATTR_STATE, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS), - ("-moz-dir-attr-ltr", MozDirAttrLTR, IN_HAS_DIR_ATTR_LTR_STATE, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS), - ("-moz-dir-attr-rtl", MozDirAttrRTL, IN_HAS_DIR_ATTR_RTL_STATE, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS), - ("-moz-dir-attr-like-auto", MozDirAttrLikeAuto, IN_HAS_DIR_ATTR_LIKE_AUTO_STATE, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS), + ("link", Link, UNVISITED, _), + ("any-link", AnyLink, VISITED_OR_UNVISITED, _), + ("visited", Visited, VISITED, _), + ("active", Active, ACTIVE, _), + ("autofill", Autofill, AUTOFILL, _), + ("checked", Checked, CHECKED, _), + ("defined", Defined, DEFINED, _), + ("disabled", Disabled, DISABLED, _), + ("enabled", Enabled, ENABLED, _), + ("focus", Focus, FOCUS, _), + ("focus-within", FocusWithin, FOCUS_WITHIN, _), + ("focus-visible", FocusVisible, FOCUSRING, _), + ("hover", Hover, HOVER, _), + ("-moz-drag-over", MozDragOver, DRAGOVER, _), + ("target", Target, URLTARGET, _), + ("indeterminate", Indeterminate, INDETERMINATE, _), + ("-moz-inert", MozInert, INERT, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS), + ("-moz-devtools-highlighted", MozDevtoolsHighlighted, DEVTOOLS_HIGHLIGHTED, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS), + ("-moz-styleeditor-transitioning", MozStyleeditorTransitioning, STYLEEDITOR_TRANSITIONING, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS), + ("fullscreen", Fullscreen, FULLSCREEN, _), + ("-moz-modal-dialog", MozModalDialog, MODAL_DIALOG, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS), + ("-moz-topmost-modal", MozTopmostModal, TOPMOST_MODAL, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS), + ("-moz-broken", MozBroken, BROKEN, _), + ("-moz-loading", MozLoading, LOADING, _), + ("-moz-has-dir-attr", MozHasDirAttr, HAS_DIR_ATTR, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS), + ("-moz-dir-attr-ltr", MozDirAttrLTR, HAS_DIR_ATTR_LTR, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS), + ("-moz-dir-attr-rtl", MozDirAttrRTL, HAS_DIR_ATTR_RTL, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS), + ("-moz-dir-attr-like-auto", MozDirAttrLikeAuto, HAS_DIR_ATTR_LIKE_AUTO, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS), - ("-moz-autofill-preview", MozAutofillPreview, IN_AUTOFILL_PREVIEW_STATE, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS_AND_CHROME), - ("-moz-value-empty", MozValueEmpty, IN_VALUE_EMPTY_STATE, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS), - ("-moz-revealed", MozRevealed, IN_REVEALED_STATE, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS), + ("-moz-autofill-preview", MozAutofillPreview, AUTOFILL_PREVIEW, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS_AND_CHROME), + ("-moz-value-empty", MozValueEmpty, VALUE_EMPTY, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS), + ("-moz-revealed", MozRevealed, REVEALED, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS), - ("-moz-math-increment-script-level", MozMathIncrementScriptLevel, IN_INCREMENT_SCRIPT_LEVEL_STATE, _), + ("-moz-math-increment-script-level", MozMathIncrementScriptLevel, INCREMENT_SCRIPT_LEVEL, _), - ("required", Required, IN_REQUIRED_STATE, _), - ("optional", Optional, IN_OPTIONAL_STATE, _), - ("valid", Valid, IN_VALID_STATE, _), - ("invalid", Invalid, IN_INVALID_STATE, _), - ("in-range", InRange, IN_INRANGE_STATE, _), - ("out-of-range", OutOfRange, IN_OUTOFRANGE_STATE, _), - ("default", Default, IN_DEFAULT_STATE, _), - ("placeholder-shown", PlaceholderShown, IN_PLACEHOLDER_SHOWN_STATE, _), - ("read-only", ReadOnly, IN_READONLY_STATE, _), - ("read-write", ReadWrite, IN_READWRITE_STATE, _), - ("user-valid", UserValid, IN_MOZ_UI_VALID_STATE, _), - ("user-invalid", UserInvalid, IN_MOZ_UI_INVALID_STATE, _), - ("-moz-meter-optimum", MozMeterOptimum, IN_OPTIMUM_STATE, _), - ("-moz-meter-sub-optimum", MozMeterSubOptimum, IN_SUB_OPTIMUM_STATE, _), - ("-moz-meter-sub-sub-optimum", MozMeterSubSubOptimum, IN_SUB_SUB_OPTIMUM_STATE, _), + ("required", Required, REQUIRED, _), + ("optional", Optional, OPTIONAL_, _), + ("valid", Valid, VALID, _), + ("invalid", Invalid, INVALID, _), + ("in-range", InRange, INRANGE, _), + ("out-of-range", OutOfRange, OUTOFRANGE, _), + ("default", Default, DEFAULT, _), + ("placeholder-shown", PlaceholderShown, PLACEHOLDER_SHOWN, _), + ("read-only", ReadOnly, READONLY, _), + ("read-write", ReadWrite, READWRITE, _), + ("user-valid", UserValid, MOZ_UI_VALID, _), + ("user-invalid", UserInvalid, MOZ_UI_INVALID, _), + ("-moz-meter-optimum", MozMeterOptimum, OPTIMUM, _), + ("-moz-meter-sub-optimum", MozMeterSubOptimum, SUB_OPTIMUM, _), + ("-moz-meter-sub-sub-optimum", MozMeterSubSubOptimum, SUB_SUB_OPTIMUM, _), ("-moz-first-node", MozFirstNode, _, _), ("-moz-last-node", MozLastNode, _, _), diff --git a/components/style/gecko/selector_parser.rs b/components/style/gecko/selector_parser.rs index 7cfb01e2794..50de91d6c47 100644 --- a/components/style/gecko/selector_parser.rs +++ b/components/style/gecko/selector_parser.rs @@ -4,7 +4,6 @@ //! Gecko-specific bits for selector-parsing. -use crate::element_state::{DocumentState, ElementState}; use crate::gecko_bindings::structs::RawServoSelectorList; use crate::gecko_bindings::sugar::ownership::{HasBoxFFI, HasFFI, HasSimpleFFI}; use crate::invalidation::element::document_state::InvalidationMatchingData; @@ -14,6 +13,7 @@ use crate::string_cache::{Atom, Namespace, WeakAtom, WeakNamespace}; use crate::values::{AtomIdent, AtomString}; use cssparser::{BasicParseError, BasicParseErrorKind, Parser}; use cssparser::{CowRcStr, SourceLocation, ToCss, Token}; +use dom::{DocumentState, ElementState}; use selectors::parser::SelectorParseErrorKind; use selectors::SelectorList; use std::fmt; diff --git a/components/style/gecko/snapshot.rs b/components/style/gecko/snapshot.rs index 8ff794a4d8c..84756406ed8 100644 --- a/components/style/gecko/snapshot.rs +++ b/components/style/gecko/snapshot.rs @@ -6,7 +6,6 @@ //! change in order to properly calculate restyle hints. use crate::dom::TElement; -use crate::element_state::ElementState; use crate::gecko::snapshot_helpers; use crate::gecko::wrapper::{GeckoElement, NamespaceConstraintHelpers}; use crate::gecko_bindings::bindings; @@ -19,6 +18,7 @@ use crate::string_cache::{Atom, Namespace}; use crate::values::{AtomIdent, AtomString}; use crate::LocalName; use crate::WeakAtom; +use dom::ElementState; use selectors::attr::{AttrSelectorOperation, AttrSelectorOperator}; use selectors::attr::{CaseSensitivity, NamespaceConstraint}; diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index 9c4c3c43118..b1c217339fe 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -19,7 +19,7 @@ use crate::author_styles::AuthorStyles; use crate::context::{PostAnimationTasks, QuirksMode, SharedStyleContext, UpdateAnimationsTasks}; use crate::data::ElementData; use crate::dom::{LayoutIterator, NodeInfo, OpaqueNode, TDocument, TElement, TNode, TShadowRoot}; -use crate::element_state::{DocumentState, ElementState}; +use dom::{DocumentState, ElementState}; use crate::gecko::data::GeckoStyleSheet; use crate::gecko::selector_parser::{NonTSPseudoClass, PseudoElement, SelectorImpl}; use crate::gecko::snapshot_helpers; @@ -732,14 +732,14 @@ impl<'le> GeckoElement<'le> { .as_node() .get_bool_flag(nsINode_BooleanFlag::ElementHasLockedStyleStates) { - return self.0.mState.mStates; + return self.0.mState.bits; } unsafe { Gecko_ElementState(self.0) } } #[inline] fn document_state(&self) -> DocumentState { - DocumentState::from_bits_truncate(self.as_node().owner_doc().0.mDocumentState.mStates) + DocumentState::from_bits_truncate(self.as_node().owner_doc().0.mDocumentState.bits) } #[inline] @@ -1336,7 +1336,7 @@ impl<'le> TElement for GeckoElement<'le> { } fn is_visited_link(&self) -> bool { - self.state().intersects(ElementState::IN_VISITED_STATE) + self.state().intersects(ElementState::VISITED) } /// This logic is duplicated in Gecko's nsINode::IsInNativeAnonymousSubtree. @@ -2107,8 +2107,7 @@ impl<'le> ::selectors::Element for GeckoElement<'le> { #[inline] fn is_link(&self) -> bool { - self.state() - .intersects(ElementState::IN_VISITED_OR_UNVISITED_STATE) + self.state().intersects(ElementState::VISITED_OR_UNVISITED) } #[inline] diff --git a/components/style/invalidation/element/document_state.rs b/components/style/invalidation/element/document_state.rs index 358257feac0..5b308cbdfa4 100644 --- a/components/style/invalidation/element/document_state.rs +++ b/components/style/invalidation/element/document_state.rs @@ -5,12 +5,12 @@ //! An invalidation processor for style changes due to document state changes. use crate::dom::TElement; -use crate::element_state::DocumentState; use crate::invalidation::element::invalidation_map::Dependency; use crate::invalidation::element::invalidator::{DescendantInvalidationLists, InvalidationVector}; use crate::invalidation::element::invalidator::{Invalidation, InvalidationProcessor}; use crate::invalidation::element::state_and_attributes; use crate::stylist::CascadeData; +use dom::DocumentState; use selectors::matching::{MatchingContext, MatchingMode, QuirksMode, VisitedHandlingMode, NeedsSelectorFlags}; /// A struct holding the members necessary to invalidate document state diff --git a/components/style/invalidation/element/element_wrapper.rs b/components/style/invalidation/element/element_wrapper.rs index 84d0e5c351a..b244f45d1c4 100644 --- a/components/style/invalidation/element/element_wrapper.rs +++ b/components/style/invalidation/element/element_wrapper.rs @@ -6,11 +6,11 @@ //! against a past state of the element. use crate::dom::TElement; -use crate::element_state::ElementState; use crate::selector_parser::{AttrValue, NonTSPseudoClass, PseudoElement, SelectorImpl}; use crate::selector_parser::{Snapshot, SnapshotMap}; use crate::values::AtomIdent; use crate::{CaseSensitivityExt, LocalName, Namespace, WeakAtom}; +use dom::ElementState; use selectors::attr::{AttrSelectorOperation, CaseSensitivity, NamespaceConstraint}; use selectors::matching::{ElementSelectorFlags, MatchingContext}; use selectors::{Element, OpaqueElement}; @@ -252,7 +252,7 @@ where fn is_link(&self) -> bool { match self.snapshot().and_then(|s| s.state()) { - Some(state) => state.intersects(ElementState::IN_VISITED_OR_UNVISITED_STATE), + Some(state) => state.intersects(ElementState::VISITED_OR_UNVISITED), None => self.element.is_link(), } } diff --git a/components/style/invalidation/element/invalidation_map.rs b/components/style/invalidation/element/invalidation_map.rs index f083225b4b7..e319116b43a 100644 --- a/components/style/invalidation/element/invalidation_map.rs +++ b/components/style/invalidation/element/invalidation_map.rs @@ -5,13 +5,13 @@ //! Code for invalidations due to state or attribute changes. use crate::context::QuirksMode; -use crate::element_state::{DocumentState, ElementState}; use crate::selector_map::{ MaybeCaseInsensitiveHashMap, PrecomputedHashMap, SelectorMap, SelectorMapEntry, }; use crate::selector_parser::SelectorImpl; use crate::AllocErr; use crate::{Atom, LocalName, Namespace, ShrinkIfNeeded}; +use dom::{DocumentState, ElementState}; use selectors::attr::NamespaceConstraint; use selectors::parser::{Combinator, Component}; use selectors::parser::{Selector, SelectorIter}; diff --git a/components/style/invalidation/element/state_and_attributes.rs b/components/style/invalidation/element/state_and_attributes.rs index 1d02d52947b..62642dec761 100644 --- a/components/style/invalidation/element/state_and_attributes.rs +++ b/components/style/invalidation/element/state_and_attributes.rs @@ -8,7 +8,6 @@ use crate::context::SharedStyleContext; use crate::data::ElementData; use crate::dom::TElement; -use crate::element_state::ElementState; use crate::invalidation::element::element_wrapper::{ElementSnapshot, ElementWrapper}; use crate::invalidation::element::invalidation_map::*; use crate::invalidation::element::invalidator::{DescendantInvalidationLists, InvalidationVector}; @@ -18,6 +17,7 @@ use crate::selector_map::SelectorMap; use crate::selector_parser::Snapshot; use crate::stylesheets::origin::OriginSet; use crate::{Atom, WeakAtom}; +use dom::ElementState; use selectors::attr::CaseSensitivity; use selectors::matching::{matches_selector, MatchingContext, MatchingMode, VisitedHandlingMode, NeedsSelectorFlags}; use selectors::NthIndexCache; @@ -201,7 +201,7 @@ where // TODO(emilio): This piece of code should be removed when // layout.css.always-repaint-on-unvisited is true, since we cannot get // into this situation in that case. - if state_changes.contains(ElementState::IN_VISITED_OR_UNVISITED_STATE) { + if state_changes.contains(ElementState::VISITED_OR_UNVISITED) { trace!(" > visitedness change, force subtree restyle"); // We can't just return here because there may also be attribute // changes as well that imply additional hints for siblings. diff --git a/components/style/lib.rs b/components/style/lib.rs index b1cec716fcf..c5f1aba1176 100644 --- a/components/style/lib.rs +++ b/components/style/lib.rs @@ -89,7 +89,6 @@ pub mod data; pub mod dom; pub mod dom_apis; pub mod driver; -pub mod element_state; #[cfg(feature = "servo")] mod encoding_support; pub mod error_reporting; diff --git a/components/style/selector_parser.rs b/components/style/selector_parser.rs index f29cab9735d..4586c33f470 100644 --- a/components/style/selector_parser.rs +++ b/components/style/selector_parser.rs @@ -6,11 +6,11 @@ #![deny(missing_docs)] -use crate::element_state::ElementState; use crate::stylesheets::{Namespaces, Origin, UrlExtraData}; use crate::values::serialize_atom_identifier; use crate::Atom; use cssparser::{Parser as CssParser, ParserInput}; +use dom::ElementState; use selectors::parser::SelectorList; use std::fmt::{self, Debug, Write}; use style_traits::{CssWriter, ParseError, ToCss}; @@ -220,8 +220,8 @@ impl Direction { /// Gets the element state relevant to this :dir() selector. pub fn element_state(&self) -> ElementState { match self.as_horizontal_direction() { - Some(HorizontalDirection::Ltr) => ElementState::IN_LTR_STATE, - Some(HorizontalDirection::Rtl) => ElementState::IN_RTL_STATE, + Some(HorizontalDirection::Ltr) => ElementState::LTR, + Some(HorizontalDirection::Rtl) => ElementState::RTL, None => ElementState::empty(), } } diff --git a/components/style/servo/selector_parser.rs b/components/style/servo/selector_parser.rs index 82c6c1cda2f..33b8a2d4463 100644 --- a/components/style/servo/selector_parser.rs +++ b/components/style/servo/selector_parser.rs @@ -8,7 +8,6 @@ use crate::attr::{AttrIdentifier, AttrValue}; use crate::dom::{OpaqueNode, TElement, TNode}; -use crate::element_state::{DocumentState, ElementState}; use crate::invalidation::element::document_state::InvalidationMatchingData; use crate::invalidation::element::element_wrapper::ElementSnapshot; use crate::properties::longhands::display::computed_value::T as Display; @@ -18,6 +17,7 @@ use crate::selector_parser::{PseudoElementCascadeType, SelectorParser}; use crate::values::{AtomIdent, AtomString}; use crate::{Atom, CaseSensitivityExt, LocalName, Namespace, Prefix}; use cssparser::{serialize_identifier, CowRcStr, Parser as CssParser, SourceLocation, ToCss}; +use dom::{DocumentState, ElementState}; use fxhash::FxHashMap; use selectors::attr::{AttrSelectorOperation, CaseSensitivity, NamespaceConstraint}; use selectors::parser::SelectorParseErrorKind; diff --git a/components/style/stylist.rs b/components/style/stylist.rs index 21b975c9e92..b2d102523b5 100644 --- a/components/style/stylist.rs +++ b/components/style/stylist.rs @@ -9,7 +9,6 @@ use crate::applicable_declarations::{ }; use crate::context::{CascadeInputs, QuirksMode}; use crate::dom::{TElement, TShadowRoot}; -use crate::element_state::{DocumentState, ElementState}; #[cfg(feature = "gecko")] use crate::gecko_bindings::structs::{ServoStyleSetSizes, StyleRuleInclusion}; use crate::invalidation::element::invalidation_map::InvalidationMap; @@ -42,6 +41,7 @@ use crate::stylesheets::{ use crate::stylesheets::{StyleRule, StylesheetContents, StylesheetInDocument}; use crate::AllocErr; use crate::{Atom, LocalName, Namespace, ShrinkIfNeeded, WeakAtom}; +use dom::{DocumentState, ElementState}; use fxhash::FxHashMap; use malloc_size_of::{MallocSizeOf, MallocShallowSizeOf, MallocSizeOfOps}; #[cfg(feature = "gecko")]