mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
layout: Add a new cascading mode that inherits all properties, even
non-inheritable ones. This works like the `modify_style_for_*` functions and will allow us to easily migrate from them to real cascading.
This commit is contained in:
parent
93e41ba4aa
commit
fb2d1e1020
6 changed files with 86 additions and 43 deletions
|
@ -10,7 +10,8 @@ use error_reporting::StdoutErrorReporter;
|
|||
use keyframes::KeyframesAnimation;
|
||||
use media_queries::{Device, MediaType};
|
||||
use parking_lot::{RwLock, RwLockReadGuard};
|
||||
use properties::{self, PropertyDeclaration, PropertyDeclarationBlock, ComputedValues, Importance};
|
||||
use properties::{self, CascadeFlags, ComputedValues, INHERIT_ALL, Importance};
|
||||
use properties::{PropertyDeclaration, PropertyDeclarationBlock};
|
||||
use quickersort::sort_by;
|
||||
use restyle_hints::{RestyleHint, DependencySet};
|
||||
use selector_impl::{ElementExt, TheSelectorImpl, PseudoElement};
|
||||
|
@ -252,19 +253,30 @@ impl Stylist {
|
|||
|
||||
/// Computes the style for a given "precomputed" pseudo-element, taking the
|
||||
/// universal rules and applying them.
|
||||
///
|
||||
/// If `inherit_all` is true, then all properties are inherited from the parent; otherwise,
|
||||
/// non-inherited properties are reset to their initial values. The flow constructor uses this
|
||||
/// flag when constructing anonymous flows.
|
||||
pub fn precomputed_values_for_pseudo(&self,
|
||||
pseudo: &PseudoElement,
|
||||
parent: Option<&Arc<ComputedValues>>)
|
||||
parent: Option<&Arc<ComputedValues>>,
|
||||
inherit_all: bool)
|
||||
-> Option<Arc<ComputedValues>> {
|
||||
debug_assert!(TheSelectorImpl::pseudo_element_cascade_type(pseudo).is_precomputed());
|
||||
if let Some(declarations) = self.precomputed_pseudo_element_decls.get(pseudo) {
|
||||
let mut flags = CascadeFlags::empty();
|
||||
if inherit_all {
|
||||
flags.insert(INHERIT_ALL)
|
||||
}
|
||||
|
||||
let (computed, _) =
|
||||
properties::cascade(self.device.au_viewport_size(),
|
||||
&declarations, false,
|
||||
&declarations,
|
||||
parent.map(|p| &**p),
|
||||
None,
|
||||
None,
|
||||
Box::new(StdoutErrorReporter));
|
||||
Box::new(StdoutErrorReporter),
|
||||
flags);
|
||||
Some(Arc::new(computed))
|
||||
} else {
|
||||
parent.map(|p| p.clone())
|
||||
|
@ -325,10 +337,12 @@ impl Stylist {
|
|||
|
||||
let (computed, _) =
|
||||
properties::cascade(self.device.au_viewport_size(),
|
||||
&declarations, false,
|
||||
Some(&**parent), None, None,
|
||||
Box::new(StdoutErrorReporter));
|
||||
|
||||
&declarations,
|
||||
Some(&**parent),
|
||||
None,
|
||||
None,
|
||||
Box::new(StdoutErrorReporter),
|
||||
CascadeFlags::empty());
|
||||
|
||||
Some(Arc::new(computed))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue