mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
style: Make the allocation of AuthorStyles for ShadowRoot lazy.
So that we don't waste a bunch of memory with stuff like <svg:use>. I plan to shrink AuthorStyles further, but this should help regardless, and isn't very complex. Differential Revision: https://phabricator.services.mozilla.com/D4618
This commit is contained in:
parent
1bc452703b
commit
1e6aa62c6f
3 changed files with 41 additions and 28 deletions
|
@ -342,7 +342,7 @@ pub trait TShadowRoot: Sized + Copy + Clone + PartialEq {
|
|||
fn host(&self) -> <Self::ConcreteNode as TNode>::ConcreteElement;
|
||||
|
||||
/// Get the style data for this ShadowRoot.
|
||||
fn style_data<'a>(&self) -> &'a CascadeData
|
||||
fn style_data<'a>(&self) -> Option<&'a CascadeData>
|
||||
where
|
||||
Self: 'a;
|
||||
|
||||
|
@ -824,30 +824,36 @@ pub trait TElement:
|
|||
|
||||
if let Some(shadow) = self.containing_shadow() {
|
||||
doc_rules_apply = false;
|
||||
f(
|
||||
shadow.style_data(),
|
||||
self.as_node().owner_doc().quirks_mode(),
|
||||
Some(shadow.host()),
|
||||
);
|
||||
if let Some(data) = shadow.style_data() {
|
||||
f(
|
||||
data,
|
||||
self.as_node().owner_doc().quirks_mode(),
|
||||
Some(shadow.host()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(shadow) = self.shadow_root() {
|
||||
f(
|
||||
shadow.style_data(),
|
||||
self.as_node().owner_doc().quirks_mode(),
|
||||
Some(shadow.host()),
|
||||
);
|
||||
if let Some(data) = shadow.style_data() {
|
||||
f(
|
||||
data,
|
||||
self.as_node().owner_doc().quirks_mode(),
|
||||
Some(shadow.host()),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let mut current = self.assigned_slot();
|
||||
while let Some(slot) = current {
|
||||
// Slots can only have assigned nodes when in a shadow tree.
|
||||
let shadow = slot.containing_shadow().unwrap();
|
||||
f(
|
||||
shadow.style_data(),
|
||||
self.as_node().owner_doc().quirks_mode(),
|
||||
Some(shadow.host()),
|
||||
);
|
||||
if let Some(data) = shadow.style_data() {
|
||||
f(
|
||||
data,
|
||||
self.as_node().owner_doc().quirks_mode(),
|
||||
Some(shadow.host()),
|
||||
);
|
||||
}
|
||||
current = slot.assigned_slot();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue