mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Remove the dependency of css/matching.rs on SharedLayoutContext.
This commit is contained in:
parent
08f2a24552
commit
94b0789a5f
2 changed files with 21 additions and 22 deletions
|
@ -7,7 +7,6 @@
|
||||||
#![allow(unsafe_code)]
|
#![allow(unsafe_code)]
|
||||||
|
|
||||||
use animation;
|
use animation;
|
||||||
use context::SharedLayoutContext;
|
|
||||||
use msg::ParseErrorReporter;
|
use msg::ParseErrorReporter;
|
||||||
use script::layout_interface::Animation;
|
use script::layout_interface::Animation;
|
||||||
use selectors::bloom::BloomFilter;
|
use selectors::bloom::BloomFilter;
|
||||||
|
@ -15,6 +14,7 @@ use selectors::parser::PseudoElement;
|
||||||
use selectors::{Element};
|
use selectors::{Element};
|
||||||
use std::sync::mpsc::Sender;
|
use std::sync::mpsc::Sender;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
use style::context::SharedStyleContext;
|
||||||
use style::data::PrivateStyleData;
|
use style::data::PrivateStyleData;
|
||||||
use style::dom::{TElement, TNode, TRestyleDamage};
|
use style::dom::{TElement, TNode, TRestyleDamage};
|
||||||
use style::matching::{ApplicableDeclarations, ApplicableDeclarationsCache};
|
use style::matching::{ApplicableDeclarations, ApplicableDeclarationsCache};
|
||||||
|
@ -35,7 +35,7 @@ pub enum StyleSharingResult<ConcreteRestyleDamage: TRestyleDamage> {
|
||||||
|
|
||||||
trait PrivateMatchMethods<'ln>: TNode<'ln> {
|
trait PrivateMatchMethods<'ln>: TNode<'ln> {
|
||||||
fn cascade_node_pseudo_element(&self,
|
fn cascade_node_pseudo_element(&self,
|
||||||
layout_context: &SharedLayoutContext,
|
context: &SharedStyleContext,
|
||||||
parent_style: Option<&Arc<ComputedValues>>,
|
parent_style: Option<&Arc<ComputedValues>>,
|
||||||
applicable_declarations: &[DeclarationBlock],
|
applicable_declarations: &[DeclarationBlock],
|
||||||
style: &mut Option<Arc<ComputedValues>>,
|
style: &mut Option<Arc<ComputedValues>>,
|
||||||
|
@ -47,7 +47,7 @@ trait PrivateMatchMethods<'ln>: TNode<'ln> {
|
||||||
-> Self::ConcreteRestyleDamage {
|
-> Self::ConcreteRestyleDamage {
|
||||||
let mut cacheable = true;
|
let mut cacheable = true;
|
||||||
if animate_properties {
|
if animate_properties {
|
||||||
cacheable = !self.update_animations_for_cascade(layout_context, style) && cacheable;
|
cacheable = !self.update_animations_for_cascade(context, style) && cacheable;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut this_style;
|
let mut this_style;
|
||||||
|
@ -58,22 +58,22 @@ trait PrivateMatchMethods<'ln>: TNode<'ln> {
|
||||||
None => None,
|
None => None,
|
||||||
Some(ref style) => Some(&**style),
|
Some(ref style) => Some(&**style),
|
||||||
};
|
};
|
||||||
let (the_style, is_cacheable) = cascade(layout_context.style_context.viewport_size,
|
let (the_style, is_cacheable) = cascade(context.viewport_size,
|
||||||
applicable_declarations,
|
applicable_declarations,
|
||||||
shareable,
|
shareable,
|
||||||
Some(&***parent_style),
|
Some(&***parent_style),
|
||||||
cached_computed_values,
|
cached_computed_values,
|
||||||
layout_context.style_context.error_reporter.clone());
|
context.error_reporter.clone());
|
||||||
cacheable = cacheable && is_cacheable;
|
cacheable = cacheable && is_cacheable;
|
||||||
this_style = the_style
|
this_style = the_style
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
let (the_style, is_cacheable) = cascade(layout_context.style_context.viewport_size,
|
let (the_style, is_cacheable) = cascade(context.viewport_size,
|
||||||
applicable_declarations,
|
applicable_declarations,
|
||||||
shareable,
|
shareable,
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
layout_context.style_context.error_reporter.clone());
|
context.error_reporter.clone());
|
||||||
cacheable = cacheable && is_cacheable;
|
cacheable = cacheable && is_cacheable;
|
||||||
this_style = the_style
|
this_style = the_style
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ trait PrivateMatchMethods<'ln>: TNode<'ln> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_animations_for_cascade(&self,
|
fn update_animations_for_cascade(&self,
|
||||||
layout_context: &SharedLayoutContext,
|
context: &SharedStyleContext,
|
||||||
style: &mut Option<Arc<ComputedValues>>)
|
style: &mut Option<Arc<ComputedValues>>)
|
||||||
-> bool {
|
-> bool {
|
||||||
let style = match *style {
|
let style = match *style {
|
||||||
|
@ -120,7 +120,7 @@ trait PrivateMatchMethods<'ln>: TNode<'ln> {
|
||||||
let this_opaque = self.opaque();
|
let this_opaque = self.opaque();
|
||||||
let had_animations_to_expire;
|
let had_animations_to_expire;
|
||||||
{
|
{
|
||||||
let all_expired_animations = layout_context.style_context.expired_animations.read().unwrap();
|
let all_expired_animations = context.expired_animations.read().unwrap();
|
||||||
let animations_to_expire = all_expired_animations.get(&this_opaque);
|
let animations_to_expire = all_expired_animations.get(&this_opaque);
|
||||||
had_animations_to_expire = animations_to_expire.is_some();
|
had_animations_to_expire = animations_to_expire.is_some();
|
||||||
if let Some(ref animations) = animations_to_expire {
|
if let Some(ref animations) = animations_to_expire {
|
||||||
|
@ -131,18 +131,17 @@ trait PrivateMatchMethods<'ln>: TNode<'ln> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if had_animations_to_expire {
|
if had_animations_to_expire {
|
||||||
layout_context.style_context.expired_animations.write().unwrap().remove(&this_opaque);
|
context.expired_animations.write().unwrap().remove(&this_opaque);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Merge any running transitions into the current style, and cancel them.
|
// Merge any running transitions into the current style, and cancel them.
|
||||||
let had_running_animations = layout_context.style_context
|
let had_running_animations = context.running_animations
|
||||||
.running_animations
|
.read()
|
||||||
.read()
|
.unwrap()
|
||||||
.unwrap()
|
.get(&this_opaque)
|
||||||
.get(&this_opaque)
|
.is_some();
|
||||||
.is_some();
|
|
||||||
if had_running_animations {
|
if had_running_animations {
|
||||||
let mut all_running_animations = layout_context.style_context.running_animations.write().unwrap();
|
let mut all_running_animations = context.running_animations.write().unwrap();
|
||||||
for running_animation in all_running_animations.get(&this_opaque).unwrap() {
|
for running_animation in all_running_animations.get(&this_opaque).unwrap() {
|
||||||
animation::update_style_for_animation::<Self::ConcreteRestyleDamage>(running_animation, style, None);
|
animation::update_style_for_animation::<Self::ConcreteRestyleDamage>(running_animation, style, None);
|
||||||
}
|
}
|
||||||
|
@ -307,7 +306,7 @@ pub trait MatchMethods<'ln> : TNode<'ln> {
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn cascade_node(&self,
|
unsafe fn cascade_node(&self,
|
||||||
layout_context: &SharedLayoutContext,
|
context: &SharedStyleContext,
|
||||||
parent: Option<Self>,
|
parent: Option<Self>,
|
||||||
applicable_declarations: &ApplicableDeclarations,
|
applicable_declarations: &ApplicableDeclarations,
|
||||||
applicable_declarations_cache: &mut ApplicableDeclarationsCache,
|
applicable_declarations_cache: &mut ApplicableDeclarationsCache,
|
||||||
|
@ -340,7 +339,7 @@ pub trait MatchMethods<'ln> : TNode<'ln> {
|
||||||
let mut data_ref = self.mutate_data().unwrap();
|
let mut data_ref = self.mutate_data().unwrap();
|
||||||
let mut data = &mut *data_ref;
|
let mut data = &mut *data_ref;
|
||||||
damage = self.cascade_node_pseudo_element(
|
damage = self.cascade_node_pseudo_element(
|
||||||
layout_context,
|
context,
|
||||||
parent_style,
|
parent_style,
|
||||||
&applicable_declarations.normal,
|
&applicable_declarations.normal,
|
||||||
&mut data.style,
|
&mut data.style,
|
||||||
|
@ -350,7 +349,7 @@ pub trait MatchMethods<'ln> : TNode<'ln> {
|
||||||
true);
|
true);
|
||||||
if !applicable_declarations.before.is_empty() {
|
if !applicable_declarations.before.is_empty() {
|
||||||
damage = damage | self.cascade_node_pseudo_element(
|
damage = damage | self.cascade_node_pseudo_element(
|
||||||
layout_context,
|
context,
|
||||||
Some(data.style.as_ref().unwrap()),
|
Some(data.style.as_ref().unwrap()),
|
||||||
&*applicable_declarations.before,
|
&*applicable_declarations.before,
|
||||||
&mut data.before_style,
|
&mut data.before_style,
|
||||||
|
@ -361,7 +360,7 @@ pub trait MatchMethods<'ln> : TNode<'ln> {
|
||||||
}
|
}
|
||||||
if !applicable_declarations.after.is_empty() {
|
if !applicable_declarations.after.is_empty() {
|
||||||
damage = damage | self.cascade_node_pseudo_element(
|
damage = damage | self.cascade_node_pseudo_element(
|
||||||
layout_context,
|
context,
|
||||||
Some(data.style.as_ref().unwrap()),
|
Some(data.style.as_ref().unwrap()),
|
||||||
&*applicable_declarations.after,
|
&*applicable_declarations.after,
|
||||||
&mut data.after_style,
|
&mut data.after_style,
|
||||||
|
|
|
@ -217,7 +217,7 @@ fn recalc_style_at<'a, 'ln, N: LayoutNode<'ln>> (context: &'a DomTraversalContex
|
||||||
|
|
||||||
// Perform the CSS cascade.
|
// Perform the CSS cascade.
|
||||||
unsafe {
|
unsafe {
|
||||||
node.cascade_node(context.layout_context.shared,
|
node.cascade_node(&context.layout_context.shared.style_context,
|
||||||
parent_opt,
|
parent_opt,
|
||||||
&applicable_declarations,
|
&applicable_declarations,
|
||||||
&mut context.layout_context.applicable_declarations_cache(),
|
&mut context.layout_context.applicable_declarations_cache(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue