style: Unify Gecko and Servo EventState/ElementState bits

Add a dom/base/rust crate called just "dom" where we can share these.

Most of the changes are automatic:

  s/mozilla::EventStates/mozilla::dom::ElementState/
  s/EventStates/ElementState/
  s/NS_EVENT_STATE_/ElementState::/
  s/NS_DOCUMENT_STATE_/DocumentState::/

And so on. This requires a new cbindgen version to avoid ugly casts for
large shifts.

Differential Revision: https://phabricator.services.mozilla.com/D148537
This commit is contained in:
Emilio Cobos Álvarez 2022-06-07 23:09:52 +00:00 committed by Martin Robinson
parent 949fd0e172
commit 1ce75ff7dd
17 changed files with 70 additions and 220 deletions

View file

@ -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

View file

@ -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(),
}
}

View file

@ -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};

View file

@ -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.