mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
style: Run rustfmt on servo/components/style and servo/ports/geckolib
This patch is generated by running `cargo +nightly fmt` under `servo/components/style/` and `servo/ports/geckolib` against mozilla-central https://hg.mozilla.org/mozilla-central/rev/b193f2e7a6a5d1f042c957ea4acd5c89bf210512 My nightly version is: 1.58.0-nightly (c9c4b5d72 2021-11-17) Manually remove the redundant braces in author_styles.rs to fix a warning. Differential Revision: https://phabricator.services.mozilla.com/D131556
This commit is contained in:
parent
33ad82c3da
commit
a0617bff0d
50 changed files with 486 additions and 340 deletions
|
@ -11,7 +11,9 @@ use crate::element_state::{DocumentState, ElementState};
|
|||
#[cfg(feature = "gecko")]
|
||||
use crate::gecko_bindings::structs::{ServoStyleSetSizes, StyleRuleInclusion};
|
||||
use crate::invalidation::element::invalidation_map::InvalidationMap;
|
||||
use crate::invalidation::media_queries::{EffectiveMediaQueryResults, MediaListKey, ToMediaListKey};
|
||||
use crate::invalidation::media_queries::{
|
||||
EffectiveMediaQueryResults, MediaListKey, ToMediaListKey,
|
||||
};
|
||||
use crate::invalidation::stylesheets::RuleChangeKind;
|
||||
use crate::media_queries::Device;
|
||||
use crate::properties::{self, CascadeMode, ComputedValues};
|
||||
|
@ -25,15 +27,18 @@ use crate::shared_lock::{Locked, SharedRwLockReadGuard, StylesheetGuards};
|
|||
use crate::stylesheet_set::{DataValidity, DocumentStylesheetSet, SheetRebuildKind};
|
||||
use crate::stylesheet_set::{DocumentStylesheetFlusher, SheetCollectionFlusher};
|
||||
use crate::stylesheets::keyframes_rule::KeyframesAnimation;
|
||||
use crate::stylesheets::layer_rule::{LayerName, LayerId, LayerOrder};
|
||||
use crate::stylesheets::layer_rule::{LayerId, LayerName, LayerOrder};
|
||||
use crate::stylesheets::viewport_rule::{self, MaybeNew, ViewportRule};
|
||||
use crate::stylesheets::{StyleRule, StylesheetInDocument, StylesheetContents};
|
||||
#[cfg(feature = "gecko")]
|
||||
use crate::stylesheets::{CounterStyleRule, FontFaceRule, FontFeatureValuesRule, PageRule};
|
||||
use crate::stylesheets::{CssRule, Origin, OriginSet, PerOrigin, PerOriginIter, EffectiveRulesIterator};
|
||||
use crate::stylesheets::{
|
||||
CssRule, EffectiveRulesIterator, Origin, OriginSet, PerOrigin, PerOriginIter,
|
||||
};
|
||||
use crate::stylesheets::{StyleRule, StylesheetContents, StylesheetInDocument};
|
||||
use crate::thread_state::{self, ThreadState};
|
||||
use crate::{Atom, LocalName, Namespace, WeakAtom};
|
||||
use fallible::FallibleVec;
|
||||
use fxhash::FxHashMap;
|
||||
use hashglobe::FailedAllocationError;
|
||||
use malloc_size_of::MallocSizeOf;
|
||||
#[cfg(feature = "gecko")]
|
||||
|
@ -48,11 +53,10 @@ use selectors::NthIndexCache;
|
|||
use servo_arc::{Arc, ArcBorrow};
|
||||
use smallbitvec::SmallBitVec;
|
||||
use smallvec::SmallVec;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::sync::Mutex;
|
||||
use std::{mem, ops};
|
||||
use std::hash::{Hash, Hasher};
|
||||
use style_traits::viewport::ViewportConstraints;
|
||||
use fxhash::FxHashMap;
|
||||
|
||||
/// The type of the stylesheets that the stylist contains.
|
||||
#[cfg(feature = "servo")]
|
||||
|
@ -93,7 +97,7 @@ struct CascadeDataCacheKey {
|
|||
unsafe impl Send for CascadeDataCacheKey {}
|
||||
unsafe impl Sync for CascadeDataCacheKey {}
|
||||
|
||||
trait CascadeDataCacheEntry : Sized {
|
||||
trait CascadeDataCacheEntry: Sized {
|
||||
/// Returns a reference to the cascade data.
|
||||
fn cascade_data(&self) -> &CascadeData;
|
||||
/// Rebuilds the cascade data for the new stylesheet collection. The
|
||||
|
@ -121,7 +125,9 @@ where
|
|||
Entry: CascadeDataCacheEntry,
|
||||
{
|
||||
fn new() -> Self {
|
||||
Self { entries: Default::default() }
|
||||
Self {
|
||||
entries: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
fn len(&self) -> usize {
|
||||
|
@ -165,15 +171,9 @@ where
|
|||
match self.entries.entry(key) {
|
||||
HashMapEntry::Vacant(e) => {
|
||||
debug!("> Picking the slow path (not in the cache)");
|
||||
new_entry = Entry::rebuild(
|
||||
device,
|
||||
quirks_mode,
|
||||
collection,
|
||||
guard,
|
||||
old_entry,
|
||||
)?;
|
||||
new_entry = Entry::rebuild(device, quirks_mode, collection, guard, old_entry)?;
|
||||
e.insert(new_entry.clone());
|
||||
}
|
||||
},
|
||||
HashMapEntry::Occupied(mut e) => {
|
||||
// Avoid reusing our old entry (this can happen if we get
|
||||
// invalidated due to CSSOM mutations and our old stylesheet
|
||||
|
@ -192,15 +192,9 @@ where
|
|||
}
|
||||
|
||||
debug!("> Picking the slow path due to same entry as old");
|
||||
new_entry = Entry::rebuild(
|
||||
device,
|
||||
quirks_mode,
|
||||
collection,
|
||||
guard,
|
||||
old_entry,
|
||||
)?;
|
||||
new_entry = Entry::rebuild(device, quirks_mode, collection, guard, old_entry)?;
|
||||
e.insert(new_entry.clone());
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
Ok(Some(new_entry))
|
||||
|
@ -272,7 +266,7 @@ impl CascadeDataCacheEntry for UserAgentCascadeData {
|
|||
_old: &Self,
|
||||
) -> Result<Arc<Self>, FailedAllocationError>
|
||||
where
|
||||
S: StylesheetInDocument + PartialEq + 'static
|
||||
S: StylesheetInDocument + PartialEq + 'static,
|
||||
{
|
||||
// TODO: Maybe we should support incremental rebuilds, though they seem
|
||||
// uncommon and rebuild() doesn't deal with
|
||||
|
@ -604,13 +598,8 @@ impl Stylist {
|
|||
where
|
||||
S: StylesheetInDocument + PartialEq + 'static,
|
||||
{
|
||||
self.author_data_cache.lookup(
|
||||
&self.device,
|
||||
self.quirks_mode,
|
||||
collection,
|
||||
guard,
|
||||
old_data,
|
||||
)
|
||||
self.author_data_cache
|
||||
.lookup(&self.device, self.quirks_mode, collection, guard, old_data)
|
||||
}
|
||||
|
||||
/// Iterate over the extra data in origin order.
|
||||
|
@ -2114,7 +2103,11 @@ impl CascadeData {
|
|||
}
|
||||
|
||||
fn compute_layer_order(&mut self) {
|
||||
debug_assert_ne!(self.layers.len(), 0, "There should be at least the root layer!");
|
||||
debug_assert_ne!(
|
||||
self.layers.len(),
|
||||
0,
|
||||
"There should be at least the root layer!"
|
||||
);
|
||||
if self.layers.len() == 1 {
|
||||
return; // Nothing to do
|
||||
}
|
||||
|
@ -2131,7 +2124,10 @@ impl CascadeData {
|
|||
order: &mut LayerOrder,
|
||||
) {
|
||||
for child in parent.children.iter() {
|
||||
debug_assert!(parent.id < *child, "Children are always registered after parents");
|
||||
debug_assert!(
|
||||
parent.id < *child,
|
||||
"Children are always registered after parents"
|
||||
);
|
||||
let child_index = (child.0 - parent.id.0 - 1) as usize;
|
||||
let (first, remaining) = remaining_layers.split_at_mut(child_index + 1);
|
||||
let child = &mut first[child_index];
|
||||
|
@ -2323,7 +2319,10 @@ impl CascadeData {
|
|||
|
||||
let keyframes_rule = keyframes_rule.read_with(guard);
|
||||
debug!("Found valid keyframes rule: {:?}", *keyframes_rule);
|
||||
match self.animations.try_entry(keyframes_rule.name.as_atom().clone())? {
|
||||
match self
|
||||
.animations
|
||||
.try_entry(keyframes_rule.name.as_atom().clone())?
|
||||
{
|
||||
Entry::Vacant(e) => {
|
||||
e.insert(KeyframesAnimation::from_keyframes(
|
||||
&keyframes_rule.keyframes,
|
||||
|
@ -2338,9 +2337,8 @@ impl CascadeData {
|
|||
//
|
||||
// TODO(emilio): This will need to be harder for
|
||||
// layers.
|
||||
let needs_insert =
|
||||
keyframes_rule.vendor_prefix.is_none() ||
|
||||
e.get().vendor_prefix.is_some();
|
||||
let needs_insert = keyframes_rule.vendor_prefix.is_none() ||
|
||||
e.get().vendor_prefix.is_some();
|
||||
if needs_insert {
|
||||
e.insert(KeyframesAnimation::from_keyframes(
|
||||
&keyframes_rule.keyframes,
|
||||
|
@ -2401,13 +2399,8 @@ impl CascadeData {
|
|||
}
|
||||
|
||||
let mut effective = false;
|
||||
let children = EffectiveRulesIterator::children(
|
||||
rule,
|
||||
device,
|
||||
quirks_mode,
|
||||
guard,
|
||||
&mut effective,
|
||||
);
|
||||
let children =
|
||||
EffectiveRulesIterator::children(rule, device, quirks_mode, guard, &mut effective);
|
||||
|
||||
if !effective {
|
||||
continue;
|
||||
|
@ -2426,7 +2419,8 @@ impl CascadeData {
|
|||
let mut parent = layer.clone();
|
||||
parent.0.pop();
|
||||
|
||||
*data.layer_id
|
||||
*data
|
||||
.layer_id
|
||||
.get_mut(&parent)
|
||||
.expect("Parent layers should be registered before child layers")
|
||||
} else {
|
||||
|
@ -2489,7 +2483,6 @@ impl CascadeData {
|
|||
&mut layer_names_to_pop,
|
||||
);
|
||||
}
|
||||
|
||||
},
|
||||
CssRule::Media(ref lock) => {
|
||||
if rebuild_kind.should_rebuild_invalidation() {
|
||||
|
@ -2509,7 +2502,7 @@ impl CascadeData {
|
|||
&mut current_layer,
|
||||
&mut layer_names_to_pop,
|
||||
);
|
||||
}
|
||||
},
|
||||
LayerRuleKind::Statement { ref names } => {
|
||||
for name in &**names {
|
||||
let mut pushed = 0;
|
||||
|
@ -2525,7 +2518,7 @@ impl CascadeData {
|
|||
current_layer.0.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
// We don't care about any other rule.
|
||||
|
@ -2609,7 +2602,9 @@ impl CascadeData {
|
|||
|
||||
let effective_now = stylesheet.is_effective_for_device(device, guard);
|
||||
|
||||
let effective_then = self.effective_media_query_results.was_effective(stylesheet.contents());
|
||||
let effective_then = self
|
||||
.effective_media_query_results
|
||||
.was_effective(stylesheet.contents());
|
||||
|
||||
if effective_now != effective_then {
|
||||
debug!(
|
||||
|
@ -2739,7 +2734,7 @@ impl CascadeDataCacheEntry for CascadeData {
|
|||
old: &Self,
|
||||
) -> Result<Arc<Self>, FailedAllocationError>
|
||||
where
|
||||
S: StylesheetInDocument + PartialEq + 'static
|
||||
S: StylesheetInDocument + PartialEq + 'static,
|
||||
{
|
||||
debug_assert!(collection.dirty(), "We surely need to do something?");
|
||||
// If we're doing a full rebuild anyways, don't bother cloning the data.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue