mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Rename ComputedValuesStruct to ComputedValues.
Doing this in a separate commit avoids mixups with the ComputedValues trait that the previous commit removed.
This commit is contained in:
parent
789807b7b0
commit
4b7060554b
15 changed files with 101 additions and 101 deletions
|
@ -15,7 +15,7 @@ use properties::longhands::animation_iteration_count::computed_value::AnimationI
|
|||
use properties::longhands::animation_play_state::computed_value::AnimationPlayState;
|
||||
use properties::longhands::transition_timing_function::computed_value::StartEnd;
|
||||
use properties::longhands::transition_timing_function::computed_value::TransitionTimingFunction;
|
||||
use properties::{self, ComputedValuesStruct};
|
||||
use properties::{self, ComputedValues};
|
||||
use selector_impl::SelectorImplExt;
|
||||
use selectors::matching::DeclarationBlock;
|
||||
use std::sync::Arc;
|
||||
|
@ -71,7 +71,7 @@ pub struct KeyframesAnimationState {
|
|||
pub expired: bool,
|
||||
/// The original cascade style, needed to compute the generated keyframes of
|
||||
/// the animation.
|
||||
pub cascade_style: Arc<ComputedValuesStruct>,
|
||||
pub cascade_style: Arc<ComputedValues>,
|
||||
}
|
||||
|
||||
impl KeyframesAnimationState {
|
||||
|
@ -249,8 +249,8 @@ impl PropertyAnimation {
|
|||
/// Any number of animations may be returned, from zero (if the property did not animate) to
|
||||
/// one (for a single transition property) to arbitrarily many (for `all`).
|
||||
pub fn from_transition(transition_index: usize,
|
||||
old_style: &ComputedValuesStruct,
|
||||
new_style: &mut ComputedValuesStruct)
|
||||
old_style: &ComputedValues,
|
||||
new_style: &mut ComputedValues)
|
||||
-> Vec<PropertyAnimation> {
|
||||
let mut result = vec![];
|
||||
let box_style = new_style.get_box();
|
||||
|
@ -288,8 +288,8 @@ impl PropertyAnimation {
|
|||
fn from_transition_property(transition_property: TransitionProperty,
|
||||
timing_function: TransitionTimingFunction,
|
||||
duration: Time,
|
||||
old_style: &ComputedValuesStruct,
|
||||
new_style: &ComputedValuesStruct)
|
||||
old_style: &ComputedValues,
|
||||
new_style: &ComputedValues)
|
||||
-> Option<PropertyAnimation> {
|
||||
let animated_property = AnimatedProperty::from_transition_property(&transition_property,
|
||||
old_style,
|
||||
|
@ -308,7 +308,7 @@ impl PropertyAnimation {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn update(&self, style: &mut ComputedValuesStruct, time: f64) {
|
||||
pub fn update(&self, style: &mut ComputedValues, time: f64) {
|
||||
let progress = match self.timing_function {
|
||||
TransitionTimingFunction::CubicBezier(p1, p2) => {
|
||||
// See `WebCore::AnimationBase::solveEpsilon(double)` in WebKit.
|
||||
|
@ -341,8 +341,8 @@ impl PropertyAnimation {
|
|||
// cloneable part and a non-cloneable part..
|
||||
pub fn start_transitions_if_applicable<Impl: SelectorImplExt>(new_animations_sender: &Sender<Animation>,
|
||||
node: OpaqueNode,
|
||||
old_style: &ComputedValuesStruct,
|
||||
new_style: &mut Arc<ComputedValuesStruct>)
|
||||
old_style: &ComputedValues,
|
||||
new_style: &mut Arc<ComputedValues>)
|
||||
-> bool {
|
||||
let mut had_animations = false;
|
||||
for i in 0..new_style.get_box().transition_property_count() {
|
||||
|
@ -374,9 +374,9 @@ pub fn start_transitions_if_applicable<Impl: SelectorImplExt>(new_animations_sen
|
|||
|
||||
fn compute_style_for_animation_step<Impl: SelectorImplExt>(context: &SharedStyleContext<Impl>,
|
||||
step: &KeyframesStep,
|
||||
previous_style: &ComputedValuesStruct,
|
||||
style_from_cascade: &ComputedValuesStruct)
|
||||
-> ComputedValuesStruct {
|
||||
previous_style: &ComputedValues,
|
||||
style_from_cascade: &ComputedValues)
|
||||
-> ComputedValues {
|
||||
match step.value {
|
||||
// TODO: avoiding this spurious clone might involve having to create
|
||||
// an Arc in the below (more common case).
|
||||
|
@ -401,7 +401,7 @@ fn compute_style_for_animation_step<Impl: SelectorImplExt>(context: &SharedStyle
|
|||
pub fn maybe_start_animations<Impl: SelectorImplExt>(context: &SharedStyleContext<Impl>,
|
||||
new_animations_sender: &Sender<Animation>,
|
||||
node: OpaqueNode,
|
||||
new_style: &Arc<ComputedValuesStruct>) -> bool
|
||||
new_style: &Arc<ComputedValues>) -> bool
|
||||
{
|
||||
let mut had_animations = false;
|
||||
|
||||
|
@ -469,7 +469,7 @@ pub fn maybe_start_animations<Impl: SelectorImplExt>(context: &SharedStyleContex
|
|||
|
||||
/// Updates a given computed style for a given animation frame. Returns a bool
|
||||
/// representing if the style was indeed updated.
|
||||
pub fn update_style_for_animation_frame(mut new_style: &mut Arc<ComputedValuesStruct>,
|
||||
pub fn update_style_for_animation_frame(mut new_style: &mut Arc<ComputedValues>,
|
||||
now: f64,
|
||||
start_time: f64,
|
||||
frame: &AnimationFrame) -> bool {
|
||||
|
@ -490,7 +490,7 @@ pub fn update_style_for_animation_frame(mut new_style: &mut Arc<ComputedValuesSt
|
|||
/// If `damage` is provided, inserts the appropriate restyle damage.
|
||||
pub fn update_style_for_animation<Damage, Impl>(context: &SharedStyleContext<Impl>,
|
||||
animation: &Animation,
|
||||
style: &mut Arc<ComputedValuesStruct>,
|
||||
style: &mut Arc<ComputedValues>,
|
||||
damage: Option<&mut Damage>)
|
||||
where Impl: SelectorImplExt,
|
||||
Damage: TRestyleDamage {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
//! Per-node data used in style calculation.
|
||||
|
||||
use properties::ComputedValuesStruct;
|
||||
use properties::ComputedValues;
|
||||
use selectors::parser::SelectorImpl;
|
||||
use std::collections::HashMap;
|
||||
use std::hash::BuildHasherDefault;
|
||||
|
@ -13,10 +13,10 @@ use std::sync::atomic::AtomicIsize;
|
|||
|
||||
pub struct PrivateStyleData<Impl: SelectorImpl> {
|
||||
/// The results of CSS styling for this node.
|
||||
pub style: Option<Arc<ComputedValuesStruct>>,
|
||||
pub style: Option<Arc<ComputedValues>>,
|
||||
|
||||
/// The results of CSS styling for each pseudo-element (if any).
|
||||
pub per_pseudo: HashMap<Impl::PseudoElement, Arc<ComputedValuesStruct>,
|
||||
pub per_pseudo: HashMap<Impl::PseudoElement, Arc<ComputedValues>,
|
||||
BuildHasherDefault<::fnv::FnvHasher>>,
|
||||
|
||||
/// Information needed during parallel traversals.
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
use context::SharedStyleContext;
|
||||
use data::PrivateStyleData;
|
||||
use element_state::ElementState;
|
||||
use properties::{ComputedValuesStruct, PropertyDeclaration, PropertyDeclarationBlock};
|
||||
use properties::{ComputedValues, PropertyDeclaration, PropertyDeclarationBlock};
|
||||
use refcell::{Ref, RefMut};
|
||||
use restyle_hints::{ElementSnapshot, RESTYLE_DESCENDANTS, RESTYLE_LATER_SIBLINGS, RESTYLE_SELF, RestyleHint};
|
||||
use selector_impl::{ElementExt, SelectorImplExt};
|
||||
|
@ -46,7 +46,7 @@ impl OpaqueNode {
|
|||
}
|
||||
|
||||
pub trait TRestyleDamage : BitOr<Output=Self> + Copy {
|
||||
fn compute(old: Option<&Arc<ComputedValuesStruct>>, new: &ComputedValuesStruct) -> Self;
|
||||
fn compute(old: Option<&Arc<ComputedValues>>, new: &ComputedValues) -> Self;
|
||||
fn rebuild_and_reflow() -> Self;
|
||||
}
|
||||
|
||||
|
@ -178,7 +178,7 @@ pub trait TNode : Sized + Copy + Clone {
|
|||
/// has not yet been performed, fails.
|
||||
fn style(&self,
|
||||
_context: &SharedStyleContext<<Self::ConcreteElement as Element>::Impl>)
|
||||
-> Ref<Arc<ComputedValuesStruct>>
|
||||
-> Ref<Arc<ComputedValues>>
|
||||
where <Self::ConcreteElement as Element>::Impl: SelectorImplExt {
|
||||
Ref::map(self.borrow_data().unwrap(), |data| data.style.as_ref().unwrap())
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ use cache::{LRUCache, SimpleHashCache};
|
|||
use context::{StyleContext, SharedStyleContext};
|
||||
use data::PrivateStyleData;
|
||||
use dom::{TElement, TNode, TRestyleDamage};
|
||||
use properties::{ComputedValuesStruct, PropertyDeclaration, cascade};
|
||||
use properties::{ComputedValues, PropertyDeclaration, cascade};
|
||||
use selector_impl::{ElementExt, SelectorImplExt};
|
||||
use selector_matching::{DeclarationBlock, Stylist};
|
||||
use selectors::Element;
|
||||
|
@ -150,7 +150,7 @@ impl<'a> Hash for ApplicableDeclarationsCacheQuery<'a> {
|
|||
static APPLICABLE_DECLARATIONS_CACHE_SIZE: usize = 32;
|
||||
|
||||
pub struct ApplicableDeclarationsCache {
|
||||
cache: SimpleHashCache<ApplicableDeclarationsCacheEntry, Arc<ComputedValuesStruct>>,
|
||||
cache: SimpleHashCache<ApplicableDeclarationsCacheEntry, Arc<ComputedValues>>,
|
||||
}
|
||||
|
||||
impl ApplicableDeclarationsCache {
|
||||
|
@ -160,14 +160,14 @@ impl ApplicableDeclarationsCache {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn find(&self, declarations: &[DeclarationBlock]) -> Option<Arc<ComputedValuesStruct>> {
|
||||
pub fn find(&self, declarations: &[DeclarationBlock]) -> Option<Arc<ComputedValues>> {
|
||||
match self.cache.find(&ApplicableDeclarationsCacheQuery::new(declarations)) {
|
||||
None => None,
|
||||
Some(ref values) => Some((*values).clone()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn insert(&mut self, declarations: Vec<DeclarationBlock>, style: Arc<ComputedValuesStruct>) {
|
||||
pub fn insert(&mut self, declarations: Vec<DeclarationBlock>, style: Arc<ComputedValues>) {
|
||||
self.cache.insert(ApplicableDeclarationsCacheEntry::new(declarations), style)
|
||||
}
|
||||
|
||||
|
@ -183,8 +183,8 @@ pub struct StyleSharingCandidateCache {
|
|||
|
||||
#[derive(Clone)]
|
||||
pub struct StyleSharingCandidate {
|
||||
pub style: Arc<ComputedValuesStruct>,
|
||||
pub parent_style: Arc<ComputedValuesStruct>,
|
||||
pub style: Arc<ComputedValues>,
|
||||
pub parent_style: Arc<ComputedValues>,
|
||||
pub local_name: Atom,
|
||||
pub classes: Vec<Atom>,
|
||||
pub namespace: Namespace,
|
||||
|
@ -369,14 +369,14 @@ trait PrivateMatchMethods: TNode
|
|||
/// pseudo-elements.
|
||||
fn cascade_node_pseudo_element<'a, Ctx>(&self,
|
||||
context: &Ctx,
|
||||
parent_style: Option<&Arc<ComputedValuesStruct>>,
|
||||
parent_style: Option<&Arc<ComputedValues>>,
|
||||
applicable_declarations: &[DeclarationBlock],
|
||||
mut style: Option<&mut Arc<ComputedValuesStruct>>,
|
||||
mut style: Option<&mut Arc<ComputedValues>>,
|
||||
applicable_declarations_cache:
|
||||
&mut ApplicableDeclarationsCache,
|
||||
shareable: bool,
|
||||
animate_properties: bool)
|
||||
-> (Self::ConcreteRestyleDamage, Arc<ComputedValuesStruct>)
|
||||
-> (Self::ConcreteRestyleDamage, Arc<ComputedValues>)
|
||||
where Ctx: StyleContext<'a, <Self::ConcreteElement as Element>::Impl> {
|
||||
let mut cacheable = true;
|
||||
let shared_context = context.shared_context();
|
||||
|
@ -456,7 +456,7 @@ trait PrivateMatchMethods: TNode
|
|||
|
||||
fn update_animations_for_cascade(&self,
|
||||
context: &SharedStyleContext<<Self::ConcreteElement as Element>::Impl>,
|
||||
style: &mut Option<&mut Arc<ComputedValuesStruct>>)
|
||||
style: &mut Option<&mut Arc<ComputedValues>>)
|
||||
-> bool {
|
||||
let style = match *style {
|
||||
None => return false,
|
||||
|
@ -524,7 +524,7 @@ trait PrivateElementMatchMethods: TElement {
|
|||
fn share_style_with_candidate_if_possible(&self,
|
||||
parent_node: Option<Self::ConcreteNode>,
|
||||
candidate: &StyleSharingCandidate)
|
||||
-> Option<Arc<ComputedValuesStruct>> {
|
||||
-> Option<Arc<ComputedValues>> {
|
||||
let parent_node = match parent_node {
|
||||
Some(ref parent_node) if parent_node.as_element().is_some() => parent_node,
|
||||
Some(_) | None => return None,
|
||||
|
@ -694,7 +694,7 @@ pub trait MatchMethods : TNode {
|
|||
if self.is_text_node() {
|
||||
let mut data_ref = self.mutate_data().unwrap();
|
||||
let mut data = &mut *data_ref;
|
||||
let cloned_parent_style = ComputedValuesStruct::style_for_child_text_node(parent_style.unwrap());
|
||||
let cloned_parent_style = ComputedValues::style_for_child_text_node(parent_style.unwrap());
|
||||
damage = Self::ConcreteRestyleDamage::compute(data.style.as_ref(),
|
||||
&*cloned_parent_style);
|
||||
data.style = Some(cloned_parent_style);
|
||||
|
|
|
@ -45,7 +45,7 @@ pub mod style_structs {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct ComputedValuesStruct {
|
||||
pub struct ComputedValues {
|
||||
% for style_struct in data.style_structs:
|
||||
${style_struct.ident}: Arc<style_structs::${style_struct.name}>,
|
||||
% endfor
|
||||
|
@ -56,9 +56,9 @@ pub struct ComputedValuesStruct {
|
|||
pub root_font_size: Au,
|
||||
}
|
||||
|
||||
impl ComputedValuesStruct {
|
||||
impl ComputedValues {
|
||||
pub fn inherit_from(parent: &Arc<Self>) -> Arc<Self> {
|
||||
Arc::new(ComputedValuesStruct {
|
||||
Arc::new(ComputedValues {
|
||||
custom_properties: parent.custom_properties.clone(),
|
||||
shareable: parent.shareable,
|
||||
writing_mode: parent.writing_mode,
|
||||
|
@ -81,7 +81,7 @@ impl ComputedValuesStruct {
|
|||
${style_struct.ident}: Arc<style_structs::${style_struct.name}>,
|
||||
% endfor
|
||||
) -> Self {
|
||||
ComputedValuesStruct {
|
||||
ComputedValues {
|
||||
custom_properties: custom_properties,
|
||||
shareable: shareable,
|
||||
writing_mode: writing_mode,
|
||||
|
@ -96,7 +96,7 @@ impl ComputedValuesStruct {
|
|||
// Gecko expects text nodes to be styled as if they were elements that
|
||||
// matched no rules (that is, inherited style structs are inherited and
|
||||
// non-inherited style structs are set to their initial values).
|
||||
ComputedValuesStruct::inherit_from(parent)
|
||||
ComputedValues::inherit_from(parent)
|
||||
}
|
||||
|
||||
pub fn initial_values() -> &'static Self { &*INITIAL_GECKO_VALUES }
|
||||
|
@ -1296,7 +1296,7 @@ fn static_assert() {
|
|||
#[allow(non_snake_case, unused_variables)]
|
||||
pub extern "C" fn Servo_GetStyle${style_struct.gecko_name}(computed_values: *mut bindings::ServoComputedValues)
|
||||
-> *const ${style_struct.gecko_ffi_name} {
|
||||
type Helpers = ArcHelpers<bindings::ServoComputedValues, ComputedValuesStruct>;
|
||||
type Helpers = ArcHelpers<bindings::ServoComputedValues, ComputedValues>;
|
||||
Helpers::with(computed_values, |values| values.get_${style_struct.name_lower}().get_gecko()
|
||||
as *const ${style_struct.gecko_ffi_name})
|
||||
}
|
||||
|
@ -1312,7 +1312,7 @@ ${define_ffi_struct_accessor(style_struct)}
|
|||
% endfor
|
||||
|
||||
lazy_static! {
|
||||
pub static ref INITIAL_GECKO_VALUES: ComputedValuesStruct = ComputedValuesStruct {
|
||||
pub static ref INITIAL_GECKO_VALUES: ComputedValues = ComputedValues {
|
||||
% for style_struct in data.style_structs:
|
||||
${style_struct.ident}: style_structs::${style_struct.name}::initial(),
|
||||
% endfor
|
||||
|
|
|
@ -170,7 +170,7 @@
|
|||
use error_reporting::ParseErrorReporter;
|
||||
use properties::longhands;
|
||||
use properties::property_bit_field::PropertyBitField;
|
||||
use properties::{ComputedValuesStruct, PropertyDeclaration};
|
||||
use properties::{ComputedValues, PropertyDeclaration};
|
||||
use properties::style_structs;
|
||||
use std::boxed::Box as StdBox;
|
||||
use std::collections::HashMap;
|
||||
|
@ -181,7 +181,7 @@
|
|||
${caller.body()}
|
||||
#[allow(unused_variables)]
|
||||
pub fn cascade_property(declaration: &PropertyDeclaration,
|
||||
inherited_style: &ComputedValuesStruct,
|
||||
inherited_style: &ComputedValues,
|
||||
context: &mut computed::Context,
|
||||
seen: &mut PropertyBitField,
|
||||
cacheable: &mut bool,
|
||||
|
@ -210,7 +210,7 @@
|
|||
DeclaredValue::Initial => {
|
||||
// We assume that it's faster to use copy_*_from rather than
|
||||
// set_*(get_initial_value());
|
||||
let initial_struct = ComputedValuesStruct::initial_values()
|
||||
let initial_struct = ComputedValues::initial_values()
|
||||
.get_${data.current_style_struct.name_lower}();
|
||||
context.mutate_style().mutate_${data.current_style_struct.name_lower}()
|
||||
.copy_${property.ident}_from(initial_struct);
|
||||
|
|
|
@ -26,7 +26,7 @@ use properties::longhands::visibility::computed_value::T as Visibility;
|
|||
use properties::longhands::z_index::computed_value::T as ZIndex;
|
||||
use std::cmp;
|
||||
use std::fmt;
|
||||
use super::ComputedValuesStruct;
|
||||
use super::ComputedValues;
|
||||
use values::computed::{Angle, LengthOrPercentageOrAuto, LengthOrPercentageOrNone};
|
||||
use values::computed::{BorderRadiusSize, LengthOrNone};
|
||||
use values::computed::{CalcLengthOrPercentage, LengthOrPercentage};
|
||||
|
@ -114,7 +114,7 @@ impl AnimatedProperty {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn update(&self, style: &mut ComputedValuesStruct, progress: f64) {
|
||||
pub fn update(&self, style: &mut ComputedValues, progress: f64) {
|
||||
match *self {
|
||||
% for prop in data.longhands:
|
||||
% if prop.animatable:
|
||||
|
@ -129,8 +129,8 @@ impl AnimatedProperty {
|
|||
}
|
||||
|
||||
pub fn from_transition_property(transition_property: &TransitionProperty,
|
||||
old_style: &ComputedValuesStruct,
|
||||
new_style: &ComputedValuesStruct)
|
||||
old_style: &ComputedValues,
|
||||
new_style: &ComputedValues)
|
||||
-> AnimatedProperty {
|
||||
match *transition_property {
|
||||
TransitionProperty::All => panic!("Can't use TransitionProperty::All here."),
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
|
||||
% if product == "servo":
|
||||
fn cascade_property_custom(_declaration: &PropertyDeclaration,
|
||||
_inherited_style: &ComputedValuesStruct,
|
||||
_inherited_style: &ComputedValues,
|
||||
context: &mut computed::Context,
|
||||
_seen: &mut PropertyBitField,
|
||||
_cacheable: &mut bool,
|
||||
|
|
|
@ -109,7 +109,7 @@ ${helpers.single_keyword("unicode-bidi",
|
|||
|
||||
% if product == "servo":
|
||||
fn cascade_property_custom(_declaration: &PropertyDeclaration,
|
||||
_inherited_style: &ComputedValuesStruct,
|
||||
_inherited_style: &ComputedValues,
|
||||
context: &mut computed::Context,
|
||||
_seen: &mut PropertyBitField,
|
||||
_cacheable: &mut bool,
|
||||
|
|
|
@ -1242,14 +1242,14 @@ pub mod style_structs {
|
|||
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
pub use gecko_properties::ComputedValuesStruct;
|
||||
pub use gecko_properties::ComputedValues;
|
||||
|
||||
#[cfg(feature = "servo")]
|
||||
pub type ServoComputedValues = ComputedValuesStruct;
|
||||
pub type ServoComputedValues = ComputedValues;
|
||||
|
||||
#[cfg(feature = "servo")]
|
||||
#[cfg_attr(feature = "servo", derive(Clone, Debug, HeapSizeOf))]
|
||||
pub struct ComputedValuesStruct {
|
||||
pub struct ComputedValues {
|
||||
% for style_struct in data.active_style_structs():
|
||||
${style_struct.ident}: Arc<style_structs::${style_struct.name}>,
|
||||
% endfor
|
||||
|
@ -1260,7 +1260,7 @@ pub struct ComputedValuesStruct {
|
|||
}
|
||||
|
||||
#[cfg(feature = "servo")]
|
||||
impl ComputedValuesStruct {
|
||||
impl ComputedValues {
|
||||
pub fn new(custom_properties: Option<Arc<::custom_properties::ComputedValuesMap>>,
|
||||
shareable: bool,
|
||||
writing_mode: WritingMode,
|
||||
|
@ -1269,7 +1269,7 @@ impl ComputedValuesStruct {
|
|||
${style_struct.ident}: Arc<style_structs::${style_struct.name}>,
|
||||
% endfor
|
||||
) -> Self {
|
||||
ComputedValuesStruct {
|
||||
ComputedValues {
|
||||
custom_properties: custom_properties,
|
||||
shareable: shareable,
|
||||
writing_mode: writing_mode,
|
||||
|
@ -1562,11 +1562,11 @@ pub use self::lazy_static_module::INITIAL_SERVO_VALUES;
|
|||
mod lazy_static_module {
|
||||
use logical_geometry::WritingMode;
|
||||
use std::sync::Arc;
|
||||
use super::{ComputedValuesStruct, longhands, style_structs};
|
||||
use super::{ComputedValues, longhands, style_structs};
|
||||
|
||||
/// The initial values for all style structs as defined by the specification.
|
||||
lazy_static! {
|
||||
pub static ref INITIAL_SERVO_VALUES: ComputedValuesStruct = ComputedValuesStruct {
|
||||
pub static ref INITIAL_SERVO_VALUES: ComputedValues = ComputedValues {
|
||||
% for style_struct in data.active_style_structs():
|
||||
${style_struct.ident}: Arc::new(style_structs::${style_struct.name} {
|
||||
% for longhand in style_struct.longhands:
|
||||
|
@ -1591,16 +1591,16 @@ fn cascade_with_cached_declarations(
|
|||
viewport_size: Size2D<Au>,
|
||||
applicable_declarations: &[DeclarationBlock<Vec<PropertyDeclaration>>],
|
||||
shareable: bool,
|
||||
parent_style: &ComputedValuesStruct,
|
||||
cached_style: &ComputedValuesStruct,
|
||||
parent_style: &ComputedValues,
|
||||
cached_style: &ComputedValues,
|
||||
custom_properties: Option<Arc<::custom_properties::ComputedValuesMap>>,
|
||||
mut error_reporter: StdBox<ParseErrorReporter + Send>)
|
||||
-> ComputedValuesStruct {
|
||||
-> ComputedValues {
|
||||
let mut context = computed::Context {
|
||||
is_root_element: false,
|
||||
viewport_size: viewport_size,
|
||||
inherited_style: parent_style,
|
||||
style: ComputedValuesStruct::new(
|
||||
style: ComputedValues::new(
|
||||
custom_properties,
|
||||
shareable,
|
||||
WritingMode::empty(),
|
||||
|
@ -1693,7 +1693,7 @@ fn cascade_with_cached_declarations(
|
|||
|
||||
pub type CascadePropertyFn =
|
||||
extern "Rust" fn(declaration: &PropertyDeclaration,
|
||||
inherited_style: &ComputedValuesStruct,
|
||||
inherited_style: &ComputedValues,
|
||||
context: &mut computed::Context,
|
||||
seen: &mut PropertyBitField,
|
||||
cacheable: &mut bool,
|
||||
|
@ -1727,11 +1727,11 @@ static CASCADE_PROPERTY: [CascadePropertyFn; ${len(data.longhands)}] = [
|
|||
pub fn cascade(viewport_size: Size2D<Au>,
|
||||
applicable_declarations: &[DeclarationBlock<Vec<PropertyDeclaration>>],
|
||||
shareable: bool,
|
||||
parent_style: Option<<&ComputedValuesStruct>,
|
||||
cached_style: Option<<&ComputedValuesStruct>,
|
||||
parent_style: Option<<&ComputedValues>,
|
||||
cached_style: Option<<&ComputedValues>,
|
||||
mut error_reporter: StdBox<ParseErrorReporter + Send>)
|
||||
-> (ComputedValuesStruct, bool) {
|
||||
let initial_values = ComputedValuesStruct::initial_values();
|
||||
-> (ComputedValues, bool) {
|
||||
let initial_values = ComputedValues::initial_values();
|
||||
let (is_root_element, inherited_style) = match parent_style {
|
||||
Some(parent_style) => (false, parent_style),
|
||||
None => (true, initial_values),
|
||||
|
@ -1771,7 +1771,7 @@ pub fn cascade(viewport_size: Size2D<Au>,
|
|||
is_root_element: is_root_element,
|
||||
viewport_size: viewport_size,
|
||||
inherited_style: inherited_style,
|
||||
style: ComputedValuesStruct::new(
|
||||
style: ComputedValues::new(
|
||||
custom_properties,
|
||||
shareable,
|
||||
WritingMode::empty(),
|
||||
|
@ -1796,7 +1796,7 @@ pub fn cascade(viewport_size: Size2D<Au>,
|
|||
// We could (and used to) use a pattern match here, but that bloats this function to over 100K
|
||||
// of compiled code! To improve i-cache behavior, we outline the individual functions and use
|
||||
// virtual dispatch instead.
|
||||
ComputedValuesStruct::do_cascade_property(|cascade_property| {
|
||||
ComputedValues::do_cascade_property(|cascade_property| {
|
||||
% for category_to_cascade_now in ["early", "other"]:
|
||||
for sub_list in applicable_declarations.iter().rev() {
|
||||
// Declarations are already stored in reverse order.
|
||||
|
@ -1941,7 +1941,7 @@ pub fn cascade(viewport_size: Size2D<Au>,
|
|||
}
|
||||
|
||||
#[cfg(feature = "servo")]
|
||||
pub fn modify_style_for_anonymous_flow(style: &mut Arc<ComputedValuesStruct>,
|
||||
pub fn modify_style_for_anonymous_flow(style: &mut Arc<ComputedValues>,
|
||||
new_display_value: longhands::display::computed_value::T) {
|
||||
// The 'align-self' property needs some special treatment since
|
||||
// its value depends on the 'align-items' value of its parent.
|
||||
|
@ -1990,7 +1990,7 @@ pub fn modify_style_for_anonymous_flow(style: &mut Arc<ComputedValuesStruct>,
|
|||
/// FIXME(#5625, pcwalton): It would probably be cleaner and faster to do this in the cascade.
|
||||
#[cfg(feature = "servo")]
|
||||
#[inline]
|
||||
pub fn modify_style_for_replaced_content(style: &mut Arc<ComputedValuesStruct>) {
|
||||
pub fn modify_style_for_replaced_content(style: &mut Arc<ComputedValues>) {
|
||||
// Reset `position` to handle cases like `<div style="position: absolute">foo bar baz</div>`.
|
||||
if style.box_.display != longhands::display::computed_value::T::inline {
|
||||
let mut style = Arc::make_mut(style);
|
||||
|
@ -2027,10 +2027,10 @@ pub fn modify_style_for_replaced_content(style: &mut Arc<ComputedValuesStruct>)
|
|||
/// not outermost.
|
||||
#[cfg(feature = "servo")]
|
||||
#[inline]
|
||||
pub fn modify_border_style_for_inline_sides(style: &mut Arc<ComputedValuesStruct>,
|
||||
pub fn modify_border_style_for_inline_sides(style: &mut Arc<ComputedValues>,
|
||||
is_first_fragment_of_element: bool,
|
||||
is_last_fragment_of_element: bool) {
|
||||
fn modify_side(style: &mut Arc<ComputedValuesStruct>, side: PhysicalSide) {
|
||||
fn modify_side(style: &mut Arc<ComputedValues>, side: PhysicalSide) {
|
||||
{
|
||||
let border = &style.border;
|
||||
let current_style = match side {
|
||||
|
@ -2080,7 +2080,7 @@ pub fn modify_border_style_for_inline_sides(style: &mut Arc<ComputedValuesStruct
|
|||
#[cfg(feature = "servo")]
|
||||
#[inline]
|
||||
pub fn modify_style_for_anonymous_table_object(
|
||||
style: &mut Arc<ComputedValuesStruct>,
|
||||
style: &mut Arc<ComputedValues>,
|
||||
new_display_value: longhands::display::computed_value::T) {
|
||||
let mut style = Arc::make_mut(style);
|
||||
let box_style = Arc::make_mut(&mut style.box_);
|
||||
|
@ -2091,7 +2091,7 @@ pub fn modify_style_for_anonymous_table_object(
|
|||
/// Adjusts the `position` property as necessary for the outer fragment wrapper of an inline-block.
|
||||
#[cfg(feature = "servo")]
|
||||
#[inline]
|
||||
pub fn modify_style_for_outer_inline_block_fragment(style: &mut Arc<ComputedValuesStruct>) {
|
||||
pub fn modify_style_for_outer_inline_block_fragment(style: &mut Arc<ComputedValues>) {
|
||||
let mut style = Arc::make_mut(style);
|
||||
let box_style = Arc::make_mut(&mut style.box_);
|
||||
box_style.position = longhands::position::computed_value::T::static_
|
||||
|
@ -2103,7 +2103,7 @@ pub fn modify_style_for_outer_inline_block_fragment(style: &mut Arc<ComputedValu
|
|||
/// itself relatively positioned.
|
||||
#[cfg(feature = "servo")]
|
||||
#[inline]
|
||||
pub fn modify_style_for_text(style: &mut Arc<ComputedValuesStruct>) {
|
||||
pub fn modify_style_for_text(style: &mut Arc<ComputedValues>) {
|
||||
if style.box_.position == longhands::position::computed_value::T::relative {
|
||||
// We leave the `position` property set to `relative` so that we'll still establish a
|
||||
// containing block if needed. But we reset all position offsets to `auto`.
|
||||
|
@ -2139,7 +2139,7 @@ pub fn modify_style_for_text(style: &mut Arc<ComputedValuesStruct>) {
|
|||
/// Margins apply to the `input` element itself, so including them in the text will cause them to
|
||||
/// be double-counted.
|
||||
#[cfg(feature = "servo")]
|
||||
pub fn modify_style_for_input_text(style: &mut Arc<ComputedValuesStruct>) {
|
||||
pub fn modify_style_for_input_text(style: &mut Arc<ComputedValues>) {
|
||||
let mut style = Arc::make_mut(style);
|
||||
let margin_style = Arc::make_mut(&mut style.margin);
|
||||
margin_style.margin_top = computed::LengthOrPercentageOrAuto::Length(Au(0));
|
||||
|
@ -2155,7 +2155,7 @@ pub fn modify_style_for_input_text(style: &mut Arc<ComputedValuesStruct>) {
|
|||
/// Adjusts the `clip` property so that an inline absolute hypothetical fragment doesn't clip its
|
||||
/// children.
|
||||
#[cfg(feature = "servo")]
|
||||
pub fn modify_style_for_inline_absolute_hypothetical_fragment(style: &mut Arc<ComputedValuesStruct>) {
|
||||
pub fn modify_style_for_inline_absolute_hypothetical_fragment(style: &mut Arc<ComputedValues>) {
|
||||
if style.get_effects().clip.0.is_some() {
|
||||
let mut style = Arc::make_mut(style);
|
||||
let effects_style = Arc::make_mut(&mut style.effects);
|
||||
|
|
|
@ -9,7 +9,7 @@ use element_state::*;
|
|||
use error_reporting::StdoutErrorReporter;
|
||||
use keyframes::KeyframesAnimation;
|
||||
use media_queries::{Device, MediaType};
|
||||
use properties::{self, PropertyDeclaration, PropertyDeclarationBlock, ComputedValuesStruct};
|
||||
use properties::{self, PropertyDeclaration, PropertyDeclarationBlock, ComputedValues};
|
||||
use restyle_hints::{ElementSnapshot, RestyleHint, DependencySet};
|
||||
use selector_impl::SelectorImplExt;
|
||||
use selectors::bloom::BloomFilter;
|
||||
|
@ -231,8 +231,8 @@ impl<Impl: SelectorImplExt> Stylist<Impl> {
|
|||
/// universal rules and applying them.
|
||||
pub fn precomputed_values_for_pseudo(&self,
|
||||
pseudo: &Impl::PseudoElement,
|
||||
parent: Option<&Arc<ComputedValuesStruct>>)
|
||||
-> Option<Arc<ComputedValuesStruct>> {
|
||||
parent: Option<&Arc<ComputedValues>>)
|
||||
-> Option<Arc<ComputedValues>> {
|
||||
debug_assert!(Impl::pseudo_element_cascade_type(pseudo).is_precomputed());
|
||||
if let Some(declarations) = self.precomputed_pseudo_element_decls.get(pseudo) {
|
||||
let (computed, _) =
|
||||
|
@ -250,8 +250,8 @@ impl<Impl: SelectorImplExt> Stylist<Impl> {
|
|||
pub fn lazily_compute_pseudo_element_style<E>(&self,
|
||||
element: &E,
|
||||
pseudo: &Impl::PseudoElement,
|
||||
parent: &Arc<ComputedValuesStruct>)
|
||||
-> Option<Arc<ComputedValuesStruct>>
|
||||
parent: &Arc<ComputedValues>)
|
||||
-> Option<Arc<ComputedValues>>
|
||||
where E: Element<Impl=Impl, AttrString=Impl::AttrString> +
|
||||
PresentationalHintsSynthetizer {
|
||||
debug_assert!(Impl::pseudo_element_cascade_type(pseudo).is_lazy());
|
||||
|
|
|
@ -1657,7 +1657,7 @@ pub mod specified {
|
|||
pub mod computed {
|
||||
use app_units::Au;
|
||||
use euclid::size::Size2D;
|
||||
use properties::ComputedValuesStruct;
|
||||
use properties::ComputedValues;
|
||||
use std::fmt;
|
||||
use super::LocalToCss;
|
||||
use super::specified::AngleOrCorner;
|
||||
|
@ -1669,19 +1669,19 @@ pub mod computed {
|
|||
pub struct Context<'a> {
|
||||
pub is_root_element: bool,
|
||||
pub viewport_size: Size2D<Au>,
|
||||
pub inherited_style: &'a ComputedValuesStruct,
|
||||
pub inherited_style: &'a ComputedValues,
|
||||
|
||||
/// Values access through this need to be in the properties "computed early":
|
||||
/// color, text-decoration, font-size, display, position, float, border-*-style, outline-style
|
||||
pub style: ComputedValuesStruct,
|
||||
pub style: ComputedValues,
|
||||
}
|
||||
|
||||
impl<'a> Context<'a> {
|
||||
pub fn is_root_element(&self) -> bool { self.is_root_element }
|
||||
pub fn viewport_size(&self) -> Size2D<Au> { self.viewport_size }
|
||||
pub fn inherited_style(&self) -> &ComputedValuesStruct { &self.inherited_style }
|
||||
pub fn style(&self) -> &ComputedValuesStruct { &self.style }
|
||||
pub fn mutate_style(&mut self) -> &mut ComputedValuesStruct { &mut self.style }
|
||||
pub fn inherited_style(&self) -> &ComputedValues { &self.inherited_style }
|
||||
pub fn style(&self) -> &ComputedValues { &self.style }
|
||||
pub fn mutate_style(&mut self) -> &mut ComputedValues { &mut self.style }
|
||||
}
|
||||
|
||||
pub trait ToComputedValue {
|
||||
|
|
|
@ -13,7 +13,7 @@ use cssparser::{AtRuleParser, DeclarationListParser, DeclarationParser, Parser,
|
|||
use euclid::scale_factor::ScaleFactor;
|
||||
use euclid::size::{Size2D, TypedSize2D};
|
||||
use parser::{ParserContext, log_css_error};
|
||||
use properties::ComputedValuesStruct;
|
||||
use properties::ComputedValues;
|
||||
use std::ascii::AsciiExt;
|
||||
use std::fmt;
|
||||
use std::iter::Enumerate;
|
||||
|
@ -646,8 +646,8 @@ impl MaybeNew for ViewportConstraints {
|
|||
let context = Context {
|
||||
is_root_element: false,
|
||||
viewport_size: initial_viewport,
|
||||
inherited_style: ComputedValuesStruct::initial_values(),
|
||||
style: ComputedValuesStruct::initial_values().clone(),
|
||||
inherited_style: ComputedValues::initial_values(),
|
||||
style: ComputedValues::initial_values().clone(),
|
||||
};
|
||||
|
||||
// DEVICE-ADAPT § 9.3 Resolving 'extend-to-zoom'
|
||||
|
|
|
@ -14,7 +14,7 @@ use gecko_bindings::bindings::{ServoDeclarationBlock, ServoNodeData, ThreadSafeP
|
|||
use gecko_bindings::bindings::{ThreadSafeURIHolder, nsHTMLCSSStyleSheet};
|
||||
use gecko_bindings::ptr::{GeckoArcPrincipal, GeckoArcURI};
|
||||
use gecko_bindings::structs::{SheetParsingMode, nsIAtom};
|
||||
use properties::ComputedValuesStruct;
|
||||
use properties::ComputedValues;
|
||||
use selector_impl::{GeckoSelectorImpl, PseudoElement, SharedStyleContext, Stylesheet};
|
||||
use std::mem::transmute;
|
||||
use std::ptr;
|
||||
|
@ -87,7 +87,7 @@ fn restyle_subtree(node: GeckoNode, raw_data: *mut RawServoStyleSet) {
|
|||
// rid of the HackilyFindSomeDeviceContext stuff that happens during
|
||||
// initial_values computation, since that stuff needs to be called further
|
||||
// along in startup than the sensible place to call Servo_Initialize.
|
||||
ComputedValuesStruct::initial_values();
|
||||
ComputedValues::initial_values();
|
||||
|
||||
let _needs_dirtying = Arc::get_mut(&mut per_doc_data.stylist).unwrap()
|
||||
.update(&per_doc_data.stylesheets,
|
||||
|
@ -259,7 +259,7 @@ pub extern "C" fn Servo_GetComputedValues(node: *mut RawGeckoNode)
|
|||
// cases where Gecko wants the style for a node that Servo never
|
||||
// traversed. We should remove this as soon as possible.
|
||||
error!("stylo: encountered unstyled node, substituting default values.");
|
||||
Arc::new(ComputedValuesStruct::initial_values().clone())
|
||||
Arc::new(ComputedValues::initial_values().clone())
|
||||
},
|
||||
};
|
||||
unsafe { transmute(arc_cv) }
|
||||
|
@ -280,7 +280,7 @@ pub extern "C" fn Servo_GetComputedValuesForAnonymousBox(parent_style_or_null: *
|
|||
}
|
||||
};
|
||||
|
||||
type Helpers = ArcHelpers<ServoComputedValues, ComputedValuesStruct>;
|
||||
type Helpers = ArcHelpers<ServoComputedValues, ComputedValues>;
|
||||
|
||||
Helpers::maybe_with(parent_style_or_null, |maybe_parent| {
|
||||
let new_computed = data.stylist.precomputed_values_for_pseudo(&pseudo, maybe_parent);
|
||||
|
@ -319,7 +319,7 @@ pub extern "C" fn Servo_GetComputedValuesForPseudoElement(parent_style: *mut Ser
|
|||
|
||||
let element = unsafe { GeckoElement::from_raw(match_element) };
|
||||
|
||||
type Helpers = ArcHelpers<ServoComputedValues, ComputedValuesStruct>;
|
||||
type Helpers = ArcHelpers<ServoComputedValues, ComputedValues>;
|
||||
|
||||
match GeckoSelectorImpl::pseudo_element_cascade_type(&pseudo) {
|
||||
PseudoElementCascadeType::Eager => {
|
||||
|
@ -347,22 +347,22 @@ pub extern "C" fn Servo_GetComputedValuesForPseudoElement(parent_style: *mut Ser
|
|||
#[no_mangle]
|
||||
pub extern "C" fn Servo_InheritComputedValues(parent_style: *mut ServoComputedValues)
|
||||
-> *mut ServoComputedValues {
|
||||
type Helpers = ArcHelpers<ServoComputedValues, ComputedValuesStruct>;
|
||||
type Helpers = ArcHelpers<ServoComputedValues, ComputedValues>;
|
||||
Helpers::with(parent_style, |parent| {
|
||||
let style = ComputedValuesStruct::inherit_from(parent);
|
||||
let style = ComputedValues::inherit_from(parent);
|
||||
Helpers::from(style)
|
||||
})
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_AddRefComputedValues(ptr: *mut ServoComputedValues) -> () {
|
||||
type Helpers = ArcHelpers<ServoComputedValues, ComputedValuesStruct>;
|
||||
type Helpers = ArcHelpers<ServoComputedValues, ComputedValues>;
|
||||
unsafe { Helpers::addref(ptr) };
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn Servo_ReleaseComputedValues(ptr: *mut ServoComputedValues) -> () {
|
||||
type Helpers = ArcHelpers<ServoComputedValues, ComputedValuesStruct>;
|
||||
type Helpers = ArcHelpers<ServoComputedValues, ComputedValues>;
|
||||
unsafe { Helpers::release(ptr) };
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ use gecko_bindings::structs::nsIAtom;
|
|||
use gecko_bindings::structs::{NODE_HAS_DIRTY_DESCENDANTS_FOR_SERVO, NODE_IS_DIRTY_FOR_SERVO};
|
||||
use glue::GeckoDeclarationBlock;
|
||||
use libc::uintptr_t;
|
||||
use properties::ComputedValuesStruct;
|
||||
use properties::ComputedValues;
|
||||
use selector_impl::{GeckoSelectorImpl, NonTSPseudoClass, PrivateStyleData};
|
||||
use selectors::Element;
|
||||
use selectors::matching::DeclarationBlock;
|
||||
|
@ -99,7 +99,7 @@ impl<'ln> GeckoNode<'ln> {
|
|||
#[derive(Clone, Copy)]
|
||||
pub struct DummyRestyleDamage;
|
||||
impl TRestyleDamage for DummyRestyleDamage {
|
||||
fn compute(_: Option<&Arc<ComputedValuesStruct>>, _: &ComputedValuesStruct) -> Self { DummyRestyleDamage }
|
||||
fn compute(_: Option<&Arc<ComputedValues>>, _: &ComputedValues) -> Self { DummyRestyleDamage }
|
||||
fn rebuild_and_reflow() -> Self { DummyRestyleDamage }
|
||||
}
|
||||
impl BitOr for DummyRestyleDamage {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue