mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
style: Better debugging for media-query related code and ua-cache.
Bug: 1470145 Reviewed-by: xidorn MozReview-Commit-ID: 3XHAxK2BOTS
This commit is contained in:
parent
f564b32b75
commit
82db42390d
4 changed files with 49 additions and 11 deletions
|
@ -75,6 +75,10 @@ impl UserAgentCascadeDataCache {
|
|||
Self { entries: vec![] }
|
||||
}
|
||||
|
||||
fn len(&self) -> usize {
|
||||
self.entries.len()
|
||||
}
|
||||
|
||||
// FIXME(emilio): This may need to be keyed on quirks-mode too, though there
|
||||
// aren't class / id selectors on those sheets, usually, so it's probably
|
||||
// ok...
|
||||
|
@ -90,6 +94,7 @@ impl UserAgentCascadeDataCache {
|
|||
S: StylesheetInDocument + ToMediaListKey + PartialEq + 'static,
|
||||
{
|
||||
let mut key = EffectiveMediaQueryResults::new();
|
||||
debug!("UserAgentCascadeDataCache::lookup({:?})", device);
|
||||
for sheet in sheets.clone() {
|
||||
CascadeData::collect_applicable_media_query_results_into(device, sheet, guard, &mut key)
|
||||
}
|
||||
|
@ -105,6 +110,8 @@ impl UserAgentCascadeDataCache {
|
|||
precomputed_pseudo_element_decls: PrecomputedPseudoElementDeclarations::default(),
|
||||
};
|
||||
|
||||
debug!("> Picking the slow path");
|
||||
|
||||
for sheet in sheets {
|
||||
new_data.cascade_data.add_stylesheet(
|
||||
device,
|
||||
|
@ -117,7 +124,6 @@ impl UserAgentCascadeDataCache {
|
|||
}
|
||||
|
||||
let new_data = Arc::new(new_data);
|
||||
|
||||
self.entries.push(new_data.clone());
|
||||
Ok(new_data)
|
||||
}
|
||||
|
@ -244,8 +250,8 @@ impl DocumentCascadeData {
|
|||
let origin_sheets = flusher.origin_sheets(Origin::UserAgent);
|
||||
let ua_cascade_data =
|
||||
ua_cache.lookup(origin_sheets, device, quirks_mode, guards.ua_or_user)?;
|
||||
|
||||
ua_cache.expire_unused();
|
||||
debug!("User agent data cache size {:?}", ua_cache.len());
|
||||
self.user_agent = ua_cascade_data;
|
||||
}
|
||||
}
|
||||
|
@ -1085,7 +1091,7 @@ impl Stylist {
|
|||
guards: &StylesheetGuards,
|
||||
device: &Device,
|
||||
) -> OriginSet {
|
||||
debug!("Stylist::media_features_change_changed_style");
|
||||
debug!("Stylist::media_features_change_changed_style {:?}", device);
|
||||
|
||||
let mut origins = OriginSet::empty();
|
||||
let stylesheets = self.stylesheets.iter();
|
||||
|
@ -2145,16 +2151,19 @@ impl CascadeData {
|
|||
return;
|
||||
}
|
||||
|
||||
debug!(" + {:?}", stylesheet);
|
||||
results.saw_effective(stylesheet);
|
||||
|
||||
for rule in stylesheet.effective_rules(device, guard) {
|
||||
match *rule {
|
||||
CssRule::Import(ref lock) => {
|
||||
let import_rule = lock.read_with(guard);
|
||||
debug!(" + {:?}", import_rule.stylesheet.media(guard));
|
||||
results.saw_effective(import_rule);
|
||||
},
|
||||
CssRule::Media(ref lock) => {
|
||||
let media_rule = lock.read_with(guard);
|
||||
debug!(" + {:?}", media_rule.media_queries.read_with(guard));
|
||||
results.saw_effective(media_rule);
|
||||
},
|
||||
_ => {},
|
||||
|
@ -2346,8 +2355,10 @@ impl CascadeData {
|
|||
|
||||
if effective_now != effective_then {
|
||||
debug!(
|
||||
" > Stylesheet changed -> {}, {}",
|
||||
effective_then, effective_now
|
||||
" > Stylesheet {:?} changed -> {}, {}",
|
||||
stylesheet.media(guard),
|
||||
effective_then,
|
||||
effective_now
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
@ -2382,8 +2393,10 @@ impl CascadeData {
|
|||
.was_effective(import_rule);
|
||||
if effective_now != effective_then {
|
||||
debug!(
|
||||
" > @import rule changed {} -> {}",
|
||||
effective_then, effective_now
|
||||
" > @import rule {:?} changed {} -> {}",
|
||||
import_rule.stylesheet.media(guard),
|
||||
effective_then,
|
||||
effective_now
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
@ -2401,8 +2414,10 @@ impl CascadeData {
|
|||
|
||||
if effective_now != effective_then {
|
||||
debug!(
|
||||
" > @media rule changed {} -> {}",
|
||||
effective_then, effective_now
|
||||
" > @media rule {:?} changed {} -> {}",
|
||||
mq,
|
||||
effective_then,
|
||||
effective_now
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue