mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Bump bitflags to 1.0 in every servo crate
This commit is contained in:
parent
b6475cf433
commit
29b4eec141
131 changed files with 1591 additions and 1580 deletions
|
@ -10,11 +10,11 @@ use atomic_refcell::AtomicRef;
|
|||
use context::{QuirksMode, SharedStyleContext};
|
||||
use data::ElementData;
|
||||
use dom::TElement;
|
||||
use element_state::{ElementState, IN_VISITED_OR_UNVISITED_STATE};
|
||||
use element_state::ElementState;
|
||||
use invalidation::element::element_wrapper::{ElementSnapshot, ElementWrapper};
|
||||
use invalidation::element::invalidation_map::*;
|
||||
use invalidation::element::invalidator::{InvalidationVector, Invalidation, InvalidationProcessor};
|
||||
use invalidation::element::restyle_hints::*;
|
||||
use invalidation::element::restyle_hints::RestyleHint;
|
||||
use selector_map::SelectorMap;
|
||||
use selector_parser::Snapshot;
|
||||
use selectors::NthIndexCache;
|
||||
|
@ -128,7 +128,7 @@ where
|
|||
// force a restyle here. Matching doesn't depend on the actual visited
|
||||
// state at all, so we can't look at matching results to decide what to
|
||||
// do for this case.
|
||||
if state_changes.intersects(IN_VISITED_OR_UNVISITED_STATE) {
|
||||
if state_changes.intersects(ElementState::IN_VISITED_OR_UNVISITED_STATE) {
|
||||
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.
|
||||
|
@ -215,7 +215,7 @@ where
|
|||
};
|
||||
|
||||
if invalidated_self {
|
||||
self.data.hint.insert(RESTYLE_SELF);
|
||||
self.data.hint.insert(RestyleHint::RESTYLE_SELF);
|
||||
}
|
||||
|
||||
invalidated_self
|
||||
|
@ -224,7 +224,7 @@ where
|
|||
fn should_process_descendants(&mut self, element: E) -> bool {
|
||||
if element == self.element {
|
||||
return !self.data.styles.is_display_none() &&
|
||||
!self.data.hint.contains(RESTYLE_DESCENDANTS)
|
||||
!self.data.hint.contains(RestyleHint::RESTYLE_DESCENDANTS)
|
||||
}
|
||||
|
||||
let data = match element.borrow_data() {
|
||||
|
@ -233,17 +233,17 @@ where
|
|||
};
|
||||
|
||||
!data.styles.is_display_none() &&
|
||||
!data.hint.contains(RESTYLE_DESCENDANTS)
|
||||
!data.hint.contains(RestyleHint::RESTYLE_DESCENDANTS)
|
||||
}
|
||||
|
||||
fn recursion_limit_exceeded(&mut self, element: E) {
|
||||
if element == self.element {
|
||||
self.data.hint.insert(RESTYLE_DESCENDANTS);
|
||||
self.data.hint.insert(RestyleHint::RESTYLE_DESCENDANTS);
|
||||
return;
|
||||
}
|
||||
|
||||
if let Some(mut data) = element.mutate_data() {
|
||||
data.hint.insert(RESTYLE_DESCENDANTS);
|
||||
data.hint.insert(RestyleHint::RESTYLE_DESCENDANTS);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -271,7 +271,7 @@ where
|
|||
fn invalidated_self(&mut self, element: E) {
|
||||
debug_assert_ne!(element, self.element);
|
||||
if let Some(mut data) = element.mutate_data() {
|
||||
data.hint.insert(RESTYLE_SELF);
|
||||
data.hint.insert(RestyleHint::RESTYLE_SELF);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -363,7 +363,7 @@ where
|
|||
return true;
|
||||
}
|
||||
let visited_dependent =
|
||||
if dependency.state.intersects(IN_VISITED_OR_UNVISITED_STATE) {
|
||||
if dependency.state.intersects(ElementState::IN_VISITED_OR_UNVISITED_STATE) {
|
||||
VisitedDependent::Yes
|
||||
} else {
|
||||
VisitedDependent::No
|
||||
|
|
|
@ -20,16 +20,16 @@ use smallvec::SmallVec;
|
|||
#[cfg(feature = "gecko")]
|
||||
/// Gets the element state relevant to the given `:dir` pseudo-class selector.
|
||||
pub fn dir_selector_to_state(s: &[u16]) -> ElementState {
|
||||
use element_state::{IN_LTR_STATE, IN_RTL_STATE};
|
||||
use element_state::ElementState;
|
||||
|
||||
// Jump through some hoops to deal with our Box<[u16]> thing.
|
||||
const LTR: [u16; 4] = [b'l' as u16, b't' as u16, b'r' as u16, 0];
|
||||
const RTL: [u16; 4] = [b'r' as u16, b't' as u16, b'l' as u16, 0];
|
||||
|
||||
if LTR == *s {
|
||||
IN_LTR_STATE
|
||||
ElementState::IN_LTR_STATE
|
||||
} else if RTL == *s {
|
||||
IN_RTL_STATE
|
||||
ElementState::IN_RTL_STATE
|
||||
} else {
|
||||
// :dir(something-random) is a valid selector, but shouldn't
|
||||
// match anything.
|
||||
|
|
|
@ -10,38 +10,38 @@ use traversal_flags::TraversalFlags;
|
|||
|
||||
bitflags! {
|
||||
/// The kind of restyle we need to do for a given element.
|
||||
pub flags RestyleHint: u8 {
|
||||
pub struct RestyleHint: u8 {
|
||||
/// Do a selector match of the element.
|
||||
const RESTYLE_SELF = 1 << 0,
|
||||
const RESTYLE_SELF = 1 << 0;
|
||||
|
||||
/// Do a selector match of the element's descendants.
|
||||
const RESTYLE_DESCENDANTS = 1 << 1,
|
||||
const RESTYLE_DESCENDANTS = 1 << 1;
|
||||
|
||||
/// Recascade the current element.
|
||||
const RECASCADE_SELF = 1 << 2,
|
||||
const RECASCADE_SELF = 1 << 2;
|
||||
|
||||
/// Recascade all descendant elements.
|
||||
const RECASCADE_DESCENDANTS = 1 << 3,
|
||||
const RECASCADE_DESCENDANTS = 1 << 3;
|
||||
|
||||
/// Replace the style data coming from CSS transitions without updating
|
||||
/// any other style data. This hint is only processed in animation-only
|
||||
/// traversal which is prior to normal traversal.
|
||||
const RESTYLE_CSS_TRANSITIONS = 1 << 4,
|
||||
const RESTYLE_CSS_TRANSITIONS = 1 << 4;
|
||||
|
||||
/// Replace the style data coming from CSS animations without updating
|
||||
/// any other style data. This hint is only processed in animation-only
|
||||
/// traversal which is prior to normal traversal.
|
||||
const RESTYLE_CSS_ANIMATIONS = 1 << 5,
|
||||
const RESTYLE_CSS_ANIMATIONS = 1 << 5;
|
||||
|
||||
/// Don't re-run selector-matching on the element, only the style
|
||||
/// attribute has changed, and this change didn't have any other
|
||||
/// dependencies.
|
||||
const RESTYLE_STYLE_ATTRIBUTE = 1 << 6,
|
||||
const RESTYLE_STYLE_ATTRIBUTE = 1 << 6;
|
||||
|
||||
/// Replace the style data coming from SMIL animations without updating
|
||||
/// any other style data. This hint is only processed in animation-only
|
||||
/// traversal which is prior to normal traversal.
|
||||
const RESTYLE_SMIL = 1 << 7,
|
||||
const RESTYLE_SMIL = 1 << 7;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,26 +49,26 @@ impl RestyleHint {
|
|||
/// Creates a new `RestyleHint` indicating that the current element and all
|
||||
/// its descendants must be fully restyled.
|
||||
pub fn restyle_subtree() -> Self {
|
||||
RESTYLE_SELF | RESTYLE_DESCENDANTS
|
||||
RestyleHint::RESTYLE_SELF | RestyleHint::RESTYLE_DESCENDANTS
|
||||
}
|
||||
|
||||
/// Creates a new `RestyleHint` indicating that the current element and all
|
||||
/// its descendants must be recascaded.
|
||||
pub fn recascade_subtree() -> Self {
|
||||
RECASCADE_SELF | RECASCADE_DESCENDANTS
|
||||
RestyleHint::RECASCADE_SELF | RestyleHint::RECASCADE_DESCENDANTS
|
||||
}
|
||||
|
||||
/// Returns whether this hint invalidates the element and all its
|
||||
/// descendants.
|
||||
pub fn contains_subtree(&self) -> bool {
|
||||
self.contains(RESTYLE_SELF | RESTYLE_DESCENDANTS)
|
||||
self.contains(RestyleHint::RESTYLE_SELF | RestyleHint::RESTYLE_DESCENDANTS)
|
||||
}
|
||||
|
||||
/// Returns whether we need to restyle this element.
|
||||
pub fn has_non_animation_invalidations(&self) -> bool {
|
||||
self.intersects(
|
||||
RESTYLE_SELF |
|
||||
RECASCADE_SELF |
|
||||
RestyleHint::RESTYLE_SELF |
|
||||
RestyleHint::RECASCADE_SELF |
|
||||
(Self::replacements() & !Self::for_animations())
|
||||
)
|
||||
}
|
||||
|
@ -96,10 +96,10 @@ impl RestyleHint {
|
|||
/// Returns a new `CascadeHint` appropriate for children of the current
|
||||
/// element.
|
||||
fn propagate_for_non_animation_restyle(&self) -> Self {
|
||||
if self.contains(RESTYLE_DESCENDANTS) {
|
||||
if self.contains(RestyleHint::RESTYLE_DESCENDANTS) {
|
||||
return Self::restyle_subtree()
|
||||
}
|
||||
if self.contains(RECASCADE_DESCENDANTS) {
|
||||
if self.contains(RestyleHint::RECASCADE_DESCENDANTS) {
|
||||
return Self::recascade_subtree()
|
||||
}
|
||||
Self::empty()
|
||||
|
@ -108,24 +108,24 @@ impl RestyleHint {
|
|||
/// Creates a new `RestyleHint` that indicates the element must be
|
||||
/// recascaded.
|
||||
pub fn recascade_self() -> Self {
|
||||
RECASCADE_SELF
|
||||
RestyleHint::RECASCADE_SELF
|
||||
}
|
||||
|
||||
/// Returns a hint that contains all the replacement hints.
|
||||
pub fn replacements() -> Self {
|
||||
RESTYLE_STYLE_ATTRIBUTE | Self::for_animations()
|
||||
RestyleHint::RESTYLE_STYLE_ATTRIBUTE | Self::for_animations()
|
||||
}
|
||||
|
||||
/// The replacements for the animation cascade levels.
|
||||
#[inline]
|
||||
pub fn for_animations() -> Self {
|
||||
RESTYLE_SMIL | RESTYLE_CSS_ANIMATIONS | RESTYLE_CSS_TRANSITIONS
|
||||
RestyleHint::RESTYLE_SMIL | RestyleHint::RESTYLE_CSS_ANIMATIONS | RestyleHint::RESTYLE_CSS_TRANSITIONS
|
||||
}
|
||||
|
||||
/// Returns whether the hint specifies that the currently element must be
|
||||
/// recascaded.
|
||||
pub fn has_recascade_self(&self) -> bool {
|
||||
self.contains(RECASCADE_SELF)
|
||||
self.contains(RestyleHint::RECASCADE_SELF)
|
||||
}
|
||||
|
||||
/// Returns whether the hint specifies that an animation cascade level must
|
||||
|
@ -139,7 +139,7 @@ impl RestyleHint {
|
|||
/// be replaced.
|
||||
#[inline]
|
||||
pub fn has_animation_hint_or_recascade(&self) -> bool {
|
||||
self.intersects(Self::for_animations() | RECASCADE_SELF)
|
||||
self.intersects(Self::for_animations() | RestyleHint::RECASCADE_SELF)
|
||||
}
|
||||
|
||||
/// Returns whether the hint specifies some restyle work other than an
|
||||
|
@ -153,7 +153,7 @@ impl RestyleHint {
|
|||
/// for the element.
|
||||
#[inline]
|
||||
pub fn match_self(&self) -> bool {
|
||||
self.intersects(RESTYLE_SELF)
|
||||
self.intersects(RestyleHint::RESTYLE_SELF)
|
||||
}
|
||||
|
||||
/// Returns whether the hint specifies that some cascade levels must be
|
||||
|
@ -177,7 +177,7 @@ impl RestyleHint {
|
|||
// normal restyle. (We could have separate RECASCADE_SELF_NORMAL and
|
||||
// RECASCADE_SELF_ANIMATIONS flags to make it clear, but this isn't
|
||||
// currently necessary.)
|
||||
self.remove(RECASCADE_SELF);
|
||||
self.remove(RestyleHint::RECASCADE_SELF);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -204,23 +204,23 @@ impl From<nsRestyleHint> for RestyleHint {
|
|||
|
||||
if (raw.0 & (eRestyle_Self.0 | eRestyle_Subtree.0)) != 0 {
|
||||
raw.0 &= !eRestyle_Self.0;
|
||||
hint.insert(RESTYLE_SELF);
|
||||
hint.insert(RestyleHint::RESTYLE_SELF);
|
||||
}
|
||||
|
||||
if (raw.0 & (eRestyle_Subtree.0 | eRestyle_SomeDescendants.0)) != 0 {
|
||||
raw.0 &= !eRestyle_Subtree.0;
|
||||
raw.0 &= !eRestyle_SomeDescendants.0;
|
||||
hint.insert(RESTYLE_DESCENDANTS);
|
||||
hint.insert(RestyleHint::RESTYLE_DESCENDANTS);
|
||||
}
|
||||
|
||||
if (raw.0 & (eRestyle_ForceDescendants.0 | eRestyle_Force.0)) != 0 {
|
||||
raw.0 &= !eRestyle_Force.0;
|
||||
hint.insert(RECASCADE_SELF);
|
||||
hint.insert(RestyleHint::RECASCADE_SELF);
|
||||
}
|
||||
|
||||
if (raw.0 & eRestyle_ForceDescendants.0) != 0 {
|
||||
raw.0 &= !eRestyle_ForceDescendants.0;
|
||||
hint.insert(RECASCADE_DESCENDANTS);
|
||||
hint.insert(RestyleHint::RECASCADE_DESCENDANTS);
|
||||
}
|
||||
|
||||
hint.insert(RestyleHint::from_bits_truncate(raw.0 as u8));
|
||||
|
@ -239,7 +239,7 @@ pub fn assert_restyle_hints_match() {
|
|||
use gecko_bindings::structs;
|
||||
|
||||
macro_rules! check_restyle_hints {
|
||||
( $( $a:ident => $b:ident ),*, ) => {
|
||||
( $( $a:ident => $b:path),*, ) => {
|
||||
if cfg!(debug_assertions) {
|
||||
let mut replacements = RestyleHint::replacements();
|
||||
$(
|
||||
|
@ -254,9 +254,9 @@ pub fn assert_restyle_hints_match() {
|
|||
}
|
||||
|
||||
check_restyle_hints! {
|
||||
nsRestyleHint_eRestyle_CSSTransitions => RESTYLE_CSS_TRANSITIONS,
|
||||
nsRestyleHint_eRestyle_CSSAnimations => RESTYLE_CSS_ANIMATIONS,
|
||||
nsRestyleHint_eRestyle_StyleAttribute => RESTYLE_STYLE_ATTRIBUTE,
|
||||
nsRestyleHint_eRestyle_StyleAttribute_Animations => RESTYLE_SMIL,
|
||||
nsRestyleHint_eRestyle_CSSTransitions => RestyleHint::RESTYLE_CSS_TRANSITIONS,
|
||||
nsRestyleHint_eRestyle_CSSAnimations => RestyleHint::RESTYLE_CSS_ANIMATIONS,
|
||||
nsRestyleHint_eRestyle_StyleAttribute => RestyleHint::RESTYLE_STYLE_ATTRIBUTE,
|
||||
nsRestyleHint_eRestyle_StyleAttribute_Animations => RestyleHint::RESTYLE_SMIL,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ use Atom;
|
|||
use LocalName as SelectorLocalName;
|
||||
use dom::{TElement, TNode};
|
||||
use fnv::FnvHashSet;
|
||||
use invalidation::element::restyle_hints::{RESTYLE_SELF, RestyleHint};
|
||||
use invalidation::element::restyle_hints::RestyleHint;
|
||||
use media_queries::Device;
|
||||
use selector_parser::SelectorImpl;
|
||||
use selectors::attr::CaseSensitivity;
|
||||
|
@ -223,12 +223,12 @@ impl StylesheetInvalidationSet {
|
|||
|
||||
let mut self_invalid = false;
|
||||
|
||||
if !data.hint.contains(RESTYLE_SELF) {
|
||||
if !data.hint.contains(RestyleHint::RESTYLE_SELF) {
|
||||
for invalidation in &self.invalid_elements {
|
||||
if invalidation.matches(element) {
|
||||
debug!("process_invalidations_in_subtree: {:?} matched self {:?}",
|
||||
element, invalidation);
|
||||
data.hint.insert(RESTYLE_SELF);
|
||||
data.hint.insert(RestyleHint::RESTYLE_SELF);
|
||||
self_invalid = true;
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue